public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
* [PATCH v2 00/14] Clean up checksum and header generation for inbound packets
@ 2022-10-19  0:43 David Gibson
  2022-10-19  0:43 ` [PATCH v2 01/14] Add csum_icmp6() helper for calculating ICMPv6 checksums David Gibson
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: David Gibson @ 2022-10-19  0:43 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).

Changes since v1:
 * Numerous minor style changes
 * Rename header generation helpers to make their behaviour clearer
 * Added several missing function doc comments
 * Corrected some erroneous statements and terms in comments

David Gibson (14):
  Add csum_icmp6() helper for calculating ICMPv6 checksums
  Add csum_icmp4() helper for calculating ICMP 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 | 120 ++++++++++++++++-----
 checksum.h |  15 ++-
 dhcp.c     |  19 +---
 dhcpv6.c   |  21 +---
 icmp.c     |  12 +--
 ndp.c      |  28 +----
 ndp.h      |   3 +-
 tap.c      | 312 ++++++++++++++++++++++++++++++++++-------------------
 tap.h      |  19 +++-
 10 files changed, 345 insertions(+), 206 deletions(-)

-- 
2.37.3


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

end of thread, other threads:[~2022-10-22  8:21 UTC | newest]

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

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).