xdp-tutorial
xdp-tutorial copied to clipboard
Testing "offline"?
Is there an easy way to simulate and test my functions? I want to play around with IPv6 headers and it would be easier to do the parsing and testing offline. I would need to get the struct xdp_md *ctx. Or maybe some function that crafts me a package?
You could use the BPF_PROG_TEST_RUN kernel API to run your program with a given packet.
The bpftool also has support for doing this:
https://www.spinics.net/lists/netdev/msg584123.html
Guess you can create your IPv6 packet with scapy in python.
Eelco Chaudron [email protected] writes:
You could use the BPF_PROG_TEST_RUN kernel API to run your program with a given packet.
The bpftool also has support for doing this:
https://www.spinics.net/lists/netdev/msg584123.html
The XDP testing framework we use for xdp-tools also has support for using bpf_prog_test_run:
https://github.com/shoracek/xdp-test-harness
See the Python tests for xdp-filter for examples:
https://github.com/xdp-project/xdp-tools/blob/master/xdp-filter/tests/test_basic.py
Interesting. I have to go through it. Can I maybe capture an IPv6 packet with pcap and cut that out and then use this BPF_PROG_TEST_RUN? The perl -e 'print "\x0" x 14' is for tracing the binary data to the bpf-tool, or? So in realty it would be a much longer string?