avoid SIOCSIFADDR if there's an IPv4 address already.

the comment doesn't match the behavior, it seems that the code assumed that
there's only one IPv4 address on an interface.  sync w/kame
This commit is contained in:
itojun 2002-09-04 00:03:58 +00:00
parent a4e86e6cd5
commit 91d888cd38
1 changed files with 13 additions and 3 deletions

View File

@ -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 <sys/cdefs.h>
__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);