From 2918e61046388821c3d4411c602dc5b28ad59329 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Sat, 3 Sep 2011 21:31:26 +0200 Subject: Fixes for OSPF NSSA handling. --- proto/ospf/config.Y | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'proto/ospf/config.Y') diff --git a/proto/ospf/config.Y b/proto/ospf/config.Y index e48f460..ec7da8e 100644 --- a/proto/ospf/config.Y +++ b/proto/ospf/config.Y @@ -58,7 +58,16 @@ static void ospf_area_finish(void) { if ((this_area->areaid == 0) && (this_area->type != OPT_E)) - cf_error( "Backbone area cannot be stub/NSSA"); + cf_error("Backbone area cannot be stub/NSSA"); + + if (this_area->summary && (this_area->type == OPT_E)) + cf_error("Only Stub/NSSA areas can use summary propagation"); + + if (this_area->default_nssa && ((this_area->type != OPT_N) || ! this_area->summary)) + cf_error("Only NSSA areas with summary propagation can use NSSA default route"); + + if ((this_area->default_cost & LSA_EXT_EBIT) && ! this_area->default_nssa) + cf_error("Only NSSA default route can use type 2 metric"); } static void @@ -94,10 +103,17 @@ ospf_proto_finish(void) cf_error( "Vlinks cannot be used on single area router"); } +static inline void +check_defcost(int cost) +{ + if ((cost <= 0) || (cost >= LSINFINITY)) + cf_error("Default cost must be in range 1-%d", LSINFINITY); +} + CF_DECLS CF_KEYWORDS(OSPF, AREA, OSPF_METRIC1, OSPF_METRIC2, OSPF_TAG, OSPF_ROUTER_ID) -CF_KEYWORDS(NEIGHBORS, RFC1583COMPAT, STUB, TICK, COST, RETRANSMIT) +CF_KEYWORDS(NEIGHBORS, RFC1583COMPAT, STUB, TICK, COST, COST2, RETRANSMIT) CF_KEYWORDS(HELLO, TRANSMIT, PRIORITY, DEAD, TYPE, BROADCAST, BCAST) CF_KEYWORDS(NONBROADCAST, NBMA, POINTOPOINT, PTP, POINTOMULTIPOINT, PTMP) CF_KEYWORDS(NONE, SIMPLE, AUTHENTICATION, STRICT, CRYPTOGRAPHIC) @@ -139,7 +155,7 @@ ospf_area_start: AREA idval { this_area = cfg_allocz(sizeof(struct ospf_area_config)); add_tail(&OSPF_CFG->area_list, NODE this_area); this_area->areaid = $2; - this_area->stub_cost = DEFAULT_STUB_COST; + this_area->default_cost = DEFAULT_STUB_COST; this_area->type = OPT_E; this_area->transint = DEFAULT_TRANSINT; @@ -159,10 +175,13 @@ ospf_area_opts: ; ospf_area_item: - STUB COST expr { this_area->stub_cost = $3 ; if($3<=0) cf_error("Stub cost must be greater than zero"); } - | STUB bool { this_area->type = $2 ? 0 : OPT_E; /* We should remove the option */ } + STUB bool { this_area->type = $2 ? 0 : OPT_E; /* We should remove the option */ } | NSSA { this_area->type = OPT_N; } | SUMMARY bool { this_area->summary = $2; } + | DEFAULT NSSA bool { this_area->default_nssa = $3; } + | DEFAULT COST expr { this_area->default_cost = $3; check_defcost($3); } + | DEFAULT COST2 expr { this_area->default_cost = $3 | LSA_EXT_EBIT; check_defcost($3); } + | STUB COST expr { this_area->default_cost = $3; check_defcost($3); } | TRANSLATOR bool { this_area->translator = $2; } | TRANSLATOR STABILITY expr { this_area->transint = $3; } | NETWORKS { this_nets = &this_area->net_list; } '{' pref_list '}' -- cgit v1.2.3