bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Question about the release of BPF_MAP_TYPE_STRUCT_OPS fd
@ 2021-09-28 14:13 Hou Tao
  2021-09-28 18:33 ` Martin KaFai Lau
  0 siblings, 1 reply; 2+ messages in thread
From: Hou Tao @ 2021-09-28 14:13 UTC (permalink / raw)
  To: Martin KaFai Lau; +Cc: netdev, bpf

Hi Martin,

During the testing of bpf_tcp_ca, I found that if the test program
aborts before calling bpf_link__detach_struct_ops(), the registered
bpf_dctcp will not be unregistered, and running bpf_tcp_ca test again
will fail with -EEXIST error as shown below:

test_dctcp:PASS:bpf_dctcp__open_and_load 0 nsec
test_dctcp:FAIL:bpf_map__attach_struct_ops unexpected error: -17

The root cause is that the release of BPF_MAP_TYPE_STRUCT_OPS fd
neither put struct_ops programs in maps nor unregister the struct_ops
from kernel. Was the implementation intentional, or was it an oversight ?
If it is an oversight, I will post a patch to fix it.

Regards,
Tao

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Question about the release of BPF_MAP_TYPE_STRUCT_OPS fd
  2021-09-28 14:13 Question about the release of BPF_MAP_TYPE_STRUCT_OPS fd Hou Tao
@ 2021-09-28 18:33 ` Martin KaFai Lau
  0 siblings, 0 replies; 2+ messages in thread
From: Martin KaFai Lau @ 2021-09-28 18:33 UTC (permalink / raw)
  To: Hou Tao; +Cc: netdev, bpf

On Tue, Sep 28, 2021 at 10:13:45PM +0800, Hou Tao wrote:
> Hi Martin,
> 
> During the testing of bpf_tcp_ca, I found that if the test program
> aborts before calling bpf_link__detach_struct_ops(), the registered
> bpf_dctcp will not be unregistered, and running bpf_tcp_ca test again
> will fail with -EEXIST error as shown below:
> 
> test_dctcp:PASS:bpf_dctcp__open_and_load 0 nsec
> test_dctcp:FAIL:bpf_map__attach_struct_ops unexpected error: -17
> 
> The root cause is that the release of BPF_MAP_TYPE_STRUCT_OPS fd
> neither put struct_ops programs in maps nor unregister the struct_ops
> from kernel. Was the implementation intentional, or was it an oversight ?
> If it is an oversight, I will post a patch to fix it.
The original use case for the struct_ops is to register and unregister
by command like "bpftool struct_ops (un)register" and then
the kernel sub-system (tcp here) owns it, instead of finding where the maps
may be pinned (could be in multiple locations).  More like the insmod/rmmod.

I think you meant to unregister it in ".map_release_uref"? but it will break
the existing contract above.  I believe a better way to do the auto-unreg
is to create a real bpf_link for struct_ops.  bpf_link has been added to
the xdp and cgroup attachments since then.  I did not give too much
thoughts on this yet.

What bpf-tcp-cc are you implementing
or it is for running the test_progs purpose only ?

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-28 18:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-28 14:13 Question about the release of BPF_MAP_TYPE_STRUCT_OPS fd Hou Tao
2021-09-28 18:33 ` Martin KaFai Lau

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).