Skip to content

Commit 5848e91

Browse files
ArtisticFantasygregkh
authored andcommitted
ipvs: use parsed transport offset in TCP state lookup
[ Upstream commit 2500fa3 ] TCP state handling reparses the skb to find the TCP header. For IPv6 it uses sizeof(struct ipv6hdr), while the surrounding IPVS code already parsed the packet with ip_vs_fill_iph_skb() and has the real transport-header offset in iph.len. This makes TCP state handling look at the wrong bytes when an IPv6 packet carries extension headers. Use the parsed transport offset passed down from ip_vs_set_state() when reading the TCP header. For IPv4 and for IPv6 packets without extension headers, the passed offset matches the previous value. Fixes: 0bbdd42 ("IPVS: Extend protocol DNAT/SNAT and state handlers") Link: https://lore.kernel.org/netdev/20260705125659.37744-1-zhaoyz24@mails.tsinghua.edu.cn/ Reported-by: Yizhou Zhao <zhaoyz24@mails.tsinghua.edu.cn> Reported-by: Yuxiang Yang <yangyx22@mails.tsinghua.edu.cn> Reported-by: Ao Wang <wangao@seu.edu.cn> Reported-by: Xuewei Feng <fengxw06@126.com> Reported-by: Qi Li <qli01@tsinghua.edu.cn> Reported-by: Ke Xu <xuke@tsinghua.edu.cn> Assisted-by: Claude Code:GLM-5.2 Signed-off-by: Yizhou Zhao <zhaoyz24@mails.tsinghua.edu.cn> Acked-by: Julian Anastasov <ja@ssi.bg> Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent aef993b commit 5848e91

1 file changed

Lines changed: 1 addition & 7 deletions

File tree

net/netfilter/ipvs/ip_vs_proto_tcp.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -585,13 +585,7 @@ tcp_state_transition(struct ip_vs_conn *cp, int direction,
585585
{
586586
struct tcphdr _tcph, *th;
587587

588-
#ifdef CONFIG_IP_VS_IPV6
589-
int ihl = cp->af == AF_INET ? ip_hdrlen(skb) : sizeof(struct ipv6hdr);
590-
#else
591-
int ihl = ip_hdrlen(skb);
592-
#endif
593-
594-
th = skb_header_pointer(skb, ihl, sizeof(_tcph), &_tcph);
588+
th = skb_header_pointer(skb, iph_len, sizeof(_tcph), &_tcph);
595589
if (th == NULL)
596590
return;
597591

0 commit comments

Comments
 (0)