Source-Changes-HG archive

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

[src/netbsd-1-6]: src/sys/net Apply patch (requested by itojun in ticket #1290):



details:   https://anonhg.NetBSD.org/src/rev/964d4ec0cf01
branches:  netbsd-1-6
changeset: 530370:964d4ec0cf01
user:      grant <grant%NetBSD.org@localhost>
date:      Thu Jun 19 02:39:52 2003 +0000

description:
Apply patch (requested by itojun in ticket #1290):

AF_LINK sockaddr has to be attached to ifp->if_addrlist until the end,
as many of the code assumes that TAILQ_FIRST(ifp->if_addrlist) is
non-null.

diffstat:

 sys/net/if.c |  67 ++++++++++++++++++++++++++---------------------------------
 1 files changed, 30 insertions(+), 37 deletions(-)

diffs (112 lines):

diff -r c4bbaed2089c -r 964d4ec0cf01 sys/net/if.c
--- a/sys/net/if.c      Thu Jun 19 02:29:50 2003 +0000
+++ b/sys/net/if.c      Thu Jun 19 02:39:52 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if.c,v 1.104.4.1 2002/11/01 10:56:17 tron Exp $        */
+/*     $NetBSD: if.c,v 1.104.4.2 2003/06/19 02:39:52 grant Exp $       */
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.104.4.1 2002/11/01 10:56:17 tron Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.104.4.2 2003/06/19 02:39:52 grant Exp $");
 
 #include "opt_inet.h"
 
@@ -508,7 +508,7 @@
        struct ifnet *ifp;
 {
        struct socket so;
-       struct ifaddr *ifa;
+       struct ifaddr *ifa, *next;
 #ifdef IFAREF_DEBUG
        struct ifaddr *last_ifa = NULL;
 #endif
@@ -541,13 +541,12 @@
        (void) pfil_head_unregister(&ifp->if_pfil);
 #endif
 
-       if_free_sadl(ifp);
-
        /*
         * Rip all the addresses off the interface.  This should make
         * all of the routes go away.
         */
-       while ((ifa = TAILQ_FIRST(&ifp->if_addrlist)) != NULL) {
+       for (ifa = TAILQ_FIRST(&ifp->if_addrlist); ifa; ifa = next) {
+               next = TAILQ_NEXT(ifa, ifa_list);
                family = ifa->ifa_addr->sa_family;
 #ifdef IFAREF_DEBUG
                printf("if_detach: ifaddr %p, family %d, refcnt %d\n",
@@ -556,43 +555,37 @@
                        panic("if_detach: loop detected");
                last_ifa = ifa;
 #endif
-               if (family == AF_LINK) {
-                       /*
-                        * XXX This case may now be obsolete by
-                        * XXX the call to if_free_sadl().
-                        */
-                       rtinit(ifa, RTM_DELETE, 0);
-                       TAILQ_REMOVE(&ifp->if_addrlist, ifa, ifa_list);
-                       IFAFREE(ifa);
-               } else {
-                       dp = pffinddomain(family);
+               if (family == AF_LINK)
+                       continue;
+               dp = pffinddomain(family);
 #ifdef DIAGNOSTIC
-                       if (dp == NULL)
-                               panic("if_detach: no domain for AF %d\n",
-                                   family);
+               if (dp == NULL)
+                       panic("if_detach: no domain for AF %d\n",
+                           family);
 #endif
-                       purged = 0;
-                       for (pr = dp->dom_protosw;
-                            pr < dp->dom_protoswNPROTOSW; pr++) {
-                               so.so_proto = pr;
-                               if (pr->pr_usrreq != NULL) {
-                                       (void) (*pr->pr_usrreq)(&so,
-                                           PRU_PURGEIF, NULL, NULL,
-                                           (struct mbuf *) ifp, curproc);
-                                       purged = 1;
-                               }
-                       }
-                       if (purged == 0) {
-                               /*
-                                * XXX What's really the best thing to do
-                                * XXX here?  --thorpej%netbsd.org@localhost
-                                */
-                               printf("if_detach: WARNING: AF %d not purged\n",
-                                   family);
+               purged = 0;
+               for (pr = dp->dom_protosw;
+                    pr < dp->dom_protoswNPROTOSW; pr++) {
+                       so.so_proto = pr;
+                       if (pr->pr_usrreq != NULL) {
+                               (void) (*pr->pr_usrreq)(&so,
+                                   PRU_PURGEIF, NULL, NULL,
+                                   (struct mbuf *) ifp, curproc);
+                               purged = 1;
                        }
                }
+               if (purged == 0) {
+                       /*
+                        * XXX What's really the best thing to do
+                        * XXX here?  --thorpej%netbsd.org@localhost
+                        */
+                       printf("if_detach: WARNING: AF %d not purged\n",
+                           family);
+               }
        }
 
+       if_free_sadl(ifp);
+
        /* Walk the routing table looking for straglers. */
        for (i = 0; i <= AF_MAX; i++) {
                if ((rnh = rt_tables[i]) != NULL)



Home | Main Index | Thread Index | Old Index