Subject: Re: [PATCH bpf v3 1/2] bpf: Update transport_header when encapsulating UDP tunnel in lwt

From: Leon Hwang <[email-masked]>
Date: Tue, 2 Jun 2026 13:38:58 +0800

On 2/6/26 11:17, Jiayuan Chen wrote:
> 
> On 6/1/26 11:02 PM, Leon Hwang wrote:
[...]
>> @@ -637,6 +644,10 @@ int bpf_lwt_push_ip_encap(struct sk_buff *skb,
>> void *hdr, u32 len, bool ingress)
>>       if (ingress)
>>           skb_postpush_rcsum(skb, iph, len);
>>       skb_reset_network_header(skb);
>> +    if (ipv4 && is_udp_tunnel)
>> +        skb_set_transport_header(skb, skb_network_offset(skb) + iph-
>> >ihl * 4);
>> +    else if (!ipv4 && is_udp_tunnel)
>> +        skb_set_transport_header(skb, skb_network_offset(skb) +
>> sizeof(struct ipv6hdr));
> 
> 
> I think GRE is also affected, why not unconditionally set transport
> header to network_offset + outer_ip_ihl regardless of outer protocol??
> 

Probably, yes. But, I'm not sure about this.

At Shopee, we encountered the issue that the VxLAN packets encapsulated
with lwt-bpf were dropped on ice driver. And, it is to be fixed by this
patch.

IOW, if someone encounter the same issue for GRE packets, he can fix the
issue by the same way.

Thanks,
Leon

>>       memcpy(skb_network_header(skb), hdr, len);
>>       bpf_compute_data_pointers(skb);
>>       skb_clear_hash(skb);