Commit dedc5a08 authored by Davide Caratti's avatar Davide Caratti Committed by David S. Miller

net: avoid errors when trying to pop MLPS header on non-MPLS packets

the following script:

 # tc qdisc add dev eth0 clsact
 # tc filter add dev eth0 egress matchall action mpls pop

implicitly makes the kernel drop all packets transmitted by eth0, if they
don't have a MPLS header. This behavior is uncommon: other encapsulations
(like VLAN) just let the packet pass unmodified. Since the result of MPLS
'pop' operation would be the same regardless of the presence / absence of
MPLS header(s) in the original packet, we can let skb_mpls_pop() return 0
when dealing with non-MPLS packets.

For the OVS use-case, this is acceptable because __ovs_nla_copy_actions()
already ensures that MPLS 'pop' operation only occurs with packets having
an MPLS Ethernet type (and there are no other callers in current code, so
the semantic change should be ok).

v2: better documentation of use-cases for skb_mpls_pop(), thanks to Simon
    Horman

Fixes: 2a2ea508 ("net: sched: add mpls manipulation actions to TC")
Reviewed-by: default avatarSimon Horman <simon.horman@netronome.com>
Acked-by: default avatarJohn Hurley <john.hurley@netronome.com>
Signed-off-by: default avatarDavide Caratti <dcaratti@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a03681dd
...@@ -5536,7 +5536,7 @@ int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto) ...@@ -5536,7 +5536,7 @@ int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto)
int err; int err;
if (unlikely(!eth_p_mpls(skb->protocol))) if (unlikely(!eth_p_mpls(skb->protocol)))
return -EINVAL; return 0;
err = skb_ensure_writable(skb, skb->mac_len + MPLS_HLEN); err = skb_ensure_writable(skb, skb->mac_len + MPLS_HLEN);
if (unlikely(err)) if (unlikely(err))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment