|
|
36cfb7 |
From 738c49477eb843b37cb799115e5b562303bfcd9e Mon Sep 17 00:00:00 2001
|
|
|
36cfb7 |
From: Phil Sutter <psutter@redhat.com>
|
|
|
36cfb7 |
Date: Wed, 6 Feb 2019 14:51:12 +0100
|
|
|
36cfb7 |
Subject: [PATCH] tc/flower: Add match on encapsulating tos/ttl
|
|
|
36cfb7 |
|
|
|
36cfb7 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1641909
|
|
|
36cfb7 |
Upstream Status: iproute2.git commit 761ec9e29ff86
|
|
|
36cfb7 |
Conflicts: Adjusted code to missing commit e28b88a464c49
|
|
|
36cfb7 |
("tc: jsonify flower filter").
|
|
|
36cfb7 |
|
|
|
36cfb7 |
commit 761ec9e29ff867452057f59dc6ca430688b409ea
|
|
|
36cfb7 |
Author: Or Gerlitz <ogerlitz@mellanox.com>
|
|
|
36cfb7 |
Date: Thu Jul 19 14:02:15 2018 +0300
|
|
|
36cfb7 |
|
|
|
36cfb7 |
tc/flower: Add match on encapsulating tos/ttl
|
|
|
36cfb7 |
|
|
|
36cfb7 |
Add matching on tos/ttl of the IP tunnel headers.
|
|
|
36cfb7 |
|
|
|
36cfb7 |
For example, here's decap rule that matches on the tunnel tos:
|
|
|
36cfb7 |
|
|
|
36cfb7 |
tc filter add dev vxlan_sys_4789 protocol ip parent ffff: prio 10 flower \
|
|
|
36cfb7 |
enc_src_ip 192.168.10.2 enc_dst_ip 192.168.10.1 enc_key_id 100 enc_dst_port 4789 enc_tos 0x30 \
|
|
|
36cfb7 |
src_mac e4:11:22:33:44:70 dst_mac e4:11:22:33:44:50 \
|
|
|
36cfb7 |
action tunnel_key unset \
|
|
|
36cfb7 |
action mirred egress redirect dev eth0_0
|
|
|
36cfb7 |
|
|
|
36cfb7 |
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
|
|
|
36cfb7 |
Reviewed-by: Roi Dayan <roid@mellanox.com>
|
|
|
36cfb7 |
Acked-by: Jiri Pirko <jiri@mellanox.com>
|
|
|
36cfb7 |
Signed-off-by: David Ahern <dsahern@gmail.com>
|
|
|
36cfb7 |
---
|
|
|
36cfb7 |
man/man8/tc-flower.8 | 14 +++++++++++++-
|
|
|
36cfb7 |
tc/f_flower.c | 27 +++++++++++++++++++++++++++
|
|
|
36cfb7 |
2 files changed, 40 insertions(+), 1 deletion(-)
|
|
|
36cfb7 |
|
|
|
36cfb7 |
diff --git a/man/man8/tc-flower.8 b/man/man8/tc-flower.8
|
|
|
e138d9 |
index be46f0278b4ff..af19708d9649e 100644
|
|
|
36cfb7 |
--- a/man/man8/tc-flower.8
|
|
|
36cfb7 |
+++ b/man/man8/tc-flower.8
|
|
|
36cfb7 |
@@ -57,6 +57,10 @@ flower \- flow based traffic control filter
|
|
|
36cfb7 |
.IR ipv4_address " | " ipv6_address " } | "
|
|
|
36cfb7 |
.B enc_dst_port
|
|
|
36cfb7 |
.IR port_number " | "
|
|
|
36cfb7 |
+.B enc_tos
|
|
|
36cfb7 |
+.IR TOS " | "
|
|
|
36cfb7 |
+.B enc_ttl
|
|
|
36cfb7 |
+.IR TTL " | "
|
|
|
36cfb7 |
.BR ip_flags
|
|
|
36cfb7 |
.IR IP_FLAGS
|
|
|
36cfb7 |
.SH DESCRIPTION
|
|
|
36cfb7 |
@@ -207,6 +211,10 @@ bits is assumed.
|
|
|
36cfb7 |
.BI enc_src_ip " PREFIX"
|
|
|
36cfb7 |
.TQ
|
|
|
36cfb7 |
.BI enc_dst_port " NUMBER"
|
|
|
36cfb7 |
+.TQ
|
|
|
36cfb7 |
+.BI enc_tos " NUMBER"
|
|
|
36cfb7 |
+.TQ
|
|
|
36cfb7 |
+.BI enc_ttl " NUMBER"
|
|
|
36cfb7 |
Match on IP tunnel metadata. Key id
|
|
|
36cfb7 |
.I NUMBER
|
|
|
36cfb7 |
is a 32 bit tunnel key id (e.g. VNI for VXLAN tunnel).
|
|
|
36cfb7 |
@@ -215,7 +223,11 @@ must be a valid IPv4 or IPv6 address optionally followed by a slash and the
|
|
|
36cfb7 |
prefix length. If the prefix is missing, \fBtc\fR assumes a full-length
|
|
|
36cfb7 |
host match. Dst port
|
|
|
36cfb7 |
.I NUMBER
|
|
|
36cfb7 |
-is a 16 bit UDP dst port.
|
|
|
36cfb7 |
+is a 16 bit UDP dst port. Tos
|
|
|
36cfb7 |
+.I NUMBER
|
|
|
36cfb7 |
+is an 8 bit tos (dscp+ecn) value, ttl
|
|
|
36cfb7 |
+.I NUMBER
|
|
|
36cfb7 |
+is an 8 bit time-to-live value.
|
|
|
36cfb7 |
.TP
|
|
|
36cfb7 |
.BI ip_flags " IP_FLAGS"
|
|
|
36cfb7 |
.I IP_FLAGS
|
|
|
36cfb7 |
diff --git a/tc/f_flower.c b/tc/f_flower.c
|
|
|
e138d9 |
index 5be693ab7f6af..5f5236ca523f8 100644
|
|
|
36cfb7 |
--- a/tc/f_flower.c
|
|
|
36cfb7 |
+++ b/tc/f_flower.c
|
|
|
36cfb7 |
@@ -70,6 +70,8 @@ static void explain(void)
|
|
|
36cfb7 |
" enc_dst_ip [ IPV4-ADDR | IPV6-ADDR ] |\n"
|
|
|
36cfb7 |
" enc_src_ip [ IPV4-ADDR | IPV6-ADDR ] |\n"
|
|
|
36cfb7 |
" enc_key_id [ KEY-ID ] |\n"
|
|
|
36cfb7 |
+ " enc_tos MASKED-IP_TOS |\n"
|
|
|
36cfb7 |
+ " enc_ttl MASKED-IP_TTL |\n"
|
|
|
36cfb7 |
" ip_flags IP-FLAGS | \n"
|
|
|
36cfb7 |
" enc_dst_port [ port_number ] }\n"
|
|
|
36cfb7 |
" FILTERID := X:Y:Z\n"
|
|
|
36cfb7 |
@@ -883,6 +885,26 @@ static int flower_parse_opt(struct filter_util *qu, char *handle,
|
|
|
36cfb7 |
fprintf(stderr, "Illegal \"enc_dst_port\"\n");
|
|
|
36cfb7 |
return -1;
|
|
|
36cfb7 |
}
|
|
|
36cfb7 |
+ } else if (matches(*argv, "enc_tos") == 0) {
|
|
|
36cfb7 |
+ NEXT_ARG();
|
|
|
36cfb7 |
+ ret = flower_parse_ip_tos_ttl(*argv,
|
|
|
36cfb7 |
+ TCA_FLOWER_KEY_ENC_IP_TOS,
|
|
|
36cfb7 |
+ TCA_FLOWER_KEY_ENC_IP_TOS_MASK,
|
|
|
36cfb7 |
+ n);
|
|
|
36cfb7 |
+ if (ret < 0) {
|
|
|
36cfb7 |
+ fprintf(stderr, "Illegal \"enc_tos\"\n");
|
|
|
36cfb7 |
+ return -1;
|
|
|
36cfb7 |
+ }
|
|
|
36cfb7 |
+ } else if (matches(*argv, "enc_ttl") == 0) {
|
|
|
36cfb7 |
+ NEXT_ARG();
|
|
|
36cfb7 |
+ ret = flower_parse_ip_tos_ttl(*argv,
|
|
|
36cfb7 |
+ TCA_FLOWER_KEY_ENC_IP_TTL,
|
|
|
36cfb7 |
+ TCA_FLOWER_KEY_ENC_IP_TTL_MASK,
|
|
|
36cfb7 |
+ n);
|
|
|
36cfb7 |
+ if (ret < 0) {
|
|
|
36cfb7 |
+ fprintf(stderr, "Illegal \"enc_ttl\"\n");
|
|
|
36cfb7 |
+ return -1;
|
|
|
36cfb7 |
+ }
|
|
|
36cfb7 |
} else if (matches(*argv, "action") == 0) {
|
|
|
36cfb7 |
NEXT_ARG();
|
|
|
36cfb7 |
ret = parse_action(&argc, &argv, TCA_FLOWER_ACT, n);
|
|
|
36cfb7 |
@@ -1296,6 +1318,11 @@ static int flower_print_opt(struct filter_util *qu, FILE *f,
|
|
|
36cfb7 |
flower_print_port(f, "enc_dst_port",
|
|
|
36cfb7 |
tb[TCA_FLOWER_KEY_ENC_UDP_DST_PORT]);
|
|
|
36cfb7 |
|
|
|
36cfb7 |
+ flower_print_ip_attr(f, "enc_tos", tb[TCA_FLOWER_KEY_ENC_IP_TOS],
|
|
|
36cfb7 |
+ tb[TCA_FLOWER_KEY_ENC_IP_TOS_MASK]);
|
|
|
36cfb7 |
+ flower_print_ip_attr(f, "enc_ttl", tb[TCA_FLOWER_KEY_ENC_IP_TTL],
|
|
|
36cfb7 |
+ tb[TCA_FLOWER_KEY_ENC_IP_TTL_MASK]);
|
|
|
36cfb7 |
+
|
|
|
36cfb7 |
flower_print_matching_flags(f, "ip_flags",
|
|
|
36cfb7 |
FLOWER_IP_FLAGS,
|
|
|
36cfb7 |
tb[TCA_FLOWER_KEY_FLAGS],
|
|
|
36cfb7 |
--
|
|
|
e138d9 |
2.21.0
|
|
|
36cfb7 |
|