net: core: add MPLS update core helper and use in OvS
Open vSwitch allows the updating of an existing MPLS header on a packet. In preparation for supporting similar functionality in TC, move this to a common skb helper function. Signed-off-by: John Hurley <john.hurley@netronome.com> Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com> Reviewed-by: Simon Horman <simon.horman@netronome.com> Reviewed-by: Willem de Bruijn <willemb@google.com> Acked-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
ed246cee09
commit
d27cf5c59a
@@ -193,19 +193,12 @@ static int set_mpls(struct sk_buff *skb, struct sw_flow_key *flow_key,
|
||||
__be32 lse;
|
||||
int err;
|
||||
|
||||
err = skb_ensure_writable(skb, skb->mac_len + MPLS_HLEN);
|
||||
if (unlikely(err))
|
||||
return err;
|
||||
|
||||
stack = mpls_hdr(skb);
|
||||
lse = OVS_MASKED(stack->label_stack_entry, *mpls_lse, *mask);
|
||||
if (skb->ip_summed == CHECKSUM_COMPLETE) {
|
||||
__be32 diff[] = { ~(stack->label_stack_entry), lse };
|
||||
err = skb_mpls_update_lse(skb, lse);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
skb->csum = csum_partial((char *)diff, sizeof(diff), skb->csum);
|
||||
}
|
||||
|
||||
stack->label_stack_entry = lse;
|
||||
flow_key->mpls.top_lse = lse;
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user