All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martin KaFai Lau <martin.lau@linux.dev>
To: "Asbjørn Sloth Tønnesen" <ast@fiberby.net>,
	"Toke Høiland-Jørgensen" <toke@kernel.org>
Cc: bpf@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>, Song Liu <song@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	Stanislav Fomichev <sdf@fomichev.me>, Hao Luo <haoluo@google.com>,
	Jiri Olsa <jolsa@kernel.org>, Mykola Lysenko <mykolal@fb.com>,
	Shuah Khan <shuah@kernel.org>,
	Tushar Vyavahare <tushar.vyavahare@intel.com>,
	Magnus Karlsson <magnus.karlsson@intel.com>,
	Willem de Bruijn <willemb@google.com>,
	netdev@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH bpf-next] selftests/bpf: Avoid subtraction after htons() in ipip tests
Date: Tue, 13 Aug 2024 18:15:54 -0700	[thread overview]
Message-ID: <77a5dbd2-7792-486c-b161-76e2262b67a7@linux.dev> (raw)
In-Reply-To: <87sevfpdti.fsf@toke.dk>

On 8/8/24 2:24 AM, Toke Høiland-Jørgensen wrote:
> Asbjørn Sloth Tønnesen <ast@fiberby.net> writes:
> 
>> On little-endian systems, doing subtraction after htons()
>> leads to interesting results:
>>
>> Given:
>>    MAGIC_BYTES = 123 = 0x007B aka. in big endian: 0x7B00 = 31488
>>    sizeof(struct iphdr) = 20
>>
>> Before this patch:
>> __bpf_constant_htons(MAGIC_BYTES) - sizeof(struct iphdr) = 0x7AEC
>> 0x7AEC = htons(0xEC7A) = htons(60538)
>>
>> So these were outer IP packets with a total length of 123 bytes,
>> containing an inner IP packet with a total length of 60538 bytes.
> 
> It's just using bag of holding technology!
> 
>> After this patch:
>> __bpf_constant_htons(MAGIC_BYTES - sizeof(struct iphdr)) = htons(103)
>>
>> Now these packets are outer IP packets with a total length of 123 bytes,
>> containing an inner IP packet with a total length of 103 bytes.
>>
>> Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
> 
> Reviewed-by: Toke Høiland-Jørgensen <toke@kernel.org>

Applied to bpf-next/net. Thanks.


      reply	other threads:[~2024-08-14  1:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-08  7:59 [PATCH bpf-next] selftests/bpf: Avoid subtraction after htons() in ipip tests Asbjørn Sloth Tønnesen
2024-08-08  9:24 ` Toke Høiland-Jørgensen
2024-08-14  1:15   ` Martin KaFai Lau [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=77a5dbd2-7792-486c-b161-76e2262b67a7@linux.dev \
    --to=martin.lau@linux.dev \
    --cc=andrii@kernel.org \
    --cc=ast@fiberby.net \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=magnus.karlsson@intel.com \
    --cc=mykolal@fb.com \
    --cc=netdev@vger.kernel.org \
    --cc=sdf@fomichev.me \
    --cc=shuah@kernel.org \
    --cc=song@kernel.org \
    --cc=toke@kernel.org \
    --cc=tushar.vyavahare@intel.com \
    --cc=willemb@google.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.