summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2008-11-24 18:28:03 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2008-11-24 18:28:03 +0000
commit5460acda0cda78ccfa08605a33dad07c1451fce0 (patch)
treefc61f0c47e2639ce346fc937e08d93e60d7a57f1
parent04603baab844b95908eff978bb0c1b88810f203c (diff)
Initial support for stub areas. The bit still missing is the redistribution
of the default summary net lsa on ABRs but that is comming. OK norby@
-rw-r--r--usr.sbin/ospfd/database.c9
-rw-r--r--usr.sbin/ospfd/ospfd.c6
-rw-r--r--usr.sbin/ospfd/ospfd.h3
-rw-r--r--usr.sbin/ospfd/ospfe.c27
-rw-r--r--usr.sbin/ospfd/parse.y3
-rw-r--r--usr.sbin/ospfd/printconf.c4
-rw-r--r--usr.sbin/ospfd/rde.c23
-rw-r--r--usr.sbin/ospfd/rde_lsdb.c4
8 files changed, 62 insertions, 17 deletions
diff --git a/usr.sbin/ospfd/database.c b/usr.sbin/ospfd/database.c
index bd29a4bf4d2..9f6b58befac 100644
--- a/usr.sbin/ospfd/database.c
+++ b/usr.sbin/ospfd/database.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: database.c,v 1.22 2008/02/11 12:37:37 norby Exp $ */
+/* $OpenBSD: database.c,v 1.23 2008/11/24 18:28:02 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -235,16 +235,15 @@ recv_db_description(struct nbr *nbr, char *buf, u_int16_t len)
}
nbr->dd_seq_num++;
+ /* event negotiation done */
+ nbr_fsm(nbr, NBR_EVT_NEG_DONE);
+
/* this packet may already have data so pass it on */
if (len > 0) {
nbr->dd_pending++;
ospfe_imsg_compose_rde(IMSG_DD, nbr->peerid,
0, buf, len);
}
-
- /* event negotiation done */
- nbr_fsm(nbr, NBR_EVT_NEG_DONE);
-
} else {
/* ignore packet */
log_debug("recv_db_description: packet ignored in "
diff --git a/usr.sbin/ospfd/ospfd.c b/usr.sbin/ospfd/ospfd.c
index cf9de3de988..e07b942d790 100644
--- a/usr.sbin/ospfd/ospfd.c
+++ b/usr.sbin/ospfd/ospfd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfd.c,v 1.57 2008/05/12 19:15:02 pyr Exp $ */
+/* $OpenBSD: ospfd.c,v 1.58 2008/11/24 18:28:02 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -701,6 +701,10 @@ merge_config(struct ospfd_conf *conf, struct ospfd_conf *xconf)
* stub is not yet used but switching between stub and normal
* will be another painful job.
*/
+ if (a->stub != xa->stub &&
+ ospfd_process == PROC_OSPF_ENGINE)
+ a->dirty = 1; /* force rtr LSA update */
+
a->stub = xa->stub;
a->stub_default_cost = xa->stub_default_cost;
if (ospfd_process == PROC_RDE_ENGINE)
diff --git a/usr.sbin/ospfd/ospfd.h b/usr.sbin/ospfd/ospfd.h
index e4926bd1a89..9b1213ff955 100644
--- a/usr.sbin/ospfd/ospfd.h
+++ b/usr.sbin/ospfd/ospfd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfd.h,v 1.71 2007/10/11 12:19:31 claudio Exp $ */
+/* $OpenBSD: ospfd.h,v 1.72 2008/11/24 18:28:02 claudio Exp $ */
/*
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
@@ -130,6 +130,7 @@ enum imsg_type {
IMSG_NETWORK_DEL,
IMSG_DD,
IMSG_DD_END,
+ IMSG_DD_BADLSA,
IMSG_DB_SNAPSHOT,
IMSG_DB_END,
IMSG_LS_REQ,
diff --git a/usr.sbin/ospfd/ospfe.c b/usr.sbin/ospfd/ospfe.c
index af7a4067a75..05134e12329 100644
--- a/usr.sbin/ospfd/ospfe.c
+++ b/usr.sbin/ospfd/ospfe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfe.c,v 1.60 2007/10/13 13:21:24 claudio Exp $ */
+/* $OpenBSD: ospfe.c,v 1.61 2008/11/24 18:28:02 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -432,6 +432,15 @@ ospfe_dispatch_rde(int fd, short event, void *bula)
if (nbr == NULL)
break;
+ /*
+ * Ignore imsg when in the wrong state because a
+ * NBR_EVT_SEQ_NUM_MIS may have been issued in between.
+ * Luckily regetting the DB snapshot acts as a barrier
+ * for both state and process synchronisation.
+ */
+ if ((nbr->state & NBR_STA_FLOOD) == 0)
+ break;
+
/* put these on my ls_req_list for retrieval */
lhp = lsa_hdr_new();
memcpy(lhp, imsg.data, sizeof(*lhp));
@@ -442,6 +451,10 @@ ospfe_dispatch_rde(int fd, short event, void *bula)
if (nbr == NULL)
break;
+ /* see above */
+ if ((nbr->state & NBR_STA_FLOOD) == 0)
+ break;
+
nbr->dd_pending--;
if (nbr->dd_pending == 0 && nbr->state & NBR_STA_LOAD) {
if (ls_req_list_empty(nbr))
@@ -450,6 +463,17 @@ ospfe_dispatch_rde(int fd, short event, void *bula)
start_ls_req_tx_timer(nbr);
}
break;
+ case IMSG_DD_BADLSA:
+ nbr = nbr_find_peerid(imsg.hdr.peerid);
+ if (nbr == NULL)
+ break;
+
+ if (nbr->iface->self == nbr)
+ fatalx("ospfe_dispatch_rde: "
+ "dummy neighbor got BADREQ");
+
+ nbr_fsm(nbr, NBR_EVT_SEQ_NUM_MIS);
+ break;
case IMSG_DB_SNAPSHOT:
nbr = nbr_find_peerid(imsg.hdr.peerid);
if (nbr == NULL)
@@ -894,6 +918,7 @@ orig_rtr_lsa(struct area *area)
/*
* Set the E bit as soon as an as-ext lsa may be redistributed, only
* setting it in case we redistribute something is not worth the fuss.
+ * Do not set the E bit in case of a stub area.
*/
if (oeconf->redistribute && !area->stub)
lsa_rtr.flags |= OSPF_RTR_E;
diff --git a/usr.sbin/ospfd/parse.y b/usr.sbin/ospfd/parse.y
index cc075c5f148..d441d9cee2e 100644
--- a/usr.sbin/ospfd/parse.y
+++ b/usr.sbin/ospfd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.62 2008/10/17 13:02:55 henning Exp $ */
+/* $OpenBSD: parse.y,v 1.63 2008/11/24 18:28:02 claudio Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -525,6 +525,7 @@ areaoptsl : interface
}
}
| defaults
+ | STUB { area->stub = 1; }
;
interface : INTERFACE STRING {
diff --git a/usr.sbin/ospfd/printconf.c b/usr.sbin/ospfd/printconf.c
index ad827965444..d1ee875aefe 100644
--- a/usr.sbin/ospfd/printconf.c
+++ b/usr.sbin/ospfd/printconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: printconf.c,v 1.11 2007/09/30 13:28:09 claudio Exp $ */
+/* $OpenBSD: printconf.c,v 1.12 2008/11/24 18:28:02 claudio Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -160,6 +160,8 @@ print_config(struct ospfd_conf *conf)
LIST_FOREACH(area, &conf->area_list, entry) {
printf("area %s {\n", inet_ntoa(area->id));
+ if (area->stub)
+ printf("\tstub\n");
if (*area->demote_group)
printf("\tdemote %s %d\n", area->demote_group,
area->demote_level);
diff --git a/usr.sbin/ospfd/rde.c b/usr.sbin/ospfd/rde.c
index 5dd06236062..587c637c8e8 100644
--- a/usr.sbin/ospfd/rde.c
+++ b/usr.sbin/ospfd/rde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.c,v 1.73 2008/02/11 12:37:37 norby Exp $ */
+/* $OpenBSD: rde.c,v 1.74 2008/11/24 18:28:02 claudio Exp $ */
/*
* Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org>
@@ -236,7 +236,7 @@ rde_dispatch_imsg(int fd, short event, void *bula)
char *buf;
ssize_t n;
time_t now;
- int r, state, self, shut = 0;
+ int r, state, self, error, shut = 0;
u_int16_t l;
switch (event) {
@@ -311,11 +311,17 @@ rde_dispatch_imsg(int fd, short event, void *bula)
break;
buf = imsg.data;
+ error = 0;
for (l = imsg.hdr.len - IMSG_HEADER_SIZE;
l >= sizeof(lsa_hdr); l -= sizeof(lsa_hdr)) {
memcpy(&lsa_hdr, buf, sizeof(lsa_hdr));
buf += sizeof(lsa_hdr);
+ if (lsa_hdr.type == LSA_TYPE_EXTERNAL &&
+ nbr->area->stub) {
+ error = 1;
+ break;
+ }
v = lsa_find(nbr->area, lsa_hdr.type,
lsa_hdr.ls_id, lsa_hdr.adv_rtr);
if (v == NULL)
@@ -334,13 +340,17 @@ rde_dispatch_imsg(int fd, short event, void *bula)
sizeof(lsa_hdr));
}
}
- if (l != 0)
+ if (l != 0 && !error)
log_warnx("rde_dispatch_imsg: peerid %lu, "
"trailing garbage in Database Description "
"packet", imsg.hdr.peerid);
- imsg_compose(ibuf_ospfe, IMSG_DD_END, imsg.hdr.peerid,
- 0, NULL, 0);
+ if (!error)
+ imsg_compose(ibuf_ospfe, IMSG_DD_END,
+ imsg.hdr.peerid, 0, NULL, 0);
+ else
+ imsg_compose(ibuf_ospfe, IMSG_DD_BADLSA,
+ imsg.hdr.peerid, 0, NULL, 0);
break;
case IMSG_LS_REQ:
nbr = rde_nbr_find(imsg.hdr.peerid);
@@ -1090,6 +1100,9 @@ rde_summary_update(struct rt_node *rte, struct area *area)
if (rte->d_type == DT_NET) {
type = LSA_TYPE_SUM_NETWORK;
} else if (rte->d_type == DT_RTR) {
+ if (area->stub)
+ /* do not redistribute type 4 LSA into stub areas */
+ return;
type = LSA_TYPE_SUM_ROUTER;
} else
fatalx("rde_summary_update: unknown route type");
diff --git a/usr.sbin/ospfd/rde_lsdb.c b/usr.sbin/ospfd/rde_lsdb.c
index 24e8e8fc254..82e6d78f859 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.40 2008/02/11 12:37:37 norby Exp $ */
+/* $OpenBSD: rde_lsdb.c,v 1.41 2008/11/24 18:28:02 claudio Exp $ */
/*
* Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org>
@@ -517,7 +517,7 @@ lsa_snap(struct area *area, u_int32_t peerid)
rde_imsg_compose_ospfe(IMSG_DB_SNAPSHOT, peerid,
0, &v->lsa->hdr, sizeof(struct lsa_hdr));
}
- if (tree != &area->lsa_tree)
+ if (tree != &area->lsa_tree || area->stub)
break;
tree = &asext_tree;
} while (1);