[PATCH] bpf: cg_skb add get classid helper

From: Feng zhou
Date: Wed Aug 14 2024 - 05:51:11 EST


From: Feng Zhou <zhoufeng.zf@xxxxxxxxxxxxx>

At cg_skb hook point, can get classid for v1 or v2, allowing
users to do more functions such as acl.

Signed-off-by: Feng Zhou <zhoufeng.zf@xxxxxxxxxxxxx>
---
net/core/filter.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/net/core/filter.c b/net/core/filter.c
index 78a6f746ea0b..d69ba589882f 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -8111,6 +8111,12 @@ cg_skb_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
return &bpf_get_listener_sock_proto;
case BPF_FUNC_skb_ecn_set_ce:
return &bpf_skb_ecn_set_ce_proto;
+ case BPF_FUNC_get_cgroup_classid:
+ return &bpf_get_cgroup_classid_proto;
+#endif
+#ifdef CONFIG_CGROUP_NET_CLASSID
+ case BPF_FUNC_skb_cgroup_classid:
+ return &bpf_skb_cgroup_classid_proto;
#endif
default:
return sk_filter_func_proto(func_id, prog);
--
2.30.2