aboutsummaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorDaniel Borkmann <dxchgb@gmail.com>2012-09-23 22:23:59 -0400
committerDavid S. Miller <davem@davemloft.net>2012-09-24 16:49:21 -0400
commit9e49e88958feb41ec701fa34b44723dabadbc28c (patch)
treeab17d7738505ade25a0a16bf442086cbf07d0f22 /net/core
parent718cffc4ac65f01c6f1efd6baec8b4b5ff0c76b5 (diff)
filter: add XOR instruction for use with X/K
SKF_AD_ALU_XOR_X has been added a while ago, but as an 'ancillary' operation that is invoked through a negative offset in K within BPF load operations. Since BPF_MOD has recently been added, BPF_XOR should also be part of the common ALU operations. Removing SKF_AD_ALU_XOR_X might not be an option since this is exposed to user space. Signed-off-by: Daniel Borkmann <daniel.borkmann@tik.ee.ethz.ch> Acked-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/filter.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/net/core/filter.c b/net/core/filter.c
index fbe3a8d12570..3d92ebb7fbcf 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -187,6 +187,13 @@ unsigned int sk_run_filter(const struct sk_buff *skb,
187 case BPF_S_ALU_OR_K: 187 case BPF_S_ALU_OR_K:
188 A |= K; 188 A |= K;
189 continue; 189 continue;
190 case BPF_S_ANC_ALU_XOR_X:
191 case BPF_S_ALU_XOR_X:
192 A ^= X;
193 continue;
194 case BPF_S_ALU_XOR_K:
195 A ^= K;
196 continue;
190 case BPF_S_ALU_LSH_X: 197 case BPF_S_ALU_LSH_X:
191 A <<= X; 198 A <<= X;
192 continue; 199 continue;
@@ -334,9 +341,6 @@ load_b:
334 case BPF_S_ANC_CPU: 341 case BPF_S_ANC_CPU:
335 A = raw_smp_processor_id(); 342 A = raw_smp_processor_id();
336 continue; 343 continue;
337 case BPF_S_ANC_ALU_XOR_X:
338 A ^= X;
339 continue;
340 case BPF_S_ANC_NLATTR: { 344 case BPF_S_ANC_NLATTR: {
341 struct nlattr *nla; 345 struct nlattr *nla;
342 346
@@ -483,6 +487,8 @@ int sk_chk_filter(struct sock_filter *filter, unsigned int flen)
483 [BPF_ALU|BPF_AND|BPF_X] = BPF_S_ALU_AND_X, 487 [BPF_ALU|BPF_AND|BPF_X] = BPF_S_ALU_AND_X,
484 [BPF_ALU|BPF_OR|BPF_K] = BPF_S_ALU_OR_K, 488 [BPF_ALU|BPF_OR|BPF_K] = BPF_S_ALU_OR_K,
485 [BPF_ALU|BPF_OR|BPF_X] = BPF_S_ALU_OR_X, 489 [BPF_ALU|BPF_OR|BPF_X] = BPF_S_ALU_OR_X,
490 [BPF_ALU|BPF_XOR|BPF_K] = BPF_S_ALU_XOR_K,
491 [BPF_ALU|BPF_XOR|BPF_X] = BPF_S_ALU_XOR_X,
486 [BPF_ALU|BPF_LSH|BPF_K] = BPF_S_ALU_LSH_K, 492 [BPF_ALU|BPF_LSH|BPF_K] = BPF_S_ALU_LSH_K,
487 [BPF_ALU|BPF_LSH|BPF_X] = BPF_S_ALU_LSH_X, 493 [BPF_ALU|BPF_LSH|BPF_X] = BPF_S_ALU_LSH_X,
488 [BPF_ALU|BPF_RSH|BPF_K] = BPF_S_ALU_RSH_K, 494 [BPF_ALU|BPF_RSH|BPF_K] = BPF_S_ALU_RSH_K,