Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1261667

Re: [PATCH v2 net-next] net/core: generic support for disabling netdev features down stack

From Jarod Wilson <jarod@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH v2 net-next] net/core: generic support for disabling netdev features down stack
Date 2015-11-03 17:10 +0100
Message-ID <qqMjM-53W-9@gated-at.bofh.it> (permalink)
References (1 earlier) <qqzZg-56X-3@gated-at.bofh.it> <qqGHp-1jJ-23@gated-at.bofh.it> <qqKhX-3qa-7@gated-at.bofh.it> <qqKhY-3qa-9@gated-at.bofh.it> <qqKrF-3Jf-25@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Nikolay Aleksandrov wrote:
> On 11/03/2015 02:57 PM, Jarod Wilson wrote:
>> Geert Uytterhoeven wrote:
>>> On Tue, Nov 3, 2015 at 11:03 AM, Nikolay Aleksandrov
>>> <nikolay@cumulusnetworks.com>   wrote:
>>>> On 11/03/2015 03:55 AM, Jarod Wilson wrote:
>>>> [snip]
>>>>> +#define for_each_netdev_feature(mask_addr, feature)                          \
>>>>> +     int bit;                                                                \
>>>>> +     for_each_set_bit(bit, (unsigned long *)mask_addr, NETDEV_FEATURE_COUNT) \
>>>>> +             feature = __NETIF_F_BIT(bit);
>>>>> +
>>>> ^
>>>> This is broken, it will not work for more than a single feature.
>>> Indeed it is.
>>>
>>> This is used as:
>>>
>>>           for_each_netdev_feature(&upper_disables, feature) {
>>>           ...
>>>           }
>>>
>>> which expands to:
>>>
>>>           int bit;
>>>           for_each_set_bit(bit, (unsigned long *)mask_addr, NETDEV_FEATURE_COUNT)
>>>                   feature = __NETIF_F_BIT(bit);
>>>           {
>>>                   ...
>>>           }
>>>
>>> Note the assignment to "feature" happens outside the {}-delimited block.
>>> And the block is always executed once.
>> Bah, crap, I was still staring at the code not seeing it, thank you for the detailed cluebat. I'll fix that up right now.
>>
>
> Yeah, sorry for not elaborating, I wrote it in a hurry. :-)
> Thanks Geert!
>
> By the way since you'll be changing this code, I don't know if it's okay to
> declare caller-visible hidden local variables in a macro like this, at the very
> least please consider renaming it to something that's much less common, I can see
> "bit" being used here and there. IMO either try to find a way to avoid it
> altogether or add another argument to the macro so it's explicitly passed.

Just posted a follow-up that removes the macro-internal use of bit and 
doesn't botch up assigning feature. It's not as pretty, but it works 
correctly with multiple feature bits.

-- 
Jarod Wilson
jarod@redhat.com


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH net-next] net/core: generic support for disabling netdev features down stack Jarod Wilson <jarod@redhat.com> - 2015-11-02 19:00 +0100
  Re: [PATCH net-next] net/core: generic support for disabling netdev  features down stack Alexander Duyck <alexander.duyck@gmail.com> - 2015-11-02 19:10 +0100
    Re: [PATCH net-next] net/core: generic support for disabling netdev  features down stack Jarod Wilson <jarod@redhat.com> - 2015-11-02 23:00 +0100
  [PATCH v2 net-next] net/core: generic support for disabling netdev features down stack Jarod Wilson <jarod@redhat.com> - 2015-11-03 04:00 +0100
    Re: [PATCH v2 net-next] net/core: generic support for disabling  netdev features down stack David Miller <davem@davemloft.net> - 2015-11-03 05:50 +0100
    Re: [PATCH v2 net-next] net/core: generic support for disabling  netdev features down stack Nikolay Aleksandrov <nikolay@cumulusnetworks.com> - 2015-11-03 11:10 +0100
      Re: [PATCH v2 net-next] net/core: generic support for disabling  netdev features down stack Geert Uytterhoeven <geert@linux-m68k.org> - 2015-11-03 15:00 +0100
        Re: [PATCH v2 net-next] net/core: generic support for disabling netdev  features down stack Jarod Wilson <jarod@redhat.com> - 2015-11-03 15:00 +0100
          Re: [PATCH v2 net-next] net/core: generic support for disabling  netdev features down stack Nikolay Aleksandrov <nikolay@cumulusnetworks.com> - 2015-11-03 15:10 +0100
            Re: [PATCH v2 net-next] net/core: generic support for disabling netdev  features down stack Jarod Wilson <jarod@redhat.com> - 2015-11-03 17:10 +0100
    [PATCH net-next] net/core: fix for_each_netdev_feature Jarod Wilson <jarod@redhat.com> - 2015-11-03 16:20 +0100
      Re: [PATCH net-next] net/core: fix for_each_netdev_feature Nikolay Aleksandrov <nikolay@cumulusnetworks.com> - 2015-11-03 16:50 +0100
      Re: [PATCH net-next] net/core: fix for_each_netdev_feature David Miller <davem@davemloft.net> - 2015-11-03 17:40 +0100
    [PATCH net-next] net/core: ensure features get disabled on new lower devs Jarod Wilson <jarod@redhat.com> - 2015-11-03 21:40 +0100
      Re: [PATCH net-next] net/core: ensure features get disabled on new  lower devs Alexander Duyck <alexander.duyck@gmail.com> - 2015-11-03 22:20 +0100
        Re: [PATCH net-next] net/core: ensure features get disabled on new  lower devs Jarod Wilson <jarod@redhat.com> - 2015-11-03 23:20 +0100
          Re: [PATCH net-next] net/core: ensure features get disabled on new  lower devs Alexander Duyck <alexander.duyck@gmail.com> - 2015-11-04 00:10 +0100
      Re: [PATCH net-next] net/core: ensure features get disabled on new  lower devs Nikolay Aleksandrov <nikolay@cumulusnetworks.com> - 2015-11-03 22:30 +0100
      Re: [PATCH net-next] net/core: ensure features get disabled on new  lower devs Michal Kubecek <mkubecek@suse.cz> - 2015-11-03 23:00 +0100
        Re: [PATCH net-next] net/core: ensure features get disabled on new  lower devs Jarod Wilson <jarod@redhat.com> - 2015-11-03 23:00 +0100
      [PATCH v2 net-next] net/core: ensure features get disabled on new lower devs Jarod Wilson <jarod@redhat.com> - 2015-11-04 05:10 +0100
        Re: [PATCH v2 net-next] net/core: ensure features get disabled on  new lower devs David Miller <davem@davemloft.net> - 2015-11-05 04:00 +0100
          Re: [PATCH v2 net-next] net/core: ensure features get disabled on  new lower devs Florian Fainelli <f.fainelli@gmail.com> - 2015-11-13 01:30 +0100
            Re: [PATCH v2 net-next] net/core: ensure features get disabled on  new lower devs Jiri Pirko <jiri@resnulli.us> - 2015-11-13 11:30 +0100
              Re: [PATCH v2 net-next] net/core: ensure features get disabled on new  lower devs Nikolay Aleksandrov <nikolay@cumulusnetworks.com> - 2015-11-13 12:00 +0100
                Re: [PATCH v2 net-next] net/core: ensure features get disabled on new  lower devs Laura Abbott <labbott@redhat.com> - 2015-11-13 23:40 +0100

csiph-web