Skip to content

Commit de55412

Browse files
rpearsonhpe-designjgunthorpe
authored andcommitted
RDMA/rxe: Fix bug rejecting all multicast packets
Fix a bug in rxe_rcv() that causes all multicast packets to be dropped. Currently rxe_match_dgid() is called for each packet to verify that the destination IP address matches one of the entries in the port source GID table. This is incorrect for IP multicast addresses since they do not appear in the GID table. Add code to detect multicast addresses. Change function name to rxe_chk_dgid() which is clearer. Link: https://lore.kernel.org/r/20201008212753.265249-1-rpearson@hpe.com Signed-off-by: Bob Pearson <rpearson@hpe.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent e7ec96f commit de55412

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

drivers/infiniband/sw/rxe/rxe_recv.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,17 @@ static void rxe_rcv_mcast_pkt(struct rxe_dev *rxe, struct sk_buff *skb)
287287
kfree_skb(skb);
288288
}
289289

290-
static int rxe_match_dgid(struct rxe_dev *rxe, struct sk_buff *skb)
290+
/**
291+
* rxe_chk_dgid - validate destination IP address
292+
* @rxe: rxe device that received packet
293+
* @skb: the received packet buffer
294+
*
295+
* Accept any loopback packets
296+
* Extract IP address from packet and
297+
* Accept if multicast packet
298+
* Accept if matches an SGID table entry
299+
*/
300+
static int rxe_chk_dgid(struct rxe_dev *rxe, struct sk_buff *skb)
291301
{
292302
struct rxe_pkt_info *pkt = SKB_TO_PKT(skb);
293303
const struct ib_gid_attr *gid_attr;
@@ -305,6 +315,9 @@ static int rxe_match_dgid(struct rxe_dev *rxe, struct sk_buff *skb)
305315
pdgid = (union ib_gid *)&ipv6_hdr(skb)->daddr;
306316
}
307317

318+
if (rdma_is_multicast_addr((struct in6_addr *)pdgid))
319+
return 0;
320+
308321
gid_attr = rdma_find_gid_by_port(&rxe->ib_dev, pdgid,
309322
IB_GID_TYPE_ROCE_UDP_ENCAP,
310323
1, skb->dev);
@@ -329,8 +342,8 @@ void rxe_rcv(struct sk_buff *skb)
329342
if (unlikely(skb->len < pkt->offset + RXE_BTH_BYTES))
330343
goto drop;
331344

332-
if (rxe_match_dgid(rxe, skb) < 0) {
333-
pr_warn_ratelimited("failed matching dgid\n");
345+
if (rxe_chk_dgid(rxe, skb) < 0) {
346+
pr_warn_ratelimited("failed checking dgid\n");
334347
goto drop;
335348
}
336349

0 commit comments

Comments
 (0)