mirror of
https://git.proxmox.com/git/mirror_iproute2
synced 2025-10-17 13:47:52 +00:00
tc/act_tunnel_key: Enable setup of tos and ttl
Allow to set tos and ttl for the tunnel. For example, here's encap rule that sets tos to the tunnel: tc filter add dev eth0_0 protocol ip parent ffff: prio 10 flower \ src_mac e4:11:22:33:44:50 dst_mac e4:11:22:33:44:70 \ action tunnel_key set src_ip 192.168.10.1 dst_ip 192.168.10.2 id 100 dst_port 4789 tos 0x30 \ action mirred egress redirect dev vxlan_sys_4789 Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com> Reviewed-by: Roi Dayan <roid@mellanox.com> Acked-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David Ahern <dsahern@gmail.com>
This commit is contained in:
parent
204db84eb8
commit
9f89b0cc0e
@ -16,6 +16,8 @@ tunnel_key - Tunnel metadata manipulation
|
||||
.IR ADDRESS
|
||||
.BI id " KEY_ID"
|
||||
.BI dst_port " UDP_PORT"
|
||||
.BI tos " TOS"
|
||||
.BI ttl " TTL"
|
||||
.RB "[ " csum " | " nocsum " ]"
|
||||
|
||||
.SH DESCRIPTION
|
||||
@ -89,6 +91,12 @@ is specified in the form CLASS:TYPE:DATA, where CLASS is represented as a
|
||||
variable length hexadecimal value. Additionally multiple options may be
|
||||
listed using a comma delimiter.
|
||||
.TP
|
||||
.B tos
|
||||
Outer header TOS
|
||||
.TP
|
||||
.B ttl
|
||||
Outer header TTL
|
||||
.TP
|
||||
.RB [ no ] csum
|
||||
Controlls outer UDP checksum. When set to
|
||||
.B csum
|
||||
|
@ -190,6 +190,22 @@ static int tunnel_key_parse_geneve_opts(char *str, struct nlmsghdr *n)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tunnel_key_parse_tos_ttl(char *str, int type, struct nlmsghdr *n)
|
||||
{
|
||||
int ret;
|
||||
__u8 val;
|
||||
|
||||
ret = get_u8(&val, str, 10);
|
||||
if (ret)
|
||||
ret = get_u8(&val, str, 16);
|
||||
if (ret)
|
||||
return -1;
|
||||
|
||||
addattr8(n, MAX_MSG, type, val);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int parse_tunnel_key(struct action_util *a, int *argc_p, char ***argv_p,
|
||||
int tca_id, struct nlmsghdr *n)
|
||||
{
|
||||
@ -273,6 +289,22 @@ static int parse_tunnel_key(struct action_util *a, int *argc_p, char ***argv_p,
|
||||
fprintf(stderr, "Illegal \"geneve_opts\"\n");
|
||||
return -1;
|
||||
}
|
||||
} else if (matches(*argv, "tos") == 0) {
|
||||
NEXT_ARG();
|
||||
ret = tunnel_key_parse_tos_ttl(*argv,
|
||||
TCA_TUNNEL_KEY_ENC_TOS, n);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Illegal \"tos\"\n");
|
||||
return -1;
|
||||
}
|
||||
} else if (matches(*argv, "ttl") == 0) {
|
||||
NEXT_ARG();
|
||||
ret = tunnel_key_parse_tos_ttl(*argv,
|
||||
TCA_TUNNEL_KEY_ENC_TTL, n);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Illegal \"ttl\"\n");
|
||||
return -1;
|
||||
}
|
||||
} else if (matches(*argv, "csum") == 0) {
|
||||
csum = 1;
|
||||
} else if (matches(*argv, "nocsum") == 0) {
|
||||
@ -435,6 +467,23 @@ static void tunnel_key_print_key_opt(const char *name, struct rtattr *attr)
|
||||
tb[TCA_TUNNEL_KEY_ENC_OPTS_GENEVE]);
|
||||
}
|
||||
|
||||
static void tunnel_key_print_tos_ttl(FILE *f, char *name,
|
||||
struct rtattr *attr)
|
||||
{
|
||||
if (!attr)
|
||||
return;
|
||||
|
||||
if (matches(name, "tos") == 0 && rta_getattr_u8(attr) != 0) {
|
||||
print_string(PRINT_FP, NULL, "%s", _SL_);
|
||||
print_uint(PRINT_ANY, "tos", "\ttos 0x%x",
|
||||
rta_getattr_u8(attr));
|
||||
} else if (matches(name, "ttl") == 0 && rta_getattr_u8(attr) != 0) {
|
||||
print_string(PRINT_FP, NULL, "%s", _SL_);
|
||||
print_uint(PRINT_ANY, "ttl", "\tttl %u",
|
||||
rta_getattr_u8(attr));
|
||||
}
|
||||
}
|
||||
|
||||
static int print_tunnel_key(struct action_util *au, FILE *f, struct rtattr *arg)
|
||||
{
|
||||
struct rtattr *tb[TCA_TUNNEL_KEY_MAX + 1];
|
||||
@ -476,6 +525,10 @@ static int print_tunnel_key(struct action_util *au, FILE *f, struct rtattr *arg)
|
||||
tb[TCA_TUNNEL_KEY_ENC_OPTS]);
|
||||
tunnel_key_print_flag(f, "nocsum", "csum",
|
||||
tb[TCA_TUNNEL_KEY_NO_CSUM]);
|
||||
tunnel_key_print_tos_ttl(f, "tos",
|
||||
tb[TCA_TUNNEL_KEY_ENC_TOS]);
|
||||
tunnel_key_print_tos_ttl(f, "ttl",
|
||||
tb[TCA_TUNNEL_KEY_ENC_TTL]);
|
||||
break;
|
||||
}
|
||||
print_action_control(f, " ", parm->action, "");
|
||||
|
Loading…
Reference in New Issue
Block a user