Skip to content

Conversation

@akhinvasara-jumptrading
Copy link
Contributor

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

#include "fd_eth.h"
#include "fd_ip4.h"
#include "fd_udp.h"
#include "fd_gre.h"
Copy link
Contributor

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?

Copy link
Contributor Author

@akhinvasara-jumptrading akhinvasara-jumptrading Jan 2, 2026

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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fd_ip4_hdr_validate( fd_ip4_hdr_t const * hdr,
fd_ip4_hdr_check_len( fd_ip4_hdr_t const * hdr,

Copy link
Contributor Author

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 ) {
Copy link
Contributor

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_payload and opt_payload_sz are in bounds of data and data_sz
  • opt_eth is in bounds
  • opt_ip4 is in bounds
  • opt_udp is in bounds

Copy link
Contributor Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants