Skip to contentSkip to conversation

Decouple receive and transmit enablement in team driver

PATCH Superseded Marc Harvey 3 participants 25 messages Apr 6 – Apr 8

Subsystems (5)

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v5 cover Decouple receive and transmit enablement in team driver

Allow independent control over receive and transmit enablement states for aggregated ports in the team driver.

The motivation is that IEE 802.3ad LACP "independent control" can't be implemented for the team driver currently. This was added to the bonding driver in commit 240fd405528b ("bonding: Add independent control state machine").

This series also has a few patches that add tests to show that the old coupled enablement still works and that the new decoupled enablement works as intended (4, 5, and 10).

There are three patches with small fixes as well, with the goal of making the final decoupling patch clearer (1, 2, and 3).

---
Changes in v5:
- Change teamd activebackup selftest in patch 5 to try graceful teamd
teardown before using sigkill.
- Make the teamd activebackup selftest in patch 5 delete leftover
teamd files during teardown.
- Reorder function calls in team_port_enable function in patch 7,
since the enablement behavior shouldn't change.
- Make selftests use tcpdump instead of checking rx counters.
- Fix minor typos in patch 10.
- Link to v4: https://lore.kernel.org/r/[email protected]

Changes in v4:
- Split the large v3 patch "net: team: Decouple rx and tx enablement
in the team driver" into 4 smaller patches.
- Link to v3: https://lore.kernel.org/r/[email protected]

Changes in v3:
- Patch 5: In test cleanup, kill teamd to fix timeout.
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- Patch 4 and 5: Fix shellcheck errors and warnings, use iperf3
instead of netcat+pv, fix dependency checking.
- Patch 7: Fix shellcheck errors and warnings, fix dependency
checking.
- Link to v1: https://lore.kernel.org/all/[email protected]/

---
Marc Harvey (10):
net: team: Annotate reads and writes for mixed lock accessed values
net: team: Remove unused team_mode_op, port_enabled
net: team: Rename port_disabled team mode op to port_tx_disabled
selftests: net: Add tests for failover of team-aggregated ports
selftests: net: Add test for enablement of ports with teamd
net: team: Rename enablement functions and struct members to tx
net: team: Track rx enablement separately from tx enablement
net: team: Add new rx_enabled team port option
net: team: Add new tx_enabled team port option
selftests: net: Add tests for team driver decoupled tx and rx control

 drivers/net/team/team_core.c                       | 237 +++++++++++++++----
 drivers/net/team/team_mode_loadbalance.c           |   8 +-
 drivers/net/team/team_mode_random.c                |   4 +-
 drivers/net/team/team_mode_roundrobin.c            |   2 +-
 include/linux/if_team.h                            |  63 ++++--
 tools/testing/selftests/drivers/net/team/Makefile  |   4 +
 tools/testing/selftests/drivers/net/team/config    |   4 +
 .../drivers/net/team/decoupled_enablement.sh       | 249 ++++++++++++++++++++
 .../testing/selftests/drivers/net/team/options.sh  |  99 +++++++-
 .../testing/selftests/drivers/net/team/team_lib.sh | 172 ++++++++++++++
 .../drivers/net/team/teamd_activebackup.sh         | 251 +++++++++++++++++++++
 .../drivers/net/team/transmit_failover.sh          | 158 +++++++++++++
 tools/testing/selftests/net/forwarding/lib.sh      |   7 +-
 tools/testing/selftests/net/lib.sh                 |  13 ++
 14 files changed, 1199 insertions(+), 72 deletions(-)

---
base-commit: 3741f8fa004bf598cd5032b0ff240984332d6f05
change-id: 20260401-teaming-driver-internal-83f2f0074d68

Best regards,

Signature · 1 line
Marc Harvey <[email protected]>
#1 lore raw

PATCH v5 1/10 net: team: Annotate reads and writes for mixed lock accessed values

The team_port's "index" and the team's "en_port_count" are read in the hot transmit path, but are only written to when holding the rtnl lock.

Use READ_ONCE() for all lockless reads of these values, and use WRITE_ONCE() for all writes.

---
Changes in v5:
- None

Changes in v4:
- None

Changes in v3:
- None

Changes in v2:
- None

---
 drivers/net/team/team_core.c        | 11 ++++++-----
 drivers/net/team/team_mode_random.c |  2 +-
 include/linux/if_team.h             |  4 ++--
 3 files changed, 9 insertions(+), 8 deletions(-)
drivers/net/team/team_core.c +6 -5
index 566a5d102c23..becd066279a6 100644
@@ -938,7 +938,8 @@ static void team_port_enable(struct team *team,
 {
 	if (team_port_enabled(port))
 		return;
-	port->index = team->en_port_count++;
+	WRITE_ONCE(port->index, team->en_port_count);
+	WRITE_ONCE(team->en_port_count, team->en_port_count + 1);
 	hlist_add_head_rcu(&port->hlist,
 			   team_port_index_hash(team, port->index));
 	team_adjust_ops(team);
@@ -958,7 +959,7 @@ static void __reconstruct_port_hlist(struct team *team, int rm_index)
 	for (i = rm_index + 1; i < team->en_port_count; i++) {
 		port = team_get_port_by_index(team, i);
 		hlist_del_rcu(&port->hlist);
-		port->index--;
+		WRITE_ONCE(port->index, port->index - 1);
 		hlist_add_head_rcu(&port->hlist,
 				   team_port_index_hash(team, port->index));
 	}
@@ -973,8 +974,8 @@ static void team_port_disable(struct team *team,
 		team->ops.port_disabled(team, port);
 	hlist_del_rcu(&port->hlist);
 	__reconstruct_port_hlist(team, port->index);
-	port->index = -1;
-	team->en_port_count--;
+	WRITE_ONCE(port->index, -1);
+	WRITE_ONCE(team->en_port_count, team->en_port_count - 1);
 	team_queue_override_port_del(team, port);
 	team_adjust_ops(team);
 	team_lower_state_changed(port);
@@ -1245,7 +1246,7 @@ static int team_port_add(struct team *team, struct net_device *port_dev,
 		netif_addr_unlock_bh(dev);
 	}
 
-	port->index = -1;
+	WRITE_ONCE(port->index, -1);
 	list_add_tail_rcu(&port->list, &team->port_list);
 	team_port_enable(team, port);
 	netdev_compute_master_upper_features(dev, true);
drivers/net/team/team_mode_random.c +1 -1
index 53d0ce34b8ce..169a7bc865b2 100644
@@ -16,7 +16,7 @@ static bool rnd_transmit(struct team *team, struct sk_buff *skb)
 	struct team_port *port;
 	int port_index;
 
-	port_index = get_random_u32_below(team->en_port_count);
+	port_index = get_random_u32_below(READ_ONCE(team->en_port_count));
 	port = team_get_port_by_index_rcu(team, port_index);
 	if (unlikely(!port))
 		goto drop;
include/linux/if_team.h +2 -2
index ccb5327de26d..06f4d7400c1e 100644
@@ -77,7 +77,7 @@ static inline struct team_port *team_port_get_rcu(const struct net_device *dev)
 
 static inline bool team_port_enabled(struct team_port *port)
 {
-	return port->index != -1;
+	return READ_ONCE(port->index) != -1;
 }
 
 static inline bool team_port_txable(struct team_port *port)
@@ -272,7 +272,7 @@ static inline struct team_port *team_get_port_by_index_rcu(struct team *team,
 	struct hlist_head *head = team_port_index_hash(team, port_index);
 
 	hlist_for_each_entry_rcu(port, head, hlist)
-		if (port->index == port_index)
+		if (READ_ONCE(port->index) == port_index)
 			return port;
 	return NULL;
 }
Signature · 1 line
2.53.0.1185.g05d4b7b318-goog
#3 lore raw

PATCH v5 2/10 net: team: Remove unused team_mode_op, port_enabled

In reply to Marc Harvey

This team_mode_op wasn't used by any of the team modes, so remove it.

---
Changes in v5:
- None

Changes in v4:
- None

Changes in v3:
- None

Changes in v2:
- None

---
 drivers/net/team/team_core.c | 2 --
 include/linux/if_team.h      | 1 -
 2 files changed, 3 deletions(-)
drivers/net/team/team_core.c +0 -2
index becd066279a6..e54bd21bd068 100644
@@ -944,8 +944,6 @@ static void team_port_enable(struct team *team,
 			   team_port_index_hash(team, port->index));
 	team_adjust_ops(team);
 	team_queue_override_port_add(team, port);
-	if (team->ops.port_enabled)
-		team->ops.port_enabled(team, port);
 	team_notify_peers(team);
 	team_mcast_rejoin(team);
 	team_lower_state_changed(port);
include/linux/if_team.h +0 -1
index 06f4d7400c1e..a761f5282bcf 100644
@@ -121,7 +121,6 @@ struct team_mode_ops {
 	int (*port_enter)(struct team *team, struct team_port *port);
 	void (*port_leave)(struct team *team, struct team_port *port);
 	void (*port_change_dev_addr)(struct team *team, struct team_port *port);
-	void (*port_enabled)(struct team *team, struct team_port *port);
 	void (*port_disabled)(struct team *team, struct team_port *port);
 };
 
Signature · 1 line
2.53.0.1185.g05d4b7b318-goog
#5 lore raw

PATCH v5 3/10 net: team: Rename port_disabled team mode op to port_tx_disabled

In reply to Marc Harvey

This team mode op is only used by the load balance mode, and it only uses it in the tx path.

---
Changes in v5:
- None

Changes in v4:
- None

Changes in v3:
- None

Changes in v2:
- None

---
 drivers/net/team/team_core.c             | 4 ++--
 drivers/net/team/team_mode_loadbalance.c | 4 ++--
 include/linux/if_team.h                  | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/team/team_core.c +2 -2
index e54bd21bd068..2ce31999c99f 100644
@@ -968,8 +968,8 @@ static void team_port_disable(struct team *team,
 {
 	if (!team_port_enabled(port))
 		return;
-	if (team->ops.port_disabled)
-		team->ops.port_disabled(team, port);
+	if (team->ops.port_tx_disabled)
+		team->ops.port_tx_disabled(team, port);
 	hlist_del_rcu(&port->hlist);
 	__reconstruct_port_hlist(team, port->index);
 	WRITE_ONCE(port->index, -1);
drivers/net/team/team_mode_loadbalance.c +2 -2
index 684954c2a8de..840f409d250b 100644
@@ -655,7 +655,7 @@ static void lb_port_leave(struct team *team, struct team_port *port)
 	free_percpu(lb_port_priv->pcpu_stats);
 }
 
-static void lb_port_disabled(struct team *team, struct team_port *port)
+static void lb_port_tx_disabled(struct team *team, struct team_port *port)
 {
 	lb_tx_hash_to_port_mapping_null_port(team, port);
 }
@@ -665,7 +665,7 @@ static const struct team_mode_ops lb_mode_ops = {
 	.exit			= lb_exit,
 	.port_enter		= lb_port_enter,
 	.port_leave		= lb_port_leave,
-	.port_disabled		= lb_port_disabled,
+	.port_tx_disabled	= lb_port_tx_disabled,
 	.receive		= lb_receive,
 	.transmit		= lb_transmit,
 };
include/linux/if_team.h +1 -1
index a761f5282bcf..740cb3100dfc 100644
@@ -121,7 +121,7 @@ struct team_mode_ops {
 	int (*port_enter)(struct team *team, struct team_port *port);
 	void (*port_leave)(struct team *team, struct team_port *port);
 	void (*port_change_dev_addr)(struct team *team, struct team_port *port);
-	void (*port_disabled)(struct team *team, struct team_port *port);
+	void (*port_tx_disabled)(struct team *team, struct team_port *port);
 };
 
 extern int team_modeop_port_enter(struct team *team, struct team_port *port);
Signature · 1 line
2.53.0.1185.g05d4b7b318-goog
#6 lore raw

PATCH v5 4/10 selftests: net: Add tests for failover of team-aggregated ports

In reply to Marc Harvey

There are currently no kernel tests that verify the effect of setting the enabled team driver option. In a followup patch, there will be changes to this option, so it will be important to make sure it still behaves as it does now.

The test verifies that tcp continues to work across two different team devices in separate network namespaces, even when member links are manually disabled.

---
Changes in v5:
- Use tcpdump for collecting traffic, rather than reading rx counters.
- Link to v4: https://lore.kernel.org/netdev/[email protected]/

Changes in v4:
- None

Changes in v3:
- None

Changes in v2:
- Fix shellcheck failures.
- Remove dependency on net forwarding lib and pipe viewer tools.
- Use iperf3 for tcp instead of netcat.
- Link to v1: https://lore.kernel.org/all/[email protected]/

---
 tools/testing/selftests/drivers/net/team/Makefile  |   2 +
 tools/testing/selftests/drivers/net/team/config    |   4 +
 .../testing/selftests/drivers/net/team/team_lib.sh | 146 +++++++++++++++++++
 .../drivers/net/team/transmit_failover.sh          | 158 +++++++++++++++++++++
 tools/testing/selftests/net/forwarding/lib.sh      |   7 +-
 5 files changed, 316 insertions(+), 1 deletion(-)
tools/testing/selftests/drivers/net/team/Makefile +2 -0
index 02d6f51d5a06..777da2e0429e 100644
@@ -7,9 +7,11 @@ TEST_PROGS := \
 	options.sh \
 	propagation.sh \
 	refleak.sh \
+	transmit_failover.sh \
 # end of TEST_PROGS
 
 TEST_INCLUDES := \
+	team_lib.sh \
 	../bonding/lag_lib.sh \
 	../../../net/forwarding/lib.sh \
 	../../../net/in_netns.sh \
tools/testing/selftests/drivers/net/team/config +4 -0
index 5d36a22ef080..8f04ae419c53 100644
@@ -6,4 +6,8 @@ CONFIG_NETDEVSIM=m
 CONFIG_NET_IPGRE=y
 CONFIG_NET_TEAM=y
 CONFIG_NET_TEAM_MODE_ACTIVEBACKUP=y
+CONFIG_NET_TEAM_MODE_BROADCAST=y
 CONFIG_NET_TEAM_MODE_LOADBALANCE=y
+CONFIG_NET_TEAM_MODE_RANDOM=y
+CONFIG_NET_TEAM_MODE_ROUNDROBIN=y
+CONFIG_VETH=y
tools/testing/selftests/drivers/net/team/team_lib.sh new file +146 -0

146 lines not on this page · raw message

tools/testing/selftests/drivers/net/team/transmit_failover.sh new file +158 -0

158 lines not on this page · raw message

tools/testing/selftests/net/forwarding/lib.sh +6 -1
index d8cc4c64148d..a1017b11e3ea 100644
@@ -1749,12 +1749,17 @@ tcpdump_start()
 	sleep 1
 }
 
-tcpdump_stop()
+tcpdump_stop_nosleep()
 {
 	local if_name=$1
 	local pid=${cappid[$if_name]}
 
 	$ns_cmd kill "$pid" && wait "$pid"
+}
+
+tcpdump_stop()
+{
+	tcpdump_stop_nosleep "$1"
 	sleep 1
 }
 
Signature · 1 line
2.53.0.1185.g05d4b7b318-goog
#7 lore raw

PATCH v5 5/10 selftests: net: Add test for enablement of ports with teamd

In reply to Marc Harvey

There are no tests that verify enablement and disablement of team driver ports with teamd. This should work even with changes to the enablement option, so it is important to test.

This test sets up an active-backup network configuration across two network namespaces, and tries to send traffic while changing which link is the active one.

---
Changes in v5:
- Make test wait for inactive link to stop receiving traffic after
setting it to inactive, since there was a race condition.
- Change test teardown to try graceful shutdown first, then use
sigkill if needed.
- Manually delete leftover teamd files during teardown.
- Use tcpdump instead of checking rx counters.
- Link to v4: https://lore.kernel.org/netdev/[email protected]/

Changes in v4:
- None

Changed in v3:
- Make test cleanup kill teamd instead of terminate.
- Link to v2: https://lore.kernel.org/netdev/[email protected]/

Changes in v2:
- Fix shellcheck failures.
- Remove dependency on net forwarding lib and pipe viewer tools.
- Use iperf3 for tcp instead of netcat.
- Link to v1: https://lore.kernel.org/all/[email protected]/

---
 tools/testing/selftests/drivers/net/team/Makefile  |   1 +
 .../testing/selftests/drivers/net/team/team_lib.sh |  26 +++
 .../drivers/net/team/teamd_activebackup.sh         | 251 +++++++++++++++++++++
 tools/testing/selftests/net/lib.sh                 |  13 ++
 4 files changed, 291 insertions(+)
tools/testing/selftests/drivers/net/team/Makefile +1 -0
index 777da2e0429e..dab922d7f83d 100644
@@ -7,6 +7,7 @@ TEST_PROGS := \
 	options.sh \
 	propagation.sh \
 	refleak.sh \
+	teamd_activebackup.sh \
 	transmit_failover.sh \
 # end of TEST_PROGS
 
tools/testing/selftests/drivers/net/team/team_lib.sh +26 -0
index a3102bdcb99c..43db0be19a42 100644
@@ -144,3 +144,29 @@ did_interface_receive()
 		false
 	fi
 }
+
+# Return true if the given interface in the given namespace does NOT receive
+# traffic over a 1 second period.
+# Arguments:
+#   interface - The name of the interface.
+#   ip_address - The destination IP address.
+#   namespace - The name of the namespace that the interface is in.
+check_no_traffic()
+{
+	local interface="$1"
+	local ip_address="$2"
+	local namespace="$3"
+	local rc
+
+	save_tcpdump_outputs "${namespace}" "${interface}"
+	did_interface_receive "${interface}" "${ip_address}"
+	rc=$?
+
+	clear_tcpdump_outputs "${interface}"
+
+	if [[ "${rc}" -eq 0 ]]; then
+		return 1
+	else
+		return 0
+	fi
+}
tools/testing/selftests/drivers/net/team/teamd_activebackup.sh new file +251 -0

251 lines not on this page · raw message

tools/testing/selftests/net/lib.sh +13 -0
index e915386daf1b..b3827b43782b 100644
@@ -224,6 +224,19 @@ setup_ns()
 	NS_LIST+=("${ns_list[@]}")
 }
 
+in_all_ns()
+{
+	local ret=0
+	local ns_list=("${NS_LIST[@]}")
+
+	for ns in "${ns_list[@]}"; do
+		ip netns exec "${ns}" "$@"
+		(( ret = ret || $? ))
+	done
+
+	return "${ret}"
+}
+
 # Create netdevsim with given id and net namespace.
 create_netdevsim() {
     local id="$1"
Signature · 1 line
2.53.0.1185.g05d4b7b318-goog
#8 lore raw

PATCH v5 6/10 net: team: Rename enablement functions and struct members to tx

In reply to Marc Harvey

Add no functional changes, but rename enablement functions, variables etc. that are used in teaming driver transmit decisions.

Since rx and tx enablement are still coupled, some of the variables renamed in this patch are still used for the rx path, but that will change in a follow-up patch.

---
Changes in v5:
- None

Changes in v4:
- New patch: split from the original monolithic v3 patch "net: team:
Decouple rx and tx enablement in the team driver".
- Link to v3: https://lore.kernel.org/netdev/[email protected]/

---
 drivers/net/team/team_core.c             | 44 +++++++++++++++---------------
 drivers/net/team/team_mode_loadbalance.c |  2 +-
 drivers/net/team/team_mode_random.c      |  4 +--
 drivers/net/team/team_mode_roundrobin.c  |  2 +-
 include/linux/if_team.h                  | 46 +++++++++++++++++---------------
 5 files changed, 51 insertions(+), 47 deletions(-)
drivers/net/team/team_core.c +23 -21
index 2ce31999c99f..826769473878 100644
@@ -532,13 +532,13 @@ static void team_adjust_ops(struct team *team)
 	 * correct ops are always set.
 	 */
 
-	if (!team->en_port_count || !team_is_mode_set(team) ||
+	if (!team->tx_en_port_count || !team_is_mode_set(team) ||
 	    !team->mode->ops->transmit)
 		team->ops.transmit = team_dummy_transmit;
 	else
 		team->ops.transmit = team->mode->ops->transmit;
 
-	if (!team->en_port_count || !team_is_mode_set(team) ||
+	if (!team->tx_en_port_count || !team_is_mode_set(team) ||
 	    !team->mode->ops->receive)
 		team->ops.receive = team_dummy_receive;
 	else
@@ -831,7 +831,7 @@ static bool team_queue_override_port_has_gt_prio_than(struct team_port *port,
 		return true;
 	if (port->priority > cur->priority)
 		return false;
-	if (port->index < cur->index)
+	if (port->tx_index < cur->tx_index)
 		return true;
 	return false;
 }
@@ -929,7 +929,7 @@ static bool team_port_find(const struct team *team,
 
 /*
  * Enable/disable port by adding to enabled port hashlist and setting
- * port->index (Might be racy so reader could see incorrect ifindex when
+ * port->tx_index (Might be racy so reader could see incorrect ifindex when
  * processing a flying packet, but that is not a problem). Write guarded
  * by RTNL.
  */
@@ -938,10 +938,10 @@ static void team_port_enable(struct team *team,
 {
 	if (team_port_enabled(port))
 		return;
-	WRITE_ONCE(port->index, team->en_port_count);
-	WRITE_ONCE(team->en_port_count, team->en_port_count + 1);
-	hlist_add_head_rcu(&port->hlist,
-			   team_port_index_hash(team, port->index));
+	WRITE_ONCE(port->tx_index, team->tx_en_port_count);
+	WRITE_ONCE(team->tx_en_port_count, team->tx_en_port_count + 1);
+	hlist_add_head_rcu(&port->tx_hlist,
+			   team_tx_port_index_hash(team, port->tx_index));
 	team_adjust_ops(team);
 	team_queue_override_port_add(team, port);
 	team_notify_peers(team);
@@ -951,15 +951,17 @@ static void team_port_enable(struct team *team,
 
 static void __reconstruct_port_hlist(struct team *team, int rm_index)
 {
-	int i;
+	struct hlist_head *tx_port_index_hash;
 	struct team_port *port;
+	int i;
 
-	for (i = rm_index + 1; i < team->en_port_count; i++) {
-		port = team_get_port_by_index(team, i);
-		hlist_del_rcu(&port->hlist);
-		WRITE_ONCE(port->index, port->index - 1);
-		hlist_add_head_rcu(&port->hlist,
-				   team_port_index_hash(team, port->index));
+	for (i = rm_index + 1; i < team->tx_en_port_count; i++) {
+		port = team_get_port_by_tx_index(team, i);
+		hlist_del_rcu(&port->tx_hlist);
+		WRITE_ONCE(port->tx_index, port->tx_index - 1);
+		tx_port_index_hash = team_tx_port_index_hash(team,
+							     port->tx_index);
+		hlist_add_head_rcu(&port->tx_hlist, tx_port_index_hash);
 	}
 }
 
@@ -970,10 +972,10 @@ static void team_port_disable(struct team *team,
 		return;
 	if (team->ops.port_tx_disabled)
 		team->ops.port_tx_disabled(team, port);
-	hlist_del_rcu(&port->hlist);
-	__reconstruct_port_hlist(team, port->index);
-	WRITE_ONCE(port->index, -1);
-	WRITE_ONCE(team->en_port_count, team->en_port_count - 1);
+	hlist_del_rcu(&port->tx_hlist);
+	__reconstruct_port_hlist(team, port->tx_index);
+	WRITE_ONCE(port->tx_index, -1);
+	WRITE_ONCE(team->tx_en_port_count, team->tx_en_port_count - 1);
 	team_queue_override_port_del(team, port);
 	team_adjust_ops(team);
 	team_lower_state_changed(port);
@@ -1244,7 +1246,7 @@ static int team_port_add(struct team *team, struct net_device *port_dev,
 		netif_addr_unlock_bh(dev);
 	}
 
-	WRITE_ONCE(port->index, -1);
+	WRITE_ONCE(port->tx_index, -1);
 	list_add_tail_rcu(&port->list, &team->port_list);
 	team_port_enable(team, port);
 	netdev_compute_master_upper_features(dev, true);
@@ -1595,7 +1597,7 @@ static int team_init(struct net_device *dev)
 		return -ENOMEM;
 
 	for (i = 0; i < TEAM_PORT_HASHENTRIES; i++)
-		INIT_HLIST_HEAD(&team->en_port_hlist[i]);
+		INIT_HLIST_HEAD(&team->tx_en_port_hlist[i]);
 	INIT_LIST_HEAD(&team->port_list);
 	err = team_queue_override_init(team);
 	if (err)
drivers/net/team/team_mode_loadbalance.c +1 -1
index 840f409d250b..4833fbfe241e 100644
@@ -120,7 +120,7 @@ static struct team_port *lb_hash_select_tx_port(struct team *team,
 {
 	int port_index = team_num_to_port_index(team, hash);
 
-	return team_get_port_by_index_rcu(team, port_index);
+	return team_get_port_by_tx_index_rcu(team, port_index);
 }
 
 /* Hash to port mapping select tx port */
drivers/net/team/team_mode_random.c +2 -2
index 169a7bc865b2..370e974f3dca 100644
@@ -16,8 +16,8 @@ static bool rnd_transmit(struct team *team, struct sk_buff *skb)
 	struct team_port *port;
 	int port_index;
 
-	port_index = get_random_u32_below(READ_ONCE(team->en_port_count));
-	port = team_get_port_by_index_rcu(team, port_index);
+	port_index = get_random_u32_below(READ_ONCE(team->tx_en_port_count));
+	port = team_get_port_by_tx_index_rcu(team, port_index);
 	if (unlikely(!port))
 		goto drop;
 	port = team_get_first_port_txable_rcu(team, port);
drivers/net/team/team_mode_roundrobin.c +1 -1
index dd405d82c6ac..ecbeef28c221 100644
@@ -27,7 +27,7 @@ static bool rr_transmit(struct team *team, struct sk_buff *skb)
 
 	port_index = team_num_to_port_index(team,
 					    rr_priv(team)->sent_packets++);
-	port = team_get_port_by_index_rcu(team, port_index);
+	port = team_get_port_by_tx_index_rcu(team, port_index);
 	if (unlikely(!port))
 		goto drop;
 	port = team_get_first_port_txable_rcu(team, port);
include/linux/if_team.h +24 -22

92 lines not on this page · raw message

Signature · 1 line
2.53.0.1185.g05d4b7b318-goog
#10 lore raw

PATCH v5 7/10 net: team: Track rx enablement separately from tx enablement

In reply to Marc Harvey

Separate the rx and tx enablement/disablement into different functions so that it is easier to interact with them independently later.

Although this patch changes receive and transmit paths, the actual behavior of the teaming driver should remain unchanged, since there is no option introduced yet to change rx or tx enablement independently. Those options will be added in follow-up patches.

---
Changes in v5:
- Reorder function calls in team_port_enable() to make sure the call
order stays the same as before.
- Link to v4: https://lore.kernel.org/netdev/[email protected]/

Changes in v4:
- New patch: split from the original monolithic v3 patch "net: team:
Decouple rx and tx enablement in the team driver".
- Link to v3: https://lore.kernel.org/netdev/[email protected]/

---
 drivers/net/team/team_core.c             | 104 ++++++++++++++++++++++++-------
 drivers/net/team/team_mode_loadbalance.c |   2 +-
 include/linux/if_team.h                  |  16 ++++-
 3 files changed, 95 insertions(+), 27 deletions(-)
drivers/net/team/team_core.c +80 -24
index 826769473878..e437099a5a17 100644
@@ -87,7 +87,7 @@ static void team_lower_state_changed(struct team_port *port)
 	struct netdev_lag_lower_state_info info;
 
 	info.link_up = port->linkup;
-	info.tx_enabled = team_port_enabled(port);
+	info.tx_enabled = team_port_tx_enabled(port);
 	netdev_lower_state_changed(port->dev, &info);
 }
 
@@ -538,7 +538,7 @@ static void team_adjust_ops(struct team *team)
 	else
 		team->ops.transmit = team->mode->ops->transmit;
 
-	if (!team->tx_en_port_count || !team_is_mode_set(team) ||
+	if (!team->rx_en_port_count || !team_is_mode_set(team) ||
 	    !team->mode->ops->receive)
 		team->ops.receive = team_dummy_receive;
 	else
@@ -734,7 +734,7 @@ static rx_handler_result_t team_handle_frame(struct sk_buff **pskb)
 
 	port = team_port_get_rcu(skb->dev);
 	team = port->team;
-	if (!team_port_enabled(port)) {
+	if (!team_port_rx_enabled(port)) {
 		if (is_link_local_ether_addr(eth_hdr(skb)->h_dest))
 			/* link-local packets are mostly useful when stack receives them
 			 * with the link they arrive on.
@@ -876,7 +876,7 @@ static void __team_queue_override_enabled_check(struct team *team)
 static void team_queue_override_port_prio_changed(struct team *team,
 						  struct team_port *port)
 {
-	if (!port->queue_id || !team_port_enabled(port))
+	if (!port->queue_id || !team_port_tx_enabled(port))
 		return;
 	__team_queue_override_port_del(team, port);
 	__team_queue_override_port_add(team, port);
@@ -887,7 +887,7 @@ static void team_queue_override_port_change_queue_id(struct team *team,
 						     struct team_port *port,
 						     u16 new_queue_id)
 {
-	if (team_port_enabled(port)) {
+	if (team_port_tx_enabled(port)) {
 		__team_queue_override_port_del(team, port);
 		port->queue_id = new_queue_id;
 		__team_queue_override_port_add(team, port);
@@ -927,26 +927,33 @@ static bool team_port_find(const struct team *team,
 	return false;
 }
 
+static void __team_port_enable_rx(struct team *team,
+				  struct team_port *port)
+{
+	team->rx_en_port_count++;
+	WRITE_ONCE(port->rx_enabled, true);
+}
+
+static void __team_port_disable_rx(struct team *team,
+				   struct team_port *port)
+{
+	team->rx_en_port_count--;
+	WRITE_ONCE(port->rx_enabled, false);
+}
+
 /*
- * Enable/disable port by adding to enabled port hashlist and setting
- * port->tx_index (Might be racy so reader could see incorrect ifindex when
- * processing a flying packet, but that is not a problem). Write guarded
- * by RTNL.
+ * Enable just TX on the port by adding to tx-enabled port hashlist and
+ * setting port->tx_index (Might be racy so reader could see incorrect
+ * ifindex when processing a flying packet, but that is not a problem).
+ * Write guarded by RTNL.
  */
-static void team_port_enable(struct team *team,
-			     struct team_port *port)
+static void __team_port_enable_tx(struct team *team,
+				  struct team_port *port)
 {
-	if (team_port_enabled(port))
-		return;
 	WRITE_ONCE(port->tx_index, team->tx_en_port_count);
 	WRITE_ONCE(team->tx_en_port_count, team->tx_en_port_count + 1);
 	hlist_add_head_rcu(&port->tx_hlist,
 			   team_tx_port_index_hash(team, port->tx_index));
-	team_adjust_ops(team);
-	team_queue_override_port_add(team, port);
-	team_notify_peers(team);
-	team_mcast_rejoin(team);
-	team_lower_state_changed(port);
 }
 
 static void __reconstruct_port_hlist(struct team *team, int rm_index)
@@ -965,20 +972,69 @@ static void __reconstruct_port_hlist(struct team *team, int rm_index)
 	}
 }
 
-static void team_port_disable(struct team *team,
-			      struct team_port *port)
+static void __team_port_disable_tx(struct team *team,
+				   struct team_port *port)
 {
-	if (!team_port_enabled(port))
-		return;
 	if (team->ops.port_tx_disabled)
 		team->ops.port_tx_disabled(team, port);
+
 	hlist_del_rcu(&port->tx_hlist);
 	__reconstruct_port_hlist(team, port->tx_index);
+
 	WRITE_ONCE(port->tx_index, -1);
 	WRITE_ONCE(team->tx_en_port_count, team->tx_en_port_count - 1);
-	team_queue_override_port_del(team, port);
+}
+
+/*
+ * Enable TX AND RX on the port.
+ */
+static void team_port_enable(struct team *team,
+			     struct team_port *port)
+{
+	bool rx_was_enabled;
+	bool tx_was_enabled;
+
+	if (team_port_enabled(port))
+		return;
+
+	rx_was_enabled = team_port_rx_enabled(port);
+	tx_was_enabled = team_port_tx_enabled(port);
+
+	if (!rx_was_enabled)
+		__team_port_enable_rx(team, port);
+	if (!tx_was_enabled)
+		__team_port_enable_tx(team, port);
+
+	team_adjust_ops(team);
+	if (!tx_was_enabled)
+		team_queue_override_port_add(team, port);
+	team_notify_peers(team);
+	if (!rx_was_enabled)
+		team_mcast_rejoin(team);
+	if (!tx_was_enabled)
+		team_lower_state_changed(port);
+}
+
+static void team_port_disable(struct team *team,
+			      struct team_port *port)
+{
+	bool rx_was_enabled = team_port_rx_enabled(port);
+	bool tx_was_enabled = team_port_tx_enabled(port);
+
+	if (!tx_was_enabled && !rx_was_enabled)
+		return;
+
+	if (tx_was_enabled) {
+		__team_port_disable_tx(team, port);
+		team_queue_override_port_del(team, port);
+	}
+	if (rx_was_enabled)
+		__team_port_disable_rx(team, port);
+
 	team_adjust_ops(team);
-	team_lower_state_changed(port);
+
+	if (tx_was_enabled)
+		team_lower_state_changed(port);
 }
 
 static int team_port_enter(struct team *team, struct team_port *port)
drivers/net/team/team_mode_loadbalance.c +1 -1
index 4833fbfe241e..38a459649569 100644
@@ -380,7 +380,7 @@ static int lb_tx_hash_to_port_mapping_set(struct team *team,
 
 	list_for_each_entry(port, &team->port_list, list) {
 		if (ctx->data.u32_val == port->dev->ifindex &&
-		    team_port_enabled(port)) {
+		    team_port_tx_enabled(port)) {
 			rcu_assign_pointer(LB_HTPM_PORT_BY_HASH(lb_priv, hash),
 					   port);
 			return 0;
include/linux/if_team.h +14 -2
index c777170ef552..3d21e06fda67 100644
@@ -31,6 +31,7 @@ struct team_port {
 	struct list_head list; /* node in ordinary list */
 	struct team *team;
 	int tx_index; /* index of tx enabled port. If disabled, -1 */
+	bool rx_enabled;
 
 	bool linkup; /* either state.linkup or user.linkup */
 
@@ -75,14 +76,24 @@ static inline struct team_port *team_port_get_rcu(const struct net_device *dev)
 	return rcu_dereference(dev->rx_handler_data);
 }
 
-static inline bool team_port_enabled(struct team_port *port)
+static inline bool team_port_rx_enabled(struct team_port *port)
+{
+	return READ_ONCE(port->rx_enabled);
+}
+
+static inline bool team_port_tx_enabled(struct team_port *port)
 {
 	return READ_ONCE(port->tx_index) != -1;
 }
 
+static inline bool team_port_enabled(struct team_port *port)
+{
+	return team_port_rx_enabled(port) && team_port_tx_enabled(port);
+}
+
 static inline bool team_port_txable(struct team_port *port)
 {
-	return port->linkup && team_port_enabled(port);
+	return port->linkup && team_port_tx_enabled(port);
 }
 
 static inline bool team_port_dev_txable(const struct net_device *port_dev)
@@ -193,6 +204,7 @@ struct team {
 	 * List of tx-enabled ports and counts of rx and tx-enabled ports.
 	 */
 	int tx_en_port_count;
+	int rx_en_port_count;
 	struct hlist_head tx_en_port_hlist[TEAM_PORT_HASHENTRIES];
 
 	struct list_head port_list; /* list of all ports */
Signature · 1 line
2.53.0.1185.g05d4b7b318-goog
#12 lore raw

PATCH v5 8/10 net: team: Add new rx_enabled team port option

In reply to Marc Harvey

Allow independent control over rx enablement via the rx_enabled option without affecting tx enablement. This affects the normal enabled option since a port is only considered enabled if both tx and rx are enabled.

If this option is not used, then the enabled option will continue to behave exactly as it did before.

Tested in a follow-up patch with a new selftest.

---
Changes in v5:
- None

Changes in v4:
- New patch: split from the original monolithic v3 patch "net: team:
Decouple rx and tx enablement in the team driver".
- Link to v3: https://lore.kernel.org/netdev/[email protected]/

---
 drivers/net/team/team_core.c | 49 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
drivers/net/team/team_core.c +49 -0
index e437099a5a17..67f77de4cf10 100644
@@ -941,6 +941,28 @@ static void __team_port_disable_rx(struct team *team,
 	WRITE_ONCE(port->rx_enabled, false);
 }
 
+static void team_port_enable_rx(struct team *team,
+				struct team_port *port)
+{
+	if (team_port_rx_enabled(port))
+		return;
+
+	__team_port_enable_rx(team, port);
+	team_adjust_ops(team);
+	team_notify_peers(team);
+	team_mcast_rejoin(team);
+}
+
+static void team_port_disable_rx(struct team *team,
+				 struct team_port *port)
+{
+	if (!team_port_rx_enabled(port))
+		return;
+
+	__team_port_disable_rx(team, port);
+	team_adjust_ops(team);
+}
+
 /*
  * Enable just TX on the port by adding to tx-enabled port hashlist and
  * setting port->tx_index (Might be racy so reader could see incorrect
@@ -1487,6 +1509,26 @@ static int team_port_en_option_set(struct team *team,
 	return 0;
 }
 
+static void team_port_rx_en_option_get(struct team *team,
+				       struct team_gsetter_ctx *ctx)
+{
+	struct team_port *port = ctx->info->port;
+
+	ctx->data.bool_val = team_port_rx_enabled(port);
+}
+
+static int team_port_rx_en_option_set(struct team *team,
+				      struct team_gsetter_ctx *ctx)
+{
+	struct team_port *port = ctx->info->port;
+
+	if (ctx->data.bool_val)
+		team_port_enable_rx(team, port);
+	else
+		team_port_disable_rx(team, port);
+	return 0;
+}
+
 static void team_user_linkup_option_get(struct team *team,
 					struct team_gsetter_ctx *ctx)
 {
@@ -1608,6 +1650,13 @@ static const struct team_option team_options[] = {
 		.getter = team_port_en_option_get,
 		.setter = team_port_en_option_set,
 	},
+	{
+		.name = "rx_enabled",
+		.type = TEAM_OPTION_TYPE_BOOL,
+		.per_port = true,
+		.getter = team_port_rx_en_option_get,
+		.setter = team_port_rx_en_option_set,
+	},
 	{
 		.name = "user_linkup",
 		.type = TEAM_OPTION_TYPE_BOOL,
Signature · 1 line
2.53.0.1185.g05d4b7b318-goog
#14 lore raw

PATCH v5 9/10 net: team: Add new tx_enabled team port option

In reply to Marc Harvey

This option allows independent control over tx enablement without affecting rx enablement. Like the rx_enabled option, this also implicitly affects the enabled option.

If this option is not used, then the enabled option will continue to behave as it did before.

Tested in a follow-up patch with a new selftest.

---
Changes in v5:
- None

Changes in v4:
- New patch: split from the original monolithic v3 patch "net: team:
Decouple rx and tx enablement in the team driver".
- Link to v3: https://lore.kernel.org/netdev/[email protected]/

---
 drivers/net/team/team_core.c | 55 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
drivers/net/team/team_core.c +55 -0
index 67f77de4cf10..0c87f9972457 100644
@@ -978,6 +978,21 @@ static void __team_port_enable_tx(struct team *team,
 			   team_tx_port_index_hash(team, port->tx_index));
 }
 
+static void team_port_enable_tx(struct team *team,
+				struct team_port *port)
+{
+	if (team_port_tx_enabled(port))
+		return;
+
+	__team_port_enable_tx(team, port);
+	team_adjust_ops(team);
+	team_queue_override_port_add(team, port);
+
+	/* Don't rejoin multicast, since this port might not be receiving. */
+	team_notify_peers(team);
+	team_lower_state_changed(port);
+}
+
 static void __reconstruct_port_hlist(struct team *team, int rm_index)
 {
 	struct hlist_head *tx_port_index_hash;
@@ -1007,6 +1022,19 @@ static void __team_port_disable_tx(struct team *team,
 	WRITE_ONCE(team->tx_en_port_count, team->tx_en_port_count - 1);
 }
 
+static void team_port_disable_tx(struct team *team,
+				 struct team_port *port)
+{
+	if (!team_port_tx_enabled(port))
+		return;
+
+	__team_port_disable_tx(team, port);
+
+	team_queue_override_port_del(team, port);
+	team_adjust_ops(team);
+	team_lower_state_changed(port);
+}
+
 /*
  * Enable TX AND RX on the port.
  */
@@ -1529,6 +1557,26 @@ static int team_port_rx_en_option_set(struct team *team,
 	return 0;
 }
 
+static void team_port_tx_en_option_get(struct team *team,
+				       struct team_gsetter_ctx *ctx)
+{
+	struct team_port *port = ctx->info->port;
+
+	ctx->data.bool_val = team_port_tx_enabled(port);
+}
+
+static int team_port_tx_en_option_set(struct team *team,
+				      struct team_gsetter_ctx *ctx)
+{
+	struct team_port *port = ctx->info->port;
+
+	if (ctx->data.bool_val)
+		team_port_enable_tx(team, port);
+	else
+		team_port_disable_tx(team, port);
+	return 0;
+}
+
 static void team_user_linkup_option_get(struct team *team,
 					struct team_gsetter_ctx *ctx)
 {
@@ -1657,6 +1705,13 @@ static const struct team_option team_options[] = {
 		.getter = team_port_rx_en_option_get,
 		.setter = team_port_rx_en_option_set,
 	},
+	{
+		.name = "tx_enabled",
+		.type = TEAM_OPTION_TYPE_BOOL,
+		.per_port = true,
+		.getter = team_port_tx_en_option_get,
+		.setter = team_port_tx_en_option_set,
+	},
 	{
 		.name = "user_linkup",
 		.type = TEAM_OPTION_TYPE_BOOL,
Signature · 1 line
2.53.0.1185.g05d4b7b318-goog
#16 lore raw

PATCH v5 10/10 selftests: net: Add tests for team driver decoupled tx and rx control

In reply to Marc Harvey

Use ping and tcpdump to verify that independent rx and tx enablement of team driver member interfaces works as intended.

---
Changes in v5:
- Minor typo fixes in both test files.
- Link to v4: https://lore.kernel.org/netdev/[email protected]/

Changes in v4:
- None

Changes in v3:
- None

Changes in v2:
- Fix shellcheck failures.
- Link to v1: https://lore.kernel.org/all/[email protected]/

---
 tools/testing/selftests/drivers/net/team/Makefile  |   1 +
 .../drivers/net/team/decoupled_enablement.sh       | 249 +++++++++++++++++++++
 .../testing/selftests/drivers/net/team/options.sh  |  99 +++++++-
 3 files changed, 348 insertions(+), 1 deletion(-)
tools/testing/selftests/drivers/net/team/Makefile +1 -0
index dab922d7f83d..7c58cf82121e 100644
@@ -2,6 +2,7 @@
 # Makefile for net selftests
 
 TEST_PROGS := \
+	decoupled_enablement.sh \
 	dev_addr_lists.sh \
 	non_ether_header_ops.sh \
 	options.sh \
tools/testing/selftests/drivers/net/team/decoupled_enablement.sh new file +249 -0

249 lines not on this page · raw message

tools/testing/selftests/drivers/net/team/options.sh +98 -1

120 lines not on this page · raw message

Signature · 1 line
2.53.0.1185.g05d4b7b318-goog
maintainer
#17 lore raw
In reply to Marc Harvey
Quoted 8 lines · On Mon, 06 Apr 2026 03:03:36 +0000 Marc Harvey wrote:

Allow independent control over receive and transmit enablement states for aggregated ports in the team driver.

The motivation is that IEE 802.3ad LACP "independent control" can't be implemented for the team driver currently. This was added to the bonding driver in commit 240fd405528b ("bonding: Add independent control state machine").

Quoted 6 lines

This series also has a few patches that add tests to show that the old coupled enablement still works and that the new decoupled enablement works as intended (4, 5, and 10).

There are three patches with small fixes as well, with the goal of making the final decoupling patch clearer (1, 2, and 3).

activebackup:

TAP version 13
1..1

# overriding timeout to 2400
# selftests: drivers/net/team: teamd_activebackup.sh
# Setting up two-link aggregation for runner activebackup
# Teamd version is: teamd 1.32
# Conf files are /tmp/tmp.ydjNK9Um7H and /tmp/tmp.xZuc3cWbN0
# This program is not intended to be run as root.
# This program is not intended to be run as root.
# Created team devices
# Teamd PIDs are 21457 and 21461
# exec of "ip link set eth0 up" failed: No such file or directory
# exec of "ip link set eth0 up" failed: No such file or directory
# exec of "ip link set eth1 up" failed: No such file or directory
# exec of "ip link set eth1 up" failed: No such file or directory
# PING fd00::2 (fd00::2) 56 data bytes
# 64 bytes from fd00::2: icmp_seq=1 ttl=64 time=0.753 ms
# 
# --- fd00::2 ping statistics ---
# 1 packets transmitted, 1 received, 0% packet loss, time 0ms
# rtt min/avg/max/mdev = 0.753/0.753/0.753/0.000 msPacket count for test_team2 was 0
# Waiting for eth0 in ns2-lZ0gqd to stop receiving
# Packet count for eth0 was 0Packet count for eth0 was 0
# Packet count for eth1 was 0
# Waiting for eth1 in ns2-lZ0gqd to stop receiving
# Packet count for eth1 was 0Packet count for eth0 was 0
# Packet count for eth1 was 0
# TEST: teamd active backup runner test                               [FAIL]
# Traffic did not reach team interface in NS2.
# Tearing down two-link aggregation
# Failed to kill daemon: Timer expired
# Failed to kill daemon: Timer expired
# Sending sigkill to teamd for test_team1
# rm: cannot remove '/var/run/teamd/test_team1.pid': No such file or directory
# rm: cannot remove '/var/run/teamd/test_team1.sock': No such file or directory
# Sending sigkill to teamd for test_team2
# rm: cannot remove '/var/run/teamd/test_team2.pid': No such file or directory
# rm: cannot remove '/var/run/teamd/test_team2.sock': No such file or directory
not ok 1 selftests: drivers/net/team: teamd_activebackup.sh # exit=1

transmit_failover:

TAP version 13
1..1

# overriding timeout to 2400
# selftests: drivers/net/team: transmit_failover.sh
# Error: ipv6: address not found.
# Setting team in ns2-yxjiUo to mode roundrobin
# Error: ipv6: address not found.
# Setting team in ns1-Jht6kA to mode broadcast
# Packet count for eth0 was 0
# Packet count for eth1 was 0
# Packet count for eth0 was 0
# Packet count for eth1 was 0
# Packet count for eth0 was 0
# Packet count for eth1 was 0
# TEST: Failover of 'broadcast' test                                  [FAIL]
# eth0 not transmitting when both links enabled
# Setting team in ns1-Jht6kA to mode roundrobin
# Packet count for eth0 was 0
# Packet count for eth1 was 0
# Packet count for eth0 was 0
# Packet count for eth1 was 0
# Packet count for eth0 was 0
# Packet count for eth1 was 0
# TEST: Failover of 'roundrobin' test                                 [FAIL]
# eth0 not transmitting when both links enabled
# Setting team in ns1-Jht6kA to mode random
# Packet count for eth0 was 0
# Packet count for eth1 was 0
# Packet count for eth0 was 0
# Packet count for eth1 was 0
# Packet count for eth0 was 0
# Packet count for eth1 was 0
# TEST: Failover of 'random' test                                     [FAIL]
# eth0 not transmitting when both links enabled
not ok 1 selftests: drivers/net/team: transmit_failover.sh # exit=1
Signature · 1 line
pw-bot: cr
#18 lore raw
Quoted 91 lines · Jakub Kicinski
Quoted 8 lines · On Mon, 06 Apr 2026 03:03:36 +0000 Marc Harvey wrote:

Allow independent control over receive and transmit enablement states for aggregated ports in the team driver.

The motivation is that IEE 802.3ad LACP "independent control" can't be implemented for the team driver currently. This was added to the bonding driver in commit 240fd405528b ("bonding: Add independent control state machine").

Quoted 6 lines

This series also has a few patches that add tests to show that the old coupled enablement still works and that the new decoupled enablement works as intended (4, 5, and 10).

There are three patches with small fixes as well, with the goal of making the final decoupling patch clearer (1, 2, and 3).

activebackup:

TAP version 13
1..1

# overriding timeout to 2400
# selftests: drivers/net/team: teamd_activebackup.sh
# Setting up two-link aggregation for runner activebackup
# Teamd version is: teamd 1.32
# Conf files are /tmp/tmp.ydjNK9Um7H and /tmp/tmp.xZuc3cWbN0
# This program is not intended to be run as root.
# This program is not intended to be run as root.
# Created team devices
# Teamd PIDs are 21457 and 21461
# exec of "ip link set eth0 up" failed: No such file or directory
# exec of "ip link set eth0 up" failed: No such file or directory
# exec of "ip link set eth1 up" failed: No such file or directory
# exec of "ip link set eth1 up" failed: No such file or directory
# PING fd00::2 (fd00::2) 56 data bytes
# 64 bytes from fd00::2: icmp_seq=1 ttl=64 time=0.753 ms
#
# --- fd00::2 ping statistics ---
# 1 packets transmitted, 1 received, 0% packet loss, time 0ms
# rtt min/avg/max/mdev = 0.753/0.753/0.753/0.000 msPacket count for test_team2 was 0
# Waiting for eth0 in ns2-lZ0gqd to stop receiving
# Packet count for eth0 was 0Packet count for eth0 was 0
# Packet count for eth1 was 0
# Waiting for eth1 in ns2-lZ0gqd to stop receiving
# Packet count for eth1 was 0Packet count for eth0 was 0
# Packet count for eth1 was 0
# TEST: teamd active backup runner test                               [FAIL]
# Traffic did not reach team interface in NS2.
# Tearing down two-link aggregation
# Failed to kill daemon: Timer expired
# Failed to kill daemon: Timer expired
# Sending sigkill to teamd for test_team1
# rm: cannot remove '/var/run/teamd/test_team1.pid': No such file or directory
# rm: cannot remove '/var/run/teamd/test_team1.sock': No such file or directory
# Sending sigkill to teamd for test_team2
# rm: cannot remove '/var/run/teamd/test_team2.pid': No such file or directory
# rm: cannot remove '/var/run/teamd/test_team2.sock': No such file or directory
not ok 1 selftests: drivers/net/team: teamd_activebackup.sh # exit=1

transmit_failover:

TAP version 13
1..1

# overriding timeout to 2400
# selftests: drivers/net/team: transmit_failover.sh
# Error: ipv6: address not found.
# Setting team in ns2-yxjiUo to mode roundrobin
# Error: ipv6: address not found.
# Setting team in ns1-Jht6kA to mode broadcast
# Packet count for eth0 was 0
# Packet count for eth1 was 0
# Packet count for eth0 was 0
# Packet count for eth1 was 0
# Packet count for eth0 was 0
# Packet count for eth1 was 0
# TEST: Failover of 'broadcast' test                                  [FAIL]
# eth0 not transmitting when both links enabled
# Setting team in ns1-Jht6kA to mode roundrobin
# Packet count for eth0 was 0
# Packet count for eth1 was 0
# Packet count for eth0 was 0
# Packet count for eth1 was 0
# Packet count for eth0 was 0
# Packet count for eth1 was 0
# TEST: Failover of 'roundrobin' test                                 [FAIL]
# eth0 not transmitting when both links enabled
# Setting team in ns1-Jht6kA to mode random
# Packet count for eth0 was 0
# Packet count for eth1 was 0
# Packet count for eth0 was 0
Quoted 8 lines
# Packet count for eth1 was 0
# Packet count for eth0 was 0
# Packet count for eth1 was 0
# TEST: Failover of 'random' test                                     [FAIL]
# eth0 not transmitting when both links enabled
not ok 1 selftests: drivers/net/team: transmit_failover.sh # exit=1
--
pw-bot: cr

Apologies for all of the test failures. Before sending this revision, I ran each test thousands of times and observed no failures, so I thought the flakiness would be resolved.

No matter what I try, I can't recreate either issue on my end. I've tried building with the exact config from one of the test runs
(https://netdev-ctrl.bots.linux.dev/logs/vmksft/bonding/results/590921/).
I've tried stressing the VM according to
https://github.com/linux-netdev/nipa/wiki/How-to-run-netdev-selftests-CI-style#reproducing-unstable-tests
(this makes the tests time out, but I can still see traffic). I've tried using the netdev-testing/net-next-2026-04-06--09-00 kernel source. I've tried in nested and unnested virtual machines. I've also tried running multiple test instances in parallel, but nothing recreates the issues. The issues seem related to tcpdump, but without reproducing them, I can only guess. Any suggestions for running the tests exactly as the CI does would be greatly appreciated.

- Marc

maintainer
#21 lore raw
In reply to Marc Harvey
Quoted 8 lines · Mon, Apr 06, 2026 at 05:03:36AM +0200, [email protected] wrote:

Allow independent control over receive and transmit enablement states for aggregated ports in the team driver.

The motivation is that IEE 802.3ad LACP "independent control" can't be implemented for the team driver currently. This was added to the bonding driver in commit 240fd405528b ("bonding: Add independent control state machine").

Quoted 6 lines

This series also has a few patches that add tests to show that the old coupled enablement still works and that the new decoupled enablement works as intended (4, 5, and 10).

There are three patches with small fixes as well, with the goal of making the final decoupling patch clearer (1, 2, and 3).

Looks fine to me now. Do you have libteam/teamd counterpart?

maintainer Reviewed-by on v5 1/10
#2 lore raw

Re: [PATCH net-next v5 01/10] net: team: Annotate reads and writes for mixed lock accessed values

In reply to Marc Harvey
Quoted 12 lines · Mon, Apr 06, 2026 at 05:03:37AM +0200, [email protected] wrote:

The team_port's "index" and the team's "en_port_count" are read in the hot transmit path, but are only written to when holding the rtnl lock.

Use READ_ONCE() for all lockless reads of these values, and use WRITE_ONCE() for all writes.

---
Changes in v5:
- None

Quoted 8 lines

Changes in v4:
- None

Changes in v3:
- None

Changes in v2:
- None

Nit: I don't think you need to add such record when there is no change.

maintainer Reviewed-by on v5 6/10
#9 lore raw

Re: [PATCH net-next v5 06/10] net: team: Rename enablement functions and struct members to tx

In reply to Marc Harvey
Quoted 8 lines · Mon, Apr 06, 2026 at 05:03:42AM +0200, [email protected] wrote:

Add no functional changes, but rename enablement functions, variables etc. that are used in teaming driver transmit decisions.

Since rx and tx enablement are still coupled, some of the variables renamed in this patch are still used for the rx path, but that will change in a follow-up patch.

maintainer Reviewed-by on v5 7/10
#11 lore raw

Re: [PATCH net-next v5 07/10] net: team: Track rx enablement separately from tx enablement

In reply to Marc Harvey
Quoted 10 lines · Mon, Apr 06, 2026 at 05:03:43AM +0200, [email protected] wrote:

Separate the rx and tx enablement/disablement into different functions so that it is easier to interact with them independently later.

Although this patch changes receive and transmit paths, the actual behavior of the teaming driver should remain unchanged, since there is no option introduced yet to change rx or tx enablement independently. Those options will be added in follow-up patches.

maintainer Reviewed-by on v5 8/10
#13 lore raw

Re: [PATCH net-next v5 08/10] net: team: Add new rx_enabled team port option

In reply to Marc Harvey
Quoted 11 lines · Mon, Apr 06, 2026 at 05:03:44AM +0200, [email protected] wrote:

Allow independent control over rx enablement via the rx_enabled option without affecting tx enablement. This affects the normal enabled option since a port is only considered enabled if both tx and rx are enabled.

If this option is not used, then the enabled option will continue to behave exactly as it did before.

Tested in a follow-up patch with a new selftest.

maintainer Reviewed-by on v5 9/10
#15 lore raw

Re: [PATCH net-next v5 09/10] net: team: Add new tx_enabled team port option

In reply to Marc Harvey
Quoted 10 lines · Mon, Apr 06, 2026 at 05:03:45AM +0200, [email protected] wrote:

This option allows independent control over tx enablement without affecting rx enablement. Like the rx_enabled option, this also implicitly affects the enabled option.

If this option is not used, then the enabled option will continue to behave as it did before.

Tested in a follow-up patch with a new selftest.

#19 lore raw
In reply to Marc Harvey
Quoted 119 lines · Marc Harvey
Quoted 91 lines · Jakub Kicinski
Quoted 8 lines · On Mon, 06 Apr 2026 03:03:36 +0000 Marc Harvey wrote:

Allow independent control over receive and transmit enablement states for aggregated ports in the team driver.

The motivation is that IEE 802.3ad LACP "independent control" can't be implemented for the team driver currently. This was added to the bonding driver in commit 240fd405528b ("bonding: Add independent control state machine").

Quoted 6 lines

This series also has a few patches that add tests to show that the old coupled enablement still works and that the new decoupled enablement works as intended (4, 5, and 10).

There are three patches with small fixes as well, with the goal of making the final decoupling patch clearer (1, 2, and 3).

activebackup:

TAP version 13
1..1

# overriding timeout to 2400
# selftests: drivers/net/team: teamd_activebackup.sh
# Setting up two-link aggregation for runner activebackup
# Teamd version is: teamd 1.32
# Conf files are /tmp/tmp.ydjNK9Um7H and /tmp/tmp.xZuc3cWbN0
# This program is not intended to be run as root.
# This program is not intended to be run as root.
# Created team devices
# Teamd PIDs are 21457 and 21461
# exec of "ip link set eth0 up" failed: No such file or directory
# exec of "ip link set eth0 up" failed: No such file or directory
# exec of "ip link set eth1 up" failed: No such file or directory
# exec of "ip link set eth1 up" failed: No such file or directory
# PING fd00::2 (fd00::2) 56 data bytes
# 64 bytes from fd00::2: icmp_seq=1 ttl=64 time=0.753 ms
#
# --- fd00::2 ping statistics ---
# 1 packets transmitted, 1 received, 0% packet loss, time 0ms
# rtt min/avg/max/mdev = 0.753/0.753/0.753/0.000 msPacket count for test_team2 was 0
# Waiting for eth0 in ns2-lZ0gqd to stop receiving
# Packet count for eth0 was 0Packet count for eth0 was 0
# Packet count for eth1 was 0
# Waiting for eth1 in ns2-lZ0gqd to stop receiving
# Packet count for eth1 was 0Packet count for eth0 was 0
# Packet count for eth1 was 0
# TEST: teamd active backup runner test                               [FAIL]
# Traffic did not reach team interface in NS2.
# Tearing down two-link aggregation
# Failed to kill daemon: Timer expired
# Failed to kill daemon: Timer expired
# Sending sigkill to teamd for test_team1
# rm: cannot remove '/var/run/teamd/test_team1.pid': No such file or directory
# rm: cannot remove '/var/run/teamd/test_team1.sock': No such file or directory
# Sending sigkill to teamd for test_team2
# rm: cannot remove '/var/run/teamd/test_team2.pid': No such file or directory
# rm: cannot remove '/var/run/teamd/test_team2.sock': No such file or directory
not ok 1 selftests: drivers/net/team: teamd_activebackup.sh # exit=1

transmit_failover:

TAP version 13
1..1

# overriding timeout to 2400
# selftests: drivers/net/team: transmit_failover.sh
# Error: ipv6: address not found.
# Setting team in ns2-yxjiUo to mode roundrobin
# Error: ipv6: address not found.
# Setting team in ns1-Jht6kA to mode broadcast
# Packet count for eth0 was 0
# Packet count for eth1 was 0
# Packet count for eth0 was 0
# Packet count for eth1 was 0
# Packet count for eth0 was 0
# Packet count for eth1 was 0
# TEST: Failover of 'broadcast' test                                  [FAIL]
# eth0 not transmitting when both links enabled
# Setting team in ns1-Jht6kA to mode roundrobin
# Packet count for eth0 was 0
# Packet count for eth1 was 0
# Packet count for eth0 was 0
# Packet count for eth1 was 0
# Packet count for eth0 was 0
# Packet count for eth1 was 0
# TEST: Failover of 'roundrobin' test                                 [FAIL]
# eth0 not transmitting when both links enabled
# Setting team in ns1-Jht6kA to mode random
# Packet count for eth0 was 0
# Packet count for eth1 was 0
# Packet count for eth0 was 0
Quoted 8 lines
# Packet count for eth1 was 0
# Packet count for eth0 was 0
# Packet count for eth1 was 0
# TEST: Failover of 'random' test                                     [FAIL]
# eth0 not transmitting when both links enabled
not ok 1 selftests: drivers/net/team: transmit_failover.sh # exit=1
--
pw-bot: cr

Apologies for all of the test failures. Before sending this revision, I ran each test thousands of times and observed no failures, so I thought the flakiness would be resolved.

No matter what I try, I can't recreate either issue on my end. I've tried building with the exact config from one of the test runs
(https://netdev-ctrl.bots.linux.dev/logs/vmksft/bonding/results/590921/).
I've tried stressing the VM according to
https://github.com/linux-netdev/nipa/wiki/How-to-run-netdev-selftests-CI-style#reproducing-unstable-tests
(this makes the tests time out, but I can still see traffic). I've tried using the netdev-testing/net-next-2026-04-06--09-00 kernel source. I've tried in nested and unnested virtual machines. I've also tried running multiple test instances in parallel, but nothing recreates the issues. The issues seem related to tcpdump, but without reproducing them, I can only guess. Any suggestions for running the tests exactly as the CI does would be greatly appreciated.

Quoted 1 line

- Marc

Thank you very much to [email protected], who figured out how to recreate the issue on Fedora. Fedora's /etc/services maps TCP port 1234 to the "search-agent" service (normal), which tcpdump then uses to text-replace port numbers in its output. So the tests were looking for ${ip_address}.1234, but tcpdump was spitting out ${ip_address}.search_agent. What is strange is that the test already uses tcpdump's "-n" option: "Don't convert addresses (i.e., host addresses, port numbers, etc.) to names."

It turns out that Fedora has a patched version of tcpdump that separates the normal "-n" option into two options! "-n" handles host addresses, and "-nn" handles port and protocol numbers. The tcpdump invocation used by the selftests only uses "-n". What's stranger is that passing "-nn" to tcpdump is actually portable, because under the hood it is treated as a counter, with or without the Fedora patch:
https://github.com/the-tcpdump-group/tcpdump/blob/master/tcpdump.c#L1915
(thanks again to Kuniyuki for discovering this).

For v6, I will just change the TCP port to one that is not used by a service, and will make the tcpdump helper function in the net/forwarding lib use "-nn" instead of "-n".

- Marc

#22 lore raw
In reply to Jiri Pirko
Quoted 10 lines · Jiri Pirko
Quoted 8 lines · Mon, Apr 06, 2026 at 05:03:36AM +0200, [email protected] wrote:

Allow independent control over receive and transmit enablement states for aggregated ports in the team driver.

The motivation is that IEE 802.3ad LACP "independent control" can't be implemented for the team driver currently. This was added to the bonding driver in commit 240fd405528b ("bonding: Add independent control state machine").

Quoted 8 lines
Quoted 6 lines

This series also has a few patches that add tests to show that the old coupled enablement still works and that the new decoupled enablement works as intended (4, 5, and 10).

There are three patches with small fixes as well, with the goal of making the final decoupling patch clearer (1, 2, and 3).

Looks fine to me now. Do you have libteam/teamd counterpart?

I don't see a need for this to be used in any of the teamd runners. Libteam should support this out of the box, since the options are identified over netlink by their string names. The options.sh test uses teamnl, which uses libteam, to set the new options.

maintainer
#20 lore raw
In reply to Marc Harvey
Quoted 9 lines · On Tue, 7 Apr 2026 16:06:02 -0700 Marc Harvey wrote:

Thank you very much to [email protected], who figured out how to recreate the issue on Fedora. Fedora's /etc/services maps TCP port 1234 to the "search-agent" service (normal), which tcpdump then uses to text-replace port numbers in its output. So the tests were looking for ${ip_address}.1234, but tcpdump was spitting out ${ip_address}.search_agent. What is strange is that the test already uses tcpdump's "-n" option: "Don't convert addresses (i.e., host addresses, port numbers, etc.) to names."

Quoted 8 lines

It turns out that Fedora has a patched version of tcpdump that separates the normal "-n" option into two options! "-n" handles host addresses, and "-nn" handles port and protocol numbers. The tcpdump invocation used by the selftests only uses "-n". What's stranger is that passing "-nn" to tcpdump is actually portable, because under the hood it is treated as a counter, with or without the Fedora patch:
https://github.com/the-tcpdump-group/tcpdump/blob/master/tcpdump.c#L1915
(thanks again to Kuniyuki for discovering this).

Oh wow! Thanks to both of you for not giving up and getting to the bottom of this :)

maintainer
#23 lore raw
In reply to Marc Harvey
Quoted 15 lines · Wed, Apr 08, 2026 at 02:12:35AM +0200, [email protected] wrote:
Quoted 14 lines · Jiri Pirko
Quoted 12 lines · Mon, Apr 06, 2026 at 05:03:36AM +0200, [email protected] wrote:

Allow independent control over receive and transmit enablement states for aggregated ports in the team driver.

The motivation is that IEE 802.3ad LACP "independent control" can't be implemented for the team driver currently. This was added to the bonding driver in commit 240fd405528b ("bonding: Add independent control state machine").

This series also has a few patches that add tests to show that the old coupled enablement still works and that the new decoupled enablement works as intended (4, 5, and 10).

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

There are three patches with small fixes as well, with the goal of making the final decoupling patch clearer (1, 2, and 3).

Looks fine to me now. Do you have libteam/teamd counterpart?

I don't see a need for this to be used in any of the teamd runners.

Why do you need this then?

#24 lore raw
Quoted 8 lines · Jiri Pirko
Quoted 5 lines · Wed, Apr 08, 2026 at 02:12:35AM +0200, [email protected] wrote:
Quoted 2 lines · Jiri Pirko

Looks fine to me now. Do you have libteam/teamd counterpart?

I don't see a need for this to be used in any of the teamd runners.

Why do you need this then?

Initially, we plan to use a non-teamd userspace component for teaming control due to several non-standard requirements, such as synchronization with unrelated software. It is probably worth converting the teamd lacp runner to independent control at some point, because according to the spec: "It is recommended that the independent control state diagram be implemented in preference to the coupled control state diagram."