Message ID | 20220621074919.2636622-2-liuhangbin@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | f2b3b28ce5237a4995a17d6f6aac9e05243d7a0b |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | Bonding: add per-port priority support | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Clearly marked for net-next |
netdev/fixes_present | success | Fixes tag not required for -next series |
netdev/subject_prefix | success | Link |
netdev/cover_letter | success | Series has a cover letter |
netdev/patch_count | success | Link |
netdev/header_inline | success | No static functions without inline keyword in header files |
netdev/build_32bit | success | Errors and warnings before: 11 this patch: 11 |
netdev/cc_maintainers | warning | 1 maintainers not CCed: edumazet@google.com |
netdev/build_clang | success | Errors and warnings before: 3 this patch: 3 |
netdev/module_param | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Signed-off-by tag matches author and committer |
netdev/check_selftest | success | No net selftest shell script |
netdev/verify_fixes | success | No Fixes tag |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 11 this patch: 11 |
netdev/checkpatch | warning | WARNING: line length of 84 exceeds 80 columns |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/source_inline | success | Was 0 now: 0 |
On 6/21/22 03:49, Hangbin Liu wrote: > 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: Jonathan Toppins <jtoppins@redhat.com> > Signed-off-by: Hangbin Liu <liuhangbin@gmail.com> Acked-by: Jonathan Toppins <jtoppins@redhat.com>
diff --git a/include/net/bond_options.h b/include/net/bond_options.h index 1618b76f4903..eade8236a4df 100644 --- a/include/net/bond_options.h +++ b/include/net/bond_options.h @@ -83,7 +83,10 @@ struct bond_opt_value { char *string; u64 value; u32 flags; - char extra[BOND_OPT_EXTRA_MAXLEN]; + union { + char extra[BOND_OPT_EXTRA_MAXLEN]; + struct net_device *slave_dev; + }; }; struct bonding; @@ -133,13 +136,16 @@ static inline void __bond_opt_init(struct bond_opt_value *optval, optval->value = value; else if (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); } #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_initextra(optval, 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); #if IS_ENABLED(CONFIG_IPV6)
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: Jonathan Toppins <jtoppins@redhat.com> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com> --- include/net/bond_options.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)