summaryrefslogtreecommitdiff
path: root/include/net
diff options
context:
space:
mode:
authordpward <david.ward@ll.mit.edu>2011-09-05 16:47:24 +0000
committerGreg Kroah-Hartman <gregkh@suse.de>2011-11-11 09:37:17 -0800
commit3fa57c1bf5fb311544199b7837a08b9f5bf5e6e4 (patch)
tree9285297f1b3fee391dca9773416e900d0b49b7a8 /include/net
parent867ca3109d0289d0a62bb3c7fc3d365e9d478fae (diff)
net: Handle different key sizes between address families in flow cache
commit aa1c366e4febc7f5c2b84958a2dd7cd70e28f9d0 upstream. With the conversion of struct flowi to a union of AF-specific structs, some operations on the flow cache need to account for the exact size of the key. Signed-off-by: David Ward <david.ward@ll.mit.edu> Signed-off-by: David S. Miller <davem@davemloft.net> Cc: Kim Phillips <kim.phillips@freescale.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/flow.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/net/flow.h b/include/net/flow.h
index a33385366edb..32359fdc7e73 100644
--- a/include/net/flow.h
+++ b/include/net/flow.h
@@ -7,6 +7,7 @@
#ifndef _NET_FLOW_H
#define _NET_FLOW_H
+#include <linux/socket.h>
#include <linux/in6.h>
#include <asm/atomic.h>
@@ -161,6 +162,24 @@ static inline struct flowi *flowidn_to_flowi(struct flowidn *fldn)
return container_of(fldn, struct flowi, u.dn);
}
+typedef unsigned long flow_compare_t;
+
+static inline size_t flow_key_size(u16 family)
+{
+ switch (family) {
+ case AF_INET:
+ BUILD_BUG_ON(sizeof(struct flowi4) % sizeof(flow_compare_t));
+ return sizeof(struct flowi4) / sizeof(flow_compare_t);
+ case AF_INET6:
+ BUILD_BUG_ON(sizeof(struct flowi6) % sizeof(flow_compare_t));
+ return sizeof(struct flowi6) / sizeof(flow_compare_t);
+ case AF_DECnet:
+ BUILD_BUG_ON(sizeof(struct flowidn) % sizeof(flow_compare_t));
+ return sizeof(struct flowidn) / sizeof(flow_compare_t);
+ }
+ return 0;
+}
+
#define FLOW_DIR_IN 0
#define FLOW_DIR_OUT 1
#define FLOW_DIR_FWD 2