Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Oct 2021 23:31:28 GMT
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 5c5340108e9c - main - net: Allow binding of unspecified address without address existance
Message-ID:  <202110202331.19KNVSbL074530@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=5c5340108e9c2e384ca646720e17d037c69acc4c

commit 5c5340108e9c2e384ca646720e17d037c69acc4c
Author:     Roy Marples <roy@marples.name>
AuthorDate: 2021-10-20 15:47:29 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2021-10-20 23:25:51 +0000

    net: Allow binding of unspecified address without address existance
    
    Previously in_pcbbind_setup returned EADDRNOTAVAIL for empty
    V_in_ifaddrhead (i.e., no IPv4 addresses configured) and in6_pcbbind
    did the same for empty V_in6_ifaddrhead (no IPv6 addresses).
    
    An equivalent test has existed since 4.4-Lite.  It was presumably done
    to avoid extra work (assuming the address isn't going to be found
    later).
    
    In normal system operation *_ifaddrhead will not be empty: they will
    at least have the loopback address(es).  In practice no work will be
    avoided.
    
    Further, this case caused net/dhcpd to fail when run early in boot
    before assignment of any addresses.  It should be possible to bind the
    unspecified address even if no addresses have been configured yet, so
    just remove the tests.
    
    The now-removed "XXX broken" comments were added in 59562606b9d3,
    which converted the ifaddr lists to TAILQs.  As far as I (emaste) can
    tell the brokenness is the issue described above, not some aspect of
    the TAILQ conversion.
    
    PR:             253166
    Reviewed by:    ae, bz, donner, emaste, glebius
    MFC after:      1 month
    Differential Revision:  https://reviews.freebsd.org/D32563
---
 sys/netinet/in_pcb.c   | 2 --
 sys/netinet6/in6_pcb.c | 2 --
 2 files changed, 4 deletions(-)

diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index 1a7639c0137b..b8b5c6fbdcd5 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -932,8 +932,6 @@ in_pcbbind_setup(struct inpcb *inp, struct sockaddr *nam, in_addr_t *laddrp,
 	INP_LOCK_ASSERT(inp);
 	INP_HASH_LOCK_ASSERT(pcbinfo);
 
-	if (CK_STAILQ_EMPTY(&V_in_ifaddrhead)) /* XXX broken! */
-		return (EADDRNOTAVAIL);
 	laddr.s_addr = *laddrp;
 	if (nam != NULL && laddr.s_addr != INADDR_ANY)
 		return (EINVAL);
diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c
index 9a5d69e16a1c..ad4cda9d48ab 100644
--- a/sys/netinet6/in6_pcb.c
+++ b/sys/netinet6/in6_pcb.c
@@ -173,8 +173,6 @@ in6_pcbbind(struct inpcb *inp, struct sockaddr *nam,
 	INP_WLOCK_ASSERT(inp);
 	INP_HASH_WLOCK_ASSERT(pcbinfo);
 
-	if (CK_STAILQ_EMPTY(&V_in6_ifaddrhead))	/* XXX broken! */
-		return (EADDRNOTAVAIL);
 	if (inp->inp_lport || !IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr))
 		return (EINVAL);
 	if ((so->so_options & (SO_REUSEADDR|SO_REUSEPORT|SO_REUSEPORT_LB)) == 0)



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