From patchwork Fri May 5 01:38:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 9712947 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 1BFC56020B for ; Fri, 5 May 2017 02:00:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 01ECD286C2 for ; Fri, 5 May 2017 02:00:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA366286C6; Fri, 5 May 2017 02:00:58 +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=-5.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, RCVD_NUMERIC_HELO autolearn=unavailable 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 6567B286C2 for ; Fri, 5 May 2017 02:00:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752149AbdEECA4 (ORCPT ); Thu, 4 May 2017 22:00:56 -0400 Received: from gateway21.websitewelcome.com ([192.185.45.250]:13520 "EHLO gateway21.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752043AbdEECA4 (ORCPT ); Thu, 4 May 2017 22:00:56 -0400 X-Greylist: delayed 1350 seconds by postgrey-1.27 at vger.kernel.org; Thu, 04 May 2017 22:00:56 EDT Received: from cm4.websitewelcome.com (unknown [108.167.139.16]) by gateway21.websitewelcome.com (Postfix) with ESMTP id 3DD86400CF3B7 for ; Thu, 4 May 2017 20:38:23 -0500 (CDT) Received: from gator4166.hostgator.com ([108.167.133.22]) by cm4.websitewelcome.com with id GReN1v00C0V9LXg01RePuF; Thu, 04 May 2017 20:38:23 -0500 Received: from gator4166.hostgator.com ([108.167.133.22]:14173) by gator4166.hostgator.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.87) (envelope-from ) id 1d6SCL-0002s5-QY; Thu, 04 May 2017 20:38:21 -0500 Received: from 177.237.177.8 ([177.237.177.8]) by gator4166.hostgator.com (Horde Framework) with HTTPS; Thu, 04 May 2017 20:38:20 -0500 Date: Thu, 04 May 2017 20:38:20 -0500 Message-ID: <20170504203820.Horde.-XF5wCocLZWytz_Ml2dGEBZ@gator4166.hostgator.com> From: "Gustavo A. R. Silva" To: Doug Ledford Cc: Parav Pandit , Sean Hefty , Hal Rosenstock , Sagi Grimberg , Bart Van Assche , Steve Wise , Leon Romanovsky , Yishai Hadas , Moni Shoua , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [infiniband-core] question about arguments position References: <20170504124209.Horde.B4I2tu9lZ9_KMd07dtjWcl2@gator4166.hostgator.com> <1493941746.3041.242.camel@redhat.com> In-Reply-To: <1493941746.3041.242.camel@redhat.com> User-Agent: Horde Application Framework 5 MIME-Version: 1.0 Content-Disposition: inline X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 108.167.133.22 X-Exim-ID: 1d6SCL-0002s5-QY X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: gator4166.hostgator.com [108.167.133.22]:14173 X-Source-Auth: garsilva@embeddedor.com X-Email-Count: 4 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= 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 Hi Parav and Doug, Quoting Doug Ledford : > On Thu, 2017-05-04 at 21:52 +0000, Parav Pandit wrote: >> Hi, >> >> > >> > -----Original Message----- >> > From: linux-rdma-owner@vger.kernel.org [mailto:linux-rdma- >> > owner@vger.kernel.org] On Behalf Of Gustavo A. R. Silva >> > Sent: Thursday, May 4, 2017 12:42 PM >> > To: Doug Ledford ; Sean Hefty >> > ; Hal Rosenstock ; >> > Sagi >> > Grimberg ; Bart Van Assche >> > ; Steve Wise > > om>; >> > Leon Romanovsky ; Yishai Hadas >> > ; Moni Shoua >> > Cc: linux-rdma@vger.kernel.org; linux-kernel@vger.kernel.org >> > Subject: [infiniband-core] question about arguments position >> > >> > >> > Hello everybody, >> > >> > While looking into Coverity ID 1351047 I ran into the following >> > piece of code at >> > drivers/infiniband/core/verbs.c:496: >> > >> > ret = rdma_addr_find_l2_eth_by_grh(&dgid, &sgid, >> >                                     ah_attr->dmac, >> >                                     wc->wc_flags & IB_WC_WITH_VLAN >> > ? >> >                                     NULL : &vlan_id, >> >                                     &if_index, &hoplimit); >> > >> > >> > The issue here is that the position of arguments in the call to >> > rdma_addr_find_l2_eth_by_grh() function do not match the order of >> > the >> > parameters: >> > >> > &dgid is passed to sgid >> > &sgid is passed to dgid >> > >> > This is the function prototype: >> > >> > int rdma_addr_find_l2_eth_by_grh(const union ib_gid *sgid, >> >  const union ib_gid *dgid, >> >  u8 *dmac, u16 *vlan_id, int *if_index, >> >  int *hoplimit) >> > >> > My question here is if this is intentional? >> > >> Yes. ib_init_ah_from_wc() creates ah from the incoming packet. >> Incoming packet has dgid of the receiver node on which this code is >> getting executed >> And sgid contains the GID of the sender. >> >> When resolving mac address of destination, you use arrived dgid as >> sgid. >> And use sgid as dgid because sgid contains destinations GID whom to >> respond to. > > A patch to add a comment and forestall future questions here might be a > good addition. > In the case of Coverity, I already triaged and documented this issue. So people can ignore it in the future. Regarding the code comments, what about the following patch based on Parav's comments: struct ib_ah_attr *ah_attr) Thanks for clarifying --- Gustavo A. R. Silva -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c index 85ed505..38864ea 100644 --- a/drivers/infiniband/core/verbs.c +++ b/drivers/infiniband/core/verbs.c @@ -450,6 +450,19 @@ int ib_get_gids_from_rdma_hdr(const union rdma_network_hdr *hdr, } EXPORT_SYMBOL(ib_get_gids_from_rdma_hdr); +/* + * This function creates ah from the incoming packet. + * Incoming packet has dgid of the receiver node on which this code is + * getting executed and, sgid contains the GID of the sender. + * + * When resolving mac address of destination, the arrived dgid is used + * as sgid and, sgid is used as dgid because sgid contains destinations + * GID whom to respond to. + * + * This is why when calling rdma_addr_find_l2_eth_by_grh() function, the + * position of arguments dgid and sgid do not match the order of the + * parameters. + */ int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, const struct ib_wc *wc, const struct ib_grh *grh,