Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753391AbdHXRlV (ORCPT ); Thu, 24 Aug 2017 13:41:21 -0400 Received: from smtprelay0064.hostedemail.com ([216.40.44.64]:53717 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752583AbdHXRlT (ORCPT ); Thu, 24 Aug 2017 13:41:19 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::,RULES_HIT:41:355:379:541:599:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:2828:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3868:3871:3873:4321:5007:8603:9040:10004:10400:10848:11026:11232:11658:11914:12043:12296:12438:12740:12760:12895:13069:13161:13229:13311:13357:13439:14659:14721:21080:21627:30003:30054:30079:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: cloud40_458624a78a934 X-Filterd-Recvd-Size: 2418 Message-ID: <1503596476.12569.6.camel@perches.com> Subject: Re: [PATCH] IB/core: replace memcpy with ether_addr_copy From: Joe Perches To: Himanshu Jha Cc: dledford@redhat.com, sean.hefty@intel.com, hal.rosenstock@gmail.com, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Date: Thu, 24 Aug 2017 10:41:16 -0700 In-Reply-To: <20170824173103.GA13379@himanshu-Vostro-3559> References: <1503589307-10457-1-git-send-email-himanshujha199640@gmail.com> <1503590792.12569.2.camel@perches.com> <20170824173103.GA13379@himanshu-Vostro-3559> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.22.6-1ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1446 Lines: 42 On Thu, 2017-08-24 at 23:01 +0530, Himanshu Jha wrote: > On Thu, Aug 24, 2017 at 09:06:32AM -0700, Joe Perches wrote: > > On Thu, 2017-08-24 at 21:11 +0530, Himanshu Jha wrote: > > > Use ether_addr_copy to copy an ethernet address of size ETH_ALEN > > > instead of memcpy. > > > > [] > > diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c > > [] > > > @@ -798,7 +798,7 @@ int rdma_addr_find_l2_eth_by_grh(const union ib_gid *sgid, > > > if (ret) > > > return ret; > > > > > > - memcpy(dmac, dev_addr.dst_dev_addr, ETH_ALEN); > > > + ether_addr_copy(dmac, dev_addr.dst_dev_addr); > > > dev = dev_get_by_index(&init_net, dev_addr.bound_dev_if); > > > if (!dev) > > > return -ENODEV; > > > @@ -831,7 +831,7 @@ int rdma_addr_find_smac_by_sgid(union ib_gid *sgid, u8 *smac, u16 *vlan_id) > > > if (ret) > > > return ret; > > > > > > - memcpy(smac, dev_addr.src_dev_addr, ETH_ALEN); > > > + ether_addr_copy(smac, dev_addr.src_dev_addr); > > > return ret; > > > } > > > EXPORT_SYMBOL(rdma_addr_find_smac_by_sgid); > > > > Both dmac and smac are function arguments. > > What guarantees these to be > > aligned properly? > > > > Yes, you are correct! > The arguments should be a pointer to a six byte Ethernet address. Just for completeness: The argument should be a pointer to a 6 byte Ethernet address which is also aligned to an even hardware address. i.e.: u8 mac_addr[ETH_ALEN] __aligned(2);