Enhanced skb_mpls_pop to update ethertype of the packet in all the cases when an ethernet header is present is the packet.
Subsystems (4)
PATCH v2 1/1 Enhanced skb_mpls_pop to update ethertype of the packet in all the cases when an ethernet header is present is the packet.
From: Martin Varghese <[email protected]>
The skb_mpls_pop was not updating ethertype of an ethernet packet if the packet was originally received from a non ARPHRD_ETHER device.
In the below OVS data path flow, since the device corresponding to port 7 is an l3 device (ARPHRD_NONE) the skb_mpls_pop function does not update the ethertype of the packet even though the previous push_eth action had added an ethernet header to the packet.
recirc_id(0),in_port(7),eth_type(0x8847), mpls(label=12/0xfffff,tc=0/0,ttl=0/0x0,bos=1/1), actions:push_eth(src=00:00:00:00:00:00,dst=00:00:00:00:00:00), pop_mpls(eth_type=0x800),4
---
Changes in v2:
- check for dev type removed while updating ethertype in function skb_mpls_pop.
- key->mac_proto is checked in function pop_mpls to pass ethernt flag to skb_mpls_pop.
- dev type is checked in function tcf_mpls_act to pass ethernet flag to skb_mpls_pop.
include/linux/skbuff.h | 3 ++- net/core/skbuff.c | 7 ++++--- net/openvswitch/actions.c | 4 +++- net/sched/act_mpls.c | 4 +++- 4 files changed, 12 insertions(+), 6 deletions(-)
include/linux/skbuff.h +2 -1
@@ -3530,7 +3530,8 @@ int skb_zerocopy(struct sk_buff *to, struct sk_buff *from,int skb_vlan_push (struct sk_buff *skb,__be16 vlan_proto,u16 vlan_tci);int skb_mpls_push (struct sk_buff *skb,__be32 mpls_lse,__be16 mpls_proto,int mac_len); -int skb_mpls_pop (struct sk_buff *skb,__be16 next_proto,int mac_len); +int skb_mpls_pop (struct sk_buff *skb,__be16 next_proto,int mac_len, +bool ethernet);int skb_mpls_update_lse (struct sk_buff *skb,__be32 mpls_lse);int skb_mpls_dec_ttl (struct sk_buff *skb); struct sk_buff *pskb_extract(struct sk_buff *skb, int off, int to_copy,
net/core/skbuff.c +4 -3
@@ -5529,12 +5529,13 @@ int skb_mpls_push(struct sk_buff *skb, __be32 mpls_lse, __be16 mpls_proto,* @skb: buffer * @next_proto: ethertype of header after popped MPLS header * @mac_len: length of the MAC header -* +* @ethernet: flag to indicate if ethernet header is present in packet * Expects skb->data at mac header. * * Returns 0 on success, -errno otherwise. */ -int skb_mpls_pop (struct sk_buff *skb,__be16 next_proto,int mac_len) +int skb_mpls_pop (struct sk_buff *skb,__be16 next_proto,int mac_len, +bool ethernet) {int err;
@@ -5553,7 +5554,7 @@ int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto, int mac_len)skb_reset_mac_header (skb);skb_set_network_header (skb, mac_len); -if (skb->dev && skb->dev->type ==ARPHRD_ETHER ) { +if (ethernet) {struct ethhdr *hdr;/* use mpls_hdr() to get ethertype to account for VLANs. */
net/openvswitch/actions.c +3 -1
@@ -179,7 +179,9 @@ static int pop_mpls(struct sk_buff *skb, struct sw_flow_key *key, {int err; - err =skb_mpls_pop (skb, ethertype, skb->mac_len); + err =skb_mpls_pop (skb, ethertype, skb->mac_len, + (key->mac_proto & ~SW_FLOW_KEY_INVALID ) + ==MAC_PROTO_ETHERNET );if (err)return err;
net/sched/act_mpls.c +3 -1
@@ -13,6 +13,7 @@#include <net/pkt_sched.h> #include <net/pkt_cls.h> #include <net/tc_act/tc_mpls.h> +#include <linux/if_arp.h> static unsigned int mpls_net_id;static struct tc_action_ops act_mpls_ops;
@@ -76,7 +77,8 @@ static int tcf_mpls_act(struct sk_buff *skb, const struct tc_action *a,switch (p->tcfm_action) {case TCA_MPLS_ACT_POP : -if (skb_mpls_pop (skb, p->tcfm_proto, mac_len)) +if (skb_mpls_pop (skb, p->tcfm_proto, mac_len, + (skb->dev && skb->dev->type ==ARPHRD_ETHER ))) goto drop;break ;case TCA_MPLS_ACT_PUSH :
Signature · 1 line
1.8.3.1
Quoted 10 lines · Martin Varghese
From: Martin Varghese <[email protected]>
The
skb_mpls_popwas not updating ethertype of an ethernet packet if the packet was originally received from a nonARPHRD_ETHERdevice.In the below OVS data path flow, since the device corresponding to port 7 is an l3 device (
ARPHRD_NONE) theskb_mpls_popfunction does not update the ethertype of the packet even though the previouspush_ethaction had added an ethernet header to the packet.
Quoted 6 lines
recirc_id(0),in_port(7),eth_type(0x8847),
mpls(label=12/0xfffff,tc=0/0,ttl=0/0x0,bos=1/1), actions:push_eth(src=00:00:00:00:00:00,dst=00:00:00:00:00:00), pop_mpls(eth_type=0x800),4Signed-off-by Martin Varghese <[email protected]>
So this fixes all the way back to commit ed246cee09b9 ("net: core: move pop MPLS functionality from OvS to core helper")? Please add a Fixes: tag.
Quoted 7 lines
Changes in v2:
- check for dev type removed while updating ethertype in functionskb_mpls_pop.
-key->mac_protois checked in functionpop_mplsto pass ethernt flag toskb_mpls_pop.
- dev type is checked in functiontcf_mpls_actto pass ethernet flag toskb_mpls_pop.
nit: changelog can be kept in the commit message for netdev patches
net/core/skbuff.c int skb_mpls_push(struct sk_buff *skb, __be32 mpls_lse, __be16 mpls_proto, · line 5532
Quoted 10 lines
net/core/skbuff.c +1
-1@@ -5529,12 +5529,13 @@ int skb_mpls_push(struct sk_buff *skb, __be32 mpls_lse, __be16 mpls_proto,* @skb: buffer * @next_proto: ethertype of header after popped MPLS header * @mac_len: length of the MAC header -* +* @ethernet: flag to indicate if ethernet header is present in packet
Please don't remove the empty line between params and function description.
Quoted 16 lines
net/core/skbuff.c +2
-1* Expects skb->data at mac header. * * Returns 0 on success, -errno otherwise. */ -int skb_mpls_pop (struct sk_buff *skb,__be16 next_proto,int mac_len) +int skb_mpls_pop (struct sk_buff *skb,__be16 next_proto,int mac_len, +bool ethernet) {int err;net/sched/act_mpls.c +0
-0
net/sched/act_mpls.c line 16
Quoted 4 lines
net/sched/act_mpls.c +1
-0@@ -13,6 +13,7 @@#include <net/pkt_sched.h> #include <net/pkt_cls.h> #include <net/tc_act/tc_mpls.h> +#include <linux/if_arp.h>
Please retain the alphabetical order of includes.
net/sched/act_mpls.c static int tcf_mpls_act(struct sk_buff *skb, const struct tc_action *a, · line 81
Quoted 9 lines
net/sched/act_mpls.c +2
-1static unsigned int mpls_net_id;static struct tc_action_ops act_mpls_ops;@@ -76,7 +77,8 @@ static int tcf_mpls_act(struct sk_buff *skb, const struct tc_action *a,switch (p->tcfm_action) {case TCA_MPLS_ACT_POP : -if (skb_mpls_pop (skb, p->tcfm_proto, mac_len)) +if (skb_mpls_pop (skb, p->tcfm_proto, mac_len, + (skb->dev && skb->dev->type ==ARPHRD_ETHER )))
Parenthesis unnecessary
Quoted 3 lines
net/sched/act_mpls.c +0
-0goto drop;break ;case TCA_MPLS_ACT_PUSH :
Quoted 80 lines · Martin Varghese
From: Martin Varghese <[email protected]>
The
skb_mpls_popwas not updating ethertype of an ethernet packet if the packet was originally received from a nonARPHRD_ETHERdevice.In the below OVS data path flow, since the device corresponding to port 7 is an l3 device (
ARPHRD_NONE) theskb_mpls_popfunction does not update the ethertype of the packet even though the previouspush_ethaction had added an ethernet header to the packet.recirc_id(0),in_port(7),eth_type(0x8847),
mpls(label=12/0xfffff,tc=0/0,ttl=0/0x0,bos=1/1), actions:push_eth(src=00:00:00:00:00:00,dst=00:00:00:00:00:00), pop_mpls(eth_type=0x800),4Signed-off-by Martin Varghese <[email protected]>---
Changes in v2:
- check for dev type removed while updating ethertype in functionskb_mpls_pop.
-key->mac_protois checked in functionpop_mplsto pass ethernt flag toskb_mpls_pop.
- dev type is checked in functiontcf_mpls_actto pass ethernet flag toskb_mpls_pop.include/linux/skbuff.h | 3 ++- net/core/skbuff.c | 7 ++++--- net/openvswitch/actions.c | 4 +++- net/sched/act_mpls.c | 4 +++- 4 files changed, 12 insertions(+), 6 deletions(-)include/linux/skbuff.h +2
-1@@ -3530,7 +3530,8 @@ int skb_zerocopy(struct sk_buff *to, struct sk_buff *from,int skb_vlan_push (struct sk_buff *skb,__be16 vlan_proto,u16 vlan_tci);int skb_mpls_push (struct sk_buff *skb,__be32 mpls_lse,__be16 mpls_proto,int mac_len); -int skb_mpls_pop (struct sk_buff *skb,__be16 next_proto,int mac_len); +int skb_mpls_pop (struct sk_buff *skb,__be16 next_proto,int mac_len, +bool ethernet);int skb_mpls_update_lse (struct sk_buff *skb,__be32 mpls_lse);int skb_mpls_dec_ttl (struct sk_buff *skb); struct sk_buff *pskb_extract(struct sk_buff *skb, int off, int to_copy,net/core/skbuff.c +4
-3@@ -5529,12 +5529,13 @@ int skb_mpls_push(struct sk_buff *skb, __be32 mpls_lse, __be16 mpls_proto,* @skb: buffer * @next_proto: ethertype of header after popped MPLS header * @mac_len: length of the MAC header -* +* @ethernet: flag to indicate if ethernet header is present in packet * Expects skb->data at mac header. * * Returns 0 on success, -errno otherwise. */ -int skb_mpls_pop (struct sk_buff *skb,__be16 next_proto,int mac_len) +int skb_mpls_pop (struct sk_buff *skb,__be16 next_proto,int mac_len, +bool ethernet) {int err;@@ -5553,7 +5554,7 @@ int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto, int mac_len)skb_reset_mac_header (skb);skb_set_network_header (skb, mac_len); -if (skb->dev && skb->dev->type ==ARPHRD_ETHER ) { +if (ethernet) {struct ethhdr *hdr;/* use mpls_hdr() to get ethertype to account for VLANs. */ net/openvswitch/actions.c +0
-0
net/openvswitch/actions.c static int pop_mpls(struct sk_buff *skb, struct sw_flow_key *key, · line 187
Quoted 10 lines
net/openvswitch/actions.c +3
-1@@ -179,7 +179,9 @@ static int pop_mpls(struct sk_buff *skb, struct sw_flow_key *key, {int err; - err =skb_mpls_pop (skb, ethertype, skb->mac_len); + err =skb_mpls_pop (skb, ethertype, skb->mac_len, + (key->mac_proto & ~SW_FLOW_KEY_INVALID ) + ==MAC_PROTO_ETHERNET );if (err)return err;
Why you are not using ovs_key_mac_proto() here?
Quoted 25 lines
net/sched/act_mpls.c +3
-2@@ -13,6 +13,7 @@#include <net/pkt_sched.h> #include <net/pkt_cls.h> #include <net/tc_act/tc_mpls.h> +#include <linux/if_arp.h> static unsigned int mpls_net_id;static struct tc_action_ops act_mpls_ops;@@ -76,7 +77,8 @@ static int tcf_mpls_act(struct sk_buff *skb, const struct tc_action *a,switch (p->tcfm_action) {case TCA_MPLS_ACT_POP : -if (skb_mpls_pop (skb, p->tcfm_proto, mac_len)) +if (skb_mpls_pop (skb, p->tcfm_proto, mac_len, + (skb->dev && skb->dev->type ==ARPHRD_ETHER ))) goto drop;break ;case TCA_MPLS_ACT_PUSH : --1.8.3.1
Quoted 85 lines · Pravin Shelar
Quoted 83 lines · Martin Varghese
From: Martin Varghese <[email protected]>
The
skb_mpls_popwas not updating ethertype of an ethernet packet if the packet was originally received from a nonARPHRD_ETHERdevice.In the below OVS data path flow, since the device corresponding to port 7 is an l3 device (
ARPHRD_NONE) theskb_mpls_popfunction does not update the ethertype of the packet even though the previouspush_ethaction had added an ethernet header to the packet.recirc_id(0),in_port(7),eth_type(0x8847),
mpls(label=12/0xfffff,tc=0/0,ttl=0/0x0,bos=1/1), actions:push_eth(src=00:00:00:00:00:00,dst=00:00:00:00:00:00), pop_mpls(eth_type=0x800),4Signed-off-by Martin Varghese <[email protected]>---
Changes in v2:
- check for dev type removed while updating ethertype in functionskb_mpls_pop.
-key->mac_protois checked in functionpop_mplsto pass ethernt flag toskb_mpls_pop.
- dev type is checked in functiontcf_mpls_actto pass ethernet flag toskb_mpls_pop.include/linux/skbuff.h | 3 ++- net/core/skbuff.c | 7 ++++--- net/openvswitch/actions.c | 4 +++- net/sched/act_mpls.c | 4 +++- 4 files changed, 12 insertions(+), 6 deletions(-)include/linux/skbuff.h +2
-1@@ -3530,7 +3530,8 @@ int skb_zerocopy(struct sk_buff *to, struct sk_buff *from,int skb_vlan_push (struct sk_buff *skb,__be16 vlan_proto,u16 vlan_tci);int skb_mpls_push (struct sk_buff *skb,__be32 mpls_lse,__be16 mpls_proto,int mac_len); -int skb_mpls_pop (struct sk_buff *skb,__be16 next_proto,int mac_len); +int skb_mpls_pop (struct sk_buff *skb,__be16 next_proto,int mac_len, +bool ethernet);int skb_mpls_update_lse (struct sk_buff *skb,__be32 mpls_lse);int skb_mpls_dec_ttl (struct sk_buff *skb); struct sk_buff *pskb_extract(struct sk_buff *skb, int off, int to_copy,net/core/skbuff.c +4
-3@@ -5529,12 +5529,13 @@ int skb_mpls_push(struct sk_buff *skb, __be32 mpls_lse, __be16 mpls_proto,* @skb: buffer * @next_proto: ethertype of header after popped MPLS header * @mac_len: length of the MAC header -* +* @ethernet: flag to indicate if ethernet header is present in packet * Expects skb->data at mac header. * * Returns 0 on success, -errno otherwise. */ -int skb_mpls_pop (struct sk_buff *skb,__be16 next_proto,int mac_len) +int skb_mpls_pop (struct sk_buff *skb,__be16 next_proto,int mac_len, +bool ethernet) {int err;@@ -5553,7 +5554,7 @@ int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto, int mac_len)skb_reset_mac_header (skb);skb_set_network_header (skb, mac_len); -if (skb->dev && skb->dev->type ==ARPHRD_ETHER ) { +if (ethernet) {struct ethhdr *hdr;/* use mpls_hdr() to get ethertype to account for VLANs. */ net/openvswitch/actions.c +0
-0@@ -179,7 +179,9 @@ static int pop_mpls(struct sk_buff *skb, struct sw_flow_key *key, {int err;
Quoted 9 lines
net/openvswitch/actions.c static int pop_mpls(struct sk_buff *skb, struct sw_flow_key *key, · line 187
Quoted 7 lines
net/openvswitch/actions.c +3
-1- err =skb_mpls_pop (skb, ethertype, skb->mac_len); + err =skb_mpls_pop (skb, ethertype, skb->mac_len, + (key->mac_proto & ~SW_FLOW_KEY_INVALID ) + ==MAC_PROTO_ETHERNET );if (err)return err;Why you are not using
ovs_key_mac_proto()here?
ovs_key_mac_proto returns u8 (supposedly enum sw_flow_mac_proto)
The new skb_mpls_pop takes bool as the last argument.
int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto, int mac_len,
bool ethernet)
But if I change the new prototype to take u8(enum sw_flow_mac_proto) as the last argument
I need to make the generic skb_mpls_pop code aware of enum sw_flow_mac_proto defined in Openvswitch/flow.h .
- if (ethernet) {
+ if(ethernet == MAC_PROTO_ETHERNET)
struct ethhdr *hdr;
/* use mpls_hdr() to get ethertype to account for VLANs. */
hdr = (struct ethhdr *)((void *)mpls_hdr(skb) - ETH_HLEN);
skb_mod_eth_type(skb, hdr, next_proto);
}
skb->protocol = next_proto;Also ,it means at all the places where skb_mpls_pop is used, this Openvswitch header file (Openvswitch/flow.h) has to be included, which I assume is not clean.
Quoted 25 lines
Quoted 25 lines
net/sched/act_mpls.c +3
-2@@ -13,6 +13,7 @@#include <net/pkt_sched.h> #include <net/pkt_cls.h> #include <net/tc_act/tc_mpls.h> +#include <linux/if_arp.h> static unsigned int mpls_net_id;static struct tc_action_ops act_mpls_ops;@@ -76,7 +77,8 @@ static int tcf_mpls_act(struct sk_buff *skb, const struct tc_action *a,switch (p->tcfm_action) {case TCA_MPLS_ACT_POP : -if (skb_mpls_pop (skb, p->tcfm_proto, mac_len)) +if (skb_mpls_pop (skb, p->tcfm_proto, mac_len, + (skb->dev && skb->dev->type ==ARPHRD_ETHER ))) goto drop;break ;case TCA_MPLS_ACT_PUSH : --1.8.3.1
Quoted 29 lines · Jakub Kicinski
Quoted 10 lines · Martin Varghese
From: Martin Varghese <[email protected]>
The
skb_mpls_popwas not updating ethertype of an ethernet packet if the packet was originally received from a nonARPHRD_ETHERdevice.In the below OVS data path flow, since the device corresponding to port 7 is an l3 device (
ARPHRD_NONE) theskb_mpls_popfunction does not update the ethertype of the packet even though the previouspush_ethaction had added an ethernet header to the packet.Quoted 6 lines
recirc_id(0),in_port(7),eth_type(0x8847),
mpls(label=12/0xfffff,tc=0/0,ttl=0/0x0,bos=1/1), actions:push_eth(src=00:00:00:00:00:00,dst=00:00:00:00:00:00), pop_mpls(eth_type=0x800),4Signed-off-by Martin Varghese <[email protected]>So this fixes all the way back to commit
ed246cee09b9("net: core: move pop MPLS functionality from OvS to core helper")? Please add a Fixes: tag.Quoted 7 lines
Changes in v2:
- check for dev type removed while updating ethertype in functionskb_mpls_pop.
-key->mac_protois checked in functionpop_mplsto pass ethernt flag toskb_mpls_pop.
- dev type is checked in functiontcf_mpls_actto pass ethernet flag toskb_mpls_pop.
Quoted 2 lines
nit: changelog can be kept in the commit message for netdev patches
Multiple versions are mostly due to coding error.do you insist to keep the change log in commit message ?
Quoted 41 lines
net/core/skbuff.c int skb_mpls_push(struct sk_buff *skb, __be32 mpls_lse, __be16 mpls_proto, · line 5532
Quoted 10 lines
net/core/skbuff.c +1
-1@@ -5529,12 +5529,13 @@ int skb_mpls_push(struct sk_buff *skb, __be32 mpls_lse, __be16 mpls_proto,* @skb: buffer * @next_proto: ethertype of header after popped MPLS header * @mac_len: length of the MAC header -* +* @ethernet: flag to indicate if ethernet header is present in packet Please don't remove the empty line between params and function description.
Quoted 16 lines
net/core/skbuff.c +2
-1* Expects skb->data at mac header. * * Returns 0 on success, -errno otherwise. */ -int skb_mpls_pop (struct sk_buff *skb,__be16 next_proto,int mac_len) +int skb_mpls_pop (struct sk_buff *skb,__be16 next_proto,int mac_len, +bool ethernet) {int err;net/sched/act_mpls.c +0
-0net/sched/act_mpls.c line 16
Quoted 4 lines
net/sched/act_mpls.c +1
-0@@ -13,6 +13,7 @@#include <net/pkt_sched.h> #include <net/pkt_cls.h> #include <net/tc_act/tc_mpls.h> +#include <linux/if_arp.h> Please retain the alphabetical order of includes.
Quoted 4 lines
net/sched/act_mpls.c +0
-0static unsigned int mpls_net_id;static struct tc_action_ops act_mpls_ops;@@ -76,7 +77,8 @@ static int tcf_mpls_act(struct sk_buff *skb, const struct tc_action *a,
Quoted 12 lines
net/sched/act_mpls.c static int tcf_mpls_act(struct sk_buff *skb, const struct tc_action *a, · line 81
Quoted 5 lines
net/sched/act_mpls.c +2
-1switch (p->tcfm_action) {case TCA_MPLS_ACT_POP : -if (skb_mpls_pop (skb, p->tcfm_proto, mac_len)) +if (skb_mpls_pop (skb, p->tcfm_proto, mac_len, + (skb->dev && skb->dev->type ==ARPHRD_ETHER )))Parenthesis unnecessary
Quoted 3 lines
net/sched/act_mpls.c +0
-0goto drop;break ;case TCA_MPLS_ACT_PUSH :
Thanks for reviewing the patch.
Quoted 85 lines · Pravin Shelar
Quoted 83 lines · Martin Varghese
From: Martin Varghese <[email protected]>
The
skb_mpls_popwas not updating ethertype of an ethernet packet if the packet was originally received from a nonARPHRD_ETHERdevice.In the below OVS data path flow, since the device corresponding to port 7 is an l3 device (
ARPHRD_NONE) theskb_mpls_popfunction does not update the ethertype of the packet even though the previouspush_ethaction had added an ethernet header to the packet.recirc_id(0),in_port(7),eth_type(0x8847),
mpls(label=12/0xfffff,tc=0/0,ttl=0/0x0,bos=1/1), actions:push_eth(src=00:00:00:00:00:00,dst=00:00:00:00:00:00), pop_mpls(eth_type=0x800),4Signed-off-by Martin Varghese <[email protected]>---
Changes in v2:
- check for dev type removed while updating ethertype in functionskb_mpls_pop.
-key->mac_protois checked in functionpop_mplsto pass ethernt flag toskb_mpls_pop.
- dev type is checked in functiontcf_mpls_actto pass ethernet flag toskb_mpls_pop.include/linux/skbuff.h | 3 ++- net/core/skbuff.c | 7 ++++--- net/openvswitch/actions.c | 4 +++- net/sched/act_mpls.c | 4 +++- 4 files changed, 12 insertions(+), 6 deletions(-)include/linux/skbuff.h +2
-1@@ -3530,7 +3530,8 @@ int skb_zerocopy(struct sk_buff *to, struct sk_buff *from,int skb_vlan_push (struct sk_buff *skb,__be16 vlan_proto,u16 vlan_tci);int skb_mpls_push (struct sk_buff *skb,__be32 mpls_lse,__be16 mpls_proto,int mac_len); -int skb_mpls_pop (struct sk_buff *skb,__be16 next_proto,int mac_len); +int skb_mpls_pop (struct sk_buff *skb,__be16 next_proto,int mac_len, +bool ethernet);int skb_mpls_update_lse (struct sk_buff *skb,__be32 mpls_lse);int skb_mpls_dec_ttl (struct sk_buff *skb); struct sk_buff *pskb_extract(struct sk_buff *skb, int off, int to_copy,net/core/skbuff.c +4
-3@@ -5529,12 +5529,13 @@ int skb_mpls_push(struct sk_buff *skb, __be32 mpls_lse, __be16 mpls_proto,* @skb: buffer * @next_proto: ethertype of header after popped MPLS header * @mac_len: length of the MAC header -* +* @ethernet: flag to indicate if ethernet header is present in packet * Expects skb->data at mac header. * * Returns 0 on success, -errno otherwise. */ -int skb_mpls_pop (struct sk_buff *skb,__be16 next_proto,int mac_len) +int skb_mpls_pop (struct sk_buff *skb,__be16 next_proto,int mac_len, +bool ethernet) {int err;@@ -5553,7 +5554,7 @@ int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto, int mac_len)skb_reset_mac_header (skb);skb_set_network_header (skb, mac_len); -if (skb->dev && skb->dev->type ==ARPHRD_ETHER ) { +if (ethernet) {struct ethhdr *hdr;/* use mpls_hdr() to get ethertype to account for VLANs. */ net/openvswitch/actions.c +0
-0@@ -179,7 +179,9 @@ static int pop_mpls(struct sk_buff *skb, struct sw_flow_key *key, {int err;
Quoted 9 lines
net/openvswitch/actions.c static int pop_mpls(struct sk_buff *skb, struct sw_flow_key *key, · line 187
Quoted 7 lines
net/openvswitch/actions.c +3
-1- err =skb_mpls_pop (skb, ethertype, skb->mac_len); + err =skb_mpls_pop (skb, ethertype, skb->mac_len, + (key->mac_proto & ~SW_FLOW_KEY_INVALID ) + ==MAC_PROTO_ETHERNET );if (err)return err;Why you are not using
ovs_key_mac_proto()here?
you meant
err = skb_mpls_pop(skb, ethertype, skb->mac_len,
ovs_key_mac_proto() == MAC_PROTO_ETHERNET);
Yes we could use it.
Quoted 25 lines
Quoted 25 lines
net/sched/act_mpls.c +3
-2@@ -13,6 +13,7 @@#include <net/pkt_sched.h> #include <net/pkt_cls.h> #include <net/tc_act/tc_mpls.h> +#include <linux/if_arp.h> static unsigned int mpls_net_id;static struct tc_action_ops act_mpls_ops;@@ -76,7 +77,8 @@ static int tcf_mpls_act(struct sk_buff *skb, const struct tc_action *a,switch (p->tcfm_action) {case TCA_MPLS_ACT_POP : -if (skb_mpls_pop (skb, p->tcfm_proto, mac_len)) +if (skb_mpls_pop (skb, p->tcfm_proto, mac_len, + (skb->dev && skb->dev->type ==ARPHRD_ETHER ))) goto drop;break ;case TCA_MPLS_ACT_PUSH : --1.8.3.1
Quoted 8 lines · Martin Varghese
Quoted 8 lines
Quoted 7 lines
Changes in v2:
- check for dev type removed while updating ethertype in functionskb_mpls_pop.
-key->mac_protois checked in functionpop_mplsto pass ethernt flag toskb_mpls_pop.
- dev type is checked in functiontcf_mpls_actto pass ethernet flag toskb_mpls_pop.
Quoted 4 lines
Quoted 2 lines
nit: changelog can be kept in the commit message for netdev patches
Multiple versions are mostly due to coding error.do you insist to keep the change log in commit message ?
Not really, just a minor suggestion.