forked from Freescale/linux-fslc
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 Signed-off-by: John Hurley <[email protected]> Reviewed-by: Jakub Kicinski <[email protected]> Reviewed-by: Simon Horman <[email protected]> Reviewed-by: Willem de Bruijn <[email protected]> Acked-by: Cong Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
- Loading branch information
Showing
8 changed files
with
514 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ | ||
/* Copyright (C) 2019 Netronome Systems, Inc. */ | ||
|
||
#ifndef __NET_TC_MPLS_H | ||
#define __NET_TC_MPLS_H | ||
|
||
#include <linux/tc_act/tc_mpls.h> | ||
#include <net/act_api.h> | ||
|
||
struct tcf_mpls_params { | ||
int tcfm_action; | ||
u32 tcfm_label; | ||
u8 tcfm_tc; | ||
u8 tcfm_ttl; | ||
u8 tcfm_bos; | ||
__be16 tcfm_proto; | ||
struct rcu_head rcu; | ||
}; | ||
|
||
#define ACT_MPLS_TC_NOT_SET 0xff | ||
#define ACT_MPLS_BOS_NOT_SET 0xff | ||
#define ACT_MPLS_LABEL_NOT_SET 0xffffffff | ||
|
||
struct tcf_mpls { | ||
struct tc_action common; | ||
struct tcf_mpls_params __rcu *mpls_p; | ||
}; | ||
#define to_mpls(a) ((struct tcf_mpls *)a) | ||
|
||
#endif /* __NET_TC_MPLS_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | ||
/* Copyright (C) 2019 Netronome Systems, Inc. */ | ||
|
||
#ifndef __LINUX_TC_MPLS_H | ||
#define __LINUX_TC_MPLS_H | ||
|
||
#include <linux/pkt_cls.h> | ||
|
||
#define TCA_MPLS_ACT_POP 1 | ||
#define TCA_MPLS_ACT_PUSH 2 | ||
#define TCA_MPLS_ACT_MODIFY 3 | ||
#define TCA_MPLS_ACT_DEC_TTL 4 | ||
|
||
struct tc_mpls { | ||
tc_gen; /* generic TC action fields. */ | ||
int m_action; /* action of type TCA_MPLS_ACT_*. */ | ||
}; | ||
|
||
enum { | ||
TCA_MPLS_UNSPEC, | ||
TCA_MPLS_TM, /* struct tcf_t; time values associated with action. */ | ||
TCA_MPLS_PARMS, /* struct tc_mpls; action type and general TC fields. */ | ||
TCA_MPLS_PAD, | ||
TCA_MPLS_PROTO, /* be16; eth_type of pushed or next (for pop) header. */ | ||
TCA_MPLS_LABEL, /* u32; MPLS label. Lower 20 bits are used. */ | ||
TCA_MPLS_TC, /* u8; MPLS TC field. Lower 3 bits are used. */ | ||
TCA_MPLS_TTL, /* u8; MPLS TTL field. Must not be 0. */ | ||
TCA_MPLS_BOS, /* u8; MPLS BOS field. Either 1 or 0. */ | ||
__TCA_MPLS_MAX, | ||
}; | ||
#define TCA_MPLS_MAX (__TCA_MPLS_MAX - 1) | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.