Skip to content

Commit 37f523a

Browse files
Martin Varghesegregkh
authored andcommitted
Fixed updating of ethertype in function skb_mpls_pop
[ Upstream commit 040b5cf ] 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 Fixes: ed246ce ("net: core: move pop MPLS functionality from OvS to core helper") Signed-off-by: Martin Varghese <martin.varghese@nokia.com> Acked-by: Pravin B Shelar <pshelar@ovn.org> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 338ac29 commit 37f523a

4 files changed

Lines changed: 11 additions & 5 deletions

File tree

‎include/linux/skbuff.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3483,7 +3483,8 @@ int skb_vlan_pop(struct sk_buff *skb);
34833483
int skb_vlan_push(struct sk_buff *skb, __be16 vlan_proto, u16 vlan_tci);
34843484
int skb_mpls_push(struct sk_buff *skb, __be32 mpls_lse, __be16 mpls_proto,
34853485
int mac_len);
3486-
int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto, int mac_len);
3486+
int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto, int mac_len,
3487+
bool ethernet);
34873488
int skb_mpls_update_lse(struct sk_buff *skb, __be32 mpls_lse);
34883489
int skb_mpls_dec_ttl(struct sk_buff *skb);
34893490
struct sk_buff *pskb_extract(struct sk_buff *skb, int off, int to_copy,

‎net/core/skbuff.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5517,12 +5517,14 @@ EXPORT_SYMBOL_GPL(skb_mpls_push);
55175517
* @skb: buffer
55185518
* @next_proto: ethertype of header after popped MPLS header
55195519
* @mac_len: length of the MAC header
5520+
* @ethernet: flag to indicate if ethernet header is present in packet
55205521
*
55215522
* Expects skb->data at mac header.
55225523
*
55235524
* Returns 0 on success, -errno otherwise.
55245525
*/
5525-
int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto, int mac_len)
5526+
int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto, int mac_len,
5527+
bool ethernet)
55265528
{
55275529
int err;
55285530

@@ -5541,7 +5543,7 @@ int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto, int mac_len)
55415543
skb_reset_mac_header(skb);
55425544
skb_set_network_header(skb, mac_len);
55435545

5544-
if (skb->dev && skb->dev->type == ARPHRD_ETHER) {
5546+
if (ethernet) {
55455547
struct ethhdr *hdr;
55465548

55475549
/* use mpls_hdr() to get ethertype to account for VLANs. */

‎net/openvswitch/actions.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ static int pop_mpls(struct sk_buff *skb, struct sw_flow_key *key,
179179
{
180180
int err;
181181

182-
err = skb_mpls_pop(skb, ethertype, skb->mac_len);
182+
err = skb_mpls_pop(skb, ethertype, skb->mac_len,
183+
ovs_key_mac_proto(key) == MAC_PROTO_ETHERNET);
183184
if (err)
184185
return err;
185186

‎net/sched/act_mpls.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
22
/* Copyright (C) 2019 Netronome Systems, Inc. */
33

4+
#include <linux/if_arp.h>
45
#include <linux/init.h>
56
#include <linux/kernel.h>
67
#include <linux/module.h>
@@ -76,7 +77,8 @@ static int tcf_mpls_act(struct sk_buff *skb, const struct tc_action *a,
7677

7778
switch (p->tcfm_action) {
7879
case TCA_MPLS_ACT_POP:
79-
if (skb_mpls_pop(skb, p->tcfm_proto, mac_len))
80+
if (skb_mpls_pop(skb, p->tcfm_proto, mac_len,
81+
skb->dev && skb->dev->type == ARPHRD_ETHER))
8082
goto drop;
8183
break;
8284
case TCA_MPLS_ACT_PUSH:

0 commit comments

Comments
 (0)