From owner-freebsd-net@freebsd.org Tue May 11 11:40:54 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 CF007634242 for ; Tue, 11 May 2021 11:40:54 +0000 (UTC) (envelope-from hausen@punkt.de) Received: from mail.punkt.de (mail.punkt.de [217.29.41.227]) (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 4Ffbb95flwz3nRl for ; Tue, 11 May 2021 11:40:53 +0000 (UTC) (envelope-from hausen@punkt.de) Received: from [IPv6:2003:a:d59:3880:59ca:695b:6b42:2e05] (unknown [IPv6:2003:a:d59:3880:59ca:695b:6b42:2e05]) (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 D18B82F42D; Tue, 11 May 2021 13:40:45 +0200 (CEST) From: "Patrick M. Hausen" Message-Id: <846FFF4A-0D81-4F04-8358-1B14F996C0A2@punkt.de> Content-Type: multipart/signed; boundary="Apple-Mail=_D570B725-284C-47E1-9CFE-A86D10271DD7"; 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: Tue, 11 May 2021 13:40:44 +0200 In-Reply-To: Cc: freebsd-net@freebsd.org To: Peter Jeremy References: <2B26D5AB-0F77-4E36-AD9A-D7D6CE5F173C@punkt.de> X-Mailer: Apple Mail (2.3445.104.20) X-Rspamd-Queue-Id: 4Ffbb95flwz3nRl X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of hausen@punkt.de designates 217.29.41.227 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)[+ip4:217.29.32.0/20]; 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)[217.29.41.227:from:127.0.2.255]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RBL_DBL_DONT_QUERY_IPS(0.00)[217.29.41.227: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:217.29.32.0/20, 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: Tue, 11 May 2021 11:40:54 -0000 --Apple-Mail=_D570B725-284C-47E1-9CFE-A86D10271DD7 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Hi! > Am 11.05.2021 um 12:38 schrieb Peter Jeremy : >=20 > On 2021-May-08 19:05:56 +0200, "Patrick M. Hausen" = wrote: >> I am facing a problem that is perfectly explained by the semantics >> of the socket interface for UDP, if one assumes that the application >> in question binds to INADDR_ANY and does not specifically set the >> sender address when sending datagrams. > ... >> Their code in question is here: >> = https://github.com/AdguardTeam/dnsproxy/blob/1163404e605c3dfbeab360fc3540f= c290f61a321/proxyutil/udp_unix.go#L47 >=20 > So, they say that they retrieve "the net interface IP the packet was > sent to (dst addr) from the socket's OOB data" and I agree that's what > the referenced code does. I hadn't heard of that behaviour before and > went digging... Thank you. I received some code with internal debugging added from the AdGuard core team and will try that today or tomorrow. If I read the = quote from the documentation correctly, on possible explanation would be them calling recvmsg() but forgetting to setsockopt()? Kind regards, 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=_D570B725-284C-47E1-9CFE-A86D10271DD7 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/mj9CSsTg2kG8u4u3aiVwFAmCabTwACgkQkG8u4u3a iVziTwf/QUvq7YXWreIzK7uO486J3pk/pjWqazNAsfioPcIECJEq0O3s8PY7H8Wy GcP0IzS4gi5AdHEo8PE02yqB1DZxnTL1yjL7kpOIi4pssE4fEBMmrPa6bR9604nb dF80d1bq9PxiUaZeh9wUTksxfntnnnhOSOBADXBqvjR/2G0jZyQNKT0k7QWNIQi2 ReLhsUBKmk3TDdFY29RVGx5RqonQmjVgynSZSScdVFxOBCW6iCXvydk8elf9xKnG O0fIcneXQjJSRQ3i6OqDl8j77DvySvlgMgrqk6cKPtgwjUtSy6x1kbEepiZ6yBQN b1pRadbFAmp+5ok0Yjdrdb3nN7VFEA== =xU/M -----END PGP SIGNATURE----- --Apple-Mail=_D570B725-284C-47E1-9CFE-A86D10271DD7--