Messages in this thread Patch in this message | | | From | shaozhengchao <> | Subject | 答复: [PATCH bpf-next] samples/bpf: detach xdp prog when program exits unexpectedly in x dp rxq info user | Date | Wed, 27 Apr 2022 00:45:39 +0000 |
| |
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>
[...]
| |