diff options
author | Esben Norby <norby@cvs.openbsd.org> | 2006-02-09 20:47:21 +0000 |
---|---|---|
committer | Esben Norby <norby@cvs.openbsd.org> | 2006-02-09 20:47:21 +0000 |
commit | 26c75d270994c70a5d3ddde49551934ed142ba38 (patch) | |
tree | 2d73a55260cdd1d98fcb4cb698ff2db9acff6aed /usr.sbin/ospfd | |
parent | d57aef148afa0cc5051c6239ff7c52cb50634681 (diff) |
Don't calculate all areas every time the link state database is updated,
only calculate the dirty ones.
ok claudio@
Diffstat (limited to 'usr.sbin/ospfd')
-rw-r--r-- | usr.sbin/ospfd/ospfd.h | 3 | ||||
-rw-r--r-- | usr.sbin/ospfd/rde_lsdb.c | 12 | ||||
-rw-r--r-- | usr.sbin/ospfd/rde_spf.c | 16 |
3 files changed, 20 insertions, 11 deletions
diff --git a/usr.sbin/ospfd/ospfd.h b/usr.sbin/ospfd/ospfd.h index 62e676dde7c..7ae0e39d012 100644 --- a/usr.sbin/ospfd/ospfd.h +++ b/usr.sbin/ospfd/ospfd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfd.h,v 1.42 2006/02/01 18:31:47 norby Exp $ */ +/* $OpenBSD: ospfd.h,v 1.43 2006/02/09 20:47:20 norby Exp $ */ /* * Copyright (c) 2004 Esben Norby <norby@openbsd.org> @@ -181,6 +181,7 @@ struct area { u_int8_t priority; u_int8_t transit; u_int8_t stub; + u_int8_t dirty; }; /* interface states */ diff --git a/usr.sbin/ospfd/rde_lsdb.c b/usr.sbin/ospfd/rde_lsdb.c index 0b9370f380a..da325cf6e88 100644 --- a/usr.sbin/ospfd/rde_lsdb.c +++ b/usr.sbin/ospfd/rde_lsdb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_lsdb.c,v 1.24 2006/01/05 15:10:57 norby Exp $ */ +/* $OpenBSD: rde_lsdb.c,v 1.25 2006/02/09 20:47:20 norby Exp $ */ /* * Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org> @@ -344,14 +344,17 @@ lsa_add(struct rde_nbr *nbr, struct lsa *lsa) old = RB_INSERT(lsa_tree, tree, new); if (old != NULL) { - if (!lsa_equal(new->lsa, old->lsa)) + if (!lsa_equal(new->lsa, old->lsa)) { + nbr->area->dirty = 1; start_spf_timer(); + } RB_REMOVE(lsa_tree, tree, old); vertex_free(old); RB_INSERT(lsa_tree, tree, new); - } else + } else { + nbr->area->dirty = 1; start_spf_timer(); - + } /* timeout handling either MAX_AGE or LS_REFRESH_TIME */ timerclear(&tv); @@ -615,6 +618,7 @@ lsa_merge(struct rde_nbr *nbr, struct lsa *lsa, struct vertex *v) free(v->lsa); v->lsa = lsa; start_spf_timer(); + nbr->area->dirty = 1; /* set correct timeout for reflooding the LSA */ clock_gettime(CLOCK_MONOTONIC, &tp); diff --git a/usr.sbin/ospfd/rde_spf.c b/usr.sbin/ospfd/rde_spf.c index 99b36c53420..72818bdca9a 100644 --- a/usr.sbin/ospfd/rde_spf.c +++ b/usr.sbin/ospfd/rde_spf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_spf.c,v 1.46 2006/02/02 15:10:57 norby Exp $ */ +/* $OpenBSD: rde_spf.c,v 1.47 2006/02/09 20:47:20 norby Exp $ */ /* * Copyright (c) 2005 Esben Norby <norby@openbsd.org> @@ -536,12 +536,16 @@ spf_timer(int fd, short event, void *arg) rt_invalidate(); LIST_FOREACH(area, &conf->area_list, entry) { - /* calculate SPF tree */ - spf_calc(area); + if (area->dirty) { + /* calculate SPF tree */ + spf_calc(area); - /* calculate route table */ - RB_FOREACH(v, lsa_tree, &area->lsa_tree) { - rt_calc(v, area); + /* calculate route table */ + RB_FOREACH(v, lsa_tree, &area->lsa_tree) { + rt_calc(v, area); + } + + area->dirty = 0; } } |