Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

bonding: guard ns_targets by CONFIG_IPV6

Guard ns_targets in struct bond_params by CONFIG_IPV6, which could save
256 bytes if IPv6 not configed. Also add this protection for function
bond_is_ip6_target_ok() and bond_get_targets_ip6().

Remove the IS_ENABLED() check for bond_opts[] as this will make
BOND_OPT_NS_TARGETS uninitialized if CONFIG_IPV6 not enabled. Add
a dummy bond_option_ns_ip6_targets_set() for this situation.

Fixes: 4e24be018eb9 ("bonding: add new parameter ns_targets")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Acked-by: Jonathan Toppins <jtoppins@redhat.com>
Link: https://lore.kernel.org/r/20220531063727.224043-1-liuhangbin@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Hangbin Liu and committed by
Paolo Abeni
c4caa500 0a375c82

+14 -4
+2
drivers/net/bonding/bond_main.c
··· 6159 6159 strscpy_pad(params->primary, primary, sizeof(params->primary)); 6160 6160 6161 6161 memcpy(params->arp_targets, arp_target, sizeof(arp_target)); 6162 + #if IS_ENABLED(CONFIG_IPV6) 6162 6163 memset(params->ns_targets, 0, sizeof(struct in6_addr) * BOND_MAX_NS_TARGETS); 6164 + #endif 6163 6165 6164 6166 return 0; 6165 6167 }
+6 -4
drivers/net/bonding/bond_options.c
··· 34 34 static int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target); 35 35 static int bond_option_arp_ip_targets_set(struct bonding *bond, 36 36 const struct bond_opt_value *newval); 37 - #if IS_ENABLED(CONFIG_IPV6) 38 37 static int bond_option_ns_ip6_targets_set(struct bonding *bond, 39 38 const struct bond_opt_value *newval); 40 - #endif 41 39 static int bond_option_arp_validate_set(struct bonding *bond, 42 40 const struct bond_opt_value *newval); 43 41 static int bond_option_arp_all_targets_set(struct bonding *bond, ··· 297 299 .flags = BOND_OPTFLAG_RAWVAL, 298 300 .set = bond_option_arp_ip_targets_set 299 301 }, 300 - #if IS_ENABLED(CONFIG_IPV6) 301 302 [BOND_OPT_NS_TARGETS] = { 302 303 .id = BOND_OPT_NS_TARGETS, 303 304 .name = "ns_ip6_target", ··· 304 307 .flags = BOND_OPTFLAG_RAWVAL, 305 308 .set = bond_option_ns_ip6_targets_set 306 309 }, 307 - #endif 308 310 [BOND_OPT_DOWNDELAY] = { 309 311 .id = BOND_OPT_DOWNDELAY, 310 312 .name = "downdelay", ··· 1249 1253 _bond_options_ns_ip6_target_set(bond, index, target, jiffies); 1250 1254 1251 1255 return 0; 1256 + } 1257 + #else 1258 + static int bond_option_ns_ip6_targets_set(struct bonding *bond, 1259 + const struct bond_opt_value *newval) 1260 + { 1261 + return -EPERM; 1252 1262 } 1253 1263 #endif 1254 1264
+6
include/net/bonding.h
··· 149 149 struct reciprocal_value reciprocal_packets_per_slave; 150 150 u16 ad_actor_sys_prio; 151 151 u16 ad_user_port_key; 152 + #if IS_ENABLED(CONFIG_IPV6) 152 153 struct in6_addr ns_targets[BOND_MAX_NS_TARGETS]; 154 + #endif 153 155 154 156 /* 2 bytes of padding : see ether_addr_equal_64bits() */ 155 157 u8 ad_actor_system[ETH_ALEN + 2]; ··· 505 503 return !ipv4_is_lbcast(addr) && !ipv4_is_zeronet(addr); 506 504 } 507 505 506 + #if IS_ENABLED(CONFIG_IPV6) 508 507 static inline int bond_is_ip6_target_ok(struct in6_addr *addr) 509 508 { 510 509 return !ipv6_addr_any(addr) && 511 510 !ipv6_addr_loopback(addr) && 512 511 !ipv6_addr_is_multicast(addr); 513 512 } 513 + #endif 514 514 515 515 /* Get the oldest arp which we've received on this slave for bond's 516 516 * arp_targets. ··· 750 746 return -1; 751 747 } 752 748 749 + #if IS_ENABLED(CONFIG_IPV6) 753 750 static inline int bond_get_targets_ip6(struct in6_addr *targets, struct in6_addr *ip) 754 751 { 755 752 int i; ··· 763 758 764 759 return -1; 765 760 } 761 + #endif 766 762 767 763 /* exported from bond_main.c */ 768 764 extern unsigned int bond_net_id;