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 <[email protected]> Reviewed-by: Roi Dayan <[email protected]> --- lib/netdev-tc-offloads.c | 50 ++++++++++++++++++++++++------------------------ lib/tc.c | 38 ++++++++++++++++++------------------ lib/tc.h | 33 ++++++++++++++++---------------- 3 files changed, 61 insertions(+), 60 deletions(-) diff --git a/lib/netdev-tc-offloads.c b/lib/netdev-tc-offloads.c index 7bc745e..32d09d8 100644 --- a/lib/netdev-tc-offloads.c +++ b/lib/netdev-tc-offloads.c @@ -500,24 +500,24 @@ parse_tc_flower_to_match(struct tc_flower *flower, } } - 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); } } @@ -964,16 +964,16 @@ netdev_tc_flow_put(struct netdev *netdev, struct match *match, 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); diff --git a/lib/tc.c b/lib/tc.c index bbc3823..22e72ee 100644 --- a/lib/tc.c +++ b/lib/tc.c @@ -393,34 +393,34 @@ nl_parse_flower_tunnel(struct nlattr **attrs, struct tc_flower *flower) 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]); } } @@ -702,7 +702,7 @@ nl_parse_act_tunnel_key(struct nlattr *options, struct tc_flower *flower) 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); @@ -1513,7 +1513,7 @@ nl_msg_put_flower_acts(struct ofpbuf *request, struct tc_flower *flower) { 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); @@ -1615,14 +1615,14 @@ nl_msg_put_masked_value(struct ofpbuf *request, uint16_t type, 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); @@ -1739,7 +1739,7 @@ nl_msg_put_flower_options(struct ofpbuf *request, struct tc_flower *flower) 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); } diff --git a/lib/tc.h b/lib/tc.h index aa8805d..d935bfc 100644 --- a/lib/tc.h +++ b/lib/tc.h @@ -106,6 +106,22 @@ struct tc_flower_key { 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 { @@ -173,22 +189,7 @@ struct tc_flower { 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; -- 2.5.5 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
