public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Nikolay Aleksandrov <nikolay@redhat•com>
To: Andy Gospodarek <gospo@cumulusnetworks•com>,
	Jonathan Toppins <jtoppins@cumulusnetworks•com>
Cc: netdev@vger•kernel.org, shm@cumulusnetworks•com
Subject: Re: [PATCH] bonding: cleanup bond_opts array
Date: Mon, 12 Jan 2015 12:05:30 +0100	[thread overview]
Message-ID: <54B3AA7A.2010606@redhat.com> (raw)
In-Reply-To: <20150109184821.GC56806@gospo.home.greyhouse.net>

On 09/01/15 19:48, Andy Gospodarek wrote:
> On Fri, Jan 09, 2015 at 01:31:08PM -0500, Jonathan Toppins wrote:
>> Remove the empty array element initializer and size the array with
>> BOND_OPT_LAST so the compiler will complain if more elements are in
>> there than should be.
>>
>> An interesting unwanted side effect of this initializer is that if one
>> inserts new options into the middle of the array then this initializer
>> will zero out the option that equals BOND_OPT_TLB_DYNAMIC_LB+1.
>>
>> Example:
>> Extend the OPTS enum:
>> enum {
>>    ...
>>    BOND_OPT_TLB_DYNAMIC_LB,
>>    BOND_OPT_LACP_NEW1,
>>    BOND_OPT_LAST
>> };
>>
>> Now insert into bond_opts array:
>> static const struct bond_option bond_opts[] = {
>>       ...
>>       [BOND_OPT_LACP_RATE] = { .... unchanged stuff .... },
>>       [BOND_OPT_LACP_NEW1] = { ... new stuff ... },
>>       ...
>>       [BOND_OPT_TLB_DYNAMIC_LB] = { .... unchanged stuff ....},
>>       { } // MARK A
>> };
>>
>> Since BOND_OPT_LACP_NEW1 = BOND_OPT_TLB_DYNAMIC_LB+1, the last
>> initializer (MARK A) will overwrite the contents of BOND_OPT_LACP_NEW1
>> and can be easily viewed with the crash utility.
>>
>> Signed-off-by: Jonathan Toppins <jtoppins@cumulusnetworks•com>
>> Cc: Andy Gospodarek <gospo@cumulusnetworks•com>
>> Cc: Nikolay Aleksandrov <nikolay@redhat•com>
> 
> I do not recall if there was a specific reason that Nik added this, so
> presuming there was not....
> 
> Signed-off-by: Andy Gospodarek <gospo@cumulusnetworks•com>
> 
Indeed, it's an oversight on my part from a previous version of the opts
patch-set which used a different end-of-array indicator :-)


Acked-by: Nikolay Aleksandrov <nikolay@redhat•com>

  reply	other threads:[~2015-01-12 11:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-09 18:31 [PATCH] bonding: cleanup bond_opts array Jonathan Toppins
2015-01-09 18:48 ` Andy Gospodarek
2015-01-12 11:05   ` Nikolay Aleksandrov [this message]
2015-01-12 21:43 ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54B3AA7A.2010606@redhat.com \
    --to=nikolay@redhat$(echo .)com \
    --cc=gospo@cumulusnetworks$(echo .)com \
    --cc=jtoppins@cumulusnetworks$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=shm@cumulusnetworks$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox