From nobody Mon Jul 27 21:55:27 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4h8C7z68dcz6lv25 for ; Mon, 27 Jul 2026 21:55:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4h8C7z3qJ0z43t7 for ; Mon, 27 Jul 2026 21:55:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1785189327; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=KDdQSj/ELfJqOpbFHWNm2clEQNPEUqKYf7MUzPfjLoY=; b=Qe5movK12Crrm+K7Yr98mcW5oRlOiPyrorWzzuW8JzvWbVFLFvKjIjxGtRfhthdeaeRPtX tCzmOwjDbpHvQPEFMCPK5nk21q35PFTUdkWudK6B817UPqm2sHTnJ3TrBt0QRSpL3jlyUm gxrFZUMozXdjg4JSJ6IjCNGHgEfT7eSz3v6WCnlAkdcZffnPC1411StHtQt7o5zJp/j4fP nXkG8ve/EYZsGm1uxNRJVvUktGK/k4jU3NIP/3Q66jjzbbA6UQeJFXzlC0og06EJ3ab9Ng ZMIlTnEeo1lmvmleZm4e96PP2wOvaIwr5Kjz4E5SSTIKRZnyC2dwmQljqPyk3A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1785189327; a=rsa-sha256; cv=none; b=IBe5DlnLU/7gGtO3P8bktwHsbXGRli9f/CzA8eLVun/mk4izSFkTYvCRRjw+6h29Bja4fa PZwOI7M7X0JICTxFDaUUSMk1RqmRMGJYltuZpTuRwPC4bXUsLFHBFDq7mU6lbSsx6JnlqL umlkq3PH0vmv4pZvOLOV+GMmYLonAmO4dolE/HdlkRQeqOTI2P08WfFNgOp5IQfKEWSLTw PjCB+4agjolLMsH59BLYvU5kI/ZxsY8y39KrnUf5SXIC/D2YFQdDDuPX+VdO9kyifNRbLX 30Vzz7apUO/emHPMF1sdsep43qIUyn9SEKzOAVUc1xoD1h9NUrxtX1c4dsmtQQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1785189327; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=KDdQSj/ELfJqOpbFHWNm2clEQNPEUqKYf7MUzPfjLoY=; b=LS6poQj5L2UB+MkqULZyIgYucftvFls8YoxAql5cw80Y7/0to9GysN/Fxz/klZ2xEJS4KH ft0y+DO45bHcRe440FhYQXy6r7/o8SMJu5QGPTQ5wV7b2liabYtuLLuZyuMq+u+kCkXgJ5 kehKnS9Bf7dXgQaeO5cZW5DbCcA619VKKwaY+BwcV9zZxMdTJhV/jv+n0z97KQNDgbiPmI Bfz67niXDVMe9TbWShdtpDm1tcXWIiNvdKgwmXeb/ATRst3FQrs3v1rS0JzLTibswogjMX SkLQaYrBGrI9MSPnO9m5fWognCz0ckJsutdMqh+YIAFv5CWehDpzZU3HbvLncA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4h8C7z2V6Gz1Q5H for ; Mon, 27 Jul 2026 21:55:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 21369 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 27 Jul 2026 21:55:27 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Bruce M Simpson Subject: git: d93d23529128 - main - netinet: Replace IFP_TO_IA() with in_ifprimaryaddr() completely. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bms X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d93d235291282b8eec90e49be95a1e78a295b34e Auto-Submitted: auto-generated Date: Mon, 27 Jul 2026 21:55:27 +0000 Message-Id: <6a67d3cf.21369.34fe6774@gitrepo.freebsd.org> The branch main has been updated by bms: URL: https://cgit.FreeBSD.org/src/commit/?id=d93d235291282b8eec90e49be95a1e78a295b34e commit d93d235291282b8eec90e49be95a1e78a295b34e Author: Bruce M Simpson AuthorDate: 2026-02-18 08:53:07 +0000 Commit: Bruce M Simpson CommitDate: 2026-07-27 21:55:12 +0000 netinet: Replace IFP_TO_IA() with in_ifprimaryaddr() completely. IPv4 multicast currently has the big caveat that it depends on the first assigned IPv4 address on an interface (the so-called "primary address"). in_ifprimaryaddr() only needs to be used by the following: - the 0.0.0.0 booting node input workaround in IGMPv1; - filtering out the node's own reports in IGMPv2; - preserving the source IP where an IGMPv3 report has been looped back; - inferring the default upstream IPv4 interface address for the IP_MULTICAST_IF socket option; - and inferring the source address during ip_output() for a multicast datagram where an interface has been explicitly specified by that option. All of these uses mandate the use of IPv4 source address selection, but FreeBSD does not yet (fully) implement this functionality. Approved by: glebius (2026-02-26) Reviewed by: adrian, glebius, pouria Differential Revision: D55345 --- sys/netinet/igmp.c | 10 +++++----- sys/netinet/in_mcast.c | 2 +- sys/netinet/in_var.h | 15 --------------- sys/netinet/ip_output.c | 2 +- 4 files changed, 7 insertions(+), 22 deletions(-) diff --git a/sys/netinet/igmp.c b/sys/netinet/igmp.c index 226f38a035fb..5ca5a4575026 100644 --- a/sys/netinet/igmp.c +++ b/sys/netinet/igmp.c @@ -213,8 +213,8 @@ static MALLOC_DEFINE(M_IGMP, "igmp", "igmp state"); * Obviously the IGMPv3 per-interface state has per-vimage granularity * also as a result. * - * FUTURE: Stop using IFP_TO_IA/INADDR_ANY, and use source address selection - * policy to control the address used by IGMP on the link. + * FUTURE: Use source address selection policy to control the address + * used by IGMP on the link. */ VNET_DEFINE_STATIC(int, interface_timers_running); /* IGMPv3 general * query response */ @@ -1283,7 +1283,7 @@ igmp_input_v1_report(struct ifnet *ifp, /*const*/ struct ip *ip, * Replace 0.0.0.0 with the subnet address if told to do so. */ if (V_igmp_recvifkludge && in_nullhost(ip->ip_src)) { - IFP_TO_IA(ifp, ia); + ia = in_ifprimaryaddr(ifp); if (ia != NULL) ip->ip_src.s_addr = htonl(ia->ia_subnet); } @@ -1377,7 +1377,7 @@ igmp_input_v2_report(struct ifnet *ifp, /*const*/ struct ip *ip, * leave requires knowing that we are the only member of a * group. */ - IFP_TO_IA(ifp, ia); + ia = in_ifprimaryaddr(ifp); if (ia != NULL && in_hosteq(ip->ip_src, IA_SIN(ia)->sin_addr)) { return (0); } @@ -3600,7 +3600,7 @@ igmp_v3_encap_report(struct ifnet *ifp, struct mbuf *m) if (m->m_flags & M_IGMP_LOOP) { struct in_ifaddr *ia; - IFP_TO_IA(ifp, ia); + ia = in_ifprimaryaddr(ifp); if (ia != NULL) ip->ip_src = ia->ia_addr.sin_addr; } diff --git a/sys/netinet/in_mcast.c b/sys/netinet/in_mcast.c index 340218cf5397..934cc71e745b 100644 --- a/sys/netinet/in_mcast.c +++ b/sys/netinet/in_mcast.c @@ -1768,7 +1768,7 @@ inp_getmoptions(struct inpcb *inp, struct sockopt *sopt) mreqn.imr_ifindex = ifp->if_index; NET_EPOCH_ENTER(et); - IFP_TO_IA(ifp, ia); + ia = in_ifprimaryaddr(ifp); if (ia != NULL) mreqn.imr_address = IA_SIN(ia)->sin_addr; diff --git a/sys/netinet/in_var.h b/sys/netinet/in_var.h index 191f3a54dbe5..99a628477155 100644 --- a/sys/netinet/in_var.h +++ b/sys/netinet/in_var.h @@ -151,21 +151,6 @@ do { \ (ifp) = (ia == NULL) ? NULL : ia->ia_ifp; \ } -/* - * Macro for finding the internet address structure (in_ifaddr) corresponding - * to a given interface (ifnet structure). DEPRECATED. - */ -#define IFP_TO_IA(ifp, ia) \ - /* struct ifnet *ifp; */ \ - /* struct in_ifaddr *ia; */ \ -do { \ - NET_EPOCH_ASSERT(); \ - for ((ia) = CK_STAILQ_FIRST(&V_in_ifaddrhead); \ - (ia) != NULL && (ia)->ia_ifp != (ifp); \ - (ia) = CK_STAILQ_NEXT((ia), ia_link)) \ - continue; \ -} while (0) - /* * Legacy IPv4 IGMP per-link structure. */ diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 200f281f34a7..a7cb1234f97c 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -459,7 +459,7 @@ again: */ ifp = imo->imo_multicast_ifp; mtu = ifp->if_mtu; - IFP_TO_IA(ifp, ia); + ia = in_ifprimaryaddr(ifp); isbroadcast = false; /* Interface may have no addresses. */ if (ia != NULL)