version 1.1, 2012/02/21 17:26:12
|
version 1.1.1.3, 2013/07/21 23:54:40
|
Line 126 ospf_route_table_free (struct route_table *rt)
|
Line 126 ospf_route_table_free (struct route_table *rt)
|
route_table_finish (rt); |
route_table_finish (rt); |
} |
} |
|
|
|
/* If a prefix exists in the new routing table, then return 1, |
|
otherwise return 0. Since the ZEBRA-RIB does an implicit |
|
withdraw, it is not necessary to send a delete, an add later |
|
will act like an implicit delete. */ |
|
static int |
|
ospf_route_exist_new_table (struct route_table *rt, struct prefix_ipv4 *prefix) |
|
{ |
|
struct route_node *rn; |
|
|
|
assert (rt); |
|
assert (prefix); |
|
|
|
rn = route_node_lookup (rt, (struct prefix *) prefix); |
|
if (!rn) { |
|
return 0; |
|
} |
|
route_unlock_node (rn); |
|
|
|
if (!rn->info) { |
|
return 0; |
|
} |
|
|
|
return 1; |
|
} |
|
|
/* If a prefix and a nexthop match any route in the routing table, |
/* If a prefix and a nexthop match any route in the routing table, |
then return 1, otherwise return 0. */ |
then return 1, otherwise return 0. */ |
int |
int |
Line 223 ospf_route_delete_uniq (struct route_table *rt, struct
|
Line 248 ospf_route_delete_uniq (struct route_table *rt, struct
|
{ |
{ |
if (or->type == OSPF_DESTINATION_NETWORK) |
if (or->type == OSPF_DESTINATION_NETWORK) |
{ |
{ |
if (! ospf_route_match_same (cmprt, | if (! ospf_route_exist_new_table (cmprt, |
(struct prefix_ipv4 *) &rn->p, or)) | (struct prefix_ipv4 *) &rn->p)) |
ospf_zebra_delete ((struct prefix_ipv4 *) &rn->p, or); |
ospf_zebra_delete ((struct prefix_ipv4 *) &rn->p, or); |
} |
} |
else if (or->type == OSPF_DESTINATION_DISCARD) |
else if (or->type == OSPF_DESTINATION_DISCARD) |
if (! ospf_route_match_same (cmprt, | if (! ospf_route_exist_new_table (cmprt, |
(struct prefix_ipv4 *) &rn->p, or)) | (struct prefix_ipv4 *) &rn->p)) |
ospf_zebra_delete_discard ((struct prefix_ipv4 *) &rn->p); |
ospf_zebra_delete_discard ((struct prefix_ipv4 *) &rn->p); |
} |
} |
} |
} |
Line 272 ospf_route_install (struct ospf *ospf, struct route_ta
|
Line 297 ospf_route_install (struct ospf *ospf, struct route_ta
|
} |
} |
} |
} |
|
|
static void |
|
ospf_intra_route_add (struct route_table *rt, struct vertex *v, |
|
struct ospf_area *area) |
|
{ |
|
struct route_node *rn; |
|
struct ospf_route *or; |
|
struct prefix_ipv4 p; |
|
struct ospf_path *path; |
|
struct vertex_parent *parent; |
|
struct listnode *node, *nnode; |
|
|
|
p.family = AF_INET; |
|
p.prefix = v->id; |
|
if (v->type == OSPF_VERTEX_ROUTER) |
|
p.prefixlen = IPV4_MAX_BITLEN; |
|
else |
|
{ |
|
struct network_lsa *lsa = (struct network_lsa *) v->lsa; |
|
p.prefixlen = ip_masklen (lsa->mask); |
|
} |
|
apply_mask_ipv4 (&p); |
|
|
|
rn = route_node_get (rt, (struct prefix *) &p); |
|
if (rn->info) |
|
{ |
|
zlog_warn ("Same routing information exists for %s", inet_ntoa (v->id)); |
|
route_unlock_node (rn); |
|
return; |
|
} |
|
|
|
or = ospf_route_new (); |
|
|
|
if (v->type == OSPF_VERTEX_NETWORK) |
|
{ |
|
or->type = OSPF_DESTINATION_NETWORK; |
|
|
|
for (ALL_LIST_ELEMENTS (v->parents, node, nnode, parent)) |
|
{ |
|
path = ospf_path_new (); |
|
path->nexthop = parent->nexthop->router; |
|
listnode_add (or->paths, path); |
|
} |
|
} |
|
else |
|
or->type = OSPF_DESTINATION_ROUTER; |
|
|
|
or->id = v->id; |
|
or->u.std.area_id = area->area_id; |
|
or->u.std.external_routing= area->external_routing; |
|
or->path_type = OSPF_PATH_INTRA_AREA; |
|
or->cost = v->distance; |
|
|
|
rn->info = or; |
|
} |
|
|
|
/* RFC2328 16.1. (4). For "router". */ |
/* RFC2328 16.1. (4). For "router". */ |
void |
void |
ospf_intra_add_router (struct route_table *rt, struct vertex *v, |
ospf_intra_add_router (struct route_table *rt, struct vertex *v, |
Line 484 ospf_intra_add_transit (struct route_table *rt, struct
|
Line 454 ospf_intra_add_transit (struct route_table *rt, struct
|
void |
void |
ospf_intra_add_stub (struct route_table *rt, struct router_lsa_link *link, |
ospf_intra_add_stub (struct route_table *rt, struct router_lsa_link *link, |
struct vertex *v, struct ospf_area *area, |
struct vertex *v, struct ospf_area *area, |
int parent_is_root) | int parent_is_root, int lsa_pos) |
{ |
{ |
u_int32_t cost; |
u_int32_t cost; |
struct route_node *rn; |
struct route_node *rn; |
Line 632 ospf_intra_add_stub (struct route_table *rt, struct ro
|
Line 602 ospf_intra_add_stub (struct route_table *rt, struct ro
|
if (IS_DEBUG_OSPF_EVENT) |
if (IS_DEBUG_OSPF_EVENT) |
zlog_debug ("ospf_intra_add_stub(): this network is on this router"); |
zlog_debug ("ospf_intra_add_stub(): this network is on this router"); |
|
|
if ((oi = ospf_if_lookup_by_prefix (area->ospf, &p))) | if ((oi = ospf_if_lookup_by_lsa_pos (area, lsa_pos))) |
{ |
{ |
if (IS_DEBUG_OSPF_EVENT) |
if (IS_DEBUG_OSPF_EVENT) |
zlog_debug ("ospf_intra_add_stub(): the interface is %s", |
zlog_debug ("ospf_intra_add_stub(): the interface is %s", |
Line 1009 ospf_add_discard_route (struct route_table *rt, struct
|
Line 979 ospf_add_discard_route (struct route_table *rt, struct
|
ospf_route_free (rn->info); |
ospf_route_free (rn->info); |
} |
} |
|
|
|
if (IS_DEBUG_OSPF_EVENT) |
|
zlog_debug ("ospf_add_discard_route(): " |
|
"adding %s/%d", inet_ntoa (p->prefix), p->prefixlen); |
|
|
new_or = ospf_route_new (); |
new_or = ospf_route_new (); |
new_or->type = OSPF_DESTINATION_DISCARD; |
new_or->type = OSPF_DESTINATION_DISCARD; |
new_or->id.s_addr = 0; |
new_or->id.s_addr = 0; |
Line 1024 ospf_add_discard_route (struct route_table *rt, struct
|
Line 998 ospf_add_discard_route (struct route_table *rt, struct
|
} |
} |
|
|
void |
void |
ospf_delete_discard_route (struct prefix_ipv4 *p) | ospf_delete_discard_route (struct route_table *rt, struct prefix_ipv4 *p) |
{ |
{ |
|
struct route_node *rn; |
|
struct ospf_route *or; |
|
|
|
if (IS_DEBUG_OSPF_EVENT) |
|
zlog_debug ("ospf_delete_discard_route(): " |
|
"deleting %s/%d", inet_ntoa (p->prefix), p->prefixlen); |
|
|
|
rn = route_node_lookup (rt, (struct prefix*)p); |
|
|
|
if (rn == NULL) |
|
{ |
|
if (IS_DEBUG_OSPF_EVENT) |
|
zlog_debug("ospf_delete_discard_route(): no route found"); |
|
return; |
|
} |
|
|
|
or = rn->info; |
|
|
|
if (or->path_type == OSPF_PATH_INTRA_AREA) |
|
{ |
|
if (IS_DEBUG_OSPF_EVENT) |
|
zlog_debug ("ospf_delete_discard_route(): " |
|
"an intra-area route exists"); |
|
return; |
|
} |
|
|
|
if (or->type != OSPF_DESTINATION_DISCARD) |
|
{ |
|
if (IS_DEBUG_OSPF_EVENT) |
|
zlog_debug ("ospf_delete_discard_route(): " |
|
"not a discard entry"); |
|
return; |
|
} |
|
|
|
/* free the route entry and the route node */ |
|
ospf_route_free (rn->info); |
|
|
|
rn->info = NULL; |
|
route_unlock_node (rn); |
|
route_unlock_node (rn); |
|
|
|
/* remove the discard entry from the rib */ |
ospf_zebra_delete_discard(p); |
ospf_zebra_delete_discard(p); |
|
|
|
return; |
} |
} |
|
|