Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netinet avoid SIOCSIFADDR if there's an IPv4 address alr...



details:   https://anonhg.NetBSD.org/src/rev/0febe82e246c
branches:  trunk
changeset: 535985:0febe82e246c
user:      itojun <itojun%NetBSD.org@localhost>
date:      Wed Sep 04 00:03:58 2002 +0000

description:
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

diffstat:

 sys/netinet/in.c |  16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diffs (44 lines):

diff -r 1d0966145300 -r 0febe82e246c sys/netinet/in.c
--- a/sys/netinet/in.c  Tue Sep 03 23:00:40 2002 +0000
+++ b/sys/netinet/in.c  Wed Sep 04 00:03:58 2002 +0000
@@ -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 @@
        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 @@
         * 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);



Home | Main Index | Thread Index | Old Index