bpf, sockmap: Introduce tracing capability for sockmap #12
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.
Sockmap has the same high-performance forwarding capability as XDP, but operates at Layer 7.
Introduce tracing capability for sockmap, similar to XDP, to trace the execution results of BPF programs without modifying the programs themselves, similar to the existing trace_xdp_redirect{_map}.
It is crucial for debugging BPF programs, especially in production environments.
Additionally, a header file was added to bpf_trace.h to automatically generate tracepoints.
Test results:
$ echo "1" > /sys/kernel/tracing/events/sockmap/enable
skb:
sockmap_redirect: sk=00000000d3266a8d, type=skb, family=2, protocol=6, \ prog_id=73, length=256, action=PASS
msg:
sockmap_redirect: sk=00000000528c7614, type=msg, family=2, protocol=6, \ prog_id=185, length=5, action=REDIRECT
tls:
sockmap_redirect: sk=00000000d04d2224, type=skb, family=2, protocol=6, \ prog_id=143, length=35, action=PASS
strparser:
sockmap_skb_strp_parse: sk=00000000ecab0b30, family=2, protocol=6, \ prog_id=170, size=5