Skip to content

Commit bf0098f

Browse files
Daniel Borkmanndavem330
authored andcommitted
ARM: net: bpf_jit_32: 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: Mircea Gherzan <mgherzan@gmail.com> Cc: Arnd Bergmann <arnd@arndb.de> Acked-by: Mircea Gherzan <mgherzan@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 3cbe204 commit bf0098f

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

‎arch/arm/net/bpf_jit_32.c‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/netdevice.h>
1717
#include <linux/string.h>
1818
#include <linux/slab.h>
19+
#include <linux/if_vlan.h>
1920
#include <asm/cacheflush.h>
2021
#include <asm/hwcap.h>
2122

@@ -168,6 +169,8 @@ static inline bool is_load_to_a(u16 inst)
168169
case BPF_S_ANC_MARK:
169170
case BPF_S_ANC_PROTOCOL:
170171
case BPF_S_ANC_RXHASH:
172+
case BPF_S_ANC_VLAN_TAG:
173+
case BPF_S_ANC_VLAN_TAG_PRESENT:
171174
case BPF_S_ANC_QUEUE:
172175
return true;
173176
default:
@@ -815,6 +818,17 @@ static int build_body(struct jit_ctx *ctx)
815818
off = offsetof(struct sk_buff, rxhash);
816819
emit(ARM_LDR_I(r_A, r_skb, off), ctx);
817820
break;
821+
case BPF_S_ANC_VLAN_TAG:
822+
case BPF_S_ANC_VLAN_TAG_PRESENT:
823+
ctx->seen |= SEEN_SKB;
824+
BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, vlan_tci) != 2);
825+
off = offsetof(struct sk_buff, vlan_tci);
826+
emit(ARM_LDRH_I(r_A, r_skb, off), ctx);
827+
if (inst->code == BPF_S_ANC_VLAN_TAG)
828+
OP_IMM3(ARM_AND, r_A, r_A, VLAN_VID_MASK, ctx);
829+
else
830+
OP_IMM3(ARM_AND, r_A, r_A, VLAN_TAG_PRESENT, ctx);
831+
break;
818832
case BPF_S_ANC_QUEUE:
819833
ctx->seen |= SEEN_SKB;
820834
BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff,

0 commit comments

Comments
 (0)