Skip to content

Commit d04ac22

Browse files
Martin Varghesedavem330
authored andcommitted
net: Fixed updating of ethertype in skb_mpls_push()
The skb_mpls_push 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_push 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(0x0800),ipv4(tos=0/0xfc,ttl=64,frag=no), actions:push_eth(src=00:00:00:00:00:00,dst=00:00:00:00:00:00), push_mpls(label=13,tc=0,ttl=64,bos=1,eth_type=0x8847),4 Fixes: 8822e27 ("net: core: move push MPLS functionality from OvS to core helper") Signed-off-by: Martin Varghese <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 099ffd7 commit d04ac22

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

include/linux/skbuff.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3529,7 +3529,7 @@ int __skb_vlan_pop(struct sk_buff *skb, u16 *vlan_tci);
35293529
int skb_vlan_pop(struct sk_buff *skb);
35303530
int skb_vlan_push(struct sk_buff *skb, __be16 vlan_proto, u16 vlan_tci);
35313531
int skb_mpls_push(struct sk_buff *skb, __be32 mpls_lse, __be16 mpls_proto,
3532-
int mac_len);
3532+
int mac_len, bool ethernet);
35333533
int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto, int mac_len,
35343534
bool ethernet);
35353535
int skb_mpls_update_lse(struct sk_buff *skb, __be32 mpls_lse);

net/core/skbuff.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5484,7 +5484,7 @@ static void skb_mod_eth_type(struct sk_buff *skb, struct ethhdr *hdr,
54845484
* Returns 0 on success, -errno otherwise.
54855485
*/
54865486
int skb_mpls_push(struct sk_buff *skb, __be32 mpls_lse, __be16 mpls_proto,
5487-
int mac_len)
5487+
int mac_len, bool ethernet)
54885488
{
54895489
struct mpls_shim_hdr *lse;
54905490
int err;
@@ -5515,7 +5515,7 @@ int skb_mpls_push(struct sk_buff *skb, __be32 mpls_lse, __be16 mpls_proto,
55155515
lse->label_stack_entry = mpls_lse;
55165516
skb_postpush_rcsum(skb, lse, MPLS_HLEN);
55175517

5518-
if (skb->dev && skb->dev->type == ARPHRD_ETHER)
5518+
if (ethernet)
55195519
skb_mod_eth_type(skb, eth_hdr(skb), mpls_proto);
55205520
skb->protocol = mpls_proto;
55215521

net/openvswitch/actions.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ static int push_mpls(struct sk_buff *skb, struct sw_flow_key *key,
166166
int err;
167167

168168
err = skb_mpls_push(skb, mpls->mpls_lse, mpls->mpls_ethertype,
169-
skb->mac_len);
169+
skb->mac_len,
170+
ovs_key_mac_proto(key) == MAC_PROTO_ETHERNET);
170171
if (err)
171172
return err;
172173

net/sched/act_mpls.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ static int tcf_mpls_act(struct sk_buff *skb, const struct tc_action *a,
8383
break;
8484
case TCA_MPLS_ACT_PUSH:
8585
new_lse = tcf_mpls_get_lse(NULL, p, !eth_p_mpls(skb->protocol));
86-
if (skb_mpls_push(skb, new_lse, p->tcfm_proto, mac_len))
86+
if (skb_mpls_push(skb, new_lse, p->tcfm_proto, mac_len,
87+
skb->dev && skb->dev->type == ARPHRD_ETHER))
8788
goto drop;
8889
break;
8990
case TCA_MPLS_ACT_MODIFY:

0 commit comments

Comments
 (0)