public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: shaozhengchao <shaozhengchao@huawei•com>
To: "Toke Høiland-Jørgensen" <toke@kernel•org>,
	"bpf@vger•kernel.org" <bpf@vger•kernel.org>,
	"netdev@vger•kernel.org" <netdev@vger•kernel.org>,
	"linux-kernel@vger•kernel.org" <linux-kernel@vger•kernel.org>,
	"ast@kernel•org" <ast@kernel•org>,
	"daniel@iogearbox•net" <daniel@iogearbox•net>,
	"davem@davemloft•net" <davem@davemloft•net>,
	"kuba@kernel•org" <kuba@kernel•org>,
	"hawk@kernel•org" <hawk@kernel•org>,
	"john.fastabend@gmail•com" <john.fastabend@gmail•com>,
	"andrii@kernel•org" <andrii@kernel•org>,
	"kafai@fb•com" <kafai@fb•com>,
	"songliubraving@fb•com" <songliubraving@fb•com>,
	"yhs@fb•com" <yhs@fb•com>,
	"kpsingh@kernel•org" <kpsingh@kernel•org>
Cc: "weiyongjun (A)" <weiyongjun1@huawei•com>,
	yuehaibing <yuehaibing@huawei•com>
Subject: 答复: 答复: [PATCH bpf-next] samples/bpf: check detach prog exist or not in xdp_fwd
Date: Tue, 17 May 2022 02:00:52 +0000	[thread overview]
Message-ID: <942eaafecf074ae8a5bb336c18658453@huawei.com> (raw)
In-Reply-To: <87h75zynz2.fsf@toke.dk>



-----邮件原件-----
发件人: Toke Høiland-Jørgensen [mailto:toke@kernel•org] 
发送时间: 2022年5月9日 18:55
收件人: shaozhengchao <shaozhengchao@huawei•com>; bpf@vger•kernel.org; netdev@vger•kernel.org; linux-kernel@vger•kernel.org; ast@kernel•org; daniel@iogearbox•net; davem@davemloft•net; kuba@kernel•org; hawk@kernel•org; john.fastabend@gmail•com; andrii@kernel•org; kafai@fb•com; songliubraving@fb•com; yhs@fb•com; kpsingh@kernel•org
抄送: weiyongjun (A) <weiyongjun1@huawei•com>; yuehaibing <yuehaibing@huawei•com>
主题: Re: 答复: [PATCH bpf-next] samples/bpf: check detach prog exist or not in xdp_fwd

shaozhengchao <shaozhengchao@huawei•com> writes:

> -----邮件原件-----
> 发件人: Toke Høiland-Jørgensen [mailto:toke@kernel•org]
> 发送时间: 2022年5月9日 17:46
> 收件人: shaozhengchao <shaozhengchao@huawei•com>; bpf@vger•kernel.org; 
> netdev@vger•kernel.org; linux-kernel@vger•kernel.org; ast@kernel•org; 
> daniel@iogearbox•net; davem@davemloft•net; kuba@kernel•org; 
> hawk@kernel•org; john.fastabend@gmail•com; andrii@kernel•org; 
> kafai@fb•com; songliubraving@fb•com; yhs@fb•com; kpsingh@kernel•org
> 抄送: weiyongjun (A) <weiyongjun1@huawei•com>; shaozhengchao 
> <shaozhengchao@huawei•com>; yuehaibing <yuehaibing@huawei•com>
> 主题: Re: [PATCH bpf-next] samples/bpf: check detach prog exist or not 
> in xdp_fwd
>
> Zhengchao Shao <shaozhengchao@huawei•com> writes:
>
>> Before detach the prog, we should check detach prog exist or not.
>
> If we're adding such a check we should also check that it's the *right* program. I.e., query the ID for the program name and check that it matches what the program attached, then obtain an fd and pass that as XDP_EXPECTED_FD on detach to make sure it wasn't swapped out in the meantime...
>
> -Toke
>
> Thank you for your reply. When finish running xdp_fwd to attatch prog, 
> the program will exit and can't store fd as XDP_EXPECTED_FD.
>
> I think the sample xdp_fwd -d is just detach prog and don't care if 
> the fd is expected.

So why are you adding the check? Either keep it the way it is, or add a proper check that examines the program type; you're right that it doesn't store the prog FD, but you can still check the program name and see if it matches to get some idea that it's not a totally separate program that's loaded. I think doing so would be an improvement to the sample, but just adding a check if a program is loaded is not, really...

-Toke


Could I add helper function to implement this function which can check the program name and see if it attach to the device.

-Zhengchao Shao

  reply	other threads:[~2022-05-17  2:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-09  0:51 [PATCH bpf-next] samples/bpf: check detach prog exist or not in xdp_fwd Zhengchao Shao
2022-05-09  9:46 ` Toke Høiland-Jørgensen
2022-05-09 10:27   ` 答复: " shaozhengchao
2022-05-09 10:55     ` Toke Høiland-Jørgensen
2022-05-17  2:00       ` shaozhengchao [this message]
2022-05-17  9:42         ` 答复: " Toke Høiland-Jørgensen

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=942eaafecf074ae8a5bb336c18658453@huawei.com \
    --to=shaozhengchao@huawei$(echo .)com \
    --cc=andrii@kernel$(echo .)org \
    --cc=ast@kernel$(echo .)org \
    --cc=bpf@vger$(echo .)kernel.org \
    --cc=daniel@iogearbox$(echo .)net \
    --cc=davem@davemloft$(echo .)net \
    --cc=hawk@kernel$(echo .)org \
    --cc=john.fastabend@gmail$(echo .)com \
    --cc=kafai@fb$(echo .)com \
    --cc=kpsingh@kernel$(echo .)org \
    --cc=kuba@kernel$(echo .)org \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=songliubraving@fb$(echo .)com \
    --cc=toke@kernel$(echo .)org \
    --cc=weiyongjun1@huawei$(echo .)com \
    --cc=yhs@fb$(echo .)com \
    --cc=yuehaibing@huawei$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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