Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow filtering unsupported protocols #209

Open
qdeslandes opened this issue Feb 12, 2025 · 0 comments
Open

Allow filtering unsupported protocols #209

qdeslandes opened this issue Feb 12, 2025 · 0 comments
Labels
area: codegen BPF bytecode generation

Comments

@qdeslandes
Copy link
Contributor

r7 and r8 are used to store the L3 protocol ID (e.g. ETH_P_IP) and the L4 protocol ID (e.g. IPPROTO_TCP). During the L3 and L4 parsing logic, if the protocol is not supported, the register is set to 0 to prevent falsely relying on this header later on:

# Parsing L3 header
if (r7 == ETH_P_IP)
    l3_size = sizeof(struct iphdr);
else if (r7 == ETH_P_IPV6)
    l3_size = sizeof(struct ipv6hdr);
else
    r7 = 0

# Parse the L3 header
...

However, such behaviour prevents filtering on non-supported protocol: r7 does not contain the ID of unsupported protocols, so meta.l3_proto only works for IPv4 and IPv6.

Prevent the header parsing functions in stub.c from resetting the protocol ID to 0.

@qdeslandes qdeslandes added the area: codegen BPF bytecode generation label Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: codegen BPF bytecode generation
Projects
Status: No status
Development

No branches or pull requests

1 participant