|
|
930fb9 |
From b24c686f3e5bb0acbebf40c3e7f5a16f0582fd64 Mon Sep 17 00:00:00 2001
|
|
|
930fb9 |
From: Phil Sutter <psutter@redhat.com>
|
|
|
930fb9 |
Date: Thu, 13 Sep 2018 20:55:45 +0200
|
|
|
930fb9 |
Subject: [PATCH] tc/act_tunnel_key: Enable setup of tos and ttl
|
|
|
930fb9 |
|
|
|
930fb9 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1615915
|
|
|
930fb9 |
Upstream Status: iproute2.git commit 9f89b0cc0eda2
|
|
|
930fb9 |
Conflicts: Context change due to missing Geneve support.
|
|
|
930fb9 |
|
|
|
930fb9 |
commit 9f89b0cc0eda2ef52d8850b0610f3e2e09fd7c1c
|
|
|
930fb9 |
Author: Or Gerlitz <ogerlitz@mellanox.com>
|
|
|
930fb9 |
Date: Thu Jul 19 14:02:14 2018 +0300
|
|
|
930fb9 |
|
|
|
930fb9 |
tc/act_tunnel_key: Enable setup of tos and ttl
|
|
|
930fb9 |
|
|
|
930fb9 |
Allow to set tos and ttl for the tunnel.
|
|
|
930fb9 |
|
|
|
930fb9 |
For example, here's encap rule that sets tos to the tunnel:
|
|
|
930fb9 |
|
|
|
930fb9 |
tc filter add dev eth0_0 protocol ip parent ffff: prio 10 flower \
|
|
|
930fb9 |
src_mac e4:11:22:33:44:50 dst_mac e4:11:22:33:44:70 \
|
|
|
930fb9 |
action tunnel_key set src_ip 192.168.10.1 dst_ip 192.168.10.2 id 100 dst_port 4789 tos 0x30 \
|
|
|
930fb9 |
action mirred egress redirect dev vxlan_sys_4789
|
|
|
930fb9 |
|
|
|
930fb9 |
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
|
|
|
930fb9 |
Reviewed-by: Roi Dayan <roid@mellanox.com>
|
|
|
930fb9 |
Acked-by: Jiri Pirko <jiri@mellanox.com>
|
|
|
930fb9 |
Signed-off-by: David Ahern <dsahern@gmail.com>
|
|
|
930fb9 |
---
|
|
|
930fb9 |
man/man8/tc-tunnel_key.8 | 8 ++++++++
|
|
|
930fb9 |
tc/m_tunnel_key.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
930fb9 |
2 files changed, 61 insertions(+)
|
|
|
930fb9 |
|
|
|
930fb9 |
diff --git a/man/man8/tc-tunnel_key.8 b/man/man8/tc-tunnel_key.8
|
|
|
930fb9 |
index e979a74..71cee5b 100644
|
|
|
930fb9 |
--- a/man/man8/tc-tunnel_key.8
|
|
|
930fb9 |
+++ b/man/man8/tc-tunnel_key.8
|
|
|
930fb9 |
@@ -16,6 +16,8 @@ tunnel_key - Tunnel metadata manipulation
|
|
|
930fb9 |
.IR ADDRESS
|
|
|
930fb9 |
.BI id " KEY_ID"
|
|
|
930fb9 |
.BI dst_port " UDP_PORT"
|
|
|
930fb9 |
+.BI tos " TOS"
|
|
|
930fb9 |
+.BI ttl " TTL"
|
|
|
930fb9 |
.RB "[ " csum " | " nocsum " ]"
|
|
|
930fb9 |
|
|
|
930fb9 |
.SH DESCRIPTION
|
|
|
930fb9 |
@@ -79,6 +81,12 @@ Outer header destination IP address (IPv4 or IPv6)
|
|
|
930fb9 |
.B dst_port
|
|
|
930fb9 |
Outer header destination UDP port
|
|
|
930fb9 |
.TP
|
|
|
930fb9 |
+.B tos
|
|
|
930fb9 |
+Outer header TOS
|
|
|
930fb9 |
+.TP
|
|
|
930fb9 |
+.B ttl
|
|
|
930fb9 |
+Outer header TTL
|
|
|
930fb9 |
+.TP
|
|
|
930fb9 |
.RB [ no ] csum
|
|
|
930fb9 |
Controlls outer UDP checksum. When set to
|
|
|
930fb9 |
.B csum
|
|
|
930fb9 |
diff --git a/tc/m_tunnel_key.c b/tc/m_tunnel_key.c
|
|
|
930fb9 |
index 0fa4615..8d0a8d1 100644
|
|
|
930fb9 |
--- a/tc/m_tunnel_key.c
|
|
|
930fb9 |
+++ b/tc/m_tunnel_key.c
|
|
|
930fb9 |
@@ -81,6 +81,22 @@ static int tunnel_key_parse_dst_port(char *str, int type, struct nlmsghdr *n)
|
|
|
930fb9 |
return 0;
|
|
|
930fb9 |
}
|
|
|
930fb9 |
|
|
|
930fb9 |
+static int tunnel_key_parse_tos_ttl(char *str, int type, struct nlmsghdr *n)
|
|
|
930fb9 |
+{
|
|
|
930fb9 |
+ int ret;
|
|
|
930fb9 |
+ __u8 val;
|
|
|
930fb9 |
+
|
|
|
930fb9 |
+ ret = get_u8(&val, str, 10);
|
|
|
930fb9 |
+ if (ret)
|
|
|
930fb9 |
+ ret = get_u8(&val, str, 16);
|
|
|
930fb9 |
+ if (ret)
|
|
|
930fb9 |
+ return -1;
|
|
|
930fb9 |
+
|
|
|
930fb9 |
+ addattr8(n, MAX_MSG, type, val);
|
|
|
930fb9 |
+
|
|
|
930fb9 |
+ return 0;
|
|
|
930fb9 |
+}
|
|
|
930fb9 |
+
|
|
|
930fb9 |
static int parse_tunnel_key(struct action_util *a, int *argc_p, char ***argv_p,
|
|
|
930fb9 |
int tca_id, struct nlmsghdr *n)
|
|
|
930fb9 |
{
|
|
|
930fb9 |
@@ -157,6 +173,22 @@ static int parse_tunnel_key(struct action_util *a, int *argc_p, char ***argv_p,
|
|
|
930fb9 |
fprintf(stderr, "Illegal \"dst port\"\n");
|
|
|
930fb9 |
return -1;
|
|
|
930fb9 |
}
|
|
|
930fb9 |
+ } else if (matches(*argv, "tos") == 0) {
|
|
|
930fb9 |
+ NEXT_ARG();
|
|
|
930fb9 |
+ ret = tunnel_key_parse_tos_ttl(*argv,
|
|
|
930fb9 |
+ TCA_TUNNEL_KEY_ENC_TOS, n);
|
|
|
930fb9 |
+ if (ret < 0) {
|
|
|
930fb9 |
+ fprintf(stderr, "Illegal \"tos\"\n");
|
|
|
930fb9 |
+ return -1;
|
|
|
930fb9 |
+ }
|
|
|
930fb9 |
+ } else if (matches(*argv, "ttl") == 0) {
|
|
|
930fb9 |
+ NEXT_ARG();
|
|
|
930fb9 |
+ ret = tunnel_key_parse_tos_ttl(*argv,
|
|
|
930fb9 |
+ TCA_TUNNEL_KEY_ENC_TTL, n);
|
|
|
930fb9 |
+ if (ret < 0) {
|
|
|
930fb9 |
+ fprintf(stderr, "Illegal \"ttl\"\n");
|
|
|
930fb9 |
+ return -1;
|
|
|
930fb9 |
+ }
|
|
|
930fb9 |
} else if (matches(*argv, "csum") == 0) {
|
|
|
930fb9 |
csum = 1;
|
|
|
930fb9 |
} else if (matches(*argv, "nocsum") == 0) {
|
|
|
930fb9 |
@@ -260,6 +292,23 @@ static void tunnel_key_print_flag(FILE *f, const char *name_on,
|
|
|
930fb9 |
rta_getattr_u8(attr) ? name_on : name_off);
|
|
|
930fb9 |
}
|
|
|
930fb9 |
|
|
|
930fb9 |
+static void tunnel_key_print_tos_ttl(FILE *f, char *name,
|
|
|
930fb9 |
+ struct rtattr *attr)
|
|
|
930fb9 |
+{
|
|
|
930fb9 |
+ if (!attr)
|
|
|
930fb9 |
+ return;
|
|
|
930fb9 |
+
|
|
|
930fb9 |
+ if (matches(name, "tos") == 0 && rta_getattr_u8(attr) != 0) {
|
|
|
930fb9 |
+ print_string(PRINT_FP, NULL, "%s", _SL_);
|
|
|
930fb9 |
+ print_uint(PRINT_ANY, "tos", "\ttos 0x%x",
|
|
|
930fb9 |
+ rta_getattr_u8(attr));
|
|
|
930fb9 |
+ } else if (matches(name, "ttl") == 0 && rta_getattr_u8(attr) != 0) {
|
|
|
930fb9 |
+ print_string(PRINT_FP, NULL, "%s", _SL_);
|
|
|
930fb9 |
+ print_uint(PRINT_ANY, "ttl", "\tttl %u",
|
|
|
930fb9 |
+ rta_getattr_u8(attr));
|
|
|
930fb9 |
+ }
|
|
|
930fb9 |
+}
|
|
|
930fb9 |
+
|
|
|
930fb9 |
static int print_tunnel_key(struct action_util *au, FILE *f, struct rtattr *arg)
|
|
|
930fb9 |
{
|
|
|
930fb9 |
struct rtattr *tb[TCA_TUNNEL_KEY_MAX + 1];
|
|
|
930fb9 |
@@ -299,6 +348,10 @@ static int print_tunnel_key(struct action_util *au, FILE *f, struct rtattr *arg)
|
|
|
930fb9 |
tb[TCA_TUNNEL_KEY_ENC_DST_PORT]);
|
|
|
930fb9 |
tunnel_key_print_flag(f, "nocsum", "csum",
|
|
|
930fb9 |
tb[TCA_TUNNEL_KEY_NO_CSUM]);
|
|
|
930fb9 |
+ tunnel_key_print_tos_ttl(f, "tos",
|
|
|
930fb9 |
+ tb[TCA_TUNNEL_KEY_ENC_TOS]);
|
|
|
930fb9 |
+ tunnel_key_print_tos_ttl(f, "ttl",
|
|
|
930fb9 |
+ tb[TCA_TUNNEL_KEY_ENC_TTL]);
|
|
|
930fb9 |
break;
|
|
|
930fb9 |
}
|
|
|
930fb9 |
print_action_control(f, " ", parm->action, "");
|
|
|
930fb9 |
--
|
|
|
930fb9 |
1.8.3.1
|
|
|
930fb9 |
|