git: e2dc8d789f68 - main - dhclient: do not add 0.0.0.0 interface alias.

From: Alexander V. Chernikov <melifaro_at_FreeBSD.org>
Date: Mon, 06 Mar 2023 15:08:31 UTC
The branch main has been updated by melifaro:

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

commit e2dc8d789f68a9a2267c7f1006aba36c7840b177
Author:     Alexander V. Chernikov <melifaro@FreeBSD.org>
AuthorDate: 2023-03-04 15:18:26 +0000
Commit:     Alexander V. Chernikov <melifaro@FreeBSD.org>
CommitDate: 2023-03-06 15:08:09 +0000

    dhclient: do not add 0.0.0.0 interface alias.
    
    Subscribers: imp
    
    Differential Revision: https://reviews.freebsd.org/D38908
---
 sbin/dhclient/dhclient-script |  3 +--
 sbin/dhclient/dispatch.c      | 27 ++++++++-------------------
 2 files changed, 9 insertions(+), 21 deletions(-)

diff --git a/sbin/dhclient/dhclient-script b/sbin/dhclient/dhclient-script
index c5649e1a1d2a..bcc9050407d4 100755
--- a/sbin/dhclient/dhclient-script
+++ b/sbin/dhclient/dhclient-script
@@ -318,13 +318,12 @@ fi
 case $reason in
 MEDIUM)
 	eval "$IFCONFIG $interface $medium"
-	eval "$IFCONFIG $interface inet -alias 0.0.0.0 $medium" >/dev/null 2>&1
 	sleep 1
 	;;
 
 PREINIT)
 	delete_old_alias
-	$IFCONFIG $interface inet alias 0.0.0.0 netmask 255.0.0.0 broadcast 255.255.255.255 up
+	eval "$IFCONFIG $interface up"
 	;;
 
 ARPCHECK|ARPSEND)
diff --git a/sbin/dhclient/dispatch.c b/sbin/dhclient/dispatch.c
index 91f1694ec902..29ae73103913 100644
--- a/sbin/dhclient/dispatch.c
+++ b/sbin/dhclient/dispatch.c
@@ -78,6 +78,7 @@ discover_interfaces(struct interface_info *iface)
 {
 	struct ifaddrs *ifap, *ifa;
 	struct ifreq *tif;
+	int len = IFNAMSIZ + sizeof(struct sockaddr_storage);
 
 	if (getifaddrs(&ifap) != 0)
 		error("getifaddrs failed");
@@ -118,26 +119,14 @@ discover_interfaces(struct interface_info *iface)
 			iface->hw_address.htype = HTYPE_ETHER; /* XXX */
 			memcpy(iface->hw_address.haddr,
 			    LLADDR(foo), foo->sdl_alen);
-		} else if (ifa->ifa_addr->sa_family == AF_INET) {
-			struct sockaddr_in foo;
-			struct iaddr addr;
-
-			memcpy(&foo, ifa->ifa_addr, sizeof(foo));
-			if (foo.sin_addr.s_addr == htonl(INADDR_LOOPBACK))
-				continue;
-			if (!iface->ifp) {
-				if ((tif = calloc(1, sizeof(struct ifreq)))
-				    == NULL)
-					error("no space to remember ifp");
-				strlcpy(tif->ifr_name, ifa->ifa_name, IFNAMSIZ);
-				memcpy(&tif->ifr_addr, ifa->ifa_addr,
-				    ifa->ifa_addr->sa_len);
-				iface->ifp = tif;
-				iface->primary_address = foo.sin_addr;
-			}
-			addr.len = 4;
-			memcpy(addr.iabuf, &foo.sin_addr.s_addr, addr.len);
 		}
+		if (!iface->ifp) {
+			if ((tif = calloc(1, len)) == NULL)
+				error("no space to remember ifp");
+			strlcpy(tif->ifr_name, ifa->ifa_name, IFNAMSIZ);
+			iface->ifp = tif;
+		}
+
 	}
 
 	if (!iface->ifp)