From mboxrd@z Thu Jan 1 00:00:00 1970 From: Doug Ledford Subject: Re: [infiniband-core] question about arguments position Date: Thu, 04 May 2017 19:49:06 -0400 Message-ID: <1493941746.3041.242.camel@redhat.com> References: <20170504124209.Horde.B4I2tu9lZ9_KMd07dtjWcl2@gator4166.hostgator.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit Return-path: In-Reply-To: Sender: linux-rdma-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Parav Pandit , "Gustavo A. R. Silva" , Sean Hefty , Hal Rosenstock , Sagi Grimberg , Bart Van Assche , Steve Wise , Leon Romanovsky , Yishai Hadas , Moni Shoua Cc: "linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , "linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" List-Id: linux-rdma@vger.kernel.org On Thu, 2017-05-04 at 21:52 +0000, Parav Pandit wrote: > Hi, > > > > > -----Original Message----- > > From: linux-rdma-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org [mailto:linux-rdma- > > owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.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-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.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. -- Doug Ledford     GPG KeyID: B826A3330E572FDD     Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752475AbdEDXtK (ORCPT ); Thu, 4 May 2017 19:49:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44756 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751478AbdEDXtJ (ORCPT ); Thu, 4 May 2017 19:49:09 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2515A61B9C Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dledford@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 2515A61B9C Message-ID: <1493941746.3041.242.camel@redhat.com> Subject: Re: [infiniband-core] question about arguments position From: Doug Ledford To: Parav Pandit , "Gustavo A. R. Silva" , Sean Hefty , Hal Rosenstock , Sagi Grimberg , Bart Van Assche , Steve Wise , Leon Romanovsky , Yishai Hadas , Moni Shoua Cc: "linux-rdma@vger.kernel.org" , "linux-kernel@vger.kernel.org" Date: Thu, 04 May 2017 19:49:06 -0400 In-Reply-To: References: <20170504124209.Horde.B4I2tu9lZ9_KMd07dtjWcl2@gator4166.hostgator.com> Organization: Red Hat, Inc. Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 04 May 2017 23:49:09 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. -- Doug Ledford     GPG KeyID: B826A3330E572FDD     Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD