[2/3] Add CGROUP_SOCK_ADDR initial chain support#459
Open
yaakov-stein wants to merge 2 commits intofacebook:mainfrom
Open
[2/3] Add CGROUP_SOCK_ADDR initial chain support#459yaakov-stein wants to merge 2 commits intofacebook:mainfrom
CGROUP_SOCK_ADDR initial chain support#459yaakov-stein wants to merge 2 commits intofacebook:mainfrom
Conversation
|
Claude: review of facebook/bpfilter #459 (d894cd1) Suggestions
Nits
|
CGROUP_SOCK_ADDR support
76e2a42 to
1658309
Compare
9b215d0 to
2019d91
Compare
2019d91 to
e033686
Compare
CGROUP_SOCK_ADDR supportCGROUP_SOCK_ADDR initial chain support
CGROUP_SOCK_ADDR initial chain supportCGROUP_SOCK_ADDR initial chain support
cbf8eae to
ee24e7c
Compare
This was referenced Mar 9, 2026
ee24e7c to
06becee
Compare
qdeslandes
requested changes
Mar 11, 2026
Contributor
qdeslandes
left a comment
There was a problem hiding this comment.
Please update the documentation for these new hooks, and a test file in tests/e2e/rulesets (no need for rules, only a chain).
06becee to
4574a28
Compare
Add BF_FLAVOR_CGROUP_SOCK_ADDR and BF_HOOK_CGROUP_SOCK_ADDR_CONNECT4/CONNECT6 to support BPF_PROG_TYPE_CGROUP_SOCK_ADDR programs. This is the foundational enum/mapping work for sock_addr filtering. All mapping tables (hook strings, flavor, prog_type, attach_type), BPF type constants, link creation, and hookopts are updated. All existing matchers are blocked on the new hooks via unsupported_hooks. Flavor ops are registered as NULL and codegen is added in a follow-up.
Implement bf_flavor_ops for BF_FLAVOR_CGROUP_SOCK_ADDR so chains with a default policy can be loaded and attached to a cgroup.
4574a28 to
d894cd1
Compare
Contributor
Author
|
Testing and documentation is left for #465, where it can be done together with the matchers. (Can switch to add some here though if we think that'd be better.) |
qdeslandes
requested changes
Mar 13, 2026
Contributor
qdeslandes
left a comment
There was a problem hiding this comment.
Little, LGTM otherwise.
| return bf_err_r(-EINVAL, | ||
| "XDP and Netfilter chains can't set packet mark"); | ||
| bf_hook_to_flavor(chain->hook) != BF_FLAVOR_TC && | ||
| bf_hook_to_flavor(chain->hook) != BF_FLAVOR_CGROUP_SKB) { |
Contributor
There was a problem hiding this comment.
You're missing CGROUP_SOCK_ADDR.
Contributor
Author
There was a problem hiding this comment.
This reverses the logic (now that fewer flavors allow for setting the mark than those that don't). So we're checking if it's not an allowed flavor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked PRs:
CGROUP_SOCK_ADDRinitial chain support #459CGROUP_SOCK_ADDRmatcher support #465Adds initial cgroup_sock_addr support as described in #355.
Summary
BF_FLAVOR_CGROUP_SOCK_ADDRwithCONNECT4/CONNECT6hooksbpf_sock_addr.familyto R7 and loadsbpf_sock_addr.protocolinto R8-ENOTSUP- matcher support is in [3/3] AddCGROUP_SOCK_ADDRmatcher support #465cgroup_skbNotes:
BF_MATCHER_SETnow goes through unsupported_hooks like all other matchers (support will be added later)pkt_sizeis zeroed in the prologue so the counters stub runs cleanly (size is a no-op forCGROUP_SOCK_ADDRTest plan