From: Yonghong Song <yhs@fb.com>
To: Muhammad Falak Reyaz <falakreyaz@gmail.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>, <bpf@vger.kernel.org>,
"open list:NETWORKING DRIVERS" <netdev@vger.kernel.org>,
KP Singh <kpsingh@kernel.org>, Song Liu <songliubraving@fb.com>,
Martin KaFai Lau <kafai@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
Jesper Dangaard Brouer <hawk@kernel.org>,
Jakub Kicinski <kuba@kernel.org>,
"David S . Miller" <davem@davemloft.net>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] samples: bpf: xdp1: remove duplicate code to find protocol
Date: Sun, 8 Aug 2021 17:01:29 -0700 [thread overview]
Message-ID: <4c897a6a-6f5e-b990-7c36-4258a26e1752@fb.com> (raw)
In-Reply-To: <CAOmbKqkYDXvMQntk39Ud-63G3ju+Kti2A8UFNodgJ6y1+4=AeA@mail.gmail.com>
On 8/8/21 10:19 AM, Muhammad Falak Reyaz wrote:
> On Sun, Aug 8, 2021 at 10:23 PM Yonghong Song <yhs@fb.com> wrote:
>>
>>
>>
>> On 8/8/21 5:24 AM, Muhammad Falak R Wani wrote:
>>> The code to find h_vlan_encapsulated_proto is duplicated.
>>> Remove the extra block.
>>>
>>> Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
>>> ---
>>> samples/bpf/xdp1_kern.c | 9 ---------
>>> 1 file changed, 9 deletions(-)
>>>
>>> diff --git a/samples/bpf/xdp1_kern.c b/samples/bpf/xdp1_kern.c
>>> index 34b64394ed9c..a35e064d7726 100644
>>> --- a/samples/bpf/xdp1_kern.c
>>> +++ b/samples/bpf/xdp1_kern.c
>>> @@ -57,15 +57,6 @@ int xdp_prog1(struct xdp_md *ctx)
>>>
>>> h_proto = eth->h_proto;
>>>
>>> - if (h_proto == htons(ETH_P_8021Q) || h_proto == htons(ETH_P_8021AD)) {
>>> - struct vlan_hdr *vhdr;
>>> -
>>> - vhdr = data + nh_off;
>>> - nh_off += sizeof(struct vlan_hdr);
>>> - if (data + nh_off > data_end)
>>> - return rc;
>>> - h_proto = vhdr->h_vlan_encapsulated_proto;
>>
>> No. This is not a duplicate. The h_proto in the above line will be used
>> in the below "if" condition.
>>
>>> - }
>>> if (h_proto == htons(ETH_P_8021Q) || h_proto == htons(ETH_P_8021AD)) {
>>> struct vlan_hdr *vhdr;
>>>
>>>
> Apologies :(
> I now realize, it could be double vlan encapsulated.
> Would it make sense to add an explicit comment for newbies like me ?
> I can send a patch, if it is okay.
This is not the first time people sending a patch trying to remove this
"duplicated" code. I think it is okay to send a patch with comments to
say this is intended to handle nested vlan, so we can save everybody's
time. Thanks.
>
> -mfrw
>
prev parent reply other threads:[~2021-08-09 0:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-08 12:24 [PATCH] samples: bpf: xdp1: remove duplicate code to find protocol Muhammad Falak R Wani
2021-08-08 16:53 ` Yonghong Song
2021-08-08 17:19 ` Muhammad Falak Reyaz
2021-08-09 0:01 ` Yonghong Song [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=4c897a6a-6f5e-b990-7c36-4258a26e1752@fb.com \
--to=yhs@fb.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=falakreyaz@gmail.com \
--cc=hawk@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=songliubraving@fb.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 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).