Source-Changes-HG archive

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

[src/trunk]: src/sys PRU_PURGEADDR -> PRU_PURGEIF, per a discussion w/ itojun...



details:   https://anonhg.NetBSD.org/src/rev/590efb9620dd
branches:  trunk
changeset: 481628:590efb9620dd
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Wed Feb 02 23:28:08 2000 +0000

description:
PRU_PURGEADDR -> PRU_PURGEIF, per a discussion w/ itojun.  In the IPv4
and IPv6 code, also use this to traverse PCB tables, looking for cached
routes referencing the dying ifnet, forcing them to be refreshed.

diffstat:

 sys/net/if.c               |  14 ++++++--------
 sys/netatalk/at_control.c  |  16 +++++++++++++++-
 sys/netatalk/at_extern.h   |   3 ++-
 sys/netatalk/ddp_usrreq.c  |   6 +++---
 sys/netinet/in.c           |  16 +++++++++++++++-
 sys/netinet/in_pcb.c       |  19 ++++++++++++++++++-
 sys/netinet/in_pcb.h       |   3 ++-
 sys/netinet/in_var.h       |   3 ++-
 sys/netinet/raw_ip.c       |   7 ++++---
 sys/netinet/tcp_usrreq.c   |  10 +++++++---
 sys/netinet/udp_usrreq.c   |   7 ++++---
 sys/netinet6/in6.c         |  26 ++++++++++++++------------
 sys/netinet6/in6_pcb.c     |  17 ++++++++++++++++-
 sys/netinet6/in6_pcb.h     |   3 ++-
 sys/netinet6/in6_var.h     |   3 ++-
 sys/netinet6/raw_ip6.c     |   7 ++++---
 sys/netinet6/udp6_usrreq.c |   7 ++++---
 sys/netiso/cltp_usrreq.c   |   6 +++---
 sys/netiso/iso.c           |  16 +++++++++++++++-
 sys/netiso/iso_var.h       |   3 ++-
 sys/netns/idp_usrreq.c     |   6 +++---
 sys/netns/ns.c             |  16 +++++++++++++++-
 sys/netns/ns_var.h         |   3 ++-
 sys/netns/spp_usrreq.c     |   6 +++---
 sys/sys/protosw.h          |   6 +++---
 25 files changed, 166 insertions(+), 63 deletions(-)

diffs (truncated from 596 to 300 lines):

diff -r 13e62e1bfd96 -r 590efb9620dd sys/net/if.c
--- a/sys/net/if.c      Wed Feb 02 22:57:33 2000 +0000
+++ b/sys/net/if.c      Wed Feb 02 23:28:08 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if.c,v 1.53 2000/02/01 22:52:04 thorpej Exp $  */
+/*     $NetBSD: if.c,v 1.54 2000/02/02 23:28:08 thorpej Exp $  */
 
 /*-
  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -418,9 +418,8 @@
                        pr = pffindtype(ifa->ifa_addr->sa_family, SOCK_DGRAM);
                        so.so_proto = pr;
                        if (pr->pr_usrreq) {
-                               (void) (*pr->pr_usrreq)(&so, PRU_PURGEADDR,
-                                   NULL,
-                                   (struct mbuf *) ifa,
+                               (void) (*pr->pr_usrreq)(&so, PRU_PURGEIF,
+                                   NULL, NULL,
                                    (struct mbuf *) ifp, curproc);
                        } else {
                                rtinit(ifa, RTM_DELETE, 0);
@@ -431,10 +430,9 @@
        }
 
        /* Walk the routing table looking for straglers. */
-       for (i = 1; i <= AF_MAX; i++) {
-               if ((rnh = rt_tables[i]) != NULL &&
-                   (*rnh->rnh_walktree)(rnh, if_rt_walktree, ifp) != 0)
-                       break;
+       for (i = 0; i <= AF_MAX; i++) {
+               if ((rnh = rt_tables[i]) != NULL)
+                       (void) (*rnh->rnh_walktree)(rnh, if_rt_walktree, ifp);
        }
 
        IFAFREE(ifnet_addrs[ifp->if_index]);
diff -r 13e62e1bfd96 -r 590efb9620dd sys/netatalk/at_control.c
--- a/sys/netatalk/at_control.c Wed Feb 02 22:57:33 2000 +0000
+++ b/sys/netatalk/at_control.c Wed Feb 02 23:28:08 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: at_control.c,v 1.2 2000/02/01 22:52:06 thorpej Exp $    */
+/*     $NetBSD: at_control.c,v 1.3 2000/02/02 23:28:09 thorpej Exp $    */
 
 /*
  * Copyright (c) 1990,1994 Regents of The University of Michigan.
@@ -330,6 +330,20 @@
        IFAFREE(&aa->aa_ifa);
 }
 
+void
+at_purgeif(ifp)
+       struct ifnet *ifp;
+{
+       struct ifaddr *ifa, *nifa;
+
+       for (ifa = TAILQ_FIRST(&ifp->if_addrlist); ifa != NULL; ifa = nifa) {
+               nifa = TAILQ_NEXT(ifa, ifa_list);
+               if (ifa->ifa_addr->sa_family != AF_APPLETALK)
+                       continue;
+               at_purgeaddr(ifa, ifp);
+       }
+}
+
 /*
  * Given an interface and an at_ifaddr (supposedly on that interface) remove
  * any routes that depend on this. Why ifp is needed I'm not sure, as
diff -r 13e62e1bfd96 -r 590efb9620dd sys/netatalk/at_extern.h
--- a/sys/netatalk/at_extern.h  Wed Feb 02 22:57:33 2000 +0000
+++ b/sys/netatalk/at_extern.h  Wed Feb 02 23:28:08 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: at_extern.h,v 1.4 2000/02/01 22:52:06 thorpej Exp $    */
+/*     $NetBSD: at_extern.h,v 1.5 2000/02/02 23:28:09 thorpej Exp $    */
 
 /*
  * Copyright (c) 1990,1994 Regents of The University of Michigan.
@@ -47,6 +47,7 @@
 void   aarp_clean      __P((void));
 int    at_control      __P((u_long, caddr_t, struct ifnet *, struct proc *));
 void   at_purgeaddr    __P((struct ifaddr *, struct ifnet *));
+void   at_purgeif      __P((struct ifnet *));
 u_int16_t
        at_cksum        __P((struct mbuf *, int));
 int    ddp_usrreq      __P((struct socket *, int, struct mbuf *, struct mbuf *,
diff -r 13e62e1bfd96 -r 590efb9620dd sys/netatalk/ddp_usrreq.c
--- a/sys/netatalk/ddp_usrreq.c Wed Feb 02 22:57:33 2000 +0000
+++ b/sys/netatalk/ddp_usrreq.c Wed Feb 02 23:28:08 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ddp_usrreq.c,v 1.3 2000/02/01 22:52:06 thorpej Exp $    */
+/*     $NetBSD: ddp_usrreq.c,v 1.4 2000/02/02 23:28:09 thorpej Exp $    */
 
 /*
  * Copyright (c) 1990,1991 Regents of The University of Michigan.
@@ -79,8 +79,8 @@
                return (at_control((long) m, (caddr_t) addr,
                    (struct ifnet *) rights, (struct proc *) p));
        }
-       if (req == PRU_PURGEADDR) {
-               at_purgeaddr((struct ifaddr *) addr, (struct ifnet *) rights);
+       if (req == PRU_PURGEIF) {
+               at_purgeif((struct ifnet *) rights);
                return (0);
        }
        if (rights && rights->m_len) {
diff -r 13e62e1bfd96 -r 590efb9620dd sys/netinet/in.c
--- a/sys/netinet/in.c  Wed Feb 02 22:57:33 2000 +0000
+++ b/sys/netinet/in.c  Wed Feb 02 23:28:08 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in.c,v 1.50 2000/02/01 22:52:07 thorpej Exp $  */
+/*     $NetBSD: in.c,v 1.51 2000/02/02 23:28:09 thorpej Exp $  */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -549,6 +549,20 @@
        in_setmaxmtu();
 }
 
+void
+in_purgeif(ifp)
+       struct ifnet *ifp;
+{
+       struct ifaddr *ifa, *nifa;
+
+       for (ifa = TAILQ_FIRST(&ifp->if_addrlist); ifa != NULL; ifa = nifa) {
+               nifa = TAILQ_NEXT(ifa, ifa_list);
+               if (ifa->ifa_addr->sa_family != AF_INET)
+                       continue;
+               in_purgeaddr(ifa, ifp);
+       }
+}
+
 /*
  * SIOC[GAD]LIFADDR.
  *     SIOCGLIFADDR: get first address. (???)
diff -r 13e62e1bfd96 -r 590efb9620dd sys/netinet/in_pcb.c
--- a/sys/netinet/in_pcb.c      Wed Feb 02 22:57:33 2000 +0000
+++ b/sys/netinet/in_pcb.c      Wed Feb 02 23:28:08 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in_pcb.c,v 1.62 2000/02/01 00:05:07 thorpej Exp $      */
+/*     $NetBSD: in_pcb.c,v 1.63 2000/02/02 23:28:09 thorpej Exp $      */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -621,6 +621,23 @@
        }
 }
 
+void
+in_pcbpurgeif(table, ifp)
+       struct inpcbtable *table;
+       struct ifnet *ifp;
+{
+       register struct inpcb *inp, *ninp;
+
+       for (inp = table->inpt_queue.cqh_first;
+           inp != (struct inpcb *)&table->inpt_queue;
+           inp = ninp) {
+               ninp = inp->inp_queue.cqe_next;
+               if (inp->inp_route.ro_rt != NULL &&
+                   inp->inp_route.ro_rt->rt_ifp == ifp)
+                       in_rtchange(inp, 0);
+       }
+}
+
 /*
  * Check for alternatives when higher level complains
  * about service problems.  For now, invalidate cached
diff -r 13e62e1bfd96 -r 590efb9620dd sys/netinet/in_pcb.h
--- a/sys/netinet/in_pcb.h      Wed Feb 02 22:57:33 2000 +0000
+++ b/sys/netinet/in_pcb.h      Wed Feb 02 23:28:08 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in_pcb.h,v 1.28 2000/01/31 14:18:53 itojun Exp $       */
+/*     $NetBSD: in_pcb.h,v 1.29 2000/02/02 23:28:09 thorpej Exp $      */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -151,6 +151,7 @@
            struct in_addr, u_int, int, void (*)(struct inpcb *, int)));
 void   in_pcbnotifyall __P((struct inpcbtable *, struct in_addr, int,
            void (*)(struct inpcb *, int)));
+void   in_pcbpurgeif __P((struct inpcbtable *, struct ifnet *));
 void   in_pcbstate __P((struct inpcb *, int));
 void   in_rtchange __P((struct inpcb *, int));
 void   in_setpeeraddr __P((struct inpcb *, struct mbuf *));
diff -r 13e62e1bfd96 -r 590efb9620dd sys/netinet/in_var.h
--- a/sys/netinet/in_var.h      Wed Feb 02 22:57:33 2000 +0000
+++ b/sys/netinet/in_var.h      Wed Feb 02 23:28:08 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in_var.h,v 1.36 2000/02/01 22:52:08 thorpej Exp $      */
+/*     $NetBSD: in_var.h,v 1.37 2000/02/02 23:28:09 thorpej Exp $      */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -313,6 +313,7 @@
 int    in_control __P((struct socket *, u_long, caddr_t, struct ifnet *,
            struct proc *));
 void   in_purgeaddr __P((struct ifaddr *, struct ifnet *));
+void   in_purgeif __P((struct ifnet *));
 void   ip_input __P((struct mbuf *));
 int    ipflow_fastforward __P((struct mbuf *));
 
diff -r 13e62e1bfd96 -r 590efb9620dd sys/netinet/raw_ip.c
--- a/sys/netinet/raw_ip.c      Wed Feb 02 22:57:33 2000 +0000
+++ b/sys/netinet/raw_ip.c      Wed Feb 02 23:28:08 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: raw_ip.c,v 1.49 2000/02/01 22:52:08 thorpej Exp $      */
+/*     $NetBSD: raw_ip.c,v 1.50 2000/02/02 23:28:09 thorpej Exp $      */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -431,8 +431,9 @@
                return (in_control(so, (long)m, (caddr_t)nam,
                    (struct ifnet *)control, p));
 
-       if (req == PRU_PURGEADDR) {
-               in_purgeaddr((struct ifaddr *)nam, (struct ifnet *)control);
+       if (req == PRU_PURGEIF) {
+               in_purgeif((struct ifnet *)control);
+               in_pcbpurgeif(&rawcbtable, (struct ifnet *)control);
                return (0);
        }
 
diff -r 13e62e1bfd96 -r 590efb9620dd sys/netinet/tcp_usrreq.c
--- a/sys/netinet/tcp_usrreq.c  Wed Feb 02 22:57:33 2000 +0000
+++ b/sys/netinet/tcp_usrreq.c  Wed Feb 02 23:28:08 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tcp_usrreq.c,v 1.45 2000/02/01 22:52:10 thorpej Exp $  */
+/*     $NetBSD: tcp_usrreq.c,v 1.46 2000/02/02 23:28:09 thorpej Exp $  */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -200,8 +200,12 @@
                }
        }
 
-       if (req == PRU_PURGEADDR) {
-               in_purgeaddr((struct ifaddr *)nam, (struct ifnet *)control);
+       if (req == PRU_PURGEIF) {
+               in_purgeif((struct ifnet *)control);
+               in_pcbpurgeif(&tcbtable, (struct ifnet *)control);
+#ifdef INET6
+               in6_pcbpurgeif(&tcb6, (struct ifnet *)control);
+#endif
                return (0);
        }
 
diff -r 13e62e1bfd96 -r 590efb9620dd sys/netinet/udp_usrreq.c
--- a/sys/netinet/udp_usrreq.c  Wed Feb 02 22:57:33 2000 +0000
+++ b/sys/netinet/udp_usrreq.c  Wed Feb 02 23:28:08 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: udp_usrreq.c,v 1.59 2000/02/01 22:52:10 thorpej Exp $  */
+/*     $NetBSD: udp_usrreq.c,v 1.60 2000/02/02 23:28:09 thorpej Exp $  */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -1309,8 +1309,9 @@
                return (in_control(so, (long)m, (caddr_t)nam,
                    (struct ifnet *)control, p));
 
-       if (req == PRU_PURGEADDR) {
-               in_purgeaddr((struct ifaddr *)nam, (struct ifnet *)control);
+       if (req == PRU_PURGEIF) {
+               in_purgeif((struct ifnet *)control);
+               in_pcbpurgeif(&udbtable, (struct ifnet *)control);
                return (0);
        }
 
diff -r 13e62e1bfd96 -r 590efb9620dd sys/netinet6/in6.c
--- a/sys/netinet6/in6.c        Wed Feb 02 22:57:33 2000 +0000
+++ b/sys/netinet6/in6.c        Wed Feb 02 23:28:08 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in6.c,v 1.13 2000/02/02 17:54:07 itojun Exp $  */
+/*     $NetBSD: in6.c,v 1.14 2000/02/02 23:28:10 thorpej Exp $ */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -946,20 +946,22 @@
        }
 
        IFAFREE(&oia->ia_ifa);
+}
 
-       /*
-        * if the interface is going away, and this was the last IPv6
-        * address on the interface, remove route to link-local
-        * allnodes multicast address
-        */
-       if (ifp->if_output == if_nulloutput) {
-               /* was it the last IPv6 address for the interface? */
-               for (ifa = ifp->if_addrlist.tqh_first; ifa; ifa = ifa->ifa_list.tqe_next)
-                       if (ifa->ifa_addr->sa_family == AF_INET6)
-                               return;
+void
+in6_purgeif(ifp)
+       struct ifnet *ifp;
+{
+       struct ifaddr *ifa, *nifa;
 
-               in6_ifdetach(ifp);
+       for (ifa = TAILQ_FIRST(&ifp->if_addrlist); ifa != NULL; ifa = nifa) {
+               nifa = TAILQ_NEXT(ifa, ifa_list);
+               if (ifa->ifa_addr->sa_family != AF_INET6)



Home | Main Index | Thread Index | Old Index