|
|
99be8f |
From 7521695ca299ceb723dc6b17f304b91300b3b16c Mon Sep 17 00:00:00 2001
|
|
|
99be8f |
From: Phil Sutter <psutter@redhat.com>
|
|
|
99be8f |
Date: Wed, 6 Feb 2019 14:51:57 +0100
|
|
|
99be8f |
Subject: [PATCH] tc/act_tunnel_key: Enable setup of tos and ttl
|
|
|
99be8f |
|
|
|
99be8f |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1641909
|
|
|
99be8f |
Upstream Status: iproute2.git commit 9f89b0cc0eda2
|
|
|
99be8f |
Conflicts:
|
|
|
99be8f |
* Context change due to missing commits
|
|
|
99be8f |
59eb271d1d259 ("tc: m_tunnel_key: add csum/nocsum option") and
|
|
|
99be8f |
6217917a38268 ("tc: m_tunnel_key: Add tunnel option support to act_tunnel_key").
|
|
|
99be8f |
* Adjusted tunnel_key_print_tos_ttl() to missing commit 8feb516bfcdd9
|
|
|
99be8f |
("tc: jsonify tunnel_key action").
|
|
|
99be8f |
|
|
|
99be8f |
commit 9f89b0cc0eda2ef52d8850b0610f3e2e09fd7c1c
|
|
|
99be8f |
Author: Or Gerlitz <ogerlitz@mellanox.com>
|
|
|
99be8f |
Date: Thu Jul 19 14:02:14 2018 +0300
|
|
|
99be8f |
|
|
|
99be8f |
tc/act_tunnel_key: Enable setup of tos and ttl
|
|
|
99be8f |
|
|
|
99be8f |
Allow to set tos and ttl for the tunnel.
|
|
|
99be8f |
|
|
|
99be8f |
For example, here's encap rule that sets tos to the tunnel:
|
|
|
99be8f |
|
|
|
99be8f |
tc filter add dev eth0_0 protocol ip parent ffff: prio 10 flower \
|
|
|
99be8f |
src_mac e4:11:22:33:44:50 dst_mac e4:11:22:33:44:70 \
|
|
|
99be8f |
action tunnel_key set src_ip 192.168.10.1 dst_ip 192.168.10.2 id 100 dst_port 4789 tos 0x30 \
|
|
|
99be8f |
action mirred egress redirect dev vxlan_sys_4789
|
|
|
99be8f |
|
|
|
99be8f |
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
|
|
|
99be8f |
Reviewed-by: Roi Dayan <roid@mellanox.com>
|
|
|
99be8f |
Acked-by: Jiri Pirko <jiri@mellanox.com>
|
|
|
99be8f |
Signed-off-by: David Ahern <dsahern@gmail.com>
|
|
|
99be8f |
---
|
|
|
d30c09 |
man/man8/tc-tunnel_key.8 | 8 +++++++
|
|
|
d30c09 |
tc/m_tunnel_key.c | 49 ++++++++++++++++++++++++++++++++++++++++
|
|
|
99be8f |
2 files changed, 57 insertions(+)
|
|
|
99be8f |
|
|
|
99be8f |
diff --git a/man/man8/tc-tunnel_key.8 b/man/man8/tc-tunnel_key.8
|
|
|
d30c09 |
index 52fa585a75c8f..5e93c59d49465 100644
|
|
|
99be8f |
--- a/man/man8/tc-tunnel_key.8
|
|
|
99be8f |
+++ b/man/man8/tc-tunnel_key.8
|
|
|
99be8f |
@@ -16,6 +16,8 @@ tunnel_key - Tunnel metadata manipulation
|
|
|
99be8f |
.IR ADDRESS
|
|
|
99be8f |
.BI id " KEY_ID"
|
|
|
99be8f |
.BI dst_port " UDP_PORT"
|
|
|
99be8f |
+.BI tos " TOS"
|
|
|
99be8f |
+.BI ttl " TTL"
|
|
|
99be8f |
|
|
|
99be8f |
.SH DESCRIPTION
|
|
|
99be8f |
The
|
|
|
99be8f |
@@ -77,6 +79,12 @@ Outer header destination IP address (IPv4 or IPv6)
|
|
|
99be8f |
.TP
|
|
|
99be8f |
.B dst_port
|
|
|
99be8f |
Outer header destination UDP port
|
|
|
99be8f |
+.TP
|
|
|
99be8f |
+.B tos
|
|
|
99be8f |
+Outer header TOS
|
|
|
99be8f |
+.TP
|
|
|
99be8f |
+.B ttl
|
|
|
99be8f |
+Outer header TTL
|
|
|
99be8f |
.RE
|
|
|
99be8f |
.SH EXAMPLES
|
|
|
99be8f |
The following example encapsulates incoming ICMP packets on eth0 into a vxlan
|
|
|
99be8f |
diff --git a/tc/m_tunnel_key.c b/tc/m_tunnel_key.c
|
|
|
d30c09 |
index acbcfc15cda76..60fd1c464e531 100644
|
|
|
99be8f |
--- a/tc/m_tunnel_key.c
|
|
|
99be8f |
+++ b/tc/m_tunnel_key.c
|
|
|
99be8f |
@@ -80,6 +80,22 @@ static int tunnel_key_parse_dst_port(char *str, int type, struct nlmsghdr *n)
|
|
|
99be8f |
return 0;
|
|
|
99be8f |
}
|
|
|
99be8f |
|
|
|
99be8f |
+static int tunnel_key_parse_tos_ttl(char *str, int type, struct nlmsghdr *n)
|
|
|
99be8f |
+{
|
|
|
99be8f |
+ int ret;
|
|
|
99be8f |
+ __u8 val;
|
|
|
99be8f |
+
|
|
|
99be8f |
+ ret = get_u8(&val, str, 10);
|
|
|
99be8f |
+ if (ret)
|
|
|
99be8f |
+ ret = get_u8(&val, str, 16);
|
|
|
99be8f |
+ if (ret)
|
|
|
99be8f |
+ return -1;
|
|
|
99be8f |
+
|
|
|
99be8f |
+ addattr8(n, MAX_MSG, type, val);
|
|
|
99be8f |
+
|
|
|
99be8f |
+ return 0;
|
|
|
99be8f |
+}
|
|
|
99be8f |
+
|
|
|
99be8f |
static int parse_tunnel_key(struct action_util *a, int *argc_p, char ***argv_p,
|
|
|
99be8f |
int tca_id, struct nlmsghdr *n)
|
|
|
99be8f |
{
|
|
|
99be8f |
@@ -154,6 +170,22 @@ static int parse_tunnel_key(struct action_util *a, int *argc_p, char ***argv_p,
|
|
|
99be8f |
fprintf(stderr, "Illegal \"dst port\"\n");
|
|
|
99be8f |
return -1;
|
|
|
99be8f |
}
|
|
|
99be8f |
+ } else if (matches(*argv, "tos") == 0) {
|
|
|
99be8f |
+ NEXT_ARG();
|
|
|
99be8f |
+ ret = tunnel_key_parse_tos_ttl(*argv,
|
|
|
99be8f |
+ TCA_TUNNEL_KEY_ENC_TOS, n);
|
|
|
99be8f |
+ if (ret < 0) {
|
|
|
99be8f |
+ fprintf(stderr, "Illegal \"tos\"\n");
|
|
|
99be8f |
+ return -1;
|
|
|
99be8f |
+ }
|
|
|
99be8f |
+ } else if (matches(*argv, "ttl") == 0) {
|
|
|
99be8f |
+ NEXT_ARG();
|
|
|
99be8f |
+ ret = tunnel_key_parse_tos_ttl(*argv,
|
|
|
99be8f |
+ TCA_TUNNEL_KEY_ENC_TTL, n);
|
|
|
99be8f |
+ if (ret < 0) {
|
|
|
99be8f |
+ fprintf(stderr, "Illegal \"ttl\"\n");
|
|
|
99be8f |
+ return -1;
|
|
|
99be8f |
+ }
|
|
|
99be8f |
} else if (matches(*argv, "help") == 0) {
|
|
|
99be8f |
usage();
|
|
|
99be8f |
} else {
|
|
|
99be8f |
@@ -231,6 +263,19 @@ static void tunnel_key_print_dst_port(FILE *f, char *name,
|
|
|
99be8f |
fprintf(f, "\n\t%s %d", name, rta_getattr_be16(attr));
|
|
|
99be8f |
}
|
|
|
99be8f |
|
|
|
99be8f |
+static void tunnel_key_print_tos_ttl(FILE *f, char *name,
|
|
|
99be8f |
+ struct rtattr *attr)
|
|
|
99be8f |
+{
|
|
|
99be8f |
+ if (!attr)
|
|
|
99be8f |
+ return;
|
|
|
99be8f |
+
|
|
|
99be8f |
+ if (matches(name, "tos") == 0 && rta_getattr_u8(attr) != 0) {
|
|
|
99be8f |
+ fprintf(f, "\n\t%s 0x%x", name, rta_getattr_u8(attr));
|
|
|
99be8f |
+ } else if (matches(name, "ttl") == 0 && rta_getattr_u8(attr) != 0) {
|
|
|
99be8f |
+ fprintf(f, "\n\t%s %u", name, rta_getattr_u8(attr));
|
|
|
99be8f |
+ }
|
|
|
99be8f |
+}
|
|
|
99be8f |
+
|
|
|
99be8f |
static int print_tunnel_key(struct action_util *au, FILE *f, struct rtattr *arg)
|
|
|
99be8f |
{
|
|
|
99be8f |
struct rtattr *tb[TCA_TUNNEL_KEY_MAX + 1];
|
|
|
99be8f |
@@ -267,6 +312,10 @@ static int print_tunnel_key(struct action_util *au, FILE *f, struct rtattr *arg)
|
|
|
99be8f |
tb[TCA_TUNNEL_KEY_ENC_KEY_ID]);
|
|
|
99be8f |
tunnel_key_print_dst_port(f, "dst_port",
|
|
|
99be8f |
tb[TCA_TUNNEL_KEY_ENC_DST_PORT]);
|
|
|
99be8f |
+ tunnel_key_print_tos_ttl(f, "tos",
|
|
|
99be8f |
+ tb[TCA_TUNNEL_KEY_ENC_TOS]);
|
|
|
99be8f |
+ tunnel_key_print_tos_ttl(f, "ttl",
|
|
|
99be8f |
+ tb[TCA_TUNNEL_KEY_ENC_TTL]);
|
|
|
99be8f |
break;
|
|
|
99be8f |
}
|
|
|
99be8f |
fprintf(f, " %s", action_n2a(parm->action));
|
|
|
99be8f |
--
|
|
|
d30c09 |
2.21.0
|
|
|
99be8f |
|