diff mbox series

[for-next] rdma_rxe: fix bug rejecting multicast packets

Message ID 20201008195412.256485-1-rpearson@hpe.com (mailing list archive)
State Superseded
Headers show
Series [for-next] rdma_rxe: fix bug rejecting multicast packets | expand

Commit Message

Bob Pearson Oct. 8, 2020, 7:54 p.m. UTC
- 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.

Signed-off-by: Bob Pearson <rpearson@hpe.com>
Fixes: 8700e3e7c485 ("Soft RoCE (RXE) - The software RoCE driver")
---
 drivers/infiniband/sw/rxe/rxe_recv.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/infiniband/sw/rxe/rxe_recv.c b/drivers/infiniband/sw/rxe/rxe_recv.c
index a3eed4da1540..a9be4efba5f3 100644
--- a/drivers/infiniband/sw/rxe/rxe_recv.c
+++ b/drivers/infiniband/sw/rxe/rxe_recv.c
@@ -280,7 +280,17 @@  static void rxe_rcv_mcast_pkt(struct rxe_dev *rxe, struct sk_buff *skb)
 	kfree_skb(skb);
 }
 
-static int rxe_match_dgid(struct rxe_dev *rxe, struct sk_buff *skb)
+/**
+ * rxe_chk_dgid - validate destination IP address
+ * @rxe: rxe device that received packet
+ * @skb: the received packet buffer
+ *
+ * Accept any loopback packets
+ * Extract IP address from packet and
+ * Accept if multicast packet
+ * Accept if matches an SGID table entry
+ */
+static int rxe_chk_dgid(struct rxe_dev *rxe, struct sk_buff *skb)
 {
 	struct rxe_pkt_info *pkt = SKB_TO_PKT(skb);
 	const struct ib_gid_attr *gid_attr;
@@ -298,6 +308,9 @@  static int rxe_match_dgid(struct rxe_dev *rxe, struct sk_buff *skb)
 		pdgid = (union ib_gid *)&ipv6_hdr(skb)->daddr;
 	}
 
+	if (rdma_is_multicast_addr((struct in6_addr *)pdgid))
+		return 0;
+
 	gid_attr = rdma_find_gid_by_port(&rxe->ib_dev, pdgid,
 					 IB_GID_TYPE_ROCE_UDP_ENCAP,
 					 1, skb->dev);