diff --git a/sys/netinet/in.c b/sys/netinet/in.c index c2d64a0e5ab5..4ab2946c782b 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -1,4 +1,4 @@ -/* $NetBSD: in.c,v 1.77 2002/06/09 16:33:38 itojun Exp $ */ +/* $NetBSD: in.c,v 1.78 2002/09/04 00:03:58 itojun Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -102,7 +102,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.77 2002/06/09 16:33:38 itojun Exp $"); +__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.78 2002/09/04 00:03:58 itojun Exp $"); #include "opt_inet.h" #include "opt_inet_conf.h" @@ -792,6 +792,8 @@ in_ifinit(ifp, ia, sin, scrub) u_int32_t i = sin->sin_addr.s_addr; struct sockaddr_in oldaddr; int s = splnet(), flags = RTF_UP, error; + int ifacount; + struct ifaddr *ifa; /* * Set up new addresses. @@ -807,7 +809,15 @@ in_ifinit(ifp, ia, sin, scrub) * if this is its first address, * and to validate the address if necessary. */ - if (ifp->if_ioctl && + ifacount = 0; + TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { + if (ifa->ifa_addr == NULL) + continue; + if (ifa->ifa_addr->sa_family != AF_INET) + continue; + ifacount++; + } + if (ifacount <= 1 && ifp->if_ioctl && (error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR, (caddr_t)ia))) goto bad; splx(s);