From: Martin KaFai Lau Date: Wed, 29 Jan 2025 21:31:19 +0000 (-0800) Subject: Merge branch 'bpf-fix-wrong-copied_seq-calculation-and-add-tests' X-Git-Tag: v6.14-rc4~19^2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9bf412d4d5b1f431e6cdd8111094be39c031036c;p=thirdparty%2Flinux.git Merge branch 'bpf-fix-wrong-copied_seq-calculation-and-add-tests' Jiayuan Chen says: ==================== A previous commit described in this topic http://lore.kernel.org/bpf/20230523025618.113937-9-john.fastabend@gmail.com directly updated 'sk->copied_seq' in the tcp_eat_skb() function when the action of a BPF program was SK_REDIRECT. For other actions, like SK_PASS, the update logic for 'sk->copied_seq' was moved to tcp_bpf_recvmsg_parser() to ensure the accuracy of the 'fionread' feature. That commit works for a single stream_verdict scenario, as it also modified 'sk_data_ready->sk_psock_verdict_data_ready->tcp_read_skb' to remove updating 'sk->copied_seq'. However, for programs where both stream_parser and stream_verdict are active (strparser purpose), tcp_read_sock() was used instead of tcp_read_skb() (sk_data_ready->strp_data_ready->tcp_read_sock). tcp_read_sock() now still updates 'sk->copied_seq', leading to duplicated updates. In summary, for strparser + SK_PASS, copied_seq is redundantly calculated in both tcp_read_sock() and tcp_bpf_recvmsg_parser(). The issue causes incorrect copied_seq calculations, which prevent correct data reads from the recv() interface in user-land. Also we added test cases for bpf + strparser and separated them from sockmap_basic, as strparser has more encapsulation and parsing capabilities compared to sockmap. ==================== Link: https://patch.msgid.link/20250122100917.49845-1-mrpre@163.com Signed-off-by: Martin KaFai Lau --- 9bf412d4d5b1f431e6cdd8111094be39c031036c