summaryrefslogtreecommitdiff
path: root/usr.sbin/ospf6d
diff options
context:
space:
mode:
authorStefan Sperling <stsp@cvs.openbsd.org>2009-03-07 00:33:14 +0000
committerStefan Sperling <stsp@cvs.openbsd.org>2009-03-07 00:33:14 +0000
commitb22a81d6b274dbea0a388b02bf4d0038bbd91f7f (patch)
treeaf8b5b3fe363fcd5d9c81361b6ecdc4253922c68 /usr.sbin/ospf6d
parentbffb22f951ffb8169dd2fcb777a0872b6cd79f86 (diff)
Add lsa_find_tree() to allow searching for LSAs in a specific LSA tree.
We had code marked XXX searching an LSA tree manually using RB_FIND(), switch it over to lsa_find_tree(). Make lsa_find() use the new function, too, to avoid code duplication. ok claudio@
Diffstat (limited to 'usr.sbin/ospf6d')
-rw-r--r--usr.sbin/ospf6d/rde.c15
-rw-r--r--usr.sbin/ospf6d/rde.h3
-rw-r--r--usr.sbin/ospf6d/rde_lsdb.c29
3 files changed, 24 insertions, 23 deletions
diff --git a/usr.sbin/ospf6d/rde.c b/usr.sbin/ospf6d/rde.c
index 7c0175b05b6..dab6850c231 100644
--- a/usr.sbin/ospf6d/rde.c
+++ b/usr.sbin/ospf6d/rde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.c,v 1.24 2009/02/19 22:21:17 stsp Exp $ */
+/* $OpenBSD: rde.c,v 1.25 2009/03/07 00:33:13 stsp Exp $ */
/*
* Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org>
@@ -1483,7 +1483,6 @@ orig_intra_area_prefix_lsas(struct area *area)
struct lsa *lsa;
struct vertex *old;
struct iface *iface;
- struct vertex key;
LIST_FOREACH(iface, &area->iface_list, entry) {
if (iface->type == IF_TYPE_BROADCAST ||
@@ -1496,16 +1495,8 @@ orig_intra_area_prefix_lsas(struct area *area)
}
}
- /* XXX: lsa_find() should take an LSA tree as argument,
- * if you have no iface at hand you cannot use it... */
- bzero(&key, sizeof(key));
- key.type = LSA_TYPE_INTRA_A_PREFIX;
- key.ls_id = LS_ID_INTRA_RTR;
- key.adv_rtr = ntohl(rde_router_id());
- old = RB_FIND(lsa_tree, &area->lsa_tree, &key);
- if (old && old->deleted)
- old = NULL;
-
+ old = lsa_find_tree(&area->lsa_tree, htons(LSA_TYPE_INTRA_A_PREFIX),
+ htonl(LS_ID_INTRA_RTR), rde_router_id());
lsa = orig_intra_lsa_rtr(area, old);
if (lsa)
lsa_merge(rde_nbr_self(area), lsa, old);
diff --git a/usr.sbin/ospf6d/rde.h b/usr.sbin/ospf6d/rde.h
index 10ded006d5a..33de3c2186f 100644
--- a/usr.sbin/ospf6d/rde.h
+++ b/usr.sbin/ospf6d/rde.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.h,v 1.9 2009/02/12 16:54:30 stsp Exp $ */
+/* $OpenBSD: rde.h,v 1.10 2009/03/07 00:33:13 stsp Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -143,6 +143,7 @@ void lsa_del(struct rde_nbr *, struct lsa_hdr *);
void lsa_age(struct vertex *);
struct vertex *lsa_find(struct iface *, u_int16_t, u_int32_t, u_int32_t);
struct vertex *lsa_find_net(struct area *area, u_int32_t);
+struct vertex *lsa_find_tree(struct lsa_tree *, u_int16_t, u_int32_t, u_int32_t);
u_int16_t lsa_num_links(struct vertex *);
void lsa_snap(struct rde_nbr *, u_int32_t);
void lsa_dump(struct lsa_tree *, int, pid_t);
diff --git a/usr.sbin/ospf6d/rde_lsdb.c b/usr.sbin/ospf6d/rde_lsdb.c
index e199eb87ec4..0257408cb5b 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.18 2009/02/12 16:54:31 stsp Exp $ */
+/* $OpenBSD: rde_lsdb.c,v 1.19 2009/03/07 00:33:13 stsp Exp $ */
/*
* Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org>
@@ -507,27 +507,36 @@ struct vertex *
lsa_find(struct iface *iface, u_int16_t type, u_int32_t ls_id,
u_int32_t adv_rtr)
{
- struct vertex key;
- struct vertex *v;
struct lsa_tree *tree;
- key.ls_id = ntohl(ls_id);
- key.adv_rtr = ntohl(adv_rtr);
- key.type = ntohs(type);
-
- if (LSA_IS_SCOPE_AS(key.type))
+ if (LSA_IS_SCOPE_AS(ntohs(type)))
tree = &asext_tree;
- else if (LSA_IS_SCOPE_AREA(key.type)) {
+ else if (LSA_IS_SCOPE_AREA(ntohs(type))) {
struct area *area;
if ((area = area_find(rdeconf, iface->area_id)) == NULL)
fatalx("interface lost area");
tree = &area->lsa_tree;
- } else if (LSA_IS_SCOPE_LLOCAL(key.type))
+ } else if (LSA_IS_SCOPE_LLOCAL(ntohs(type)))
tree = &iface->lsa_tree;
else
fatalx("unknown scope type");
+ return lsa_find_tree(tree, type, ls_id, adv_rtr);
+
+}
+
+struct vertex *
+lsa_find_tree(struct lsa_tree *tree, u_int16_t type, u_int32_t ls_id,
+ u_int32_t adv_rtr)
+{
+ struct vertex key;
+ struct vertex *v;
+
+ key.ls_id = ntohl(ls_id);
+ key.adv_rtr = ntohl(adv_rtr);
+ key.type = ntohs(type);
+
v = RB_FIND(lsa_tree, tree, &key);
/* LSA that are deleted are not findable */