Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PPC: net: bpf_jit_comp: add VLAN instructions for BPF JIT

This patch is a follow-up for patch "net: filter: add vlan tag access"
to support the new VLAN_TAG/VLAN_TAG_PRESENT accessors in BPF JIT.

Signed-off-by: Daniel Borkmann <daniel.borkmann@tik.ee.ethz.ch>
Cc: Matt Evans <matt@ozlabs.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Daniel Borkmann and committed by
David S. Miller
5082dfb7 02871903

+14
+14
arch/powerpc/net/bpf_jit_comp.c
··· 13 13 #include <asm/cacheflush.h> 14 14 #include <linux/netdevice.h> 15 15 #include <linux/filter.h> 16 + #include <linux/if_vlan.h> 17 + 16 18 #include "bpf_jit.h" 17 19 18 20 #ifndef __BIG_ENDIAN ··· 91 89 case BPF_S_ANC_IFINDEX: 92 90 case BPF_S_ANC_MARK: 93 91 case BPF_S_ANC_RXHASH: 92 + case BPF_S_ANC_VLAN_TAG: 93 + case BPF_S_ANC_VLAN_TAG_PRESENT: 94 94 case BPF_S_ANC_CPU: 95 95 case BPF_S_ANC_QUEUE: 96 96 case BPF_S_LD_W_ABS: ··· 385 381 BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, rxhash) != 4); 386 382 PPC_LWZ_OFFS(r_A, r_skb, offsetof(struct sk_buff, 387 383 rxhash)); 384 + break; 385 + case BPF_S_ANC_VLAN_TAG: 386 + case BPF_S_ANC_VLAN_TAG_PRESENT: 387 + BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, vlan_tci) != 2); 388 + PPC_LHZ_OFFS(r_A, r_skb, offsetof(struct sk_buff, 389 + vlan_tci)); 390 + if (filter[i].code == BPF_S_ANC_VLAN_TAG) 391 + PPC_ANDI(r_A, r_A, VLAN_VID_MASK); 392 + else 393 + PPC_ANDI(r_A, r_A, VLAN_TAG_PRESENT); 388 394 break; 389 395 case BPF_S_ANC_QUEUE: 390 396 BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff,