Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 16 May 2021 21:18:55 +1000
From:      Peter Jeremy <peter@rulingia.com>
To:        "Patrick M. Hausen" <hausen@punkt.de>
Cc:        freebsd-net@freebsd.org
Subject:   Re: sender source IP address on UDP socket bound to INADDR_ANY in golang
Message-ID:  <YKD/n0Wvz5gwKiso@server.rulingia.com>
In-Reply-To: <D72535AB-1CC4-4091-8446-356DE83812A9@punkt.de>
References:  <2B26D5AB-0F77-4E36-AD9A-D7D6CE5F173C@punkt.de> <YJpenW9tB7LzlyS9@server.rulingia.com> <846FFF4A-0D81-4F04-8358-1B14F996C0A2@punkt.de> <YJvEsc9MED9rOFBV@server.rulingia.com> <D72535AB-1CC4-4091-8446-356DE83812A9@punkt.de>

next in thread | previous in thread | raw e-mail | index | archive | help

--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" <hausen@punkt.de> 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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?YKD/n0Wvz5gwKiso>