Skip to content

Commit 8c63ff0

Browse files
JoePerchesjessegross
authored andcommitted
openvswitch: Use ether_addr_copy
It's slightly smaller/faster for some architectures. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Jesse Gross <jesse@nicira.com>
1 parent 2235ad1 commit 8c63ff0

3 files changed

Lines changed: 16 additions & 16 deletions

File tree

‎net/openvswitch/actions.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ static int set_eth_addr(struct sk_buff *skb,
134134

135135
skb_postpull_rcsum(skb, eth_hdr(skb), ETH_ALEN * 2);
136136

137-
memcpy(eth_hdr(skb)->h_source, eth_key->eth_src, ETH_ALEN);
138-
memcpy(eth_hdr(skb)->h_dest, eth_key->eth_dst, ETH_ALEN);
137+
ether_addr_copy(eth_hdr(skb)->h_source, eth_key->eth_src);
138+
ether_addr_copy(eth_hdr(skb)->h_dest, eth_key->eth_dst);
139139

140140
ovs_skb_postpush_rcsum(skb, eth_hdr(skb), ETH_ALEN * 2);
141141

‎net/openvswitch/flow.c‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -372,14 +372,14 @@ static int parse_icmpv6(struct sk_buff *skb, struct sw_flow_key *key,
372372
&& opt_len == 8) {
373373
if (unlikely(!is_zero_ether_addr(key->ipv6.nd.sll)))
374374
goto invalid;
375-
memcpy(key->ipv6.nd.sll,
376-
&nd->opt[offset+sizeof(*nd_opt)], ETH_ALEN);
375+
ether_addr_copy(key->ipv6.nd.sll,
376+
&nd->opt[offset+sizeof(*nd_opt)]);
377377
} else if (nd_opt->nd_opt_type == ND_OPT_TARGET_LL_ADDR
378378
&& opt_len == 8) {
379379
if (unlikely(!is_zero_ether_addr(key->ipv6.nd.tll)))
380380
goto invalid;
381-
memcpy(key->ipv6.nd.tll,
382-
&nd->opt[offset+sizeof(*nd_opt)], ETH_ALEN);
381+
ether_addr_copy(key->ipv6.nd.tll,
382+
&nd->opt[offset+sizeof(*nd_opt)]);
383383
}
384384

385385
icmp_len -= opt_len;
@@ -439,8 +439,8 @@ int ovs_flow_extract(struct sk_buff *skb, u16 in_port, struct sw_flow_key *key)
439439
* header in the linear data area.
440440
*/
441441
eth = eth_hdr(skb);
442-
memcpy(key->eth.src, eth->h_source, ETH_ALEN);
443-
memcpy(key->eth.dst, eth->h_dest, ETH_ALEN);
442+
ether_addr_copy(key->eth.src, eth->h_source);
443+
ether_addr_copy(key->eth.dst, eth->h_dest);
444444

445445
__skb_pull(skb, 2 * ETH_ALEN);
446446
/* We are going to push all headers that we pull, so no need to
@@ -538,8 +538,8 @@ int ovs_flow_extract(struct sk_buff *skb, u16 in_port, struct sw_flow_key *key)
538538
key->ip.proto = ntohs(arp->ar_op);
539539
memcpy(&key->ipv4.addr.src, arp->ar_sip, sizeof(key->ipv4.addr.src));
540540
memcpy(&key->ipv4.addr.dst, arp->ar_tip, sizeof(key->ipv4.addr.dst));
541-
memcpy(key->ipv4.arp.sha, arp->ar_sha, ETH_ALEN);
542-
memcpy(key->ipv4.arp.tha, arp->ar_tha, ETH_ALEN);
541+
ether_addr_copy(key->ipv4.arp.sha, arp->ar_sha);
542+
ether_addr_copy(key->ipv4.arp.tha, arp->ar_tha);
543543
}
544544
} else if (key->eth.type == htons(ETH_P_IPV6)) {
545545
int nh_len; /* IPv6 Header + Extensions */

‎net/openvswitch/flow_netlink.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -986,8 +986,8 @@ int ovs_nla_put_flow(const struct sw_flow_key *swkey,
986986
goto nla_put_failure;
987987

988988
eth_key = nla_data(nla);
989-
memcpy(eth_key->eth_src, output->eth.src, ETH_ALEN);
990-
memcpy(eth_key->eth_dst, output->eth.dst, ETH_ALEN);
989+
ether_addr_copy(eth_key->eth_src, output->eth.src);
990+
ether_addr_copy(eth_key->eth_dst, output->eth.dst);
991991

992992
if (swkey->eth.tci || swkey->eth.type == htons(ETH_P_8021Q)) {
993993
__be16 eth_type;
@@ -1059,8 +1059,8 @@ int ovs_nla_put_flow(const struct sw_flow_key *swkey,
10591059
arp_key->arp_sip = output->ipv4.addr.src;
10601060
arp_key->arp_tip = output->ipv4.addr.dst;
10611061
arp_key->arp_op = htons(output->ip.proto);
1062-
memcpy(arp_key->arp_sha, output->ipv4.arp.sha, ETH_ALEN);
1063-
memcpy(arp_key->arp_tha, output->ipv4.arp.tha, ETH_ALEN);
1062+
ether_addr_copy(arp_key->arp_sha, output->ipv4.arp.sha);
1063+
ether_addr_copy(arp_key->arp_tha, output->ipv4.arp.tha);
10641064
}
10651065

10661066
if ((swkey->eth.type == htons(ETH_P_IP) ||
@@ -1147,8 +1147,8 @@ int ovs_nla_put_flow(const struct sw_flow_key *swkey,
11471147
nd_key = nla_data(nla);
11481148
memcpy(nd_key->nd_target, &output->ipv6.nd.target,
11491149
sizeof(nd_key->nd_target));
1150-
memcpy(nd_key->nd_sll, output->ipv6.nd.sll, ETH_ALEN);
1151-
memcpy(nd_key->nd_tll, output->ipv6.nd.tll, ETH_ALEN);
1150+
ether_addr_copy(nd_key->nd_sll, output->ipv6.nd.sll);
1151+
ether_addr_copy(nd_key->nd_tll, output->ipv6.nd.tll);
11521152
}
11531153
}
11541154
}

0 commit comments

Comments
 (0)