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.
Unified · Split
| @@ -16,6 +16,7 @@ · 15 unmodified lines | |||
| 16 | #include <linux/netdevice.h> | 16 | #include <linux/netdevice.h> |
| 17 | #include <linux/string.h> | 17 | #include <linux/string.h> |
| 18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
| 19 | #include <linux/if_vlan.h> | ||
| 19 | #include <asm/cacheflush.h> | 20 | #include <asm/cacheflush.h> |
| 20 | #include <asm/hwcap.h> | 21 | #include <asm/hwcap.h> |
| 21 | 22 | ||
| @@ -168,6 +169,8 @@ static inline bool is_load_to_a(u16 inst) · 146 unmodified lines | |||
| 168 | case BPF_S_ANC_MARK: | 169 | case BPF_S_ANC_MARK: |
| 169 | case BPF_S_ANC_PROTOCOL: | 170 | case BPF_S_ANC_PROTOCOL: |
| 170 | case BPF_S_ANC_RXHASH: | 171 | case BPF_S_ANC_RXHASH: |
| 172 | case BPF_S_ANC_VLAN_TAG: | ||
| 173 | case BPF_S_ANC_VLAN_TAG_PRESENT: | ||
| 171 | case BPF_S_ANC_QUEUE: | 174 | case BPF_S_ANC_QUEUE: |
| 172 | return true; | 175 | return true; |
| 173 | default: | 176 | default: |
| @@ -815,6 +818,17 @@ b_epilogue: · 641 unmodified lines | |||
| 815 | off = offsetof(struct sk_buff, rxhash); | 818 | off = offsetof(struct sk_buff, rxhash); |
| 816 | emit(ARM_LDR_I(r_A, r_skb, off), ctx); | 819 | emit(ARM_LDR_I(r_A, r_skb, off), ctx); |
| 817 | break; | 820 | 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; | ||
| 818 | case BPF_S_ANC_QUEUE: | 832 | case BPF_S_ANC_QUEUE: |
| 819 | ctx->seen |= SEEN_SKB; | 833 | ctx->seen |= SEEN_SKB; |
| 820 | BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, | 834 | BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, |