From owner-freebsd-net@freebsd.org Sun May 16 11:19:13 2021 Return-Path: Delivered-To: freebsd-net@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B521063E2B6 for ; Sun, 16 May 2021 11:19:13 +0000 (UTC) (envelope-from peter@rulingia.com) Received: from vtr.rulingia.com (vtr.rulingia.com [IPv6:2001:19f0:5801:ebe:5400:1ff:fe53:30fd]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA512 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "vtr.rulingia.com", Issuer "R3" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fjfsr3RhWz3L4d for ; Sun, 16 May 2021 11:19:12 +0000 (UTC) (envelope-from peter@rulingia.com) Received: from server.rulingia.com (ppp239-208.static.internode.on.net [59.167.239.208]) by vtr.rulingia.com (8.16.1/8.15.2) with ESMTPS id 14GBJ1Ah080405 (version=TLSv1.3 cipher=AEAD-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 16 May 2021 21:19:07 +1000 (AEST) (envelope-from peter@rulingia.com) DKIM-Filter: OpenDKIM Filter v2.10.3 vtr.rulingia.com 14GBJ1Ah080405 X-Bogosity: Ham, spamicity=0.000000 Received: from server.rulingia.com (localhost.rulingia.com [127.0.0.1]) by server.rulingia.com (8.16.1/8.16.1) with ESMTPS id 14GBItrD075421 (version=TLSv1.3 cipher=AEAD-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 16 May 2021 21:18:55 +1000 (AEST) (envelope-from peter@server.rulingia.com) Received: (from peter@localhost) by server.rulingia.com (8.16.1/8.16.1/Submit) id 14GBItWe075420; Sun, 16 May 2021 21:18:55 +1000 (AEST) (envelope-from peter) Date: Sun, 16 May 2021 21:18:55 +1000 From: Peter Jeremy To: "Patrick M. Hausen" Cc: freebsd-net@freebsd.org Subject: Re: sender source IP address on UDP socket bound to INADDR_ANY in golang Message-ID: References: <2B26D5AB-0F77-4E36-AD9A-D7D6CE5F173C@punkt.de> <846FFF4A-0D81-4F04-8358-1B14F996C0A2@punkt.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Fy7fqJva2Z+yZ6Q2" Content-Disposition: inline In-Reply-To: X-PGP-Key: http://www.rulingia.com/keys/peter.pgp X-Rspamd-Queue-Id: 4Fjfsr3RhWz3L4d X-Spamd-Bar: ------ X-Spamd-Result: default: False [-6.10 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[rulingia.com:s=default]; FREEFALL_USER(0.00)[peter]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+mx]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.20)[multipart/signed,text/plain]; SPAMHAUS_ZRD(0.00)[2001:19f0:5801:ebe:5400:1ff:fe53:30fd:from:127.0.2.255]; RCVD_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[rulingia.com:+]; RCPT_COUNT_TWO(0.00)[2]; DMARC_POLICY_ALLOW(-0.50)[rulingia.com,quarantine]; NEURAL_HAM_SHORT(-1.00)[-1.000]; SIGNED_PGP(-2.00)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; RBL_DBL_DONT_QUERY_IPS(0.00)[2001:19f0:5801:ebe:5400:1ff:fe53:30fd:from]; ASN(0.00)[asn:20473, ipnet:2001:19f0:5800::/38, country:US]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[freebsd-net] X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 11:19:13 -0000 --Fy7fqJva2Z+yZ6Q2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Patrick, On 2021-May-14 23:40:04 +0200, "Patrick M. Hausen" wrote: >do you have some spare time and would you be so kind to look at our discus= sion >here: https://github.com/AdguardTeam/AdGuardHome/issues/3015 > >Andrey from the AdGuard team references this golang issue: >https://github.com/golang/go/issues/8329 > >Which references this FreeBSD issue: >https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D193246 I've skimmed through all three issues. >What I as a sysadmin can observe is that the test code Andrey gave me >binds to *.53 on IPv4 and IPv6 although I start it with `-l 0.0.0.0` which= is >clearly an IPv4 "any" address. > >I am not 100% familiar with the API but as I understand you can treat >IPv4 as IPv6 via the socket interface by using an IPv4-mapped IPv6 >address. So far so good. Yes. >But then of course you have an AF_INET6 socket and it seems that >FreeBSD does not allow setting IPv4 specific options via setsockopt() >because it's an IPv6 socket. Correct? That's my reading of the FreeBSD issue. >Why can you have a single socket on both address families, anyway? >IPv4 and IPv6 are as "related" as IP and IPX - if you go dual stack, >treat them both separately - no? This is getting outside my expertise but my understanding is that the idea behind using IPv4-mapped addressed is to simplify building dual-stack applications, particularly during the early introduction of IPv6. The main benefit is that it made it possible to support both IPv4 and IPv6 without needing 2 sockets - which means you can stick to doing an accept() on a blocking socket, rather than needing to use poll() or select() etc with a pair of non-blocking sockets. I'm not sure how to solve your problem, sorry. --=20 Peter Jeremy --Fy7fqJva2Z+yZ6Q2 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQKTBAEBCgB9FiEE7rKYbDBnHnTmXCJ+FqWXoOSiCzQFAmCg/5RfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldEVF QjI5ODZDMzA2NzFFNzRFNjVDMjI3RTE2QTU5N0EwRTRBMjBCMzQACgkQFqWXoOSi CzSLqA//b5p4Ec/UOsqe4tLRvvQhhLjIHVUdmn7lfQwmn0I5luDQ1mz8nNl7kGeU BsDKOdfUXc6mhzHFW+rA4uD0//3GWnnz/wbSoOJFH+olAa91Heggyx15DgbodTuG LaxKY79jBsjKXpuaWtTOhnr955/FgyfXx28yVLdm541KAJ8kOMKDWaxBV2xJSRYR e46ww3kak/k6wm5xuc91NzYL3fU01Rrkbl1bEr39kOb8r/Wm9pk5JGWmpjeeRuWC mWAwXFIP/C315AZdMx4lI/vS9YidusvHZP79hGATm7VT1+64A5lTFNaObXnPHQE0 Iq9A4aBidLE2tYPWCBqB2Re/P/7TWo2It4cgiHW/w7uIjsa7tJSPTPlGSS+u7q2H WRfcurfaINw6h8d/3RIA/rSMyi21iutnERVAgK9LD8cwcDuUjejtCEyd5UfEYFdk uAyusWvizdgeKMBtL8YJ7eXZ5QkXoLhAbSNGHdsdnwEsOM7Y5Gsvq+i3y1S3NpjU kx2L6pAwq6An8jPidvF4h/PCdtPVS+z1wOiSDMhovbE8Ld0SzrNKoXCGNpBopaod I7lHfAPZehuqAdYy4yx5WCAIkJmyGyqV8l6o5NB2vZ6J47PI6c1B5LH67Art3YJT Wg2tFTJS29PENkL+bOiEum8K4l/mf7U8pcHWrQcJHJwuiBDUBho= =QdIG -----END PGP SIGNATURE----- --Fy7fqJva2Z+yZ6Q2--