From patchwork Thu Jan 24 14:44:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Heib X-Patchwork-Id: 10779137 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2F66491E for ; Thu, 24 Jan 2019 14:44:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 32C1F2F862 for ; Thu, 24 Jan 2019 14:44:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 264CA2F992; Thu, 24 Jan 2019 14:44:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3CB42F862 for ; Thu, 24 Jan 2019 14:44:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728288AbfAXOox (ORCPT ); Thu, 24 Jan 2019 09:44:53 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:55963 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727649AbfAXOox (ORCPT ); Thu, 24 Jan 2019 09:44:53 -0500 Received: by mail-wm1-f66.google.com with SMTP id y139so3367241wmc.5 for ; Thu, 24 Jan 2019 06:44:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=iD5OY/qjdGqkEP62lRwYgoD+0KzH8B/1o4By7uJW49g=; b=NBLeh4+77YGe1Qup37djtzytauN0NacwURjtls09Uyr4RQ9HJr65a1ceR+qRDuAoa4 JCacNGKZOSBLtZVVljp44g6DnA1AHplt45/8d+YcuSusulvw8giZcJNN6iCuSGPatzcu LWpT71Ea4IBcfOME2XVuvTA5wyeVlg+72op37regsx0Y+EBPoLDyy9Ajki1sg+PZD82i cTFJq3eoH0xkU3V3Y8za3FVYALdXZO8Uu2V3695D2W07RvUge5NIQDRW+N2ju55n2YvZ gMk7AFDeHurD1nGH6K+UKiEqs3wTRqI10YdetOShw5fjwxvrrhng0BHQKUorbfqGYA/B roEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=iD5OY/qjdGqkEP62lRwYgoD+0KzH8B/1o4By7uJW49g=; b=pzaz7blcpVRR8/Vx4LmugEswEF7AtfdGIBBOY6mo/C4FBLtFniLBW0+IWXSW3EdkSe ymDuFLPhnWqCJbrHa2qb0sQq+yTbpiZhh2ruevF7gXeye9f2y0uPT1z21/4VJ8NDfG81 OOq+m6Cp6772HWUQlnnvdURFKwMOQoexaVMAlN2mrlYKYRSkiQGV6ciVLZBlUPolrcEw i3wEqDfyslCdKa0dpHbhj4FugvetMav6vggPGbov7DwHIfQp6XZhgq9a5NZXq3y1GM5Z 8qHCOsE7RlDrdT5ExIquM0n0i0hBOqTqQ7yUlGvoMu8p0uFmq9HZtT2AZZdMFUooNB7h sJbw== X-Gm-Message-State: AJcUukfz3OLeegvfviW6DmrlSAtRGz2G0iMa/D7tT/1WYzvAX4nDz2vv bOSMGdxeghM1TwLAC/kiKaE= X-Google-Smtp-Source: ALg8bN5A3wmTUTNUzR6F7XOshbQniwDfBf6EARvdHC7tpmn+YxvEGiCE24nTKE09l526OppSwfyezg== X-Received: by 2002:a1c:448a:: with SMTP id r132mr2867487wma.47.1548341091475; Thu, 24 Jan 2019 06:44:51 -0800 (PST) Received: from kheib-workstation.redhat.com ([192.116.94.216]) by smtp.gmail.com with ESMTPSA id k3sm137444485wrm.7.2019.01.24.06.44.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Jan 2019 06:44:50 -0800 (PST) From: Kamal Heib To: Doug Ledford , Jason Gunthorpe Cc: linux-rdma@vger.kernel.org, Marcel Apfelbaum , Yuval Shaia , Kamal Heib Subject: [PATCH for-rc] IB/rxe: Improve loopback marking Date: Thu, 24 Jan 2019 16:44:34 +0200 Message-Id: <20190124144434.24910-1-kamalheib1@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently a packet is marked for loopback only if the source and destination addresses match, This is not enough when multiple gids are present in rxe device's gid table and the traffic is from one gid to another, this patch fixes this by marking the packet for loopback if the destination address found in the rxe's netdevice address list. Fixes: 8700e3e7c485 ("Soft RoCE driver") Signed-off-by: Marcel Apfelbaum Signed-off-by: Kamal Heib Reviewed-by: Yuval Shaia Tested-by: Yuval Shaia --- drivers/infiniband/sw/rxe/rxe_net.c | 45 +++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c index 8fd03ae20efc..6ee984b7793b 100644 --- a/drivers/infiniband/sw/rxe/rxe_net.c +++ b/drivers/infiniband/sw/rxe/rxe_net.c @@ -368,6 +368,25 @@ static void prepare_ipv6_hdr(struct dst_entry *dst, struct sk_buff *skb, ip6h->payload_len = htons(skb->len - sizeof(*ip6h)); } +static inline bool same_rxe4(struct net_device *ndev, struct in_addr *daddr) +{ + struct in_device *in_dev; + bool same_rxe = false; + + in_dev = in_dev_get(ndev); + if (!in_dev) + return false; + + for_ifa(in_dev) + if (!memcmp(&ifa->ifa_address, daddr, sizeof(*daddr))) { + same_rxe = true; + break; + } + endfor_ifa(in_dev); + in_dev_put(in_dev); + return same_rxe; +} + static int prepare4(struct rxe_pkt_info *pkt, struct sk_buff *skb, struct rxe_av *av) { @@ -384,7 +403,7 @@ static int prepare4(struct rxe_pkt_info *pkt, struct sk_buff *skb, return -EHOSTUNREACH; } - if (!memcmp(saddr, daddr, sizeof(*daddr))) + if (same_rxe4(skb->dev, daddr)) pkt->mask |= RXE_LOOPBACK_MASK; prepare_udp_hdr(skb, cpu_to_be16(qp->src_port), @@ -397,6 +416,28 @@ static int prepare4(struct rxe_pkt_info *pkt, struct sk_buff *skb, return 0; } +static inline bool same_rxe6(struct net_device *ndev, struct in6_addr *daddr) +{ + struct inet6_dev *in6_dev; + struct inet6_ifaddr *ifp; + bool same_rxe = false; + + in6_dev = in6_dev_get(ndev); + if (!in6_dev) + return false; + + read_lock_bh(&in6_dev->lock); + list_for_each_entry(ifp, &in6_dev->addr_list, if_list) { + if (!memcmp(&ifp->addr, daddr, sizeof(*daddr))) { + same_rxe = true; + break; + } + } + read_unlock_bh(&in6_dev->lock); + in6_dev_put(in6_dev); + return same_rxe; +} + static int prepare6(struct rxe_pkt_info *pkt, struct sk_buff *skb, struct rxe_av *av) { @@ -411,7 +452,7 @@ static int prepare6(struct rxe_pkt_info *pkt, struct sk_buff *skb, return -EHOSTUNREACH; } - if (!memcmp(saddr, daddr, sizeof(*daddr))) + if (same_rxe6(skb->dev, daddr)) pkt->mask |= RXE_LOOPBACK_MASK; prepare_udp_hdr(skb, cpu_to_be16(qp->src_port),