From 0fe29325e6999e76bb13e382fd3dcde86763a4d5 Mon Sep 17 00:00:00 2001 From: Aman Khinvasara Date: Mon, 8 Dec 2025 08:56:28 +0000 Subject: [PATCH 1/2] Revert "pktgen: set IP Ethertype" This reverts commit caaff553ca190510383fca1ef1834e5413b0e5c2 and 12174e183c66f3164ffd83202cdf3d6f4371d811. --- .../commands/pktgen/fd_pktgen_tile.c | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/src/app/shared_dev/commands/pktgen/fd_pktgen_tile.c b/src/app/shared_dev/commands/pktgen/fd_pktgen_tile.c index dd75c242293..7b141d45c30 100644 --- a/src/app/shared_dev/commands/pktgen/fd_pktgen_tile.c +++ b/src/app/shared_dev/commands/pktgen/fd_pktgen_tile.c @@ -1,12 +1,11 @@ /* fd_pktgen_tile floods a net tile with small outgoing packets. - Each packet is a minimum size Ethernet frame. IPv4 ethertype is used - with TTL=0 so packets get dropped immediately and don't leak to the - Internet. + Each packet is a minimum size Ethernet frame. An invalid + Ethertype is used to avoid leaking the flood out to the Internet. - Each packet contains a 16 bit sequence number in the ip4 net_id field - such that each payload is different. Experiments revealed that some NICs - stop sending if we send the same payload over and over again. + Each packet contains a 64 bit sequence number such that each + payload is different. Experiments revealed that some NICs stop + sending if we send the same payload over and over again (probably protection against a buggy driver melting the network). */ #include "../../../../disco/topo/fd_topo.h" @@ -20,7 +19,7 @@ struct fd_pktgen_tile_ctx { ulong chunk0; ulong wmark; ulong chunk; - ushort tag; + ulong tag; uint fake_dst_ip; }; @@ -70,23 +69,15 @@ before_credit( fd_pktgen_tile_ctx_t * ctx, /* Send an Ethernet frame */ ulong chunk = ctx->chunk; uchar * frame = fd_chunk_to_laddr( ctx->out_base, chunk ); - ushort tag = ctx->tag; + ulong tag = ctx->tag; ulong sz = sizeof(fd_eth_hdr_t) + 46; - - /* Set IPv4 ethertype and minimal IPv4 header for XDP validation */ - fd_eth_hdr_t * eth = (fd_eth_hdr_t *)frame; - fd_ip4_hdr_t * ip4 = (fd_ip4_hdr_t *)(eth+1); - eth->net_type = fd_ushort_bswap( FD_ETH_HDR_TYPE_IP ); - ip4->verihl = FD_IP4_VERIHL( 4, 5 ); - ip4->ttl = 0; - ip4->net_id = tag; - + FD_STORE( ulong, frame+sizeof(fd_eth_hdr_t), tag ); fd_stem_publish( stem, 0UL, sig, chunk, sz, 0UL, 0UL, 0UL ); /* Wind up for next iteration */ chunk++; /* Min sz Ethernet frames are exactly FD_CHUNK_SZ */ chunk = fd_ulong_if( chunk>ctx->wmark, ctx->chunk0, chunk ); - ctx->tag = tag+1; + ctx->tag = tag+1UL; ctx->chunk = chunk; } From 3ad30b03207431462e10bb8f5cc55a73b8271346 Mon Sep 17 00:00:00 2001 From: Aman Khinvasara Date: Tue, 9 Dec 2025 15:33:26 +0000 Subject: [PATCH 2/2] pktgen: valid Ethtype and IP VERIHL --- src/app/fdctl/config/default.toml | 4 ++-- src/app/firedancer/config/default.toml | 2 +- .../commands/pktgen/fd_pktgen_tile.c | 22 +++++++++++-------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/app/fdctl/config/default.toml b/src/app/fdctl/config/default.toml index 759eea0c048..b39805a91d5 100644 --- a/src/app/fdctl/config/default.toml +++ b/src/app/fdctl/config/default.toml @@ -1756,8 +1756,8 @@ dynamic_port_range = "8900-9000" # # The net tile queries the route and neighbor tables as part of the # benchmark. In short, these resolve the dst MAC address of the - # outgoing Ethernet packets. Since pktgen does not produce IPv4 - # packets, no traffic actually gets sent to this IP. + # outgoing Ethernet packets. Since pktgen does not produce + # valid IPv4 packets, no traffic actually gets sent to this IP. # # The IP address should fulfill these requirements: # - 'ip route get ' resolves to the XDP interface diff --git a/src/app/firedancer/config/default.toml b/src/app/firedancer/config/default.toml index 62a32dd534d..52e9dc127db 100644 --- a/src/app/firedancer/config/default.toml +++ b/src/app/firedancer/config/default.toml @@ -1762,7 +1762,7 @@ user = "" # The net tile queries the route and neighbor tables as part of # the benchmark. In short, these resolve the dst MAC address of # the outgoing Ethernet packets. Since pktgen does not produce - # IPv4 packets, no traffic actually gets sent to this IP. + # valid IPv4 packets, no traffic actually gets sent to this IP. # # The IP address should fulfill these requirements: # - 'ip route get ' resolves to the XDP interface diff --git a/src/app/shared_dev/commands/pktgen/fd_pktgen_tile.c b/src/app/shared_dev/commands/pktgen/fd_pktgen_tile.c index 7b141d45c30..4ea6393ad41 100644 --- a/src/app/shared_dev/commands/pktgen/fd_pktgen_tile.c +++ b/src/app/shared_dev/commands/pktgen/fd_pktgen_tile.c @@ -1,7 +1,7 @@ /* fd_pktgen_tile floods a net tile with small outgoing packets. - Each packet is a minimum size Ethernet frame. An invalid - Ethertype is used to avoid leaking the flood out to the Internet. + Each packet is a minimum size Ethernet frame. An invalid ip4 hdr + is used to avoid leaking the flood out to the Internet. Each packet contains a 64 bit sequence number such that each payload is different. Experiments revealed that some NICs stop @@ -61,17 +61,21 @@ before_credit( fd_pktgen_tile_ctx_t * ctx, *charge_busy = 1; /* Select an arbitrary public IP as the fake destination. The outgoing - packet is not an Internet packet, so it will not reach that - destination. The net tile, however, needs a valid dst IP to select + packet has an an invalid ip header, so it will not reach that + destination. The net tile, however, needs a valid dst IP to select the dst MAC address. */ ulong sig = fd_disco_netmux_sig( 0U, 0U, ctx->fake_dst_ip, DST_PROTO_OUTGOING, FD_NETMUX_SIG_MIN_HDR_SZ ); /* Send an Ethernet frame */ - ulong chunk = ctx->chunk; - uchar * frame = fd_chunk_to_laddr( ctx->out_base, chunk ); - ulong tag = ctx->tag; - ulong sz = sizeof(fd_eth_hdr_t) + 46; - FD_STORE( ulong, frame+sizeof(fd_eth_hdr_t), tag ); + ulong chunk = ctx->chunk; + uchar * frame = fd_chunk_to_laddr( ctx->out_base, chunk ); + fd_eth_hdr_t * eth = (fd_eth_hdr_t *)frame; + fd_ip4_hdr_t * ip4 = (fd_ip4_hdr_t *)(eth+1); + ulong tag = ctx->tag; + ulong sz = sizeof(fd_eth_hdr_t) + 46; + eth->net_type = fd_ushort_bswap( FD_ETH_HDR_TYPE_IP ); + ip4->verihl = FD_IP4_VERIHL( 4, 5 ); + FD_STORE( ulong, ip4+1, tag ); /* Unique seq number */ fd_stem_publish( stem, 0UL, sig, chunk, sz, 0UL, 0UL, 0UL ); /* Wind up for next iteration */