public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
* [PATCH 00/14] Clean up checksum and header generation for inbound packets
@ 2022-10-17  8:57 David Gibson
  2022-10-17  8:57 ` [PATCH 01/14] Add csum_icmp6() helper for calculating ICMPv6 checksums David Gibson
                   ` (13 more replies)
  0 siblings, 14 replies; 36+ messages in thread
From: David Gibson @ 2022-10-17  8:57 UTC (permalink / raw)
  To: Stefano Brivio; +Cc: passt-dev, David Gibson

The main packet "fast paths" for UDP and TCP mostly just forward
packets rather than generating them from scratch.  However the control
paths for ICMP and DHCP sometimes generate packets more or less from
scratch.  Because these are relatively rare, it's not performance
critical.

The paths for sending these packets have some duplication of the
header generation.  There's also some layering violation in
tap_ip_send() which both generates IP headers and updates the L4 (UDP
or UCMP) checksum.

Finally that checksum generation is a little awkward: it temporarily
generates the IP pseudo header (or something close enough to serve) in
the place of the actual header, generates the checksum, then replaces
it with the real IP header.  This approach seems to be causing
miscompiles with some LTO optimization, because the stores to the
pseudo header are being moved or elided across the code calculating
the checksum.

This series addresses all of these.  We consolidate and clarify the
packet sending helpers, and use them in some places there was
previously duplicated code.  In the process we use new checksum
generation helpers which take a different approach which should avoid
the LTO problems (this aspect I haven't tested yet though).

David Gibson (14):
  Add csum_icmp6() helper for calculating ICMPv6 checksums
  Add csum_icmp4() helper for calculating ICMPv4 checksums
  Add csum_udp6() helper for calculating UDP over IPv6 checksums
  Add csum_udp4() helper for calculating UDP over IPv4 checksums
  Add csum_ip4_header() helper to calculate IPv4 header checksums
  Add helpers for normal inbound packet destination addresses
  Remove support for TCP packets from tap_ip_send()
  tap: Remove unhelpeful vnet_pre optimization from tap_send()
  Split tap_ip_send() into IPv4 and IPv6 specific functions
  tap: Split tap_ip6_send() into UDP and ICMP variants
  ndp: Remove unneeded eh_source parameter
  ndp: Use tap_icmp6_send() helper
  tap: Split tap_ip4_send() into UDP and ICMP variants
  dhcp: Use tap_udp4_send() helper in dhcp()

 arp.c      |   2 +-
 checksum.c | 122 ++++++++++++++++++-----
 checksum.h |  19 +++-
 dhcp.c     |  19 +---
 dhcpv6.c   |  21 +---
 icmp.c     |  12 +--
 ndp.c      |  28 +-----
 ndp.h      |   3 +-
 tap.c      | 286 ++++++++++++++++++++++++++++++++---------------------
 tap.h      |  19 +++-
 10 files changed, 323 insertions(+), 208 deletions(-)

-- 
2.37.3


^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2022-10-18 23:54 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-17  8:57 [PATCH 00/14] Clean up checksum and header generation for inbound packets David Gibson
2022-10-17  8:57 ` [PATCH 01/14] Add csum_icmp6() helper for calculating ICMPv6 checksums David Gibson
2022-10-18  3:01   ` Stefano Brivio
2022-10-18 12:05     ` David Gibson
2022-10-17  8:57 ` [PATCH 02/14] Add csum_icmp4() helper for calculating ICMPv4 checksums David Gibson
2022-10-18  3:01   ` Stefano Brivio
2022-10-18 12:06     ` David Gibson
2022-10-18 12:28       ` Stefano Brivio
2022-10-17  8:57 ` [PATCH 03/14] Add csum_udp6() helper for calculating UDP over IPv6 checksums David Gibson
2022-10-18  3:02   ` Stefano Brivio
2022-10-18 12:06     ` David Gibson
2022-10-17  8:57 ` [PATCH 04/14] Add csum_udp4() helper for calculating UDP over IPv4 checksums David Gibson
2022-10-18  3:03   ` Stefano Brivio
2022-10-18 12:06     ` David Gibson
2022-10-17  8:57 ` [PATCH 05/14] Add csum_ip4_header() helper to calculate IPv4 header checksums David Gibson
2022-10-18  3:03   ` Stefano Brivio
2022-10-18 12:07     ` David Gibson
2022-10-17  8:57 ` [PATCH 06/14] Add helpers for normal inbound packet destination addresses David Gibson
2022-10-18  3:04   ` Stefano Brivio
2022-10-18 12:07     ` David Gibson
2022-10-17  8:58 ` [PATCH 07/14] Remove support for TCP packets from tap_ip_send() David Gibson
2022-10-17  8:58 ` [PATCH 08/14] tap: Remove unhelpeful vnet_pre optimization from tap_send() David Gibson
2022-10-18  3:05   ` Stefano Brivio
2022-10-18 12:07     ` David Gibson
2022-10-17  8:58 ` [PATCH 09/14] Split tap_ip_send() into IPv4 and IPv6 specific functions David Gibson
2022-10-18  3:06   ` Stefano Brivio
2022-10-18 12:07     ` David Gibson
2022-10-17  8:58 ` [PATCH 10/14] tap: Split tap_ip6_send() into UDP and ICMP variants David Gibson
2022-10-17  8:58 ` [PATCH 11/14] ndp: Remove unneeded eh_source parameter David Gibson
2022-10-17  8:58 ` [PATCH 12/14] ndp: Use tap_icmp6_send() helper David Gibson
2022-10-17  8:58 ` [PATCH 13/14] tap: Split tap_ip4_send() into UDP and ICMP variants David Gibson
2022-10-18  3:06   ` Stefano Brivio
2022-10-18 12:07     ` David Gibson
2022-10-18 12:27       ` Stefano Brivio
2022-10-18 23:54         ` David Gibson
2022-10-17  8:58 ` [PATCH 14/14] dhcp: Use tap_udp4_send() helper in dhcp() David Gibson

Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).