[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221101091834.4dbdcbc1@kernel.org>
Date: Tue, 1 Nov 2022 09:18:34 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Jiri Pirko <jiri@...nulli.us>
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
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.
> +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?
> + 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