Skip to content

Commit 4598380

Browse files
liuhangbindavem330
authored andcommitted
bonding: fix ns validation on backup slaves
When arp_validate is set to 2, 3, or 6, validation is performed for backup slaves as well. As stated in the bond documentation, validation involves checking the broadcast ARP request sent out via the active slave. This helps determine which slaves are more likely to function in the event of an active slave failure. However, when the target is an IPv6 address, the NS message sent from the active interface is not checked on backup slaves. Additionally, based on the bond_arp_rcv() rule b, we must reverse the saddr and daddr when checking the NS message. Note that when checking the NS message, the destination address is a multicast address. Therefore, we must convert the target address to solicited multicast in the bond_get_targets_ip6() function. Prior to the fix, the backup slaves had a mii status of "down", but after the fix, all of the slaves' mii status was updated to "UP". Fixes: 4e24be0 ("bonding: add new parameter ns_targets") Reviewed-by: Jonathan Toppins <[email protected]> Acked-by: Jay Vosburgh <[email protected]> Signed-off-by: Hangbin Liu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent dc5110c commit 4598380

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

drivers/net/bonding/bond_main.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3269,7 +3269,8 @@ static int bond_na_rcv(const struct sk_buff *skb, struct bonding *bond,
32693269

32703270
combined = skb_header_pointer(skb, 0, sizeof(_combined), &_combined);
32713271
if (!combined || combined->ip6.nexthdr != NEXTHDR_ICMP ||
3272-
combined->icmp6.icmp6_type != NDISC_NEIGHBOUR_ADVERTISEMENT)
3272+
(combined->icmp6.icmp6_type != NDISC_NEIGHBOUR_SOLICITATION &&
3273+
combined->icmp6.icmp6_type != NDISC_NEIGHBOUR_ADVERTISEMENT))
32733274
goto out;
32743275

32753276
saddr = &combined->ip6.saddr;
@@ -3291,7 +3292,7 @@ static int bond_na_rcv(const struct sk_buff *skb, struct bonding *bond,
32913292
else if (curr_active_slave &&
32923293
time_after(slave_last_rx(bond, curr_active_slave),
32933294
curr_active_slave->last_link_up))
3294-
bond_validate_na(bond, slave, saddr, daddr);
3295+
bond_validate_na(bond, slave, daddr, saddr);
32953296
else if (curr_arp_slave &&
32963297
bond_time_in_interval(bond, slave_last_tx(curr_arp_slave), 1))
32973298
bond_validate_na(bond, slave, saddr, daddr);

include/net/bonding.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -761,13 +761,17 @@ static inline int bond_get_targets_ip(__be32 *targets, __be32 ip)
761761
#if IS_ENABLED(CONFIG_IPV6)
762762
static inline int bond_get_targets_ip6(struct in6_addr *targets, struct in6_addr *ip)
763763
{
764+
struct in6_addr mcaddr;
764765
int i;
765766

766-
for (i = 0; i < BOND_MAX_NS_TARGETS; i++)
767-
if (ipv6_addr_equal(&targets[i], ip))
767+
for (i = 0; i < BOND_MAX_NS_TARGETS; i++) {
768+
addrconf_addr_solict_mult(&targets[i], &mcaddr);
769+
if ((ipv6_addr_equal(&targets[i], ip)) ||
770+
(ipv6_addr_equal(&mcaddr, ip)))
768771
return i;
769772
else if (ipv6_addr_any(&targets[i]))
770773
break;
774+
}
771775

772776
return -1;
773777
}

0 commit comments

Comments
 (0)