History

Fixed updating of ethertype in function skb_mpls_pop

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

Martin Varghese committed 6 years ago

Commit 040b5cf1 parent b3c424e4 files · +11 −5Browse files

Unified · Split

4 files
  1. include/linux/skbuff.h +2 −1
  2. net/core/skbuff.c +4 −2
  3. net/openvswitch/actions.c +2 −1
  4. net/sched/act_mpls.c +3 −1
include/linux/skbuff.h+2−1
@@ -3530,7 +3530,8 @@ int skb_vlan_pop(struct sk_buff *skb); · 3529 unmodified lines
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,
35323532 int mac_len);
3533−int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto, int mac_len);
3533+int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto, int mac_len,
3534+ bool ethernet);
35343535 int skb_mpls_update_lse(struct sk_buff *skb, __be32 mpls_lse);
35353536 int skb_mpls_dec_ttl(struct sk_buff *skb);
35363537 struct sk_buff *pskb_extract(struct sk_buff *skb, int off, int to_copy,
net/core/skbuff.c+4−2
@@ -5529,12 +5529,14 @@ EXPORT_SYMBOL_GPL(skb_mpls_push); · 5528 unmodified lines
55295529 * @skb: buffer
55305530 * @next_proto: ethertype of header after popped MPLS header
55315531 * @mac_len: length of the MAC header
5532+ * @ethernet: flag to indicate if ethernet header is present in packet
55325533 *
55335534 * Expects skb->data at mac header.
55345535 *
55355536 * Returns 0 on success, -errno otherwise.
55365537 */
5537−int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto, int mac_len)
5538+int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto, int mac_len,
5539+ bool ethernet)
55385540 {
55395541 int err;
55405542
@@ -5553,7 +5555,7 @@ int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto, int mac_len) · 12 unmodified lines
55535555 skb_reset_mac_header(skb);
55545556 skb_set_network_header(skb, mac_len);
55555557
5556− if (skb->dev && skb->dev->type == ARPHRD_ETHER) {
5558+ if (ethernet) {
55575559 struct ethhdr *hdr;
55585560
55595561 /* use mpls_hdr() to get ethertype to account for VLANs. */
net/openvswitch/actions.c+2−1
@@ -179,7 +179,8 @@ static int pop_mpls(struct sk_buff *skb, struct sw_flow_key *key, · 178 unmodified lines
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+3−1
@@ -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, · 69 unmodified lines
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:

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t