* [PATCH rdma-next] RDMA: Preserve fixed-MAC bond GIDs across failover
@ 2026-12-02 12:30 Mark Bloch
2026-12-02 12:38 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Mark Bloch @ 2026-12-02 12:30 UTC (permalink / raw)
To: Jason Gunthorpe, Leon Romanovsky
Cc: Jay Vosburgh, netdev, Mark Bloch, Or Gerlitz, Junxian Huang,
Maher Sanalla, linux-rdma, linux-kernel
NETDEV_BONDING_FAILOVER deletes the bond's GIDs and adds them back.
The delete clears the hardware entry even if a live QP still holds
a reference to the GID. That reference keeps the old slot occupied,
so re-adding the GID cannot restore the entry used by the QP.
Some providers can move existing QPs to the new physical port without
replacing their GIDs. Add RDMA_CORE_CAP_BONDING_FAILOVER so providers
can advertise this, and set it for mlx5 RoCE LAG.
Skip the failover purge for ports with this capability when their
associated netdevice belongs to an active-backup bond using
fail_over_mac=none. The source MAC stays the same, so the GIDs remain
valid. Check the direct bond master, since the capability does not
cover failover further up the netdevice hierarchy, such as when the
bond itself is enslaved to another bond.
Only GIDs that belong to the bond netdevice itself are preserved.
NETDEV_BONDING_FAILOVER is also propagated to devices stacked on the
bond, such as VLAN, macvlan and ipvlan, and for those events the purge
still runs, so their GIDs are deleted and added back as before. This
is intentional: keep the initial support minimal and extend it to
stacked devices later if needed.
Also stop requiring the port's netdevice to be the active member when
handling address events for the bond or for a VLAN on top of it. The
provider switches the port to the new active member asynchronously, so
the GID work can run while the port still points at the old one, and
an address added or removed in that window would be missed. With the
purge skipped, nothing would later remove a GID whose address deletion
was missed.
Cc: Or Gerlitz <gerlitz.or@gmail.com>
Signed-off-by: Mark Bloch <mbloch@nvidia.com>
Tested-by: Junxian Huang <huangjunxian6@hisilicon.com>
Reviewed-by: Maher Sanalla <msanalla@nvidia.com>
---
drivers/infiniband/core/roce_gid_mgmt.c | 46 +++++++++++++++++++++++--
drivers/infiniband/hw/mlx5/main.c | 2 ++
include/rdma/ib_verbs.h | 2 ++
3 files changed, 47 insertions(+), 3 deletions(-)
diff --git a/drivers/infiniband/core/roce_gid_mgmt.c b/drivers/infiniband/core/roce_gid_mgmt.c
index 4a2a4638b476..59a504b648d5 100644
--- a/drivers/infiniband/core/roce_gid_mgmt.c
+++ b/drivers/infiniband/core/roce_gid_mgmt.c
@@ -141,6 +141,29 @@ static enum bonding_slave_state is_eth_active_slave_of_bonding_rcu(struct net_de
return BONDING_SLAVE_STATE_NA;
}
+static bool bond_preserves_gids(struct ib_device *ib_dev, u32 port,
+ struct net_device *rdma_ndev,
+ struct net_device *ndev)
+{
+ const struct ib_port_immutable *immutable;
+ struct bonding *bond;
+ bool preserves;
+
+ immutable = ib_port_immutable_read(ib_dev, port);
+ if (!(immutable->core_cap_flags & RDMA_CORE_CAP_BONDING_FAILOVER) ||
+ !netif_is_bond_master(ndev))
+ return false;
+
+ rcu_read_lock();
+ bond = netdev_priv(ndev);
+ preserves = netdev_master_upper_dev_get_rcu(rdma_ndev) == ndev &&
+ READ_ONCE(bond->params.mode) == BOND_MODE_ACTIVEBACKUP &&
+ READ_ONCE(bond->params.fail_over_mac) == BOND_FOM_NONE;
+ rcu_read_unlock();
+
+ return preserves;
+}
+
#define REQUIRED_BOND_STATES (BONDING_SLAVE_STATE_ACTIVE | \
BONDING_SLAVE_STATE_NA)
static bool
@@ -159,8 +182,9 @@ is_eth_port_of_netdev_filter(struct ib_device *ib_dev, u32 port,
real_dev = cookie;
res = ((rdma_is_upper_dev_rcu(rdma_ndev, cookie) &&
- (is_eth_active_slave_of_bonding_rcu(rdma_ndev, real_dev) &
- REQUIRED_BOND_STATES)) ||
+ (bond_preserves_gids(ib_dev, port, rdma_ndev, real_dev) ||
+ (is_eth_active_slave_of_bonding_rcu(rdma_ndev, real_dev) &
+ REQUIRED_BOND_STATES))) ||
real_dev == rdma_ndev);
rcu_read_unlock();
@@ -248,6 +272,22 @@ static bool upper_device_filter(struct ib_device *ib_dev, u32 port,
return res;
}
+static bool bonding_failover_filter(struct ib_device *ib_dev, u32 port,
+ struct net_device *rdma_ndev, void *cookie)
+{
+ /*
+ * Skip deletion when the provider moves existing QPs to the new
+ * active member and preserves the bond's GIDs. Deleting them would
+ * clear hardware entries still used by live QPs.
+ *
+ * This can run before the provider associates the RDMA port with the
+ * new active member, so check bond membership without requiring the
+ * associated member to be active.
+ */
+ return upper_device_filter(ib_dev, port, rdma_ndev, cookie) &&
+ !bond_preserves_gids(ib_dev, port, rdma_ndev, cookie);
+}
+
/**
* is_upper_ndev_bond_master_filter - Check if a given netdevice
* is bond master device of netdevice of the RDMA device of port.
@@ -771,7 +811,7 @@ static int netdevice_event(struct notifier_block *this, unsigned long event,
.filter = is_eth_port_of_netdev_filter
};
static const struct netdev_event_work_cmd bonding_event_ips_del_cmd = {
- .cb = del_netdev_upper_ips, .filter = upper_device_filter};
+ .cb = del_netdev_upper_ips, .filter = bonding_failover_filter};
struct net_device *ndev = netdev_notifier_info_to_dev(ptr);
struct netdev_event_work_cmd cmds[ROCE_NETDEV_CALLBACK_SZ] = { {NULL} };
diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index 81f8498a9246..0a19d9eb9e78 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -3664,6 +3664,8 @@ static int mlx5_port_immutable(struct ib_device *ibdev, u32 port_num,
immutable->pkey_tbl_len = attr.pkey_tbl_len;
immutable->gid_tbl_len = attr.gid_tbl_len;
immutable->core_cap_flags = get_core_cap_flags(ibdev, &rep);
+ if (mlx5_lag_is_roce(dev->mdev))
+ immutable->core_cap_flags |= RDMA_CORE_CAP_BONDING_FAILOVER;
immutable->max_mad_size = IB_MGMT_MAD_SIZE;
return 0;
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index ab6b9af1a6d3..24c15e7bb586 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -650,6 +650,8 @@ void rdma_free_hw_stats_struct(struct rdma_hw_stats *stats);
#define RDMA_CORE_CAP_IW_CM 0x00000008
#define RDMA_CORE_CAP_IB_SA 0x00000010
#define RDMA_CORE_CAP_OPA_MAD 0x00000020
+/* Existing QPs can switch bond members without replacing their GIDs. */
+#define RDMA_CORE_CAP_BONDING_FAILOVER 0x00000040
/* Address format 0x000FF000 */
#define RDMA_CORE_CAP_AF_IB 0x00001000
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH rdma-next] RDMA: Preserve fixed-MAC bond GIDs across failover
2026-12-02 12:30 [PATCH rdma-next] RDMA: Preserve fixed-MAC bond GIDs across failover Mark Bloch
@ 2026-12-02 12:38 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-12-02 12:38 UTC (permalink / raw)
To: Mark Bloch; +Cc: linux-rdma
> NETDEV_BONDING_FAILOVER deletes the bond's GIDs and adds them back.
> The delete clears the hardware entry even if a live QP still holds
> a reference to the GID. That reference keeps the old slot occupied,
> so re-adding the GID cannot restore the entry used by the QP.
>
> Some providers can move existing QPs to the new physical port without
> replacing their GIDs. Add RDMA_CORE_CAP_BONDING_FAILOVER so providers
> can advertise this, and set it for mlx5 RoCE LAG.
>
> Skip the failover purge for ports with this capability when their
> associated netdevice belongs to an active-backup bond using
> fail_over_mac=none. The source MAC stays the same, so the GIDs remain
> valid. Check the direct bond master, since the capability does not
> cover failover further up the netdevice hierarchy, such as when the
> bond itself is enslaved to another bond.
> [ ... ]
> purge skipped, nothing would later remove a GID whose address deletion
> was missed.
>
> Cc: Or Gerlitz <gerlitz.or@gmail.com>
> Signed-off-by: Mark Bloch <mbloch@nvidia.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261202123010.3914123-1-mbloch@nvidia.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-02 12:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 12:30 [PATCH rdma-next] RDMA: Preserve fixed-MAC bond GIDs across failover Mark Bloch
2026-12-02 12:38 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox