Skip to contentSkip to conversation

wireguard: Wire-up big tcp support

PATCH In review Daniel Borkmann 2 participants 3 messages Oct 4, 2024 – Oct 7, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 wireguard: Wire-up big tcp support

Advertise GSO_MAX_SIZE as TSO max size in order support BIG TCP for wireguard. This helps to improve wireguard performance a bit when enabled as it allows wireguard to aggregate larger skbs in wg_packet_consume_data_done() via napi_gro_receive(), but also allows the stack to build larger skbs on xmit where the driver then segments them before encryption inside wg_xmit().

Cc Jason A. Donenfeld <[email protected]>
Cc Anton Protopopov <[email protected]>
Cc Martynas Pumputis <[email protected]>

---
v2: fixed up my gitconfig and Cc's now

 drivers/net/wireguard/device.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/wireguard/device.c +1 -0
index 45e9b908dbfb..79be517b2216 100644
@@ -301,6 +301,7 @@ static void wg_setup(struct net_device *dev)
 
 	/* We need to keep the dst around in case of icmp replies. */
 	netif_keep_dst(dev);
+	netif_set_tso_max_size(dev, GSO_MAX_SIZE);
 
 	memset(wg, 0, sizeof(*wg));
 	wg->dev = dev;
Signature · 1 line
2.43.0
#1 lore raw

Hi Daniel,

Quoted 5 lines · Daniel Borkmann

Advertise GSO_MAX_SIZE as TSO max size in order support BIG TCP for wireguard. This helps to improve wireguard performance a bit when enabled as it allows wireguard to aggregate larger skbs in wg_packet_consume_data_done() via napi_gro_receive(), but also allows the stack to build larger skbs on xmit where the driver then segments them before encryption inside wg_xmit().

Thanks, I'll queue this up. Do you have any perf numbers on the speedup, btw?

Jason

#2 lore raw

Hi Jason,

Quoted 9 lines · Jason A. Donenfeld
Quoted 5 lines · Daniel Borkmann

Advertise GSO_MAX_SIZE as TSO max size in order support BIG TCP for wireguard. This helps to improve wireguard performance a bit when enabled as it allows wireguard to aggregate larger skbs in wg_packet_consume_data_done() via napi_gro_receive(), but also allows the stack to build larger skbs on xmit where the driver then segments them before encryption inside wg_xmit().

Thanks, I'll queue this up. Do you have any perf numbers on the speedup, btw?

Awesome, thanks! Few weeks back we had an LPC session with some initial work around wireguard performance (https://lpc.events/event/18/contributions/1968/)
including benchmarks. It depends on the specific scenario, but this as well as an L2 GRO implementation (yet to come as patches in the next weeks) we got ~+15% for host-host in case of TCP STREAM. In case of Cilium I haven't done the measurement yet, but I expect that there would be further gains as bigger packets can traverse the stack and thus less processing in upper layers (e.g. our tcx BPF code).

Thanks,
Daniel