diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2005-05-12 08:55:40 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2005-05-12 08:55:40 +0000 |
commit | bcbe4b13eb93b6f2d9d53233186733d2079af903 (patch) | |
tree | 51e7d66bde8ccd5865426aaf8545a0be5c05a690 /usr.sbin/ospfd | |
parent | 1a3b287a0be3f9277039b96380699269417b27b7 (diff) |
If activly connected to more than one area set B flag in the self-originated
router LSA. To do that correctly we need to track the number of active
neighbors for each area. If the routers ABR status changes all router LSA
need to be updated via orig_rtr_lsa_all().
OK norby@
Diffstat (limited to 'usr.sbin/ospfd')
-rw-r--r-- | usr.sbin/ospfd/area.c | 29 | ||||
-rw-r--r-- | usr.sbin/ospfd/neighbor.c | 3 | ||||
-rw-r--r-- | usr.sbin/ospfd/ospfd.h | 6 | ||||
-rw-r--r-- | usr.sbin/ospfd/ospfe.c | 30 |
4 files changed, 62 insertions, 6 deletions
diff --git a/usr.sbin/ospfd/area.c b/usr.sbin/ospfd/area.c index 6e51eddb2a7..784b04031db 100644 --- a/usr.sbin/ospfd/area.c +++ b/usr.sbin/ospfd/area.c @@ -1,4 +1,4 @@ -/* $OpenBSD: area.c,v 1.2 2005/01/28 17:53:33 norby Exp $ */ +/* $OpenBSD: area.c,v 1.3 2005/05/12 08:55:39 claudio Exp $ */ /* * Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org> @@ -78,7 +78,7 @@ area_del(struct area *area) struct area * area_find(struct ospfd_conf *conf, struct in_addr area_id) { - struct area *area = NULL; + struct area *area; LIST_FOREACH(area, &conf->area_list, entry) { if (area->id.s_addr == area_id.s_addr) { @@ -89,3 +89,28 @@ area_find(struct ospfd_conf *conf, struct in_addr area_id) log_debug("area_find: area ID %s not found", inet_ntoa(area_id)); return (NULL); } + +void +area_track(struct area *area, int state) +{ + if (state & NBR_STA_FULL) + area->active++; + else if (area->active == 0) + fatalx("king bula sez: area already inactive"); + else + area->active--; +} + +int +area_border_router(struct ospfd_conf *conf) +{ + struct area *area; + int active = 0; + + LIST_FOREACH(area, &conf->area_list, entry) + if (area->active > 0) + active++; + + return (active > 1); +} + diff --git a/usr.sbin/ospfd/neighbor.c b/usr.sbin/ospfd/neighbor.c index 5731cff39e2..0a9ce8b4a03 100644 --- a/usr.sbin/ospfd/neighbor.c +++ b/usr.sbin/ospfd/neighbor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: neighbor.c,v 1.16 2005/05/01 17:35:27 david Exp $ */ +/* $OpenBSD: neighbor.c,v 1.17 2005/05/12 08:55:39 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -209,6 +209,7 @@ nbr_fsm(struct nbr *nbr, enum nbr_event event) /* neighbor changed from/to FULL originate new rtr and net LSA */ if (old_state != nbr->state && (old_state & NBR_STA_FULL || nbr->state & NBR_STA_FULL)) { + area_track(nbr->iface->area, nbr->state); orig_rtr_lsa(nbr->iface->area); if (nbr->iface->state & IF_STA_DR) orig_net_lsa(nbr->iface); diff --git a/usr.sbin/ospfd/ospfd.h b/usr.sbin/ospfd/ospfd.h index 06eb2b6fbc5..62d366660cc 100644 --- a/usr.sbin/ospfd/ospfd.h +++ b/usr.sbin/ospfd/ospfd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfd.h,v 1.27 2005/04/27 11:27:28 claudio Exp $ */ +/* $OpenBSD: ospfd.h,v 1.28 2005/05/12 08:55:39 claudio Exp $ */ /* * Copyright (c) 2004 Esben Norby <norby@openbsd.org> @@ -163,6 +163,7 @@ struct area { u_int32_t stub_default_cost; u_int32_t num_spf_calc; u_int32_t dead_interval; + int active; u_int16_t transmit_delay; u_int16_t hello_interval; u_int16_t rxmt_interval; @@ -348,6 +349,7 @@ struct ospfd_conf { int redistribute_flags; int options; /* OSPF options */ u_int8_t rfc1583compat; + u_int8_t border; }; /* kroute */ @@ -452,6 +454,8 @@ void show_config(struct ospfd_conf *xconf); struct area *area_new(void); int area_del(struct area *); struct area *area_find(struct ospfd_conf *, struct in_addr); +void area_track(struct area *, int); +int area_border_router(struct ospfd_conf *); /* buffer.c */ struct buf *buf_open(size_t); diff --git a/usr.sbin/ospfd/ospfe.c b/usr.sbin/ospfd/ospfe.c index ca245f4bef9..b3ebe1572ae 100644 --- a/usr.sbin/ospfd/ospfe.c +++ b/usr.sbin/ospfd/ospfe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfe.c,v 1.18 2005/05/02 02:26:35 djm Exp $ */ +/* $OpenBSD: ospfe.c,v 1.19 2005/05/12 08:55:39 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -43,6 +43,7 @@ void ospfe_sig_handler(int, short, void *); void ospfe_shutdown(void); +void orig_rtr_lsa_all(struct area *); volatile sig_atomic_t ospfe_quit = 0; struct ospfd_conf *oeconf = NULL; @@ -564,6 +565,20 @@ ospfe_dispatch_rde(int fd, short event, void *bula) } void +orig_rtr_lsa_all(struct area *area) +{ + struct area *a; + + /* + * update all router LSA in all areas except area itself, + * as this update is already running. + */ + LIST_FOREACH(a, &oeconf->area_list, entry) + if (a != area) + orig_rtr_lsa(a); +} + +void orig_rtr_lsa(struct area *area) { struct lsa_hdr lsa_hdr; @@ -574,6 +589,7 @@ orig_rtr_lsa(struct area *area) struct nbr *nbr, *self = NULL; u_int16_t num_links = 0; u_int16_t chksum; + u_int8_t border; log_debug("orig_rtr_lsa: area %s", inet_ntoa(area->id)); @@ -727,7 +743,17 @@ orig_rtr_lsa(struct area *area) */ if (oeconf->redistribute_flags && (oeconf->options & OSPF_OPTION_E)) lsa_rtr.flags |= OSPF_RTR_E; - /* TODO if activly connected to more than one area set B flag */ + + border = area_border_router(oeconf); + + if (border != oeconf->border) { + oeconf->border = border; + orig_rtr_lsa_all(area); + } + + if (oeconf->border) + lsa_rtr.flags |= OSPF_RTR_B; + /* TODO set V flag if a active virtual link ends here and the * area is the tranist area for this link. */ lsa_rtr.dummy = 0; |