From nobody Tue Apr 7 06:14:31 2026 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (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 4BBC133893D for ; Mon, 16 Mar 2026 04:27:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773635240; cv=none; b=m9DMUNNoxCsEm8zihQra9trql5Vq/6n+UyHvoZfBgn/B5420PEOy1PFRKF8tgyrvLRU6xA9/qMqhgCZq7KYe8WtNFeOmqbmu1k+IyIEKB2pahryLAuL5KSdMM87wDpTgZ6Wp3j1qaqSZDrXg3Qjwl4TNtzYw7fR8ScpYt7VXw1A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773635240; c=relaxed/simple; bh=uOA8Btfuyt1fRyZXJtbLTVld/QlqU0lmL5OyV/kUGLE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lDFfZtuetV8uoNg9pbgC9e8cQSvdflSD/uKV+qS6iChbY+oXLIdlOXm2cT9Q1u1C7N+YrLcWPG4L3CUCzzb0CTu8rJQORvdpB40dOjrvH6vDHhMV93H9Zb4g1NHafbI38wAqTVGbi7bR0uTIt4pBngXCm9Afl7AoPKGtsaiMiHM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=HIZPvFKr; arc=none smtp.client-ip=209.85.210.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HIZPvFKr" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-82735a41920so1478712b3a.2 for ; Sun, 15 Mar 2026 21:27:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773635238; x=1774240038; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=XZnXe6ZII/Ekwqx2euSYzckFZIl5gweSRd+FY9OyPQE=; b=HIZPvFKrMiyOBDcpqGDJWdzUUe78cH4cfpR70RZJpuVsqASDtD71qTeRuP5s0vMmKv rrThqggMs7ncy8nFhzeBcGrpyto36HF9q2Wy+w7MpWtEdUzS81LgwDu/CEkUoFpUd0Yc fpDraKN84z9KA3JftfK0eCXmGX14nmZlsZRbpTZM/p6IuEm4kL6UsuB1Io4hF7iZSvvp mCpN+jMBFNefte7y+8nK7hvdnx0kSuAeZ92VpzdS5ucvEuL/IcWLKd/BtRrBnilop8Yh 3650BIQ6JrfXn/TCvVUkd5C32NIGnneFuLci6aDsknrhPmeyvXuHHKdJhtsQ0ARXOe0N RwOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773635238; x=1774240038; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=XZnXe6ZII/Ekwqx2euSYzckFZIl5gweSRd+FY9OyPQE=; b=RPWLkBPtZ1Ej84oSyzS91buXHOnW6oLlIU4eNdPHRLI5Qx3OWPV2KyO3iAn79fjwjz VyPku9HvyMEdPG4Y6RL54XCSMJs/p3GnR9mPF5M4wYH75YuHDiCfLu6CHAl/Ri3BNBrw t5ODioTjy4l0brdsQPW4YyFnuCdnHUpQfIRS25C0QvNej4Bu9WMsA8wsAxQeYsVWKJUA hLneFrIL9J+Yj5QgdtPIrpwgjc5qsl/pgz/szJC4wVMSiJ7B8xIJWFutzOosa7sj9a/U uiKTdl7BNRDPrxarUWX93cC0aUIIoZlpLc4oOgKipa49rqoK+LAM85SdLqDGfIyfhSM1 +acA== X-Forwarded-Encrypted: i=1; AJvYcCXSr7Lwyk3RZ5lBT68NVOLwjCA21Y+3GQ80DeDOs6v93UXbZ4oMGR6Pbw7rx8HpwBeZCRRqe/XQOkAj6sY=@vger.kernel.org X-Gm-Message-State: AOJu0YwvJBQ7i6oypxAWgm/aV5uyztQe7ssA3pF55YLuTyFGhaIFhGgQ /5JenlGTmpcUKgJTlhWa5MQxqqeTfkznPdcmElKlxL9f9IKYVFZFdmyB X-Gm-Gg: ATEYQzxnHOeMf/NsPt+O9/xmGdikkZvYo04YNwqXQCVnQCGZNZoOGUQ2F6T+QvCDDBp HZPDBbbI2McDJwJYOJS31jUYVYQJobbAFhkQVWTrZCBxQ3B2zefocNBgUhIA7GENOkOcXUuCXvc uN2m+YkJVcvVA1C93t8gIsmw0Ck5ufiZOOpkgtTkwx2xlv1qm+aYszCO5wQYH7F43m0mXhHgV73 8BCHBjoMcvd/gXWL7LA+ezOnFEZhCeb/E36PhV3/OaL3EVHcUpfUAZLiDE2cScIx06ggYzqc8sm E+TgTpGpOaUnxPGJq1YvLMEzfPZPpnsO2BKK7mbvPn73Td1J7mojPwOwQ9+IP3yxef4tLFoxu45 +RUPWCReqxCDiLTzagCgz15aJnAEN5PnflA1QYY0K9pHBF+Og42ht16+HyKtmwaqYJisEHKkxJm 2snSMs3AKaN8Uomm/KYRwkiTXhY1pshpuZPY1Vj66dYQJvTvY16DX7eSotjg== X-Received: by 2002:a05:6a00:a803:b0:82a:8aa:cbb6 with SMTP id d2e1a72fcca58-82a19925747mr10091291b3a.55.1773635237584; Sun, 15 Mar 2026 21:27:17 -0700 (PDT) Received: from 1.0.0.127.in-addr.arpa ([240e:34c:5760:3860:bc29:deed:92d0:823c]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82a0738422esm12180267b3a.55.2026.03.15.21.27.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Mar 2026 21:27:17 -0700 (PDT) From: Hangbin Liu Date: Mon, 16 Mar 2026 12:26:10 +0800 Subject: [PATCH net-next v3 2/5] net: use ndo_update_offloads to set offload features for bonding/bridge/team Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260316-offload_compute-v3-2-a5d4a07d86d3@gmail.com> References: <20260316-offload_compute-v3-0-a5d4a07d86d3@gmail.com> In-Reply-To: <20260316-offload_compute-v3-0-a5d4a07d86d3@gmail.com> To: Jay Vosburgh , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jiri Pirko , Nikolay Aleksandrov , Ido Schimmel , Simon Horman , Sabrina Dubroca , Sridhar Samudrala Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bridge@lists.linux.dev, Hangbin Liu X-Mailer: b4 0.14.3 Convert bonding, bridge, and team drivers to use the new ndo_update_offloads callback instead of manually calling netdev_compute_master_upper_features() during port add/remove operations. This change centralizes the feature computation flow: Before: - netdev_master_upper_dev_link() - netdev_compute_master_upper_features() <- called manually - compute offload features - netdev_change_features() - __netdev_update_features() - update other features After: - netdev_master_upper_dev_link() - __netdev_upper_dev_link() - netdev_change_features() - __netdev_update_features() - ndo_update_offloads() - netdev_compute_master_upper_features() - update other features This ensures offload features are computed automatically when upper/lower device links change, removing the need for manual feature computation calls in the driver code. The netdev_change_features() call in team_uninit() is also removed since it calls team_port_del() for each port, which now triggers feature updates automatically. Signed-off-by: Hangbin Liu --- drivers/net/bonding/bond_main.c | 10 +++++++--- drivers/net/team/team_core.c | 11 +++++++---- net/bridge/br_device.c | 6 ++++++ net/bridge/br_if.c | 4 ---- net/core/dev.c | 8 ++++++-- 5 files changed, 26 insertions(+), 13 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_mai= n.c index 90b71bd53040..ea6bb20f9348 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -1509,6 +1509,11 @@ static netdev_features_t bond_fix_features(struct ne= t_device *dev, return features; } =20 +static void bond_update_offloads(struct net_device *dev) +{ + netdev_compute_master_upper_features(dev, true); +} + static int bond_header_create(struct sk_buff *skb, struct net_device *bond= _dev, unsigned short type, const void *daddr, const void *saddr, unsigned int len) @@ -2273,7 +2278,6 @@ int bond_enslave(struct net_device *bond_dev, struct = net_device *slave_dev, } =20 bond->slave_cnt++; - netdev_compute_master_upper_features(bond->dev, true); bond_set_carrier(bond); =20 /* Needs to be called before bond_select_active_slave(), which will @@ -2528,7 +2532,6 @@ static int __bond_release_one(struct net_device *bond= _dev, call_netdevice_notifiers(NETDEV_RELEASE, bond->dev); } =20 - netdev_compute_master_upper_features(bond->dev, true); if (!(bond_dev->features & NETIF_F_VLAN_CHALLENGED) && (old_features & NETIF_F_VLAN_CHALLENGED)) slave_info(bond_dev, slave_dev, "last VLAN challenged slave left bond - = VLAN blocking is removed\n"); @@ -4026,7 +4029,7 @@ static int bond_slave_netdev_event(unsigned long even= t, case NETDEV_FEAT_CHANGE: if (!bond->notifier_ctx) { bond->notifier_ctx =3D true; - netdev_compute_master_upper_features(bond->dev, true); + netdev_change_features(bond->dev); bond->notifier_ctx =3D false; } break; @@ -5953,6 +5956,7 @@ static const struct net_device_ops bond_netdev_ops = =3D { .ndo_add_slave =3D bond_enslave, .ndo_del_slave =3D bond_release, .ndo_fix_features =3D bond_fix_features, + .ndo_update_offloads =3D bond_update_offloads, .ndo_features_check =3D passthru_features_check, .ndo_get_xmit_slave =3D bond_xmit_get_slave, .ndo_sk_get_lower_dev =3D bond_sk_get_lower_dev, diff --git a/drivers/net/team/team_core.c b/drivers/net/team/team_core.c index b7282f5c9632..affbcc6fc130 100644 --- a/drivers/net/team/team_core.c +++ b/drivers/net/team/team_core.c @@ -1247,7 +1247,6 @@ static int team_port_add(struct team *team, struct ne= t_device *port_dev, port->index =3D -1; list_add_tail_rcu(&port->list, &team->port_list); team_port_enable(team, port); - netdev_compute_master_upper_features(team->dev, true); __team_port_change_port_added(port, !!netif_oper_up(port_dev)); __team_options_change_check(team); =20 @@ -1337,7 +1336,6 @@ static int team_port_del(struct team *team, struct ne= t_device *port_dev, bool un } kfree_rcu(port, rcu); netdev_info(dev, "Port device %s removed\n", portname); - netdev_compute_master_upper_features(team->dev, true); =20 return 0; } @@ -1645,7 +1643,6 @@ static void team_uninit(struct net_device *dev) team_mcast_rejoin_fini(team); team_notify_peers_fini(team); team_queue_override_fini(team); - netdev_change_features(dev); } =20 static void team_destructor(struct net_device *dev) @@ -1972,6 +1969,11 @@ static netdev_features_t team_fix_features(struct ne= t_device *dev, return features; } =20 +static void team_update_offloads(struct net_device *dev) +{ + netdev_compute_master_upper_features(dev, true); +} + static int team_change_carrier(struct net_device *dev, bool new_carrier) { struct team *team =3D netdev_priv(dev); @@ -2007,6 +2009,7 @@ static const struct net_device_ops team_netdev_ops = =3D { .ndo_add_slave =3D team_add_slave, .ndo_del_slave =3D team_del_slave, .ndo_fix_features =3D team_fix_features, + .ndo_update_offloads =3D team_update_offloads, .ndo_change_carrier =3D team_change_carrier, .ndo_features_check =3D passthru_features_check, }; @@ -2944,7 +2947,7 @@ static int team_device_event(struct notifier_block *u= nused, case NETDEV_FEAT_CHANGE: if (!port->team->notifier_ctx) { port->team->notifier_ctx =3D true; - netdev_compute_master_upper_features(port->team->dev, true); + netdev_change_features(port->team->dev); port->team->notifier_ctx =3D false; } break; diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c index f7502e62dd35..137cad13379b 100644 --- a/net/bridge/br_device.c +++ b/net/bridge/br_device.c @@ -289,6 +289,11 @@ static netdev_features_t br_fix_features(struct net_de= vice *dev, return br_features_recompute(br, features); } =20 +static void br_update_offloads(struct net_device *dev) +{ + netdev_compute_master_upper_features(dev, false); +} + #ifdef CONFIG_NET_POLL_CONTROLLER static void br_poll_controller(struct net_device *br_dev) { @@ -456,6 +461,7 @@ static const struct net_device_ops br_netdev_ops =3D { .ndo_add_slave =3D br_add_slave, .ndo_del_slave =3D br_del_slave, .ndo_fix_features =3D br_fix_features, + .ndo_update_offloads =3D br_update_offloads, .ndo_fdb_add =3D br_fdb_add, .ndo_fdb_del =3D br_fdb_delete, .ndo_fdb_del_bulk =3D br_fdb_delete_bulk, diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c index d39571e13744..030248bc94c5 100644 --- a/net/bridge/br_if.c +++ b/net/bridge/br_if.c @@ -680,8 +680,6 @@ int br_add_if(struct net_bridge *br, struct net_device = *dev, =20 br_mtu_auto_adjust(br); =20 - netdev_compute_master_upper_features(br->dev, false); - kobject_uevent(&p->kobj, KOBJ_ADD); =20 return 0; @@ -734,8 +732,6 @@ int br_del_if(struct net_bridge *br, struct net_device = *dev) if (changed_addr) call_netdevice_notifiers(NETDEV_CHANGEADDR, br->dev); =20 - netdev_compute_master_upper_features(br->dev, false); - return 0; } =20 diff --git a/net/core/dev.c b/net/core/dev.c index bbd532aa6a1b..8bcbf7c22830 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -8923,6 +8923,9 @@ static int __netdev_upper_dev_link(struct net_device = *dev, __netdev_walk_all_upper_dev(upper_dev, __netdev_update_lower_level, priv); =20 + /* re-compute all features after adding link */ + netdev_change_features(upper_dev); + return 0; =20 rollback: @@ -9015,6 +9018,9 @@ static void __netdev_upper_dev_unlink(struct net_devi= ce *dev, __netdev_update_lower_level(upper_dev, priv); __netdev_walk_all_upper_dev(upper_dev, __netdev_update_lower_level, priv); + + /* re-compute all features after removing link */ + netdev_change_features(upper_dev); } =20 /** @@ -12880,8 +12886,6 @@ void netdev_compute_master_upper_features(struct ne= t_device *dev, bool update_he =20 netif_set_tso_max_segs(dev, tso_max_segs); netif_set_tso_max_size(dev, tso_max_size); - - netdev_change_features(dev); } EXPORT_SYMBOL(netdev_compute_master_upper_features); =20 --=20 Git-155)