mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/7] net: Convert aligned memcpy to ether_addr_copy
       [not found] <20140115.164540.450877805879786067.davem@davemloft.net>
@ 2014-01-20 17:52 ` Joe Perches
  2014-01-20 17:52   ` [PATCH 1/7] 8021q: Use ether_addr_copy Joe Perches
                     ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: Joe Perches @ 2014-01-20 17:52 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, linux-kernel

On Wed, 2014-01-15 at 16:45 -0800, David Miller wrote:
From: Joe Perches <joe@perches.com>
> Date: Wed, 15 Jan 2014 16:07:58 -0800
> 
> > If you want the ones for net-next net/ now (but not
> > for batman-adv, that maybe could use a new function like
> > ether_addr_copy_unaligned) here's a changestat.
> > 
> > Otherwise, I'll wait for the next cycle.
> 
> This looks fine, why don't you toss it my way over the weekend as I
> still have some backlog to process at the moment?
 
I didn't get that done this weekend, so next cycle
for most of net/.

I don't want to introduce any breakage this late and
there are possible unaligned memcpy(foo, bar, ETH_ALEN)
where one or both of foo/bar are stack pointers where
the alignment is hard to verify.

There are also statics declared without __aligned(2)
that will need updating.

Maybe ether_addr_copy_unaligned should be added too.

Here are the ones I could easily verify...
No worries if it's this cycle or next.

Joe Perches (7):
  8021q: Use ether_addr_copy
  appletalk: Use ether_addr_copy
  atm: Use ether_addr_copy
  caif_usb: Use ether_addr_copy
  netpoll: Use ether_addr_copy
  pktgen: Use ether_addr_copy
  dsa: Use ether_addr_copy

 net/8021q/vlan.c     |  2 +-
 net/8021q/vlan_dev.c |  6 +++---
 net/appletalk/aarp.c | 12 ++++++------
 net/atm/lec.c        |  9 +++++----
 net/atm/mpc.c        |  2 +-
 net/caif/caif_usb.c  |  4 ++--
 net/core/netpoll.c   |  4 ++--
 net/core/pktgen.c    |  8 ++++----
 net/dsa/slave.c      |  2 +-
 9 files changed, 25 insertions(+), 24 deletions(-)

-- 
1.8.1.2.459.gbcd45b4.dirty


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/7] 8021q: Use ether_addr_copy
  2014-01-20 17:52 ` [PATCH 0/7] net: Convert aligned memcpy to ether_addr_copy Joe Perches
@ 2014-01-20 17:52   ` Joe Perches
  2014-01-22  2:13     ` David Miller
  2014-01-20 17:52   ` [PATCH 2/7] appletalk: " Joe Perches
                     ` (5 subsequent siblings)
  6 siblings, 1 reply; 9+ messages in thread
From: Joe Perches @ 2014-01-20 17:52 UTC (permalink / raw)
  To: David Miller; +Cc: Patrick McHardy, David S. Miller, netdev, linux-kernel

Use ether_addr_copy instead of memcpy(a, b, ETH_ALEN) to
save some cycles on arm and powerpc.

Signed-off-by: Joe Perches <joe@perches.com>
---
 net/8021q/vlan.c     | 2 +-
 net/8021q/vlan_dev.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index b3d17d1..ec99099 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -301,7 +301,7 @@ static void vlan_sync_address(struct net_device *dev,
 	    !ether_addr_equal(vlandev->dev_addr, dev->dev_addr))
 		dev_uc_add(dev, vlandev->dev_addr);
 
-	memcpy(vlan->real_dev_addr, dev->dev_addr, ETH_ALEN);
+	ether_addr_copy(vlan->real_dev_addr, dev->dev_addr);
 }
 
 static void vlan_transfer_features(struct net_device *dev,
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 47c908f..de51c48 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -61,7 +61,7 @@ static int vlan_dev_rebuild_header(struct sk_buff *skb)
 		pr_debug("%s: unable to resolve type %X addresses\n",
 			 dev->name, ntohs(veth->h_vlan_encapsulated_proto));
 
-		memcpy(veth->h_source, dev->dev_addr, ETH_ALEN);
+		ether_addr_copy(veth->h_source, dev->dev_addr);
 		break;
 	}
 
@@ -303,7 +303,7 @@ static int vlan_dev_open(struct net_device *dev)
 			goto clear_allmulti;
 	}
 
-	memcpy(vlan->real_dev_addr, real_dev->dev_addr, ETH_ALEN);
+	ether_addr_copy(vlan->real_dev_addr, real_dev->dev_addr);
 
 	if (vlan->flags & VLAN_FLAG_GVRP)
 		vlan_gvrp_request_join(dev);
@@ -367,7 +367,7 @@ static int vlan_dev_set_mac_address(struct net_device *dev, void *p)
 		dev_uc_del(real_dev, dev->dev_addr);
 
 out:
-	memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
+	ether_addr_copy(dev->dev_addr, addr->sa_data);
 	return 0;
 }
 
-- 
1.8.1.2.459.gbcd45b4.dirty


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 2/7] appletalk: Use ether_addr_copy
  2014-01-20 17:52 ` [PATCH 0/7] net: Convert aligned memcpy to ether_addr_copy Joe Perches
  2014-01-20 17:52   ` [PATCH 1/7] 8021q: Use ether_addr_copy Joe Perches
@ 2014-01-20 17:52   ` Joe Perches
  2014-01-20 17:52   ` [PATCH 3/7] atm: " Joe Perches
                     ` (4 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Joe Perches @ 2014-01-20 17:52 UTC (permalink / raw)
  To: David Miller
  Cc: Arnaldo Carvalho de Melo, David S. Miller, netdev, linux-kernel

Use ether_addr_copy instead of memcpy(a, b, ETH_ALEN) to
save some cycles on arm and powerpc.

Convert struct aarp_entry.hwaddr[6] to hwaddr[ETH_ALEN].

Signed-off-by: Joe Perches <joe@perches.com>
---
 net/appletalk/aarp.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/net/appletalk/aarp.c b/net/appletalk/aarp.c
index 690356f..d0b7be1 100644
--- a/net/appletalk/aarp.c
+++ b/net/appletalk/aarp.c
@@ -67,7 +67,7 @@ struct aarp_entry {
 	unsigned long		expires_at;
 	struct atalk_addr	target_addr;
 	struct net_device	*dev;
-	char			hwaddr[6];
+	char			hwaddr[ETH_ALEN];
 	unsigned short		xmit_count;
 	struct aarp_entry	*next;
 };
@@ -134,7 +134,7 @@ static void __aarp_send_query(struct aarp_entry *a)
 	eah->pa_len	 = AARP_PA_ALEN;
 	eah->function	 = htons(AARP_REQUEST);
 
-	memcpy(eah->hw_src, dev->dev_addr, ETH_ALEN);
+	ether_addr_copy(eah->hw_src, dev->dev_addr);
 
 	eah->pa_src_zero = 0;
 	eah->pa_src_net	 = sat->s_net;
@@ -181,7 +181,7 @@ static void aarp_send_reply(struct net_device *dev, struct atalk_addr *us,
 	eah->pa_len	 = AARP_PA_ALEN;
 	eah->function	 = htons(AARP_REPLY);
 
-	memcpy(eah->hw_src, dev->dev_addr, ETH_ALEN);
+	ether_addr_copy(eah->hw_src, dev->dev_addr);
 
 	eah->pa_src_zero = 0;
 	eah->pa_src_net	 = us->s_net;
@@ -190,7 +190,7 @@ static void aarp_send_reply(struct net_device *dev, struct atalk_addr *us,
 	if (!sha)
 		memset(eah->hw_dst, '\0', ETH_ALEN);
 	else
-		memcpy(eah->hw_dst, sha, ETH_ALEN);
+		ether_addr_copy(eah->hw_dst, sha);
 
 	eah->pa_dst_zero = 0;
 	eah->pa_dst_net	 = them->s_net;
@@ -232,7 +232,7 @@ static void aarp_send_probe(struct net_device *dev, struct atalk_addr *us)
 	eah->pa_len	 = AARP_PA_ALEN;
 	eah->function	 = htons(AARP_PROBE);
 
-	memcpy(eah->hw_src, dev->dev_addr, ETH_ALEN);
+	ether_addr_copy(eah->hw_src, dev->dev_addr);
 
 	eah->pa_src_zero = 0;
 	eah->pa_src_net	 = us->s_net;
@@ -790,7 +790,7 @@ static int aarp_rcv(struct sk_buff *skb, struct net_device *dev,
 			break;
 
 		/* We can fill one in - this is good. */
-		memcpy(a->hwaddr, ea->hw_src, ETH_ALEN);
+		ether_addr_copy(a->hwaddr, ea->hw_src);
 		__aarp_resolved(&unresolved[hash], a, hash);
 		if (!unresolved_count)
 			mod_timer(&aarp_timer,
-- 
1.8.1.2.459.gbcd45b4.dirty


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 3/7] atm: Use ether_addr_copy
  2014-01-20 17:52 ` [PATCH 0/7] net: Convert aligned memcpy to ether_addr_copy Joe Perches
  2014-01-20 17:52   ` [PATCH 1/7] 8021q: Use ether_addr_copy Joe Perches
  2014-01-20 17:52   ` [PATCH 2/7] appletalk: " Joe Perches
@ 2014-01-20 17:52   ` Joe Perches
  2014-01-20 17:52   ` [PATCH 4/7] caif_usb: " Joe Perches
                     ` (3 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Joe Perches @ 2014-01-20 17:52 UTC (permalink / raw)
  To: David Miller; +Cc: David S. Miller, netdev, linux-kernel

Use ether_addr_copy instead of memcpy(a, b, ETH_ALEN) to
save some cycles on arm and powerpc.

Signed-off-by: Joe Perches <joe@perches.com>
---
 net/atm/lec.c | 9 +++++----
 net/atm/mpc.c | 2 +-
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/net/atm/lec.c b/net/atm/lec.c
index f23916b..0b73ae9 100644
--- a/net/atm/lec.c
+++ b/net/atm/lec.c
@@ -521,7 +521,7 @@ send_to_lecd(struct lec_priv *priv, atmlec_msg_type type,
 	if (data != NULL)
 		mesg->sizeoftlvs = data->len;
 	if (mac_addr)
-		memcpy(&mesg->content.normal.mac_addr, mac_addr, ETH_ALEN);
+		ether_addr_copy(&mesg->content.normal.mac_addr, mac_addr);
 	else
 		mesg->content.normal.targetless_le_arp = 1;
 	if (atm_addr)
@@ -1565,7 +1565,7 @@ static struct lec_arp_table *make_entry(struct lec_priv *priv,
 		pr_info("LEC: Arp entry kmalloc failed\n");
 		return NULL;
 	}
-	memcpy(to_return->mac_addr, mac_addr, ETH_ALEN);
+	ether_addr_copy(to_return->mac_addr, mac_addr);
 	INIT_HLIST_NODE(&to_return->next);
 	setup_timer(&to_return->timer, lec_arp_expire_arp,
 			(unsigned long)to_return);
@@ -1887,7 +1887,8 @@ lec_arp_update(struct lec_priv *priv, const unsigned char *mac_addr,
 					entry = tmp;
 				} else {
 					entry->status = ESI_FORWARD_DIRECT;
-					memcpy(entry->mac_addr, mac_addr, ETH_ALEN);
+					ether_addr_copy(entry->mac_addr,
+							mac_addr);
 					entry->last_used = jiffies;
 					lec_arp_add(priv, entry);
 				}
@@ -2263,7 +2264,7 @@ lec_arp_check_empties(struct lec_priv *priv,
 				  &priv->lec_arp_empty_ones, next) {
 		if (vcc == entry->vcc) {
 			del_timer(&entry->timer);
-			memcpy(entry->mac_addr, src, ETH_ALEN);
+			ether_addr_copy(entry->mac_addr, src);
 			entry->status = ESI_FORWARD_DIRECT;
 			entry->last_used = jiffies;
 			/* We might have got an entry */
diff --git a/net/atm/mpc.c b/net/atm/mpc.c
index 3af1275..b71ff6b 100644
--- a/net/atm/mpc.c
+++ b/net/atm/mpc.c
@@ -478,7 +478,7 @@ static const uint8_t *copy_macs(struct mpoa_client *mpc,
 			return NULL;
 		}
 	}
-	memcpy(mpc->mps_macs, router_mac, ETH_ALEN);
+	ether_addr_copy(mpc->mps_macs, router_mac);
 	tlvs += 20; if (device_type == MPS_AND_MPC) tlvs += 20;
 	if (mps_macs > 0)
 		memcpy(mpc->mps_macs, tlvs, mps_macs*ETH_ALEN);
-- 
1.8.1.2.459.gbcd45b4.dirty


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 4/7] caif_usb: Use ether_addr_copy
  2014-01-20 17:52 ` [PATCH 0/7] net: Convert aligned memcpy to ether_addr_copy Joe Perches
                     ` (2 preceding siblings ...)
  2014-01-20 17:52   ` [PATCH 3/7] atm: " Joe Perches
@ 2014-01-20 17:52   ` Joe Perches
  2014-01-20 17:52   ` [PATCH 5/7] netpoll: " Joe Perches
                     ` (2 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Joe Perches @ 2014-01-20 17:52 UTC (permalink / raw)
  To: David Miller; +Cc: Dmitry Tarnyagin, David S. Miller, netdev, linux-kernel

Use ether_addr_copy instead of memcpy(a, b, ETH_ALEN) to
save some cycles on arm and powerpc.

Signed-off-by: Joe Perches <joe@perches.com>
---
 net/caif/caif_usb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/caif/caif_usb.c b/net/caif/caif_usb.c
index 75ed04b..dda589c 100644
--- a/net/caif/caif_usb.c
+++ b/net/caif/caif_usb.c
@@ -105,8 +105,8 @@ static struct cflayer *cfusbl_create(int phyid, u8 ethaddr[ETH_ALEN],
 	 *	5-11	source address
 	 *	12-13	protocol type
 	 */
-	memcpy(&this->tx_eth_hdr[ETH_ALEN], braddr, ETH_ALEN);
-	memcpy(&this->tx_eth_hdr[ETH_ALEN], ethaddr, ETH_ALEN);
+	ether_addr_copy(&this->tx_eth_hdr[ETH_ALEN], braddr);
+	ether_addr_copy(&this->tx_eth_hdr[ETH_ALEN], ethaddr);
 	this->tx_eth_hdr[12] = cpu_to_be16(ETH_P_802_EX1) & 0xff;
 	this->tx_eth_hdr[13] = (cpu_to_be16(ETH_P_802_EX1) >> 8) & 0xff;
 	pr_debug("caif ethernet TX-header dst:%pM src:%pM type:%02x%02x\n",
-- 
1.8.1.2.459.gbcd45b4.dirty


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 5/7] netpoll: Use ether_addr_copy
  2014-01-20 17:52 ` [PATCH 0/7] net: Convert aligned memcpy to ether_addr_copy Joe Perches
                     ` (3 preceding siblings ...)
  2014-01-20 17:52   ` [PATCH 4/7] caif_usb: " Joe Perches
@ 2014-01-20 17:52   ` Joe Perches
  2014-01-20 17:52   ` [PATCH 6/7] pktgen: " Joe Perches
  2014-01-20 17:52   ` [PATCH 7/7] dsa: " Joe Perches
  6 siblings, 0 replies; 9+ messages in thread
From: Joe Perches @ 2014-01-20 17:52 UTC (permalink / raw)
  To: David Miller; +Cc: David S. Miller, netdev, linux-kernel

Use ether_addr_copy instead of memcpy(a, b, ETH_ALEN) to
save some cycles on arm and powerpc.

Signed-off-by: Joe Perches <joe@perches.com>
---
 net/core/netpoll.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index 19fe9c7..c03f3de 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -520,8 +520,8 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
 		skb->protocol = eth->h_proto = htons(ETH_P_IP);
 	}
 
-	memcpy(eth->h_source, np->dev->dev_addr, ETH_ALEN);
-	memcpy(eth->h_dest, np->remote_mac, ETH_ALEN);
+	ether_addr_copy(eth->h_source, np->dev->dev_addr);
+	ether_addr_copy(eth->h_dest, np->remote_mac);
 
 	skb->dev = np->dev;
 
-- 
1.8.1.2.459.gbcd45b4.dirty


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 6/7] pktgen: Use ether_addr_copy
  2014-01-20 17:52 ` [PATCH 0/7] net: Convert aligned memcpy to ether_addr_copy Joe Perches
                     ` (4 preceding siblings ...)
  2014-01-20 17:52   ` [PATCH 5/7] netpoll: " Joe Perches
@ 2014-01-20 17:52   ` Joe Perches
  2014-01-20 17:52   ` [PATCH 7/7] dsa: " Joe Perches
  6 siblings, 0 replies; 9+ messages in thread
From: Joe Perches @ 2014-01-20 17:52 UTC (permalink / raw)
  To: David Miller; +Cc: David S. Miller, netdev, linux-kernel

Use ether_addr_copy instead of memcpy(a, b, ETH_ALEN) to
save some cycles on arm and powerpc.

Signed-off-by: Joe Perches <joe@perches.com>
---
 net/core/pktgen.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index fa3e128..fdac61c 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -1440,7 +1440,7 @@ static ssize_t pktgen_if_write(struct file *file,
 		if (!mac_pton(valstr, pkt_dev->dst_mac))
 			return -EINVAL;
 		/* Set up Dest MAC */
-		memcpy(&pkt_dev->hh[0], pkt_dev->dst_mac, ETH_ALEN);
+		ether_addr_copy(&pkt_dev->hh[0], pkt_dev->dst_mac);
 
 		sprintf(pg_result, "OK: dstmac %pM", pkt_dev->dst_mac);
 		return count;
@@ -1457,7 +1457,7 @@ static ssize_t pktgen_if_write(struct file *file,
 		if (!mac_pton(valstr, pkt_dev->src_mac))
 			return -EINVAL;
 		/* Set up Src MAC */
-		memcpy(&pkt_dev->hh[6], pkt_dev->src_mac, ETH_ALEN);
+		ether_addr_copy(&pkt_dev->hh[6], pkt_dev->src_mac);
 
 		sprintf(pg_result, "OK: srcmac %pM", pkt_dev->src_mac);
 		return count;
@@ -2060,10 +2060,10 @@ static void pktgen_setup_inject(struct pktgen_dev *pkt_dev)
 	/* Default to the interface's mac if not explicitly set. */
 
 	if (is_zero_ether_addr(pkt_dev->src_mac))
-		memcpy(&(pkt_dev->hh[6]), pkt_dev->odev->dev_addr, ETH_ALEN);
+		ether_addr_copy(&(pkt_dev->hh[6]), pkt_dev->odev->dev_addr);
 
 	/* Set up Dest MAC */
-	memcpy(&(pkt_dev->hh[0]), pkt_dev->dst_mac, ETH_ALEN);
+	ether_addr_copy(&(pkt_dev->hh[0]), pkt_dev->dst_mac);
 
 	if (pkt_dev->flags & F_IPV6) {
 		int i, set = 0, err = 1;
-- 
1.8.1.2.459.gbcd45b4.dirty


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 7/7] dsa: Use ether_addr_copy
  2014-01-20 17:52 ` [PATCH 0/7] net: Convert aligned memcpy to ether_addr_copy Joe Perches
                     ` (5 preceding siblings ...)
  2014-01-20 17:52   ` [PATCH 6/7] pktgen: " Joe Perches
@ 2014-01-20 17:52   ` Joe Perches
  6 siblings, 0 replies; 9+ messages in thread
From: Joe Perches @ 2014-01-20 17:52 UTC (permalink / raw)
  To: David Miller; +Cc: David S. Miller, netdev, linux-kernel

Use ether_addr_copy instead of memcpy(a, b, ETH_ALEN) to
save some cycles on arm and powerpc.

Signed-off-by: Joe Perches <joe@perches.com>
---
 net/dsa/slave.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 29d684e..02c0e17 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -156,7 +156,7 @@ static int dsa_slave_set_mac_address(struct net_device *dev, void *a)
 		dev_uc_del(master, dev->dev_addr);
 
 out:
-	memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
+	ether_addr_copy(dev->dev_addr, addr->sa_data);
 
 	return 0;
 }
-- 
1.8.1.2.459.gbcd45b4.dirty


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/7] 8021q: Use ether_addr_copy
  2014-01-20 17:52   ` [PATCH 1/7] 8021q: Use ether_addr_copy Joe Perches
@ 2014-01-22  2:13     ` David Miller
  0 siblings, 0 replies; 9+ messages in thread
From: David Miller @ 2014-01-22  2:13 UTC (permalink / raw)
  To: joe; +Cc: kaber, netdev, linux-kernel


All 7 patches applied, thanks Joe.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-01-22  2:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20140115.164540.450877805879786067.davem@davemloft.net>
2014-01-20 17:52 ` [PATCH 0/7] net: Convert aligned memcpy to ether_addr_copy Joe Perches
2014-01-20 17:52   ` [PATCH 1/7] 8021q: Use ether_addr_copy Joe Perches
2014-01-22  2:13     ` David Miller
2014-01-20 17:52   ` [PATCH 2/7] appletalk: " Joe Perches
2014-01-20 17:52   ` [PATCH 3/7] atm: " Joe Perches
2014-01-20 17:52   ` [PATCH 4/7] caif_usb: " Joe Perches
2014-01-20 17:52   ` [PATCH 5/7] netpoll: " Joe Perches
2014-01-20 17:52   ` [PATCH 6/7] pktgen: " Joe Perches
2014-01-20 17:52   ` [PATCH 7/7] dsa: " Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome