net: sched: support vxlan and erspan options
Subsystems (3)
v2 cover net: sched: support vxlan and erspan options
This patchset is to add vxlan and erspan options support in cls_flower and act_tunnel_key. The form is pretty much like geneve_opts in:
https://patchwork.ozlabs.org/patch/935272/
https://patchwork.ozlabs.org/patch/954564/
but only one option is allowed for vxlan and erspan.
v1->v2:
- see each patch changelog.
Xin Long (4):
net: sched: add vxlan option support to act_tunnel_key
net: sched: add erspan option support to act_tunnel_key
net: sched: allow flower to match vxlan options
net: sched: allow flower to match erspan options
include/uapi/linux/pkt_cls.h | 29 ++++ include/uapi/linux/tc_act/tc_tunnel_key.h | 29 ++++ net/sched/act_tunnel_key.c | 203 +++++++++++++++++++++++- net/sched/cls_flower.c | 254 ++++++++++++++++++++++++++++++ 4 files changed, 514 insertions(+), 1 deletion(-)
Signature · 1 line
2.1.0
PATCH v2 1/4 net: sched: add vxlan option support to act_tunnel_key
This patch is to allow setting vxlan options using the act_tunnel_key action. Different from geneve options, only one option can be set. And also, geneve options and vxlan options can't be set at the same time.
gbp is the only param for vxlan options:
# ip link add name vxlan0 type vxlan dstport 0 external
# tc qdisc add dev eth0 ingress
# tc filter add dev eth0 protocol ip parent ffff: \
flower indev eth0 \
ip_proto udp \
action tunnel_key \
set src_ip 10.0.99.192 \
dst_ip 10.0.99.193 \
dst_port 6081 \
id 11 \
vxlan_opts 01020304 \
action mirred egress redirect dev vxlan0v1->v2:
- add .strict_start_type for enc_opts_policy as Jakub noticed.
- use Duplicate instead of Wrong in err msg for extack as Jakub suggested.
--- include/uapi/linux/tc_act/tc_tunnel_key.h | 13 +++++ net/sched/act_tunnel_key.c | 85 ++++++++++++++++++++++++++++++- 2 files changed, 97 insertions(+), 1 deletion(-)
include/uapi/linux/tc_act/tc_tunnel_key.h +13 -0
@@ -50,6 +50,10 @@ enum {* TCA_TUNNEL_KEY_ENC_OPTS_ * attributes */ +TCA_TUNNEL_KEY_ENC_OPTS_VXLAN ,/* Nested +* TCA_TUNNEL_KEY_ENC_OPTS_ +* attributes +*/ __TCA_TUNNEL_KEY_ENC_OPTS_MAX, };
@@ -67,4 +71,13 @@ enum {#define TCA_TUNNEL_KEY_ENC_OPT_GENEVE_MAX \ (__TCA_TUNNEL_KEY_ENC_OPT_GENEVE_MAX - 1) +enum { +TCA_TUNNEL_KEY_ENC_OPT_VXLAN_UNSPEC , +TCA_TUNNEL_KEY_ENC_OPT_VXLAN_GBP ,/* u32 */ + __TCA_TUNNEL_KEY_ENC_OPT_VXLAN_MAX, +}; + +#define TCA_TUNNEL_KEY_ENC_OPT_VXLAN_MAX \ + (__TCA_TUNNEL_KEY_ENC_OPT_VXLAN_MAX - 1) +#endif
net/sched/act_tunnel_key.c +84 -1
143 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH v2 2/4 net: sched: add erspan option support to act_tunnel_key
This patch is to allow setting erspan options using the act_tunnel_key action. Different from geneve options, only one option can be set. And also, geneve options, vxlan options or erspan options can't be set at the same time.
Options are expressed as ver:index:dir:hwid, when ver is set to 1, index will be applied while dir and hwid will be ignored, and when ver is set to 2, dir and hwid will be used while index will be ignored.
# ip link add name erspan1 type erspan external
# tc qdisc add dev eth0 ingress
# tc filter add dev eth0 protocol ip parent ffff: \
flower indev eth0 \
ip_proto udp \
action tunnel_key \
set src_ip 10.0.99.192 \
dst_ip 10.0.99.193 \
dst_port 6081 \
id 11 \
erspan_opts 1:2:0:0 \
action mirred egress redirect dev erspan1v1->v2:
- do the validation when dst is not yet allocated as Jakub suggested.
- use Duplicate instead of Wrong in err msg for extack.
--- include/uapi/linux/tc_act/tc_tunnel_key.h | 16 ++++ net/sched/act_tunnel_key.c | 118 ++++++++++++++++++++++++++++++ 2 files changed, 134 insertions(+)
include/uapi/linux/tc_act/tc_tunnel_key.h +16 -0
@@ -54,6 +54,10 @@ enum {* TCA_TUNNEL_KEY_ENC_OPTS_ * attributes */ +TCA_TUNNEL_KEY_ENC_OPTS_ERSPAN ,/* Nested +* TCA_TUNNEL_KEY_ENC_OPTS_ +* attributes +*/ __TCA_TUNNEL_KEY_ENC_OPTS_MAX, };
@@ -80,4 +84,16 @@ enum {#define TCA_TUNNEL_KEY_ENC_OPT_VXLAN_MAX \ (__TCA_TUNNEL_KEY_ENC_OPT_VXLAN_MAX - 1) +enum { +TCA_TUNNEL_KEY_ENC_OPT_ERSPAN_UNSPEC , +TCA_TUNNEL_KEY_ENC_OPT_ERSPAN_VER ,/* u8 */ +TCA_TUNNEL_KEY_ENC_OPT_ERSPAN_INDEX ,/* be32 */ +TCA_TUNNEL_KEY_ENC_OPT_ERSPAN_DIR ,/* u8 */ +TCA_TUNNEL_KEY_ENC_OPT_ERSPAN_HWID ,/* u8 */ + __TCA_TUNNEL_KEY_ENC_OPT_ERSPAN_MAX, +}; + +#define TCA_TUNNEL_KEY_ENC_OPT_ERSPAN_MAX \ + (__TCA_TUNNEL_KEY_ENC_OPT_ERSPAN_MAX - 1) +#endif
net/sched/act_tunnel_key.c +118 -0
166 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH v2 3/4 net: sched: allow flower to match vxlan options
This patch is to allow matching gbp option in vxlan.
The options can be described in the form GBP/GBP_MASK, where GBP is represented as a 32bit hexadecimal value. Different from geneve, only one option can be set. And also, geneve options and vxlan options can't be set at the same time.
# ip link add name vxlan0 type vxlan dstport 0 external
# tc qdisc add dev vxlan0 ingress
# tc filter add dev vxlan0 protocol ip parent ffff: \
flower \
enc_src_ip 10.0.99.192 \
enc_dst_ip 10.0.99.193 \
enc_key_id 11 \
vxlan_opts 01020304/ffffffff \
ip_proto udp \
action mirred egress redirect dev eth0v1->v2:
- add .strict_start_type for enc_opts_policy as Jakub noticed.
- use Duplicate instead of Wrong in err msg for extack as Jakub suggested.
--- include/uapi/linux/pkt_cls.h | 13 ++++++ net/sched/cls_flower.c | 109 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+)
include/uapi/linux/pkt_cls.h +13 -0
@@ -571,6 +571,10 @@ enum {* TCA_FLOWER_KEY_ENC_OPT_GENEVE_ * attributes */ +TCA_FLOWER_KEY_ENC_OPTS_VXLAN ,/* Nested +* TCA_FLOWER_KEY_ENC_OPT_VXLAN_ +* attributes +*/ __TCA_FLOWER_KEY_ENC_OPTS_MAX, };
@@ -589,6 +593,15 @@ enum { (__TCA_FLOWER_KEY_ENC_OPT_GENEVE_MAX - 1)enum { +TCA_FLOWER_KEY_ENC_OPT_VXLAN_UNSPEC , +TCA_FLOWER_KEY_ENC_OPT_VXLAN_GBP ,/* u32 */ + __TCA_FLOWER_KEY_ENC_OPT_VXLAN_MAX, +}; + +#define TCA_FLOWER_KEY_ENC_OPT_VXLAN_MAX \ + (__TCA_FLOWER_KEY_ENC_OPT_VXLAN_MAX - 1) + +enum {TCA_FLOWER_KEY_FLAGS_IS_FRAGMENT = (1 <<0 ),TCA_FLOWER_KEY_FLAGS_FRAG_IS_FIRST = (1 <<1 ), };
net/sched/cls_flower.c +109 -0
158 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH v2 4/4 net: sched: allow flower to match erspan options
This patch is to allow matching options in erspan.
The options can be described in the form:
VER:INDEX:DIR:HWID/VER:INDEX_MASK:DIR_MASK:HWID_MASK. When ver is set to 1, index will be applied while dir and hwid will be ignored, and when ver is set to 2, dir and hwid will be used while index will be ignored.
Different from geneve, only one option can be set. And also, geneve options, vxlan options or erspan options can't be set at the same time.
# ip link add name erspan1 type erspan external
# tc qdisc add dev erspan1 ingress
# tc filter add dev erspan1 protocol ip parent ffff: \
flower \
enc_src_ip 10.0.99.192 \
enc_dst_ip 10.0.99.193 \
enc_key_id 11 \
erspan_opts 1:12:0:0/1:ffff:0:0 \
ip_proto udp \
action mirred egress redirect dev eth0v1->v2:
- improve some err msgs of extack.
--- include/uapi/linux/pkt_cls.h | 16 +++++ net/sched/cls_flower.c | 145 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 161 insertions(+)
include/uapi/linux/pkt_cls.h +16 -0
@@ -575,6 +575,10 @@ enum {* TCA_FLOWER_KEY_ENC_OPT_VXLAN_ * attributes */ +TCA_FLOWER_KEY_ENC_OPTS_ERSPAN ,/* Nested +* TCA_FLOWER_KEY_ENC_OPT_ERSPAN_ +* attributes +*/ __TCA_FLOWER_KEY_ENC_OPTS_MAX, };
@@ -602,6 +606,18 @@ enum { (__TCA_FLOWER_KEY_ENC_OPT_VXLAN_MAX - 1)enum { +TCA_FLOWER_KEY_ENC_OPT_ERSPAN_UNSPEC , +TCA_FLOWER_KEY_ENC_OPT_ERSPAN_VER ,/* u8 */ +TCA_FLOWER_KEY_ENC_OPT_ERSPAN_INDEX ,/* be32 */ +TCA_FLOWER_KEY_ENC_OPT_ERSPAN_DIR ,/* u8 */ +TCA_FLOWER_KEY_ENC_OPT_ERSPAN_HWID ,/* u8 */ + __TCA_FLOWER_KEY_ENC_OPT_ERSPAN_MAX, +}; + +#define TCA_FLOWER_KEY_ENC_OPT_ERSPAN_MAX \ + (__TCA_FLOWER_KEY_ENC_OPT_ERSPAN_MAX - 1) + +enum {TCA_FLOWER_KEY_FLAGS_IS_FRAGMENT = (1 <<0 ),TCA_FLOWER_KEY_FLAGS_FRAG_IS_FIRST = (1 <<1 ), };
net/sched/cls_flower.c +145 -0
187 lines not on this page · raw message
Signature · 1 line
2.1.0
Quoted 8 lines · Xin Long
This patchset is to add vxlan and erspan options support in
cls_flowerandact_tunnel_key. The form is pretty much likegeneve_optsin:https://patchwork.ozlabs.org/patch/935272/
https://patchwork.ozlabs.org/patch/954564/but only one option is allowed for vxlan and erspan.
I have only cursory understanding of the flower parts, but looks good to me:
David Miller
maintainerFrom: Xin Long <[email protected]>
Date: Thu, 21 Nov 2019 18:03:25 +0800
Quoted 11 lines
This patchset is to add vxlan and erspan options support in
cls_flowerandact_tunnel_key. The form is pretty much likegeneve_optsin:https://patchwork.ozlabs.org/patch/935272/
https://patchwork.ozlabs.org/patch/954564/but only one option is allowed for vxlan and erspan.
v1->v2:
- see each patch changelog.
Series applied.