Skip to content

Commit ffe06c1

Browse files
Jiri Pirkodavem330
authored andcommitted
filter: add XOR operation
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>
1 parent 302d663 commit ffe06c1

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

‎include/linux/filter.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ struct sock_fprog { /* Required for SO_ATTACH_FILTER. */
126126
#define SKF_AD_HATYPE 28
127127
#define SKF_AD_RXHASH 32
128128
#define SKF_AD_CPU 36
129-
#define SKF_AD_MAX 40
129+
#define SKF_AD_ALU_XOR_X 40
130+
#define SKF_AD_MAX 44
130131
#define SKF_NET_OFF (-0x100000)
131132
#define SKF_LL_OFF (-0x200000)
132133

@@ -231,6 +232,7 @@ enum {
231232
BPF_S_ANC_HATYPE,
232233
BPF_S_ANC_RXHASH,
233234
BPF_S_ANC_CPU,
235+
BPF_S_ANC_ALU_XOR_X,
234236
};
235237

236238
#endif /* __KERNEL__ */

‎net/core/filter.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,9 @@ unsigned int sk_run_filter(const struct sk_buff *skb,
315315
case BPF_S_ANC_CPU:
316316
A = raw_smp_processor_id();
317317
continue;
318+
case BPF_S_ANC_ALU_XOR_X:
319+
A ^= X;
320+
continue;
318321
case BPF_S_ANC_NLATTR: {
319322
struct nlattr *nla;
320323

@@ -559,6 +562,7 @@ int sk_chk_filter(struct sock_filter *filter, unsigned int flen)
559562
ANCILLARY(HATYPE);
560563
ANCILLARY(RXHASH);
561564
ANCILLARY(CPU);
565+
ANCILLARY(ALU_XOR_X);
562566
}
563567
}
564568
ftest->code = code;

0 commit comments

Comments
 (0)