Source-Changes-HG archive

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

[src/trunk]: src/sys/netinet6 honor ifa reference counting.



details:   https://anonhg.NetBSD.org/src/rev/214e9afb88d9
branches:  trunk
changeset: 481908:214e9afb88d9
user:      itojun <itojun%NetBSD.org@localhost>
date:      Wed Feb 09 03:34:01 2000 +0000

description:
honor ifa reference counting.

diffstat:

 sys/netinet6/in6_prefix.c |  19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)

diffs (82 lines):

diff -r 7b8b680e7e2e -r 214e9afb88d9 sys/netinet6/in6_prefix.c
--- a/sys/netinet6/in6_prefix.c Wed Feb 09 03:27:29 2000 +0000
+++ b/sys/netinet6/in6_prefix.c Wed Feb 09 03:34:01 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in6_prefix.c,v 1.9 2000/02/07 05:48:11 itojun Exp $    */
+/*     $NetBSD: in6_prefix.c,v 1.10 2000/02/09 03:34:01 itojun Exp $   */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -386,6 +386,7 @@
                 sizeof(*IA6_IN6(ia)) << 3, rpp->rp_plen, iilen);
        /* link to ia, and put into list */
        rap->ra_addr = ia;
+       IFAREF(&rap->ra_addr->ia_ifa);
 #if 0 /* Can't do this now, because rpp may be on th stack. should fix it? */
        ia->ia6_ifpr = rp2ifpr(rpp);
 #endif
@@ -485,9 +486,10 @@
        }
        rap = search_ifidwithprefix(ifpr2rp(ifpr), IA6_IN6(ia));
        if (rap != NULL) {
-               if (rap->ra_addr == NULL)
+               if (rap->ra_addr == NULL) {
                        rap->ra_addr = ia;
-               else if (rap->ra_addr != ia) {
+                       IFAREF(&rap->ra_addr->ia_ifa);
+               } else if (rap->ra_addr != ia) {
                        /* There may be some inconsistencies between addrs. */
                        log(LOG_ERR, "ip6_prefix.c: addr %s/%d matched prefix"
                            "has already another ia %p(%s) on its ifid list\n",
@@ -517,6 +519,8 @@
                int s = splsoftnet();
                LIST_REMOVE(rap, ra_entry);
                splx(s);
+               if (rap->ra_addr)
+                       IFAFREE(&rap->ra_addr->ia_ifa);
                free(rap, M_RR_ADDR);
        }
        if (LIST_FIRST(&ifpr2rp(ia->ia6_ifpr)->rp_addrhead) == NULL)
@@ -570,12 +574,16 @@
        if (ia6 != NULL) {
                if (ia6->ia6_ifpr == NULL) {
                        /* link this addr and the prefix each other */
+                       IFAFREE(&rap->ra_addr->ia_ifa);
                        rap->ra_addr = ia6;
+                       IFAREF(&rap->ra_addr->ia_ifa);
                        ia6->ia6_ifpr = rp2ifpr(rpp);
                        return;
                }
                if (ia6->ia6_ifpr == rp2ifpr(rpp)) {
+                       IFAFREE(&rap->ra_addr->ia_ifa);
                        rap->ra_addr = ia6;
+                       IFAREF(&rap->ra_addr->ia_ifa);
                        return;
                }
                /*
@@ -663,6 +671,8 @@
                        LIST_REMOVE(rap, ra_entry);
                        if (search_ifidwithprefix(rpp, &rap->ra_ifid)
                            != NULL) {
+                               if (rap->ra_addr)
+                                       IFAFREE(&rap->ra_addr->ia_ifa);
                                free(rap, M_RR_ADDR);
                                continue;
                        }
@@ -849,6 +859,8 @@
 
                rap = LIST_FIRST(&rpp->rp_addrhead);
                LIST_REMOVE(rap, ra_entry);
+               if (rap->ra_addr)
+                       IFAFREE(&rap->ra_addr->ia_ifa);
                free(rap, M_RR_ADDR);
        }
 }
@@ -919,6 +931,7 @@
                rap->ra_addr->ia6_ifpr = NULL;
 
                in6_purgeaddr(&rap->ra_addr->ia_ifa, rpp->rp_ifp);
+               IFAFREE(&rap->ra_addr->ia_ifa);
                free(rap, M_RR_ADDR);
        }
        rp_remove(rpp);



Home | Main Index | Thread Index | Old Index