From owner-freebsd-net@freebsd.org Fri May 14 21:40:15 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 7F16162CF93 for ; Fri, 14 May 2021 21:40:15 +0000 (UTC) (envelope-from hausen@punkt.de) Received: from mail.punkt.de (mail.punkt.de [IPv6:2a00:b580:8000:11:1c6b:7032:35e9:5616]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4FhhlL3ffQz3w18 for ; Fri, 14 May 2021 21:40:14 +0000 (UTC) (envelope-from hausen@punkt.de) Received: from [IPv6:2003:a:d59:3880:1461:16e:232d:baa] (unknown [IPv6:2003:a:d59:3880:1461:16e:232d:baa]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.punkt.de (Postfix) with ESMTPSA id 20138334D3; Fri, 14 May 2021 23:40:06 +0200 (CEST) From: "Patrick M. Hausen" Message-Id: Content-Type: multipart/signed; boundary="Apple-Mail=_ED5C81E3-9046-4C6D-AC53-243E87DB2815"; protocol="application/pgp-signature"; micalg=pgp-sha256 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.20\)) Subject: Re: sender source IP address on UDP socket bound to INADDR_ANY in golang Date: Fri, 14 May 2021 23:40:04 +0200 In-Reply-To: Cc: freebsd-net@freebsd.org To: Peter Jeremy References: <2B26D5AB-0F77-4E36-AD9A-D7D6CE5F173C@punkt.de> <846FFF4A-0D81-4F04-8358-1B14F996C0A2@punkt.de> X-Mailer: Apple Mail (2.3445.104.20) X-Rspamd-Queue-Id: 4FhhlL3ffQz3w18 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of hausen@punkt.de designates 2a00:b580:8000:11:1c6b:7032:35e9:5616 as permitted sender) smtp.mailfrom=hausen@punkt.de X-Spamd-Result: default: False [-4.90 / 15.00]; RCVD_TLS_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MV_CASE(0.50)[]; R_SPF_ALLOW(-0.20)[+ip6:2a00:b580::/32]; HAS_ATTACHMENT(0.00)[]; MIME_GOOD(-0.20)[multipart/signed,text/plain]; ARC_NA(0.00)[]; DMARC_NA(0.00)[punkt.de]; SPAMHAUS_ZRD(0.00)[2a00:b580:8000:11:1c6b:7032:35e9:5616:from:127.0.2.255]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RBL_DBL_DONT_QUERY_IPS(0.00)[2a00:b580:8000:11:1c6b:7032:35e9:5616:from]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCPT_COUNT_TWO(0.00)[2]; NEURAL_HAM_SHORT(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; SIGNED_PGP(-2.00)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; ASN(0.00)[asn:16188, ipnet:2a00:b580::/32, country:DE]; RCVD_COUNT_TWO(0.00)[2]; 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: Fri, 14 May 2021 21:40:15 -0000 --Apple-Mail=_ED5C81E3-9046-4C6D-AC53-243E87DB2815 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Hi Peter and everyone else following, > Am 12.05.2021 um 14:06 schrieb Peter Jeremy via freebsd-net = : > As I see it, the possibilities boil down to: > 1) The Go code isn't enabling IPPROTO_IP.IP_RECVDSTADDR on the socket. > 2) There's a FreeBSD kernel bug that mean setting IP_RECVDSTADDR > isn't being correctly reflected into the recvmsg control message. > 3) The control message isn't being correctly plumbed through from > recvmsg(2) to the Go RecvMsg() return. >=20 > Note that a lot of the relevant Go library code is BSD- or FreeBSD- > specific so it's also possible that there is a bug in the Go library > code. do you have some spare time and would you be so kind to look at our = discussion 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 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. 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? 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? Any light you can shed on this issue greatly appreciated. Thanks, Patrick -- punkt.de GmbH Patrick M. Hausen .infrastructure Kaiserallee 13a 76133 Karlsruhe Tel. +49 721 9109500 https://infrastructure.punkt.de info@punkt.de AG Mannheim 108285 Gesch=C3=A4ftsf=C3=BChrer: J=C3=BCrgen Egeling, Daniel Lienert, Fabian = Stein --Apple-Mail=_ED5C81E3-9046-4C6D-AC53-243E87DB2815 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEgzqrjO/mj9CSsTg2kG8u4u3aiVwFAmCe7jQACgkQkG8u4u3a iVw7wAf9G9KpbOyycqkc3VGIgguyqNRn6CMAAkSCi/Ec/DAkkfIldTJw7ynS5SB5 6Sa9iUzdkD9OBA0q6GuZDyobGhLSUkoXaII8pRbSO3+EiXa7lTyo05YSLxqZF5c4 aSnlzzy0s/XMLljm5TPAVJq7VgZvNNo1kNonhvvJCIYevuwSTnr3cKqcad5xHsny 8eGK0CZVLvHQWgC6H5bf/Lyi05bgQVwv7FXbB/XanYBtKv5z5BDDwh/mfQrs7yJI 8mZa7MHO6D/E4XzEvCuKpnw+6pKOWchjYSTBJgHBhvDG3+ggtql2PeY2QfETijcs bPI3jU+jE+QT0tjmoqC5cOYnbs6xSQ== =AneT -----END PGP SIGNATURE----- --Apple-Mail=_ED5C81E3-9046-4C6D-AC53-243E87DB2815--