Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1719348 > unrolled thread

[PATCH] IB/core: replace memcpy with ether_addr_copy

Started byHimanshu Jha <himanshujha199640@gmail.com>
First post2017-08-24 17:50 +0200
Last post2017-08-24 19:50 +0200
Articles 4 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] IB/core: replace memcpy with ether_addr_copy Himanshu Jha <himanshujha199640@gmail.com> - 2017-08-24 17:50 +0200
    Re: [PATCH] IB/core: replace memcpy with ether_addr_copy Joe Perches <joe@perches.com> - 2017-08-24 18:10 +0200
      Re: [PATCH] IB/core: replace memcpy with ether_addr_copy Himanshu Jha <himanshujha199640@gmail.com> - 2017-08-24 19:40 +0200
        Re: [PATCH] IB/core: replace memcpy with ether_addr_copy Joe Perches <joe@perches.com> - 2017-08-24 19:50 +0200

#1719348 — [PATCH] IB/core: replace memcpy with ether_addr_copy

FromHimanshu Jha <himanshujha199640@gmail.com>
Date2017-08-24 17:50 +0200
Subject[PATCH] IB/core: replace memcpy with ether_addr_copy
Message-ID<ui2yl-8q8-15@gated-at.bofh.it>
Use ether_addr_copy to copy an ethernet address of size ETH_ALEN
instead of memcpy.

Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
---
 drivers/infiniband/core/addr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index 437522c..fc5bf11 100644
--- 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);
-- 
2.7.4

[toc] | [next] | [standalone]


#1719374

FromJoe Perches <joe@perches.com>
Date2017-08-24 18:10 +0200
Message-ID<ui2RJ-kG-55@gated-at.bofh.it>
In reply to#1719348
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?

[toc] | [prev] | [next] | [standalone]


#1719463

FromHimanshu Jha <himanshujha199640@gmail.com>
Date2017-08-24 19:40 +0200
Message-ID<ui4gO-17m-5@gated-at.bofh.it>
In reply to#1719374
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.

Apologies!

[toc] | [prev] | [next] | [standalone]


#1719478

FromJoe Perches <joe@perches.com>
Date2017-08-24 19:50 +0200
Message-ID<ui4qu-1bx-23@gated-at.bofh.it>
In reply to#1719463
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);

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web