Commit f2b3b28c authored by Hangbin Liu's avatar Hangbin Liu Committed by David S. Miller

bonding: add slave_dev field for bond_opt_value

Currently, bond_opt_value are mostly used for bonding option settings. If
we want to set a value for slave, we need to re-alloc a string to store
both slave name and vlaue, like bond_option_queue_id_set() does, which
is complex and dumb.

As Jon suggested, let's add a union field slave_dev for bond_opt_value,
which will be benefit for future slave option setting. In function
__bond_opt_init(), we will always check the extra field and set it
if it's not NULL.
Suggested-by: default avatarJonathan Toppins <jtoppins@redhat.com>
Signed-off-by: default avatarHangbin Liu <liuhangbin@gmail.com>
Acked-by: default avatarJonathan Toppins <jtoppins@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7747de17
...@@ -83,7 +83,10 @@ struct bond_opt_value { ...@@ -83,7 +83,10 @@ struct bond_opt_value {
char *string; char *string;
u64 value; u64 value;
u32 flags; u32 flags;
union {
char extra[BOND_OPT_EXTRA_MAXLEN]; char extra[BOND_OPT_EXTRA_MAXLEN];
struct net_device *slave_dev;
};
}; };
struct bonding; struct bonding;
...@@ -133,13 +136,16 @@ static inline void __bond_opt_init(struct bond_opt_value *optval, ...@@ -133,13 +136,16 @@ static inline void __bond_opt_init(struct bond_opt_value *optval,
optval->value = value; optval->value = value;
else if (string) else if (string)
optval->string = string; optval->string = string;
else if (extra_len <= BOND_OPT_EXTRA_MAXLEN)
if (extra && extra_len <= BOND_OPT_EXTRA_MAXLEN)
memcpy(optval->extra, extra, extra_len); memcpy(optval->extra, extra, extra_len);
} }
#define bond_opt_initval(optval, value) __bond_opt_init(optval, NULL, value, NULL, 0) #define bond_opt_initval(optval, value) __bond_opt_init(optval, NULL, value, NULL, 0)
#define bond_opt_initstr(optval, str) __bond_opt_init(optval, str, ULLONG_MAX, NULL, 0) #define bond_opt_initstr(optval, str) __bond_opt_init(optval, str, ULLONG_MAX, NULL, 0)
#define bond_opt_initextra(optval, extra, extra_len) \ #define bond_opt_initextra(optval, extra, extra_len) \
__bond_opt_init(optval, NULL, ULLONG_MAX, extra, extra_len) __bond_opt_init(optval, NULL, ULLONG_MAX, extra, extra_len)
#define bond_opt_slave_initval(optval, slave_dev, value) \
__bond_opt_init(optval, NULL, value, slave_dev, sizeof(struct net_device *))
void bond_option_arp_ip_targets_clear(struct bonding *bond); void bond_option_arp_ip_targets_clear(struct bonding *bond);
#if IS_ENABLED(CONFIG_IPV6) #if IS_ENABLED(CONFIG_IPV6)
......
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