Skip to contentSkip to conversation

bonding: fix ns validation on backup slaves

PATCH Superseded Hangbin Liu 3 participants 15 messages Mar 29, 2023 – Apr 6, 2023

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover bonding: fix ns validation on backup slaves

The first patch fixed a ns validation issue on backup slaves. The second patch re-format the bond option test and add a test lib file. The third patch add the arp validate regression test for the kernel patch.

Here is the new bonding option test without the kernel fix:

]# ./bond_options.sh
TEST: prio (active-backup miimon primary_reselect 0) [ OK ]
TEST: prio (active-backup miimon primary_reselect 1) [ OK ]
TEST: prio (active-backup miimon primary_reselect 2) [ OK ]
TEST: prio (active-backup arp_ip_target primary_reselect 0) [ OK ]
TEST: prio (active-backup arp_ip_target primary_reselect 1) [ OK ]
TEST: prio (active-backup arp_ip_target primary_reselect 2) [ OK ]
TEST: prio (active-backup ns_ip6_target primary_reselect 0) [ OK ]
TEST: prio (active-backup ns_ip6_target primary_reselect 1) [ OK ]
TEST: prio (active-backup ns_ip6_target primary_reselect 2) [ OK ]
TEST: prio (balance-tlb miimon primary_reselect 0) [ OK ]
TEST: prio (balance-tlb miimon primary_reselect 1) [ OK ]
TEST: prio (balance-tlb miimon primary_reselect 2) [ OK ]
TEST: prio (balance-tlb arp_ip_target primary_reselect 0) [ OK ]
TEST: prio (balance-tlb arp_ip_target primary_reselect 1) [ OK ]
TEST: prio (balance-tlb arp_ip_target primary_reselect 2) [ OK ]
TEST: prio (balance-tlb ns_ip6_target primary_reselect 0) [ OK ]
TEST: prio (balance-tlb ns_ip6_target primary_reselect 1) [ OK ]
TEST: prio (balance-tlb ns_ip6_target primary_reselect 2) [ OK ]
TEST: prio (balance-alb miimon primary_reselect 0) [ OK ]
TEST: prio (balance-alb miimon primary_reselect 1) [ OK ]
TEST: prio (balance-alb miimon primary_reselect 2) [ OK ]
TEST: prio (balance-alb arp_ip_target primary_reselect 0) [ OK ]
TEST: prio (balance-alb arp_ip_target primary_reselect 1) [ OK ]
TEST: prio (balance-alb arp_ip_target primary_reselect 2) [ OK ]
TEST: prio (balance-alb ns_ip6_target primary_reselect 0) [ OK ]
TEST: prio (balance-alb ns_ip6_target primary_reselect 1) [ OK ]
TEST: prio (balance-alb ns_ip6_target primary_reselect 2) [ OK ]
TEST: arp_validate (active-backup arp_ip_target arp_validate 0) [ OK ]
TEST: arp_validate (active-backup arp_ip_target arp_validate 1) [ OK ]
TEST: arp_validate (active-backup arp_ip_target arp_validate 2) [ OK ]
TEST: arp_validate (active-backup arp_ip_target arp_validate 3) [ OK ]
TEST: arp_validate (active-backup arp_ip_target arp_validate 4) [ OK ]
TEST: arp_validate (active-backup arp_ip_target arp_validate 5) [ OK ]
TEST: arp_validate (active-backup arp_ip_target arp_validate 6) [ OK ]
TEST: arp_validate (active-backup ns_ip6_target arp_validate 0) [ OK ]
TEST: arp_validate (active-backup ns_ip6_target arp_validate 1) [ OK ]
TEST: arp_validate (interface eth1 mii_status DOWN) [FAIL]
TEST: arp_validate (interface eth2 mii_status DOWN) [FAIL]
TEST: arp_validate (active-backup ns_ip6_target arp_validate 2) [FAIL]
TEST: arp_validate (interface eth1 mii_status DOWN) [FAIL]
TEST: arp_validate (interface eth2 mii_status DOWN) [FAIL]
TEST: arp_validate (active-backup ns_ip6_target arp_validate 3) [FAIL]
TEST: arp_validate (active-backup ns_ip6_target arp_validate 4) [ OK ]
TEST: arp_validate (active-backup ns_ip6_target arp_validate 5) [ OK ]
TEST: arp_validate (interface eth1 mii_status DOWN) [FAIL]
TEST: arp_validate (interface eth2 mii_status DOWN) [FAIL]
TEST: arp_validate (active-backup ns_ip6_target arp_validate 6) [FAIL]

Here is the test result after the kernel fix:
TEST: arp_validate (active-backup arp_ip_target arp_validate 0) [ OK ]
TEST: arp_validate (active-backup arp_ip_target arp_validate 1) [ OK ]
TEST: arp_validate (active-backup arp_ip_target arp_validate 2) [ OK ]
TEST: arp_validate (active-backup arp_ip_target arp_validate 3) [ OK ]
TEST: arp_validate (active-backup arp_ip_target arp_validate 4) [ OK ]
TEST: arp_validate (active-backup arp_ip_target arp_validate 5) [ OK ]
TEST: arp_validate (active-backup arp_ip_target arp_validate 6) [ OK ]
TEST: arp_validate (active-backup ns_ip6_target arp_validate 0) [ OK ]
TEST: arp_validate (active-backup ns_ip6_target arp_validate 1) [ OK ]
TEST: arp_validate (active-backup ns_ip6_target arp_validate 2) [ OK ]
TEST: arp_validate (active-backup ns_ip6_target arp_validate 3) [ OK ]
TEST: arp_validate (active-backup ns_ip6_target arp_validate 4) [ OK ]
TEST: arp_validate (active-backup ns_ip6_target arp_validate 5) [ OK ]
TEST: arp_validate (active-backup ns_ip6_target arp_validate 6) [ OK ]

Hangbin Liu (3):
bonding: fix ns validation on backup slaves
selftests: bonding: re-format bond option tests
selftests: bonding: add arp validate test

 drivers/net/bonding/bond_main.c               |   5 +-
 include/net/bonding.h                         |   8 +-
 .../selftests/drivers/net/bonding/Makefile    |   3 +-
 .../selftests/drivers/net/bonding/bond_lib.sh | 145 ++++++++++
 .../drivers/net/bonding/bond_options.sh       | 271 ++++++++++++++++++
 .../drivers/net/bonding/option_prio.sh        | 245 ----------------
 6 files changed, 427 insertions(+), 250 deletions(-)

create 100644 tools/testing/selftests/drivers/net/bonding/bond_lib.sh create 100755 tools/testing/selftests/drivers/net/bonding/bond_options.sh delete 100755 tools/testing/selftests/drivers/net/bonding/option_prio.sh

Signature · 1 line
2.38.1
#1 lore raw

PATCH 1/3 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 4e24be018eb9 ("bonding: add new parameter ns_targets")
---
 drivers/net/bonding/bond_main.c | 5 +++--
 include/net/bonding.h           | 8 ++++++--
 2 files changed, 9 insertions(+), 4 deletions(-)
drivers/net/bonding/bond_main.c +3 -2
index 236e5219c811..8cc9a74789b7 100644
@@ -3269,7 +3269,8 @@ static int bond_na_rcv(const struct sk_buff *skb, struct bonding *bond,
 
 	combined = skb_header_pointer(skb, 0, sizeof(_combined), &_combined);
 	if (!combined || combined->ip6.nexthdr != NEXTHDR_ICMP ||
-	    combined->icmp6.icmp6_type != NDISC_NEIGHBOUR_ADVERTISEMENT)
+	    (combined->icmp6.icmp6_type != NDISC_NEIGHBOUR_SOLICITATION &&
+	     combined->icmp6.icmp6_type != NDISC_NEIGHBOUR_ADVERTISEMENT))
 		goto out;
 
 	saddr = &combined->ip6.saddr;
@@ -3291,7 +3292,7 @@ static int bond_na_rcv(const struct sk_buff *skb, struct bonding *bond,
 	else if (curr_active_slave &&
 		 time_after(slave_last_rx(bond, curr_active_slave),
 			    curr_active_slave->last_link_up))
-		bond_validate_na(bond, slave, saddr, daddr);
+		bond_validate_na(bond, slave, daddr, saddr);
 	else if (curr_arp_slave &&
 		 bond_time_in_interval(bond, slave_last_tx(curr_arp_slave), 1))
 		bond_validate_na(bond, slave, saddr, daddr);
include/net/bonding.h +6 -2
index ea36ab7f9e72..c3843239517d 100644
@@ -761,13 +761,17 @@ static inline int bond_get_targets_ip(__be32 *targets, __be32 ip)
 #if IS_ENABLED(CONFIG_IPV6)
 static inline int bond_get_targets_ip6(struct in6_addr *targets, struct in6_addr *ip)
 {
+	struct in6_addr mcaddr;
 	int i;
 
-	for (i = 0; i < BOND_MAX_NS_TARGETS; i++)
-		if (ipv6_addr_equal(&targets[i], ip))
+	for (i = 0; i < BOND_MAX_NS_TARGETS; i++) {
+		addrconf_addr_solict_mult(&targets[i], &mcaddr);
+		if ((ipv6_addr_equal(&targets[i], ip)) ||
+		    (ipv6_addr_equal(&mcaddr, ip)))
 			return i;
 		else if (ipv6_addr_any(&targets[i]))
 			break;
+	}
 
 	return -1;
 }
Signature · 1 line
2.38.1
Reviewed-by on v1 1/3
#2 lore raw
Quoted 15 lines · Hangbin Liu

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.

Quoted 5 lines

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 4e24be018eb9 ("bonding: add new parameter ns_targets")
Acked-by on v1 1/3
#3 lore raw
In reply to Hangbin Liu
Quoted 15 lines · Hangbin Liu

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.

Quoted 5 lines

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 4e24be018eb9 ("bonding: add new parameter ns_targets")
Quoted 55 lines

---
drivers/net/bonding/bond_main.c | 5 +++--
include/net/bonding.h | 8 ++++++--

2 files changed, 9 insertions(+), 4 deletions(-)
drivers/net/bonding/bond_main.c +3 -2
index 236e5219c811..8cc9a74789b7 100644
@@ -3269,7 +3269,8 @@ static int bond_na_rcv(const struct sk_buff *skb, struct bonding *bond,
 
 	combined = skb_header_pointer(skb, 0, sizeof(_combined), &_combined);
 	if (!combined || combined->ip6.nexthdr != NEXTHDR_ICMP ||
-	    combined->icmp6.icmp6_type != NDISC_NEIGHBOUR_ADVERTISEMENT)
+	    (combined->icmp6.icmp6_type != NDISC_NEIGHBOUR_SOLICITATION &&
+	     combined->icmp6.icmp6_type != NDISC_NEIGHBOUR_ADVERTISEMENT))
 		goto out;
 
 	saddr = &combined->ip6.saddr;
@@ -3291,7 +3292,7 @@ static int bond_na_rcv(const struct sk_buff *skb, struct bonding *bond,
 	else if (curr_active_slave &&
 		 time_after(slave_last_rx(bond, curr_active_slave),
 			    curr_active_slave->last_link_up))
-		bond_validate_na(bond, slave, saddr, daddr);
+		bond_validate_na(bond, slave, daddr, saddr);
 	else if (curr_arp_slave &&
 		 bond_time_in_interval(bond, slave_last_tx(curr_arp_slave), 1))
 		bond_validate_na(bond, slave, saddr, daddr);
include/net/bonding.h +6 -2
index ea36ab7f9e72..c3843239517d 100644
@@ -761,13 +761,17 @@ static inline int bond_get_targets_ip(__be32 *targets, __be32 ip)
 #if IS_ENABLED(CONFIG_IPV6)
 static inline int bond_get_targets_ip6(struct in6_addr *targets, struct in6_addr *ip)
 {
+	struct in6_addr mcaddr;
 	int i;
 
-	for (i = 0; i < BOND_MAX_NS_TARGETS; i++)
-		if (ipv6_addr_equal(&targets[i], ip))
+	for (i = 0; i < BOND_MAX_NS_TARGETS; i++) {
+		addrconf_addr_solict_mult(&targets[i], &mcaddr);
+		if ((ipv6_addr_equal(&targets[i], ip)) ||
+		    (ipv6_addr_equal(&mcaddr, ip)))
 			return i;
 		else if (ipv6_addr_any(&targets[i]))
 			break;
+	}
 
 	return -1;
 }
Signature · 1 line
2.38.1
#4 lore raw

PATCH 2/3 selftests: bonding: re-format bond option tests

In reply to Hangbin Liu

To improve the testing process for bond options, A new bond library is added to our testing setup. The current option_prio.sh file will be renamed to bond_options.sh so that all bonding options can be tested here. Specifically, for priority testing, we will run all tests using module 1, 5, and 6. These changes will help us streamline the testing process and ensure that our bond options are rigorously evaluated.

---
 .../selftests/drivers/net/bonding/Makefile    |   3 +-
 .../selftests/drivers/net/bonding/bond_lib.sh | 145 +++++++++++
 .../drivers/net/bonding/bond_options.sh       | 216 +++++++++++++++
 .../drivers/net/bonding/option_prio.sh        | 245 ------------------
 4 files changed, 363 insertions(+), 246 deletions(-)
 create mode 100644 tools/testing/selftests/drivers/net/bonding/bond_lib.sh
 create mode 100755 tools/testing/selftests/drivers/net/bonding/bond_options.sh
 delete mode 100755 tools/testing/selftests/drivers/net/bonding/option_prio.sh
tools/testing/selftests/drivers/net/bonding/Makefile +2 -1
index a39bb2560d9b..4683b06afdba 100644
@@ -8,11 +8,12 @@ TEST_PROGS := \
 	dev_addr_lists.sh \
 	mode-1-recovery-updelay.sh \
 	mode-2-recovery-updelay.sh \
-	option_prio.sh \
+	bond_options.sh \
 	bond-eth-type-change.sh
 
 TEST_FILES := \
 	lag_lib.sh \
+	bond_lib.sh \
 	net_forwarding_lib.sh
 
 include ../../../lib.mk
tools/testing/selftests/drivers/net/bonding/bond_lib.sh new file +145 -0

145 lines not on this page · raw message

tools/testing/selftests/drivers/net/bonding/bond_options.sh new file +216 -0

216 lines not on this page · raw message

tools/testing/selftests/drivers/net/bonding/option_prio.sh deleted +0 -245

245 lines not on this page · raw message

Signature · 1 line
2.38.1
#5 lore raw

Re: [PATCH net 2/3] selftests: bonding: re-format bond option tests

Quoted 4 lines · Hangbin Liu

To improve the testing process for bond options, A new bond library is added to our testing setup. The current option_prio.sh file will be renamed to bond_options.sh so that all bonding options can be tested here. Specifically, for priority testing, we will run all tests using module

I think you mean modes^^^

tools/testing/selftests/drivers/net/bonding/bond_lib.sh

Quoted 37 lines

1, 5, and 6. These changes will help us streamline the testing process and ensure that our bond options are rigorously evaluated.

---
  .../selftests/drivers/net/bonding/Makefile    |   3 +-
  .../selftests/drivers/net/bonding/bond_lib.sh | 145 +++++++++++
  .../drivers/net/bonding/bond_options.sh       | 216 +++++++++++++++
  .../drivers/net/bonding/option_prio.sh        | 245 ------------------
  4 files changed, 363 insertions(+), 246 deletions(-)

create mode 100644 tools/testing/selftests/drivers/net/bonding/bond_lib.sh create mode 100755 tools/testing/selftests/drivers/net/bonding/bond_options.sh delete mode 100755 tools/testing/selftests/drivers/net/bonding/option_prio.sh

tools/testing/selftests/drivers/net/bonding/Makefile +2 -1
index a39bb2560d9b..4683b06afdba 100644
@@ -8,11 +8,12 @@ TEST_PROGS := \
  	dev_addr_lists.sh \
  	mode-1-recovery-updelay.sh \
  	mode-2-recovery-updelay.sh \
-	option_prio.sh \
+	bond_options.sh \
  	bond-eth-type-change.sh
 
  TEST_FILES := \
  	lag_lib.sh \
+	bond_lib.sh \
  	net_forwarding_lib.sh
 
  include ../../../lib.mk
tools/testing/selftests/drivers/net/bonding/bond_lib.sh new file +0 -0
new file mode 100644
index 000000000000..ca64a82e1385

I like this idea, we might want to separate network topology from library code however. That way a given test case can just include a predefined topology. A quick review of the test cases show a 2 node setup is the most common across all test cases.

-Jon

#6 lore raw

Re: [PATCH net 2/3] selftests: bonding: re-format bond option tests

Quoted 6 lines · Jonathan Toppins
Quoted 4 lines · Hangbin Liu

To improve the testing process for bond options, A new bond library is added to our testing setup. The current option_prio.sh file will be renamed to bond_options.sh so that all bonding options can be tested here. Specifically, for priority testing, we will run all tests using module

I think you mean modes^^^

Ah, yes.

Quoted 13 lines

tools/testing/selftests/drivers/net/bonding/bond_lib.sh

Quoted 10 lines

1, 5, and 6. These changes will help us streamline the testing process and ensure that our bond options are rigorously evaluated.

---

tools/testing/selftests/drivers/net/bonding/bond_lib.sh new file +0 -0
new file mode 100644
index 000000000000..ca64a82e1385

I like this idea, we might want to separate network topology from library code however. That way a given test case can just include a predefined

Would you like to help explain more clear? Separate network topology to where?

Quoted 2 lines

topology. A quick review of the test cases show a 2 node setup is the most common across all test cases.

Liang suggested that with 2 clients we can test xmit_hash_policy. In client_create() I only create 1 client for current testing. We can add more clients in future.

Thanks
Hangbin

#7 lore raw

Re: [PATCH net 2/3] selftests: bonding: re-format bond option tests

Quoted 6 lines · Hangbin Liu
Quoted 4 lines
Quoted 1 line

+++ b/tools/testing/selftests/drivers/net/bonding/bond_lib.sh

I like this idea, we might want to separate network topology from library code however. That way a given test case can just include a predefined

Would you like to help explain more clear? Separate network topology to where?

Hi Jon, would you please help explain this part?

Thanks
Hangbin

Quoted 10 lines
Quoted 3 lines

topology. A quick review of the test cases show a 2 node setup is the most common across all test cases.

Liang suggested that with 2 clients we can test xmit_hash_policy. In client_create() I only create 1 client for current testing. We can add more clients in future.

Thanks
Hangbin

#8 lore raw

Re: [PATCH net 2/3] selftests: bonding: re-format bond option tests

Quoted 10 lines · Hangbin Liu
Quoted 6 lines · Hangbin Liu
Quoted 4 lines
Quoted 1 line

+++ b/tools/testing/selftests/drivers/net/bonding/bond_lib.sh

I like this idea, we might want to separate network topology from library code however. That way a given test case can just include a predefined

Would you like to help explain more clear? Separate network topology to where?

Hi Jon, would you please help explain this part?

Thanks for the ping. It looks like several test cases build largely the same virtual network topology and then execute the test case. I was attempting to point out that it might be better to provide a standard network topology and then each test case utilizes this standard topology instead of each test case rolling its own. Also, with my comment about separating out the topology from library code I was accounting for the ability to support multiple topologies, fe:

bond_lib.sh
bond_topo_gateway.sh
bond_topo_2.sh

Then a given test case only includes/sources bond_topo_gateway.sh which creates the virtual network.

-Jon

Quoted 12 lines
Quoted 11 lines
Quoted 4 lines

topology. A quick review of the test cases show a 2 node setup is the most common across all test cases.

Liang suggested that with 2 clients we can test xmit_hash_policy. In client_create() I only create 1 client for current testing. We can add more clients in future.

Thanks
Hangbin

#9 lore raw

Re: [PATCH net 2/3] selftests: bonding: re-format bond option tests

Quoted 16 lines · Jonathan Toppins
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

I like this idea, we might want to separate network topology from library code however. That way a given test case can just include a predefined

Would you like to help explain more clear? Separate network topology to where?

Hi Jon, would you please help explain this part?

Thanks for the ping. It looks like several test cases build largely the same virtual network topology and then execute the test case. I was attempting to point out that it might be better to provide a standard network topology and then each test case utilizes this standard topology instead of each test case rolling its own. Also, with my comment about separating out the topology from library code I was accounting for the ability to support multiple topologies, fe:

Quoted 6 lines

bond_lib.sh
bond_topo_gateway.sh
bond_topo_2.sh

Then a given test case only includes/sources bond_topo_gateway.sh which creates the virtual network.

Thank Jon, this is much clear to me now. I'm not good at naming. For topology with 2 down link devices, 1 client, I plan to name it bond_topo_2d1c.sh. So 3 down links devices, 2 clients will be bond_topo_3d2c.sh. If there is no switch between server and client, it could be bond_topo_2d1c_ns.sh.

I'm not sure if the name is weird to you. Any comments?

Thanks
Hangbin

#10 lore raw

Re: [PATCH net 2/3] selftests: bonding: re-format bond option tests

Quoted 24 lines · Hangbin Liu
Quoted 16 lines · Jonathan Toppins
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

I like this idea, we might want to separate network topology from library code however. That way a given test case can just include a predefined

Would you like to help explain more clear? Separate network topology to where?

Hi Jon, would you please help explain this part?

Thanks for the ping. It looks like several test cases build largely the same virtual network topology and then execute the test case. I was attempting to point out that it might be better to provide a standard network topology and then each test case utilizes this standard topology instead of each test case rolling its own. Also, with my comment about separating out the topology from library code I was accounting for the ability to support multiple topologies, fe:

Quoted 6 lines

bond_lib.sh
bond_topo_gateway.sh
bond_topo_2.sh

Then a given test case only includes/sources bond_topo_gateway.sh which creates the virtual network.

Quoted 8 lines

Thank Jon, this is much clear to me now. I'm not good at naming. For topology with 2 down link devices, 1 client, I plan to name it bond_topo_2d1c.sh. So 3 down links devices, 2 clients will be bond_topo_3d2c.sh. If there is no switch between server and client, it could be bond_topo_2d1c_ns.sh.

I'm not sure if the name is weird to you. Any comments?

Hi Hangbin, I do not have a particular preference for the naming. What you have proposed seems good to me.

-Jon

Acked-by on v1 2/3
#11 lore raw

Re: [PATCH net 2/3] selftests: bonding: re-format bond option tests

In reply to Hangbin Liu
Quoted 4 lines · Hangbin Liu

To improve the testing process for bond options, A new bond library is added to our testing setup. The current option_prio.sh file will be renamed to bond_options.sh so that all bonding options can be tested here. Specifically, for priority testing, we will run all tests using module

Typo here, "module" vs "mode"

Quoted 2 lines

1, 5, and 6. These changes will help us streamline the testing process and ensure that our bond options are rigorously evaluated.

Other than the typo above and a couple more noted below (which
aren't new to this patch; they're in code being copied), looks good to me.

Quoted 260 lines

---

.../selftests/drivers/net/bonding/Makefile    |   3 +-
.../selftests/drivers/net/bonding/bond_lib.sh | 145 +++++++++++
.../drivers/net/bonding/bond_options.sh       | 216 +++++++++++++++
.../drivers/net/bonding/option_prio.sh        | 245 ------------------
4 files changed, 363 insertions(+), 246 deletions(-)

create mode 100644 tools/testing/selftests/drivers/net/bonding/bond_lib.sh create mode 100755 tools/testing/selftests/drivers/net/bonding/bond_options.sh delete mode 100755 tools/testing/selftests/drivers/net/bonding/option_prio.sh

tools/testing/selftests/drivers/net/bonding/Makefile +2 -1
index a39bb2560d9b..4683b06afdba 100644
@@ -8,11 +8,12 @@ TEST_PROGS := \
 	dev_addr_lists.sh \
 	mode-1-recovery-updelay.sh \
 	mode-2-recovery-updelay.sh \
-	option_prio.sh \
+	bond_options.sh \
 	bond-eth-type-change.sh
 
 TEST_FILES := \
 	lag_lib.sh \
+	bond_lib.sh \
 	net_forwarding_lib.sh
 

include ../../../lib.mk

tools/testing/selftests/drivers/net/bonding/bond_lib.sh new file +145 -0
new file mode 100644
index 000000000000..ca64a82e1385
@@ -0,0 +1,145 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# Topology for Bond mode 1,5,6 testing
+#
+#  +---------------------------------------+
+#  |                 bond0                 |  192.0.2.1/24
+#  |                   +                   |  2001:db8::1/24
+#  |       eth0        | eth1   eth2       |  Server
+#  |         +-------------------+         |
+#  |         |         |         |         |
+#  +---------------------------------------+
+#            |         |         |
+#            |         |         |
+#  +---------------------------------------+
+#  |         |         |         |         |  192.0.2.254/24
+#  |     +---+---------+---------+---+     |  2001:db8::254/24
+#  |     |            br0            |     |  Switch
+#  |     +---+---------+---------+---+     |
+#  |         |         |         |         |
+#  +---------------------------------------+
+#            |         |         |
+#      +-----+         |         +-----+
+#      |               |               |
+#  +-------+       +-------+           |
+#  |   |   |       |   |   |           +
+#  |   +   |       |   +   |     ... More clients if needed
+#  | eth0  |       | eth0  |
+#  +-------+       +-------+
+#   Client          Client1
+#  192.0.2.10      192.0.2.11
+# 2001:db8::10    2001:db8::11
+
+s_ns="s-$(mktemp -u XXXXXX)"
+sw_ns="sw-$(mktemp -u XXXXXX)"
+c_ns="c-$(mktemp -u XXXXXX)"
+s_ip4="192.0.2.1"
+c_ip4="192.0.2.10"
+sw_ip4="192.0.2.254"
+s_ip6="2001:db8::1"
+c_ip6="2001:db8::10"
+sw_ip6="2001:db8::254"
+
+switch_create()
+{
+	ip netns add ${sw_ns}
+	ip -n ${sw_ns} link add br0 type bridge
+	ip -n ${sw_ns} link set br0 up
+	ip -n ${sw_ns} addr add ${sw_ip4}/24 dev br0
+	ip -n ${sw_ns} addr add ${sw_ip6}/24 dev br0
+}
+
+switch_destroy()
+{
+	ip -n ${sw_ns} link del br0
+	ip netns del ${sw_ns}
+}
+
+server_create()
+{
+	ip netns add ${s_ns}
+	ip -n ${s_ns} link add bond0 type bond mode active-backup miimon 100
+
+	for i in $(seq 0 2); do
+		ip -n ${s_ns} link add eth${i} type veth peer name s${i} netns ${sw_ns}
+
+		ip -n ${sw_ns} link set s${i} up
+		ip -n ${sw_ns} link set s${i} master br0
+		ip -n ${s_ns} link set eth${i} master bond0
+	done
+
+	ip -n ${s_ns} link set bond0 up
+	ip -n ${s_ns} addr add ${s_ip4}/24 dev bond0
+	ip -n ${s_ns} addr add ${s_ip6}/24 dev bond0
+	sleep 2
+}
+
+bond_reset()
+{
+	local param="$1"
+
+	ip -n ${s_ns} link set bond0 down
+	ip -n ${s_ns} link del bond0
+
+	ip -n ${s_ns} link add bond0 type bond $param
+	for i in $(seq 0 2); do
+		ip -n ${s_ns} link set eth$i master bond0
+	done
+
+	ip -n ${s_ns} link set bond0 up
+	ip -n ${s_ns} addr add ${s_ip4}/24 dev bond0
+	ip -n ${s_ns} addr add ${s_ip6}/24 dev bond0
+	sleep 2
+}
+
+server_destroy()
+{
+	for i in $(seq 0 2); do
+		ip -n ${s_ns} link del eth${i}
+	done
+	ip netns del ${s_ns}
+}
+
+client_create()
+{
+	ip netns add ${c_ns}
+	ip -n ${c_ns} link add eth0 type veth peer name c0 netns ${sw_ns}
+
+	ip -n ${sw_ns} link set c0 up
+	ip -n ${sw_ns} link set c0 master br0
+
+	ip -n ${c_ns} link set eth0 up
+	ip -n ${c_ns} addr add ${c_ip4}/24 dev eth0
+	ip -n ${c_ns} addr add ${c_ip6}/24 dev eth0
+}
+
+client_destroy()
+{
+	ip -n ${c_ns} link del eth0
+	ip netns del ${c_ns}
+}
+
+setup_prepare()
+{
+	switch_create
+	server_create
+	client_create
+}
+
+cleanup()
+{
+	pre_cleanup
+
+	client_destroy
+	server_destroy
+	switch_destroy
+}
+
+bond_check_connection()
+{
+	ip netns exec ${s_ns} ping ${c_ip4} -c5 -i 0.1 -I bond0 &>/dev/null
+	check_err $? "ping failed"
+	ip netns exec ${s_ns} ping6 ${c_ip6} -c5 -i 0.1 -I bond0 &>/dev/null
+	check_err $? "ping6 failed"
+}
tools/testing/selftests/drivers/net/bonding/bond_options.sh new file +74 -0
new file mode 100755
index 000000000000..431ce0e45e3c
@@ -0,0 +1,216 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# Test bonding options
+
+ALL_TESTS="
+	prio
+"
+
+REQUIRE_MZ=no
+NUM_NETIFS=0
+lib_dir=$(dirname "$0")
+source "$lib_dir"/net_forwarding_lib.sh
+source "$lib_dir"/bond_lib.sh
+
+skip_prio()
+{
+	local skip=1
+
+	# check if iproute support prio option
+	ip -n ${s_ns} link set eth0 type bond_slave prio 10
+	[[ $? -ne 0 ]] && skip=0
+
+	# check if kernel support prio option
+	ip -n ${s_ns} -d link show eth0 | grep -q "prio 10"
+	[[ $? -ne 0 ]] && skip=0
+
+	return $skip
+}
+
+skip_ns()
+{
+	local skip=1
+
+	# check if iproute support ns_ip6_target option
+	ip -n ${s_ns} link add bond1 type bond ns_ip6_target ${sw_ip6}
+	[[ $? -ne 0 ]] && skip=0
+
+	# check if kernel support ns_ip6_target option
+	ip -n ${s_ns} -d link show bond1 | grep -q "ns_ip6_target ${sw_ip6}"
+	[[ $? -ne 0 ]] && skip=0
+
+	ip -n ${s_ns} link del bond1
+
+	return $skip
+}
+
+active_slave=""
+check_active_slave()
+{
+	local target_active_slave=$1
+	active_slave=$(cmd_jq "ip -n ${s_ns} -d -j link show bond0" ".[].linkinfo.info_data.active_slave")
+	test "$active_slave" = "$target_active_slave"
+	check_err $? "Current active slave is $active_slave but not $target_active_slave"
+}
+
+
+# Test bonding prio option
+prio_test()
+{
+	local param="$1"
+	RET=0
+
+	# create bond
+	bond_reset "${param}"
+
+	# check bonding member prio value
+	ip -n ${s_ns} link set eth0 type bond_slave prio 0
+	ip -n ${s_ns} link set eth1 type bond_slave prio 10
+	ip -n ${s_ns} link set eth2 type bond_slave prio 11
+	cmd_jq "ip -n ${s_ns} -d -j link show eth0" \
+		".[].linkinfo.info_slave_data | select (.prio == 0)" "-e" &> /dev/null
+	check_err $? "eth0 prio is not 0"
+	cmd_jq "ip -n ${s_ns} -d -j link show eth1" \

tools/testing/selftests/drivers/net/bonding/bond_options.sh line 84

Quoted 10 lines
tools/testing/selftests/drivers/net/bonding/bond_options.sh new file +10 -0
+		".[].linkinfo.info_slave_data | select (.prio == 10)" "-e" &> /dev/null
+	check_err $? "eth1 prio is not 10"
+	cmd_jq "ip -n ${s_ns} -d -j link show eth2" \
+		".[].linkinfo.info_slave_data | select (.prio == 11)" "-e" &> /dev/null
+	check_err $? "eth2 prio is not 11"
+
+	bond_check_connection
+	[ $RET -ne 0 ] && log_test "prio" "$retmsg"
+
+	# active salve should be the primary slave
	"salve" -> "slave"
Quoted 42 lines
tools/testing/selftests/drivers/net/bonding/bond_options.sh new file +42 -0
+	check_active_slave eth1
+
+	# active slave should be the higher prio slave
+	ip -n ${s_ns} link set $active_slave down
+	ip netns exec ${s_ns} ping $c_ip4 -c5 -I bond0 &>/dev/null
+	check_err $? "ping failed 2."
+	check_active_slave eth2
+
+	# when only 1 slave is up
+	ip -n ${s_ns} link set $active_slave down
+	ip netns exec ${s_ns} ping $c_ip4 -c5 -I bond0 &>/dev/null
+	check_err $? "ping failed 3."
+	check_active_slave eth0
+
+	# when a higher prio slave change to up
+	ip -n ${s_ns} link set eth2 up
+	ip netns exec ${s_ns} ping $c_ip4 -c5 -I bond0 &>/dev/null
+	check_err $? "ping failed 4."
+	case $primary_reselect in
+		"0")
+			check_active_slave "eth2"
+			;;
+		"1")
+			check_active_slave "eth0"
+			;;
+		"2")
+			check_active_slave "eth0"
+			;;
+	esac
+	local pre_active_slave=$active_slave
+
+	# when the primary slave change to up
+	ip -n ${s_ns} link set eth1 up
+	ip netns exec ${s_ns} ping $c_ip4 -c5 -I bond0 &>/dev/null
+	check_err $? "ping failed 5."
+	case $primary_reselect in
+		"0")
+			check_active_slave "eth1"
+			;;
+		"1")
+			check_active_slave "$pre_active_slave"
+			;;

tools/testing/selftests/drivers/net/bonding/bond_options.sh line 136

Quoted 10 lines
tools/testing/selftests/drivers/net/bonding/bond_options.sh new file +10 -0
+		"2")
+			check_active_slave "$pre_active_slave"
+			ip -n ${s_ns} link set $active_slave down
+			ip netns exec ${s_ns} ping $c_ip4 -c5 -I bond0 &>/dev/null
+			check_err $? "ping failed 6."
+			check_active_slave "eth1"
+			;;
+	esac
+
+	# Test changing bond salve prio
	"salve" -> "slave"
Quoted 334 lines
tools/testing/selftests/drivers/net/bonding/bond_options.sh new file +80 -0
+	if [[ "$primary_reselect" == "0" ]];then
+		ip -n ${s_ns} link set eth0 type bond_slave prio 1000000
+		ip -n ${s_ns} link set eth1 type bond_slave prio 0
+		ip -n ${s_ns} link set eth2 type bond_slave prio -50
+		ip -n ${s_ns} -d link show eth0 | grep -q 'prio 1000000'
+		check_err $? "eth0 prio is not 1000000"
+		ip -n ${s_ns} -d link show eth1 | grep -q 'prio 0'
+		check_err $? "eth1 prio is not 0"
+		ip -n ${s_ns} -d link show eth2 | grep -q 'prio -50'
+		check_err $? "eth3 prio is not -50"
+		check_active_slave "eth1"
+
+		ip -n ${s_ns} link set $active_slave down
+		ip netns exec ${s_ns} ping $c_ip4 -c5 -I bond0 &>/dev/null
+		check_err $? "ping failed 7."
+		check_active_slave "eth0"
+	fi
+}
+
+prio_miimon()
+{
+	local primary_reselect
+	local mode=$1
+
+	for primary_reselect in 0 1 2; do
+		prio_test "mode $mode miimon 100 primary eth1 primary_reselect $primary_reselect"
+		log_test "prio" "$mode miimon primary_reselect $primary_reselect"
+	done
+}
+
+prio_arp()
+{
+	local primary_reselect
+	local mode=$1
+
+	for primary_reselect in 0 1 2; do
+		prio_test "mode active-backup arp_interval 1000 arp_ip_target ${sw_ip4} primary eth1 primary_reselect $primary_reselect"
+		log_test "prio" "$mode arp_ip_target primary_reselect $primary_reselect"
+	done
+}
+
+prio_ns()
+{
+	local primary_reselect
+	local mode=$1
+
+	if skip_ns; then
+		log_test_skip "prio ns" "Current iproute or kernel doesn't support bond option 'ns_ip6_target'."
+		return 0
+	fi
+
+	for primary_reselect in 0 1 2; do
+		prio_test "mode active-backup arp_interval 1000 ns_ip6_target ${sw_ip6} primary eth1 primary_reselect $primary_reselect"
+		log_test "prio" "$mode ns_ip6_target primary_reselect $primary_reselect"
+	done
+}
+
+prio()
+{
+	local mode modes="active-backup balance-tlb balance-alb"
+
+	if skip_prio; then
+		log_test_skip "prio" "Current iproute or kernel doesn't support bond option 'prio'."
+		return 0
+	fi
+
+	for mode in $modes; do
+		prio_miimon $mode
+		prio_arp $mode
+		prio_ns $mode
+	done
+}
+
+trap cleanup EXIT
+
+setup_prepare
+setup_wait
+tests_run
+
+exit $EXIT_STATUS
tools/testing/selftests/drivers/net/bonding/option_prio.sh deleted +0 -245
deleted file mode 100755
index c32eebff5005..000000000000
@@ -1,245 +0,0 @@
-#!/bin/bash
-# SPDX-License-Identifier: GPL-2.0
-#
-# Test bonding option prio
-#
-
-ALL_TESTS="
-	prio_arp_ip_target_test
-	prio_miimon_test
-"
-
-REQUIRE_MZ=no
-REQUIRE_JQ=no
-NUM_NETIFS=0
-lib_dir=$(dirname "$0")
-source "$lib_dir"/net_forwarding_lib.sh
-
-destroy()
-{
-	ip link del bond0 &>/dev/null
-	ip link del br0 &>/dev/null
-	ip link del veth0 &>/dev/null
-	ip link del veth1 &>/dev/null
-	ip link del veth2 &>/dev/null
-	ip netns del ns1 &>/dev/null
-	ip link del veth3 &>/dev/null
-}
-
-cleanup()
-{
-	pre_cleanup
-
-	destroy
-}
-
-skip()
-{
-        local skip=1
-	ip link add name bond0 type bond mode 1 miimon 100 &>/dev/null
-	ip link add name veth0 type veth peer name veth0_p
-	ip link set veth0 master bond0
-
-	# check if iproute support prio option
-	ip link set dev veth0 type bond_slave prio 10
-	[[ $? -ne 0 ]] && skip=0
-
-	# check if bonding support prio option
-	ip -d link show veth0 | grep -q "prio 10"
-	[[ $? -ne 0 ]] && skip=0
-
-	ip link del bond0 &>/dev/null
-	ip link del veth0
-
-	return $skip
-}
-
-active_slave=""
-check_active_slave()
-{
-	local target_active_slave=$1
-	active_slave="$(cat /sys/class/net/bond0/bonding/activev_slave)"
-	test "$active_slave" = "$target_active_slave"
-	check_err $? "Current active slave is $active_slave but not $target_active_slave"
-}
-
-
-# Test bonding prio option with mode=$mode monitor=$monitor
-# and primary_reselect=$primary_reselect
-prio_test()
-{
-	RET=0
-
-	local monitor=$1
-	local mode=$2
-	local primary_reselect=$3
-
-	local bond_ip4="192.169.1.2"
-	local peer_ip4="192.169.1.1"
-	local bond_ip6="2009:0a:0b::02"
-	local peer_ip6="2009:0a:0b::01"
-
-
-	# create veths
-	ip link add name veth0 type veth peer name veth0_p
-	ip link add name veth1 type veth peer name veth1_p
-	ip link add name veth2 type veth peer name veth2_p
-
-	# create bond
-	if [[ "$monitor" == "miimon" ]];then
-		ip link add name bond0 type bond mode $mode miimon 100 primary veth1 primary_reselect $primary_reselect
-	elif [[ "$monitor" == "arp_ip_target" ]];then
-		ip link add name bond0 type bond mode $mode arp_interval 1000 arp_ip_target $peer_ip4 primary veth1 primary_reselect $primary_reselect
-	elif [[ "$monitor" == "ns_ip6_target" ]];then
-		ip link add name bond0 type bond mode $mode arp_interval 1000 ns_ip6_target $peer_ip6 primary veth1 primary_reselect $primary_reselect
-	fi
-	ip link set bond0 up
-	ip link set veth0 master bond0
-	ip link set veth1 master bond0
-	ip link set veth2 master bond0
-	# check bonding member prio value
-	ip link set dev veth0 type bond_slave prio 0
-	ip link set dev veth1 type bond_slave prio 10
-	ip link set dev veth2 type bond_slave prio 11
-	ip -d link show veth0 | grep -q 'prio 0'
-	check_err $? "veth0 prio is not 0"
-	ip -d link show veth1 | grep -q 'prio 10'
-	check_err $? "veth0 prio is not 10"
-	ip -d link show veth2 | grep -q 'prio 11'
-	check_err $? "veth0 prio is not 11"
-
-	ip link set veth0 up
-	ip link set veth1 up
-	ip link set veth2 up
-	ip link set veth0_p up
-	ip link set veth1_p up
-	ip link set veth2_p up
-
-	# prepare ping target
-	ip link add name br0 type bridge
-	ip link set br0 up
-	ip link set veth0_p master br0
-	ip link set veth1_p master br0
-	ip link set veth2_p master br0
-	ip link add name veth3 type veth peer name veth3_p
-	ip netns add ns1
-	ip link set veth3_p master br0 up
-	ip link set veth3 netns ns1 up
-	ip netns exec ns1 ip addr add $peer_ip4/24 dev veth3
-	ip netns exec ns1 ip addr add $peer_ip6/64 dev veth3
-	ip addr add $bond_ip4/24 dev bond0
-	ip addr add $bond_ip6/64 dev bond0
-	sleep 5
-
-	ping $peer_ip4 -c5 -I bond0 &>/dev/null
-	check_err $? "ping failed 1."
-	ping6 $peer_ip6 -c5 -I bond0 &>/dev/null
-	check_err $? "ping6 failed 1."
-
-	# active salve should be the primary slave
-	check_active_slave veth1
-
-	# active slave should be the higher prio slave
-	ip link set $active_slave down
-	ping $peer_ip4 -c5 -I bond0 &>/dev/null
-	check_err $? "ping failed 2."
-	check_active_slave veth2
-
-	# when only 1 slave is up
-	ip link set $active_slave down
-	ping $peer_ip4 -c5 -I bond0 &>/dev/null
-	check_err $? "ping failed 3."
-	check_active_slave veth0
-
-	# when a higher prio slave change to up
-	ip link set veth2 up
-	ping $peer_ip4 -c5 -I bond0 &>/dev/null
-	check_err $? "ping failed 4."
-	case $primary_reselect in
-		"0")
-			check_active_slave "veth2"
-			;;
-		"1")
-			check_active_slave "veth0"
-			;;
-		"2")
-			check_active_slave "veth0"
-			;;
-	esac
-	local pre_active_slave=$active_slave
-
-	# when the primary slave change to up
-	ip link set veth1 up
-	ping $peer_ip4 -c5 -I bond0 &>/dev/null
-	check_err $? "ping failed 5."
-	case $primary_reselect in
-		"0")
-			check_active_slave "veth1"
-			;;
-		"1")
-			check_active_slave "$pre_active_slave"
-			;;
-		"2")
-			check_active_slave "$pre_active_slave"
-			ip link set $active_slave down
-			ping $peer_ip4 -c5 -I bond0 &>/dev/null
-			check_err $? "ping failed 6."
-			check_active_slave "veth1"
-			;;
-	esac
-
-	# Test changing bond salve prio
-	if [[ "$primary_reselect" == "0" ]];then
-		ip link set dev veth0 type bond_slave prio 1000000
-		ip link set dev veth1 type bond_slave prio 0
-		ip link set dev veth2 type bond_slave prio -50
-		ip -d link show veth0 | grep -q 'prio 1000000'
-		check_err $? "veth0 prio is not 1000000"
-		ip -d link show veth1 | grep -q 'prio 0'
-		check_err $? "veth1 prio is not 0"
-		ip -d link show veth2 | grep -q 'prio -50'
-		check_err $? "veth3 prio is not -50"
-		check_active_slave "veth1"
-
-		ip link set $active_slave down
-		ping $peer_ip4 -c5 -I bond0 &>/dev/null
-		check_err $? "ping failed 7."
-		check_active_slave "veth0"
-	fi
-
-	cleanup
-
-	log_test "prio_test" "Test bonding option 'prio' with mode=$mode monitor=$monitor and primary_reselect=$primary_reselect"
-}
-
-prio_miimon_test()
-{
-	local mode
-	local primary_reselect
-
-	for mode in 1 5 6; do
-		for primary_reselect in 0 1 2; do
-			prio_test "miimon" $mode $primary_reselect
-		done
-	done
-}
-
-prio_arp_ip_target_test()
-{
-	local primary_reselect
-
-	for primary_reselect in 0 1 2; do
-		prio_test "arp_ip_target" 1 $primary_reselect
-	done
-}
-
-if skip;then
-	log_test_skip "option_prio.sh" "Current iproute doesn't support 'prio'."
-	exit 0
-fi
-
-trap cleanup EXIT
-
-tests_run
-
-exit "$EXIT_STATUS"
Signature · 1 line
2.38.1
#12 lore raw

PATCH 3/3 selftests: bonding: add arp validate test

In reply to Hangbin Liu

This patch add bonding arp validate tests with mode active backup, monitor arp_ip_target and ns_ip6_target. It also checks mii_status to make sure all slaves are UP.

---
 .../drivers/net/bonding/bond_options.sh       | 55 +++++++++++++++++++
 1 file changed, 55 insertions(+)
tools/testing/selftests/drivers/net/bonding/bond_options.sh +55 -0
index 431ce0e45e3c..4909d529210c 100755
@@ -5,6 +5,7 @@
 
 ALL_TESTS="
 	prio
+	arp_validate
 "
 
 REQUIRE_MZ=no
@@ -207,6 +208,60 @@ prio()
 	done
 }
 
+arp_validate_test()
+{
+	local param="$1"
+	RET=0
+
+	# create bond
+	bond_reset "${param}"
+
+	bond_check_connection
+	[ $RET -ne 0 ] && log_test "arp_validate" "$retmsg"
+
+	# wait for a while to make sure the mii status stable
+	sleep 5
+	for i in $(seq 0 2); do
+		mii_status=$(cmd_jq "ip -n ${s_ns} -j -d link show eth$i" ".[].linkinfo.info_slave_data.mii_status")
+		if [ ${mii_status} != "UP" ]; then
+			RET=1
+			log_test "arp_validate" "interface eth$i mii_status $mii_status"
+		fi
+	done
+}
+
+arp_validate_arp()
+{
+	local mode=$1
+	local val
+	for val in $(seq 0 6); do
+		arp_validate_test "mode $mode arp_interval 1000 arp_ip_target ${sw_ip4} arp_validate $val"
+		log_test "arp_validate" "mode $mode arp_ip_target arp_validate $val"
+	done
+}
+
+arp_validate_ns()
+{
+	local mode=$1
+	local val
+
+	if skip_ns; then
+		log_test_skip "arp_validate ns" "Current iproute or kernel doesn't support bond option 'ns_ip6_target'."
+		return 0
+	fi
+
+	for val in $(seq 0 6); do
+		arp_validate_test "mode $mode arp_interval 1000 ns_ip6_target ${sw_ip6} arp_validate $val"
+		log_test "arp_validate" "mode $mode ns_ip6_target arp_validate $val"
+	done
+}
+
+arp_validate()
+{
+	arp_validate_arp "active-backup"
+	arp_validate_ns "active-backup"
+}
+
 trap cleanup EXIT
 
 setup_prepare
Signature · 1 line
2.38.1
Acked-by on v1 3/3
#14 lore raw

Re: [PATCH net 3/3] selftests: bonding: add arp validate test

In reply to Hangbin Liu
Quoted 5 lines · Hangbin Liu

This patch add bonding arp validate tests with mode active backup, monitor arp_ip_target and ns_ip6_target. It also checks mii_status to make sure all slaves are UP.

Quoted 80 lines

---
.../drivers/net/bonding/bond_options.sh | 55 +++++++++++++++++++

1 file changed, 55 insertions(+)
tools/testing/selftests/drivers/net/bonding/bond_options.sh +0 -0
index 431ce0e45e3c..4909d529210c 100755
@@ -5,6 +5,7 @@
 

ALL_TESTS="
prio

tools/testing/selftests/drivers/net/bonding/bond_options.sh +1 -0
+	arp_validate

"

REQUIRE_MZ=no

tools/testing/selftests/drivers/net/bonding/bond_options.sh +54 -0
@@ -207,6 +208,60 @@ prio()
 	done
 }
 
+arp_validate_test()
+{
+	local param="$1"
+	RET=0
+
+	# create bond
+	bond_reset "${param}"
+
+	bond_check_connection
+	[ $RET -ne 0 ] && log_test "arp_validate" "$retmsg"
+
+	# wait for a while to make sure the mii status stable
+	sleep 5
+	for i in $(seq 0 2); do
+		mii_status=$(cmd_jq "ip -n ${s_ns} -j -d link show eth$i" ".[].linkinfo.info_slave_data.mii_status")
+		if [ ${mii_status} != "UP" ]; then
+			RET=1
+			log_test "arp_validate" "interface eth$i mii_status $mii_status"
+		fi
+	done
+}
+
+arp_validate_arp()
+{
+	local mode=$1
+	local val
+	for val in $(seq 0 6); do
+		arp_validate_test "mode $mode arp_interval 1000 arp_ip_target ${sw_ip4} arp_validate $val"
+		log_test "arp_validate" "mode $mode arp_ip_target arp_validate $val"
+	done
+}
+
+arp_validate_ns()
+{
+	local mode=$1
+	local val
+
+	if skip_ns; then
+		log_test_skip "arp_validate ns" "Current iproute or kernel doesn't support bond option 'ns_ip6_target'."
+		return 0
+	fi
+
+	for val in $(seq 0 6); do
+		arp_validate_test "mode $mode arp_interval 1000 ns_ip6_target ${sw_ip6} arp_validate $val"
+		log_test "arp_validate" "mode $mode ns_ip6_target arp_validate $val"
+	done
+}
+
+arp_validate()
+{
+	arp_validate_arp "active-backup"
+	arp_validate_ns "active-backup"
+}
+

trap cleanup EXIT

setup_prepare

Signature · 1 line
2.38.1