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

Merge branch 'net-vlan-claim-one-bit-from-sk_buff'

Eric Dumazet says:

====================
net: vlan: claim one bit from sk_buff

First patch claims skb->vlan_present.
This means some bpf changes, eg for sparc32 that I could not test.

Second patch removes one conditional test in gro_list_prepare().
====================

Link: https://lore.kernel.org/r/20221109095759.1874969-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+30 -36
+5 -5
arch/sparc/net/bpf_jit_comp_32.c
··· 555 555 emit_skb_load16(vlan_tci, r_A); 556 556 break; 557 557 case BPF_ANC | SKF_AD_VLAN_TAG_PRESENT: 558 - __emit_skb_load8(__pkt_vlan_present_offset, r_A); 559 - if (PKT_VLAN_PRESENT_BIT) 560 - emit_alu_K(SRL, PKT_VLAN_PRESENT_BIT); 561 - if (PKT_VLAN_PRESENT_BIT < 7) 562 - emit_andi(r_A, 1, r_A); 558 + emit_skb_load32(vlan_all, r_A); 559 + emit_cmpi(r_A, 0); 560 + emit_branch_off(BE, 12); 561 + emit_nop(); 562 + emit_loadimm(1, r_A); 563 563 break; 564 564 case BPF_LD | BPF_W | BPF_LEN: 565 565 emit_skb_load32(len, r_A);
+1 -1
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
··· 1973 1973 #endif 1974 1974 1975 1975 #ifdef CONFIG_DCB 1976 - if (!skb->vlan_present) 1976 + if (!skb_vlan_tag_present(skb)) 1977 1977 goto pick_tx; 1978 1978 1979 1979 vlan_prio = skb->vlan_tci >> 13;
+3 -6
include/linux/if_vlan.h
··· 76 76 return dev->priv_flags & IFF_802_1Q_VLAN; 77 77 } 78 78 79 - #define skb_vlan_tag_present(__skb) ((__skb)->vlan_present) 79 + #define skb_vlan_tag_present(__skb) (!!(__skb)->vlan_all) 80 80 #define skb_vlan_tag_get(__skb) ((__skb)->vlan_tci) 81 81 #define skb_vlan_tag_get_id(__skb) ((__skb)->vlan_tci & VLAN_VID_MASK) 82 82 #define skb_vlan_tag_get_cfi(__skb) (!!((__skb)->vlan_tci & VLAN_CFI_MASK)) ··· 471 471 */ 472 472 static inline void __vlan_hwaccel_clear_tag(struct sk_buff *skb) 473 473 { 474 - skb->vlan_present = 0; 474 + skb->vlan_all = 0; 475 475 } 476 476 477 477 /** ··· 483 483 */ 484 484 static inline void __vlan_hwaccel_copy_tag(struct sk_buff *dst, const struct sk_buff *src) 485 485 { 486 - dst->vlan_present = src->vlan_present; 487 - dst->vlan_proto = src->vlan_proto; 488 - dst->vlan_tci = src->vlan_tci; 486 + dst->vlan_all = src->vlan_all; 489 487 } 490 488 491 489 /* ··· 517 519 { 518 520 skb->vlan_proto = vlan_proto; 519 521 skb->vlan_tci = vlan_tci; 520 - skb->vlan_present = 1; 521 522 } 522 523 523 524 /**
+10 -8
include/linux/skbuff.h
··· 818 818 * @mark: Generic packet mark 819 819 * @reserved_tailroom: (aka @mark) number of bytes of free space available 820 820 * at the tail of an sk_buff 821 - * @vlan_present: VLAN tag is present 821 + * @vlan_all: vlan fields (proto & tci) 822 822 * @vlan_proto: vlan encapsulation protocol 823 823 * @vlan_tci: vlan tag control information 824 824 * @inner_protocol: Protocol (encapsulation) ··· 951 951 /* private: */ 952 952 __u8 __pkt_vlan_present_offset[0]; 953 953 /* public: */ 954 - __u8 vlan_present:1; /* See PKT_VLAN_PRESENT_BIT */ 954 + __u8 remcsum_offload:1; 955 955 __u8 csum_complete_sw:1; 956 956 __u8 csum_level:2; 957 957 __u8 dst_pending_confirm:1; ··· 966 966 967 967 __u8 ipvs_property:1; 968 968 __u8 inner_protocol_type:1; 969 - __u8 remcsum_offload:1; 970 969 #ifdef CONFIG_NET_SWITCHDEV 971 970 __u8 offload_fwd_mark:1; 972 971 __u8 offload_l3_fwd_mark:1; ··· 998 999 __u32 priority; 999 1000 int skb_iif; 1000 1001 __u32 hash; 1001 - __be16 vlan_proto; 1002 - __u16 vlan_tci; 1002 + union { 1003 + u32 vlan_all; 1004 + struct { 1005 + __be16 vlan_proto; 1006 + __u16 vlan_tci; 1007 + }; 1008 + }; 1003 1009 #if defined(CONFIG_NET_RX_BUSY_POLL) || defined(CONFIG_XPS) 1004 1010 union { 1005 1011 unsigned int napi_id; ··· 1063 1059 #endif 1064 1060 #define PKT_TYPE_OFFSET offsetof(struct sk_buff, __pkt_type_offset) 1065 1061 1066 - /* if you move pkt_vlan_present, tc_at_ingress, or mono_delivery_time 1062 + /* if you move tc_at_ingress or mono_delivery_time 1067 1063 * around, you also must adapt these constants. 1068 1064 */ 1069 1065 #ifdef __BIG_ENDIAN_BITFIELD 1070 - #define PKT_VLAN_PRESENT_BIT 7 1071 1066 #define TC_AT_INGRESS_MASK (1 << 0) 1072 1067 #define SKB_MONO_DELIVERY_TIME_MASK (1 << 2) 1073 1068 #else 1074 - #define PKT_VLAN_PRESENT_BIT 0 1075 1069 #define TC_AT_INGRESS_MASK (1 << 7) 1076 1070 #define SKB_MONO_DELIVERY_TIME_MASK (1 << 5) 1077 1071 #endif
-1
lib/test_bpf.c
··· 14346 14346 skb->hash = SKB_HASH; 14347 14347 skb->queue_mapping = SKB_QUEUE_MAP; 14348 14348 skb->vlan_tci = SKB_VLAN_TCI; 14349 - skb->vlan_present = SKB_VLAN_PRESENT; 14350 14349 skb->vlan_proto = htons(ETH_P_IP); 14351 14350 dev_net_set(&dev, &init_net); 14352 14351 skb->dev = &dev;
+10 -12
net/core/filter.c
··· 325 325 offsetof(struct sk_buff, vlan_tci)); 326 326 break; 327 327 case SKF_AD_VLAN_TAG_PRESENT: 328 - *insn++ = BPF_LDX_MEM(BPF_B, dst_reg, src_reg, PKT_VLAN_PRESENT_OFFSET); 329 - if (PKT_VLAN_PRESENT_BIT) 330 - *insn++ = BPF_ALU32_IMM(BPF_RSH, dst_reg, PKT_VLAN_PRESENT_BIT); 331 - if (PKT_VLAN_PRESENT_BIT < 7) 332 - *insn++ = BPF_ALU32_IMM(BPF_AND, dst_reg, 1); 328 + BUILD_BUG_ON(sizeof_field(struct sk_buff, vlan_all) != 4); 329 + *insn++ = BPF_LDX_MEM(BPF_W, dst_reg, src_reg, 330 + offsetof(struct sk_buff, vlan_all)); 331 + *insn++ = BPF_JMP_IMM(BPF_JEQ, dst_reg, 0, 1); 332 + *insn++ = BPF_ALU32_IMM(BPF_MOV, dst_reg, 1); 333 333 break; 334 334 } 335 335 ··· 9290 9290 break; 9291 9291 9292 9292 case offsetof(struct __sk_buff, vlan_present): 9293 - *target_size = 1; 9294 - *insn++ = BPF_LDX_MEM(BPF_B, si->dst_reg, si->src_reg, 9295 - PKT_VLAN_PRESENT_OFFSET); 9296 - if (PKT_VLAN_PRESENT_BIT) 9297 - *insn++ = BPF_ALU32_IMM(BPF_RSH, si->dst_reg, PKT_VLAN_PRESENT_BIT); 9298 - if (PKT_VLAN_PRESENT_BIT < 7) 9299 - *insn++ = BPF_ALU32_IMM(BPF_AND, si->dst_reg, 1); 9293 + *insn++ = BPF_LDX_MEM(BPF_W, si->dst_reg, si->src_reg, 9294 + bpf_target_off(struct sk_buff, 9295 + vlan_all, 4, target_size)); 9296 + *insn++ = BPF_JMP_IMM(BPF_JEQ, si->dst_reg, 0, 1); 9297 + *insn++ = BPF_ALU32_IMM(BPF_MOV, si->dst_reg, 1); 9300 9298 break; 9301 9299 9302 9300 case offsetof(struct __sk_buff, vlan_tci):
+1 -3
net/core/gro.c
··· 370 370 } 371 371 372 372 diffs = (unsigned long)p->dev ^ (unsigned long)skb->dev; 373 - diffs |= skb_vlan_tag_present(p) ^ skb_vlan_tag_present(skb); 374 - if (skb_vlan_tag_present(p)) 375 - diffs |= skb_vlan_tag_get(p) ^ skb_vlan_tag_get(skb); 373 + diffs |= p->vlan_all ^ skb->vlan_all; 376 374 diffs |= skb_metadata_differs(p, skb); 377 375 if (maclen == ETH_HLEN) 378 376 diffs |= compare_ether_header(skb_mac_header(p),