version 1.1, 2012/02/21 17:26:12
|
version 1.1.1.4, 2016/11/02 10:09:12
|
Line 50
|
Line 50
|
#include "ospfd/ospf_ase.h" |
#include "ospfd/ospf_ase.h" |
#include "ospfd/ospf_zebra.h" |
#include "ospfd/ospf_zebra.h" |
#include "ospfd/ospf_dump.h" |
#include "ospfd/ospf_dump.h" |
| |
static struct ospf_area_range * |
static struct ospf_area_range * |
ospf_area_range_new (struct prefix_ipv4 *p) |
ospf_area_range_new (struct prefix_ipv4 *p) |
{ |
{ |
Line 88 ospf_area_range_add (struct ospf_area *area, struct os
|
Line 88 ospf_area_range_add (struct ospf_area *area, struct os
|
} |
} |
|
|
static void |
static void |
ospf_area_range_delete (struct ospf_area *area, struct ospf_area_range *range) | ospf_area_range_delete (struct ospf_area *area, struct route_node *rn) |
{ |
{ |
struct route_node *rn; | struct ospf_area_range *range = rn->info; |
struct prefix_ipv4 p; | |
|
|
p.family = AF_INET; | if (range->specifics != 0) |
p.prefixlen = range->masklen; | ospf_delete_discard_route (area->ospf->new_table, |
p.prefix = range->addr; | (struct prefix_ipv4 *) &rn->p); |
|
|
rn = route_node_lookup (area->ranges, (struct prefix *)&p); | ospf_area_range_free (range); |
if (rn) | rn->info = NULL; |
{ | route_unlock_node (rn); |
ospf_area_range_free (rn->info); | route_unlock_node (rn); |
rn->info = NULL; | |
route_unlock_node (rn); | |
route_unlock_node (rn); | |
} | |
} |
} |
|
|
struct ospf_area_range * |
struct ospf_area_range * |
Line 263 ospf_area_range_unset (struct ospf *ospf, struct in_ad
|
Line 258 ospf_area_range_unset (struct ospf *ospf, struct in_ad
|
struct prefix_ipv4 *p) |
struct prefix_ipv4 *p) |
{ |
{ |
struct ospf_area *area; |
struct ospf_area *area; |
struct ospf_area_range *range; | struct route_node *rn; |
|
|
area = ospf_area_lookup_by_area_id (ospf, area_id); |
area = ospf_area_lookup_by_area_id (ospf, area_id); |
if (area == NULL) |
if (area == NULL) |
return 0; |
return 0; |
|
|
range = ospf_area_range_lookup (area, p); | rn = route_node_lookup (area->ranges, (struct prefix*)p); |
if (range == NULL) | if (rn == NULL) |
return 0; |
return 0; |
|
|
if (ospf_area_range_active (range)) | if (ospf_area_range_active (rn->info)) |
ospf_schedule_abr_task (ospf); |
ospf_schedule_abr_task (ospf); |
|
|
ospf_area_range_delete (area, range); | ospf_area_range_delete (area, rn); |
|
|
return 1; |
return 1; |
} |
} |
Line 384 ospf_abr_nssa_am_elected (struct ospf_area *area)
|
Line 379 ospf_abr_nssa_am_elected (struct ospf_area *area)
|
if (best == NULL) |
if (best == NULL) |
best = &lsa->data->id; |
best = &lsa->data->id; |
else |
else |
if ( IPV4_ADDR_CMP (&best, &lsa->data->id) < 0) | if (IPV4_ADDR_CMP (&best->s_addr, &lsa->data->id.s_addr) < 0) |
best = &lsa->data->id; |
best = &lsa->data->id; |
} |
} |
|
|
Line 395 ospf_abr_nssa_am_elected (struct ospf_area *area)
|
Line 390 ospf_abr_nssa_am_elected (struct ospf_area *area)
|
if (best == NULL) |
if (best == NULL) |
return 1; |
return 1; |
|
|
if ( IPV4_ADDR_CMP (&best, &area->ospf->router_id) < 0) | if (IPV4_ADDR_CMP (&best->s_addr, &area->ospf->router_id.s_addr) < 0) |
return 1; |
return 1; |
else |
else |
return 0; |
return 0; |
Line 561 ospf_check_abr_status (struct ospf *ospf)
|
Line 556 ospf_check_abr_status (struct ospf *ospf)
|
|
|
if (new_flags != ospf->flags) |
if (new_flags != ospf->flags) |
{ |
{ |
ospf_spf_calculate_schedule (ospf); | ospf_spf_calculate_schedule (ospf, SPF_FLAG_ABR_STATUS_CHANGE); |
if (IS_DEBUG_OSPF_EVENT) |
if (IS_DEBUG_OSPF_EVENT) |
zlog_debug ("ospf_check_abr_status(): new router flags: %x",new_flags); |
zlog_debug ("ospf_check_abr_status(): new router flags: %x",new_flags); |
ospf->flags = new_flags; |
ospf->flags = new_flags; |
Line 571 ospf_check_abr_status (struct ospf *ospf)
|
Line 566 ospf_check_abr_status (struct ospf *ospf)
|
|
|
static void |
static void |
ospf_abr_update_aggregate (struct ospf_area_range *range, |
ospf_abr_update_aggregate (struct ospf_area_range *range, |
struct ospf_route *or) | struct ospf_route *or, struct ospf_area *area) |
{ |
{ |
if (IS_DEBUG_OSPF_EVENT) |
if (IS_DEBUG_OSPF_EVENT) |
zlog_debug ("ospf_abr_update_aggregate(): Start"); |
zlog_debug ("ospf_abr_update_aggregate(): Start"); |
|
|
if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC) | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED) && |
| (range->cost != OSPF_STUB_MAX_METRIC_SUMMARY_COST)) |
{ |
{ |
|
range->cost = OSPF_STUB_MAX_METRIC_SUMMARY_COST; |
if (IS_DEBUG_OSPF_EVENT) |
if (IS_DEBUG_OSPF_EVENT) |
|
zlog_debug ("ospf_abr_update_aggregate(): use summary max-metric 0x%08x", |
|
range->cost); |
|
} |
|
else if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC) |
|
{ |
|
if (IS_DEBUG_OSPF_EVENT) |
zlog_debug ("ospf_abr_update_aggregate(): use configured cost %d", |
zlog_debug ("ospf_abr_update_aggregate(): use configured cost %d", |
range->cost_config); |
range->cost_config); |
|
|
Line 587 ospf_abr_update_aggregate (struct ospf_area_range *ran
|
Line 590 ospf_abr_update_aggregate (struct ospf_area_range *ran
|
else |
else |
{ |
{ |
if (range->specifics == 0) |
if (range->specifics == 0) |
range->cost = or->cost; /* 1st time get 1st cost */ | { |
| if (IS_DEBUG_OSPF_EVENT) |
| zlog_debug ("ospf_abr_update_aggregate(): use or->cost %d", |
| or->cost); |
|
|
|
range->cost = or->cost; /* 1st time get 1st cost */ |
|
} |
|
|
if (or->cost > range->cost) |
if (or->cost > range->cost) |
{ |
{ |
if (IS_DEBUG_OSPF_EVENT) |
if (IS_DEBUG_OSPF_EVENT) |
zlog_debug ("ospf_abr_update_aggregate(): largest cost, update"); | zlog_debug ("ospf_abr_update_aggregate(): update to %d", or->cost); |
|
|
range->cost = or->cost; |
range->cost = or->cost; |
} |
} |
Line 613 set_metric (struct ospf_lsa *lsa, u_int32_t metric)
|
Line 622 set_metric (struct ospf_lsa *lsa, u_int32_t metric)
|
memcpy(header->metric, mp, 3); |
memcpy(header->metric, mp, 3); |
} |
} |
|
|
static int |
|
ospf_abr_check_nssa_range (struct prefix_ipv4 *p, u_int32_t cost, |
|
struct ospf_area *area) |
|
{ |
|
/* The Type-7 is tested against the aggregated prefix and forwarded |
|
for lsa installation and flooding */ |
|
return 0; |
|
} |
|
|
|
/* ospf_abr_translate_nssa */ |
/* ospf_abr_translate_nssa */ |
static int |
static int |
ospf_abr_translate_nssa (struct ospf_area *area, struct ospf_lsa *lsa) |
ospf_abr_translate_nssa (struct ospf_area *area, struct ospf_lsa *lsa) |
Line 725 ospf_abr_announce_network_to_area (struct prefix_ipv4
|
Line 725 ospf_abr_announce_network_to_area (struct prefix_ipv4
|
{ |
{ |
struct ospf_lsa *lsa, *old = NULL; |
struct ospf_lsa *lsa, *old = NULL; |
struct summary_lsa *sl = NULL; |
struct summary_lsa *sl = NULL; |
|
u_int32_t full_cost; |
|
|
if (IS_DEBUG_OSPF_EVENT) |
if (IS_DEBUG_OSPF_EVENT) |
zlog_debug ("ospf_abr_announce_network_to_area(): Start"); |
zlog_debug ("ospf_abr_announce_network_to_area(): Start"); |
|
|
|
if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)) |
|
full_cost = OSPF_STUB_MAX_METRIC_SUMMARY_COST; |
|
else |
|
full_cost = cost; |
|
|
old = ospf_lsa_lookup_by_prefix (area->lsdb, OSPF_SUMMARY_LSA, |
old = ospf_lsa_lookup_by_prefix (area->lsdb, OSPF_SUMMARY_LSA, |
(struct prefix_ipv4 *) p, |
(struct prefix_ipv4 *) p, |
area->ospf->router_id); |
area->ospf->router_id); |
Line 743 ospf_abr_announce_network_to_area (struct prefix_ipv4
|
Line 749 ospf_abr_announce_network_to_area (struct prefix_ipv4
|
zlog_debug ("ospf_abr_announce_network_to_area(): " |
zlog_debug ("ospf_abr_announce_network_to_area(): " |
"old metric: %d, new metric: %d", |
"old metric: %d, new metric: %d", |
GET_METRIC (sl->metric), cost); |
GET_METRIC (sl->metric), cost); |
| |
if (GET_METRIC (sl->metric) == cost) | if ((GET_METRIC (sl->metric) == full_cost) && |
| ((old->flags & OSPF_LSA_IN_MAXAGE) == 0)) |
{ |
{ |
/* unchanged. simply reapprove it */ |
/* unchanged. simply reapprove it */ |
if (IS_DEBUG_OSPF_EVENT) |
if (IS_DEBUG_OSPF_EVENT) |
Line 758 ospf_abr_announce_network_to_area (struct prefix_ipv4
|
Line 765 ospf_abr_announce_network_to_area (struct prefix_ipv4
|
if (IS_DEBUG_OSPF_EVENT) |
if (IS_DEBUG_OSPF_EVENT) |
zlog_debug ("ospf_abr_announce_network_to_area(): " |
zlog_debug ("ospf_abr_announce_network_to_area(): " |
"refreshing summary"); |
"refreshing summary"); |
set_metric (old, cost); | set_metric (old, full_cost); |
lsa = ospf_lsa_refresh (area->ospf, old); |
lsa = ospf_lsa_refresh (area->ospf, old); |
|
|
if (!lsa) |
if (!lsa) |
Line 782 ospf_abr_announce_network_to_area (struct prefix_ipv4
|
Line 789 ospf_abr_announce_network_to_area (struct prefix_ipv4
|
if (IS_DEBUG_OSPF_EVENT) |
if (IS_DEBUG_OSPF_EVENT) |
zlog_debug ("ospf_abr_announce_network_to_area(): " |
zlog_debug ("ospf_abr_announce_network_to_area(): " |
"creating new summary"); |
"creating new summary"); |
lsa = ospf_summary_lsa_originate ( (struct prefix_ipv4 *)p, cost, area); | lsa = ospf_summary_lsa_originate ( (struct prefix_ipv4 *)p, full_cost, area); |
/* This will flood through area. */ |
/* This will flood through area. */ |
|
|
if (!lsa) |
if (!lsa) |
Line 943 ospf_abr_announce_network (struct ospf *ospf,
|
Line 950 ospf_abr_announce_network (struct ospf *ospf,
|
inet_ntoa (p->prefix), p->prefixlen); |
inet_ntoa (p->prefix), p->prefixlen); |
if ((range = ospf_area_range_match (or_area, p)) |
if ((range = ospf_area_range_match (or_area, p)) |
&& !ospf_area_is_transit (area)) |
&& !ospf_area_is_transit (area)) |
ospf_abr_update_aggregate (range, or); | ospf_abr_update_aggregate (range, or, area); |
else |
else |
ospf_abr_announce_network_to_area (p, or->cost, area); |
ospf_abr_announce_network_to_area (p, or->cost, area); |
} |
} |
Line 1133 ospf_abr_announce_rtr_to_area (struct prefix_ipv4 *p,
|
Line 1140 ospf_abr_announce_rtr_to_area (struct prefix_ipv4 *p,
|
GET_METRIC (slsa->metric), cost); |
GET_METRIC (slsa->metric), cost); |
} |
} |
|
|
if (old && (GET_METRIC (slsa->metric) == cost)) | if (old && (GET_METRIC (slsa->metric) == cost) && |
| ((old->flags & OSPF_LSA_IN_MAXAGE) == 0)) |
{ |
{ |
if (IS_DEBUG_OSPF_EVENT) |
if (IS_DEBUG_OSPF_EVENT) |
zlog_debug ("ospf_abr_announce_rtr_to_area(): old summary approved"); |
zlog_debug ("ospf_abr_announce_rtr_to_area(): old summary approved"); |
Line 1577 ospf_abr_send_nssa_aggregates (struct ospf *ospf) /* t
|
Line 1585 ospf_abr_send_nssa_aggregates (struct ospf *ospf) /* t
|
} |
} |
|
|
static void |
static void |
ospf_abr_announce_nssa_defaults (struct ospf *ospf) /* By ABR-Translator */ |
|
{ |
|
struct listnode *node; |
|
struct ospf_area *area; |
|
|
|
if (! IS_OSPF_ABR (ospf)) |
|
return; |
|
|
|
if (IS_DEBUG_OSPF_NSSA) |
|
zlog_debug ("ospf_abr_announce_stub_defaults(): Start"); |
|
|
|
for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
|
{ |
|
if (IS_DEBUG_OSPF_NSSA) |
|
zlog_debug ("ospf_abr_announce_nssa_defaults(): looking at area %s", |
|
inet_ntoa (area->area_id)); |
|
|
|
if (area->external_routing != OSPF_AREA_NSSA) |
|
continue; |
|
|
|
if (OSPF_IS_AREA_BACKBONE (area)) |
|
continue; /* Sanity Check */ |
|
|
|
/* if (!TranslatorRole continue V 1.0 look for "always" conf */ |
|
if (area->NSSATranslatorState) |
|
{ |
|
if (IS_DEBUG_OSPF_NSSA) |
|
zlog_debug ("ospf_abr_announce_nssa_defaults(): " |
|
"announcing 0.0.0.0/0 to this nssa"); |
|
/* ospf_abr_announce_nssa_asbr_to_as (&p, area->default_cost, area); */ |
|
/*ospf_abr_announce_network_to_area (&p, area->default_cost, area);*/ |
|
} |
|
} |
|
} |
|
|
|
static void |
|
ospf_abr_announce_stub_defaults (struct ospf *ospf) |
ospf_abr_announce_stub_defaults (struct ospf *ospf) |
{ |
{ |
struct listnode *node; |
struct listnode *node; |
Line 1740 ospf_abr_manage_discard_routes (struct ospf *ospf)
|
Line 1712 ospf_abr_manage_discard_routes (struct ospf *ospf)
|
ospf_add_discard_route (ospf->new_table, area, |
ospf_add_discard_route (ospf->new_table, area, |
(struct prefix_ipv4 *) &rn->p); |
(struct prefix_ipv4 *) &rn->p); |
else |
else |
ospf_delete_discard_route ((struct prefix_ipv4 *) &rn->p); | ospf_delete_discard_route (ospf->new_table, |
| (struct prefix_ipv4 *) &rn->p); |
} |
} |
} |
} |
|
|