答复: [PATCH bpf-next] bpf/xdp: Can't detach BPF XDP prog if not exist

From: shaozhengchao
Date: Thu May 05 2022 - 04:22:57 EST



-----邮件原件-----
发件人: Toke Høiland-Jørgensen [mailto:toke@xxxxxxxxxx]
发送时间: 2022年5月4日 19:20
收件人: shaozhengchao <shaozhengchao@xxxxxxxxxx>; netdev@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx; bpf@xxxxxxxxxxxxxxx; davem@xxxxxxxxxxxxx; edumazet@xxxxxxxxxx; kuba@xxxxxxxxxx; pabeni@xxxxxxxxxx
抄送: ast@xxxxxxxxxx; daniel@xxxxxxxxxxxxx; hawk@xxxxxxxxxx; john.fastabend@xxxxxxxxx; andrii@xxxxxxxxxx; kafai@xxxxxx; songliubraving@xxxxxx; yhs@xxxxxx; kpsingh@xxxxxxxxxx; bigeasy@xxxxxxxxxxxxx; imagedong@xxxxxxxxxxx; petrm@xxxxxxxxxx; memxor@xxxxxxxxx; arnd@xxxxxxxx; weiyongjun (A) <weiyongjun1@xxxxxxxxxx>; shaozhengchao <shaozhengchao@xxxxxxxxxx>; yuehaibing <yuehaibing@xxxxxxxxxx>
主题: Re: [PATCH bpf-next] bpf/xdp: Can't detach BPF XDP prog if not exist

Zhengchao Shao <shaozhengchao@xxxxxxxxxx> writes:

> if user sets nonexistent xdp_flags to detach xdp prog, kernel should
> return err and tell user that detach failed with detail info.
>
> Signed-off-by: Zhengchao Shao <shaozhengchao@xxxxxxxxxx>

I kinda see your point, but this will change user-visible behaviour that applications might be relying on, so I don't think we can make this change at this stage. Why can't your application just query the link for whether a program is attached?

-Toke


Thank you for your reply. I wiil change sample application firstly. But if kernel does nothing and return 0, maybe user will think setup is OK, actually It failed. Is this acceptable?