From nobody Sun Apr 5 13:12:23 2026 Received: from mail-dy1-f201.google.com (mail-dy1-f201.google.com [74.125.82.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3E65372EF6 for ; Fri, 3 Apr 2026 07:14:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775200473; cv=none; b=LUEY/X/HHAjrVeUWnFiFxGKnVXyMKN8bLyh6C9fkZu2Dg480lpSYZ1gLf1r4A0oaYSTSULPGaLbfDBeKNv31uOiri8Oz+iTkkSJtKQrB/OsFc+3c67apTSQB5LSss9mEFncXkMFX1zAfYlZWWq5wVi9MHwt3MxMVCOJdUVGtBW0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775200473; c=relaxed/simple; bh=6pngi6AbJj9IjokAnMcUuaAPhwS8Is6Gt3b4MrrqM2Y=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=UcYmJ9En+xbB1+cFD0r2xJ5vVYlc1ti/d5x9q82Ncryu8vWoYV3kenMHHtUR/6dK1xifzQvGZOb25D2snb0H2WXs4CT1VHhsS1BiWQ5tBt/zPhVlMVyQERyY5E4EztRLIG2wBrwOXVe4VoRXvNrv8FkTxtPJDbsj7wH0NtqcFIQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--marcharvey.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=GsprvlM6; arc=none smtp.client-ip=74.125.82.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--marcharvey.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="GsprvlM6" Received: by mail-dy1-f201.google.com with SMTP id 5a478bee46e88-2cc75e79b97so1172419eec.1 for ; Fri, 03 Apr 2026 00:14:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775200471; x=1775805271; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=U9tx+KxgSxiX42Rwpk7xjo8R+fCKMdHqCETpVq4j3oU=; b=GsprvlM6/t/1Tc1evZyoVFsDaUfHPBPrpFLPEeb86kfa8e+UBp/yQnW8OySMeYYysr Ba0TjZNq5BR0+2joeRgfi3yKvg3oagM0oEvdafRya/z797RY8FW2sLVUfBXUTNqGGsdL g/ZL+AVoFeRTN6fT99Uq9xAiD84HfM+1XBLkKyBNqNJbUUBNSl9t8PDgryCklY3KBKjZ 2GC5Kc7tpJt/RHodOyZYw2QSXcf9vxB+6Lu+IgrOvuWTuF1sx5DuNyOp5VeB3/qkZ5Gd Y8RFQ6TL88xvV6fcqNITQHs0Wg/yxIaqfQt0Kk6Dwj4VktN8h9CgHQ2A5bh4MHmRk9mB yF0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775200471; x=1775805271; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=U9tx+KxgSxiX42Rwpk7xjo8R+fCKMdHqCETpVq4j3oU=; b=XApKJB8aYKLdJfgwHziHrJNE7c8zVNxFp0RHrsM6EQeXszRhC0tnDVVGgBXpqMUQOp y6W/w6/k74PJ/XfBqhUZ/7rGwMdN2pkxjtZYG8ic93bfj591QdHxBCwMzauGoQWWAzVY 8v6JUZqEb1y28MWSgkX3V1sIc3UaEpQ06V7DnXtlyMMD1ypSWkr24HuUbZJ4ZuTnWMLU lJgwB/X5TSQc/HkLLt2Et2QAOz6vBuprG6ZH8rvrRR2+8SgCpVItZn2x/VacpKMkXqep pPT+8rkBm7umXcsijwOhAqlSUQYsectNxkO4JmR0kHHD3mMbDgxLcfYxC2PKPpiKKU5T yVow== X-Forwarded-Encrypted: i=1; AJvYcCUw5C2S1J1sLPB2k0nGyFsVbUj3Hkllc3SJyu+XKJfTOHdH2xmeNKxBChfRHkycb5ETwi3FmqWsUVizFw4=@vger.kernel.org X-Gm-Message-State: AOJu0YwJ60bTlmcvGGl7q36aGeKCEAw0z32hYPsDU1Jekhz1QtD6kDb+ EFj+7HYzUr9gWVUt+LYTGbmcOXdjIKxh2nsVC//CAXqZaeWo4VttzLXi3o5yVXzReCStuYOw0GR ZOdgYXZz2v+xaZ+CRBrk7wA== X-Received: from dybpk7.prod.google.com ([2002:a05:7301:4287:b0:2c5:d9bf:436c]) (user=marcharvey job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7301:1e87:b0:2c6:cdb3:bd8d with SMTP id 5a478bee46e88-2cbf9afd61emr1068538eec.7.1775200470904; Fri, 03 Apr 2026 00:14:30 -0700 (PDT) Date: Fri, 03 Apr 2026 07:14:22 +0000 In-Reply-To: <20260403-teaming-driver-internal-v4-0-d3032f33ca25@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260403-teaming-driver-internal-v4-0-d3032f33ca25@google.com> X-Developer-Key: i=marcharvey@google.com; a=ed25519; pk=OzOeciadbfF5Bug/4/hyEAwfrruSY4tn0Q0LocyYUL0= X-Developer-Signature: v=1; a=ed25519-sha256; t=1775200467; l=3717; i=marcharvey@google.com; s=20260401; h=from:subject:message-id; bh=6pngi6AbJj9IjokAnMcUuaAPhwS8Is6Gt3b4MrrqM2Y=; b=4kA3H08ExpxSDoz7Uk31FsSlbiXlBRJodlvsA8hHkFHhJOG41Za0obB3F3DKo/OyB+4DFTaut JpxnL9txSO6BS8MXI0ukTtUr9fBqS4lbzm/Z5RQY9U43zJBlDb9uMW2 X-Mailer: b4 0.14.3 Message-ID: <20260403-teaming-driver-internal-v4-1-d3032f33ca25@google.com> Subject: [PATCH net-next v4 01/10] net: team: Annotate reads and writes for mixed lock accessed values From: Marc Harvey To: Jiri Pirko , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Marc Harvey Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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. Signed-off-by: Marc Harvey --- 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(-) diff --git a/drivers/net/team/team_core.c b/drivers/net/team/team_core.c index 566a5d102c23..becd066279a6 100644 --- a/drivers/net/team/team_core.c +++ b/drivers/net/team/team_core.c @@ -938,7 +938,8 @@ static void team_port_enable(struct team *team, { if (team_port_enabled(port)) return; - port->index =3D 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 =3D rm_index + 1; i < team->en_port_count; i++) { port =3D 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 =3D -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 ne= t_device *port_dev, netif_addr_unlock_bh(dev); } =20 - port->index =3D -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); diff --git a/drivers/net/team/team_mode_random.c b/drivers/net/team/team_mo= de_random.c index 53d0ce34b8ce..169a7bc865b2 100644 --- a/drivers/net/team/team_mode_random.c +++ b/drivers/net/team/team_mode_random.c @@ -16,7 +16,7 @@ static bool rnd_transmit(struct team *team, struct sk_buf= f *skb) struct team_port *port; int port_index; =20 - port_index =3D get_random_u32_below(team->en_port_count); + port_index =3D get_random_u32_below(READ_ONCE(team->en_port_count)); port =3D team_get_port_by_index_rcu(team, port_index); if (unlikely(!port)) goto drop; diff --git a/include/linux/if_team.h b/include/linux/if_team.h index ccb5327de26d..06f4d7400c1e 100644 --- a/include/linux/if_team.h +++ b/include/linux/if_team.h @@ -77,7 +77,7 @@ static inline struct team_port *team_port_get_rcu(const s= truct net_device *dev) =20 static inline bool team_port_enabled(struct team_port *port) { - return port->index !=3D -1; + return READ_ONCE(port->index) !=3D -1; } =20 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 =3D team_port_index_hash(team, port_index); =20 hlist_for_each_entry_rcu(port, head, hlist) - if (port->index =3D=3D port_index) + if (READ_ONCE(port->index) =3D=3D port_index) return port; return NULL; } --=20 2.53.0.1185.g05d4b7b318-goog From nobody Sun Apr 5 13:12:23 2026 Received: from mail-dy1-f202.google.com (mail-dy1-f202.google.com [74.125.82.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 79ADB378D92 for ; Fri, 3 Apr 2026 07:14:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775200474; cv=none; b=k5nUD5TTkFnfi8p5vou9N1EMgaL0VSTKnklZS2gN+SOTVmpG/jVCy+lSd8TOgAl7nFIQQxUu8H07yN/ZDlUl6V4LINYMW8qAoCIBRKKAK0WR0MsVDX91srEL3j26J8xA3JJFbF1ujWHub3062llF3CI1UbZ8bt2746PaCXkT6b4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775200474; c=relaxed/simple; bh=JjS6MuWrzLQ484r+Wytp35TgT78rt/ZzACL6KUmL0o0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Jx46dlknvySW4YgIqCtmt/zM5pJzuH9fjgbC1NH0z6HYtk9NFVyds2t2xZE2skB3RXhxXS03QlGaq4B3fifw5SBRRQA69kZdO/YbcG/C0TvIU73eFLPEWbrcyjJjEHQpWM5LYrkA6NOUdkNoSz8G5wGu+ywLWexDc8SbwQdYQS8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--marcharvey.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=hW9gkIYJ; arc=none smtp.client-ip=74.125.82.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--marcharvey.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="hW9gkIYJ" Received: by mail-dy1-f202.google.com with SMTP id 5a478bee46e88-2c0f6593ef5so2202203eec.1 for ; Fri, 03 Apr 2026 00:14:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775200473; x=1775805273; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=sH3+awQ2VJG9FRCmCvGcnPpepbVJPLxWI2KeuMcmXiQ=; b=hW9gkIYJtQ1qvaWk91pKISPu5N/MRg+yxakbe/DC1Q20i6sfRhqnZtqGuBJDubtg0k QwEbI39QKGeQceEPGiouhSNFOi6ttMid79GpiVhN9g6e13sNx7+Wcgu/IilKJvmKIcpS j51QBLPmdWy0Y6Un5u7sSKHLTctEQ5KuvcilrlzDLgqdRsXVNiE3GroOq6i4EP2HggP1 yl5IpYq3hbQo6nJVknO8AHBuh7xFSQE8l7iAOaesWlu0rYe3G63c4maOgyXJESJc43Xl h4ZlVtAvFuMRjqD+ZLMQM8Ws0F/BZzbFdJiVTcze1kA+8P0iiavinX95F1EmpfiuozKh l6Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775200473; x=1775805273; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=sH3+awQ2VJG9FRCmCvGcnPpepbVJPLxWI2KeuMcmXiQ=; b=LlxiMmiCSU4nbN6k2Q3C8QdxiEYejSa+yFdCQy7qK9bqxbx5CVV7JfT21gIggviuvW ssj551NqBgTs2slQRnhfiinOMPL6pnkGL92rguTif0XDrVcq/5Dk5/8juRfc46yK1WHp 1giLHN27Q3YOLRH5adKP9l6535CovKFyTc25daFjDRvLW+e/kWhCwptxjpNzkSfuEJH0 ZXTN5FB8TvLjq6SYouObI3xOpe1rkLeFBwuuV9TM4PeEpGmwqQsL32sywTmbPPNnMlPR AQLSUm8WgYJQtDylK04BmbJM5uBMvSARCaKix2mgwGc+rgHi7Gh/CT/MwfTojaxzwb9x 9sbQ== X-Forwarded-Encrypted: i=1; AJvYcCUGj7nJ5tnqnwJJ8zAdwQe3id/R4AaD7C4YZY60qHF1/vvHNuI7BgiL0l6pt/cNP9NIW4MMvAwQRiuv5CI=@vger.kernel.org X-Gm-Message-State: AOJu0YyArA2IEhadLz1hfzOYDWjx8kAFQWzB96vcAwjHFK6lVTls15IS x9WS5o2uU3ko/SaxBfKfK8jFn0saZRbvUCZJ8fk3IlbDaHErIToblqnjuM/t//NJuwHMhiBCbp8 ZAHZEFaP3SX3ExfP60JMLiA== X-Received: from dyaf11-n1.prod.google.com ([2002:a05:693c:838b:10b0:2cb:735c:182c]) (user=marcharvey job=prod-delivery.src-stubby-dispatcher) by 2002:a05:693c:2b14:b0:2c5:d833:a4fe with SMTP id 5a478bee46e88-2cbfa5bf117mr923062eec.10.1775200472427; Fri, 03 Apr 2026 00:14:32 -0700 (PDT) Date: Fri, 03 Apr 2026 07:14:23 +0000 In-Reply-To: <20260403-teaming-driver-internal-v4-0-d3032f33ca25@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260403-teaming-driver-internal-v4-0-d3032f33ca25@google.com> X-Developer-Key: i=marcharvey@google.com; a=ed25519; pk=OzOeciadbfF5Bug/4/hyEAwfrruSY4tn0Q0LocyYUL0= X-Developer-Signature: v=1; a=ed25519-sha256; t=1775200467; l=1461; i=marcharvey@google.com; s=20260401; h=from:subject:message-id; bh=JjS6MuWrzLQ484r+Wytp35TgT78rt/ZzACL6KUmL0o0=; b=WaaKcCy6jw5XvMICkOKbYOhzmRWQdzj3dQmC//JznTNilpSYDLyMIPk7NU2fYSUCfczxIf585 TUniz+tRtmCD+2aGkmk5rkyxA2PpoukSRZ62kUhqm0Eqbv4u7F5dDR4 X-Mailer: b4 0.14.3 Message-ID: <20260403-teaming-driver-internal-v4-2-d3032f33ca25@google.com> Subject: [PATCH net-next v4 02/10] net: team: Remove unused team_mode_op, port_enabled From: Marc Harvey To: Jiri Pirko , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Marc Harvey Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable This team_mode_op wasn't used by any of the team modes, so remove it. Signed-off-by: Marc Harvey --- 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(-) diff --git a/drivers/net/team/team_core.c b/drivers/net/team/team_core.c index becd066279a6..e54bd21bd068 100644 --- a/drivers/net/team/team_core.c +++ b/drivers/net/team/team_core.c @@ -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); diff --git a/include/linux/if_team.h b/include/linux/if_team.h index 06f4d7400c1e..a761f5282bcf 100644 --- a/include/linux/if_team.h +++ b/include/linux/if_team.h @@ -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); }; =20 --=20 2.53.0.1185.g05d4b7b318-goog From nobody Sun Apr 5 13:12:23 2026 Received: from mail-dl1-f74.google.com (mail-dl1-f74.google.com [74.125.82.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 381AD37C927 for ; Fri, 3 Apr 2026 07:14:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775200476; cv=none; b=khZYe79ANV0RbPcTylGnAlhA1wkkg8tA5FhAcE79UZkaVy7x+wyxyop1WXMP1HiS8Cc5l85wyNNQFViVXW0hFeyE+Qe7yPKPNPUNnr5PalTEKF3HMXUrhjCJwUj7jPPBhiN6auClGmhHZUGln8txCd1oQRjBc9o5XoUdxAthZy8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775200476; c=relaxed/simple; bh=/N3Ja4dG8+jpoPt6AyAOHBDaHZGDjq1at+rTrxPopSQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=iwDWFt3ABcRVhHu2v5MoGzEBy8mxtla/KMPB0SVk4oxxQJZPxvkiahEn0ejTrdlhHCSiIe8gkL9tx+onRcx0gn4G3HUkLTFrkZdz62I/FcS/BtuPZwwAzbHib43jMzuNnTGnXoTf1FUsR6xo+2PVc/LFXHA4mwCyMfn/VuvcbJM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--marcharvey.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=j4g99Lkd; arc=none smtp.client-ip=74.125.82.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--marcharvey.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="j4g99Lkd" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-12737f276a2so2536166c88.1 for ; Fri, 03 Apr 2026 00:14:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775200474; x=1775805274; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=/oRMa+U4zWiyNm2ajh9HytcVZ9+GoADzxNsQhgJNjBI=; b=j4g99LkdW4vMmUjAsT3fHAIWFmbEtnRYFdscXqh1SneuBW3dlJN3GF2VHeyP3k6gW2 kEFt86KSwn6dFpzBHYOo9LYlrzqyn/SD0BMVUDKm+GI9w7aQZGyvYSp9Cwr/6Y97QczK hiEOHEhQAw2TIKSWG1bUAkWpFmveueEzk3psoLDsFUlOzepPtT5TVRvbL5VYGJTl/A3o K3GzxWEHR0s/wA3tZIbNJyiMYdsRm6hZHhH0XtB1sWk3nbbaCG9Sa6BTKCobZN4RImyv bqbic2FgTWnujgIF6L4mG+sdIrkSi+b34lyCZPc8tLYo9fxt/dVaYUhk0wR+3GZeNesf cZbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775200474; x=1775805274; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/oRMa+U4zWiyNm2ajh9HytcVZ9+GoADzxNsQhgJNjBI=; b=iC440c4KeB04KaJx34YhTbI+B0XNmb/XUGphKnc2iwmgG/42KurmmS22zqCQhB8Hyu MnO5g0kOMYfDwCLlVOixDCBG4bb/KmBB4bhxF0DXwUYzih4ziItCVlCTyuLb+Bh1dsgX 7+44gAs0+Cu9EWD7kKoe7/VSZTVQpFrbT+t8fNW8Doh7iGKFGwo6bU3SAhHGqV+ZC2yx MKDmAcSWkhn8gHkVhv5vZ1dJbBBpQ9MwHUyedaQxNPXc7Rv8XI/oeP7YGFVpsTeC+rux 0qPoXZ4a1HcWi1DtUS2ileTh/XhIOavA9eq/lnZRzZcdVRGeBcJNA1osPEJa6Uf70rtg jsqA== X-Forwarded-Encrypted: i=1; AJvYcCVkM/LdzPzjLcZG84x349UuqeXGOYbHNwh6bLFNPuxdDU7WrCI/evAQUpFnUtr8ZDJ/YWl7oE4VmHYkETY=@vger.kernel.org X-Gm-Message-State: AOJu0YwGVGl05H2bo3eFNL0csYuSz4rzmdStS1tQILg/WKmv/HyCF6Te vhXbPW0Qeky+cjYgFbtGLDV5g/JNYlPABLhDhA4m/TVUkI7wg3XcKuMpLqm7/ncPFVrIEEGV7Uu VSDwAElg58pVxv4X/n79FEw== X-Received: from dlcio26.prod.google.com ([2002:a05:7023:c01a:b0:128:bbbe:13df]) (user=marcharvey job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7023:b0c:b0:119:e56b:98a4 with SMTP id a92af1059eb24-12bfb700b66mr954561c88.11.1775200474159; Fri, 03 Apr 2026 00:14:34 -0700 (PDT) Date: Fri, 03 Apr 2026 07:14:24 +0000 In-Reply-To: <20260403-teaming-driver-internal-v4-0-d3032f33ca25@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260403-teaming-driver-internal-v4-0-d3032f33ca25@google.com> X-Developer-Key: i=marcharvey@google.com; a=ed25519; pk=OzOeciadbfF5Bug/4/hyEAwfrruSY4tn0Q0LocyYUL0= X-Developer-Signature: v=1; a=ed25519-sha256; t=1775200467; l=2585; i=marcharvey@google.com; s=20260401; h=from:subject:message-id; bh=/N3Ja4dG8+jpoPt6AyAOHBDaHZGDjq1at+rTrxPopSQ=; b=HHr4OYKRZ3b9aY/0kw0j+0+dy3qCGxeh/d9NEuDX6U8rTwBUfqCDbTi1xEgr7R9xcYz7GuBwK MGZ4WUfQsfGDXNPwfAC+u/mZi5GvXYzxuP09k+eEpbRt7vDg57RY7TM X-Mailer: b4 0.14.3 Message-ID: <20260403-teaming-driver-internal-v4-3-d3032f33ca25@google.com> Subject: [PATCH net-next v4 03/10] net: team: Rename port_disabled team mode op to port_tx_disabled From: Marc Harvey To: Jiri Pirko , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Marc Harvey Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable This team mode op is only used by the load balance mode, and it only uses it in the tx path. Signed-off-by: Marc Harvey --- 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(-) diff --git a/drivers/net/team/team_core.c b/drivers/net/team/team_core.c index e54bd21bd068..2ce31999c99f 100644 --- a/drivers/net/team/team_core.c +++ b/drivers/net/team/team_core.c @@ -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); diff --git a/drivers/net/team/team_mode_loadbalance.c b/drivers/net/team/te= am_mode_loadbalance.c index 684954c2a8de..840f409d250b 100644 --- a/drivers/net/team/team_mode_loadbalance.c +++ b/drivers/net/team/team_mode_loadbalance.c @@ -655,7 +655,7 @@ static void lb_port_leave(struct team *team, struct tea= m_port *port) free_percpu(lb_port_priv->pcpu_stats); } =20 -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 =3D { .exit =3D lb_exit, .port_enter =3D lb_port_enter, .port_leave =3D lb_port_leave, - .port_disabled =3D lb_port_disabled, + .port_tx_disabled =3D lb_port_tx_disabled, .receive =3D lb_receive, .transmit =3D lb_transmit, }; diff --git a/include/linux/if_team.h b/include/linux/if_team.h index a761f5282bcf..740cb3100dfc 100644 --- a/include/linux/if_team.h +++ b/include/linux/if_team.h @@ -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); }; =20 extern int team_modeop_port_enter(struct team *team, struct team_port *por= t); --=20 2.53.0.1185.g05d4b7b318-goog From nobody Sun Apr 5 13:12:23 2026 Received: from mail-dy1-f201.google.com (mail-dy1-f201.google.com [74.125.82.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3C3237F736 for ; Fri, 3 Apr 2026 07:14:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775200478; cv=none; b=T77jKgyl1B3OhdtJUHv1FMQNdjegk0lDk+Tt63d+R+jb6gH9nY6W1BS5UVP6DnGgY+9PQwDR9YrxvkK/fdtjOpXLSSNaLqYxcu0/qMW2rCGs7qcM4JiQOJHHwmGjlXnoyrscBHKt7laN5HCjD1gsMREBWTd9t26lYD+zY+bKRig= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775200478; c=relaxed/simple; bh=fs3Ivi646EbrguLDrwQGdI6d6JJQSlUAhI+cPwBtJls=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=BIMVYK5EBzX0/hz1P9V0dxNJwHsm8IgOjzA1sarfZZEQL9qvcTWnZ2xXocs96UiMxjVIIe33MgGVLHzjIiV3CIV1KUF5Ek+FtOM6WEONgvB9kzKp4aftrBbphXYKNOtGCpxRtjMNIBzOuZO7KNnpSQ8K+a2cVukZ2Gy4b1LAISo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--marcharvey.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=aLLOq6Ic; arc=none smtp.client-ip=74.125.82.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--marcharvey.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="aLLOq6Ic" Received: by mail-dy1-f201.google.com with SMTP id 5a478bee46e88-2c0f6593ef5so2202225eec.1 for ; Fri, 03 Apr 2026 00:14:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775200476; x=1775805276; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=WH5IXGDcQJo/RZsD9Fs3ZxBX69GUoEG0YX93CZ5jXMw=; b=aLLOq6IcxvxHcE0qiEPM+rAvTRLi2JA1xTITdNcbRRWSOMWPsxc+/FUwIJ8PqEubkE SciV9itfdVQWZyLqENrgYJG/CBBYv9Yl0FCS8TirFws1aMd3CgJoOmF9ZbScaVKvpebP Ax49koveHAu2PYG5tNyC5vBoc6MEJIAmhT4mXHqoW04+BFvNXakPVQD/3OUEfkG8Cd7j bRHlUaV7Re7LNEvKgLpIm3y5ko1SVM+ffru+Op5v9YUvPSGfvlj9XogSdvturiwmla3c De4FcC9ufCMIhMQB4pWv0PO0SpAITS8w9TYeZaMMbYshtgTp0aYi8DaY3kCp/bOzkNnL /NMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775200476; x=1775805276; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WH5IXGDcQJo/RZsD9Fs3ZxBX69GUoEG0YX93CZ5jXMw=; b=Sgug+c8LndG6qrfZfS65Iqojza6I0UNln+UM2z2XP9shB4Y7epsqWHEYbNcaef/Fop kT4f06qDqw/21ESbXF1sXAMETK+IiTK+Ul4tPiFjBnqaAnPCFwxfZLYwD73QzmxG6z/Q j5LxQ+8Pe0Z/eFunms9ElOyT/yhxDt9MHKIdUXn0UAdujlYGrGWHCGSSrfEZAqKFqMSn UBe1zXKSuHzYDMj5LRrzhTJjp0tz/2sJMvkRQ0Ggx8FoKXhc3R880tA1iKMlj06TkMmf +K0DqF8zuRK55nEYK7HdonARwkc0fxgEoAX6kWFS8uKCk467FjXhGiXKuJMKCtOxPE21 /e8w== X-Forwarded-Encrypted: i=1; AJvYcCVXQ9AwWH+Gs17SsBz1KzkXKuM30BIu8tPguwjOVYe4V8F+G9tXZSVBlliIBMkS6FUTQ/ARGg3xEwFaiYs=@vger.kernel.org X-Gm-Message-State: AOJu0YytX6xlGM7YUABVR2IOWIu4vm1bx/PVrnzuIscf9ddc5xp9aahv yMCvBAOoa19LDt49HwqIdge9g1EBgLCDteH6IqIfnahz1vQBmkSjoHyfzaNX0kgaZcSIIppCRsC rRlynNoiXTtE9T5VshBo+Hg== X-Received: from dybmd48.prod.google.com ([2002:a05:7301:1830:b0:2c5:97a1:fc5f]) (user=marcharvey job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:641a:b0:2c0:bfe3:b95c with SMTP id 5a478bee46e88-2cbf9ee8de4mr1040500eec.4.1775200475873; Fri, 03 Apr 2026 00:14:35 -0700 (PDT) Date: Fri, 03 Apr 2026 07:14:25 +0000 In-Reply-To: <20260403-teaming-driver-internal-v4-0-d3032f33ca25@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260403-teaming-driver-internal-v4-0-d3032f33ca25@google.com> X-Developer-Key: i=marcharvey@google.com; a=ed25519; pk=OzOeciadbfF5Bug/4/hyEAwfrruSY4tn0Q0LocyYUL0= X-Developer-Signature: v=1; a=ed25519-sha256; t=1775200467; l=10811; i=marcharvey@google.com; s=20260401; h=from:subject:message-id; bh=fs3Ivi646EbrguLDrwQGdI6d6JJQSlUAhI+cPwBtJls=; b=C4dpzNhBWnnzGg5USYZ6VAB2jDzncmcQIorgMbGuGK6j5vuK6aWpLkwHaXhNL1nlgnMqZNojD 71Ry2quLdYOAZOazIGv6mmTLAwErkMdI5Xy3YUyCMIrtAw1M6Qffv/2 X-Mailer: b4 0.14.3 Message-ID: <20260403-teaming-driver-internal-v4-4-d3032f33ca25@google.com> Subject: [PATCH net-next v4 04/10] selftests: net: Add tests for failover of team-aggregated ports From: Marc Harvey To: Jiri Pirko , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Marc Harvey Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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. Signed-off-by: Marc Harvey --- 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/20260331053353.2504254-5-marcharv= ey@google.com/ --- tools/testing/selftests/drivers/net/team/Makefile | 2 + tools/testing/selftests/drivers/net/team/config | 4 + .../testing/selftests/drivers/net/team/team_lib.sh | 115 ++++++++++++++++ .../drivers/net/team/transmit_failover.sh | 151 +++++++++++++++++= ++++ 4 files changed, 272 insertions(+) diff --git a/tools/testing/selftests/drivers/net/team/Makefile b/tools/test= ing/selftests/drivers/net/team/Makefile index 02d6f51d5a06..777da2e0429e 100644 --- a/tools/testing/selftests/drivers/net/team/Makefile +++ b/tools/testing/selftests/drivers/net/team/Makefile @@ -7,9 +7,11 @@ TEST_PROGS :=3D \ options.sh \ propagation.sh \ refleak.sh \ + transmit_failover.sh \ # end of TEST_PROGS =20 TEST_INCLUDES :=3D \ + team_lib.sh \ ../bonding/lag_lib.sh \ ../../../net/forwarding/lib.sh \ ../../../net/in_netns.sh \ diff --git a/tools/testing/selftests/drivers/net/team/config b/tools/testin= g/selftests/drivers/net/team/config index 5d36a22ef080..8f04ae419c53 100644 --- a/tools/testing/selftests/drivers/net/team/config +++ b/tools/testing/selftests/drivers/net/team/config @@ -6,4 +6,8 @@ CONFIG_NETDEVSIM=3Dm CONFIG_NET_IPGRE=3Dy CONFIG_NET_TEAM=3Dy CONFIG_NET_TEAM_MODE_ACTIVEBACKUP=3Dy +CONFIG_NET_TEAM_MODE_BROADCAST=3Dy CONFIG_NET_TEAM_MODE_LOADBALANCE=3Dy +CONFIG_NET_TEAM_MODE_RANDOM=3Dy +CONFIG_NET_TEAM_MODE_ROUNDROBIN=3Dy +CONFIG_VETH=3Dy diff --git a/tools/testing/selftests/drivers/net/team/team_lib.sh b/tools/t= esting/selftests/drivers/net/team/team_lib.sh new file mode 100644 index 000000000000..fce421869381 --- /dev/null +++ b/tools/testing/selftests/drivers/net/team/team_lib.sh @@ -0,0 +1,115 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +# Create a team interface inside of a given network namespace with a given +# mode, members, and IP address. +# Arguments: +# namespace - Network namespace to put the team interface into. +# team - The name of the team interface to setup. +# mode - The team mode of the interface. +# ip_address - The IP address to assign to the team interface. +# prefix_length - The prefix length for the IP address subnet. +# $@ - members - The member interfaces of the aggregation. +setup_team() +{ + local namespace=3D$1 + local team=3D$2 + local mode=3D$3 + local ip_address=3D$4 + local prefix_length=3D$5 + shift 5 + local members=3D("$@") + + # Prerequisite: team must have no members + for member in "${members[@]}"; do + ip -n "${namespace}" link set "${member}" nomaster + done + + # Prerequisite: team must have no address in order to set it + # shellcheck disable=3DSC2086 + ip -n "${namespace}" addr del "${ip_address}/${prefix_length}" \ + ${NODAD} dev "${team}" + + echo "Setting team in ${namespace} to mode ${mode}" + + if ! ip -n "${namespace}" link set "${team}" down; then + echo "Failed to bring team device down" + return 1 + fi + if ! ip netns exec "${namespace}" teamnl "${team}" setoption mode \ + "${mode}"; then + echo "Failed to set ${team} mode to '${mode}'" + return 1 + fi + + # Aggregate the members into teams. + for member in "${members[@]}"; do + ip -n "${namespace}" link set "${member}" master "${team}" + done + + # Bring team devices up and give them addresses. + if ! ip -n "${namespace}" link set "${team}" up; then + echo "Failed to set ${team} up" + return 1 + fi + + # shellcheck disable=3DSC2086 + if ! ip -n "${namespace}" addr add "${ip_address}/${prefix_length}" \ + ${NODAD} dev "${team}"; then + echo "Failed to give ${team} IP address in ${namespace}" + return 1 + fi +} + +# This is global used to keep track of the sender's iperf3 process, so tha= t it +# can be terminated. +declare sender_pid + +# Start sending and receiving TCP traffic with iperf3. +# Globals: +# sender_pid - The process ID of the iperf3 sender process. Used to kill = it +# later. +start_listening_and_sending() +{ + ip netns exec "${NS2}" iperf3 -s -p 1234 --logfile /dev/null & + # Wait for server to become reachable before starting client. + slowwait 5 ip netns exec "${NS1}" iperf3 -c "${NS2_IP}" -p 1234 -t 1 \ + --logfile /dev/null + ip netns exec "${NS1}" iperf3 -c "${NS2_IP}" -p 1234 -b 1M -l 1K -t 0 \ + --logfile /dev/null & + sender_pid=3D$! +} + +# Stop sending TCP traffic with iperf3. +# Globals: +# sender_pid - The process IF of the iperf3 sender process. +stop_sending_and_listening() +{ + kill "${sender_pid}" && wait "${sender_pid}" 2>/dev/null || true +} + +# Read RX packet counters to determine if interface received traffic. +# Arguments: +# interface - The name of the interface to count packets for. +# namespace - The name of the namespace that the interface is in. +did_interface_receive() +{ + local interface=3D"$1" + local namespace=3D"$2" + local count1 count2 diff + + count1=3D$(ip netns exec "${namespace}" cat \ + "/sys/class/net/${interface}/statistics/rx_packets") + sleep 1 + count2=3D$(ip netns exec "${namespace}" cat \ + "/sys/class/net/${interface}/statistics/rx_packets") + diff=3D$((count2 - count1)) + + echo "Packet count for ${interface} was ${diff}" + + if [[ "${diff}" -gt 0 ]]; then + true + else + false + fi +} diff --git a/tools/testing/selftests/drivers/net/team/transmit_failover.sh = b/tools/testing/selftests/drivers/net/team/transmit_failover.sh new file mode 100755 index 000000000000..212d650caf66 --- /dev/null +++ b/tools/testing/selftests/drivers/net/team/transmit_failover.sh @@ -0,0 +1,151 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +# These tests verify the basic failover capability of the team driver via = the +# `enabled` team driver option across different team driver modes. This do= es not +# rely on teamd, and instead just uses teamnl to set the `enabled` option +# directly. +# +# Topology: +# +# +-------------------------+ NS1 +# | test_team1 | +# | + | +# | eth0 | eth1 | +# | +---+---+ | +# | | | | +# +-------------------------+ +# | | +# +-------------------------+ NS2 +# | | | | +# | +-------+ | +# | eth0 | eth1 | +# | + | +# | test_team2 | +# +-------------------------+ + +export ALL_TESTS=3D"team_test_failover" + +test_dir=3D"$(dirname "$0")" +# shellcheck disable=3DSC1091 +source "${test_dir}/../../../net/lib.sh" +# shellcheck disable=3DSC1091 +source "${test_dir}/team_lib.sh" + +NS1=3D"" +NS2=3D"" +export NODAD=3D"nodad" +PREFIX_LENGTH=3D"64" +NS1_IP=3D"fd00::1" +NS2_IP=3D"fd00::2" +NS1_IP4=3D"192.168.0.1" +NS2_IP4=3D"192.168.0.2" +MEMBERS=3D("eth0" "eth1") + +while getopts "4" opt; do + case $opt in + 4) + echo "IPv4 mode selected." + export NODAD=3D + PREFIX_LENGTH=3D"24" + NS1_IP=3D"${NS1_IP4}" + NS2_IP=3D"${NS2_IP4}" + ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + exit 1 + ;; + esac +done + +# Create the network namespaces, veth pair, and team devices in the specif= ied +# mode. +# Globals: +# RET - Used by test infra, set by `check_err` functions. +# Arguments: +# mode - The team driver mode to use for the team devices. +environment_create() +{ + trap cleanup_all_ns EXIT + setup_ns ns1 ns2 + NS1=3D"${NS_LIST[0]}" + NS2=3D"${NS_LIST[1]}" + + # Create the interfaces. + ip -n "${NS1}" link add eth0 type veth peer name eth0 netns "${NS2}" + ip -n "${NS1}" link add eth1 type veth peer name eth1 netns "${NS2}" + ip -n "${NS1}" link add test_team1 type team + ip -n "${NS2}" link add test_team2 type team + + # Set up the receiving network namespace's team interface. + setup_team "${NS2}" test_team2 roundrobin "${NS2_IP}" \ + "${PREFIX_LENGTH}" "${MEMBERS[@]}" +} + + +# Check that failover works for a specific team driver mode. +# Globals: +# RET - Used by test infra, set by `check_err` functions. +# Arguments: +# mode - The mode to set the team interfaces to. +team_test_mode_failover() +{ + local mode=3D"$1" + export RET=3D0 + + # Set up the sender team with the correct mode. + setup_team "${NS1}" test_team1 "${mode}" "${NS1_IP}" \ + "${PREFIX_LENGTH}" "${MEMBERS[@]}" + check_err $? "Failed to set up sender team" + + start_listening_and_sending + + ### Scenario 1: All interfaces initially enabled. + did_interface_receive eth0 "${NS2}" + check_err $? "eth0 not transmitting when both links enabled" + did_interface_receive eth1 "${NS2}" + check_err $? "eth1 not transmitting when both links enabled" + + ### Scenario 2: One tx-side interface disabled. + ip netns exec "${NS1}" teamnl test_team1 setoption enabled false \ + --port=3Deth1 + slowwait 2 bash -c "ip netns exec ${NS1} teamnl test_team1 getoption \ + enabled --port=3Deth1 | grep -q false" + + did_interface_receive eth0 "${NS2}" + check_err $? "eth0 not transmitting when enabled" + did_interface_receive eth1 "${NS2}" + check_fail $? "eth1 IS transmitting when disabled" + + ### Scenario 3: The interface is re-enabled. + ip netns exec "${NS1}" teamnl test_team1 setoption enabled true \ + --port=3Deth1 + slowwait 2 bash -c "ip netns exec ${NS1} teamnl test_team1 getoption \ + enabled --port=3Deth1 | grep -q true" + + did_interface_receive eth0 "${NS2}" + check_err $? "eth0 not transmitting when both links enabled" + did_interface_receive eth1 "${NS2}" + check_err $? "eth1 not transmitting when both links enabled" + + log_test "Failover of '${mode}' test" + + # Clean up + stop_sending_and_listening +} + +team_test_failover() +{ + team_test_mode_failover broadcast + team_test_mode_failover roundrobin + team_test_mode_failover random + # Don't test `activebackup` or `loadbalance` modes, since they are too + # complicated for just setting `enabled` to work. They use more than + # the `enabled` option for transmit. +} + +require_command teamnl +require_command iperf3 +environment_create +tests_run +exit "${EXIT_STATUS}" --=20 2.53.0.1185.g05d4b7b318-goog From nobody Sun Apr 5 13:12:23 2026 Received: from mail-dl1-f74.google.com (mail-dl1-f74.google.com [74.125.82.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5DEDB376BFB for ; Fri, 3 Apr 2026 07:14:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775200479; cv=none; b=h0FpI9FTfttHBx2eKFb6KOMs53RMgVykrnh09huUJZOwM5Vsy4MCqNAmW0pZUjuNQwN6mOu4+9ai/BQDKTZQKOWQC6cjcVyVxUnrCIedOyMIFbwChaj5euMCgWaH+Y5nujrIg06VyozboKtn4QqDfY4NFhf5uRyOEQOPnxjp7nU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775200479; c=relaxed/simple; bh=B1CUHr6cyj7dXHUCHEQXJx2KVZ46yecg3Gc0EUFXTkI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=uN24JJXqE3SpD+yukT3v1MLhEt0+ycKRYwZqPl80xTZnHdq4r7eHEgzv2Tdp3Yy/emKddjRmPgjRwrrZaMqeRZoOoUhT/Ct9i42CUbukujCeCDARfXt2V70AgtZQnC9xqhWFw244J/Mp194SHieMXavJlpJTae7HxUDkJL1LpzA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--marcharvey.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=tqzRKvC1; arc=none smtp.client-ip=74.125.82.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--marcharvey.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="tqzRKvC1" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-1279caef718so2790893c88.1 for ; Fri, 03 Apr 2026 00:14:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775200477; x=1775805277; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=dHW/Kj+WoZEi+6uAOeMCAmInrznHjYR3guz1LxHCc1k=; b=tqzRKvC1KIhIFCvatxs4ZroZFiqLpXMBqDnEr6EuQPVKG3DWKZpKw0rguFfFE1M8zk lh3cWL4ARsb6HGrtXUbY0GWKIsQiHkx68O3HoSInaf0tSyj6THOS4T2Q661XdKSZ6Dv/ MLnGzYZc8inQuLdPoSRurOrpe5/GxcJf/myr5xCH4s66cQQ7erc8Yc7mVxEO/rROABii Jch14tvfSx5zdvIEy4VQ4yFRVooJR+lIbcoKQJF39VlFcHJ8H6oQwZ/Jf5+KWnXgmDGj bhC8dwKSMclmX+BzxSVEc9kbD5Pug/YVJpG8Ufqy24eANhe2xbQ/NLVgnLuGMvBfhfLD 0w8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775200477; x=1775805277; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=dHW/Kj+WoZEi+6uAOeMCAmInrznHjYR3guz1LxHCc1k=; b=RSRDJF8dPhx3L/wygiFuBhaNLkexutjEq7UX8nntDycV9LkIEDAlNLxPz0hvsJSYBo hAsMrernVgpePiI6N6oBtx+/wvGIABVbyVfeybakQHbs7rY+VTGcHh/VHXMVkWAF7GCw ATF8LcRbNN4b9mLebC0LAmQGirxV97RTS1KTWBQL7qlsy+oROzTkuNldEQrrzaMtzh6E Itb3QqmSvsJy2AdmfOrSTNlJvf/5Y3+PicEhgiLwiPpp4VF7X4RmQglpbh71sR9flK/u rH6yeHrjQY4+W/QTmcN3JkA9HD3jdk5NtpUpUcaDO36sR+5AtiBbbr36sfI2gex52GGX efRg== X-Forwarded-Encrypted: i=1; AJvYcCXohhIXp24rjYAJlKBwYmHLp3muSDLCyNT6r8b3hjhwm1HvpPtTMwd5gFPcyov/YwQz+hR39/FRcl+pWUo=@vger.kernel.org X-Gm-Message-State: AOJu0YxSd79j+GQvY9TIAg6hd5+EYVrrkdrPHbaVRrRaFKcNDsfPE4Sw zWuWijpX2n446wE2BsWF2iKu1OrpFkoxkUTF7SDNAG3wEh2DhnBHOnQwBCT1BlJ/GPX/YO6I3Q1 fmOM3BGZcEvBCcDqIzj6CdA== X-Received: from dlak22.prod.google.com ([2002:a05:701b:2916:b0:12a:6d14:dfd9]) (user=marcharvey job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:929:b0:127:380e:ff5a with SMTP id a92af1059eb24-12bfb73e31emr956624c88.17.1775200477366; Fri, 03 Apr 2026 00:14:37 -0700 (PDT) Date: Fri, 03 Apr 2026 07:14:26 +0000 In-Reply-To: <20260403-teaming-driver-internal-v4-0-d3032f33ca25@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260403-teaming-driver-internal-v4-0-d3032f33ca25@google.com> X-Developer-Key: i=marcharvey@google.com; a=ed25519; pk=OzOeciadbfF5Bug/4/hyEAwfrruSY4tn0Q0LocyYUL0= X-Developer-Signature: v=1; a=ed25519-sha256; t=1775200467; l=8380; i=marcharvey@google.com; s=20260401; h=from:subject:message-id; bh=B1CUHr6cyj7dXHUCHEQXJx2KVZ46yecg3Gc0EUFXTkI=; b=ozbwprojtwD9UJ4SvW3+EeQNlfHACJyBaWnDTI1Bp4UBwSkOTk+KL+z4Ki3uJB40h9XI36TUQ BhBuSjCOeJHDZbVJ0cYT4xQcRHDySEAKLq7LslClR8uvKsWTph8UVx/ X-Mailer: b4 0.14.3 Message-ID: <20260403-teaming-driver-internal-v4-5-d3032f33ca25@google.com> Subject: [PATCH net-next v4 05/10] selftests: net: Add test for enablement of ports with teamd From: Marc Harvey To: Jiri Pirko , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Marc Harvey Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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. Signed-off-by: Marc Harvey --- Changes in v4: - None Changed in v3: - Make test cleanup kill teamd instead of terminate. - Link to v2: https://lore.kernel.org/netdev/20260401-teaming-driver-intern= al-v2-5-f80c1291727b@google.com/ 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/20260331053353.2504254-6-marcharv= ey@google.com/ --- tools/testing/selftests/drivers/net/team/Makefile | 1 + .../drivers/net/team/teamd_activebackup.sh | 217 +++++++++++++++++= ++++ tools/testing/selftests/net/lib.sh | 13 ++ 3 files changed, 231 insertions(+) diff --git a/tools/testing/selftests/drivers/net/team/Makefile b/tools/test= ing/selftests/drivers/net/team/Makefile index 777da2e0429e..dab922d7f83d 100644 --- a/tools/testing/selftests/drivers/net/team/Makefile +++ b/tools/testing/selftests/drivers/net/team/Makefile @@ -7,6 +7,7 @@ TEST_PROGS :=3D \ options.sh \ propagation.sh \ refleak.sh \ + teamd_activebackup.sh \ transmit_failover.sh \ # end of TEST_PROGS =20 diff --git a/tools/testing/selftests/drivers/net/team/teamd_activebackup.sh= b/tools/testing/selftests/drivers/net/team/teamd_activebackup.sh new file mode 100755 index 000000000000..aa882e1ee3d8 --- /dev/null +++ b/tools/testing/selftests/drivers/net/team/teamd_activebackup.sh @@ -0,0 +1,217 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +# These tests verify that teamd is able to enable and disable ports via the +# active backup runner. +# +# Topology: +# +# +-------------------------+ NS1 +# | test_team1 | +# | + | +# | eth0 | eth1 | +# | +---+---+ | +# | | | | +# +-------------------------+ +# | | +# +-------------------------+ NS2 +# | | | | +# | +-------+ | +# | eth0 | eth1 | +# | + | +# | test_team2 | +# +-------------------------+ + +export ALL_TESTS=3D"teamd_test_active_backup" + +test_dir=3D"$(dirname "$0")" +# shellcheck disable=3DSC1091 +source "${test_dir}/../../../net/lib.sh" +# shellcheck disable=3DSC1091 +source "${test_dir}/team_lib.sh" + +NS1=3D"" +NS2=3D"" +export NODAD=3D"nodad" +PREFIX_LENGTH=3D"64" +NS1_IP=3D"fd00::1" +NS2_IP=3D"fd00::2" +NS1_IP4=3D"192.168.0.1" +NS2_IP4=3D"192.168.0.2" +NS1_TEAMD_CONF=3D"" +NS2_TEAMD_CONF=3D"" +NS1_TEAMD_PID=3D"" +NS2_TEAMD_PID=3D"" + +while getopts "4" opt; do + case $opt in + 4) + echo "IPv4 mode selected." + export NODAD=3D + PREFIX_LENGTH=3D"24" + NS1_IP=3D"${NS1_IP4}" + NS2_IP=3D"${NS2_IP4}" + ;; + \?) + echo "Invalid option: -${OPTARG}" >&2 + exit 1 + ;; + esac +done + +teamd_config_create() +{ + local runner=3D$1 + local dev=3D$2 + local conf + + conf=3D$(mktemp) + + cat > "${conf}" <<-EOF + { + "device": "${dev}", + "runner": {"name": "${runner}"}, + "ports": { + "eth0": {}, + "eth1": {} + } + } + EOF + echo "${conf}" +} + +# Create the network namespaces, veth pair, and team devices in the specif= ied +# runner. +# Globals: +# RET - Used by test infra, set by `check_err` functions. +# Arguments: +# runner - The Teamd runner to use for the Team devices. +environment_create() +{ + local runner=3D$1 + + echo "Setting up two-link aggregation for runner ${runner}" + trap environment_destroy EXIT + + setup_ns ns1 ns2 + NS1=3D"${NS_LIST[0]}" + NS2=3D"${NS_LIST[1]}" + + for link in $(seq 0 1); do + ip -n "${NS1}" link add "eth${link}" type veth peer name \ + "eth${link}" netns "${NS2}" + check_err $? "Failed to create veth pair" + done + + NS1_TEAMD_CONF=3D$(teamd_config_create "${runner}" "test_team1") + NS2_TEAMD_CONF=3D$(teamd_config_create "${runner}" "test_team2") + echo "Conf files are ${NS1_TEAMD_CONF} and ${NS2_TEAMD_CONF}" + + ip netns exec "${NS1}" teamd -d -f "${NS1_TEAMD_CONF}" + check_err $? "Failed to create team device in ${NS1}" + NS1_TEAMD_PID=3D$(pgrep -f "teamd -d -f ${NS1_TEAMD_CONF}") + + ip netns exec "${NS2}" teamd -d -f "${NS2_TEAMD_CONF}" + check_err $? "Failed to create team device in ${NS2}" + NS2_TEAMD_PID=3D$(pgrep -f "teamd -d -f ${NS2_TEAMD_CONF}") + + echo "Created team devices" + + rm "${NS1_TEAMD_CONF}" + rm "${NS2_TEAMD_CONF}" + NS1_TEAMD_CONF=3D"" + NS2_TEAMD_CONF=3D"" + + for link in $(seq 0 1); do + in_all_ns "ip link set eth${link} up" + check_err $? "Failed to set eth${link} up" + done + + ip -n "${NS1}" link set test_team1 up + check_err $? "Failed to set test_team1 up in ${NS1}" + ip -n "${NS2}" link set test_team2 up + check_err $? "Failed to set test_team2 up in ${NS2}" + + ip -n "${NS1}" addr add "${NS1_IP}/${PREFIX_LENGTH}" "${NODAD}" dev \ + test_team1 + check_err $? "Failed to add address to team device in ${NS1}" + ip -n "${NS2}" addr add "${NS2_IP}/${PREFIX_LENGTH}" "${NODAD}" dev \ + test_team2 + check_err $? "Failed to add address to team device in ${NS2}" + + slowwait 2 timeout 0.5 ip netns exec "${NS1}" ping -W 1 -c 1 "${NS2_IP}" +} + +# Tear down the environment: kill teamd and delete network namespaces. +environment_destroy() +{ + echo "Tearing down two-link aggregation" + if [ -n "${NS1_TEAMD_PID}" ]; then + kill -9 "${NS1_TEAMD_PID}" 2>/dev/null + fi + if [ -n "${NS2_TEAMD_PID}" ]; then + kill -9 "${NS2_TEAMD_PID}" 2>/dev/null + fi + cleanup_all_ns +} + +# Change the active port for an active-backup mode team. +# Arguments: +# namespace - The network namespace that the team is in. +# team - The name of the team. +# active_port - The port to make active. +set_active_port() +{ + local namespace=3D$1 + local team=3D$2 + local active_port=3D$3 + + ip netns exec "${namespace}" teamdctl "${team}" state item set \ + runner.active_port "${active_port}" + slowwait 2 bash -c "ip netns exec ${namespace} teamdctl ${team} state \ + item get runner.active_port | grep -q ${active_port}" +} + +# Test that active backup runner can change active ports. +# Globals: +# RET - Used by test infra, set by `check_err` functions. +teamd_test_active_backup() +{ + export RET=3D0 + + start_listening_and_sending + + ### Scenario 1: Don't manually set active port, just make sure team + # works. + did_interface_receive test_team2 "${NS2}" + check_err $? "Traffic did not reach team interface in NS2." + + ### Scenario 2: Choose active port. + set_active_port "${NS1}" test_team1 eth1 + set_active_port "${NS2}" test_team2 eth1 + + did_interface_receive eth0 "${NS2}" + check_fail $? "eth0 IS transmitting when disabled" + did_interface_receive eth1 "${NS2}" + check_err $? "eth1 not transmitting when enabled" + + ### Scenario 3: Change active port. + set_active_port "${NS1}" test_team1 eth0 + set_active_port "${NS2}" test_team2 eth0 + + did_interface_receive eth0 "${NS2}" + check_err $? "eth0 not transmitting when enabled" + did_interface_receive eth1 "${NS2}" + check_fail $? "eth1 IS transmitting when disabled" + + log_test "teamd active backup runner test" + + stop_sending_and_listening +} + +require_command teamd +require_command teamdctl +require_command iperf3 +environment_create activebackup +tests_run +exit "${EXIT_STATUS}" diff --git a/tools/testing/selftests/net/lib.sh b/tools/testing/selftests/n= et/lib.sh index e915386daf1b..8efa782dd4fd 100644 --- a/tools/testing/selftests/net/lib.sh +++ b/tools/testing/selftests/net/lib.sh @@ -224,6 +224,19 @@ setup_ns() NS_LIST+=3D("${ns_list[@]}") } =20 +in_all_ns() +{ + local ret=3D0 + local ns_list=3D("${NS_LIST[@]}") + + for ns in "${ns_list[@]}"; do + ip netns exec "${ns}" bash -c "$@" + (( ret =3D ret || $? )) + done + + return "${ret}" +} + # Create netdevsim with given id and net namespace. create_netdevsim() { local id=3D"$1" --=20 2.53.0.1185.g05d4b7b318-goog From nobody Sun Apr 5 13:12:23 2026 Received: from mail-dl1-f73.google.com (mail-dl1-f73.google.com [74.125.82.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C53938239E for ; Fri, 3 Apr 2026 07:14:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775200482; cv=none; b=SYoK7B38dtep1Ho2LmbgC5A4KOp8HFQofpf33a8g69lwaRkhrL2PlLCmkIt2zplh3rD9If7S9+DlnluJsnPz+tScs96V/BS57Dr5xBDa/UvMzpaxesLmaEZ4KWx3bfwM8yhdd727/oq/njbg8JdRBGgwZ8WZQmr5h9Vnt4qkLkA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775200482; c=relaxed/simple; bh=4PUls2oj7ppWeKiHoSHVX2Wv6E8OBa71oEbXDoIg5IM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=lNlnZ8cRFw5fODuhAjv2fhDPV/MmSt09c44qkcl1Q6a0L8OWRsNQ7XqaF8NiXQ2GVsDz05+f2BwrSZspMWXXuTTils4qPFwsDlyfKWxeVxFc5SvLwsbilQGlTwbot+fggJ91k4XKR+FoCnsdpt7kbVv50545KGAMkiXdyCALBMU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--marcharvey.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=U+xLo7pN; arc=none smtp.client-ip=74.125.82.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--marcharvey.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="U+xLo7pN" Received: by mail-dl1-f73.google.com with SMTP id a92af1059eb24-1279caef718so2790969c88.1 for ; Fri, 03 Apr 2026 00:14:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775200479; x=1775805279; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=uE0XUNqqove55/a0CwAGts/FuLqGmOy8m8bmvEm3lok=; b=U+xLo7pNJv4vr3M6zlarl6TzuhJBF3aqM5XGV0SrNGaR4H+hBMxOZmSNv7Nm3QT26G 2HebBvu4js5+TdHX6BCghmz8B8Tx4OL5Y/k+jUx+jO+cCTree5AXLtN5wdkWy8CHKzVv w2v1FAjp54TaaI/QDilyCBJRWDqB2Fq+cvpdGRzsNfiEO6xkuBiAVUUuloyAq7nM/GMx yOSb6HWkuCJVm7WUnbP/05GbVkWuMDf5ic6QTsyjRUIB0byiFSP24uSOa5A5z8cVN9MO Sxdyq/agpRfiQnpnLE+to5yMugQqE2kbPwSt52UIO29ALOXliEDx5Rhl/vaUiJFSuJLC CJhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775200479; x=1775805279; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uE0XUNqqove55/a0CwAGts/FuLqGmOy8m8bmvEm3lok=; b=LW/PwVXKkODHstTw1tEWY8PoOaPO/oDxLU84kA3DSiOFrvQ2duLJdOwJnsjLgzq0iQ EbfKwptaDJqlUpBrW3hi/whIhW83fQ68JL9dSXphGIqWUUpUwhCupiXj+IfMF8jcu33V VhQQ0i/u/Hh2slVoD/7IPkpN/xs2nhmsVoU8ON+Q0lGpfPup5OLWIcup17hgfODdEW8R VZzXLwGNtlu2/ZnrbRo2BVdIaLvganF0b7nTG4FVXEMa4QjqzAfIDSBEstlHkSENin5G PbmlicMp3toT2hmy9kUqk5g4z6WtZMdwB34KQF4zSq4akjhoQfZ8r/oWMRvRmkfGe3I2 BZxg== X-Forwarded-Encrypted: i=1; AJvYcCV5FO/n/0q+2nOTwBYSGiLkZEO5YxDt62RfjX6TDsW+tYGnRP5yn/H96y0OAe09YohxpFmBtSmvN22MKq0=@vger.kernel.org X-Gm-Message-State: AOJu0YywAp4KZohrNWHFc0s2Edp6MUe+hRCci3RdCWFXJcMeFmt4XSfc 1eVf1aeBfak8H3M7jryyhj/P9lQ9L9jWJNzYZqZbDbjrCr5IZEsRoxKkKoJUdrdT/p3CN8fBvBh HX696B45G7JlKI7Ovrp1yfg== X-Received: from dlbrl13.prod.google.com ([2002:a05:7022:f50d:b0:12a:6c32:ffd2]) (user=marcharvey job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:4386:b0:11b:9e5e:1a40 with SMTP id a92af1059eb24-12bfb70eb13mr897206c88.15.1775200479082; Fri, 03 Apr 2026 00:14:39 -0700 (PDT) Date: Fri, 03 Apr 2026 07:14:27 +0000 In-Reply-To: <20260403-teaming-driver-internal-v4-0-d3032f33ca25@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260403-teaming-driver-internal-v4-0-d3032f33ca25@google.com> X-Developer-Key: i=marcharvey@google.com; a=ed25519; pk=OzOeciadbfF5Bug/4/hyEAwfrruSY4tn0Q0LocyYUL0= X-Developer-Signature: v=1; a=ed25519-sha256; t=1775200467; l=10710; i=marcharvey@google.com; s=20260401; h=from:subject:message-id; bh=4PUls2oj7ppWeKiHoSHVX2Wv6E8OBa71oEbXDoIg5IM=; b=xRJ/9M7NSbsYBgx1A8enBQLWj3QWAZn9v0s0cAbsAKR30hP4ENVcFwLGgJHDc6iFIyQibixgv hEbQaxiF7m1CCxbdni4m6zcRTQkrYf4X07NxS7XmmMyS6BO21cHYch+ X-Mailer: b4 0.14.3 Message-ID: <20260403-teaming-driver-internal-v4-6-d3032f33ca25@google.com> Subject: [PATCH net-next v4 06/10] net: team: Rename enablement functions and struct members to tx From: Marc Harvey To: Jiri Pirko , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Marc Harvey Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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. Signed-off-by: Marc Harvey --- 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/20260402-teaming-driver-intern= al-v3-6-e8cfdec3b5c2@google.com/ --- 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(-) diff --git a/drivers/net/team/team_core.c b/drivers/net/team/team_core.c index 2ce31999c99f..826769473878 100644 --- a/drivers/net/team/team_core.c +++ b/drivers/net/team/team_core.c @@ -532,13 +532,13 @@ static void team_adjust_ops(struct team *team) * correct ops are always set. */ =20 - 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 =3D team_dummy_transmit; else team->ops.transmit =3D team->mode->ops->transmit; =20 - 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 =3D team_dummy_receive; else @@ -831,7 +831,7 @@ static bool team_queue_override_port_has_gt_prio_than(s= truct 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, =20 /* * 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, =20 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; =20 - for (i =3D rm_index + 1; i < team->en_port_count; i++) { - port =3D 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 =3D rm_index + 1; i < team->tx_en_port_count; i++) { + port =3D 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 =3D team_tx_port_index_hash(team, + port->tx_index); + hlist_add_head_rcu(&port->tx_hlist, tx_port_index_hash); } } =20 @@ -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 ne= t_device *port_dev, netif_addr_unlock_bh(dev); } =20 - 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; =20 for (i =3D 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 =3D team_queue_override_init(team); if (err) diff --git a/drivers/net/team/team_mode_loadbalance.c b/drivers/net/team/te= am_mode_loadbalance.c index 840f409d250b..4833fbfe241e 100644 --- a/drivers/net/team/team_mode_loadbalance.c +++ b/drivers/net/team/team_mode_loadbalance.c @@ -120,7 +120,7 @@ static struct team_port *lb_hash_select_tx_port(struct = team *team, { int port_index =3D team_num_to_port_index(team, hash); =20 - return team_get_port_by_index_rcu(team, port_index); + return team_get_port_by_tx_index_rcu(team, port_index); } =20 /* Hash to port mapping select tx port */ diff --git a/drivers/net/team/team_mode_random.c b/drivers/net/team/team_mo= de_random.c index 169a7bc865b2..370e974f3dca 100644 --- a/drivers/net/team/team_mode_random.c +++ b/drivers/net/team/team_mode_random.c @@ -16,8 +16,8 @@ static bool rnd_transmit(struct team *team, struct sk_buf= f *skb) struct team_port *port; int port_index; =20 - port_index =3D get_random_u32_below(READ_ONCE(team->en_port_count)); - port =3D team_get_port_by_index_rcu(team, port_index); + port_index =3D get_random_u32_below(READ_ONCE(team->tx_en_port_count)); + port =3D team_get_port_by_tx_index_rcu(team, port_index); if (unlikely(!port)) goto drop; port =3D team_get_first_port_txable_rcu(team, port); diff --git a/drivers/net/team/team_mode_roundrobin.c b/drivers/net/team/tea= m_mode_roundrobin.c index dd405d82c6ac..ecbeef28c221 100644 --- a/drivers/net/team/team_mode_roundrobin.c +++ b/drivers/net/team/team_mode_roundrobin.c @@ -27,7 +27,7 @@ static bool rr_transmit(struct team *team, struct sk_buff= *skb) =20 port_index =3D team_num_to_port_index(team, rr_priv(team)->sent_packets++); - port =3D team_get_port_by_index_rcu(team, port_index); + port =3D team_get_port_by_tx_index_rcu(team, port_index); if (unlikely(!port)) goto drop; port =3D team_get_first_port_txable_rcu(team, port); diff --git a/include/linux/if_team.h b/include/linux/if_team.h index 740cb3100dfc..c777170ef552 100644 --- a/include/linux/if_team.h +++ b/include/linux/if_team.h @@ -27,10 +27,10 @@ struct team; =20 struct team_port { struct net_device *dev; - struct hlist_node hlist; /* node in enabled ports hash list */ + struct hlist_node tx_hlist; /* node in tx-enabled ports hash list */ struct list_head list; /* node in ordinary list */ struct team *team; - int index; /* index of enabled port. If disabled, it's set to -1 */ + int tx_index; /* index of tx enabled port. If disabled, -1 */ =20 bool linkup; /* either state.linkup or user.linkup */ =20 @@ -77,7 +77,7 @@ static inline struct team_port *team_port_get_rcu(const s= truct net_device *dev) =20 static inline bool team_port_enabled(struct team_port *port) { - return READ_ONCE(port->index) !=3D -1; + return READ_ONCE(port->tx_index) !=3D -1; } =20 static inline bool team_port_txable(struct team_port *port) @@ -190,10 +190,10 @@ struct team { const struct header_ops *header_ops_cache; =20 /* - * List of enabled ports and their count + * List of tx-enabled ports and counts of rx and tx-enabled ports. */ - int en_port_count; - struct hlist_head en_port_hlist[TEAM_PORT_HASHENTRIES]; + int tx_en_port_count; + struct hlist_head tx_en_port_hlist[TEAM_PORT_HASHENTRIES]; =20 struct list_head port_list; /* list of all ports */ =20 @@ -237,41 +237,43 @@ static inline int team_dev_queue_xmit(struct team *te= am, struct team_port *port, return dev_queue_xmit(skb); } =20 -static inline struct hlist_head *team_port_index_hash(struct team *team, - int port_index) +static inline struct hlist_head *team_tx_port_index_hash(struct team *team, + int tx_port_index) { - return &team->en_port_hlist[port_index & (TEAM_PORT_HASHENTRIES - 1)]; + unsigned int list_entry =3D tx_port_index & (TEAM_PORT_HASHENTRIES - 1); + + return &team->tx_en_port_hlist[list_entry]; } =20 -static inline struct team_port *team_get_port_by_index(struct team *team, - int port_index) +static inline struct team_port *team_get_port_by_tx_index(struct team *tea= m, + int tx_port_index) { + struct hlist_head *head =3D team_tx_port_index_hash(team, tx_port_index); struct team_port *port; - struct hlist_head *head =3D team_port_index_hash(team, port_index); =20 - hlist_for_each_entry(port, head, hlist) - if (port->index =3D=3D port_index) + hlist_for_each_entry(port, head, tx_hlist) + if (port->tx_index =3D=3D tx_port_index) return port; return NULL; } =20 static inline int team_num_to_port_index(struct team *team, unsigned int n= um) { - int en_port_count =3D READ_ONCE(team->en_port_count); + int tx_en_port_count =3D READ_ONCE(team->tx_en_port_count); =20 - if (unlikely(!en_port_count)) + if (unlikely(!tx_en_port_count)) return 0; - return num % en_port_count; + return num % tx_en_port_count; } =20 -static inline struct team_port *team_get_port_by_index_rcu(struct team *te= am, - int port_index) +static inline struct team_port *team_get_port_by_tx_index_rcu(struct team = *team, + int tx_port_index) { + struct hlist_head *head =3D team_tx_port_index_hash(team, tx_port_index); struct team_port *port; - struct hlist_head *head =3D team_port_index_hash(team, port_index); =20 - hlist_for_each_entry_rcu(port, head, hlist) - if (READ_ONCE(port->index) =3D=3D port_index) + hlist_for_each_entry_rcu(port, head, tx_hlist) + if (READ_ONCE(port->tx_index) =3D=3D tx_port_index) return port; return NULL; } --=20 2.53.0.1185.g05d4b7b318-goog From nobody Sun Apr 5 13:12:23 2026 Received: from mail-dy1-f202.google.com (mail-dy1-f202.google.com [74.125.82.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C625C38643B for ; Fri, 3 Apr 2026 07:14:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775200483; cv=none; b=RCjJOGwc0jn7Da0E+R+K2UIh7C0QhIQl/3N2dKybnKC/ECTBG6DiNQyrTJOEtIAohNs+B1+ku6/AePiRzL5AcCqhdM3t3I3PIcwIb7bjj21tXgi0ABRqQo6WKUjoU7TdKgIHPgkrwEwY2VBuGDcEMXpKCDqSLzUluvntaU6wx+k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775200483; c=relaxed/simple; bh=IBHKnjHvN0686H6wGmzBNFiUh2lW+6wSCrOsJW7Imdw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=pktI/9MWdligSSTXFJojc6/h8NycvjCX+Drnciwqd5YmAeku3vXy/lNeoKA5LURMZqPA9RYIFX77xUsxAk5FxJ56FXOdFuWCKSM2At4mzOmjFdk5uNd0LsOZxWkRy6rkqbwAk0jnYYWkB9i551APo0vcZWiZVdF+JV/9hXgu+GY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--marcharvey.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=US2q6lVQ; arc=none smtp.client-ip=74.125.82.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--marcharvey.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="US2q6lVQ" Received: by mail-dy1-f202.google.com with SMTP id 5a478bee46e88-2ba9a744f7dso2433714eec.0 for ; Fri, 03 Apr 2026 00:14:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775200481; x=1775805281; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=S9b7ncp2n1BmDNM5shtlXSZlN1OT8DIe5j7j07dqIEw=; b=US2q6lVQZwJuXQ4V53IIzB3XNpjwPZ1V+2oRDsM2UEKDR49fWJDwMfSoJ09J+iDHnY 1NDzl7A0O2bjMVksjvuEkzyLkesOHJU+4TGhm9UjXwgAmUB892aATl38tSppmAa++tkV tEFv+46Df/wWDYczoXg45Obt2c6kCXTRnWJ1B+DVmqz/+tAPT01RtybJGFPW8uH6BZlC U2JJg7RuC4qd7lQdj2K+SU+3CJf/OI3tK74tRpNVnMu5O7ADfLYQPqQxIYv1ftmf5dj2 ALQ5pWplYGOKCTEJ6ww5gL601PiMimI91ZLI4ViMGZ9Z3lwckulN/dIZ+SuXKMIdMOYD EbuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775200481; x=1775805281; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=S9b7ncp2n1BmDNM5shtlXSZlN1OT8DIe5j7j07dqIEw=; b=jwHYXbo1lR4GpoQ/XqlWP3hTtrla7OTg8r6eSHFFNuA4qXY7I9kq10cgY8cT150uFi 3r5sGoZOssGrOO594fmiYxn9eUI6pSZOiryoB3EzKu5FCAIo/rUV8Tc+12JHk3ZY4GPz gw+wpeyxRPErMD5ouzjlkXYNn0y3dVCvgCjB+0vFwAEbsH0sRQK2q08NDP/dH0Yu+LRs 1B+GTh2nowEEyPMeo8dICTDYz4TdyLWe/dqGPiZVp64Qp9tVgkQ3JO0ZATWLR0m2xcVD FijxV+Vk4nX+edpdFkYyN7vaDtk3lh9veL51HgxSN7iDjdEXGRsaQO35rRIKdHSyXDKb H2Jw== X-Forwarded-Encrypted: i=1; AJvYcCVhZT5LGHEU4s5labzSTqAYMyylA4h4TuoH2gbkbcnRTW7gbWb0e9n8TiiWwyLgdvkK2CncCYNlPAENyxU=@vger.kernel.org X-Gm-Message-State: AOJu0YzAT++IZGOfl+qi/E/j1PP6KgXrxz8yL46pu6OGz2CehKWkHyMQ Dg/dAhPrltVdEii/Viw2Hu9dOEqCrpb4mnW7lXuF0AhhlhxTVBOSuvWVjwBtfYPj7DDGFfhcu2D aCPbu9GQtBJrEICUJloqeRQ== X-Received: from dyckg22.prod.google.com ([2002:a05:7301:d196:b0:2c6:55cf:de3a]) (user=marcharvey job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7301:4090:b0:2c1:7ea5:ec29 with SMTP id 5a478bee46e88-2cbf9af8882mr933292eec.4.1775200480763; Fri, 03 Apr 2026 00:14:40 -0700 (PDT) Date: Fri, 03 Apr 2026 07:14:28 +0000 In-Reply-To: <20260403-teaming-driver-internal-v4-0-d3032f33ca25@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260403-teaming-driver-internal-v4-0-d3032f33ca25@google.com> X-Developer-Key: i=marcharvey@google.com; a=ed25519; pk=OzOeciadbfF5Bug/4/hyEAwfrruSY4tn0Q0LocyYUL0= X-Developer-Signature: v=1; a=ed25519-sha256; t=1775200467; l=8749; i=marcharvey@google.com; s=20260401; h=from:subject:message-id; bh=IBHKnjHvN0686H6wGmzBNFiUh2lW+6wSCrOsJW7Imdw=; b=boDsAUwzJ3frTRyQVA8xaVfoWQI/aoMMKABFClLO7aYedlu3U3iKTOTVrzilVG8N8b55PyCf/ iVXXua7Qh3EDIu27CBqbZGhzhPfV1E0IrLlqO7pG7m91RQPQbbVA5rl X-Mailer: b4 0.14.3 Message-ID: <20260403-teaming-driver-internal-v4-7-d3032f33ca25@google.com> Subject: [PATCH net-next v4 07/10] net: team: Track rx enablement separately from tx enablement From: Marc Harvey To: Jiri Pirko , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Marc Harvey Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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. Signed-off-by: Marc Harvey --- 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/20260402-teaming-driver-intern= al-v3-6-e8cfdec3b5c2@google.com/ --- drivers/net/team/team_core.c | 105 ++++++++++++++++++++++++---= ---- drivers/net/team/team_mode_loadbalance.c | 2 +- include/linux/if_team.h | 16 ++++- 3 files changed, 96 insertions(+), 27 deletions(-) diff --git a/drivers/net/team/team_core.c b/drivers/net/team/team_core.c index 826769473878..0f95f2f04d27 100644 --- a/drivers/net/team/team_core.c +++ b/drivers/net/team/team_core.c @@ -87,7 +87,7 @@ static void team_lower_state_changed(struct team_port *po= rt) struct netdev_lag_lower_state_info info; =20 info.link_up =3D port->linkup; - info.tx_enabled =3D team_port_enabled(port); + info.tx_enabled =3D team_port_tx_enabled(port); netdev_lower_state_changed(port->dev, &info); } =20 @@ -538,7 +538,7 @@ static void team_adjust_ops(struct team *team) else team->ops.transmit =3D team->mode->ops->transmit; =20 - 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 =3D team_dummy_receive; else @@ -734,7 +734,7 @@ static rx_handler_result_t team_handle_frame(struct sk_= buff **pskb) =20 port =3D team_port_get_rcu(skb->dev); team =3D 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(st= ruct 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 =3D 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; } =20 +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); } =20 static void __reconstruct_port_hlist(struct team *team, int rm_index) @@ -965,20 +972,70 @@ static void __reconstruct_port_hlist(struct team *tea= m, int rm_index) } } =20 -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 =3D team_port_rx_enabled(port); + tx_was_enabled =3D 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_queue_override_port_add(team, port); + } + team_adjust_ops(team); - team_lower_state_changed(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 =3D team_port_rx_enabled(port); + bool tx_was_enabled =3D 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); + + if (tx_was_enabled) + team_lower_state_changed(port); } =20 static int team_port_enter(struct team *team, struct team_port *port) diff --git a/drivers/net/team/team_mode_loadbalance.c b/drivers/net/team/te= am_mode_loadbalance.c index 4833fbfe241e..38a459649569 100644 --- a/drivers/net/team/team_mode_loadbalance.c +++ b/drivers/net/team/team_mode_loadbalance.c @@ -380,7 +380,7 @@ static int lb_tx_hash_to_port_mapping_set(struct team *= team, =20 list_for_each_entry(port, &team->port_list, list) { if (ctx->data.u32_val =3D=3D 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; diff --git a/include/linux/if_team.h b/include/linux/if_team.h index c777170ef552..3d21e06fda67 100644 --- a/include/linux/if_team.h +++ b/include/linux/if_team.h @@ -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; =20 bool linkup; /* either state.linkup or user.linkup */ =20 @@ -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); } =20 -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) !=3D -1; } =20 +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); } =20 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]; =20 struct list_head port_list; /* list of all ports */ --=20 2.53.0.1185.g05d4b7b318-goog From nobody Sun Apr 5 13:12:23 2026 Received: from mail-dy1-f202.google.com (mail-dy1-f202.google.com [74.125.82.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 64CCB386C31 for ; Fri, 3 Apr 2026 07:14:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775200484; cv=none; b=HjWgWVt4sElXvaPi4HPGqkWdMF2oUYSbNNDxqZEi8OOwbpEYyzhdPSQdtusrP0/12oliCTuPpGxh2gVidlGWFkCJxI+gkQ2EULcT53j8yFtFjUxtB6+jlfVeQDJuXhF1QyVBgqVcYu0MGmgYJxnYBsAYORwPU24kV1kGnJSf2nQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775200484; c=relaxed/simple; bh=nuo0DHK7VQ/i6dfq7yT/KT+VIJKVcVO1c6MvP8D9yp0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=S4zLH+2rWIOoqNmWNCpT33a5lEIOv5Jc3WcyIPcGaLtNpyMkNfK0eyJbtWAnBn0qkowZqUlRO1AtzFg75vuco1vji6Wn4uajgyMz0tunTbBrMJsf50/PYbKs/xv3rKqtpTZAtSDbhL1mr5pOkOL+A4/wsY8QnB0sAUJCAJysWJs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--marcharvey.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=vyj9MDqa; arc=none smtp.client-ip=74.125.82.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--marcharvey.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="vyj9MDqa" Received: by mail-dy1-f202.google.com with SMTP id 5a478bee46e88-2bdd327d970so1121521eec.1 for ; Fri, 03 Apr 2026 00:14:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775200483; x=1775805283; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=wZ5euJZqrhZn3iV1Pl7AmL73nfBI/YKGmKDSeBhbmog=; b=vyj9MDqaq1WVcjX4687B0ntn3RhsLvhAY1GwU6Ps4rHrZBdqZykqL7AvvfojPNDznC cXE9cWGoU+/Exbq8NUKwiK3nqHv1AoYVpb8xmoaFYpBevhuObIVJ9RuuK4w/XHHuEEqi yr+3kyn2S4XfFwNlYyJ5bsyKbaUozL5suxsLyi8VOzzJ/N43RyfHiAduJg1W0wUaE0yC TvroGSNh8JqJRcKyAtGxI1WUJZQPkAsIfWOP0oK5sXaXoyjSIQ5YkF5ycwl8+g+D3h7p D8DJVH2pg1Rgm7hm4fXzv3QEd6hBRySP6TjMGJZCeVxH+1N7sTeW4+ukOF0FNJmjV8Tx aRYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775200483; x=1775805283; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wZ5euJZqrhZn3iV1Pl7AmL73nfBI/YKGmKDSeBhbmog=; b=TfZlSdBCn5WQVB60k8Z6uJ5GEgN0AHr6P17ZpzBJH4GzNlZeeSBih0phoIaTM0VYYs 6+yvrps0Fqfn9Tp7CyK7PNsY9Z59UkvCFViXxDTphTqSzqNgB6gxfsKCZbufuxHFBoF3 Cm31a6ci34tgsodIuHxn3Cyyy3ANIyUZexBFWy4Y7KMYOfPP07I/LETpF31K4gLcF8tN 3RBF/9ycyNM71OS/THSDpU5RS9Kd6wL6mOvrdhbJqvPGY5/EIye6eme1FD4T//OhPE3X 36BiB43NL4pgpQISYQjA5NFOkNNWczsYou/q3bQ1qd0B12amp6Jxjy6eSd2d531mNKbD BSsg== X-Forwarded-Encrypted: i=1; AJvYcCUNz05W5PgfxOzH+6SPyGlHW617Gwc1QkpTIeNLOpW7FZJ5lkxS9TUx0DWDXF5hj1UmQ6G4YON+K5cxKys=@vger.kernel.org X-Gm-Message-State: AOJu0Yz4SWfbu1tfaBttmn5F3aTJzYJUqThAt97Q1PvLG9mZfDNvcvzo c5fQipN+xszuL7jn0p0XTPrKsZ0FbWJjzNhSuOb7lwWPGp+V6nvAZ1D2/fKgnx1nP4AxfEVnLGM 6Gsm8bY6sPkXEZ7NHNsGflw== X-Received: from dybph22.prod.google.com ([2002:a05:7301:4196:b0:2c1:5ad0:b659]) (user=marcharvey job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:1284:b0:128:cf41:d6e4 with SMTP id a92af1059eb24-12bf0899182mr2300718c88.21.1775200482416; Fri, 03 Apr 2026 00:14:42 -0700 (PDT) Date: Fri, 03 Apr 2026 07:14:29 +0000 In-Reply-To: <20260403-teaming-driver-internal-v4-0-d3032f33ca25@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260403-teaming-driver-internal-v4-0-d3032f33ca25@google.com> X-Developer-Key: i=marcharvey@google.com; a=ed25519; pk=OzOeciadbfF5Bug/4/hyEAwfrruSY4tn0Q0LocyYUL0= X-Developer-Signature: v=1; a=ed25519-sha256; t=1775200467; l=2883; i=marcharvey@google.com; s=20260401; h=from:subject:message-id; bh=nuo0DHK7VQ/i6dfq7yT/KT+VIJKVcVO1c6MvP8D9yp0=; b=Dl7qLYfcAC/GnZzJvEtW3P4+XWtI0Wi8e+Y5Gw1vvAXU8OB2dic9jCu0ecn6+TUUW7l+0OD1N rIgAOrDO8ioCSbACUasgZbgAkcZDf97zf5Rs4rwRgZE7mmjP0hCZ716 X-Mailer: b4 0.14.3 Message-ID: <20260403-teaming-driver-internal-v4-8-d3032f33ca25@google.com> Subject: [PATCH net-next v4 08/10] net: team: Add new rx_enabled team port option From: Marc Harvey To: Jiri Pirko , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Marc Harvey Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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. Signed-off-by: Marc Harvey --- 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/20260402-teaming-driver-intern= al-v3-6-e8cfdec3b5c2@google.com/ --- drivers/net/team/team_core.c | 49 ++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 49 insertions(+) diff --git a/drivers/net/team/team_core.c b/drivers/net/team/team_core.c index 0f95f2f04d27..78c10111329f 100644 --- a/drivers/net/team/team_core.c +++ b/drivers/net/team/team_core.c @@ -941,6 +941,28 @@ static void __team_port_disable_rx(struct team *team, WRITE_ONCE(port->rx_enabled, false); } =20 +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 @@ -1488,6 +1510,26 @@ static int team_port_en_option_set(struct team *team, return 0; } =20 +static void team_port_rx_en_option_get(struct team *team, + struct team_gsetter_ctx *ctx) +{ + struct team_port *port =3D ctx->info->port; + + ctx->data.bool_val =3D 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 =3D 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) { @@ -1609,6 +1651,13 @@ static const struct team_option team_options[] =3D { .getter =3D team_port_en_option_get, .setter =3D team_port_en_option_set, }, + { + .name =3D "rx_enabled", + .type =3D TEAM_OPTION_TYPE_BOOL, + .per_port =3D true, + .getter =3D team_port_rx_en_option_get, + .setter =3D team_port_rx_en_option_set, + }, { .name =3D "user_linkup", .type =3D TEAM_OPTION_TYPE_BOOL, --=20 2.53.0.1185.g05d4b7b318-goog From nobody Sun Apr 5 13:12:23 2026 Received: from mail-dl1-f74.google.com (mail-dl1-f74.google.com [74.125.82.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 32C1538A708 for ; Fri, 3 Apr 2026 07:14:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775200486; cv=none; b=m+kBaSeejef2IxIviDcKgpSSowfJCTx/brTkOcReumdUcOaenywQ9JtIl5VHeeaN+1IxJ6bLyVJKDeqdJLTWQg8zTbQR0BF2soCJlLL+EChwngO3akifFGvbO/ieybs6iDr0fBEnpVuvKpcQxgmfqT42h8HDYId9AKSZufEbjus= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775200486; c=relaxed/simple; bh=tmxI5GX4cvbYDzW23oM8dCMm4F3jODVwv5cyJLTbatw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=aWcF/lqEsK6EN63FfV6ua0BoGO9DvZT94xVWSNaPmtgwdPDYIs+BBsc8GAlgDoVBT70C0b4tujT43clRP8YoJS4ZSFibZCYIWLXyXwHNBErW0gjPiyAAMuAYd7Qvcm5ohjt0Mz4qCN15b8UJVTEle7Ed3m6gQnDq7C1EeMzabj0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--marcharvey.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=P3IczgZV; arc=none smtp.client-ip=74.125.82.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--marcharvey.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="P3IczgZV" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-127133794b6so2499977c88.1 for ; Fri, 03 Apr 2026 00:14:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775200484; x=1775805284; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=EPACWJnTPULcN8fRgqAR/tqtJCCYKpSkXHAMdJtNRJU=; b=P3IczgZVojx1VwXRlwCsvVUPMdEMusinmpUufwkOtcx0KyF0SYMkcaelBIRKY7PV3A VHpx+kIPtAUurIw77hsYZY9Hiwij+tpZXCtWsqxWPAFRS1dYjYEXEFmfAJ6V6Eg5q+9c Sg7hOB3qFcA6HOLv37Efozi17pEyunbg36tsRf/mAfUlDQFiHJ1sQrmFFw2f8PxgpJ95 LpsPoPjiBEQPKkMDp2oepl2TM6Aqsu6aBiXdMb21yDqOQ+jLmMW7iRFD28Z4gRV9m7zP RyEFS1jCTkDtYTDPwHZX4QjSZIFIuTntMXa+OIX3XQIXzNlL6j/dCfWRSv6yU1fk4I5g 6WPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775200484; x=1775805284; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=EPACWJnTPULcN8fRgqAR/tqtJCCYKpSkXHAMdJtNRJU=; b=cYtYQx7sFaUH5ztWAVDPD/GqpRwvVhZSpQkFRK0QRH90I2LXlg64/wJqht2zYsz5dm bqnBsj/gLsteRFveAckQCT/GFiitdut1Hwfz8WjXIEPQx4rZYUeFFQcyh6bT2hAHnL0g BKZ84XE3IDAeWbCIOuF8tNm5so0b+durZfK6vBCeLDmai5WDt888cFlvinPJuOfGPZ33 Ww6oK/ySdU7IQmI86i8zw7sBfapk5j+bECRM7LWCTzuXYwcDi6zcCgd9IqeLINAlWvTU quk6znht2muo++E7xep8lu51Oh3TNB5jETtRUL30+Z8Ce50MYwN/PM3rYxWFTGdJI5H+ iwrQ== X-Forwarded-Encrypted: i=1; AJvYcCVvZopiXNBu4ZGTjb/jJBSEPCcniM674qlxHAmO7HaSVRASxIzDDjRTvgbOyexhICFi4OjT9sIZ6VPnG7A=@vger.kernel.org X-Gm-Message-State: AOJu0YxvVuu8JqjgQLP2jMoH3Z0eovG26uAuQrRVYY6iExpEz7Bj5G13 ZvLLiY1Swv98JC/Omqc0VM+1H9EuBczz92+w7vb9E2EwIReXj5rDcVwxrsCNLossg+D0wefmzC/ h0dCRTBTnkRoA4xj9cS+yZQ== X-Received: from dlcio26.prod.google.com ([2002:a05:7023:c01a:b0:128:bbbe:13df]) (user=marcharvey job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:6199:b0:128:cda8:3a12 with SMTP id a92af1059eb24-12bfb6fb2bamr971278c88.11.1775200484185; Fri, 03 Apr 2026 00:14:44 -0700 (PDT) Date: Fri, 03 Apr 2026 07:14:30 +0000 In-Reply-To: <20260403-teaming-driver-internal-v4-0-d3032f33ca25@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260403-teaming-driver-internal-v4-0-d3032f33ca25@google.com> X-Developer-Key: i=marcharvey@google.com; a=ed25519; pk=OzOeciadbfF5Bug/4/hyEAwfrruSY4tn0Q0LocyYUL0= X-Developer-Signature: v=1; a=ed25519-sha256; t=1775200467; l=3227; i=marcharvey@google.com; s=20260401; h=from:subject:message-id; bh=tmxI5GX4cvbYDzW23oM8dCMm4F3jODVwv5cyJLTbatw=; b=KtmgsAigcobiNoLl6kqR/En0YpyY3Jk2exAFT4Y7yzITLbo29UzXnER0hkyz4NLjoVPuw3nob Hkh5MbP+sAPD6esM9NBtdYpgE8gePF3VywOB8PoOMoTA48GyuD3zpOl X-Mailer: b4 0.14.3 Message-ID: <20260403-teaming-driver-internal-v4-9-d3032f33ca25@google.com> Subject: [PATCH net-next v4 09/10] net: team: Add new tx_enabled team port option From: Marc Harvey To: Jiri Pirko , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Marc Harvey Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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. Signed-off-by: Marc Harvey --- 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/20260402-teaming-driver-intern= al-v3-6-e8cfdec3b5c2@google.com/ --- drivers/net/team/team_core.c | 55 ++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 55 insertions(+) diff --git a/drivers/net/team/team_core.c b/drivers/net/team/team_core.c index 78c10111329f..b8f37054c717 100644 --- a/drivers/net/team/team_core.c +++ b/drivers/net/team/team_core.c @@ -978,6 +978,21 @@ static void __team_port_enable_tx(struct team *team, team_tx_port_index_hash(team, port->tx_index)); } =20 +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); } =20 +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. */ @@ -1530,6 +1558,26 @@ static int team_port_rx_en_option_set(struct team *t= eam, return 0; } =20 +static void team_port_tx_en_option_get(struct team *team, + struct team_gsetter_ctx *ctx) +{ + struct team_port *port =3D ctx->info->port; + + ctx->data.bool_val =3D 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 =3D 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) { @@ -1658,6 +1706,13 @@ static const struct team_option team_options[] =3D { .getter =3D team_port_rx_en_option_get, .setter =3D team_port_rx_en_option_set, }, + { + .name =3D "tx_enabled", + .type =3D TEAM_OPTION_TYPE_BOOL, + .per_port =3D true, + .getter =3D team_port_tx_en_option_get, + .setter =3D team_port_tx_en_option_set, + }, { .name =3D "user_linkup", .type =3D TEAM_OPTION_TYPE_BOOL, --=20 2.53.0.1185.g05d4b7b318-goog From nobody Sun Apr 5 13:12:23 2026 Received: from mail-dl1-f74.google.com (mail-dl1-f74.google.com [74.125.82.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBAA437C10E for ; Fri, 3 Apr 2026 07:14:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775200490; cv=none; b=mi7wPTWHgRUuRHn7KZFuayFD7UTNLbqDZaejw6BraheOj6R03qInToDyWbNyr3iQmpGJO1Bi334IH0m0EEpMBinMjILJpR5UqE3R9hH1D/in2Vbk8QQawEv0aVyMJHAeqEZM4U3jx/oq+2cuIC+6t23BLjGbEc3ZCESICc4leL4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775200490; c=relaxed/simple; bh=URI62RzpweBOhAgzSsnJznahl49uRTbALZleCWhnRXA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=qaA6pAG4pI9cfc+MToCPY8jCq0oHczYqC5+Cm4kXANr1gPUPk1hAA6e8DqPq89mJAV/ep5RtdJypQBv/1xOr589d8WA3MJUBC71f1mzGhAwFuIkVReh8axCIHX7uc31ZFonZ1EzzxyfMyyxpxfX3ZHVc65Q1qC/6nz0UrwXuEGw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--marcharvey.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=U+qG2VXM; arc=none smtp.client-ip=74.125.82.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--marcharvey.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="U+qG2VXM" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-127876be621so1362789c88.1 for ; Fri, 03 Apr 2026 00:14:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775200487; x=1775805287; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Mk7IUEzQ12MWkRmoxZP97tBymALw9cIFcnmQ8yAnHOY=; b=U+qG2VXMEboxc1xm740JkXD9pB/Lo+EC5g36n/KuyygjpCg1wWoY8vhrHxTIiuvFDo UVnBJ/PgOYwyjcp0DUZUDlIr075boqy7ru/WDetF+3dG+GgVt3yAiYrHQ6j/BKE3P11z /uEDXeaLZ5LDtmcRzJVKx+RyAdan47ABwqa4IYvk+sRdFGE9psKAEAwhrajBxp08GotR a68/Z4kRHLEUnPPMHOoNLIOA08XD+9nUkNQZgfgh9FtsGQK2y/6KNFMgnnX8HjeJscpd kqnKNlJIl+aohwyXmo0rC307c2k42kg/YZzRcPRjI4WgFOpJ3tOhod6lSe+MZgOJM7cG ajBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775200487; x=1775805287; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Mk7IUEzQ12MWkRmoxZP97tBymALw9cIFcnmQ8yAnHOY=; b=kICQbpsn6VBg0L57DdbQgkB96VKupUDLb3NpUg4ET+JgjOk66VVfEkd6boZWSEltFc YJ7VA34fkffXNYgqhkdgt2yE18i7ldh8yLt+B+E5ELHjv2r4h5eKlPjSMBTLEXxXs963 nL2gE2D1KrsamSTcdIShMEzhZo29NL4AeCO+tQdJC0IvfxRNAzBr+ANOvXYqG1x4BU0S qmt5+TPNnPLdMuDsGyDT1VQZ/rOBtHKOIC35nWXXhEbixuAQ0bh+o1TeYmD7e2CyOLAx lmupAm1uTSnb4hJNizoEI7Trc1XNdfWdTDlTcYsGa054g1qmJRDjEB3QPclzIP7kY+Hl 9kxw== X-Forwarded-Encrypted: i=1; AJvYcCXDEpIwdVm4EluVIFl1zkfz2HIQ9kKxvF9oIaztrifAkaEUYqR3Rwi7HYlA/s1dDpVXNxJjsU1y8jQLs4E=@vger.kernel.org X-Gm-Message-State: AOJu0Ywn0B0Ni+OlO+eQVxp+2V8DkqeSIWPbh6VZwIWZu6BuEx8gwLCt A78WYkH2TBQVdXh2W5s9j6naYZ15Lds5+DEf1SdcmUZpdQisU/0ShSBPzSwxgcN1hjVYdHifZxM JqhQlpANWUqsmEbwJayCGhg== X-Received: from dlbvv17.prod.google.com ([2002:a05:7022:5f11:b0:12a:81ef:45d2]) (user=marcharvey job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:1e0f:b0:128:d076:e7c3 with SMTP id a92af1059eb24-12bf08c083emr1953124c88.25.1775200486744; Fri, 03 Apr 2026 00:14:46 -0700 (PDT) Date: Fri, 03 Apr 2026 07:14:31 +0000 In-Reply-To: <20260403-teaming-driver-internal-v4-0-d3032f33ca25@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260403-teaming-driver-internal-v4-0-d3032f33ca25@google.com> X-Developer-Key: i=marcharvey@google.com; a=ed25519; pk=OzOeciadbfF5Bug/4/hyEAwfrruSY4tn0Q0LocyYUL0= X-Developer-Signature: v=1; a=ed25519-sha256; t=1775200467; l=12891; i=marcharvey@google.com; s=20260401; h=from:subject:message-id; bh=URI62RzpweBOhAgzSsnJznahl49uRTbALZleCWhnRXA=; b=cOQcT85Bx/NVo8L4sZQk0y5HGMwOyqq+BM5JgTc/NdX4eJy733XQsJvJc/3XJNkqIgj2d7Y5H F0C2SdskSvCCtB63oUgncL5Zw9rNNlKi9OJb25ppIKwxl6uXfVYPx8O X-Mailer: b4 0.14.3 Message-ID: <20260403-teaming-driver-internal-v4-10-d3032f33ca25@google.com> Subject: [PATCH net-next v4 10/10] selftests: net: Add tests for team driver decoupled tx and rx control From: Marc Harvey To: Jiri Pirko , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Marc Harvey Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Use ping and tcpdump to verify that independent rx and tx enablement of team driver member interfaces works as intended. Signed-off-by: Marc Harvey --- Changes in v4: - None Changes in v3: - None Changes in v2: - Fix shellcheck failures. - Link to v1: https://lore.kernel.org/all/20260331053353.2504254-8-marcharv= ey@google.com/ --- 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(-) diff --git a/tools/testing/selftests/drivers/net/team/Makefile b/tools/test= ing/selftests/drivers/net/team/Makefile index dab922d7f83d..7c58cf82121e 100644 --- a/tools/testing/selftests/drivers/net/team/Makefile +++ b/tools/testing/selftests/drivers/net/team/Makefile @@ -2,6 +2,7 @@ # Makefile for net selftests =20 TEST_PROGS :=3D \ + decoupled_enablement.sh \ dev_addr_lists.sh \ non_ether_header_ops.sh \ options.sh \ diff --git a/tools/testing/selftests/drivers/net/team/decoupled_enablement.= sh b/tools/testing/selftests/drivers/net/team/decoupled_enablement.sh new file mode 100755 index 000000000000..e2944af02d57 --- /dev/null +++ b/tools/testing/selftests/drivers/net/team/decoupled_enablement.sh @@ -0,0 +1,249 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +# These tests verify the decoupled RX and TX enablement of team driver mem= ber +# interfaces. +# +# Topology +# +# +---------------------+ NS1 +# | test_team1 | +# | | | +# | eth0 | +# | | | +# | | | +# +---------------------+ +# | +# +---------------------+ NS2 +# | | | +# | | | +# | eth0 | +# | | | +# | test_team2 | +# +---------------------+ + +export ALL_TESTS=3D" + team_test_tx_enablement + team_test_rx_enablement +" + +test_dir=3D"$(dirname "$0")" +# shellcheck disable=3DSC1091 +source "${test_dir}/../../../net/lib.sh" +# shellcheck disable=3DSC1091 +source "${test_dir}/team_lib.sh" + +NS1=3D"" +NS2=3D"" +export NODAD=3D"nodad" +PREFIX_LENGTH=3D"64" +NS1_IP=3D"fd00::1" +NS2_IP=3D"fd00::2" +NS1_IP4=3D"192.168.0.1" +NS2_IP4=3D"192.168.0.2" +MEMBERS=3D("eth0") +PING_COUNT=3D5 +PING_TIMEOUT_S=3D1 +PING_INTERVAL=3D0.1 + +while getopts "4" opt; do + case $opt in + 4) + echo "IPv4 mode selected." + export NODAD=3D + PREFIX_LENGTH=3D"24" + NS1_IP=3D"${NS1_IP4}" + NS2_IP=3D"${NS2_IP4}" + ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + exit 1 + ;; + esac +done + +# This has to be sourced after opts are gathered... +export REQUIRE_MZ=3Dno +export NUM_NETIFS=3D0 +# shellcheck disable=3DSC1091 +source "${test_dir}/../../../net/forwarding/lib.sh" + +# Create the network namespaces, veth pair, and team devices in the specif= ied +# mode. +# Globals: +# RET - Used by test infra, set by `check_err` functions. +# Arguments: +# mode - The team driver mode to use for the team devices. +environment_create() +{ + trap cleanup_all_ns EXIT + setup_ns ns1 ns2 + NS1=3D"${NS_LIST[0]}" + NS2=3D"${NS_LIST[1]}" + + # Create the interfaces. + ip -n "${NS1}" link add eth0 type veth peer name eth0 netns "${NS2}" + ip -n "${NS1}" link add test_team1 type team + ip -n "${NS2}" link add test_team2 type team + + # Set up the receiving network namespace's team interface. + setup_team "${NS2}" test_team2 roundrobin "${NS2_IP}" \ + "${PREFIX_LENGTH}" "${MEMBERS[@]}" +} + +# Set a particular option value for team or team port. +# Arguments: +# namespace - The namespace name that has the team. +# option_name - The option name to set. +# option_value - The value to set the option to. +# team_name - The name of team to set the option for. +# member_name - The (optional) optional name of the member port. +set_option_value() +{ + local namespace=3D"$1" + local option_name=3D"$2" + local option_value=3D"$3" + local team_name=3D"$4" + local member_name=3D"$5" + local port_flag=3D"--port=3D${member_name}" + + ip netns exec "${namespace}" teamnl "${team_name}" setoption \ + "${option_name}" "${option_value}" "${port_flag}" + return $? +} + +# Send some pings and return the ping command return value. +try_ping() +{ + ip netns exec "${NS1}" ping -i "${PING_INTERVAL}" -c "${PING_COUNT}" \ + "${NS2_IP}" -W "${PING_TIMEOUT_S}" +} + +# Checks tcpdump output from net/forwarding lib, and checks if there are a= ny +# ICMP(4 or 6) packets. +# Arguments: +# interface - The interface name to search for. +# ip_address - The destination IP address (4 or 6) to search for. +did_interface_receive_icmp() +{ + local interface=3D"$1" + local ip_address=3D"$2" + local packet_count + + packet_count=3D$(tcpdump_show "$interface" | grep -c \ + "> ${ip_address}: ICMP") + echo "Packet count for ${interface} was ${packet_count}" + + if [[ "$packet_count" -gt 0 ]]; then + true + else + false + fi +} + +# Test JUST tx enablement with a given mode. +# Globals: +# RET - Used by test infra, set by `check_err` functions. +# Arguments: +# mode - The mode to set the team interfaces to. +team_test_mode_tx_enablement() +{ + local mode=3D"$1" + export RET=3D0 + + # Set up the sender team with the correct mode. + setup_team "${NS1}" test_team1 "${mode}" "${NS1_IP}" \ + "${PREFIX_LENGTH}" "${MEMBERS[@]}" + check_err $? "Failed to set up sender team" + + ### Scenario 1: Member interface initially enabled. + # Expect ping to pass + try_ping + check_err $? "Ping failed when TX enabled" + + ### Scenario 2: Once tx-side interface disabled. + # Expect ping to fail. + set_option_value "${NS1}" tx_enabled false test_team1 eth0 + check_err $? "Failed to disable TX" + tcpdump_start eth0 "${NS2}" + try_ping + check_fail $? "Ping succeeded when TX disabled" + tcpdump_stop eth0 + # Expect no packets to be transmitted, since TX is disabled. + did_interface_receive_icmp eth0 "${NS2_IP}" + check_fail $? "eth0 IS transmitting when TX disabled" + tcpdump_cleanup eth0 + + ### Scenario 3: The interface has tx re-enabled. + # Expect ping to pass. + set_option_value "${NS1}" tx_enabled true test_team1 eth0 + check_err $? "Failed to reenable TX" + try_ping + check_err $? "Ping failed when TX reenabled" + + log_test "TX failover of '${mode}' test" +} + +# Test JUST rx enablement with a given mode. +# Globals: +# RET - Used by test infra, set by `check_err` functions. +# Arguments: +# mode - The mode to set the team interfaces to. +team_test_mode_rx_enablement() +{ + local mode=3D"$1" + export RET=3D0 + + # Set up the sender team with the correct mode. + setup_team "${NS1}" test_team1 "${mode}" "${NS1_IP}" \ + "${PREFIX_LENGTH}" "${MEMBERS[@]}" + check_err $? "Failed to set up sender team" + + ### Scenario 1: Member interface initially enabled. + # Expect ping to pass + try_ping + check_err $? "Ping failed when RX enabled" + + ### Scenario 2: Once rx-side interface disabled. + # Expect ping to fail. + set_option_value "${NS1}" rx_enabled false test_team1 eth0 + check_err $? "Failed to disable RX" + tcpdump_start eth0 "${NS2}" + try_ping + check_fail $? "Ping succeeded when RX disabled" + tcpdump_stop eth0 + # Expect packets to be transmitted, since only RX is disabled. + did_interface_receive_icmp eth0 "${NS2_IP}" + check_err $? "eth0 not transmitting when RX disabled" + tcpdump_cleanup eth0 + + ### Scenario 3: The interface has rx re-enabled. + # Expect ping to pass. + set_option_value "${NS1}" rx_enabled true test_team1 eth0 + check_err $? "Failed to reenable RX" + try_ping + check_err $? "Ping failed when RX reenabled" + + log_test "RX failover of '${mode}' test" +} + +team_test_tx_enablement() +{ + team_test_mode_tx_enablement broadcast + team_test_mode_tx_enablement roundrobin + team_test_mode_tx_enablement random +} + +team_test_rx_enablement() +{ + team_test_mode_rx_enablement broadcast + team_test_mode_rx_enablement roundrobin + team_test_mode_rx_enablement random +} + +require_command teamnl +require_command tcpdump +require_command ping +environment_create +tests_run +exit "${EXIT_STATUS}" diff --git a/tools/testing/selftests/drivers/net/team/options.sh b/tools/te= sting/selftests/drivers/net/team/options.sh index 44888f32b513..c87cf998a427 100755 --- a/tools/testing/selftests/drivers/net/team/options.sh +++ b/tools/testing/selftests/drivers/net/team/options.sh @@ -11,10 +11,14 @@ if [[ $# -eq 0 ]]; then exit $? fi =20 -ALL_TESTS=3D" +export ALL_TESTS=3D" team_test_options + team_test_enabled_implicit_changes + team_test_rx_enabled_implicit_changes + team_test_tx_enabled_implicit_changes " =20 +# shellcheck disable=3DSC1091 source "${test_dir}/../../../net/lib.sh" =20 TEAM_PORT=3D"team0" @@ -176,12 +180,105 @@ team_test_options() team_test_option mcast_rejoin_count 0 5 team_test_option mcast_rejoin_interval 0 5 team_test_option enabled true false "${MEMBER_PORT}" + team_test_option rx_enabled true false "${MEMBER_PORT}" + team_test_option tx_enabled true false "${MEMBER_PORT}" team_test_option user_linkup true false "${MEMBER_PORT}" team_test_option user_linkup_enabled true false "${MEMBER_PORT}" team_test_option priority 10 20 "${MEMBER_PORT}" team_test_option queue_id 0 1 "${MEMBER_PORT}" } =20 +team_test_enabled_implicit_changes() +{ + export RET=3D0 + + attach_port_if_specified "${MEMBER_PORT}" + check_err $? "Couldn't attach ${MEMBER_PORT} to master" + + # Set enabled to true. + set_and_check_get enabled true "--port=3D${MEMBER_PORT}" + check_err $? "Failed to set 'enabled' to true" + + # Show that both rx enabled and tx enabled are true. + get_and_check_value rx_enabled true "--port=3D${MEMBER_PORT}" + check_err $? "'Rx_enabled' wasn't implicitly set to true" + get_and_check_value tx_enabled true "--port=3D${MEMBER_PORT}" + check_err $? "'Tx_enabled' wasn't implicitly set to true" + + # Set enabled to false. + set_and_check_get enabled false "--port=3D${MEMBER_PORT}" + check_err $? "Failed to set 'enabled' to true" + + # Show that both rx enabled and tx enabled are false. + get_and_check_value rx_enabled false "--port=3D${MEMBER_PORT}" + check_err $? "'Rx_enabled' wasn't implicitly set to false" + get_and_check_value tx_enabled false "--port=3D${MEMBER_PORT}" + check_err $? "'Tx_enabled' wasn't implicitly set to false" + + log_test "'Enabled' implicit changes" +} + +team_test_rx_enabled_implicit_changes() +{ + export RET=3D0 + + attach_port_if_specified "${MEMBER_PORT}" + check_err $? "Couldn't attach ${MEMBER_PORT} to master" + + # Set enabled to true. + set_and_check_get enabled true "--port=3D${MEMBER_PORT}" + check_err $? "Failed to set 'enabled' to true" + + # Set rx_enabled to false. + set_and_check_get rx_enabled false "--port=3D${MEMBER_PORT}" + check_err $? "Failed to set 'rx_enabled' to false" + + # Show that enabled is false. + get_and_check_value enabled false "--port=3D${MEMBER_PORT}" + check_err $? "'enabled' wasn't implicitly set to false" + + # Set rx_enabled to true. + set_and_check_get rx_enabled true "--port=3D${MEMBER_PORT}" + check_err $? "Failed to set 'rx_enabled' to true" + + # Show that enabled is true. + get_and_check_value enabled true "--port=3D${MEMBER_PORT}" + check_err $? "'enabled' wasn't implicitly set to true" + + log_test "'Rx_enabled' implicit changes" +} + +team_test_tx_enabled_implicit_changes() +{ + export RET=3D0 + + attach_port_if_specified "${MEMBER_PORT}" + check_err $? "Couldn't attach ${MEMBER_PORT} to master" + + # Set enabled to true. + set_and_check_get enabled true "--port=3D${MEMBER_PORT}" + check_err $? "Failed to set 'enabled' to true" + + # Set tx_enabled to false. + set_and_check_get tx_enabled false "--port=3D${MEMBER_PORT}" + check_err $? "Failed to set 'tx_enabled' to false" + + # Show that enabled is false. + get_and_check_value enabled false "--port=3D${MEMBER_PORT}" + check_err $? "'enabled' wasn't implicitly set to false" + + # Set tx_enabled to true. + set_and_check_get tx_enabled true "--port=3D${MEMBER_PORT}" + check_err $? "Failed to set 'tx_enabled' to true" + + # Show that enabled is true. + get_and_check_value enabled true "--port=3D${MEMBER_PORT}" + check_err $? "'enabled' wasn't implicitly set to true" + + log_test "'Tx_enabled' implicit changes" +} + + require_command teamnl setup tests_run --=20 2.53.0.1185.g05d4b7b318-goog