linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: shaozhengchao <shaozhengchao@huawei.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: bpf <bpf@vger.kernel.org>, Networking <netdev@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Jesper Dangaard Brouer <hawk@kernel.org>,
	john fastabend <john.fastabend@gmail.com>,
	Andrii Nakryiko <andrii@kernel.org>, Martin Lau <kafai@fb.com>,
	Song Liu <songliubraving@fb.com>, Yonghong Song <yhs@fb.com>,
	KP Singh <kpsingh@kernel.org>,
	"weiyongjun (A)" <weiyongjun1@huawei.com>,
	yuehaibing <yuehaibing@huawei.com>
Subject: 答复: [PATCH bpf-next] samples/bpf: detach xdp prog when program exits unexpectedly in xdp_rxq_info_user
Date: Wed, 27 Apr 2022 00:45:39 +0000	[thread overview]
Message-ID: <2ba194b97a514384aeca0323c3bd7461@huawei.com> (raw)
In-Reply-To: <CAEf4BzY=VajaEH_09FX0-wuPFCJ6te=shZa0jj2Jc7ukL-WzMQ@mail.gmail.com>

Thank you for your reply.

I will fix the compilation warning firstly, and then convert this sample to skeleton. Thank you very much.

-----邮件原件-----
发件人: Andrii Nakryiko [mailto:andrii.nakryiko@gmail.com] 
发送时间: 2022年4月26日 12:35
收件人: shaozhengchao <shaozhengchao@huawei.com>
抄送: bpf <bpf@vger.kernel.org>; Networking <netdev@vger.kernel.org>; open list <linux-kernel@vger.kernel.org>; Alexei Starovoitov <ast@kernel.org>; Daniel Borkmann <daniel@iogearbox.net>; David S. Miller <davem@davemloft.net>; Jakub Kicinski <kuba@kernel.org>; Jesper Dangaard Brouer <hawk@kernel.org>; john fastabend <john.fastabend@gmail.com>; Andrii Nakryiko <andrii@kernel.org>; Martin Lau <kafai@fb.com>; Song Liu <songliubraving@fb.com>; Yonghong Song <yhs@fb.com>; KP Singh <kpsingh@kernel.org>; weiyongjun (A) <weiyongjun1@huawei.com>; yuehaibing <yuehaibing@huawei.com>
主题: Re: [PATCH bpf-next] samples/bpf: detach xdp prog when program exits unexpectedly in xdp_rxq_info_user

On Thu, Apr 21, 2022 at 5:07 AM Zhengchao Shao <shaozhengchao@huawei.com> wrote:
>
> When xdp_rxq_info_user program exits unexpectedly, it doesn't detach 
> xdp prog of device, and other xdp prog can't be attached to the 
> device. So call init_exit() to detach xdp prog when program exits unexpectedly.
>
> Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
> ---
>  samples/bpf/xdp_rxq_info_user.c | 21 +++++++++++++++------
>  1 file changed, 15 insertions(+), 6 deletions(-)
>

you are introducing a new compilation warning, please fix it


/data/users/andriin/linux/samples/bpf/xdp_rxq_info_user.c: In function
‘options2str’:
/data/users/andriin/linux/samples/bpf/xdp_rxq_info_user.c:153:1:
warning: control reaches end of non-void function [-Wreturn-type]
  153 | }
      | ^

It also would be good to instead use bpf_link-based XDP attachment that would be auto-detached automatically on process crash
(bpf_link_create() FTW). Please consider also converting this sample to skeleton (and then bpf_program__attach_xdp() as high-level alternative to bpf_link_create()).

> diff --git a/samples/bpf/xdp_rxq_info_user.c 
> b/samples/bpf/xdp_rxq_info_user.c index f2d90cba5164..6378007e085a 
> 100644
> --- a/samples/bpf/xdp_rxq_info_user.c
> +++ b/samples/bpf/xdp_rxq_info_user.c
> @@ -18,7 +18,7 @@ static const char *__doc__ = " XDP RX-queue info extract example\n\n"
>  #include <getopt.h>
>  #include <net/if.h>
>  #include <time.h>

[...]

      reply	other threads:[~2022-04-27  0:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-21 12:09 [PATCH bpf-next] samples/bpf: detach xdp prog when program exits unexpectedly in xdp_rxq_info_user Zhengchao Shao
2022-04-26  4:35 ` Andrii Nakryiko
2022-04-27  0:45   ` shaozhengchao [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=2ba194b97a514384aeca0323c3bd7461@huawei.com \
    --to=shaozhengchao@huawei.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --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 \
    --cc=weiyongjun1@huawei.com \
    --cc=yhs@fb.com \
    --cc=yuehaibing@huawei.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).