diff options
author | Stefan Sperling <stsp@cvs.openbsd.org> | 2009-02-12 16:54:32 +0000 |
---|---|---|
committer | Stefan Sperling <stsp@cvs.openbsd.org> | 2009-02-12 16:54:32 +0000 |
commit | f2977c3ace1c02f6905aa839cd4bf1503ef2fa21 (patch) | |
tree | 855c4e226de1e4ea5f29789ce4dfb1b7482dfcdb /usr.sbin/ospf6d | |
parent | c1665c605cee2d8efce682f3fecb6bf1a6d59242 (diff) |
Make vertex_free() correctly free LSAs in per-interface LSA trees.
Save a pointer to the right LSA tree in new member v->lsa_tree.
This saves us the hassle of finding the right tree in vertex_free(),
we already know it at creation time so why not tuck it in there?
This might cause problems if the ospfe side ever decides to call
area_del() with a non-empty area->lsa_tree, without correctly
initialising v->lsa_tree. But grep shows that the area's lsa_tree
is currently just initialized on the ospfe side, but never modified.
ospf6d daemons which crashed after about 1 min with malloc options
FGJ are now happy.
ok claudio@
Diffstat (limited to 'usr.sbin/ospf6d')
-rw-r--r-- | usr.sbin/ospf6d/rde.h | 3 | ||||
-rw-r--r-- | usr.sbin/ospf6d/rde_lsdb.c | 15 |
2 files changed, 8 insertions, 10 deletions
diff --git a/usr.sbin/ospf6d/rde.h b/usr.sbin/ospf6d/rde.h index 6468437964f..10ded006d5a 100644 --- a/usr.sbin/ospf6d/rde.h +++ b/usr.sbin/ospf6d/rde.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.h,v 1.8 2009/01/27 21:58:28 stsp Exp $ */ +/* $OpenBSD: rde.h,v 1.9 2009/02/12 16:54:30 stsp Exp $ */ /* * Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org> @@ -41,6 +41,7 @@ struct vertex { struct event ev; struct area *area; struct lsa *lsa; + struct lsa_tree *lsa_tree; time_t changed; time_t stamp; u_int32_t cost; diff --git a/usr.sbin/ospf6d/rde_lsdb.c b/usr.sbin/ospf6d/rde_lsdb.c index 2ab88a2c171..e199eb87ec4 100644 --- a/usr.sbin/ospf6d/rde_lsdb.c +++ b/usr.sbin/ospf6d/rde_lsdb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_lsdb.c,v 1.17 2009/01/29 18:52:17 stsp Exp $ */ +/* $OpenBSD: rde_lsdb.c,v 1.18 2009/02/12 16:54:31 stsp Exp $ */ /* * Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org> @@ -27,7 +27,7 @@ #include "rde.h" #include "log.h" -struct vertex *vertex_get(struct lsa *, struct rde_nbr *); +struct vertex *vertex_get(struct lsa *, struct rde_nbr *, struct lsa_tree *); int lsa_link_check(struct lsa *, u_int16_t); int lsa_intra_a_pref_check(struct lsa *, u_int16_t); @@ -66,7 +66,7 @@ lsa_compare(struct vertex *a, struct vertex *b) struct vertex * -vertex_get(struct lsa *lsa, struct rde_nbr *nbr) +vertex_get(struct lsa *lsa, struct rde_nbr *nbr, struct lsa_tree *tree) { struct vertex *v; struct timespec tp; @@ -83,6 +83,7 @@ vertex_get(struct lsa *lsa, struct rde_nbr *nbr) v->ls_id = ntohl(lsa->hdr.ls_id); v->adv_rtr = ntohl(lsa->hdr.adv_rtr); v->type = ntohs(lsa->hdr.type); + v->lsa_tree = tree; if (!nbr->self) v->flooded = 1; /* XXX fix me */ @@ -96,11 +97,7 @@ vertex_get(struct lsa *lsa, struct rde_nbr *nbr) void vertex_free(struct vertex *v) { - if (v->type == LSA_TYPE_EXTERNAL) - RB_REMOVE(lsa_tree, &asext_tree, v); - else - RB_REMOVE(lsa_tree, &v->area->lsa_tree, v); - + RB_REMOVE(lsa_tree, v->lsa_tree, v); (void)evtimer_del(&v->ev); free(v->lsa); free(v); @@ -415,7 +412,7 @@ lsa_add(struct rde_nbr *nbr, struct lsa *lsa) else fatalx("unknown scope type"); - new = vertex_get(lsa, nbr); + new = vertex_get(lsa, nbr, tree); old = RB_INSERT(lsa_tree, tree, new); if (old != NULL) { |