-
Notifications
You must be signed in to change notification settings - Fork 381
net: factor out header validation #7647
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
base: main
Are you sure you want to change the base?
net: factor out header validation #7647
Conversation
| #include "fd_eth.h" | ||
| #include "fd_ip4.h" | ||
| #include "fd_udp.h" | ||
| #include "fd_gre.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you revert these header additions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added them so that users of any net headers can just include fd_net_headers, as the name implies. But if you would still prefer all users to individually include the particular headers they need, I'll revert - lmk?
| Returns FD_NET_SUCCESS (defined in fd_net_common.h) if valid, or FD_NET_ERR_* on failure. */ | ||
|
|
||
| FD_FN_PURE static inline int | ||
| fd_ip4_hdr_validate( fd_ip4_hdr_t const * hdr, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| fd_ip4_hdr_validate( fd_ip4_hdr_t const * hdr, | |
| fd_ip4_hdr_check_len( fd_ip4_hdr_t const * hdr, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It additionally checks version and that the protocol is allowed - does this check_len name still make sense? I'll stage the change for now, but don't love it.
| ulong * opt_payload_sz, | ||
| fd_eth_hdr_t ** const opt_eth, | ||
| fd_ip4_hdr_t ** const opt_ip4, | ||
| fd_udp_hdr_t ** const opt_udp ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a fuzzer for this function?
The fuzzer should pass random inputs to data / data_sz, and then validate that:
opt_payloadandopt_payload_szare in bounds ofdataanddata_szopt_ethis in boundsopt_ip4is in boundsopt_udpis in bounds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A full fuzz target in the style of fuzz_quic_wire? Or a unit test that that does a bunch of random sampling?
This PR centralizes network header validation. The XDP tile guarantees that packets sent downstream will have passed validation.
For ease of review/reversability of desired, the first commit performs the refactor. The second commit changes the reported xdp metrics to take advantage of the new error codes.
The RX perf impact of this change is slightly positive (tested using Pktgen-DPDK from rd-merenguel1 (mlx5) to rd-chachal1 on (mlx5):
before: 8.617 Mpps
After: 8.713 Mpps