public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Jon Maloy <jmaloy@redhat.com>
Cc: 7ppKb5bW <pONy4THS@protonmail.com>,
	"passt-dev@passt.top" <passt-dev@passt.top>
Subject: Re: [PATCH v8 2/4] udp: create and send ICMPv4 to local peer when applicable
Date: Tue, 4 Mar 2025 15:54:26 +1100	[thread overview]
Message-ID: <Z8aHgtYXnA16P05L@zatzit> (raw)
In-Reply-To: <ced67cae-e7bb-448a-ad27-618092f083f9@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2502 bytes --]

On Mon, Mar 03, 2025 at 11:41:48AM -0500, Jon Maloy wrote:
> On 2025-03-03 07:07, 7ppKb5bW wrote:
[snip]
> > > -		udp_send_conn_fail_icmp4(c, ee, toside, data, rc);
> > > +		size_t dlen = rc;
> > > +
> > > +		if (hdr->cmsg_level == IPPROTO_IP) {
> > > +			dlen = MIN(dlen, ICMP4_MAX_DLEN);
> > > +			udp_send_conn_fail_icmp4(c, ee, toside, data, dlen);
> > > +		} else if (hdr->cmsg_level == IPPROTO_IPV6) {
> > > +			udp_send_conn_fail_icmp6(c, ee, toside, data,
> > > +						 dlen, sidx.flowi);
> > > +		}
> > >   	} else {
> > >   		trace("Ignoring received IP_RECVERR cmsg on listener socket");
> > >   	}
> > 
> > If the socket is dual-stack, cmsg_level may not match cmsg_data.
> > ```
> > #dual-stack-test.py
> > from socket import *
> > import time
> > IP_RECVERR=0xb
> > with socket(AF_INET6,SOCK_DGRAM,IPPROTO_UDP) as sock:
> >      sock.setsockopt(IPPROTO_IP,IP_RECVERR,1)
> >      sock.setsockopt(IPPROTO_IP,IP_TTL,1)
> >      packet=bytes(8)
> >      sock.sendto(packet,("::ffff:151.101.1.6",443))
> >      time.sleep(0.1)
> >      print(sock.recvmsg(1472,1024,MSG_ERRQUEUE))
> > 
> > ```
> 
> Yes, this was mentioned at some point during our discussions, and we should
> eventually handle it, but it is really outside the scope of the current
> series.

In fact, I think the point our mystery person is making here is subtly
different from the v4 vs v6 thing I raised earlier in the discussion.
I was talking about possible future cases where we might be using a
different IP version on the host than we're using for the guest
(e.g. CLAT).  For that we'd need to pick our generated ICMP version
based on the addresses  in the flow - and rather more complicated we'd
need to be prepared to do translation between ICMPv4 and ICMPv6
errors.

The point that 7ppKb5bW is raising here, is that a dual-stack socket
(mostly) counts as an IPv6 socket and will show the cmsg_level
accordingly, even though it can also receive ICMPv4 errors.

I don't think it's urgent to fix this before merging the series,
because we're only handling errors on reply sockets for now, and we
don't use dual-stack sockets for those.  We should fix it as a follow
up, though, which I believe we can do fairly easily by looking at
ee_origin, instead of cmsg_level.

-- 
David Gibson (he or they)	| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you, not the other way
				| around.
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2025-03-04  4:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-03 12:07 [PATCH v8 2/4] udp: create and send ICMPv4 to local peer when applicable 7ppKb5bW
2025-03-03 16:41 ` Jon Maloy
2025-03-04  4:54   ` David Gibson [this message]
  -- strict thread matches above, loose matches on Subject: below --
2025-02-28 22:41 [PATCH v8 0/4] Reconstruct incoming ICMP headers for failed UDP connect and forward back Jon Maloy
2025-02-28 22:41 ` [PATCH v8 2/4] udp: create and send ICMPv4 to local peer when applicable Jon Maloy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z8aHgtYXnA16P05L@zatzit \
    --to=david@gibson.dropbear.id.au \
    --cc=jmaloy@redhat.com \
    --cc=pONy4THS@protonmail.com \
    --cc=passt-dev@passt.top \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).