lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y2JS4bBhPB1qbDi9@nanopsycho>
Date:   Wed, 2 Nov 2022 12:22:09 +0100
From:   Jiri Pirko <jiri@...nulli.us>
To:     Jakub Kicinski <kuba@...nel.org>
Cc:     netdev@...r.kernel.org, davem@...emloft.net, pabeni@...hat.com,
        edumazet@...gle.com, tariqt@...dia.com, moshe@...dia.com,
        saeedm@...dia.com, linux-rdma@...r.kernel.org
Subject: Re: [patch net-next v3 13/13] net: expose devlink port over rtnetlink

Tue, Nov 01, 2022 at 05:18:34PM CET, kuba@...nel.org wrote:
>On Mon, 31 Oct 2022 13:42:48 +0100 Jiri Pirko wrote:
>> From: Jiri Pirko <jiri@...dia.com>
>> 
>> Expose devlink port handle related to netdev over rtnetlink. Introduce a
>> new nested IFLA attribute to carry the info. Call into devlink code to
>> fill-up the nest with existing devlink attributes that are used over
>> devlink netlink.
>
>> +int devlink_nl_port_handle_fill(struct sk_buff *msg, struct devlink_port *devlink_port)
>> +{
>> +	if (devlink_nl_put_handle(msg, devlink_port->devlink))
>> +		return -EMSGSIZE;
>> +	if (nla_put_u32(msg, DEVLINK_ATTR_PORT_INDEX, devlink_port->index))
>> +		return -EMSGSIZE;
>> +	return 0;
>> +}
>> +EXPORT_SYMBOL_GPL(devlink_nl_port_handle_fill);
>> +
>> +size_t devlink_nl_port_handle_size(struct devlink_port *devlink_port)
>> +{
>> +	struct devlink *devlink = devlink_port->devlink;
>> +
>> +	return nla_total_size(strlen(devlink->dev->bus->name) + 1) /* DEVLINK_ATTR_BUS_NAME */
>> +	     + nla_total_size(strlen(dev_name(devlink->dev)) + 1) /* DEVLINK_ATTR_DEV_NAME */
>> +	     + nla_total_size(4); /* DEVLINK_ATTR_PORT_INDEX */
>> +}
>> +EXPORT_SYMBOL_GPL(devlink_nl_port_handle_size);
>
>Why the exports? devlink is a boolean now IIRC.

Right, removed.


>
>> +static int rtnl_fill_devlink_port(struct sk_buff *skb,
>> +				  const struct net_device *dev)
>> +{
>> +	struct nlattr *devlink_port_nest;
>> +	int ret;
>> +
>> +	devlink_port_nest = nla_nest_start(skb, IFLA_DEVLINK_PORT);
>> +	if (!devlink_port_nest)
>> +		return -EMSGSIZE;
>> +
>> +	if (dev->devlink_port) {
>
>Why produce the empty nest if port is not set?

Empty nest indicates that kernel supports this but there is no devlink
port associated. I see no other way to indicate this :/


>
>> +		ret = devlink_nl_port_handle_fill(skb, dev->devlink_port);
>> +		if (ret < 0)
>> +			goto nest_cancel;
>> +	}
>> +
>> +	nla_nest_end(skb, devlink_port_nest);
>> +	return 0;
>> +
>> +nest_cancel:
>> +	nla_nest_cancel(skb, devlink_port_nest);
>> +	return ret;
>> +}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ