Commit e7dbfed1 authored by Martin Varghese's avatar Martin Varghese Committed by David S. Miller

net: skb_mpls_push() modified to allow MPLS header push at start of packet.

The existing skb_mpls_push() implementation always inserts mpls header
after the mac header. L2 VPN use cases requires MPLS header to be
inserted before the ethernet header as the ethernet packet gets tunnelled
inside MPLS header in those cases.
Signed-off-by: default avatarMartin Varghese <martin.varghese@nokia.com>
Acked-by: default avatarPravin B Shelar <pshelar@ovn.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ac80010f
...@@ -5472,12 +5472,15 @@ static void skb_mod_eth_type(struct sk_buff *skb, struct ethhdr *hdr, ...@@ -5472,12 +5472,15 @@ static void skb_mod_eth_type(struct sk_buff *skb, struct ethhdr *hdr,
} }
/** /**
* skb_mpls_push() - push a new MPLS header after the mac header * skb_mpls_push() - push a new MPLS header after mac_len bytes from start of
* the packet
* *
* @skb: buffer * @skb: buffer
* @mpls_lse: MPLS label stack entry to push * @mpls_lse: MPLS label stack entry to push
* @mpls_proto: ethertype of the new MPLS header (expects 0x8847 or 0x8848) * @mpls_proto: ethertype of the new MPLS header (expects 0x8847 or 0x8848)
* @mac_len: length of the MAC header * @mac_len: length of the MAC header
* @ethernet: flag to indicate if the resulting packet after skb_mpls_push is
* ethernet
* *
* Expects skb->data at mac header. * Expects skb->data at mac header.
* *
...@@ -5501,7 +5504,7 @@ int skb_mpls_push(struct sk_buff *skb, __be32 mpls_lse, __be16 mpls_proto, ...@@ -5501,7 +5504,7 @@ int skb_mpls_push(struct sk_buff *skb, __be32 mpls_lse, __be16 mpls_proto,
return err; return err;
if (!skb->inner_protocol) { if (!skb->inner_protocol) {
skb_set_inner_network_header(skb, mac_len); skb_set_inner_network_header(skb, skb_network_offset(skb));
skb_set_inner_protocol(skb, skb->protocol); skb_set_inner_protocol(skb, skb->protocol);
} }
...@@ -5510,6 +5513,7 @@ int skb_mpls_push(struct sk_buff *skb, __be32 mpls_lse, __be16 mpls_proto, ...@@ -5510,6 +5513,7 @@ int skb_mpls_push(struct sk_buff *skb, __be32 mpls_lse, __be16 mpls_proto,
mac_len); mac_len);
skb_reset_mac_header(skb); skb_reset_mac_header(skb);
skb_set_network_header(skb, mac_len); skb_set_network_header(skb, mac_len);
skb_reset_mac_len(skb);
lse = mpls_hdr(skb); lse = mpls_hdr(skb);
lse->label_stack_entry = mpls_lse; lse->label_stack_entry = mpls_lse;
......
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