Re: [PATCH net-next v12 7/9] openvswitch: add Ethernet push and pop actions
flat view
From: Pravin Shelar <hidden>
Date: 2016-10-21 04:22:26
On Mon, Oct 17, 2016 at 6:02 AM, Jiri Benc [off-list ref] wrote:
It's not allowed to push Ethernet header in front of another Ethernet header. It's not allowed to pop Ethernet header if there's a vlan tag. This preserves the invariant that L3 packet never has a vlan tag. Based on previous versions by Lorand Jakab and Simon Horman. Signed-off-by: Lorand Jakab <redacted> Signed-off-by: Simon Horman <redacted> Signed-off-by: Jiri Benc <redacted> --- include/uapi/linux/openvswitch.h | 15 ++++++++++++ net/openvswitch/actions.c | 49 ++++++++++++++++++++++++++++++++++++++++ net/openvswitch/flow_netlink.c | 18 +++++++++++++++ 3 files changed, 82 insertions(+)
... ...
quoted hunk ↗ jump to hunk
diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c index 064cbcb7b0c5..a63572fb878e 100644 --- a/net/openvswitch/actions.c +++ b/net/openvswitch/actions.c@@ -317,6 +317,47 @@ static int set_eth_addr(struct sk_buff *skb, struct sw_flow_key *flow_key, return 0; } +/* pop_eth does not support VLAN packets as this action is never called + * for them. + */ +static int pop_eth(struct sk_buff *skb, struct sw_flow_key *key) +{ + skb_pull_rcsum(skb, ETH_HLEN); + skb_reset_mac_header(skb); + skb->mac_len -= ETH_HLEN; + + /* safe right before invalidate_flow_key */ + key->mac_proto = MAC_PROTO_NONE; + invalidate_flow_key(key); + return 0; +} + +static int push_eth(struct sk_buff *skb, struct sw_flow_key *key, + const struct ovs_action_push_eth *ethh) +{ + struct ethhdr *hdr; + + /* Add the new Ethernet header */ + if (skb_cow_head(skb, ETH_HLEN) < 0) + return -ENOMEM; + + skb_push(skb, ETH_HLEN); + skb_reset_mac_header(skb); + skb->mac_len = ETH_HLEN; +
The eth pop substracts ETH_HLEN but here the length is set. I think it should be consistent with respect to eth-pop.