From: William Tu <[email protected]>
Upstream commit:
commit c69de58ba84f480879de64571d9dae5102d10ed6
Author: William Tu <[email protected]>
Date: Thu Jan 25 13:20:09 2018 -0800
net: erspan: use bitfield instead of mask and offset
Originally the erspan fields are defined as a group into a __be16 field,
and use mask and offset to access each field. This is more costly due to
calling ntohs/htons. The patch changes it to use bitfields.
Signed-off-by: William Tu <[email protected]>
Acked-by: Pravin B Shelar <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
Folds in the ip_gre portions of this commit. Other portions of this
commit are included in a previous patch where it is called out.
Cc: William Tu <[email protected]>
Signed-off-by: Greg Rose <[email protected]>
---
datapath/linux/compat/ip_gre.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/datapath/linux/compat/ip_gre.c b/datapath/linux/compat/ip_gre.c
index 9b3613a..f99ef1b 100644
--- a/datapath/linux/compat/ip_gre.c
+++ b/datapath/linux/compat/ip_gre.c
@@ -551,19 +551,15 @@ static void erspan_fb_xmit(struct sk_buff *skb, struct
net_device *dev,
}
if (version == 1) {
- erspan_build_header(skb, tunnel_id_to_key32(key->tun_id),
+ erspan_build_header(skb, ntohl(tunnel_id_to_key32(key->tun_id)),
ntohl(md->u.index), truncate, true);
} else if (version == 2) {
- u16 md2_flags;
- u8 direction;
- u16 hwid;
-
- md2_flags = ntohs(md->u.md2.flags);
- direction = (md2_flags & DIR_MASK) >> DIR_OFFSET;
- hwid = (md2_flags & HWID_MASK) >> HWID_OFFSET;
+ erspan_build_header_v2(skb,
+ ntohl(tunnel_id_to_key32(key->tun_id)),
+ md->u.md2.dir,
+ get_hwid(&md->u.md2),
+ truncate, true);
- erspan_build_header_v2(skb, tunnel_id_to_key32(key->tun_id),
- direction, hwid, truncate, true);
} else {
goto err_free_rt;
}
@@ -785,10 +781,11 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,
/* Push ERSPAN header */
if (tunnel->erspan_ver == 1)
- erspan_build_header(skb, tunnel->parms.o_key, tunnel->index,
+ erspan_build_header(skb, ntohl(tunnel->parms.o_key),
+ tunnel->index,
truncate, true);
else
- erspan_build_header_v2(skb, tunnel->parms.o_key,
+ erspan_build_header_v2(skb, ntohl(tunnel->parms.o_key),
tunnel->dir, tunnel->hwid,
truncate, true);
--
1.8.3.1
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev