[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d6924ce2-29e0-5604-8c79-88209f5ae295@6wind.com>
Date: Tue, 7 Dec 2021 09:27:02 +0100
From: Nicolas Dichtel <nicolas.dichtel@...nd.com>
To: David Ahern <dsahern@...il.com>,
Lahav Schlesinger <lschlesinger@...venets.com>,
netdev@...r.kernel.org
Cc: kuba@...nel.org, nikolay@...dia.com
Subject: Re: [PATCH net-next v5] rtnetlink: Support fine-grained netdevice
bulk deletion
Le 06/12/2021 à 16:20, David Ahern a écrit :
> On 12/6/21 1:25 AM, Nicolas Dichtel wrote:
>>> @@ -3050,6 +3052,78 @@ static int rtnl_group_dellink(const struct net *net, int group)
>>> return 0;
>>> }
>>>
>>> +static int dev_ifindex_cmp(const void *a, const void *b)
>>> +{
>>> + struct net_device * const *dev1 = a, * const *dev2 = b;
>>> +
>>> + return (*dev1)->ifindex - (*dev2)->ifindex;
>>> +}
>>> +
>>> +static int rtnl_ifindex_dellink(struct net *net, struct nlattr *head, int len,
>>> + struct netlink_ext_ack *extack)
>>> +{
>>> + int i = 0, num_devices = 0, rem;
>>> + struct net_device **dev_list;
>>> + const struct nlattr *nla;
>>> + LIST_HEAD(list_kill);
>>> + int ret;
>>> +
>>> + nla_for_each_attr(nla, head, len, rem) {
>>> + if (nla_type(nla) == IFLA_IFINDEX)
>>> + num_devices++;
>>> + }
>>> +
>>> + dev_list = kmalloc_array(num_devices, sizeof(*dev_list), GFP_KERNEL);
>>> + if (!dev_list)
>>> + return -ENOMEM;
>>> +
>>> + nla_for_each_attr(nla, head, len, rem) {
>>> + const struct rtnl_link_ops *ops;
>>> + struct net_device *dev;
>>> + int ifindex;
>>> +
>>> + if (nla_type(nla) != IFLA_IFINDEX)
>>> + continue;
>>> +
>>> + ifindex = nla_get_s32(nla);
>>> + ret = -ENODEV;
>>> + dev = __dev_get_by_index(net, ifindex);
>>> + if (!dev) {
>>> + NL_SET_ERR_MSG_ATTR(extack, nla, "Unknown ifindex");
>> It would be nice to have the ifindex in the error message. This message does not
>> give more information than "ENODEV".
>
> extack infra does not allow dynamic messages. It does point to the
> location of the bad index, so userspace could figure it out.
Oh yes, my bad.
Thank you,
Nicolas
Powered by blists - more mailing lists