Skip to content

Commit a45294a

Browse files
Guillaume Naultdavem330
authored andcommitted
net/sched: act_mpls: Add action to push MPLS LSE before Ethernet header
Define the MAC_PUSH action which pushes an MPLS LSE before the mac header (instead of between the mac and the network headers as the plain PUSH action does). The only special case is when the skb has an offloaded VLAN. In that case, it has to be inlined before pushing the MPLS header. Signed-off-by: Guillaume Nault <gnault@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 19fbcb3 commit a45294a

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

‎include/uapi/linux/tc_act/tc_mpls.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define TCA_MPLS_ACT_PUSH 2
1111
#define TCA_MPLS_ACT_MODIFY 3
1212
#define TCA_MPLS_ACT_DEC_TTL 4
13+
#define TCA_MPLS_ACT_MAC_PUSH 5
1314

1415
struct tc_mpls {
1516
tc_gen; /* generic TC action fields. */

‎net/sched/act_mpls.c‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,23 @@ static int tcf_mpls_act(struct sk_buff *skb, const struct tc_action *a,
8787
skb->dev && skb->dev->type == ARPHRD_ETHER))
8888
goto drop;
8989
break;
90+
case TCA_MPLS_ACT_MAC_PUSH:
91+
if (skb_vlan_tag_present(skb)) {
92+
if (__vlan_insert_inner_tag(skb, skb->vlan_proto,
93+
skb_vlan_tag_get(skb),
94+
ETH_HLEN) < 0)
95+
goto drop;
96+
97+
skb->protocol = skb->vlan_proto;
98+
__vlan_hwaccel_clear_tag(skb);
99+
}
100+
101+
new_lse = tcf_mpls_get_lse(NULL, p, mac_len ||
102+
!eth_p_mpls(skb->protocol));
103+
104+
if (skb_mpls_push(skb, new_lse, p->tcfm_proto, 0, false))
105+
goto drop;
106+
break;
90107
case TCA_MPLS_ACT_MODIFY:
91108
new_lse = tcf_mpls_get_lse(mpls_hdr(skb), p, false);
92109
if (skb_mpls_update_lse(skb, new_lse))
@@ -188,6 +205,7 @@ static int tcf_mpls_init(struct net *net, struct nlattr *nla,
188205
}
189206
break;
190207
case TCA_MPLS_ACT_PUSH:
208+
case TCA_MPLS_ACT_MAC_PUSH:
191209
if (!tb[TCA_MPLS_LABEL]) {
192210
NL_SET_ERR_MSG_MOD(extack, "Label is required for MPLS push");
193211
return -EINVAL;

0 commit comments

Comments
 (0)