From 4b84bd4554b2a9331055bfd8d02a0bab0d10df92 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Sun, 29 Nov 2009 10:29:33 +0100 Subject: Fixes some crashes in OSPFv2. --- proto/ospf/rt.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'proto/ospf') diff --git a/proto/ospf/rt.c b/proto/ospf/rt.c index a230d38..2e1de44 100644 --- a/proto/ospf/rt.c +++ b/proto/ospf/rt.c @@ -776,6 +776,8 @@ add_cand(list * l, struct top_hash_entry *en, struct top_hash_entry *par, node *prev, *n; int added = 0; struct top_hash_entry *act; + ip_addr old_nh; + struct ospf_iface *old_nhi; if (en == NULL) return; @@ -798,13 +800,20 @@ add_cand(list * l, struct top_hash_entry *en, struct top_hash_entry *par, DBG(" Adding candidate: rt: %R, id: %R, type: %u\n", en->lsa.rt, en->lsa.id, en->lsa.type); + old_nhi = en->nhi; + old_nh = en->nh; + en->nhi = NULL; en->nh = IPA_NONE; - calc_next_hop(en, par, oa); if (!en->nhi) - return; /* We cannot find next hop, ignore it */ + { + /* No next hop found, we undo changes and return */ + en->nhi = old_nhi; + en->nh = old_nh; + return; + } if (en->color == CANDIDATE) { /* We found a shorter path */ -- cgit v1.2.3 From 28008482a97c0ac70e648759fe37bad0633ed9f7 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Sat, 12 Dec 2009 01:35:51 +0100 Subject: Minor fixes in OSPF. --- proto/ospf/lsreq.c | 2 +- proto/ospf/lsupd.c | 37 ++++++++++++++++++++++--------------- 2 files changed, 23 insertions(+), 16 deletions(-) (limited to 'proto/ospf') diff --git a/proto/ospf/lsreq.c b/proto/ospf/lsreq.c index 5eeb06f..e7d7af2 100644 --- a/proto/ospf/lsreq.c +++ b/proto/ospf/lsreq.c @@ -18,7 +18,7 @@ static void ospf_dump_lsreq(struct proto *p, struct ospf_lsreq_packet *pkt) struct ospf_lsreq_header *plsr = (void *) (pkt + 1); int i, j; - j = (ntohs(op->length) - sizeof(struct ospf_dbdes_packet)) / + j = (ntohs(op->length) - sizeof(struct ospf_lsreq_packet)) / sizeof(struct ospf_lsreq_header); for (i = 0; i < j; i++) diff --git a/proto/ospf/lsupd.c b/proto/ospf/lsupd.c index ba09fec..f8195dc 100644 --- a/proto/ospf/lsupd.c +++ b/proto/ospf/lsupd.c @@ -456,27 +456,34 @@ ospf_lsupd_receive(struct ospf_lsupd_packet *ps, if (self) { - struct top_hash_entry *en; - if ((lsatmp.age == LSA_MAXAGE) && (lsatmp.sn == LSA_MAXSEQNO)) { ospf_lsack_enqueue(n, lsa, ACKL_DIRECT); continue; } - lsatmp.age = LSA_MAXAGE; - lsatmp.sn = LSA_MAXSEQNO; - lsa->age = htons(LSA_MAXAGE); - lsa->sn = htonl(LSA_MAXSEQNO); - OSPF_TRACE(D_EVENTS, "Premature aging self originated lsa."); - OSPF_TRACE(D_EVENTS, "Type: %d, Id: %R, Rt: %R", - lsatmp.type, lsatmp.id, lsatmp.rt); - lsasum_check(lsa, (lsa + 1)); /* It also calculates chsum! */ - lsatmp.checksum = ntohs(lsa->checksum); - ospf_lsupd_flood(NULL, lsa, &lsatmp, NULL, oa, 0); - if (en = ospf_hash_find_header(po->gr, oa->areaid, &lsatmp)) + OSPF_TRACE(D_EVENTS, "Received old self-originated LSA (Type: %04x, Id: %R, Rt: %R)", lsatmp.type, lsatmp.id, lsatmp.rt); + + if (lsadb) + { + OSPF_TRACE(D_EVENTS, "Reflooding new self-originated LSA with newer SN"); + lsadb->lsa.sn = lsatmp.sn + 1; + lsadb->lsa.age = 0; + lsadb->inst_t = now; + lsadb->ini_age = 0; + lsasum_calculate(&lsadb->lsa, lsadb->lsa_body); + ospf_lsupd_flood(NULL, NULL, &lsadb->lsa, NULL, oa, 1); + } + else { - ospf_lsupd_flood(NULL, NULL, &en->lsa, NULL, oa, 1); + OSPF_TRACE(D_EVENTS, "Premature aging it"); + lsatmp.age = LSA_MAXAGE; + lsatmp.sn = LSA_MAXSEQNO; + lsa->age = htons(LSA_MAXAGE); + lsa->sn = htonl(LSA_MAXSEQNO); + lsasum_check(lsa, (lsa + 1)); /* It also calculates chsum! */ + lsatmp.checksum = ntohs(lsa->checksum); + ospf_lsupd_flood(NULL, lsa, &lsatmp, NULL, oa, 0); } continue; } @@ -484,7 +491,7 @@ ospf_lsupd_receive(struct ospf_lsupd_packet *ps, /* pg 144 (5a) */ if (lsadb && ((now - lsadb->inst_t) <= MINLSARRIVAL)) /* FIXME: test for flooding? */ { - DBG("I got it in less that MINLSARRIVAL\n"); + OSPF_TRACE(D_EVENTS, "Skipping LSA received in less that MINLSARRIVAL"); sendreq = 0; continue; } -- cgit v1.2.3