History

net: sched: add mpls manipulation actions to TC

Currently, TC offers the ability to match on the MPLS fields of a packet through the use of the flow_dissector_key_mpls struct. However, as yet, TC actions do not allow the modification or manipulation of such fields. Add a new module that registers TC action ops to allow manipulation of MPLS. This includes the ability to push and pop headers as well as modify the contents of new or existing headers. A further action to decrement the TTL field of an MPLS header is also provided with a new helper added to support this. Examples of the usage of the new action with flower rules to push and pop MPLS labels are: tc filter add dev eth0 protocol ip parent ffff: flower \ action mpls push protocol mpls_uc label 123 \ action mirred egress redirect dev eth1 tc filter add dev eth0 protocol mpls_uc parent ffff: flower \ action mpls pop protocol ipv4 \ action mirred egress redirect dev eth1

John Hurley committed 7 years ago

Commit 2a2ea501 parent d27cf5c8 files · +514 −1Browse files

Showing the changes to include/uapi/linux (2 of 8 files). Show all

Unified · Split

2 files
  1. include/uapi/linux/pkt_cls.h +2 −1
  2. include/uapi/linux/tc_act/tc_mpls.h +33 −0
include/uapi/linux/pkt_cls.h+2−1
@@ -104,8 +104,9 @@ enum tca_id { · 103 unmodified lines
104 TCA_ID_SIMP = TCA_ACT_SIMP,104 TCA_ID_SIMP = TCA_ACT_SIMP,
105 TCA_ID_IFE = TCA_ACT_IFE,105 TCA_ID_IFE = TCA_ACT_IFE,
106 TCA_ID_SAMPLE = TCA_ACT_SAMPLE,106 TCA_ID_SAMPLE = TCA_ACT_SAMPLE,
107 /* other actions go here */
108 TCA_ID_CTINFO,107 TCA_ID_CTINFO,
108 TCA_ID_MPLS,
109 /* other actions go here */
109 __TCA_ID_MAX = 255110 __TCA_ID_MAX = 255
110};111};
111 112
include/uapi/linux/tc_act/tc_mpls.h+33−0
@@ -0,0 +1,33 @@
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2/* Copyright (C) 2019 Netronome Systems, Inc. */
3
4#ifndef __LINUX_TC_MPLS_H
5#define __LINUX_TC_MPLS_H
6
7#include <linux/pkt_cls.h>
8
9#define TCA_MPLS_ACT_POP 1
10#define TCA_MPLS_ACT_PUSH 2
11#define TCA_MPLS_ACT_MODIFY 3
12#define TCA_MPLS_ACT_DEC_TTL 4
13
14struct tc_mpls {
15 tc_gen; /* generic TC action fields. */
16 int m_action; /* action of type TCA_MPLS_ACT_*. */
17};
18
19enum {
20 TCA_MPLS_UNSPEC,
21 TCA_MPLS_TM, /* struct tcf_t; time values associated with action. */
22 TCA_MPLS_PARMS, /* struct tc_mpls; action type and general TC fields. */
23 TCA_MPLS_PAD,
24 TCA_MPLS_PROTO, /* be16; eth_type of pushed or next (for pop) header. */
25 TCA_MPLS_LABEL, /* u32; MPLS label. Lower 20 bits are used. */
26 TCA_MPLS_TC, /* u8; MPLS TC field. Lower 3 bits are used. */
27 TCA_MPLS_TTL, /* u8; MPLS TTL field. Must not be 0. */
28 TCA_MPLS_BOS, /* u8; MPLS BOS field. Either 1 or 0. */
29 __TCA_MPLS_MAX,
30};
31#define TCA_MPLS_MAX (__TCA_MPLS_MAX - 1)
32
33#endif