lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20802d12-004a-4b04-9b7d-93dc8b9866df@bootlin.com>
Date: Tue, 19 Nov 2024 09:57:09 +0100
From: Alexis Lothoré <alexis.lothore@...tlin.com>
To: Stanislav Fomichev <stfomichev@...il.com>
Cc: Andrii Nakryiko <andrii@...nel.org>, Eduard Zingerman
 <eddyz87@...il.com>, Mykola Lysenko <mykolal@...com>,
 Alexei Starovoitov <ast@...nel.org>, Daniel Borkmann <daniel@...earbox.net>,
 Martin KaFai Lau <martin.lau@...ux.dev>, Song Liu <song@...nel.org>,
 Yonghong Song <yonghong.song@...ux.dev>,
 John Fastabend <john.fastabend@...il.com>, KP Singh <kpsingh@...nel.org>,
 Stanislav Fomichev <sdf@...ichev.me>, Hao Luo <haoluo@...gle.com>,
 Jiri Olsa <jolsa@...nel.org>, Shuah Khan <shuah@...nel.org>,
 "David S. Miller" <davem@...emloft.net>, Jakub Kicinski <kuba@...nel.org>,
 Jesper Dangaard Brouer <hawk@...nel.org>, ebpf@...uxfoundation.org,
 Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
 Bastien Curutchet <bastien.curutchet@...tlin.com>, bpf@...r.kernel.org,
 linux-kselftest@...r.kernel.org, linux-kernel@...r.kernel.org,
 netdev@...r.kernel.org
Subject: Re: [PATCH bpf-next v2 11/13] selftests/bpf: add network helpers to
 generate udp checksums

On 11/15/24 16:54, Stanislav Fomichev wrote:
> On 11/14, Alexis Lothoré (eBPF Foundation) wrote:
>> +static inline __sum16 build_udp_v4_csum(const struct iphdr *iph, __u8 l4_proto,
>> +					__u16 l4_len, const void *l4_start,
>> +					int num_words)
>> +{
>> +	unsigned long pseudo_sum;
>> +	int num_u16 = sizeof(iph->saddr); /* halfwords: twice byte len */
>> +
>> +	pseudo_sum = add_csum_hword((void *)&iph->saddr, num_u16);
>> +	pseudo_sum += htons(l4_proto);
>> +	pseudo_sum += l4_len;
>> +	pseudo_sum += add_csum_hword(l4_start, num_words);
>> +	return csum_fold(pseudo_sum);
> 
> I was expecting to see a call to csum_tcpudp_magic here. And csum_ipv6_magic
> down below. These build pseudo header csum, so no need to manually do it
> again.

I initially tried to fit csum_tcpudp_magic here and did not manage to make a
valid UDP checksum, but after more attempts, it looks like I had a
misunderstanding this checksum computation. I am now able to used
csum_tcpudp_magic in build_udp_v4_csum, it will be fixed in the next revision :)

Thanks,

Alexis

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ