Comments

In the case where a non-MPLS packet is recieved and an MPLS stack is
added it may well be the case that the original skb is GSO but the
NIC used for transmit does not support GSO of MPLS packets.
The aim of this code is to provide GSO in software for MPLS packets
whose skbs are GSO.
When an implementation adds an MPLS stack to a non-MPLS packet it should do
the following to skb metadata:
* Set skb_mac_header(skb)->protocol to the new MPLS ethertype.
That is, either ETH_P_MPLS_UC or ETH_P_MPLS_MC.
* Leave skb->protocol as the old non-MPLS ethertype.
* Set skb->encapsulation = 1.
This may not strictly be necessary as I believe that checking
skb_mac_header(skb)->protocol and skb->protocol should be necessary and
sufficient.
However, it does seem to fit nicely with the current implementation of
dev_hard_start_xmit() where the more expensive check of
skb_mac_header(skb)->protocol may be guarded by an existing check of
skb->encapsulation.
One aspect of this patch that I am unsure about is the modification I have
made to skb_segment(). This seems to be necessary as checskum accelearation
may no longer be possible as the packet has changed to be MPLS from some
other packet type which may have been supported by the hardware in use.
I will post a patch, "[PATCH v3.24] datapath: Add basic MPLS support to
kernel" which adds MPLS support to the kernel datapath of Open vSwtich.
That patch sets the above requirements in
datapath/actions.c:set_ethertype() and was used to exercise the MPLS GSO
code. The datapath patch is against the Open vSwtich tree but it is
intended that it be added to the Open vSwtich code present in the mainline
Linux kernel at some point.
Suggested by Jesse Gross. Based heavily on "v4 GRE: Add TCP segmentation
offload for GRE" by Pravin B Shelar.
Cc: Jesse Gross <jesse@nicira.com>
Cc: Pravin B Shelar <pshelar@nicira.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
---
include/linux/netdev_features.h | 2 +
include/linux/skbuff.h | 15 +++--
net/Kconfig | 1 +
net/Makefile | 1 +
net/core/dev.c | 9 ++-
net/core/ethtool.c | 1 +
net/core/skbuff.c | 3 +-
net/ipv4/af_inet.c | 1 +
net/ipv4/tcp.c | 1 +
net/ipv4/udp.c | 2 +-
net/ipv6/ip6_offload.c | 1 +
net/ipv6/udp_offload.c | 3 +-
net/mpls/Kconfig | 9 +++
net/mpls/Makefile | 4 ++
net/mpls/mpls_gso.c | 125 +++++++++++++++++++++++++++++++++++++++
15 files changed, 170 insertions(+), 8 deletions(-)
create mode 100644 net/mpls/Kconfig
create mode 100644 net/mpls/Makefile
create mode 100644 net/mpls/mpls_gso.c