All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jose E. Marchesi" <jose.marchesi@oracle.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: bpf <bpf@vger.kernel.org>, David Faust <david.faust@oracle.com>,
	Cupertino Miranda <cupertino.miranda@oracle.com>
Subject: Re: process_l3_headers_v6 in test_xdp_noinline.c
Date: Wed, 24 Apr 2024 22:12:53 +0200	[thread overview]
Message-ID: <87bk5y7c56.fsf@oracle.com> (raw)
In-Reply-To: <CAADnVQJqFYP2JraX+41VL=MWbZKFSMSNh=-skcQWY570xB7NFQ@mail.gmail.com> (Alexei Starovoitov's message of "Wed, 24 Apr 2024 12:37:24 -0700")


> On Wed, Apr 24, 2024 at 5:25 AM Jose E. Marchesi
> <jose.marchesi@oracle.com> wrote:
>>
>>
>> Hello.
>> The following function in the BPF selftest progs/test_xdp_noinline.c:
>>
>>   /* don't believe your eyes!
>>    * below function has 6 arguments whereas bpf and llvm allow maximum of 5
>>    * but since it's _static_ llvm can optimize one argument away
>>    */
>>   __attribute__ ((noinline))
>>   static int process_l3_headers_v6(struct packet_description *pckt,
>>                                  __u8 *protocol, __u64 off,
>>                                  __u16 *pkt_bytes, void *data,
>>                                  void *data_end)
>>   {
>>         struct ipv6hdr *ip6h;
>>         __u64 iph_len;
>>         int action;
>>
>>         ip6h = data + off;
>>         if (ip6h + 1 > data_end)
>>                 return XDP_DROP;
>>         iph_len = sizeof(struct ipv6hdr);
>>         *protocol = ip6h->nexthdr;
>>         pckt->flow.proto = *protocol;
>>         *pkt_bytes = bpf_ntohs(ip6h->payload_len);
>>         off += iph_len;
>>         if (*protocol == 45) {
>>                 return XDP_DROP;
>>         } else if (*protocol == 59) {
>>                 action = parse_icmpv6(data, data_end, off, pckt);
>>                 if (action >= 0)
>>                         return action;
>>         } else {
>>                 memcpy(pckt->flow.srcv6, ip6h->saddr.in6_u.u6_addr32, 16);
>>                 memcpy(pckt->flow.dstv6, ip6h->daddr.in6_u.u6_addr32, 16);
>>         }
>>         return -1;
>>   }
>>
>> Relies, as acknowledged in the comment block, on LLVM optimizing out one
>> of the arguments.  As it happens GCC doesn't optimize that argument out,
>> and as a result it fails at compile-time when building
>> tst_xdp_noinline.c.
>>
>> Would it be possible to rewrite this particular test to not rely on that
>> particular optimization?
>
> Feel free to send a patch that reduces it to 5 args.
> This test was a copy paste of katran.
> There was no intent to test this 6->5 llvm optimization.

Ok perfect.  Will do.  Thanks!

      reply	other threads:[~2024-04-24 20:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-24 12:24 process_l3_headers_v6 in test_xdp_noinline.c Jose E. Marchesi
2024-04-24 19:37 ` Alexei Starovoitov
2024-04-24 20:12   ` Jose E. Marchesi [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=87bk5y7c56.fsf@oracle.com \
    --to=jose.marchesi@oracle.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=cupertino.miranda@oracle.com \
    --cc=david.faust@oracle.com \
    /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.