summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorclaudio <claudio@openbsd.org>2007-01-29 13:04:13 +0000
committerclaudio <claudio@openbsd.org>2007-01-29 13:04:13 +0000
commit9bd8cd2ae5c271cc08eef92927d44dba293d6bdb (patch)
tree96a08f6f5468354599f339d1069bb218ddf37456
parentBump fixed part of the stackgap to 2k. Allows two full paths to be (diff)
downloadwireguard-openbsd-9bd8cd2ae5c271cc08eef92927d44dba293d6bdb.tar.xz
wireguard-openbsd-9bd8cd2ae5c271cc08eef92927d44dba293d6bdb.zip
Do not link from the LS DB to outside structures that may vanish before
the actual LS DB entry is removed. In particular a neighbor may be removed at any time -- we were lucky because we kept down neighbors around for another 24h. Reload support unhided this problem again. Just copy the needed info into the vertex. Pointing to the area is save as the vertex is part of the area itself and removed when the area is removed. OK norby@
-rw-r--r--usr.sbin/ospfd/rde.c4
-rw-r--r--usr.sbin/ospfd/rde.h6
-rw-r--r--usr.sbin/ospfd/rde_lsdb.c21
-rw-r--r--usr.sbin/ospfd/rde_spf.c6
4 files changed, 21 insertions, 16 deletions
diff --git a/usr.sbin/ospfd/rde.c b/usr.sbin/ospfd/rde.c
index 37bda4347c4..3993cc6ddb5 100644
--- a/usr.sbin/ospfd/rde.c
+++ b/usr.sbin/ospfd/rde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.c,v 1.54 2007/01/24 10:48:47 claudio Exp $ */
+/* $OpenBSD: rde.c,v 1.55 2007/01/29 13:04:13 claudio Exp $ */
/*
* Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org>
@@ -428,7 +428,7 @@ rde_dispatch_imsg(int fd, short event, void *bula)
/* reflood self originated LSA */
if (self && v)
imsg_compose(ibuf_ospfe, IMSG_LS_FLOOD,
- v->nbr->peerid, 0, v->lsa,
+ v->peerid, 0, v->lsa,
ntohs(v->lsa->hdr.len));
/* lsa not added so free it */
if (self)
diff --git a/usr.sbin/ospfd/rde.h b/usr.sbin/ospfd/rde.h
index 8e16e8e793e..8213cae4698 100644
--- a/usr.sbin/ospfd/rde.h
+++ b/usr.sbin/ospfd/rde.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.h,v 1.30 2006/05/29 16:50:36 claudio Exp $ */
+/* $OpenBSD: rde.h,v 1.31 2007/01/29 13:04:13 claudio Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -32,16 +32,18 @@ struct vertex {
struct event ev;
struct in_addr nexthop;
struct vertex *prev;
- struct rde_nbr *nbr;
+ struct area *area;
struct lsa *lsa;
time_t changed;
time_t stamp;
u_int32_t cost;
+ u_int32_t peerid; /* neighbor unique imsg ID */
u_int32_t ls_id;
u_int32_t adv_rtr;
u_int8_t type;
u_int8_t flooded;
u_int8_t deleted;
+ u_int8_t self;
};
struct rde_req_entry {
diff --git a/usr.sbin/ospfd/rde_lsdb.c b/usr.sbin/ospfd/rde_lsdb.c
index 24782e652a2..406936bb3ca 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.36 2007/01/24 10:48:47 claudio Exp $ */
+/* $OpenBSD: rde_lsdb.c,v 1.37 2007/01/29 13:04:13 claudio Exp $ */
/*
* Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org>
@@ -69,7 +69,8 @@ vertex_get(struct lsa *lsa, struct rde_nbr *nbr)
if ((v = calloc(1, sizeof(struct vertex))) == NULL)
fatal(NULL);
- v->nbr = nbr;
+ v->area = nbr->area;
+ v->peerid = nbr->peerid;
v->lsa = lsa;
clock_gettime(CLOCK_MONOTONIC, &tp);
v->changed = v->stamp = tp.tv_sec;
@@ -77,8 +78,10 @@ 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 = lsa->hdr.type;
+
if (!nbr->self)
v->flooded = 1; /* XXX fix me */
+ v->self = nbr->self;
evtimer_set(&v->ev, lsa_timeout, v);
@@ -91,7 +94,7 @@ vertex_free(struct vertex *v)
if (v->type == LSA_TYPE_EXTERNAL)
RB_REMOVE(lsa_tree, &asext_tree, v);
else
- RB_REMOVE(lsa_tree, &v->nbr->area->lsa_tree, v);
+ RB_REMOVE(lsa_tree, &v->area->lsa_tree, v);
(void)evtimer_del(&v->ev);
free(v->lsa);
@@ -583,15 +586,15 @@ lsa_timeout(int fd, short event, void *bula)
/* schedule recalculation of the RIB */
if (v->lsa->hdr.type != LSA_TYPE_EXTERNAL)
- v->nbr->area->dirty = 1;
+ v->area->dirty = 1;
start_spf_timer();
- rde_imsg_compose_ospfe(IMSG_LS_FLOOD, v->nbr->peerid, 0,
+ rde_imsg_compose_ospfe(IMSG_LS_FLOOD, v->peerid, 0,
v->lsa, ntohs(v->lsa->hdr.len));
/* timeout handling either MAX_AGE or LS_REFRESH_TIME */
timerclear(&tv);
- if (v->nbr->self)
+ if (v->self)
tv.tv_sec = LS_REFRESH_TIME;
else
tv.tv_sec = MAX_AGE - ntohs(v->lsa->hdr.age);
@@ -602,10 +605,10 @@ lsa_timeout(int fd, short event, void *bula)
return;
}
- if (v->nbr->self && ntohs(v->lsa->hdr.age) < MAX_AGE)
+ if (v->self && ntohs(v->lsa->hdr.age) < MAX_AGE)
lsa_refresh(v);
- rde_imsg_compose_ospfe(IMSG_LS_FLOOD, v->nbr->peerid, 0,
+ rde_imsg_compose_ospfe(IMSG_LS_FLOOD, v->peerid, 0,
v->lsa, ntohs(v->lsa->hdr.len));
}
@@ -697,7 +700,7 @@ lsa_remove_invalid_sums(struct area *area)
nv = RB_NEXT(lsa_tree, tree, v);
if ((v->lsa->hdr.type == LSA_TYPE_SUM_NETWORK ||
v->lsa->hdr.type == LSA_TYPE_SUM_ROUTER) &&
- v->nbr->self && v->cost == LS_INFINITY &&
+ v->self && v->cost == LS_INFINITY &&
v->deleted == 0) {
/*
* age the lsa and call lsa_timeout() which will
diff --git a/usr.sbin/ospfd/rde_spf.c b/usr.sbin/ospfd/rde_spf.c
index e5296e3f84d..14b71b4d7b6 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.56 2007/01/24 12:05:10 claudio Exp $ */
+/* $OpenBSD: rde_spf.c,v 1.57 2007/01/29 13:04:13 claudio Exp $ */
/*
* Copyright (c) 2005 Esben Norby <norby@openbsd.org>
@@ -222,7 +222,7 @@ rt_calc(struct vertex *v, struct area *area, struct ospfd_conf *conf)
return;
/* ignore self-originated stuff */
- if (v->nbr->self)
+ if (v->self)
return;
/* TODO type 3 area address range check */
@@ -276,7 +276,7 @@ asext_calc(struct vertex *v)
switch (v->type) {
case LSA_TYPE_EXTERNAL:
/* ignore self-originated stuff */
- if (v->nbr->self)
+ if (v->self)
return;
if ((r = rt_lookup(DT_RTR, htonl(v->adv_rtr))) == NULL)