diff options
author | Joe Perches <joe@perches.com> | 2014-02-18 13:37:20 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-02-18 18:14:09 -0500 |
commit | e83abe37ba492514943f45f7bb1ba6b055eb88b0 (patch) | |
tree | 192260c8c2f01c9e47653bc0ad270241daeceb77 | |
parent | 42621fd39435126fa03a0283bda4bc76db5b52a9 (diff) |
hsr: Use ether_addr_copy
It's slightly smaller/faster for some architectures.
Make sure def_multicast_addr is __aligned(2)
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/hsr/hsr_device.c | 10 | ||||
-rw-r--r-- | net/hsr/hsr_framereg.c | 20 | ||||
-rw-r--r-- | net/hsr/hsr_main.c | 4 |
3 files changed, 17 insertions, 17 deletions
diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c index cac505f166d5..e5302b7f7ca9 100644 --- a/net/hsr/hsr_device.c +++ b/net/hsr/hsr_device.c | |||
@@ -209,7 +209,7 @@ static int slave_xmit(struct sk_buff *skb, struct hsr_priv *hsr_priv, | |||
209 | /* Address substitution (IEC62439-3 pp 26, 50): replace mac | 209 | /* Address substitution (IEC62439-3 pp 26, 50): replace mac |
210 | * address of outgoing frame with that of the outgoing slave's. | 210 | * address of outgoing frame with that of the outgoing slave's. |
211 | */ | 211 | */ |
212 | memcpy(hsr_ethhdr->ethhdr.h_source, skb->dev->dev_addr, ETH_ALEN); | 212 | ether_addr_copy(hsr_ethhdr->ethhdr.h_source, skb->dev->dev_addr); |
213 | 213 | ||
214 | return dev_queue_xmit(skb); | 214 | return dev_queue_xmit(skb); |
215 | } | 215 | } |
@@ -346,7 +346,7 @@ static void send_hsr_supervision_frame(struct net_device *hsr_dev, u8 type) | |||
346 | 346 | ||
347 | /* Payload: MacAddressA */ | 347 | /* Payload: MacAddressA */ |
348 | hsr_sp = (typeof(hsr_sp)) skb_put(skb, sizeof(*hsr_sp)); | 348 | hsr_sp = (typeof(hsr_sp)) skb_put(skb, sizeof(*hsr_sp)); |
349 | memcpy(hsr_sp->MacAddressA, hsr_dev->dev_addr, ETH_ALEN); | 349 | ether_addr_copy(hsr_sp->MacAddressA, hsr_dev->dev_addr); |
350 | 350 | ||
351 | dev_queue_xmit(skb); | 351 | dev_queue_xmit(skb); |
352 | return; | 352 | return; |
@@ -493,7 +493,7 @@ static int check_slave_ok(struct net_device *dev) | |||
493 | 493 | ||
494 | 494 | ||
495 | /* Default multicast address for HSR Supervision frames */ | 495 | /* Default multicast address for HSR Supervision frames */ |
496 | static const unsigned char def_multicast_addr[ETH_ALEN] = { | 496 | static const unsigned char def_multicast_addr[ETH_ALEN] __aligned(2) = { |
497 | 0x01, 0x15, 0x4e, 0x00, 0x01, 0x00 | 497 | 0x01, 0x15, 0x4e, 0x00, 0x01, 0x00 |
498 | }; | 498 | }; |
499 | 499 | ||
@@ -519,7 +519,7 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2], | |||
519 | hsr_priv->announce_timer.function = hsr_announce; | 519 | hsr_priv->announce_timer.function = hsr_announce; |
520 | hsr_priv->announce_timer.data = (unsigned long) hsr_priv; | 520 | hsr_priv->announce_timer.data = (unsigned long) hsr_priv; |
521 | 521 | ||
522 | memcpy(hsr_priv->sup_multicast_addr, def_multicast_addr, ETH_ALEN); | 522 | ether_addr_copy(hsr_priv->sup_multicast_addr, def_multicast_addr); |
523 | hsr_priv->sup_multicast_addr[ETH_ALEN - 1] = multicast_spec; | 523 | hsr_priv->sup_multicast_addr[ETH_ALEN - 1] = multicast_spec; |
524 | 524 | ||
525 | /* FIXME: should I modify the value of these? | 525 | /* FIXME: should I modify the value of these? |
@@ -547,7 +547,7 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2], | |||
547 | hsr_dev->features |= NETIF_F_VLAN_CHALLENGED; | 547 | hsr_dev->features |= NETIF_F_VLAN_CHALLENGED; |
548 | 548 | ||
549 | /* Set hsr_dev's MAC address to that of mac_slave1 */ | 549 | /* Set hsr_dev's MAC address to that of mac_slave1 */ |
550 | memcpy(hsr_dev->dev_addr, hsr_priv->slave[0]->dev_addr, ETH_ALEN); | 550 | ether_addr_copy(hsr_dev->dev_addr, hsr_priv->slave[0]->dev_addr); |
551 | 551 | ||
552 | /* Set required header length */ | 552 | /* Set required header length */ |
553 | for (i = 0; i < HSR_MAX_SLAVE; i++) { | 553 | for (i = 0; i < HSR_MAX_SLAVE; i++) { |
diff --git a/net/hsr/hsr_framereg.c b/net/hsr/hsr_framereg.c index 327060c6c874..3d0100f0bae3 100644 --- a/net/hsr/hsr_framereg.c +++ b/net/hsr/hsr_framereg.c | |||
@@ -108,8 +108,8 @@ int hsr_create_self_node(struct list_head *self_node_db, | |||
108 | if (!node) | 108 | if (!node) |
109 | return -ENOMEM; | 109 | return -ENOMEM; |
110 | 110 | ||
111 | memcpy(node->MacAddressA, addr_a, ETH_ALEN); | 111 | ether_addr_copy(node->MacAddressA, addr_a); |
112 | memcpy(node->MacAddressB, addr_b, ETH_ALEN); | 112 | ether_addr_copy(node->MacAddressB, addr_b); |
113 | 113 | ||
114 | rcu_read_lock(); | 114 | rcu_read_lock(); |
115 | oldnode = list_first_or_null_rcu(self_node_db, | 115 | oldnode = list_first_or_null_rcu(self_node_db, |
@@ -199,7 +199,7 @@ struct node_entry *hsr_merge_node(struct hsr_priv *hsr_priv, | |||
199 | /* Node is known, but frame was received from an unknown | 199 | /* Node is known, but frame was received from an unknown |
200 | * address. Node is PICS_SUBS capable; merge its AddrB. | 200 | * address. Node is PICS_SUBS capable; merge its AddrB. |
201 | */ | 201 | */ |
202 | memcpy(node->MacAddressB, hsr_ethsup->ethhdr.h_source, ETH_ALEN); | 202 | ether_addr_copy(node->MacAddressB, hsr_ethsup->ethhdr.h_source); |
203 | node->AddrB_if = dev_idx; | 203 | node->AddrB_if = dev_idx; |
204 | return node; | 204 | return node; |
205 | } | 205 | } |
@@ -208,8 +208,8 @@ struct node_entry *hsr_merge_node(struct hsr_priv *hsr_priv, | |||
208 | if (!node) | 208 | if (!node) |
209 | return NULL; | 209 | return NULL; |
210 | 210 | ||
211 | memcpy(node->MacAddressA, hsr_sp->MacAddressA, ETH_ALEN); | 211 | ether_addr_copy(node->MacAddressA, hsr_sp->MacAddressA); |
212 | memcpy(node->MacAddressB, hsr_ethsup->ethhdr.h_source, ETH_ALEN); | 212 | ether_addr_copy(node->MacAddressB, hsr_ethsup->ethhdr.h_source); |
213 | if (!ether_addr_equal(hsr_sp->MacAddressA, hsr_ethsup->ethhdr.h_source)) | 213 | if (!ether_addr_equal(hsr_sp->MacAddressA, hsr_ethsup->ethhdr.h_source)) |
214 | node->AddrB_if = dev_idx; | 214 | node->AddrB_if = dev_idx; |
215 | else | 215 | else |
@@ -250,7 +250,7 @@ void hsr_addr_subst_source(struct hsr_priv *hsr_priv, struct sk_buff *skb) | |||
250 | rcu_read_lock(); | 250 | rcu_read_lock(); |
251 | node = find_node_by_AddrB(&hsr_priv->node_db, ethhdr->h_source); | 251 | node = find_node_by_AddrB(&hsr_priv->node_db, ethhdr->h_source); |
252 | if (node) | 252 | if (node) |
253 | memcpy(ethhdr->h_source, node->MacAddressA, ETH_ALEN); | 253 | ether_addr_copy(ethhdr->h_source, node->MacAddressA); |
254 | rcu_read_unlock(); | 254 | rcu_read_unlock(); |
255 | } | 255 | } |
256 | 256 | ||
@@ -272,7 +272,7 @@ void hsr_addr_subst_dest(struct hsr_priv *hsr_priv, struct ethhdr *ethhdr, | |||
272 | rcu_read_lock(); | 272 | rcu_read_lock(); |
273 | node = find_node_by_AddrA(&hsr_priv->node_db, ethhdr->h_dest); | 273 | node = find_node_by_AddrA(&hsr_priv->node_db, ethhdr->h_dest); |
274 | if (node && (node->AddrB_if == dev_idx)) | 274 | if (node && (node->AddrB_if == dev_idx)) |
275 | memcpy(ethhdr->h_dest, node->MacAddressB, ETH_ALEN); | 275 | ether_addr_copy(ethhdr->h_dest, node->MacAddressB); |
276 | rcu_read_unlock(); | 276 | rcu_read_unlock(); |
277 | } | 277 | } |
278 | 278 | ||
@@ -428,13 +428,13 @@ void *hsr_get_next_node(struct hsr_priv *hsr_priv, void *_pos, | |||
428 | node = list_first_or_null_rcu(&hsr_priv->node_db, | 428 | node = list_first_or_null_rcu(&hsr_priv->node_db, |
429 | struct node_entry, mac_list); | 429 | struct node_entry, mac_list); |
430 | if (node) | 430 | if (node) |
431 | memcpy(addr, node->MacAddressA, ETH_ALEN); | 431 | ether_addr_copy(addr, node->MacAddressA); |
432 | return node; | 432 | return node; |
433 | } | 433 | } |
434 | 434 | ||
435 | node = _pos; | 435 | node = _pos; |
436 | list_for_each_entry_continue_rcu(node, &hsr_priv->node_db, mac_list) { | 436 | list_for_each_entry_continue_rcu(node, &hsr_priv->node_db, mac_list) { |
437 | memcpy(addr, node->MacAddressA, ETH_ALEN); | 437 | ether_addr_copy(addr, node->MacAddressA); |
438 | return node; | 438 | return node; |
439 | } | 439 | } |
440 | 440 | ||
@@ -462,7 +462,7 @@ int hsr_get_node_data(struct hsr_priv *hsr_priv, | |||
462 | return -ENOENT; /* No such entry */ | 462 | return -ENOENT; /* No such entry */ |
463 | } | 463 | } |
464 | 464 | ||
465 | memcpy(addr_b, node->MacAddressB, ETH_ALEN); | 465 | ether_addr_copy(addr_b, node->MacAddressB); |
466 | 466 | ||
467 | tdiff = jiffies - node->time_in[HSR_DEV_SLAVE_A]; | 467 | tdiff = jiffies - node->time_in[HSR_DEV_SLAVE_A]; |
468 | if (node->time_in_stale[HSR_DEV_SLAVE_A]) | 468 | if (node->time_in_stale[HSR_DEV_SLAVE_A]) |
diff --git a/net/hsr/hsr_main.c b/net/hsr/hsr_main.c index af68dd83a4e3..10010c543edf 100644 --- a/net/hsr/hsr_main.c +++ b/net/hsr/hsr_main.c | |||
@@ -138,8 +138,8 @@ static int hsr_netdev_notify(struct notifier_block *nb, unsigned long event, | |||
138 | break; | 138 | break; |
139 | 139 | ||
140 | if (dev == hsr_priv->slave[0]) | 140 | if (dev == hsr_priv->slave[0]) |
141 | memcpy(hsr_priv->dev->dev_addr, | 141 | ether_addr_copy(hsr_priv->dev->dev_addr, |
142 | hsr_priv->slave[0]->dev_addr, ETH_ALEN); | 142 | hsr_priv->slave[0]->dev_addr); |
143 | 143 | ||
144 | /* Make sure we recognize frames from ourselves in hsr_rcv() */ | 144 | /* Make sure we recognize frames from ourselves in hsr_rcv() */ |
145 | res = hsr_create_self_node(&hsr_priv->self_node_db, | 145 | res = hsr_create_self_node(&hsr_priv->self_node_db, |