From: Paul Mackerras Date: Thu, 27 Nov 1997 06:10:04 +0000 (+0000) Subject: remove if address before changing X-Git-Tag: RELEASE_2_3_6~146 X-Git-Url: http://git.ozlabs.org/?p=ppp.git;a=commitdiff_plain;h=9ecdd467f96ff0977e57187f294883134c2f41b9 remove if address before changing --- diff --git a/pppd/sys-bsd.c b/pppd/sys-bsd.c index 0aee267..46962de 100644 --- a/pppd/sys-bsd.c +++ b/pppd/sys-bsd.c @@ -21,8 +21,8 @@ */ #ifndef lint -static char rcsid[] = "$Id: sys-bsd.c,v 1.28 1997/04/30 05:57:46 paulus Exp $"; -#endif +static char rcsid[] = "$Id: sys-bsd.c,v 1.29 1997/11/27 06:10:04 paulus Exp $"; +/* $NetBSD: sys-bsd.c,v 1.1.1.3 1997/09/26 18:53:04 christos Exp $ */ /* * TODO: @@ -58,7 +58,12 @@ static char rcsid[] = "$Id: sys-bsd.c,v 1.28 1997/04/30 05:57:46 paulus Exp $"; #include #if RTM_VERSION >= 3 -#include +#include +#if defined(NetBSD) && (NetBSD >= 199703) +#include +#else /* NetBSD 1.2D or later */ +#include +#endif #endif #include "pppd.h" @@ -946,6 +951,7 @@ sifaddr(u, o, h, m) u_int32_t o, h, m; { struct ifaliasreq ifra; + struct ifreq ifr; strncpy(ifra.ifra_name, ifname, sizeof(ifra.ifra_name)); SET_SA_FAMILY(ifra.ifra_addr, AF_INET); @@ -957,6 +963,12 @@ sifaddr(u, o, h, m) ((struct sockaddr_in *) &ifra.ifra_mask)->sin_addr.s_addr = m; } else BZERO(&ifra.ifra_mask, sizeof(ifra.ifra_mask)); + BZERO(&ifr, sizeof(ifr)); + strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); + if (ioctl(sockfd, SIOCDIFADDR, (caddr_t) &ifr) < 0) { + if (errno != EADDRNOTAVAIL) + syslog(LOG_WARNING, "Couldn't remove interface address: %m"); + } if (ioctl(sockfd, SIOCAIFADDR, (caddr_t) &ifra) < 0) { if (errno != EEXIST) { syslog(LOG_ERR, "Couldn't set interface address: %m");