mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Alexis Lothoré" <alexis.lothore@bootlin.com>
To: "Madhav Khosla" <madhav.khoslaa@gmail.com>, <ast@kernel.org>,
	<daniel@iogearbox.net>, <andrii@kernel.org>
Cc: <alexis.lothore@bootlin.com>,
	"Eduard Zingerman" <eddyz87@gmail.com>,
	"Ihor Solodrai" <ihor.solodrai@linux.dev>,
	"Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
	"Martin KaFai Lau" <martin.lau@linux.dev>,
	"Song Liu" <song@kernel.org>,
	"Yonghong Song" <yonghong.song@linux.dev>,
	"Jiri Olsa" <jolsa@kernel.org>,
	"Emil Tsalapatis" <emil@etsalapatis.com>,
	"Shuah Khan" <shuah@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Jesper Dangaard Brouer" <hawk@kernel.org>,
	"John Fastabend" <john.fastabend@gmail.com>,
	"Stanislav Fomichev" <sdf@fomichev.me>,
	"open list:BPF [SELFTESTS] (Test Runners & Infrastructure)"
	<bpf@vger.kernel.org>,
	"open list:KERNEL SELFTEST FRAMEWORK"
	<linux-kselftest@vger.kernel.org>,
	"open list" <linux-kernel@vger.kernel.org>,
	"open list:XDP (eXpress Data Path):Keyword:(?:b|_)xdp(?:b|_)"
	<netdev@vger.kernel.org>
Subject: Re: [PATCH v2 bpf] selftests/bpf: Fix csum_partial() dropping trailing byte on odd length
Date: Fri, 18 Sep 2026 08:38:17 +0200	[thread overview]
Message-ID: <DLI8HIES5WAV.3A4W5G22Z6I1H@bootlin.com> (raw)
In-Reply-To: <20260916112554.413933-1-madhav.khoslaa@gmail.com>

Hi Madhav,

On Wed Sep 16, 2026 at 1:25 PM CEST, Madhav Khosla wrote:
> csum_partial() computes num_u16 = len >> 1 and only sums that many
> 16-bit words, so the last byte of an odd-length buffer never gets
> added to the checksum. RFC 1071 says it should be padded with a zero
> byte and summed as one more word, not dropped.
>
> This backs build_ip_csum(), build_udp_v4_csum() and
> build_udp_v6_csum(), used by flow_dissector_classification.c and
> xdp_metadata.c to hand-build packets. No current caller builds an
> odd-length payload, so nothing fails today, but a future one would
> get a silently wrong checksum.
>
> Also bump flow_dissector_classification's TEST_PACKET_LEN from 100 to
> 99 so this actually gets exercised instead of staying latent.

Great, thanks for the update.

> Without the fix and with TEST_PACKET_LEN=99, flow_dissector_classification
> fails under vmtest.sh:
>
>     test_flow_dissector_classification:FAIL:test third port unexpected
>     test third port: actual 0 != expected 10
>     #137/6   flow_dissector_classification/ipv6:FAIL
>     #137     flow_dissector_classification:FAIL
>     Summary: 1/0 PASSED, 0 SKIPPED, 1/6 FAILED
>
> Kernel just drops the packet over a bad checksum. With the fix, both
> flow_dissector_classification and xdp_metadata pass.
>
> v1 -> v2:
> - comment style: opening /* on its own line, per BPF selftests style
> - Retarget the Fixes tag to bcc00987bc56. commit f4504af68575
>   ("selftests/bpf: move ip checksum helper to network helpers") moved
>   the helper, but sizeof(iphdr) is always a multiple of 32 bit words /
>   4 Bytes (iph->ihl counts in 4-byte words), so the odd-length path
>   was never reachable through build_ip_csum(). csum_partial() first
>   gets called with a length that isn't guaranteed even in
>   bcc00987bc56, via build_udp_v4_csum()/build_udp_v6_csum().
> - TEST_PACKET_LEN 100 -> 99 so an existing test catches this instead
>   of the bug staying unexercised

Could you please move the patch changelog under --- so it does not end
up in the commit once it is merged ? You can also drop the Link tag, one
will automatically be added on the latest revision once it is merged.

Up to some extent, you could also move the ./test_progs sample output in
the comments under --- as well.

> Fixes: bcc00987bc56 ("selftests/bpf: add network helpers to generate udp checksums")

You chose to use bcc00987bc56 rather than e2a46d54d7a1, but I guess it
is ok.

> Link: https://lore.kernel.org/bpf/DLG5TIIHIMC2.2YCCY0UX86YQF@bootlin.com/T/#t
> Signed-off-by: Madhav Khosla <madhav.khoslaa@gmail.com>

Thanks,

Alexis

-- 
Alexis Lothoré, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


      parent reply	other threads:[~2026-09-18  6:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-16 11:25 Madhav Khosla
2026-09-16 12:13 ` bot+bpf-ci
2026-09-16 16:24   ` Madhav Khosla
2026-09-18  6:38 ` Alexis Lothoré [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DLI8HIES5WAV.3A4W5G22Z6I1H@bootlin.com \
    --to=alexis.lothore@bootlin.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=hawk@kernel.org \
    --cc=ihor.solodrai@linux.dev \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=madhav.khoslaa@gmail.com \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=sdf@fomichev.me \
    --cc=shuah@kernel.org \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®