summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2010-12-01 00:45:56 +0300
committerDavid S. Miller <davem@davemloft.net>2010-12-06 23:59:05 +0300
commitda2033c282264bfba4e339b7cb3df62adb5c5fc8 (patch)
tree8a28a32439f073b5b99d0782ee295cb458e108cb
parent539995d18649023199986424d140f1d620372ce5 (diff)
downloadlinux-da2033c282264bfba4e339b7cb3df62adb5c5fc8.tar.xz
filter: add SKF_AD_RXHASH and SKF_AD_CPU
Add SKF_AD_RXHASH and SKF_AD_CPU to filter ancillary mechanism, to be able to build advanced filters. This can help spreading packets on several sockets with a fast selection, after RPS dispatch to N cpus for example, or to catch a percentage of flows in one queue. tcpdump -s 500 "cpu = 1" : [0] ld CPU [1] jeq #1 jt 2 jf 3 [2] ret #500 [3] ret #0 # take 12.5 % of flows (average) tcpdump -s 1000 "rxhash & 7 = 2" : [0] ld RXHASH [1] and #7 [2] jeq #2 jt 3 jf 4 [3] ret #1000 [4] ret #0 Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Cc: Rui <wirelesser@gmail.com> Acked-by: Changli Gao <xiaosuo@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/linux/filter.h4
-rw-r--r--net/core/filter.c6
2 files changed, 9 insertions, 1 deletions
diff --git a/include/linux/filter.h b/include/linux/filter.h
index 447a775878fb..5334adaf4072 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -124,7 +124,9 @@ struct sock_fprog { /* Required for SO_ATTACH_FILTER. */
#define SKF_AD_MARK 20
#define SKF_AD_QUEUE 24
#define SKF_AD_HATYPE 28
-#define SKF_AD_MAX 32
+#define SKF_AD_RXHASH 32
+#define SKF_AD_CPU 36
+#define SKF_AD_MAX 40
#define SKF_NET_OFF (-0x100000)
#define SKF_LL_OFF (-0x200000)
diff --git a/net/core/filter.c b/net/core/filter.c
index a44d27f9f0f0..054e286861d2 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -375,6 +375,12 @@ load_b:
return 0;
A = skb->dev->type;
continue;
+ case SKF_AD_RXHASH:
+ A = skb->rxhash;
+ continue;
+ case SKF_AD_CPU:
+ A = raw_smp_processor_id();
+ continue;
case SKF_AD_NLATTR: {
struct nlattr *nla;