From patchwork Thu Mar 29 07:46:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhu Yanjun X-Patchwork-Id: 10314595 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BFB0E6055B for ; Thu, 29 Mar 2018 07:47:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2F3C285EC for ; Thu, 29 Mar 2018 07:47:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7BC128658; Thu, 29 Mar 2018 07:47:54 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY 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 48867285EC for ; Thu, 29 Mar 2018 07:47:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750884AbeC2Hrw (ORCPT ); Thu, 29 Mar 2018 03:47:52 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:46314 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751052AbeC2Hrv (ORCPT ); Thu, 29 Mar 2018 03:47:51 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w2T7TK1K190715; Thu, 29 Mar 2018 07:47:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id; s=corp-2017-10-26; bh=ZUv3T0CbfImcD/zkK7Tu+yo7f4BasUDqDNIpf7/rhUc=; b=ilMoTMvINq+TDGjVBqvhSJCMReOus5joymPRPttojCjbGZYawTPiajHhImzxh2MQ754a 1tYWrtdbHBOkYW337FsttJ8Y19k2fTxF0wltZ+pBaYgNGwxQjb3J/D0CnD+E2d6nMKS2 1DUWBcKZBx+DfC1BIXr2qfwBY3tN89G+b//QsIJmmRmhTHndHokYxk9uNTepKEls4dh5 t1ORnEmBdSfnUyTq3mcFDY4me9Y3a0iOuHF8zHeFSVYqopzKiYLnxp++dL8PBYDRzrwD 0O0TqQ0A4Rs6tXlvHXJDPL/zmfgbh8XDSJitOHI57tOvCa1fmdJ+leJbycUJj7uyZ5/z iw== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2h0ut2g20c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Mar 2018 07:47:44 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w2T7lhnU025802 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Mar 2018 07:47:43 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w2T7lgHc032613; Thu, 29 Mar 2018 07:47:42 GMT Received: from shipfan.cn.oracle.com (/10.113.210.105) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 29 Mar 2018 00:47:41 -0700 From: Zhu Yanjun To: monis@mellanox.com, dledford@redhat.com, jgg@ziepe.ca, linux-rdma@vger.kernel.org Subject: [PATCHv2 1/2] IB/rxe: make rxe_find_route6 compact Date: Thu, 29 Mar 2018 03:46:36 -0400 Message-Id: <1522309597-23022-1-git-send-email-yanjun.zhu@oracle.com> X-Mailer: git-send-email 2.7.4 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8846 signatures=668695 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=542 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1803290080 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 In the file rxe_net.c, to make rxe_find_route6 compact, IPV6_CONFIG is moved into the function rxe_find_route6. CC: Srinivas Eeda CC: Junxiao Bi Signed-off-by: Zhu Yanjun --- V1->V2: Follow Jason's advice, remove ifdef. --- drivers/infiniband/sw/rxe/rxe_net.c | 55 ++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 32 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c index 159246b..01f26f3 100644 --- a/drivers/infiniband/sw/rxe/rxe_net.c +++ b/drivers/infiniband/sw/rxe/rxe_net.c @@ -140,48 +140,39 @@ static struct dst_entry *rxe_find_route4(struct net_device *ndev, return &rt->dst; } -#if IS_ENABLED(CONFIG_IPV6) static struct dst_entry *rxe_find_route6(struct net_device *ndev, struct in6_addr *saddr, struct in6_addr *daddr) { - struct dst_entry *ndst; - struct flowi6 fl6 = { { 0 } }; - - memset(&fl6, 0, sizeof(fl6)); - fl6.flowi6_oif = ndev->ifindex; - memcpy(&fl6.saddr, saddr, sizeof(*saddr)); - memcpy(&fl6.daddr, daddr, sizeof(*daddr)); - fl6.flowi6_proto = IPPROTO_UDP; - - if (unlikely(ipv6_stub->ipv6_dst_lookup(sock_net(recv_sockets.sk6->sk), - recv_sockets.sk6->sk, &ndst, &fl6))) { - pr_err_ratelimited("no route to %pI6\n", daddr); - goto put; - } + if (IS_ENABLED(CONFIG_IPV6)) { + struct dst_entry *ndst; + struct flowi6 fl6 = { { 0 } }; + + memset(&fl6, 0, sizeof(fl6)); + fl6.flowi6_oif = ndev->ifindex; + memcpy(&fl6.saddr, saddr, sizeof(*saddr)); + memcpy(&fl6.daddr, daddr, sizeof(*daddr)); + fl6.flowi6_proto = IPPROTO_UDP; + + if (unlikely(ipv6_stub->ipv6_dst_lookup( + sock_net(recv_sockets.sk6->sk), + recv_sockets.sk6->sk, &ndst, &fl6))) { + pr_err_ratelimited("no route to %pI6\n", daddr); + goto put; + } - if (unlikely(ndst->error)) { - pr_err("no route to %pI6\n", daddr); - goto put; - } + if (unlikely(ndst->error)) { + pr_err("no route to %pI6\n", daddr); + goto put; + } - return ndst; + return ndst; put: - dst_release(ndst); - return NULL; -} - -#else - -static struct dst_entry *rxe_find_route6(struct net_device *ndev, - struct in6_addr *saddr, - struct in6_addr *daddr) -{ + dst_release(ndst); + } return NULL; } -#endif - static struct dst_entry *rxe_find_route(struct rxe_dev *rxe, struct rxe_qp *qp, struct rxe_av *av)