aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/cls_flower.c
diff options
context:
space:
mode:
authorTom Herbert <tom@herbertland.com>2015-06-04 12:16:40 -0400
committerDavid S. Miller <davem@davemloft.net>2015-06-04 18:44:30 -0400
commitc3f8324188fa80178f20c8209b492ca6191177e8 (patch)
tree7a79eea92ad702932fd81977118f6ab6394a9769 /net/sched/cls_flower.c
parent42aecaa9bb2bd57eb8d61b4565cee5d3640863fb (diff)
net: Add full IPv6 addresses to flow_keys
This patch adds full IPv6 addresses into flow_keys and uses them as input to the flow hash function. The implementation supports either IPv4 or IPv6 addresses in a union, and selector is used to determine how may words to input to jhash2. We also add flow_get_u32_dst and flow_get_u32_src functions which are used to get a u32 representation of the source and destination addresses. For IPv6, ipv6_addr_hash is called. These functions retain getting the legacy values of src and dst in flow_keys. With this patch, Ethertype and IP protocol are now included in the flow hash input. Signed-off-by: Tom Herbert <tom@herbertland.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/cls_flower.c')
-rw-r--r--net/sched/cls_flower.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
index 5a7d66c59684..b92d3f49c23e 100644
--- a/net/sched/cls_flower.c
+++ b/net/sched/cls_flower.c
@@ -28,8 +28,9 @@ struct fl_flow_key {
28 struct flow_dissector_key_control control; 28 struct flow_dissector_key_control control;
29 struct flow_dissector_key_basic basic; 29 struct flow_dissector_key_basic basic;
30 struct flow_dissector_key_eth_addrs eth; 30 struct flow_dissector_key_eth_addrs eth;
31 struct flow_dissector_key_addrs ipaddrs;
31 union { 32 union {
32 struct flow_dissector_key_addrs ipv4; 33 struct flow_dissector_key_ipv4_addrs ipv4;
33 struct flow_dissector_key_ipv6_addrs ipv6; 34 struct flow_dissector_key_ipv6_addrs ipv6;
34 }; 35 };
35 struct flow_dissector_key_ports tp; 36 struct flow_dissector_key_ports tp;
@@ -260,14 +261,14 @@ static int fl_set_key(struct net *net, struct nlattr **tb,
260 &mask->basic.ip_proto, TCA_FLOWER_UNSPEC, 261 &mask->basic.ip_proto, TCA_FLOWER_UNSPEC,
261 sizeof(key->basic.ip_proto)); 262 sizeof(key->basic.ip_proto));
262 } 263 }
263 if (key->basic.n_proto == htons(ETH_P_IP)) { 264 if (key->control.addr_type == FLOW_DISSECTOR_KEY_IPV4_ADDRS) {
264 fl_set_key_val(tb, &key->ipv4.src, TCA_FLOWER_KEY_IPV4_SRC, 265 fl_set_key_val(tb, &key->ipv4.src, TCA_FLOWER_KEY_IPV4_SRC,
265 &mask->ipv4.src, TCA_FLOWER_KEY_IPV4_SRC_MASK, 266 &mask->ipv4.src, TCA_FLOWER_KEY_IPV4_SRC_MASK,
266 sizeof(key->ipv4.src)); 267 sizeof(key->ipv4.src));
267 fl_set_key_val(tb, &key->ipv4.dst, TCA_FLOWER_KEY_IPV4_DST, 268 fl_set_key_val(tb, &key->ipv4.dst, TCA_FLOWER_KEY_IPV4_DST,
268 &mask->ipv4.dst, TCA_FLOWER_KEY_IPV4_DST_MASK, 269 &mask->ipv4.dst, TCA_FLOWER_KEY_IPV4_DST_MASK,
269 sizeof(key->ipv4.dst)); 270 sizeof(key->ipv4.dst));
270 } else if (key->basic.n_proto == htons(ETH_P_IPV6)) { 271 } else if (key->control.addr_type == FLOW_DISSECTOR_KEY_IPV6_ADDRS) {
271 fl_set_key_val(tb, &key->ipv6.src, TCA_FLOWER_KEY_IPV6_SRC, 272 fl_set_key_val(tb, &key->ipv6.src, TCA_FLOWER_KEY_IPV6_SRC,
272 &mask->ipv6.src, TCA_FLOWER_KEY_IPV6_SRC_MASK, 273 &mask->ipv6.src, TCA_FLOWER_KEY_IPV6_SRC_MASK,
273 sizeof(key->ipv6.src)); 274 sizeof(key->ipv6.src));
@@ -610,7 +611,7 @@ static int fl_dump(struct net *net, struct tcf_proto *tp, unsigned long fh,
610 sizeof(key->basic.ip_proto))) 611 sizeof(key->basic.ip_proto)))
611 goto nla_put_failure; 612 goto nla_put_failure;
612 613
613 if (key->basic.n_proto == htons(ETH_P_IP) && 614 if (key->control.addr_type == FLOW_DISSECTOR_KEY_IPV4_ADDRS &&
614 (fl_dump_key_val(skb, &key->ipv4.src, TCA_FLOWER_KEY_IPV4_SRC, 615 (fl_dump_key_val(skb, &key->ipv4.src, TCA_FLOWER_KEY_IPV4_SRC,
615 &mask->ipv4.src, TCA_FLOWER_KEY_IPV4_SRC_MASK, 616 &mask->ipv4.src, TCA_FLOWER_KEY_IPV4_SRC_MASK,
616 sizeof(key->ipv4.src)) || 617 sizeof(key->ipv4.src)) ||
@@ -618,7 +619,7 @@ static int fl_dump(struct net *net, struct tcf_proto *tp, unsigned long fh,
618 &mask->ipv4.dst, TCA_FLOWER_KEY_IPV4_DST_MASK, 619 &mask->ipv4.dst, TCA_FLOWER_KEY_IPV4_DST_MASK,
619 sizeof(key->ipv4.dst)))) 620 sizeof(key->ipv4.dst))))
620 goto nla_put_failure; 621 goto nla_put_failure;
621 else if (key->basic.n_proto == htons(ETH_P_IPV6) && 622 else if (key->control.addr_type == FLOW_DISSECTOR_KEY_IPV6_ADDRS &&
622 (fl_dump_key_val(skb, &key->ipv6.src, TCA_FLOWER_KEY_IPV6_SRC, 623 (fl_dump_key_val(skb, &key->ipv6.src, TCA_FLOWER_KEY_IPV6_SRC,
623 &mask->ipv6.src, TCA_FLOWER_KEY_IPV6_SRC_MASK, 624 &mask->ipv6.src, TCA_FLOWER_KEY_IPV6_SRC_MASK,
624 sizeof(key->ipv6.src)) || 625 sizeof(key->ipv6.src)) ||