]> git.proxmox.com Git - ovs.git/commitdiff
tc: Add ip layer ttl matching
authorPaul Blakey <paulb@mellanox.com>
Mon, 7 Aug 2017 15:19:06 +0000 (18:19 +0300)
committerJoe Stringer <joe@ovn.org>
Fri, 11 Aug 2017 18:43:40 +0000 (11:43 -0700)
Add matching on ip layer ttl, to be used later.

Signed-off-by: Paul Blakey <paulb@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Acked-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: Joe Stringer <joe@ovn.org>
lib/tc.c
lib/tc.h

index 5c36d0da731eaf8e7acb97c220af2fe3233bcc58..5a3a82af5c9b229eba22b0c2c119bf38310dc65f 100644 (file)
--- a/lib/tc.c
+++ b/lib/tc.c
@@ -196,6 +196,10 @@ static const struct nl_policy tca_flower_policy[] = {
                                            .optional = true, },
     [TCA_FLOWER_KEY_ENC_UDP_DST_PORT] = { .type = NL_A_U16,
                                           .optional = true, },
+    [TCA_FLOWER_KEY_IP_TTL] = { .type = NL_A_U8,
+                                .optional = true, },
+    [TCA_FLOWER_KEY_IP_TTL_MASK] = { .type = NL_A_U8,
+                                     .optional = true, },
 };
 
 static void
@@ -344,6 +348,11 @@ nl_parse_flower_ip(struct nlattr **attrs, struct tc_flower *flower) {
                 nl_attr_get_be16(attrs[TCA_FLOWER_KEY_SCTP_DST_MASK]);
         }
     }
+
+    if (attrs[TCA_FLOWER_KEY_IP_TTL_MASK]) {
+        key->ip_ttl = nl_attr_get_u8(attrs[TCA_FLOWER_KEY_IP_TTL]);
+        mask->ip_ttl = nl_attr_get_u8(attrs[TCA_FLOWER_KEY_IP_TTL_MASK]);
+    }
 }
 
 static const struct nl_policy tunnel_key_policy[] = {
@@ -1036,6 +1045,7 @@ nl_msg_put_flower_options(struct ofpbuf *request, struct tc_flower *flower)
     if (host_eth_type == ETH_P_IP) {
             FLOWER_PUT_MASKED_VALUE(ipv4.ipv4_src, TCA_FLOWER_KEY_IPV4_SRC);
             FLOWER_PUT_MASKED_VALUE(ipv4.ipv4_dst, TCA_FLOWER_KEY_IPV4_DST);
+            FLOWER_PUT_MASKED_VALUE(ip_ttl, TCA_FLOWER_KEY_IP_TTL);
     } else if (host_eth_type == ETH_P_IPV6) {
             FLOWER_PUT_MASKED_VALUE(ipv6.ipv6_src, TCA_FLOWER_KEY_IPV6_SRC);
             FLOWER_PUT_MASKED_VALUE(ipv6.ipv6_dst, TCA_FLOWER_KEY_IPV6_DST);
index 5f363d0a97ad522af789cf9483d7c459f03afe4b..362e751251b1fb906aa18c08a617f5e3bdc38ea4 100644 (file)
--- a/lib/tc.h
+++ b/lib/tc.h
@@ -90,6 +90,8 @@ struct tc_flower_key {
 
     ovs_be16 encap_eth_type;
 
+    uint8_t ip_ttl;
+
     struct {
         ovs_be32 ipv4_src;
         ovs_be32 ipv4_dst;