mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 20:51:03 +02:00
bpf: Add classid helper only based on skb->sk
Similarly to5a52ae4e32
("bpf: Allow to retrieve cgroup v1 classid from v2 hooks"), add a helper to retrieve cgroup v1 classid solely based on the skb->sk, so it can be used as key as part of BPF map lookups out of tc from host ns, in particular given the skb->sk is retained these days when crossing net ns thanks to9c4c325252
("skbuff: preserve sock reference when scrubbing the skb."). This is similar to bpf_skb_cgroup_id() which implements the same for v2. Kubernetes ecosystem is still operating on v1 however, hence net_cls needs to be used there until this can be dropped in with the v2 helper of bpf_skb_cgroup_id(). Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Martin KaFai Lau <kafai@fb.com> Link: https://lore.kernel.org/bpf/ed633cf27a1c620e901c5aa99ebdefb028dce600.1601477936.git.daniel@iogearbox.net
This commit is contained in:
committed by
Alexei Starovoitov
parent
963ec27a10
commit
b426ce83ba
@@ -3643,6 +3643,15 @@ union bpf_attr {
|
||||
* *flags* are identical to those used for bpf_snprintf_btf.
|
||||
* Return
|
||||
* 0 on success or a negative error in case of failure.
|
||||
*
|
||||
* u64 bpf_skb_cgroup_classid(struct sk_buff *skb)
|
||||
* Description
|
||||
* See **bpf_get_cgroup_classid**\ () for the main description.
|
||||
* This helper differs from **bpf_get_cgroup_classid**\ () in that
|
||||
* the cgroup v1 net_cls class is retrieved only from the *skb*'s
|
||||
* associated socket instead of the current process.
|
||||
* Return
|
||||
* The id is returned or 0 in case the id could not be retrieved.
|
||||
*/
|
||||
#define __BPF_FUNC_MAPPER(FN) \
|
||||
FN(unspec), \
|
||||
@@ -3796,6 +3805,7 @@ union bpf_attr {
|
||||
FN(copy_from_user), \
|
||||
FN(snprintf_btf), \
|
||||
FN(seq_printf_btf), \
|
||||
FN(skb_cgroup_classid), \
|
||||
/* */
|
||||
|
||||
/* integer value in 'imm' field of BPF_CALL instruction selects which helper
|
||||
|
Reference in New Issue
Block a user