diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2005-05-24 06:55:22 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2005-05-24 06:55:22 +0000 |
commit | f47e823e3507b0596393156b5d9b4ed27c6a5d14 (patch) | |
tree | 522d01237068b9a4ef0ae4f3b60b1f5784c8982c /usr.sbin | |
parent | 8f94c0124f80c3c76baddb6c327e5488df17d8bb (diff) |
Fix some obvious issues in the summary LSA origination.
Actually remove summary LSA if the LSA they refer to are no longer valid.
Set correct cost on the summary LSA.
Announce type 4 summary LSA.
OK norby@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ospfd/rde.c | 29 | ||||
-rw-r--r-- | usr.sbin/ospfd/rde.h | 3 | ||||
-rw-r--r-- | usr.sbin/ospfd/rde_lsdb.c | 32 | ||||
-rw-r--r-- | usr.sbin/ospfd/rde_spf.c | 5 |
4 files changed, 53 insertions, 16 deletions
diff --git a/usr.sbin/ospfd/rde.c b/usr.sbin/ospfd/rde.c index 410246266dd..27363219b1b 100644 --- a/usr.sbin/ospfd/rde.c +++ b/usr.sbin/ospfd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.20 2005/05/23 23:03:07 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.21 2005/05/24 06:55:21 claudio Exp $ */ /* * Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org> @@ -436,15 +436,17 @@ rde_dispatch_imsg(int fd, short event, void *bula) if (nbr == NULL) fatalx("rde_dispatch_imsg: " "neighbor does not exist"); - log_debug("rde_dispatch_imsg: IMSG_LS_MAXAGE, " - "neighbor %s len %d", inet_ntoa(nbr->id), - imsg.hdr.len - IMSG_HEADER_SIZE); if (imsg.hdr.len != IMSG_HEADER_SIZE + sizeof(struct lsa_hdr)) fatalx("invalid size of OE request"); memcpy(&lsa_hdr, imsg.data, sizeof(lsa_hdr)); + aid.s_addr = lsa_hdr.ls_id; + log_debug("rde_dispatch_imsg: IMSG_LS_MAXAGE, " + "type %d ls_id %d", lsa_hdr.type, + inet_ntoa(aid)); + if (rde_nbr_loading(nbr->area)) { log_debug("IMSG_LS_MAXAGE still loading"); break; @@ -984,12 +986,12 @@ rde_asext_put(struct kroute *kr) void rde_summary_update(struct rt_node *rte, struct area *area) { - struct vertex *v; + struct vertex *v = NULL; struct lsa *lsa; - u_int8_t type; + u_int8_t type = 0; /* first check if we acctually need to announce this route */ - if (!(rte->d_type == DT_NET /* || as border rtr */)) + if (!(rte->d_type == DT_NET || rte->flags & OSPF_RTR_E)) return; /* never create summaries for as-ext LSA */ if (rte->p_type == PT_TYPE1_EXT || rte->p_type == PT_TYPE2_EXT) @@ -1016,6 +1018,16 @@ rde_summary_update(struct rt_node *rte, struct area *area) lsa = orig_sum_lsa(rte, type); lsa_merge(rde_nbr_self(area), lsa, v); + + if (v == NULL) { + if (rte->d_type == DT_NET) + v = lsa_find(area, type, rte->prefix.s_addr, + rde_router_id()); + else + v = lsa_find(area, type, rte->adv_rtr.s_addr, + rde_router_id()); + } + v->cost = rte->cost; } @@ -1104,8 +1116,7 @@ orig_sum_lsa(struct rt_node *rte, u_int8_t type) lsa->data.sum.mask = 0; /* must be zero per RFC */ } - lsa->data.sum.metric = htonl(/* LSA_ASEXT_E_FLAG | */ 100); - /* XXX until now there is no metric */ + lsa->data.sum.metric = htonl(rte->cost & LSA_METRIC_MASK); lsa->hdr.ls_chksum = 0; lsa->hdr.ls_chksum = diff --git a/usr.sbin/ospfd/rde.h b/usr.sbin/ospfd/rde.h index b3bb5c13bd0..e67036f00e5 100644 --- a/usr.sbin/ospfd/rde.h +++ b/usr.sbin/ospfd/rde.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.h,v 1.15 2005/05/23 23:03:07 claudio Exp $ */ +/* $OpenBSD: rde.h,v 1.16 2005/05/24 06:55:21 claudio Exp $ */ /* * Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org> @@ -112,6 +112,7 @@ int lsa_num_links(struct vertex *); void lsa_snap(struct area *, u_int32_t); void lsa_dump(struct lsa_tree *, int, pid_t); void lsa_merge(struct rde_nbr *, struct lsa *, struct vertex *); +void lsa_remove_invalid_sums(struct area *); /* rde_spf.c */ void spf_calc(struct area *); diff --git a/usr.sbin/ospfd/rde_lsdb.c b/usr.sbin/ospfd/rde_lsdb.c index 93683fc3f5a..f5686a35d43 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.13 2005/05/12 20:43:14 claudio Exp $ */ +/* $OpenBSD: rde_lsdb.c,v 1.14 2005/05/24 06:55:21 claudio Exp $ */ /* * Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org> @@ -429,9 +429,10 @@ lsa_find_net(struct area *area, u_int32_t ls_id) struct lsa_tree *tree = &area->lsa_tree; struct vertex *v; + /* XXX speed me up */ RB_FOREACH(v, lsa_tree, tree) { - if ((v->lsa->hdr.type == LSA_TYPE_NETWORK) && - (v->lsa->hdr.ls_id == (ls_id))) { + if (v->lsa->hdr.type == LSA_TYPE_NETWORK && + v->lsa->hdr.ls_id == ls_id) { lsa_age(v); return (v); } @@ -531,8 +532,6 @@ lsa_timeout(int fd, short event, void *bula) lsa_age(v); - log_debug("lsa_timeout: REFLOOD age %d", ntohs(v->lsa->hdr.age)); - if (v->nbr->self && ntohs(v->lsa->hdr.age) < MAX_AGE) lsa_refresh(v); @@ -594,3 +593,26 @@ lsa_merge(struct rde_nbr *nbr, struct lsa *lsa, struct vertex *v) tv.tv_sec = MIN_LS_ARRIVAL; evtimer_add(&v->ev, &tv); } + +void +lsa_remove_invalid_sums(struct area *area) +{ + struct lsa_tree *tree = &area->lsa_tree; + struct vertex *v, *nv; + + /* XXX speed me up */ + for (v = RB_MIN(lsa_tree, tree); v != NULL; v = nv) { + 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) { + /* + * age the lsa and call lsa_timeout() which will + * acctually remove it form the database. + */ + v->lsa->hdr.age = htons(MAX_AGE); + lsa_timeout(0, 0, v); + } + } +} + diff --git a/usr.sbin/ospfd/rde_spf.c b/usr.sbin/ospfd/rde_spf.c index 356c025234c..a8eac117d48 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.16 2005/05/23 23:03:07 claudio Exp $ */ +/* $OpenBSD: rde_spf.c,v 1.17 2005/05/24 06:55:21 claudio Exp $ */ /* * Copyright (c) 2005 Esben Norby <norby@openbsd.org> @@ -546,6 +546,9 @@ spf_timer(int fd, short event, void *arg) rde_send_change_kroute(r); } + LIST_FOREACH(area, &conf->area_list, entry) + lsa_remove_invalid_sums(area); + start_spf_holdtimer(rdeconf); break; case SPF_HOLD: |