2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 14:25:26 +00:00

lib/tc: Support setting tos and ttl for TC IP tunnels

Allow to set the tos and ttl for TC tunnels.

Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
This commit is contained in:
Or Gerlitz
2018-07-31 13:40:38 +03:00
committed by Simon Horman
parent dfa2ccdba8
commit 4b12e45435
5 changed files with 46 additions and 7 deletions

View File

@@ -641,6 +641,8 @@ static const struct nl_policy tunnel_key_policy[] = {
.optional = true, },
[TCA_TUNNEL_KEY_ENC_KEY_ID] = { .type = NL_A_U32, .optional = true, },
[TCA_TUNNEL_KEY_ENC_DST_PORT] = { .type = NL_A_U16, .optional = true, },
[TCA_TUNNEL_KEY_ENC_TOS] = { .type = NL_A_U8, .optional = true, },
[TCA_TUNNEL_KEY_ENC_TTL] = { .type = NL_A_U8, .optional = true, },
};
static int
@@ -666,6 +668,8 @@ nl_parse_act_tunnel_key(struct nlattr *options, struct tc_flower *flower)
struct nlattr *ipv4_dst = tun_attrs[TCA_TUNNEL_KEY_ENC_IPV4_DST];
struct nlattr *ipv6_src = tun_attrs[TCA_TUNNEL_KEY_ENC_IPV6_SRC];
struct nlattr *ipv6_dst = tun_attrs[TCA_TUNNEL_KEY_ENC_IPV6_DST];
struct nlattr *tos = tun_attrs[TCA_TUNNEL_KEY_ENC_TOS];
struct nlattr *ttl = tun_attrs[TCA_TUNNEL_KEY_ENC_TTL];
action = &flower->actions[flower->action_count++];
action->type = TC_ACT_ENCAP;
@@ -679,6 +683,8 @@ nl_parse_act_tunnel_key(struct nlattr *options, struct tc_flower *flower)
}
action->encap.id = id ? be32_to_be64(nl_attr_get_be32(id)) : 0;
action->encap.tp_dst = dst_port ? nl_attr_get_be16(dst_port) : 0;
action->encap.tos = tos ? nl_attr_get_u8(tos) : 0;
action->encap.ttl = ttl ? nl_attr_get_u8(ttl) : 0;
} else if (tun->t_action == TCA_TUNNEL_KEY_ACT_RELEASE) {
flower->tunnel.tunnel = true;
} else {
@@ -1251,7 +1257,8 @@ nl_msg_put_act_tunnel_key_set(struct ofpbuf *request, ovs_be64 id,
ovs_be32 ipv4_src, ovs_be32 ipv4_dst,
struct in6_addr *ipv6_src,
struct in6_addr *ipv6_dst,
ovs_be16 tp_dst)
ovs_be16 tp_dst,
uint8_t tos, uint8_t ttl)
{
size_t offset;
@@ -1274,6 +1281,12 @@ nl_msg_put_act_tunnel_key_set(struct ofpbuf *request, ovs_be64 id,
nl_msg_put_in6_addr(request, TCA_TUNNEL_KEY_ENC_IPV6_SRC,
ipv6_src);
}
if (tos) {
nl_msg_put_u8(request, TCA_TUNNEL_KEY_ENC_TOS, tos);
}
if (ttl) {
nl_msg_put_u8(request, TCA_TUNNEL_KEY_ENC_TTL, ttl);
}
nl_msg_put_be16(request, TCA_TUNNEL_KEY_ENC_DST_PORT, tp_dst);
}
nl_msg_end_nested(request, offset);
@@ -1515,7 +1528,9 @@ nl_msg_put_flower_acts(struct ofpbuf *request, struct tc_flower *flower)
action->encap.ipv4.ipv4_dst,
&action->encap.ipv6.ipv6_src,
&action->encap.ipv6.ipv6_dst,
action->encap.tp_dst);
action->encap.tp_dst,
action->encap.tos,
action->encap.ttl);
nl_msg_end_nested(request, act_offset);
}
break;