OSDN Git Service

net/sched: fix corrupted L2 header with MPLS 'push' and 'pop' actions
authorDavide Caratti <dcaratti@redhat.com>
Sat, 12 Oct 2019 11:55:07 +0000 (13:55 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 16 Oct 2019 00:14:48 +0000 (17:14 -0700)
commitfa4e0f8855fcba600e0be2575ee29c69166f74bd
tree3224a12d0c83472a92df41f3dfff6c48b6fd1f64
parentdedc5a08da07874c6e0d411e7f39c5c2cf137014
net/sched: fix corrupted L2 header with MPLS 'push' and 'pop' actions

the following script:

 # tc qdisc add dev eth0 clsact
 # tc filter add dev eth0 egress protocol ip matchall \
 > action mpls push protocol mpls_uc label 0x355aa bos 1

causes corruption of all IP packets transmitted by eth0. On TC egress, we
can't rely on the value of skb->mac_len, because it's 0 and a MPLS 'push'
operation will result in an overwrite of the first 4 octets in the packet
L2 header (e.g. the Destination Address if eth0 is an Ethernet); the same
error pattern is present also in the MPLS 'pop' operation. Fix this error
in act_mpls data plane, computing 'mac_len' as the difference between the
network header and the mac header (when not at TC ingress), and use it in
MPLS 'push'/'pop' core functions.

v2: unbreak 'make htmldocs' because of missing documentation of 'mac_len'
    in skb_mpls_pop(), reported by kbuild test robot

CC: Lorenzo Bianconi <lorenzo@kernel.org>
Fixes: 2a2ea50870ba ("net: sched: add mpls manipulation actions to TC")
Reviewed-by: Simon Horman <simon.horman@netronome.com>
Acked-by: John Hurley <john.hurley@netronome.com>
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/skbuff.h
net/core/skbuff.c
net/openvswitch/actions.c
net/sched/act_mpls.c