[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <98c6884c-642b-66d3-10ad-a8f0afebf446@gmail.com>
Date: Mon, 6 Dec 2021 08:20:10 -0700
From: David Ahern <dsahern@...il.com>
To: nicolas.dichtel@...nd.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
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.
>
>> + goto out_free;
>> + }
>> +
>> + ret = -EOPNOTSUPP;
>> + ops = dev->rtnl_link_ops;
>> + if (!ops || !ops->dellink) {
>> + NL_SET_ERR_MSG_ATTR(extack, nla, "Device cannot be deleted");
> Same here.
>
>
> Thank you,
> Nicolas
>
Powered by blists - more mailing lists