From: Leon Romanovsky <leon@kernel.org>
To: Jason Gunthorpe <jgg@ziepe.ca>, Maor Gottlieb <maorg@mellanox.com>
Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH rdma-next 3/3] RDMA/core: Reject LAG selection when source MAC lookup fails
Date: Thu, 15 Oct 2026 14:59:02 +0300 [thread overview]
Message-ID: <20261015-ib-core-fixes-v1-3-60f6da3ddec3@nvidia.com> (raw)
In-Reply-To: <20261015-ib-core-fixes-v1-0-60f6da3ddec3@nvidia.com>
From: Leon Romanovsky <leonro@nvidia.com>
GID deletion can clear the source device association after LAG lookup
retains the bonding master. Ignoring the resulting L2 lookup failure
copies uninitialized source MAC bytes into the synthetic hash packet.
Read the source MAC before allocating the packet and propagate lookup
errors to the caller, so failed lookups cannot influence slave selection.
Fixes: bd3920eac133 ("RDMA/core: Add LAG functionality")
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
drivers/infiniband/core/lag.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/infiniband/core/lag.c b/drivers/infiniband/core/lag.c
index 88aac911e8ee..651c868aa04e 100644
--- a/drivers/infiniband/core/lag.c
+++ b/drivers/infiniband/core/lag.c
@@ -19,6 +19,11 @@ static struct sk_buff *rdma_build_skb(struct net_device *netdev,
u8 smac[ETH_ALEN];
bool is_ipv4;
int hdr_len;
+ int ret;
+
+ ret = rdma_read_gid_l2_fields(ah_attr->grh.sgid_attr, NULL, smac);
+ if (ret)
+ return ERR_PTR(ret);
is_ipv4 = ipv6_addr_v4mapped((struct in6_addr *)ah_attr->grh.dgid.raw);
hdr_len = ETH_HLEN + sizeof(struct udphdr) + LL_RESERVED_SPACE(netdev);
@@ -26,7 +31,7 @@ static struct sk_buff *rdma_build_skb(struct net_device *netdev,
skb = alloc_skb(hdr_len, flags);
if (!skb)
- return NULL;
+ return ERR_PTR(-ENOMEM);
skb->dev = netdev;
skb_reserve(skb, hdr_len);
@@ -70,7 +75,6 @@ static struct sk_buff *rdma_build_skb(struct net_device *netdev,
skb_reset_mac_header(skb);
eth = eth_hdr(skb);
skb->protocol = eth->h_proto = htons(is_ipv4 ? ETH_P_IP : ETH_P_IPV6);
- rdma_read_gid_l2_fields(ah_attr->grh.sgid_attr, NULL, smac);
memcpy(eth->h_source, smac, ETH_ALEN);
memcpy(eth->h_dest, ah_attr->roce.dmac, ETH_ALEN);
@@ -86,8 +90,8 @@ static struct net_device *rdma_get_xmit_slave_udp(struct ib_device *device,
struct sk_buff *skb;
skb = rdma_build_skb(master, ah_attr, flags);
- if (!skb)
- return ERR_PTR(-ENOMEM);
+ if (IS_ERR(skb))
+ return ERR_CAST(skb);
rcu_read_lock();
slave = netdev_get_xmit_slave(master, skb,
--
2.55.0
next prev parent reply other threads:[~2026-10-15 11:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 11:58 [PATCH rdma-next 0/3] Various core fixes spotted by LLMs Leon Romanovsky
2026-10-15 11:59 ` [PATCH rdma-next 1/3] RDMA/core: Preserve the selected source GID on failed AH modification Leon Romanovsky
2026-10-15 12:11 ` sashiko-bot
2026-10-15 11:59 ` [PATCH rdma-next 2/3] RDMA/core: Free unpublished port statistics after initial-read failure Leon Romanovsky
2026-10-15 12:09 ` sashiko-bot
2026-10-15 12:54 ` Kalesh Anakkur Purayil
2026-10-15 11:59 ` Leon Romanovsky [this message]
2026-10-15 12:15 ` [PATCH rdma-next 3/3] RDMA/core: Reject LAG selection when source MAC lookup fails sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261015-ib-core-fixes-v1-3-60f6da3ddec3@nvidia.com \
--to=leon@kernel.org \
--cc=jgg@ziepe.ca \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=maorg@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox