net: Add keys for TIPC address
authorTom Herbert <tom@herbertland.com>
Thu, 4 Jun 2015 16:16:41 +0000 (09:16 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 4 Jun 2015 22:44:31 +0000 (15:44 -0700)
Add a new flow key for TIPC addresses.

Signed-off-by: Tom Herbert <tom@herbertland.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/flow_dissector.h
net/core/flow_dissector.c

index 306d4613abbbe4e157a2d8eccdff93ac627bc3bd..3ee606a547755328b415d6b6a53d5a4238dd7217 100644 (file)
@@ -49,6 +49,14 @@ struct flow_dissector_key_ipv6_addrs {
        struct in6_addr dst;
 };
 
+/**
+ * struct flow_dissector_key_tipc_addrs:
+ * @srcnode: source node address
+ */
+struct flow_dissector_key_tipc_addrs {
+       __be32 srcnode;
+};
+
 /**
  * struct flow_dissector_key_addrs:
  * @v4addrs: IPv4 addresses
@@ -58,6 +66,7 @@ struct flow_dissector_key_addrs {
        union {
                struct flow_dissector_key_ipv4_addrs v4addrs;
                struct flow_dissector_key_ipv6_addrs v6addrs;
+               struct flow_dissector_key_tipc_addrs tipcaddrs;
        };
 };
 
@@ -97,6 +106,7 @@ enum flow_dissector_key_id {
        FLOW_DISSECTOR_KEY_IPV6_HASH_ADDRS, /* struct flow_dissector_key_addrs */
        FLOW_DISSECTOR_KEY_PORTS, /* struct flow_dissector_key_ports */
        FLOW_DISSECTOR_KEY_ETH_ADDRS, /* struct flow_dissector_key_eth_addrs */
+       FLOW_DISSECTOR_KEY_TIPC_ADDRS, /* struct flow_dissector_key_tipc_addrs */
 
        FLOW_DISSECTOR_KEY_MAX,
 };
index ca9d22488cfbc3eef0ab97085aa6872043b2233d..91861c3d45a7e723e12432a1d40ca05e53895981 100644 (file)
@@ -294,13 +294,12 @@ flow_label:
                key_control->thoff = (u16)nhoff;
 
                if (skb_flow_dissector_uses_key(flow_dissector,
-                                               FLOW_DISSECTOR_KEY_IPV6_HASH_ADDRS)) {
+                                               FLOW_DISSECTOR_KEY_TIPC_ADDRS)) {
                        key_addrs = skb_flow_dissector_target(flow_dissector,
-                                                             FLOW_DISSECTOR_KEY_IPV6_HASH_ADDRS,
+                                                             FLOW_DISSECTOR_KEY_TIPC_ADDRS,
                                                              target_container);
-                       key_addrs->v4addrs.src = hdr->srcnode;
-                       key_addrs->v4addrs.dst = 0;
-                       key_control->addr_type = FLOW_DISSECTOR_KEY_IPV4_ADDRS;
+                       key_addrs->tipcaddrs.srcnode = hdr->srcnode;
+                       key_control->addr_type = FLOW_DISSECTOR_KEY_TIPC_ADDRS;
                }
                return true;
        }
@@ -408,6 +407,9 @@ static inline size_t flow_keys_hash_length(struct flow_keys *flow)
        case FLOW_DISSECTOR_KEY_IPV6_ADDRS:
                diff -= sizeof(flow->addrs.v6addrs);
                break;
+       case FLOW_DISSECTOR_KEY_TIPC_ADDRS:
+               diff -= sizeof(flow->addrs.tipcaddrs);
+               break;
        }
        return (sizeof(*flow) - diff) / sizeof(u32);
 }
@@ -420,6 +422,8 @@ __be32 flow_get_u32_src(const struct flow_keys *flow)
        case FLOW_DISSECTOR_KEY_IPV6_ADDRS:
                return (__force __be32)ipv6_addr_hash(
                        &flow->addrs.v6addrs.src);
+       case FLOW_DISSECTOR_KEY_TIPC_ADDRS:
+               return flow->addrs.tipcaddrs.srcnode;
        default:
                return 0;
        }
@@ -650,6 +654,10 @@ static const struct flow_dissector_key flow_keys_dissector_keys[] = {
                .key_id = FLOW_DISSECTOR_KEY_IPV6_HASH_ADDRS,
                .offset = offsetof(struct flow_keys, addrs.v4addrs),
        },
+       {
+               .key_id = FLOW_DISSECTOR_KEY_TIPC_ADDRS,
+               .offset = offsetof(struct flow_keys, addrs.tipcaddrs),
+       },
        {
                .key_id = FLOW_DISSECTOR_KEY_PORTS,
                .offset = offsetof(struct flow_keys, ports),