On Wed, Mar 6, 2024 at 5:21 PM Martin KaFai Lau [off-list ref] wrote:
On 3/6/24 12:22 PM, Jamal Hadi Salim wrote:
quoted
quoted
I think my question was, who can use the act_bpf_kern object when all tc bpf
prog is unloaded? If no one can use it, it should as well be cleaned up when the
bpf prog is unloaded.
or the kernel p4 pipeline can use the act_bpf_kern object even when there is no
bpf prog loaded?
[ ... ]
quoted
quoted
quoted
I am looking at the conntrack code and i dont see how they release
entries from the cotrack table when the bpf prog goes away.
[ ... ]
quoted
I asked earlier about conntrack (where we took the inspiration from):
How is what we are doing different from contrack? If you can help me
understand that i am more than willing to make the change.
Conntrack entries can be added via the kfunc(same for us). Contrack
entries can also be added from the control plane and can be found by
ebpf lookups(same for us). They can be deleted by the control plane,
timers, entry evictions to make space for new entries, etc (same for
us). Not sure if they can be deleted by ebpf side (we can). Perusing
the conntrack code, I could not find anything that indicated that
entries created from ebpf are deleted when the ebpf program goes away.
To re-emphasize: Maybe there's something subtle i am missing that we
are not doing that conntrack is doing?
Conntrack does one small thing we dont: It allocs and returns to ebpf
the memory for insertion. I dont see that as particularly useful for
our case (and more importantly how that results in the entries being
deleted when the ebpf prog goes away)
afaik, the conntrack kfunc inserts "struct nf_conn" that can also be used by
other kernel parts, so it is reasonable to go through the kernel existing
eviction logic. It is why my earlier question on "is the act_bpf_kern object
only useful for the bpf prog alone but not other kernel parts". From reading
patch 14, it seems to be only usable by bpf prog. When all bpf program is
unloaded, who will still read it and do something useful? If I mis-understood
it, this will be useful to capture in the commit message to explain how it could
be used by other kernel parts without bpf prog running.
Ok, I think i may have got the issue. Sigh. I didnt do a good job
explaining p4tc_table_entry_act_bpf_kern which has been the crux of
our back and forth. Sorry I know you said this several times and i was
busy describing things around it instead.
A multiple of these structure p4tc_table_entry_act_bpf_kern are
preallocated(to match the P4 architecture, patch #9 describes some of
the subtleties involved) by the p4tc control plane and put in a kernel
pool. Their purpose is to hold the action parameters that are returned
to ebpf when there is a successful table lookup. When the table entry
is deleted the act_bpf_kern is recycled to a pool to be reused for the
next table entry. The only time the pool memory is released is when
the pipeline is deleted. So it is not allocated via the kfunc at all.
I am not sure if that helps, if it does and you feel it should go in
the commit message we can do that. If not, please a little more
patience with me..
cheers,
jamal