[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1732736570-19700-1-git-send-email-longli@linuxonhyperv.com>
Date: Wed, 27 Nov 2024 11:42:50 -0800
From: longli@...uxonhyperv.com
To: "K. Y. Srinivasan" <kys@...rosoft.com>,
Haiyang Zhang <haiyangz@...rosoft.com>,
Wei Liu <wei.liu@...nel.org>,
Dexuan Cui <decui@...rosoft.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Shradha Gupta <shradhagupta@...ux.microsoft.com>,
Simon Horman <horms@...nel.org>,
Konstantin Taranov <kotaranov@...rosoft.com>,
Souradeep Chakrabarti <schakrabarti@...ux.microsoft.com>,
Erick Archer <erick.archer@...look.com>,
linux-hyperv@...r.kernel.org,
netdev@...r.kernel.org,
linux-kernel@...r.kernel.org,
linux-rdma@...r.kernel.org
Cc: Long Li <longli@...rosoft.com>
Subject: [PATCH] hv_netvsc: Set device flags for properly indicating bonding
From: Long Li <longli@...rosoft.com>
hv_netvsc uses a subset of bonding features in that the master always
has only one active slave. But it never properly setup those flags.
Other kernel APIs (e.g those in "include/linux/netdevice.h") check for
IFF_MASTER, IFF_SLAVE and IFF_BONDING for determing if those are used
in a master/slave setup. RDMA uses those APIs extensively when looking
for master/slave devices.
Make hv_netvsc properly setup those flags.
Signed-off-by: Long Li <longli@...rosoft.com>
---
drivers/net/hyperv/netvsc_drv.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index d6c4abfc3a28..2112fb74eb21 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -2204,6 +2204,10 @@ static int netvsc_vf_join(struct net_device *vf_netdev,
goto rx_handler_failed;
}
+ vf_netdev->priv_flags |= IFF_BONDING;
+ ndev->priv_flags |= IFF_BONDING;
+ ndev->flags |= IFF_MASTER;
+
ret = netdev_master_upper_dev_link(vf_netdev, ndev,
NULL, NULL, NULL);
if (ret != 0) {
@@ -2484,7 +2488,15 @@ static int netvsc_unregister_vf(struct net_device *vf_netdev)
reinit_completion(&net_device_ctx->vf_add);
netdev_rx_handler_unregister(vf_netdev);
+
+ /* Unlink the slave device and clear flag */
+ vf_netdev->priv_flags &= ~IFF_BONDING;
+ ndev->priv_flags &= ~IFF_BONDING;
+ vf_netdev->flags &= ~IFF_SLAVE;
+ ndev->flags &= ~IFF_MASTER;
+
netdev_upper_dev_unlink(vf_netdev, ndev);
+
RCU_INIT_POINTER(net_device_ctx->vf_netdev, NULL);
dev_put(vf_netdev);
--
2.34.1
Powered by blists - more mailing lists