-
Notifications
You must be signed in to change notification settings - Fork 144
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
Introduce compiler for pcap filters/cBPF programs to XDP programs #356
base: master
Are you sure you want to change the base?
Commits on Oct 16, 2023
-
filterc: Compile filter to cBPF
Signed-off-by: Felix Maurer <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for a60d6dc - Browse repository at this point
Copy the full SHA a60d6dcView commit details -
filterc: Structure to compile cBPF to eBPF
Add a few helpful functions for error handling and to dump the program. Signed-off-by: Felix Maurer <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 63af7ce - Browse repository at this point
Copy the full SHA 63af7ceView commit details -
filterc: Start converting cBPF to eBPF
Start with the arithmetic instructions and a simple conversion of jumps. The jumps will be optimized in the future (if one of the branches goes to the next instruction). Signed-off-by: Felix Maurer <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 631a614 - Browse repository at this point
Copy the full SHA 631a614View commit details -
filterc: Add small instruction conversions
Signed-off-by: Felix Maurer <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 62b752b - Browse repository at this point
Copy the full SHA 62b752bView commit details -
filterc: Convert missing store instructions
The store instructions need to be guarded, i.e., checked that they only access data within the packet, because we need to pass the verifier. Linux supports legacy packet access instructions that were carried over from cBPF. However, they are only supported for programs where the context is an skb, not for XDP programs. Therefore, rewrite legacy packet access instructions to a series of eBPF instructions. Document register usage for the future. We prefer caller-saved registers at the moment because they don't need to be saved, i.e., pushed to the stack, in the JITed function, and we don't call into other functions anyways. Signed-off-by: Felix Maurer <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 604f070 - Browse repository at this point
Copy the full SHA 604f070View commit details -
filterc: Write structure for ELF file
We can now write something that is a valid ELF file, although not containing anything useful yet. The code and BTF information will be added in the next commits. Signed-off-by: Felix Maurer <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for af30fb3 - Browse repository at this point
Copy the full SHA af30fb3View commit details -
filterc: Write bpf insns to ELF file
Signed-off-by: Felix Maurer <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for fbe30ef - Browse repository at this point
Copy the full SHA fbe30efView commit details -
filterc: Add BTF info to ELF file
Signed-off-by: Felix Maurer <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for be1cf2e - Browse repository at this point
Copy the full SHA be1cf2eView commit details -
Only print the debug output if it is actually requested with the respective command line option. Signed-off-by: Felix Maurer <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 6334a2c - Browse repository at this point
Copy the full SHA 6334a2cView commit details -
The opcode of eBPF instructions has different meaning depending on the instruction class. Respect that when dumping the program. Signed-off-by: Felix Maurer <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for ac83510 - Browse repository at this point
Copy the full SHA ac83510View commit details -
filterc: Allow to write to file descriptors
Add write options in a struct that can be extended in the future. The struct is ready to be used with the validation mechanisms of libbpf/libxdp but they are not validated yet, because those mechanisms are internal to the libraries at the moment. Signed-off-by: Felix Maurer <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for ba5cd0d - Browse repository at this point
Copy the full SHA ba5cd0dView commit details -
Add a basic test to check if a compiled filter can be loaded into the kernel and does something similar to what we expect. Signed-off-by: Felix Maurer <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for a143052 - Browse repository at this point
Copy the full SHA a143052View commit details -
filterc: Allow to set program name
Add an option to configure the program name in the BPF object file. Signed-off-by: Felix Maurer <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for db19ef0 - Browse repository at this point
Copy the full SHA db19ef0View commit details -
filterc: Allow to create linkable BPF objects
If a BPF program should be linked into other programs, it requires some differences in the ELF object file: - The program needs to be in the text section Add an option to set how the BPF object file should look like. Also add a parameter to filterc to create linkable objects. Signed-off-by: Felix Maurer <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for ef7d95e - Browse repository at this point
Copy the full SHA ef7d95eView commit details -
filterc: Add test with bpf_linker
Signed-off-by: Felix Maurer <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 15bf137 - Browse repository at this point
Copy the full SHA 15bf137View commit details -
Compile a bunch of programs and check if they pass/fail as expected. Signed-off-by: Felix Maurer <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 0be7232 - Browse repository at this point
Copy the full SHA 0be7232View commit details -
When one of the branches goes to the next insn, it is not necessary to emit two eBPF insns. We can either leave out the second jump if the false case is the next insn, or we can invert the condition and leave out the second jump if the true case is the next insn. Signed-off-by: Felix Maurer <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 3e8a3aa - Browse repository at this point
Copy the full SHA 3e8a3aaView commit details