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