bpf_net_helpers: introduce bpf_get_netns_cookie() helper
Linux Kernel documentation states:
* u64 bpf_get_netns_cookie(void *ctx)
Description
Retrieve the cookie (generated by the kernel) of the network
namespace the input *ctx* is associated with. The network
namespace cookie remains stable for its lifetime and provides
a global identifier that can be assumed unique. If *ctx* is
NULL, then the helper returns the cookie for the initial
network namespace. The cookie itself is very similar to that
of **bpf_get_socket_cookie**\ () helper, but for network
namespaces instead of sockets.
Return
A 8-byte long opaque number.
This was introduced in Linux 5.7, see get_netns_cookie in
https://elixir.bootlin.com/linux/v5.7/source/net/core/filter.c
vs
https://elixir.bootlin.com/linux/v5.6/source/net/core/filter.c
But only for sock & sock_addr, while sock_ops & sk_msg were
added later (present in 6.12)
Test: N/A
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Idccb7191552be8048a02fff2358e7d7898123dd9
1 file changed