From: Vadim Fedorenko <vadim.fedorenko@linux.dev>
To: Simon Horman <horms@kernel.org>
Cc: Martin KaFai Lau <martin.lau@linux.dev>,
Andrii Nakryiko <andrii@kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Mykola Lysenko <mykolal@fb.com>, Jakub Kicinski <kuba@kernel.org>,
bpf@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH bpf-next 1/2] bpf: add CHECKSUM_COMPLETE to bpf test progs
Date: Wed, 22 May 2024 22:21:53 +0100 [thread overview]
Message-ID: <8fdc5079-149b-4690-9036-c906059659e1@linux.dev> (raw)
In-Reply-To: <20240522183207.GB883722@kernel.org>
On 22/05/2024 19:32, Simon Horman wrote:
> On Wed, May 22, 2024 at 07:57:10AM -0700, Vadim Fedorenko wrote:
>> Add special flag to validate that TC BPF program properly updates
>> checksum information in skb.
>>
>> Signed-off-by: Vadim Fedorenko <vadfed@meta.com>
>
> ...
>
>> diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
>> index f6aad4ed2ab2..841552785c65 100644
>> --- a/net/bpf/test_run.c
>> +++ b/net/bpf/test_run.c
>> @@ -974,10 +974,13 @@ int bpf_prog_test_run_skb(struct bpf_prog *prog, const union bpf_attr *kattr,
>> int hh_len = ETH_HLEN;
>> struct sk_buff *skb;
>> struct sock *sk;
>> + __wsum csum;
>> + __sum16 sum;
>
> Hi Vadim,
>
> sum seems to be is unused in this function.
> And, fwiiw, the scope of csum looks like it could be reduced.
Ah, leftover from previous iteration, thanks for catching it!
Ok, I'll move csum to the "if" block in v2.
>> void *data;
>> int ret;
>>
>> - if (kattr->test.flags || kattr->test.cpu || kattr->test.batch_size)
>> + if ((kattr->test.flags & ~BPF_F_TEST_SKB_CHECKSUM_COMPLETE) ||
>> + kattr->test.cpu || kattr->test.batch_size)
>> return -EINVAL;
>>
>> data = bpf_test_init(kattr, kattr->test.data_size_in,
>> @@ -1025,6 +1028,12 @@ int bpf_prog_test_run_skb(struct bpf_prog *prog, const union bpf_attr *kattr,
>>
>> skb_reserve(skb, NET_SKB_PAD + NET_IP_ALIGN);
>> __skb_put(skb, size);
>> +
>> + if (kattr->test.flags & BPF_F_TEST_SKB_CHECKSUM_COMPLETE) {
>> + skb->csum = skb_checksum(skb, 0, skb->len, 0);
>> + skb->ip_summed = CHECKSUM_COMPLETE;
>> + }
>> +
>> if (ctx && ctx->ifindex > 1) {
>> dev = dev_get_by_index(net, ctx->ifindex);
>> if (!dev) {
>> @@ -1079,6 +1088,14 @@ int bpf_prog_test_run_skb(struct bpf_prog *prog, const union bpf_attr *kattr,
>> }
>> convert_skb_to___skb(skb, ctx);
>>
>> + if (kattr->test.flags & BPF_F_TEST_SKB_CHECKSUM_COMPLETE) {
>> + csum = skb_checksum(skb, 0, skb->len, 0);
>> + if (skb->csum != csum) {
>> + ret = -EINVAL;
>> + goto out;
>> + }
>> + }
>> +
>> size = skb->len;
>> /* bpf program can never convert linear skb to non-linear */
>> if (WARN_ON_ONCE(skb_is_nonlinear(skb)))
>
> ...
next prev parent reply other threads:[~2024-05-22 21:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-22 14:57 [PATCH bpf-next 1/2] bpf: add CHECKSUM_COMPLETE to bpf test progs Vadim Fedorenko
2024-05-22 14:57 ` [PATCH bpf-next 2/2] selftests: bpf: validate CHECKSUM_COMPLETE option Vadim Fedorenko
2024-05-22 18:32 ` [PATCH bpf-next 1/2] bpf: add CHECKSUM_COMPLETE to bpf test progs Simon Horman
2024-05-22 21:21 ` Vadim Fedorenko [this message]
2024-05-23 14:22 ` kernel test robot
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=8fdc5079-149b-4690-9036-c906059659e1@linux.dev \
--to=vadim.fedorenko@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=martin.lau@linux.dev \
--cc=mykolal@fb.com \
--cc=netdev@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).