filter: add XOR operation
authorJiri Pirko <jpirko@redhat.com>
Sat, 31 Mar 2012 11:01:20 +0000 (11:01 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 3 Apr 2012 22:36:20 +0000 (18:36 -0400)
Add XOR instruction fo BPF machine. Needed for computing packet hashes.

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/filter.h
net/core/filter.c

index 92dd9933c43d9fb3d380e135911c13d45a0527c5..72090994d789c235c7f73545cec3bc136ff57600 100644 (file)
@@ -126,7 +126,8 @@ struct sock_fprog { /* Required for SO_ATTACH_FILTER. */
 #define SKF_AD_HATYPE  28
 #define SKF_AD_RXHASH  32
 #define SKF_AD_CPU     36
-#define SKF_AD_MAX     40
+#define SKF_AD_ALU_XOR_X       40
+#define SKF_AD_MAX     44
 #define SKF_NET_OFF   (-0x100000)
 #define SKF_LL_OFF    (-0x200000)
 
@@ -231,6 +232,7 @@ enum {
        BPF_S_ANC_HATYPE,
        BPF_S_ANC_RXHASH,
        BPF_S_ANC_CPU,
+       BPF_S_ANC_ALU_XOR_X,
 };
 
 #endif /* __KERNEL__ */
index cfbea889a0ebb4a62d3650e04a75f8fb143e1b7e..5099c4b4a53f64f9c0f440e08f8c3662b452f377 100644 (file)
@@ -315,6 +315,9 @@ load_b:
                case BPF_S_ANC_CPU:
                        A = raw_smp_processor_id();
                        continue;
+               case BPF_S_ANC_ALU_XOR_X:
+                       A ^= X;
+                       continue;
                case BPF_S_ANC_NLATTR: {
                        struct nlattr *nla;
 
@@ -559,6 +562,7 @@ int sk_chk_filter(struct sock_filter *filter, unsigned int flen)
                        ANCILLARY(HATYPE);
                        ANCILLARY(RXHASH);
                        ANCILLARY(CPU);
+                       ANCILLARY(ALU_XOR_X);
                        }
                }
                ftest->code = code;