History

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.

Daniel Borkmann committed 14 years ago

Commit bf0098f1 parent 3cbe2041 file · +14 −0Browse files

Unified · Split

arch/arm/net/bpf_jit_32.c+14−0
@@ -16,6 +16,7 @@ · 15 unmodified lines
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) · 146 unmodified lines
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 @@ b_epilogue: · 641 unmodified lines
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,