History

cgroup: bpf: Add bpf_skb_in_cgroup_proto

Adds a bpf helper, bpf_skb_in_cgroup, to decide if a skb->sk belongs to a descendant of a cgroup2. It is similar to the feature added in netfilter: commit c38c4597e4bf ("netfilter: implement xt_cgroup cgroup2 path match") The user is expected to populate a BPF_MAP_TYPE_CGROUP_ARRAY which will be used by the bpf_skb_in_cgroup. Modifications to the bpf verifier is to ensure BPF_MAP_TYPE_CGROUP_ARRAY and bpf_skb_in_cgroup() are always used together.

Martin KaFai Lau committed 10 years ago

Commit 4a482f31 parent 4ed8ec53 files · +56 −1Browse files

Showing the changes to include/uapi (1 of 3 files). Show all

Unified · Split

include/uapi/linux/bpf.h+11−0
@@ -337,6 +337,17 @@ enum bpf_func_id { · 336 unmodified lines
337337 */
338338 BPF_FUNC_skb_change_type,
339339
340+ /**
341+ * bpf_skb_in_cgroup(skb, map, index) - Check cgroup2 membership of skb
342+ * @skb: pointer to skb
343+ * @map: pointer to bpf_map in BPF_MAP_TYPE_CGROUP_ARRAY type
344+ * @index: index of the cgroup in the bpf_map
345+ * Return:
346+ * == 0 skb failed the cgroup2 descendant test
347+ * == 1 skb succeeded the cgroup2 descendant test
348+ * < 0 error
349+ */
350+ BPF_FUNC_skb_in_cgroup,
340351 __BPF_FUNC_MAX_ID,
341352 };
342353

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t