Commit 7bfa0145 authored by Jonathan Toppins's avatar Jonathan Toppins Committed by David S. Miller

bonding: cleanup bond_opts array

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: default avatarJonathan Toppins <jtoppins@cumulusnetworks.com>
Cc: Andy Gospodarek <gospo@cumulusnetworks.com>
Cc: Nikolay Aleksandrov <nikolay@redhat.com>
Signed-off-by: default avatarAndy Gospodarek <gospo@cumulusnetworks.com>
Acked-by: default avatarNikolay Aleksandrov <nikolay@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d9fbfb94
...@@ -186,7 +186,7 @@ static const struct bond_opt_value bond_tlb_dynamic_lb_tbl[] = { ...@@ -186,7 +186,7 @@ static const struct bond_opt_value bond_tlb_dynamic_lb_tbl[] = {
{ NULL, -1, 0} { NULL, -1, 0}
}; };
static const struct bond_option bond_opts[] = { static const struct bond_option bond_opts[BOND_OPT_LAST] = {
[BOND_OPT_MODE] = { [BOND_OPT_MODE] = {
.id = BOND_OPT_MODE, .id = BOND_OPT_MODE,
.name = "mode", .name = "mode",
...@@ -379,8 +379,7 @@ static const struct bond_option bond_opts[] = { ...@@ -379,8 +379,7 @@ static const struct bond_option bond_opts[] = {
.values = bond_tlb_dynamic_lb_tbl, .values = bond_tlb_dynamic_lb_tbl,
.flags = BOND_OPTFLAG_IFDOWN, .flags = BOND_OPTFLAG_IFDOWN,
.set = bond_option_tlb_dynamic_lb_set, .set = bond_option_tlb_dynamic_lb_set,
}, }
{ }
}; };
/* Searches for an option by name */ /* Searches for an option by name */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment