Skip to contentSkip to conversation

bonding: fix ns targets not work on hardware NIC

PATCH Superseded Hangbin Liu 2 participants 7 messages Nov 6, 2024 – Nov 12, 2024

Subsystems (4)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover bonding: fix ns targets not work on hardware NIC

The first patch fixed ns targets not work on hardware NIC when bonding set arp_validate.

The second patch add a related selftest for bonding.

v3: use ndisc_mc_map to convert the mcast mac address (Jay Vosburgh)
v2: only add/del mcast group on backup slaves when arp_validate is set (Jay Vosburgh)
arp_validate doesn't support 3ad, tlb, alb. So let's only do it on ab mode.

Hangbin Liu (2):
bonding: add ns target multicast address to slave device
selftests: bonding: add ns multicast group testing

 drivers/net/bonding/bond_main.c               | 18 +++-
 drivers/net/bonding/bond_options.c            | 85 ++++++++++++++++++-
 include/net/bond_options.h                    |  1 +
 .../drivers/net/bonding/bond_options.sh       | 54 +++++++++++-
 4 files changed, 155 insertions(+), 3 deletions(-)
Signature · 1 line
2.46.0
#1 lore raw

PATCH v3 1/2 bonding: add ns target multicast address to slave device

Commit 4598380f9c54 ("bonding: fix ns validation on backup slaves") tried to resolve the issue where backup slaves couldn't be brought up when receiving IPv6 Neighbor Solicitation (NS) messages. However, this fix only worked for drivers that receive all multicast messages, such as the veth interface.

For standard drivers, the NS multicast message is silently dropped because the slave device is not a member of the NS target multicast group.

To address this, we need to make the slave device join the NS target multicast group, ensuring it can receive these IPv6 NS messages to validate the slave’s status properly.

There are three policies before joining the multicast group:
1. All settings must be under active-backup mode (alb and tlb do not support arp_validate), with backup slaves and slaves supporting multicast.
2. We can add or remove multicast groups when arp_validate changes.
3. Other operations, such as enslaving, releasing, or setting NS targets, need to be guarded by arp_validate.

Fixes 4e24be018eb9 ("bonding: add new parameter ns_targets")
---
 drivers/net/bonding/bond_main.c    | 18 ++++++-
 drivers/net/bonding/bond_options.c | 85 +++++++++++++++++++++++++++++-
 include/net/bond_options.h         |  1 +
 3 files changed, 102 insertions(+), 2 deletions(-)
drivers/net/bonding/bond_main.c +17 -1
index b1bffd8e9a95..d7c1016619f9 100644
@@ -1008,6 +1008,9 @@ static void bond_hw_addr_swap(struct bonding *bond, struct slave *new_active,
 
 		if (bond->dev->flags & IFF_UP)
 			bond_hw_addr_flush(bond->dev, old_active->dev);
+
+		/* add target NS maddrs for backup slave */
+		slave_set_ns_maddrs(bond, old_active, true);
 	}
 
 	if (new_active) {
@@ -1024,6 +1027,9 @@ static void bond_hw_addr_swap(struct bonding *bond, struct slave *new_active,
 			dev_mc_sync(new_active->dev, bond->dev);
 			netif_addr_unlock_bh(bond->dev);
 		}
+
+		/* clear target NS maddrs for active slave */
+		slave_set_ns_maddrs(bond, new_active, false);
 	}
 }
 
@@ -2341,6 +2347,12 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
 	bond_compute_features(bond);
 	bond_set_carrier(bond);
 
+	/* set target NS maddrs for new slave, need to be called before
+	 * bond_select_active_slave(), which will remove the maddr if
+	 * the slave is selected as active slave
+	 */
+	slave_set_ns_maddrs(bond, new_slave, true);
+
 	if (bond_uses_primary(bond)) {
 		block_netpoll_tx();
 		bond_select_active_slave(bond);
@@ -2350,7 +2362,6 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
 	if (bond_mode_can_use_xmit_hash(bond))
 		bond_update_slave_arr(bond, NULL);
 
-
 	if (!slave_dev->netdev_ops->ndo_bpf ||
 	    !slave_dev->netdev_ops->ndo_xdp_xmit) {
 		if (bond->xdp_prog) {
@@ -2548,6 +2559,11 @@ static int __bond_release_one(struct net_device *bond_dev,
 	if (oldcurrent == slave)
 		bond_change_active_slave(bond, NULL);
 
+	/* clear target NS maddrs, must after bond_change_active_slave()
+	 * as we need to clear the maddrs on backup slave
+	 */
+	slave_set_ns_maddrs(bond, slave, false);
+
 	if (bond_is_lb(bond)) {
 		/* Must be called only after the slave has been
 		 * detached from the list and the curr_active_slave
drivers/net/bonding/bond_options.c +84 -1

119 lines not on this page · raw message

include/net/bond_options.h +1 -0
index 473a0147769e..59a91d12cd57 100644
@@ -161,5 +161,6 @@ void bond_option_arp_ip_targets_clear(struct bonding *bond);
 #if IS_ENABLED(CONFIG_IPV6)
 void bond_option_ns_ip6_targets_clear(struct bonding *bond);
 #endif
+void slave_set_ns_maddrs(struct bonding *bond, struct slave *slave, bool add);
 
 #endif /* _NET_BOND_OPTIONS_H */
Signature · 1 line
2.46.0
#2 lore raw

Re: [PATCHv3 net 1/2] bonding: add ns target multicast address to slave device

Quoted 20 lines · Hangbin Liu

Commit 4598380f9c54 ("bonding: fix ns validation on backup slaves") tried to resolve the issue where backup slaves couldn't be brought up when receiving IPv6 Neighbor Solicitation (NS) messages. However, this fix only worked for drivers that receive all multicast messages, such as the veth interface.

For standard drivers, the NS multicast message is silently dropped because the slave device is not a member of the NS target multicast group.

To address this, we need to make the slave device join the NS target multicast group, ensuring it can receive these IPv6 NS messages to validate the slave’s status properly.

There are three policies before joining the multicast group:
1. All settings must be under active-backup mode (alb and tlb do not support arp_validate), with backup slaves and slaves supporting multicast.
2. We can add or remove multicast groups when arp_validate changes.
3. Other operations, such as enslaving, releasing, or setting NS targets, need to be guarded by arp_validate.

Quoted 8 lines
Fixes 4e24be018eb9 ("bonding: add new parameter ns_targets")
---
 drivers/net/bonding/bond_main.c    | 18 ++++++-
 drivers/net/bonding/bond_options.c | 85 +++++++++++++++++++++++++++++-
 include/net/bond_options.h         |  1 +
 3 files changed, 102 insertions(+), 2 deletions(-)

Hi,
A few minor comments below,

drivers/net/bonding/bond_main.c static void bond_hw_addr_swap(struct bonding *bond, struct slave *new_active, · line 1012

Quoted 10 lines
drivers/net/bonding/bond_main.c +2 -0
index b1bffd8e9a95..d7c1016619f9 100644
@@ -1008,6 +1008,9 @@ static void bond_hw_addr_swap(struct bonding *bond, struct slave *new_active,
 
 		if (bond->dev->flags & IFF_UP)
 			bond_hw_addr_flush(bond->dev, old_active->dev);
+
+		/* add target NS maddrs for backup slave */

So instead of having these redundant comments, maybe add helper functions to show better what's happening, e.g. slave_ns_maddrs_add()...

drivers/net/bonding/bond_main.c static void bond_hw_addr_swap(struct bonding *bond, struct slave *new_active, · line 1032

Quoted 11 lines
drivers/net/bonding/bond_main.c +4 -0
+		slave_set_ns_maddrs(bond, old_active, true);
 	}
 
 	if (new_active) {
@@ -1024,6 +1027,9 @@ static void bond_hw_addr_swap(struct bonding *bond, struct slave *new_active,
 			dev_mc_sync(new_active->dev, bond->dev);
 			netif_addr_unlock_bh(bond->dev);
 		}
+
+		/* clear target NS maddrs for active slave */
+		slave_set_ns_maddrs(bond, new_active, false);

... same here slave_ns_maddrs_del()

These true/false arguments for add/del require the reader to go search what they mean.

drivers/net/bonding/bond_main.c int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev, · line 2353

Quoted 11 lines
drivers/net/bonding/bond_main.c +4 -0
 	}
 }
 
@@ -2341,6 +2347,12 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
 	bond_compute_features(bond);
 	bond_set_carrier(bond);
 
+	/* set target NS maddrs for new slave, need to be called before
+	 * bond_select_active_slave(), which will remove the maddr if
+	 * the slave is selected as active slave
+	 */

"needs to be called...which will remove the maddr*s*"

Quoted 14 lines
drivers/net/bonding/bond_main.c +2 -1
+	slave_set_ns_maddrs(bond, new_slave, true);
+
 	if (bond_uses_primary(bond)) {
 		block_netpoll_tx();
 		bond_select_active_slave(bond);
@@ -2350,7 +2362,6 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
 	if (bond_mode_can_use_xmit_hash(bond))
 		bond_update_slave_arr(bond, NULL);
 
-
 	if (!slave_dev->netdev_ops->ndo_bpf ||
 	    !slave_dev->netdev_ops->ndo_xdp_xmit) {
 		if (bond->xdp_prog) {

drivers/net/bonding/bond_main.c static int __bond_release_one(struct net_device *bond_dev, · line 2564

Quoted 6 lines
drivers/net/bonding/bond_main.c +3 -0
@@ -2548,6 +2559,11 @@ static int __bond_release_one(struct net_device *bond_dev,
 	if (oldcurrent == slave)
 		bond_change_active_slave(bond, NULL);
 
+	/* clear target NS maddrs, must after bond_change_active_slave()
+	 * as we need to clear the maddrs on backup slave
+	 */

This should be re-worded. I think there's a word missing as well in "...must after...".

Quoted 18 lines
drivers/net/bonding/bond_main.c +2 -0
+	slave_set_ns_maddrs(bond, slave, false);
+
 	if (bond_is_lb(bond)) {
 		/* Must be called only after the slave has been
 		 * detached from the list and the curr_active_slave
drivers/net/bonding/bond_options.c +1 -0
index 95d59a18c022..60368cef2704 100644
@@ -15,6 +15,7 @@
 #include <linux/sched/signal.h>
 
 #include <net/bonding.h>
+#include <net/ndisc.h>
 
 static int bond_option_active_slave_set(struct bonding *bond,
 					const struct bond_opt_value *newval);

drivers/net/bonding/bond_options.c static int bond_option_arp_ip_targets_set(struct bonding *bond, · line 1238

Quoted 4 lines
drivers/net/bonding/bond_options.c +1 -0
@@ -1234,6 +1235,64 @@ static int bond_option_arp_ip_targets_set(struct bonding *bond,
 }
 
 #if IS_ENABLED(CONFIG_IPV6)
+static bool slave_can_set_ns_maddr(struct bonding *bond, struct slave *slave)

const bond/slave

drivers/net/bonding/bond_options.c static int bond_option_arp_ip_targets_set(struct bonding *bond, · line 1245

Quoted 7 lines
drivers/net/bonding/bond_options.c +7 -0
+{
+	return BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP &&
+	       !bond_is_active_slave(slave) &&
+	       slave->dev->flags & IFF_MULTICAST;
+}
+
+static void _slave_set_ns_maddrs(struct bonding *bond, struct slave *slave, bool add)

Can we please stick to using double underscore for internal helpers? I see there are a few other places where a single underscore is used in this file which I've missed before, we can take care of those to make them consistent with the rest of the bonding code.

Quoted 12 lines
drivers/net/bonding/bond_options.c +12 -0
+{
+	struct in6_addr *targets = bond->params.ns_targets;
+	char slot_maddr[MAX_ADDR_LEN];
+	int i;
+
+	if (!slave_can_set_ns_maddr(bond, slave))
+		return;
+
+	for (i = 0; i < BOND_MAX_NS_TARGETS; i++) {
+		if (ipv6_addr_any(&targets[i]))
+			break;
+

drivers/net/bonding/bond_options.c static int bond_option_arp_ip_targets_set(struct bonding *bond, · line 1267

Quoted 10 lines
drivers/net/bonding/bond_options.c +10 -0
+		if (!ndisc_mc_map(&targets[i], slot_maddr, slave->dev, 0)) {
+			if (add)
+				dev_mc_add(slave->dev, slot_maddr);
+			else
+				dev_mc_del(slave->dev, slot_maddr);
+		}
+	}
+}
+
+void slave_set_ns_maddrs(struct bonding *bond, struct slave *slave, bool add)

Usually exported slave functions have the bond_ prefix, e.g. bond_slave...

Quoted 7 lines
drivers/net/bonding/bond_options.c +7 -0
+{
+	if (!bond->params.arp_validate)
+		return;
+
+	_slave_set_ns_maddrs(bond, slave, add);
+}
+

drivers/net/bonding/bond_options.c static int bond_option_arp_ip_targets_set(struct bonding *bond, · line 1283

Quoted 10 lines
drivers/net/bonding/bond_options.c +9 -0
+static void slave_set_ns_maddr(struct bonding *bond, struct slave *slave,
+			       struct in6_addr *target, struct in6_addr *slot)
 
+{
+	char target_maddr[MAX_ADDR_LEN], slot_maddr[MAX_ADDR_LEN];
+
+	if (!bond->params.arp_validate || !slave_can_set_ns_maddr(bond, slave))
+		return;
+
+	/* remove the previous maddr on salve */

s/salve/slave/
s/on/from/

drivers/net/bonding/bond_options.c static int bond_option_arp_ip_targets_set(struct bonding *bond, · line 1287

Quoted 4 lines
drivers/net/bonding/bond_options.c +4 -0
+	if (!ipv6_addr_any(slot) &&
+	    !ndisc_mc_map(slot, slot_maddr, slave->dev, 0)) {
+		dev_mc_del(slave->dev, slot_maddr);
+	}

drop unnecessary {}

drivers/net/bonding/bond_options.c static int bond_option_arp_ip_targets_set(struct bonding *bond, · line 1293

Quoted 6 lines
drivers/net/bonding/bond_options.c +6 -0
+
+	/* add new maddr on slave if target is set */
+	if (!ipv6_addr_any(target) &&
+	    !ndisc_mc_map(target, target_maddr, slave->dev, 0)) {
+		dev_mc_add(slave->dev, target_maddr);
+	}

drop unnesecary {}

Quoted 26 lines
drivers/net/bonding/bond_options.c +2 -0
+}
+
 static void _bond_options_ns_ip6_target_set(struct bonding *bond, int slot,
 					    struct in6_addr *target,
drivers/net/bonding/bond_options.c +8 -1
 					    unsigned long last_rx)
@@ -1243,8 +1302,10 @@ static void _bond_options_ns_ip6_target_set(struct bonding *bond, int slot,
 	struct slave *slave;
 
 	if (slot >= 0 && slot < BOND_MAX_NS_TARGETS) {
-		bond_for_each_slave(bond, slave, iter)
+		bond_for_each_slave(bond, slave, iter) {
 			slave->target_last_arp_rx[slot] = last_rx;
+			slave_set_ns_maddr(bond, slave, target, &targets[slot]);
+		}
 		targets[slot] = *target;
 	}
 }
@@ -1296,15 +1357,37 @@ static int bond_option_ns_ip6_targets_set(struct bonding *bond,
 {
 	return -EPERM;
 }
+
+static void _slave_set_ns_maddrs(struct bonding *bond, struct slave *slave, bool add)
+{
+}
+

drivers/net/bonding/bond_options.c static int bond_option_ns_ip6_targets_set(struct bonding *bond, · line 1374

Quoted 10 lines
drivers/net/bonding/bond_options.c +5 -0
+void slave_set_ns_maddrs(struct bonding *bond, struct slave *slave, bool add)
+{
+}
 #endif
 
 static int bond_option_arp_validate_set(struct bonding *bond,
 					const struct bond_opt_value *newval)
 {
+	bool changed = (bond->params.arp_validate == 0 && newval->value != 0) ||
+		       (bond->params.arp_validate != 0 && newval->value == 0);

!!bond->params.arp_validate != !!newval->value

Quoted 5 lines
drivers/net/bonding/bond_options.c +3 -0
+	struct list_head *iter;
+	struct slave *slave;
+
 	netdev_dbg(bond->dev, "Setting arp_validate to %s (%llu)\n",
 		   newval->string, newval->value);

drivers/net/bonding/bond_options.c static int bond_option_ns_ip6_targets_set(struct bonding *bond, · line 1389

Quoted 10 lines
drivers/net/bonding/bond_options.c +8 -0
 	bond->params.arp_validate = newval->value;
 
+	if (changed) {
+		bond_for_each_slave(bond, slave, iter) {
+			if (bond->params.arp_validate)
+				_slave_set_ns_maddrs(bond, slave, true);
+			else
+				_slave_set_ns_maddrs(bond, slave, false);
+		}
+	}

This block can be written shortly as:
bond_for_each_slave(bond, slave, iter)

	_slave_set_ns_maddrs(bond, slave, !!bond->params.arp_validate);
Quoted 18 lines
drivers/net/bonding/bond_options.c +1 -0
+
 	return 0;
 }
 
include/net/bond_options.h +1 -0
index 473a0147769e..59a91d12cd57 100644
@@ -161,5 +161,6 @@ void bond_option_arp_ip_targets_clear(struct bonding *bond);
 #if IS_ENABLED(CONFIG_IPV6)
 void bond_option_ns_ip6_targets_clear(struct bonding *bond);
 #endif
+void slave_set_ns_maddrs(struct bonding *bond, struct slave *slave, bool add);
 
 #endif /* _NET_BOND_OPTIONS_H */
Signature · 1 line
2.46.0

Cheers,
Nik

#3 lore raw

Re: [PATCHv3 net 1/2] bonding: add ns target multicast address to slave device

Quoted 2 lines · Nikolay Aleksandrov

Hi,
A few minor comments below,

Thanks for all the comments. I will fix them in next version.

Hangbin

#4 lore raw

Re: [PATCHv3 net 1/2] bonding: add ns target multicast address to slave device

In reply to Nikolay Aleksandrov
Quoted 20 lines · Nikolay Aleksandrov
Quoted 13 lines
drivers/net/bonding/bond_options.c +1 -0
index 95d59a18c022..60368cef2704 100644
@@ -15,6 +15,7 @@
 #include <linux/sched/signal.h>
 
 #include <net/bonding.h>
+#include <net/ndisc.h>
 
 static int bond_option_active_slave_set(struct bonding *bond,
 					const struct bond_opt_value *newval);

drivers/net/bonding/bond_options.c static int bond_option_arp_ip_targets_set(struct bonding *bond, · line 1238

Quoted 4 lines
drivers/net/bonding/bond_options.c +1 -0
@@ -1234,6 +1235,64 @@ static int bond_option_arp_ip_targets_set(struct bonding *bond,
 }
 
 #if IS_ENABLED(CONFIG_IPV6)
+static bool slave_can_set_ns_maddr(struct bonding *bond, struct slave *slave)

const bond/slave

Quoted 5 lines

drivers/net/bonding/bond_options.c static int bond_option_arp_ip_targets_set(struct bonding *bond, · line 1243

Quoted 5 lines
drivers/net/bonding/bond_options.c +5 -0
+{
+	return BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP &&
+	       !bond_is_active_slave(slave) &&
+	       slave->dev->flags & IFF_MULTICAST;
+}

Hi, FYI, in new patch I only set bond to const as slave will be called by bond_is_active_slave().

Thanks
Hangbin

#5 lore raw

Re: [PATCHv3 net 1/2] bonding: add ns target multicast address to slave device

Quoted 30 lines · Hangbin Liu
Quoted 20 lines · Nikolay Aleksandrov
Quoted 13 lines
drivers/net/bonding/bond_options.c +1 -0
index 95d59a18c022..60368cef2704 100644
@@ -15,6 +15,7 @@
 #include <linux/sched/signal.h>
 
 #include <net/bonding.h>
+#include <net/ndisc.h>
 
 static int bond_option_active_slave_set(struct bonding *bond,
 					const struct bond_opt_value *newval);

drivers/net/bonding/bond_options.c static int bond_option_arp_ip_targets_set(struct bonding *bond, · line 1238

Quoted 4 lines
drivers/net/bonding/bond_options.c +1 -0
@@ -1234,6 +1235,64 @@ static int bond_option_arp_ip_targets_set(struct bonding *bond,
 }
 
 #if IS_ENABLED(CONFIG_IPV6)
+static bool slave_can_set_ns_maddr(struct bonding *bond, struct slave *slave)

const bond/slave

Quoted 5 lines

drivers/net/bonding/bond_options.c static int bond_option_arp_ip_targets_set(struct bonding *bond, · line 1243

Quoted 5 lines
drivers/net/bonding/bond_options.c +5 -0
+{
+	return BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP &&
+	       !bond_is_active_slave(slave) &&
+	       slave->dev->flags & IFF_MULTICAST;
+}

Hi, FYI, in new patch I only set bond to const as slave will be called by bond_is_active_slave().

Quoted 2 lines

Thanks
Hangbin

Yeah, I figured. :) Thanks for letting me know!

#6 lore raw

PATCH v3 2/2 selftests: bonding: add ns multicast group testing

In reply to Hangbin Liu

Add a test to make sure the backup slaves join correct multicast group when arp_validate enabled and ns_ip6_target is set. Here is the result:

TEST: arp_validate (active-backup ns_ip6_target arp_validate 0) [ OK ]
TEST: arp_validate (join mcast group) [ OK ]
TEST: arp_validate (active-backup ns_ip6_target arp_validate 1) [ OK ]
TEST: arp_validate (join mcast group) [ OK ]
TEST: arp_validate (active-backup ns_ip6_target arp_validate 2) [ OK ]
TEST: arp_validate (join mcast group) [ OK ]
TEST: arp_validate (active-backup ns_ip6_target arp_validate 3) [ OK ]
TEST: arp_validate (join mcast group) [ OK ]
TEST: arp_validate (active-backup ns_ip6_target arp_validate 4) [ OK ]
TEST: arp_validate (join mcast group) [ OK ]
TEST: arp_validate (active-backup ns_ip6_target arp_validate 5) [ OK ]
TEST: arp_validate (join mcast group) [ OK ]
TEST: arp_validate (active-backup ns_ip6_target arp_validate 6) [ OK ]
TEST: arp_validate (join mcast group) [ OK ]

---
 .../drivers/net/bonding/bond_options.sh       | 54 ++++++++++++++++++-
 1 file changed, 53 insertions(+), 1 deletion(-)
tools/testing/selftests/drivers/net/bonding/bond_options.sh +53 -1
index 41d0859feb7d..edc56e2cc606 100755
@@ -11,6 +11,8 @@ ALL_TESTS="
 
 lib_dir=$(dirname "$0")
 source ${lib_dir}/bond_topo_3d1c.sh
+c_maddr="33:33:00:00:00:10"
+g_maddr="33:33:00:00:02:54"
 
 skip_prio()
 {
@@ -240,6 +242,54 @@ arp_validate_test()
 	done
 }
 
+# Testing correct multicast groups are added to slaves for ns targets
+arp_validate_mcast()
+{
+	RET=0
+	local arp_valid=$(cmd_jq "ip -n ${s_ns} -j -d link show bond0" ".[].linkinfo.info_data.arp_validate")
+	local active_slave=$(cmd_jq "ip -n ${s_ns} -d -j link show bond0" ".[].linkinfo.info_data.active_slave")
+
+	for i in $(seq 0 2); do
+		maddr_list=$(ip -n ${s_ns} maddr show dev eth${i})
+
+		# arp_valid == 0 or active_slave should not join any maddrs
+		if { [ "$arp_valid" == "null" ] || [ "eth${i}" == ${active_slave} ]; } && \
+			echo "$maddr_list" | grep -qE "${c_maddr}|${g_maddr}"; then
+			RET=1
+			check_err 1 "arp_valid $arp_valid active_slave $active_slave, eth$i has mcast group"
+		# arp_valid != 0 and backup_slave should join both maddrs
+		elif [ "$arp_valid" != "null" ] && [ "eth${i}" != ${active_slave} ] && \
+		     ( ! echo "$maddr_list" | grep -q "${c_maddr}" || \
+		       ! echo "$maddr_list" | grep -q "${m_maddr}"); then
+			RET=1
+			check_err 1 "arp_valid $arp_valid active_slave $active_slave, eth$i has mcast group"
+		fi
+	done
+
+	# Do failover
+	ip -n ${s_ns} link set ${active_slave} down
+	# wait for active link change
+	slowwait 2 active_slave_changed $active_slave
+	active_slave=$(cmd_jq "ip -n ${s_ns} -d -j link show bond0" ".[].linkinfo.info_data.active_slave")
+
+	for i in $(seq 0 2); do
+		maddr_list=$(ip -n ${s_ns} maddr show dev eth${i})
+
+		# arp_valid == 0 or active_slave should not join any maddrs
+		if { [ "$arp_valid" == "null" ] || [ "eth${i}" == ${active_slave} ]; } && \
+			echo "$maddr_list" | grep -qE "${c_maddr}|${g_maddr}"; then
+			RET=1
+			check_err 1 "arp_valid $arp_valid active_slave $active_slave, eth$i has mcast group"
+		# arp_valid != 0 and backup_slave should join both maddrs
+		elif [ "$arp_valid" != "null" ] && [ "eth${i}" != ${active_slave} ] && \
+		     ( ! echo "$maddr_list" | grep -q "${c_maddr}" || \
+		       ! echo "$maddr_list" | grep -q "${m_maddr}"); then
+			RET=1
+			check_err 1 "arp_valid $arp_valid active_slave $active_slave, eth$i has mcast group"
+		fi
+	done
+}
+
 arp_validate_arp()
 {
 	local mode=$1
@@ -261,8 +311,10 @@ arp_validate_ns()
 	fi
 
 	for val in $(seq 0 6); do
-		arp_validate_test "mode $mode arp_interval 100 ns_ip6_target ${g_ip6} arp_validate $val"
+		arp_validate_test "mode $mode arp_interval 100 ns_ip6_target ${g_ip6},${c_ip6} arp_validate $val"
 		log_test "arp_validate" "$mode ns_ip6_target arp_validate $val"
+		arp_validate_mcast
+		log_test "arp_validate" "join mcast group"
 	done
 }
 
Signature · 1 line
2.46.0