Move the tunnel match fields to be part of the tc/flower key structure.
This is pre-step for being able to apply masked match where needed.
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
}
}
- if (flower->tunnel.tunnel) {
- match_set_tun_id(match, flower->tunnel.id);
- if (flower->tunnel.ipv4.ipv4_dst) {
- match_set_tun_src(match, flower->tunnel.ipv4.ipv4_src);
- match_set_tun_dst(match, flower->tunnel.ipv4.ipv4_dst);
- } else if (!is_all_zeros(&flower->tunnel.ipv6.ipv6_dst,
- sizeof flower->tunnel.ipv6.ipv6_dst)) {
- match_set_tun_ipv6_src(match, &flower->tunnel.ipv6.ipv6_src);
- match_set_tun_ipv6_dst(match, &flower->tunnel.ipv6.ipv6_dst);
+ if (flower->tunnel) {
+ match_set_tun_id(match, flower->key.tunnel.id);
+ if (flower->key.tunnel.ipv4.ipv4_dst) {
+ match_set_tun_src(match, flower->key.tunnel.ipv4.ipv4_src);
+ match_set_tun_dst(match, flower->key.tunnel.ipv4.ipv4_dst);
+ } else if (!is_all_zeros(&flower->key.tunnel.ipv6.ipv6_dst,
+ sizeof flower->key.tunnel.ipv6.ipv6_dst)) {
+ match_set_tun_ipv6_src(match, &flower->key.tunnel.ipv6.ipv6_src);
+ match_set_tun_ipv6_dst(match, &flower->key.tunnel.ipv6.ipv6_dst);
}
- if (flower->tunnel.tos) {
- match_set_tun_tos(match, flower->tunnel.tos);
+ if (flower->key.tunnel.tos) {
+ match_set_tun_tos(match, flower->key.tunnel.tos);
}
- if (flower->tunnel.ttl) {
- match_set_tun_ttl(match, flower->tunnel.ttl);
+ if (flower->key.tunnel.ttl) {
+ match_set_tun_ttl(match, flower->key.tunnel.ttl);
}
- if (flower->tunnel.tp_dst) {
- match_set_tun_tp_dst(match, flower->tunnel.tp_dst);
+ if (flower->key.tunnel.tp_dst) {
+ match_set_tun_tp_dst(match, flower->key.tunnel.tp_dst);
}
}
ntohll(tnl->tun_id),
IP_ARGS(tnl->ip_src), IP_ARGS(tnl->ip_dst),
ntohs(tnl->tp_src), ntohs(tnl->tp_dst));
- flower.tunnel.id = tnl->tun_id;
- flower.tunnel.ipv4.ipv4_src = tnl->ip_src;
- flower.tunnel.ipv4.ipv4_dst = tnl->ip_dst;
- flower.tunnel.ipv6.ipv6_src = tnl->ipv6_src;
- flower.tunnel.ipv6.ipv6_dst = tnl->ipv6_dst;
- flower.tunnel.tos = tnl->ip_tos;
- flower.tunnel.ttl = tnl->ip_ttl;
- flower.tunnel.tp_src = tnl->tp_src;
- flower.tunnel.tp_dst = tnl->tp_dst;
- flower.tunnel.tunnel = true;
+ flower.key.tunnel.id = tnl->tun_id;
+ flower.key.tunnel.ipv4.ipv4_src = tnl->ip_src;
+ flower.key.tunnel.ipv4.ipv4_dst = tnl->ip_dst;
+ flower.key.tunnel.ipv6.ipv6_src = tnl->ipv6_src;
+ flower.key.tunnel.ipv6.ipv6_dst = tnl->ipv6_dst;
+ flower.key.tunnel.tos = tnl->ip_tos;
+ flower.key.tunnel.ttl = tnl->ip_ttl;
+ flower.key.tunnel.tp_src = tnl->tp_src;
+ flower.key.tunnel.tp_dst = tnl->tp_dst;
+ flower.tunnel = true;
}
memset(&mask->tunnel, 0, sizeof mask->tunnel);
if (attrs[TCA_FLOWER_KEY_ENC_KEY_ID]) {
ovs_be32 id = nl_attr_get_be32(attrs[TCA_FLOWER_KEY_ENC_KEY_ID]);
- flower->tunnel.id = be32_to_be64(id);
+ flower->key.tunnel.id = be32_to_be64(id);
}
if (attrs[TCA_FLOWER_KEY_ENC_IPV4_SRC_MASK]) {
- flower->tunnel.ipv4.ipv4_src =
+ flower->key.tunnel.ipv4.ipv4_src =
nl_attr_get_be32(attrs[TCA_FLOWER_KEY_ENC_IPV4_SRC]);
}
if (attrs[TCA_FLOWER_KEY_ENC_IPV4_DST_MASK]) {
- flower->tunnel.ipv4.ipv4_dst =
+ flower->key.tunnel.ipv4.ipv4_dst =
nl_attr_get_be32(attrs[TCA_FLOWER_KEY_ENC_IPV4_DST]);
}
if (attrs[TCA_FLOWER_KEY_ENC_IPV6_SRC_MASK]) {
- flower->tunnel.ipv6.ipv6_src =
+ flower->key.tunnel.ipv6.ipv6_src =
nl_attr_get_in6_addr(attrs[TCA_FLOWER_KEY_ENC_IPV6_SRC]);
}
if (attrs[TCA_FLOWER_KEY_ENC_IPV6_DST_MASK]) {
- flower->tunnel.ipv6.ipv6_dst =
+ flower->key.tunnel.ipv6.ipv6_dst =
nl_attr_get_in6_addr(attrs[TCA_FLOWER_KEY_ENC_IPV6_DST]);
}
if (attrs[TCA_FLOWER_KEY_ENC_UDP_DST_PORT]) {
- flower->tunnel.tp_dst =
+ flower->key.tunnel.tp_dst =
nl_attr_get_be16(attrs[TCA_FLOWER_KEY_ENC_UDP_DST_PORT]);
}
if (attrs[TCA_FLOWER_KEY_ENC_IP_TOS]) {
- flower->tunnel.tos =
+ flower->key.tunnel.tos =
nl_attr_get_u8(attrs[TCA_FLOWER_KEY_ENC_IP_TOS]);
}
if (attrs[TCA_FLOWER_KEY_ENC_IP_TTL]) {
- flower->tunnel.ttl =
+ flower->key.tunnel.ttl =
nl_attr_get_u8(attrs[TCA_FLOWER_KEY_ENC_IP_TTL]);
}
}
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;
+ flower->tunnel = true;
} else {
VLOG_ERR_RL(&error_rl, "unknown tunnel actions: %d, %d",
tun->action, tun->t_action);
{
int error;
- if (flower->tunnel.tunnel) {
+ if (flower->tunnel) {
act_offset = nl_msg_start_nested(request, act_index++);
nl_msg_put_act_tunnel_key_release(request);
nl_msg_end_nested(request, act_offset);
static void
nl_msg_put_flower_tunnel(struct ofpbuf *request, struct tc_flower *flower)
{
- ovs_be32 ipv4_src = flower->tunnel.ipv4.ipv4_src;
- ovs_be32 ipv4_dst = flower->tunnel.ipv4.ipv4_dst;
- struct in6_addr *ipv6_src = &flower->tunnel.ipv6.ipv6_src;
- struct in6_addr *ipv6_dst = &flower->tunnel.ipv6.ipv6_dst;
- ovs_be16 tp_dst = flower->tunnel.tp_dst;
- ovs_be32 id = be64_to_be32(flower->tunnel.id);
- uint8_t tos = flower->tunnel.tos;
- uint8_t ttl = flower->tunnel.ttl;
+ ovs_be32 ipv4_src = flower->key.tunnel.ipv4.ipv4_src;
+ ovs_be32 ipv4_dst = flower->key.tunnel.ipv4.ipv4_dst;
+ struct in6_addr *ipv6_src = &flower->key.tunnel.ipv6.ipv6_src;
+ struct in6_addr *ipv6_dst = &flower->key.tunnel.ipv6.ipv6_dst;
+ ovs_be16 tp_dst = flower->key.tunnel.tp_dst;
+ ovs_be32 id = be64_to_be32(flower->key.tunnel.id);
+ uint8_t tos = flower->key.tunnel.tos;
+ uint8_t ttl = flower->key.tunnel.ttl;
if (ipv4_dst) {
nl_msg_put_be32(request, TCA_FLOWER_KEY_ENC_IPV4_SRC, ipv4_src);
nl_msg_put_u32(request, TCA_FLOWER_FLAGS, tc_get_tc_cls_policy(tc_policy));
- if (flower->tunnel.tunnel) {
+ if (flower->tunnel) {
nl_msg_put_flower_tunnel(request, flower);
}
struct in6_addr ipv6_src;
struct in6_addr ipv6_dst;
} ipv6;
+
+ struct {
+ struct {
+ ovs_be32 ipv4_src;
+ ovs_be32 ipv4_dst;
+ } ipv4;
+ struct {
+ struct in6_addr ipv6_src;
+ struct in6_addr ipv6_dst;
+ } ipv6;
+ uint8_t tos;
+ uint8_t ttl;
+ ovs_be16 tp_src;
+ ovs_be16 tp_dst;
+ ovs_be64 id;
+ } tunnel;
};
enum tc_action_type {
uint32_t csum_update_flags;
- struct {
- bool tunnel;
- struct {
- ovs_be32 ipv4_src;
- ovs_be32 ipv4_dst;
- } ipv4;
- struct {
- struct in6_addr ipv6_src;
- struct in6_addr ipv6_dst;
- } ipv6;
- uint8_t tos;
- uint8_t ttl;
- ovs_be16 tp_src;
- ovs_be16 tp_dst;
- ovs_be64 id;
- } tunnel;
+ bool tunnel;
struct tc_cookie act_cookie;