summaryrefslogtreecommitdiff
path: root/usr.sbin/ospf6d
diff options
context:
space:
mode:
authorStefan Sperling <stsp@cvs.openbsd.org>2009-03-10 17:32:15 +0000
committerStefan Sperling <stsp@cvs.openbsd.org>2009-03-10 17:32:15 +0000
commit0c394b889308824a30f7e568a6958f6fb13caf41 (patch)
tree7fbae584a09725a737f561d63ad21a8136f2aa28 /usr.sbin/ospf6d
parent8904bbc45c13f4c7e6c0e8d2187a2bcff1a4991a (diff)
The linked() function had an identity crisis and referred to itself
as "spf_calc" in fatal error messages.
Diffstat (limited to 'usr.sbin/ospf6d')
-rw-r--r--usr.sbin/ospf6d/rde_lsdb.c58
1 files changed, 27 insertions, 31 deletions
diff --git a/usr.sbin/ospf6d/rde_lsdb.c b/usr.sbin/ospf6d/rde_lsdb.c
index 64667616360..7a015d04d10 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.20 2009/03/08 14:40:11 stsp Exp $ */
+/* $OpenBSD: rde_lsdb.c,v 1.21 2009/03/10 17:32:14 stsp Exp $ */
/*
* Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org>
@@ -343,44 +343,39 @@ lsa_intra_a_pref_check(struct lsa *lsa, u_int16_t len)
}
int
-lsa_self(struct rde_nbr *nbr, struct lsa *new, struct vertex *v)
+lsa_self(struct lsa *lsa)
{
- struct lsa *dummy;
-
- if (nbr->self)
- return (0);
+ /* Determine if LSA is self-originated. */
+ return rde_router_id() == lsa->hdr.adv_rtr;
+}
- if (rde_router_id() != new->hdr.adv_rtr)
- return (0);
+void
+lsa_flush(struct rde_nbr *nbr, struct lsa *lsa)
+{
+ struct lsa *copy;
- if (v == NULL) {
- /*
- * LSA is no longer announced, remove by premature aging.
- * The problem is that new may not be altered so a copy
- * needs to be added to the LSA DB first.
- */
- if ((dummy = malloc(ntohs(new->hdr.len))) == NULL)
- fatal("lsa_self");
- memcpy(dummy, new, ntohs(new->hdr.len));
- dummy->hdr.age = htons(MAX_AGE);
- /*
- * The clue is that by using the remote nbr as originator
- * the dummy LSA will be reflooded via the default timeout
- * handler.
- */
- (void)lsa_add(rde_nbr_self(nbr->area), dummy);
- return (1);
- }
+ /*
+ * The LSA may not be altered because the caller may still use it,
+ * so a copy needs to be added to the LSDB first.
+ * The copy will be reflooded via the default timeout handler.
+ */
+ if ((copy = malloc(ntohs(lsa->hdr.len))) == NULL)
+ fatal("lsa_flush");
+ memcpy(copy, lsa, ntohs(lsa->hdr.len));
+ copy->hdr.age = htons(MAX_AGE);
+ (void)lsa_add(rde_nbr_self(nbr->area), copy);
+}
+void
+lsa_reflood(struct vertex *v, struct lsa *new)
+{
/*
- * LSA is still originated, just reflood it. But we need to create
- * a new instance by setting the LSA sequence number equal to the
- * one of new and calling lsa_refresh(). Flooding will be done by the
- * caller.
+ * We need to create a new instance by setting the LSA sequence
+ * number equal to the one of 'new' and calling lsa_refresh().
+ * The LSA will be reflooded via the default timeout handler.
*/
v->lsa->hdr.seq_num = new->hdr.seq_num;
lsa_refresh(v);
- return (1);
}
int
@@ -562,6 +557,7 @@ lsa_num_links(struct vertex *v)
{
switch (v->type) {
case LSA_TYPE_ROUTER:
+ /* TODO: multiple router LSAs */
return ((ntohs(v->lsa->hdr.len) - sizeof(struct lsa_hdr)
- sizeof(u_int32_t)) / sizeof(struct lsa_rtr_link));
case LSA_TYPE_NETWORK: