2003-08-10 amir <amir@datacore.ch>

* Add missing 'i' to getopts, short form of --pid_file.
	  see http://bugzilla.quagga.net/show_bug.cgi?id=25
This commit is contained in:
paul 2003-08-10 02:51:22 +00:00
parent 286e1e7153
commit 96735eeafe
14 changed files with 169 additions and 190 deletions

View File

@ -217,7 +217,7 @@ main (int argc, char **argv)
/* Command line argument treatment. */ /* Command line argument treatment. */
while (1) while (1)
{ {
opt = getopt_long (argc, argv, "df:hp:A:P:rnu:v", longopts, 0); opt = getopt_long (argc, argv, "df:i:hp:A:P:rnu:v", longopts, 0);
if (opt == EOF) if (opt == EOF)
break; break;

View File

@ -254,7 +254,7 @@ main (int argc, char *argv[], char *envp[])
/* Command line argument treatment. */ /* Command line argument treatment. */
while (1) while (1)
{ {
opt = getopt_long (argc, argv, "df:hp:A:P:u:v", longopts, 0); opt = getopt_long (argc, argv, "df:i:hp:A:P:u:v", longopts, 0);
if (opt == EOF) if (opt == EOF)
break; break;

View File

@ -779,15 +779,15 @@ ospf_abr_nexthops_belong_to_area (struct ospf_route *or,
struct ospf_area *area) struct ospf_area *area)
{ {
listnode node; listnode node;
struct ospf_path *path;
for (node = listhead (or->path); node; nextnode (node)) LIST_LOOP (or->paths, path, node)
{ {
struct ospf_path *path = node->data;
struct ospf_interface *oi = path->oi; struct ospf_interface *oi = path->oi;
if (oi != NULL) if (oi != NULL)
if (oi->area == area) if (oi->area == area)
return 1; return 1;
} }
return 0; return 0;

View File

@ -141,7 +141,7 @@ ospf_ase_complete_direct_routes (struct ospf_route *ro, struct in_addr nexthop)
listnode node; listnode node;
struct ospf_path *op; struct ospf_path *op;
for (node = listhead (ro->path); node; nextnode (node)) for (node = listhead (ro->paths); node; nextnode (node))
if ((op = getdata (node)) != NULL) if ((op = getdata (node)) != NULL)
if (op->nexthop.s_addr == 0) if (op->nexthop.s_addr == 0)
op->nexthop.s_addr = nexthop.s_addr; op->nexthop.s_addr = nexthop.s_addr;
@ -268,7 +268,6 @@ ospf_ase_calculate_new_route (struct ospf_lsa *lsa,
} }
new->type = OSPF_DESTINATION_NETWORK; new->type = OSPF_DESTINATION_NETWORK;
new->path = list_new ();
new->u.ext.origin = lsa; new->u.ext.origin = lsa;
new->u.ext.tag = ntohl (al->e[0].route_tag); new->u.ext.tag = ntohl (al->e[0].route_tag);
new->u.ext.asbr = asbr_route; new->u.ext.asbr = asbr_route;
@ -511,7 +510,7 @@ ospf_ase_calculate_route (struct ospf *ospf, struct ospf_lsa * lsa)
else else
{ {
zlog_info ("Route[External]: Routes are equal"); zlog_info ("Route[External]: Routes are equal");
ospf_route_copy_nexthops (or, asbr_route->path); ospf_route_copy_nexthops (or, asbr_route->paths);
if (al->e[0].fwd_addr.s_addr) if (al->e[0].fwd_addr.s_addr)
ospf_ase_complete_direct_routes (or, al->e[0].fwd_addr); ospf_ase_complete_direct_routes (or, al->e[0].fwd_addr);
} }
@ -565,11 +564,11 @@ ospf_ase_route_match_same (struct route_table *rt, struct prefix *prefix,
return 0; return 0;
} }
if (or->path->count != newor->path->count) if (or->paths->count != newor->paths->count)
return 0; return 0;
/* Check each path. */ /* Check each path. */
for (n1 = listhead (or->path), n2 = listhead (newor->path); for (n1 = listhead (or->paths), n2 = listhead (newor->paths);
n1 && n2; nextnode (n1), nextnode (n2)) n1 && n2; nextnode (n1), nextnode (n2))
{ {
op = getdata (n1); op = getdata (n1);

View File

@ -71,8 +71,9 @@ ospf_find_abr_route (struct route_table *rtrs,
} }
void void
ospf_ia_network_route (struct route_table *rt, struct prefix_ipv4 *p, ospf_ia_network_route (struct ospf *ospf, struct route_table *rt,
struct ospf_route *new_or, struct ospf_route *abr_or) struct prefix_ipv4 *p, struct ospf_route *new_or,
struct ospf_route *abr_or)
{ {
struct route_node *rn1; struct route_node *rn1;
struct ospf_route *or; struct ospf_route *or;
@ -94,7 +95,7 @@ ospf_ia_network_route (struct route_table *rt, struct prefix_ipv4 *p,
zlog_info ("ospf_ia_network_route(): " zlog_info ("ospf_ia_network_route(): "
"Found a route to the same network"); "Found a route to the same network");
/* Check the existing route. */ /* Check the existing route. */
if ((res = ospf_route_cmp (new_or, or)) < 0) if ((res = ospf_route_cmp (ospf, new_or, or)) < 0)
{ {
/* New route is better, so replace old one. */ /* New route is better, so replace old one. */
ospf_route_subst (rn1, new_or, abr_or); ospf_route_subst (rn1, new_or, abr_or);
@ -103,7 +104,7 @@ ospf_ia_network_route (struct route_table *rt, struct prefix_ipv4 *p,
{ {
/* New and old route are equal, so next hops can be added. */ /* New and old route are equal, so next hops can be added. */
route_lock_node (rn1); route_lock_node (rn1);
ospf_route_copy_nexthops (or, abr_or->path); ospf_route_copy_nexthops (or, abr_or->paths);
route_unlock_node (rn1); route_unlock_node (rn1);
/* new route can be deleted, because existing route has been updated. */ /* new route can be deleted, because existing route has been updated. */
@ -127,18 +128,19 @@ ospf_ia_network_route (struct route_table *rt, struct prefix_ipv4 *p,
} }
void void
ospf_ia_router_route (struct route_table *rt, struct prefix_ipv4 *p, ospf_ia_router_route (struct ospf *ospf, struct route_table *rtrs,
struct prefix_ipv4 *p,
struct ospf_route *new_or, struct ospf_route *abr_or) struct ospf_route *new_or, struct ospf_route *abr_or)
{ {
struct route_node *rn;
struct ospf_route *or = NULL; struct ospf_route *or = NULL;
struct route_node *rn;
int ret; int ret;
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_ia_router_route(): considering %s/%d", zlog_info ("ospf_ia_router_route(): considering %s/%d",
inet_ntoa (p->prefix), p->prefixlen); inet_ntoa (p->prefix), p->prefixlen);
/* Find a route to the same dest */ /* Find a route to the same dest */
rn = route_node_get (rt,(struct prefix *) p); rn = route_node_get (rtrs, (struct prefix *) p);
if (rn->info == NULL) if (rn->info == NULL)
/* This is a new route */ /* This is a new route */
@ -146,11 +148,11 @@ ospf_ia_router_route (struct route_table *rt, struct prefix_ipv4 *p,
else else
{ {
struct ospf_area *or_area; struct ospf_area *or_area;
or_area = ospf_area_lookup_by_area_id (new_or->u.std.area_id); or_area = ospf_area_lookup_by_area_id (ospf, new_or->u.std.area_id);
assert (or_area); assert (or_area);
/* This is an additional route */ /* This is an additional route */
route_unlock_node (rn); route_unlock_node (rn);
or = ospf_find_asbr_route_through_area (rt, p, or_area); or = ospf_find_asbr_route_through_area (rtrs, p, or_area);
} }
if (or) if (or)
@ -159,7 +161,7 @@ ospf_ia_router_route (struct route_table *rt, struct prefix_ipv4 *p,
zlog_info ("ospf_ia_router_route(): " zlog_info ("ospf_ia_router_route(): "
"a route to the same ABR through the same area exists"); "a route to the same ABR through the same area exists");
/* New route is better */ /* New route is better */
if ((ret = ospf_route_cmp (new_or, or)) < 0) if ((ret = ospf_route_cmp (ospf, new_or, or)) < 0)
{ {
listnode_delete (rn->info, or); listnode_delete (rn->info, or);
ospf_route_free (or); ospf_route_free (or);
@ -171,7 +173,7 @@ ospf_ia_router_route (struct route_table *rt, struct prefix_ipv4 *p,
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_ia_router_route(): merging the new route"); zlog_info ("ospf_ia_router_route(): merging the new route");
ospf_route_copy_nexthops (or, abr_or->path); ospf_route_copy_nexthops (or, abr_or->paths);
ospf_route_free (new_or); ospf_route_free (new_or);
return; return;
} }
@ -185,7 +187,7 @@ ospf_ia_router_route (struct route_table *rt, struct prefix_ipv4 *p,
} }
} }
ospf_route_copy_nexthops (new_or, abr_or->path); ospf_route_copy_nexthops (new_or, abr_or->paths);
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_ia_router_route(): adding the new route"); zlog_info ("ospf_ia_router_route(): adding the new route");
@ -194,28 +196,21 @@ ospf_ia_router_route (struct route_table *rt, struct prefix_ipv4 *p,
} }
struct ia_args
{
struct route_table *rt;
struct route_table *rtrs;
struct ospf_area *area;
};
int int
process_summary_lsa (struct ospf_lsa *l, void *v, int i) process_summary_lsa (struct ospf_area *area, struct route_table *rt,
struct route_table *rtrs, struct ospf_lsa *lsa)
{ {
struct ospf *ospf = area->ospf;
struct ospf_area_range *range; struct ospf_area_range *range;
struct ospf_route *abr_or, *new_or; struct ospf_route *abr_or, *new_or;
struct summary_lsa *sl; struct summary_lsa *sl;
struct prefix_ipv4 p, abr; struct prefix_ipv4 p, abr;
u_int32_t metric; u_int32_t metric;
struct ia_args *args;
if (l == NULL) if (lsa == NULL)
return 0; return 0;
args = (struct ia_args *) v; sl = (struct summary_lsa *) lsa->data;
sl = (struct summary_lsa *) l->data;
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_info ("process_summary_lsa(): LS ID: %s", inet_ntoa (sl->header.id)); zlog_info ("process_summary_lsa(): LS ID: %s", inet_ntoa (sl->header.id));
@ -225,10 +220,10 @@ process_summary_lsa (struct ospf_lsa *l, void *v, int i)
if (metric == OSPF_LS_INFINITY) if (metric == OSPF_LS_INFINITY)
return 0; return 0;
if (IS_LSA_MAXAGE (l)) if (IS_LSA_MAXAGE (lsa))
return 0; return 0;
if (ospf_lsa_is_self_originated (l)) if (ospf_lsa_is_self_originated (area->ospf, lsa))
return 0; return 0;
p.family = AF_INET; p.family = AF_INET;
@ -242,12 +237,12 @@ process_summary_lsa (struct ospf_lsa *l, void *v, int i)
apply_mask_ipv4 (&p); apply_mask_ipv4 (&p);
if (sl->header.type == OSPF_SUMMARY_LSA && if (sl->header.type == OSPF_SUMMARY_LSA &&
(range = ospf_area_range_match_any (ospf_top, &p)) && (range = ospf_area_range_match_any (ospf, &p)) &&
ospf_area_range_active (range)) ospf_area_range_active (range))
return 0; return 0;
if (ospf_top->abr_type != OSPF_ABR_STAND && if (ospf->abr_type != OSPF_ABR_STAND &&
args->area->external_routing != OSPF_AREA_DEFAULT && area->external_routing != OSPF_AREA_DEFAULT &&
p.prefix.s_addr == OSPF_DEFAULT_DESTINATION && p.prefix.s_addr == OSPF_DEFAULT_DESTINATION &&
p.prefixlen == 0) p.prefixlen == 0)
return 0; /* Ignore summary default from a stub area */ return 0; /* Ignore summary default from a stub area */
@ -257,7 +252,7 @@ process_summary_lsa (struct ospf_lsa *l, void *v, int i)
abr.prefixlen = IPV4_MAX_BITLEN; abr.prefixlen = IPV4_MAX_BITLEN;
apply_mask_ipv4 (&abr); apply_mask_ipv4 (&abr);
abr_or = ospf_find_abr_route (args->rtrs, &abr, args->area); abr_or = ospf_find_abr_route (rtrs, &abr, area);
if (abr_or == NULL) if (abr_or == NULL)
return 0; return 0;
@ -269,32 +264,35 @@ process_summary_lsa (struct ospf_lsa *l, void *v, int i)
new_or->u.std.options = sl->header.options; new_or->u.std.options = sl->header.options;
new_or->u.std.origin = (struct lsa_header *) sl; new_or->u.std.origin = (struct lsa_header *) sl;
new_or->cost = abr_or->cost + metric; new_or->cost = abr_or->cost + metric;
new_or->u.std.area_id = args->area->area_id; new_or->u.std.area_id = area->area_id;
#ifdef HAVE_NSSA #ifdef HAVE_NSSA
new_or->u.std.external_routing = args->area->external_routing; new_or->u.std.external_routing = area->external_routing;
#endif /* HAVE_NSSA */ #endif /* HAVE_NSSA */
new_or->path_type = OSPF_PATH_INTER_AREA; new_or->path_type = OSPF_PATH_INTER_AREA;
if (sl->header.type == OSPF_SUMMARY_LSA) if (sl->header.type == OSPF_SUMMARY_LSA)
ospf_ia_network_route (args->rt, &p, new_or, abr_or); ospf_ia_network_route (ospf, rt, &p, new_or, abr_or);
else else
{ {
new_or->type = OSPF_DESTINATION_ROUTER; new_or->type = OSPF_DESTINATION_ROUTER;
new_or->u.std.flags = ROUTER_LSA_EXTERNAL; new_or->u.std.flags = ROUTER_LSA_EXTERNAL;
ospf_ia_router_route (args->rtrs, &p, new_or, abr_or); ospf_ia_router_route (ospf, rtrs, &p, new_or, abr_or);
} }
return 0; return 0;
} }
void void
ospf_examine_summaries (struct ospf_area * area, ospf_examine_summaries (struct ospf_area *area,
struct route_table *lsdb_rt, struct route_table *lsdb_rt,
struct route_table *rt, struct route_table *rt,
struct route_table *rtrs) struct route_table *rtrs)
{ {
struct ia_args args = {rt, rtrs, area}; struct ospf_lsa *lsa;
foreach_lsa (lsdb_rt, &args, 0, process_summary_lsa); struct route_node *rn;
LSDB_LOOP (lsdb_rt, rn, lsa)
process_summary_lsa (area, rt, rtrs, lsa);
} }
int int
@ -305,7 +303,8 @@ ospf_area_is_transit (struct ospf_area *area)
} }
void void
ospf_update_network_route (struct route_table *rt, ospf_update_network_route (struct ospf *ospf,
struct route_table *rt,
struct route_table *rtrs, struct route_table *rtrs,
struct summary_lsa *lsa, struct summary_lsa *lsa,
struct prefix_ipv4 *p, struct prefix_ipv4 *p,
@ -336,7 +335,7 @@ ospf_update_network_route (struct route_table *rt,
if (! rn) if (! rn)
{ {
if (ospf_top->abr_type != OSPF_ABR_SHORTCUT) if (ospf->abr_type != OSPF_ABR_SHORTCUT)
return; /* Standard ABR can update only already installed return; /* Standard ABR can update only already installed
backbone paths */ backbone paths */
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
@ -375,7 +374,7 @@ ospf_update_network_route (struct route_table *rt,
return; return;
} }
if (ospf_top->abr_type == OSPF_ABR_SHORTCUT) if (ospf->abr_type == OSPF_ABR_SHORTCUT)
{ {
if (or->path_type == OSPF_PATH_INTRA_AREA && if (or->path_type == OSPF_PATH_INTRA_AREA &&
!OSPF_IS_AREA_ID_BACKBONE (or->u.std.area_id)) !OSPF_IS_AREA_ID_BACKBONE (or->u.std.area_id))
@ -409,7 +408,7 @@ ospf_update_network_route (struct route_table *rt,
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_update_network_route(): " zlog_info ("ospf_update_network_route(): "
"new route is same distance, adding nexthops"); "new route is same distance, adding nexthops");
ospf_route_copy_nexthops (or, abr_or->path); ospf_route_copy_nexthops (or, abr_or->paths);
} }
if (or->cost > cost) if (or->cost > cost)
@ -417,10 +416,10 @@ ospf_update_network_route (struct route_table *rt,
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_update_network_route(): " zlog_info ("ospf_update_network_route(): "
"new route is better, overriding nexthops"); "new route is better, overriding nexthops");
ospf_route_subst_nexthops (or, abr_or->path); ospf_route_subst_nexthops (or, abr_or->paths);
or->cost = cost; or->cost = cost;
if ((ospf_top->abr_type == OSPF_ABR_SHORTCUT) && if ((ospf->abr_type == OSPF_ABR_SHORTCUT) &&
!OSPF_IS_AREA_ID_BACKBONE (or->u.std.area_id)) !OSPF_IS_AREA_ID_BACKBONE (or->u.std.area_id))
{ {
or->path_type = OSPF_PATH_INTER_AREA; or->path_type = OSPF_PATH_INTER_AREA;
@ -437,7 +436,8 @@ ospf_update_network_route (struct route_table *rt,
} }
void void
ospf_update_router_route (struct route_table *rtrs, ospf_update_router_route (struct ospf *ospf,
struct route_table *rtrs,
struct summary_lsa *lsa, struct summary_lsa *lsa,
struct prefix_ipv4 *p, struct prefix_ipv4 *p,
struct ospf_area *area) struct ospf_area *area)
@ -465,17 +465,17 @@ ospf_update_router_route (struct route_table *rtrs,
/* First try to find a backbone path, /* First try to find a backbone path,
because standard ABR can update only BB-associated paths */ because standard ABR can update only BB-associated paths */
if ((ospf_top->backbone == NULL) && if ((ospf->backbone == NULL) &&
(ospf_top->abr_type != OSPF_ABR_SHORTCUT)) (ospf->abr_type != OSPF_ABR_SHORTCUT))
/* no BB area, not Shortcut ABR, exiting */ /* no BB area, not Shortcut ABR, exiting */
return; return;
or = ospf_find_asbr_route_through_area (rtrs, p, ospf_top->backbone); or = ospf_find_asbr_route_through_area (rtrs, p, ospf->backbone);
if (or == NULL) if (or == NULL)
{ {
if (ospf_top->abr_type != OSPF_ABR_SHORTCUT) if (ospf->abr_type != OSPF_ABR_SHORTCUT)
/* route to ASBR through the BB not found /* route to ASBR through the BB not found
the router is not Shortcut ABR, exiting */ the router is not Shortcut ABR, exiting */
@ -500,7 +500,7 @@ ospf_update_router_route (struct route_table *rtrs,
#endif /* HAVE_NSSA */ #endif /* HAVE_NSSA */
new_or->path_type = OSPF_PATH_INTER_AREA; new_or->path_type = OSPF_PATH_INTER_AREA;
new_or->u.std.flags = ROUTER_LSA_EXTERNAL; new_or->u.std.flags = ROUTER_LSA_EXTERNAL;
ospf_ia_router_route (rtrs, p, new_or, abr_or); ospf_ia_router_route (ospf, rtrs, p, new_or, abr_or);
return; return;
} }
@ -523,11 +523,11 @@ ospf_update_router_route (struct route_table *rtrs,
return; return;
else if (or->cost == cost) else if (or->cost == cost)
ospf_route_copy_nexthops (or, abr_or->path); ospf_route_copy_nexthops (or, abr_or->paths);
else if (or->cost > cost) else if (or->cost > cost)
{ {
ospf_route_subst_nexthops (or, abr_or->path); ospf_route_subst_nexthops (or, abr_or->paths);
or->cost = cost; or->cost = cost;
/* Even if the ABR runs in Shortcut mode, we can't change /* Even if the ABR runs in Shortcut mode, we can't change
@ -537,22 +537,22 @@ ospf_update_router_route (struct route_table *rtrs,
} }
int int
process_transit_summary_lsa (struct ospf_lsa *l, void *v, int i) process_transit_summary_lsa (struct ospf_area *area, struct route_table *rt,
struct route_table *rtrs, struct ospf_lsa *lsa)
{ {
struct ospf *ospf = area->ospf;
struct summary_lsa *sl; struct summary_lsa *sl;
struct prefix_ipv4 p; struct prefix_ipv4 p;
u_int32_t metric; u_int32_t metric;
struct ia_args *args;
if (l == NULL) if (lsa == NULL)
return 0; return 0;
args = (struct ia_args *) v; sl = (struct summary_lsa *) lsa->data;
sl = (struct summary_lsa *) l->data;
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_info ("process_transit_summaries(): LS ID: %s", zlog_info ("process_transit_summaries(): LS ID: %s",
inet_ntoa (l->data->id)); inet_ntoa (lsa->data->id));
metric = GET_METRIC (sl->metric); metric = GET_METRIC (sl->metric);
if (metric == OSPF_LS_INFINITY) if (metric == OSPF_LS_INFINITY)
@ -562,14 +562,14 @@ process_transit_summary_lsa (struct ospf_lsa *l, void *v, int i)
return 0; return 0;
} }
if (IS_LSA_MAXAGE (l)) if (IS_LSA_MAXAGE (lsa))
{ {
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_info ("process_transit_summaries(): This LSA is too old"); zlog_info ("process_transit_summaries(): This LSA is too old");
return 0; return 0;
} }
if (ospf_lsa_is_self_originated (l)) if (ospf_lsa_is_self_originated (area->ospf, lsa))
{ {
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_info ("process_transit_summaries(): This LSA is mine, skip"); zlog_info ("process_transit_summaries(): This LSA is mine, skip");
@ -587,28 +587,29 @@ process_transit_summary_lsa (struct ospf_lsa *l, void *v, int i)
apply_mask_ipv4 (&p); apply_mask_ipv4 (&p);
if (sl->header.type == OSPF_SUMMARY_LSA) if (sl->header.type == OSPF_SUMMARY_LSA)
ospf_update_network_route (args->rt, args->rtrs, sl, &p, args->area); ospf_update_network_route (ospf, rt, rtrs, sl, &p, area);
else else
ospf_update_router_route (args->rtrs, sl, &p, args->area); ospf_update_router_route (ospf, rtrs, sl, &p, area);
return 0; return 0;
} }
void void
ospf_examine_transit_summaries (struct ospf_area *area, ospf_examine_transit_summaries (struct ospf_area *area,
/* struct ospf_lsdb *lsdb, */
struct route_table *lsdb_rt, struct route_table *lsdb_rt,
struct route_table *rt, struct route_table *rt,
struct route_table *rtrs) struct route_table *rtrs)
{ {
struct ia_args args = {rt, rtrs, area}; struct ospf_lsa *lsa;
struct route_node *rn;
/* ospf_lsdb_iterator (lsdb, &args, 0, process_transit_summary_lsa); */ LSDB_LOOP (lsdb_rt, rn, lsa)
foreach_lsa (lsdb_rt, &args, 0, process_transit_summary_lsa); process_transit_summary_lsa (area, rt, rtrs, lsa);
} }
void void
ospf_ia_routing (struct route_table *rt, ospf_ia_routing (struct ospf *ospf,
struct route_table *rt,
struct route_table *rtrs) struct route_table *rtrs)
{ {
struct ospf_area * area; struct ospf_area * area;
@ -616,18 +617,18 @@ ospf_ia_routing (struct route_table *rt,
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_ia_routing():start"); zlog_info ("ospf_ia_routing():start");
if (OSPF_IS_ABR) if (IS_OSPF_ABR (ospf))
{ {
listnode node; listnode node;
struct ospf_area *area; struct ospf_area *area;
switch (ospf_top->abr_type) switch (ospf->abr_type)
{ {
case OSPF_ABR_STAND: case OSPF_ABR_STAND:
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_ia_routing():Standard ABR"); zlog_info ("ospf_ia_routing():Standard ABR");
if ((area = ospf_top->backbone)) if ((area = ospf->backbone))
{ {
listnode node; listnode node;
@ -639,9 +640,9 @@ ospf_ia_routing (struct route_table *rt,
OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs); OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs);
for (node = listhead (ospf_top->areas); node; nextnode (node)) for (node = listhead (ospf->areas); node; nextnode (node))
if ((area = getdata (node)) != NULL) if ((area = getdata (node)) != NULL)
if (area != ospf_top->backbone) if (area != ospf->backbone)
if (ospf_area_is_transit (area)) if (ospf_area_is_transit (area))
OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL (area, rt, rtrs); OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL (area, rt, rtrs);
} }
@ -653,10 +654,10 @@ ospf_ia_routing (struct route_table *rt,
case OSPF_ABR_CISCO: case OSPF_ABR_CISCO:
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_ia_routing():Alternative Cisco/IBM ABR"); zlog_info ("ospf_ia_routing():Alternative Cisco/IBM ABR");
area = ospf_top->backbone; /* Find the BB */ area = ospf->backbone; /* Find the BB */
/* If we have an active BB connection */ /* If we have an active BB connection */
if (area && ospf_act_bb_connection ()) if (area && ospf_act_bb_connection (ospf))
{ {
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
{ {
@ -666,9 +667,9 @@ ospf_ia_routing (struct route_table *rt,
OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs); OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs);
for (node = listhead (ospf_top->areas); node; nextnode (node)) for (node = listhead (ospf->areas); node; nextnode (node))
if ((area = getdata (node)) != NULL) if ((area = getdata (node)) != NULL)
if (area != ospf_top->backbone) if (area != ospf->backbone)
if (ospf_area_is_transit (area)) if (ospf_area_is_transit (area))
OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL (area, rt, rtrs); OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL (area, rt, rtrs);
} }
@ -677,7 +678,7 @@ ospf_ia_routing (struct route_table *rt,
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_ia_routing(): " zlog_info ("ospf_ia_routing(): "
"Active BB connection not found"); "Active BB connection not found");
for (node = listhead (ospf_top->areas); node; nextnode (node)) for (node = listhead (ospf->areas); node; nextnode (node))
if ((area = getdata (node)) != NULL) if ((area = getdata (node)) != NULL)
OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs); OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs);
} }
@ -685,10 +686,10 @@ ospf_ia_routing (struct route_table *rt,
case OSPF_ABR_SHORTCUT: case OSPF_ABR_SHORTCUT:
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_ia_routing():Alternative Shortcut"); zlog_info ("ospf_ia_routing():Alternative Shortcut");
area = ospf_top->backbone; /* Find the BB */ area = ospf->backbone; /* Find the BB */
/* If we have an active BB connection */ /* If we have an active BB connection */
if (area && ospf_act_bb_connection ()) if (area && ospf_act_bb_connection (ospf))
{ {
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
{ {
@ -698,12 +699,12 @@ ospf_ia_routing (struct route_table *rt,
OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs); OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs);
} }
for (node = listhead (ospf_top->areas); node; nextnode (node)) for (node = listhead (ospf->areas); node; nextnode (node))
if ((area = getdata (node)) != NULL) if ((area = getdata (node)) != NULL)
if (area != ospf_top->backbone) if (area != ospf->backbone)
if (ospf_area_is_transit (area) || if (ospf_area_is_transit (area) ||
((area->shortcut_configured != OSPF_SHORTCUT_DISABLE) && ((area->shortcut_configured != OSPF_SHORTCUT_DISABLE) &&
((ospf_top->backbone == NULL) || ((ospf->backbone == NULL) ||
((area->shortcut_configured == OSPF_SHORTCUT_ENABLE) && ((area->shortcut_configured == OSPF_SHORTCUT_ENABLE) &&
area->shortcut_capability)))) area->shortcut_capability))))
OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL (area, rt, rtrs); OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL (area, rt, rtrs);
@ -719,7 +720,7 @@ ospf_ia_routing (struct route_table *rt,
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_info ("ospf_ia_routing():not ABR, considering all areas"); zlog_info ("ospf_ia_routing():not ABR, considering all areas");
for (node = listhead (ospf_top->areas); node; nextnode (node)) for (node = listhead (ospf->areas); node; nextnode (node))
if ((area = getdata (node)) != NULL) if ((area = getdata (node)) != NULL)
OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs); OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs);
} }

View File

@ -232,7 +232,7 @@ main (int argc, char **argv)
{ {
int opt; int opt;
opt = getopt_long (argc, argv, "dlf:hA:P:u:v", longopts, 0); opt = getopt_long (argc, argv, "dlf:i:hA:P:u:v", longopts, 0);
if (opt == EOF) if (opt == EOF)
break; break;

View File

@ -49,6 +49,8 @@ ospf_route_new ()
new->ctime = time (NULL); new->ctime = time (NULL);
new->mtime = new->ctime; new->mtime = new->ctime;
new->paths = list_new ();
new->paths->del = (void (*) (void *))ospf_path_free;
return new; return new;
} }
@ -56,15 +58,8 @@ ospf_route_new ()
void void
ospf_route_free (struct ospf_route *or) ospf_route_free (struct ospf_route *or)
{ {
listnode node; if (or->paths)
list_delete (or->paths);
if (or->path)
{
for (node = listhead (or->path); node; nextnode (node))
ospf_path_free (node->data);
list_delete (or->path);
}
XFREE (MTYPE_OSPF_ROUTE, or); XFREE (MTYPE_OSPF_ROUTE, or);
} }
@ -158,11 +153,11 @@ ospf_route_match_same (struct route_table *rt, struct prefix_ipv4 *prefix,
{ {
if (or->type == OSPF_DESTINATION_NETWORK) if (or->type == OSPF_DESTINATION_NETWORK)
{ {
if (or->path->count != newor->path->count) if (or->paths->count != newor->paths->count)
return 0; return 0;
/* Check each path. */ /* Check each path. */
for (n1 = listhead (or->path), n2 = listhead (newor->path); for (n1 = listhead (or->paths), n2 = listhead (newor->paths);
n1 && n2; nextnode (n1), nextnode (n2)) n1 && n2; nextnode (n1), nextnode (n2))
{ {
op = getdata (n1); op = getdata (n1);
@ -310,15 +305,14 @@ ospf_intra_route_add (struct route_table *rt, struct vertex *v,
if (v->type == OSPF_VERTEX_NETWORK) if (v->type == OSPF_VERTEX_NETWORK)
{ {
or->type = OSPF_DESTINATION_NETWORK; or->type = OSPF_DESTINATION_NETWORK;
or->path = list_new ();
for (nnode = listhead (v->nexthop); nnode; nextnode (nnode)) LIST_LOOP (v->nexthop, nexthop, nnode)
{ {
nexthop = getdata (nnode); nexthop = getdata (nnode);
path = ospf_path_new (); path = ospf_path_new ();
path->nexthop = nexthop->router; path->nexthop = nexthop->router;
listnode_add (or->path, path); listnode_add (or->paths, path);
} }
} }
else else
or->type = OSPF_DESTINATION_ROUTER; or->type = OSPF_DESTINATION_ROUTER;
@ -592,8 +586,8 @@ ospf_intra_add_stub (struct route_table *rt, struct router_lsa_link *link,
cur_or->cost = cost; cur_or->cost = cost;
list_delete (cur_or->path); list_delete (cur_or->paths);
cur_or->path = NULL; cur_or->paths = NULL;
ospf_route_copy_nexthops_from_vertex (cur_or, v); ospf_route_copy_nexthops_from_vertex (cur_or, v);
@ -616,7 +610,6 @@ ospf_intra_add_stub (struct route_table *rt, struct router_lsa_link *link,
or->cost = cost; or->cost = cost;
or->type = OSPF_DESTINATION_NETWORK; or->type = OSPF_DESTINATION_NETWORK;
or->u.std.origin = (struct lsa_header *) lsa; or->u.std.origin = (struct lsa_header *) lsa;
or->path = list_new ();
/* Nexthop is depend on connection type. */ /* Nexthop is depend on connection type. */
if (v != area->spf) if (v != area->spf)
@ -639,7 +632,7 @@ ospf_intra_add_stub (struct route_table *rt, struct router_lsa_link *link,
path = ospf_path_new (); path = ospf_path_new ();
path->nexthop.s_addr = 0; path->nexthop.s_addr = 0;
path->oi = oi; path->oi = oi;
listnode_add (or->path, path); listnode_add (or->paths, path);
} }
else else
{ {
@ -691,7 +684,7 @@ ospf_route_table_dump (struct route_table *rt)
BUFSIZ), BUFSIZ),
ospf_path_type_str[or->path_type], ospf_path_type_str[or->path_type],
or->cost); or->cost);
for (pnode = listhead (or->path); pnode; nextnode (pnode)) for (pnode = listhead (or->paths); pnode; nextnode (pnode))
{ {
path = getdata (pnode); path = getdata (pnode);
zlog_info (" -> %s", inet_ntoa (path->nexthop)); zlog_info (" -> %s", inet_ntoa (path->nexthop));
@ -821,8 +814,7 @@ ospf_route_copy_nexthops_from_vertex (struct ospf_route *to,
struct ospf_path *path; struct ospf_path *path;
struct vertex_nexthop *nexthop; struct vertex_nexthop *nexthop;
if (to->path == NULL) assert (to->paths);
to->path = list_new ();
for (nnode = listhead (v->nexthop); nnode; nextnode (nnode)) for (nnode = listhead (v->nexthop); nnode; nextnode (nnode))
{ {
@ -830,12 +822,12 @@ ospf_route_copy_nexthops_from_vertex (struct ospf_route *to,
if (nexthop->oi != NULL) if (nexthop->oi != NULL)
{ {
if (! ospf_path_exist (to->path, nexthop->router, nexthop->oi)) if (! ospf_path_exist (to->paths, nexthop->router, nexthop->oi))
{ {
path = ospf_path_new (); path = ospf_path_new ();
path->nexthop = nexthop->router; path->nexthop = nexthop->router;
path->oi = nexthop->oi; path->oi = nexthop->oi;
listnode_add (to->path, path); listnode_add (to->paths, path);
} }
} }
} }
@ -863,29 +855,19 @@ ospf_route_copy_nexthops (struct ospf_route *to, list from)
{ {
listnode node; listnode node;
if (to->path == NULL) assert (to->paths);
to->path = list_new ();
for (node = listhead (from); node; nextnode (node)) for (node = listhead (from); node; nextnode (node))
/* The same routes are just discarded. */ /* The same routes are just discarded. */
if (!ospf_path_lookup (to->path, node->data)) if (!ospf_path_lookup (to->paths, node->data))
listnode_add (to->path, ospf_path_dup (node->data)); listnode_add (to->paths, ospf_path_dup (node->data));
} }
void void
ospf_route_subst_nexthops (struct ospf_route *to, list from) ospf_route_subst_nexthops (struct ospf_route *to, list from)
{ {
listnode node;
struct ospf_path *op;
for (node = listhead (to->path); node; nextnode (node)) list_delete_all_node (to->paths);
if ((op = getdata (node)) != NULL)
{
ospf_path_free (op);
node->data = NULL;
}
list_delete_all_node (to->path);
ospf_route_copy_nexthops (to, from); ospf_route_copy_nexthops (to, from);
} }
@ -896,7 +878,7 @@ ospf_route_subst (struct route_node *rn, struct ospf_route *new_or,
route_lock_node (rn); route_lock_node (rn);
ospf_route_free (rn->info); ospf_route_free (rn->info);
ospf_route_copy_nexthops (new_or, over->path); ospf_route_copy_nexthops (new_or, over->paths);
rn->info = new_or; rn->info = new_or;
route_unlock_node (rn); route_unlock_node (rn);
} }
@ -909,7 +891,7 @@ ospf_route_add (struct route_table *rt, struct prefix_ipv4 *p,
rn = route_node_get (rt, (struct prefix *) p); rn = route_node_get (rt, (struct prefix *) p);
ospf_route_copy_nexthops (new_or, over->path); ospf_route_copy_nexthops (new_or, over->paths);
if (rn->info) if (rn->info)
{ {
@ -937,7 +919,7 @@ ospf_prune_unreachable_networks (struct route_table *rt)
if (rn->info != NULL) if (rn->info != NULL)
{ {
or = rn->info; or = rn->info;
if (listcount (or->path) == 0) if (listcount (or->paths) == 0)
{ {
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_info ("Pruning route to %s/%d", zlog_info ("Pruning route to %s/%d",
@ -974,7 +956,7 @@ ospf_prune_unreachable_routers (struct route_table *rtrs)
or = getdata (node); or = getdata (node);
if (listcount (or->path) == 0) if (listcount (or->paths) == 0)
{ {
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
{ {

View File

@ -110,7 +110,7 @@ struct ospf_route
u_char path_type; u_char path_type;
/* List of Paths. */ /* List of Paths. */
list path; list paths;
/* Link State Cost. */ /* Link State Cost. */
u_int32_t cost; /* i.e. metric. */ u_int32_t cost; /* i.e. metric. */
@ -124,14 +124,14 @@ struct ospf_route
}; };
struct ospf_path *ospf_path_new (); struct ospf_path *ospf_path_new ();
void ospf_path_free (struct ospf_path *op); void ospf_path_free (struct ospf_path *);
struct ospf_path *ospf_path_lookup (list, struct ospf_path *); struct ospf_path *ospf_path_lookup (list, struct ospf_path *);
struct ospf_route *ospf_route_new (); struct ospf_route *ospf_route_new ();
void ospf_route_free (struct ospf_route *or); void ospf_route_free (struct ospf_route *);
void ospf_route_delete (struct route_table *rt); void ospf_route_delete (struct route_table *);
void ospf_route_table_free (struct route_table *rt); void ospf_route_table_free (struct route_table *);
void ospf_route_install (struct route_table *); void ospf_route_install (struct ospf *, struct route_table *);
void ospf_route_table_dump (struct route_table *); void ospf_route_table_dump (struct route_table *);
void ospf_intra_add_router (struct route_table *, struct vertex *, void ospf_intra_add_router (struct route_table *, struct vertex *,
@ -143,7 +143,7 @@ void ospf_intra_add_transit (struct route_table *, struct vertex *,
void ospf_intra_add_stub (struct route_table *, struct router_lsa_link *, void ospf_intra_add_stub (struct route_table *, struct router_lsa_link *,
struct vertex *, struct ospf_area *); struct vertex *, struct ospf_area *);
int ospf_route_cmp (struct ospf_route *, struct ospf_route *); int ospf_route_cmp (struct ospf *, struct ospf_route *, struct ospf_route *);
void ospf_route_copy_nexthops (struct ospf_route *, list); void ospf_route_copy_nexthops (struct ospf_route *, list);
void ospf_route_copy_nexthops_from_vertex (struct ospf_route *, void ospf_route_copy_nexthops_from_vertex (struct ospf_route *,
struct vertex * ); struct vertex * );

View File

@ -898,7 +898,7 @@ ospf_rtrs_print (struct route_table *rtrs)
break; break;
} }
for (pnode = listhead (or->path); pnode; nextnode (pnode)) for (pnode = listhead (or->paths); pnode; nextnode (pnode))
{ {
path = getdata (pnode); path = getdata (pnode);
if (path->nexthop.s_addr == 0) if (path->nexthop.s_addr == 0)

View File

@ -6513,20 +6513,19 @@ show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
} }
if (or->type == OSPF_DESTINATION_NETWORK) if (or->type == OSPF_DESTINATION_NETWORK)
for (pnode = listhead (or->path); pnode; nextnode (pnode)) LIST_LOOP (or->paths, path, pnode)
{ {
path = getdata (pnode); if (path->oi != NULL)
if (path->oi != NULL) {
{ if (path->nexthop.s_addr == 0)
if (path->nexthop.s_addr == 0) vty_out (vty, "%24s directly attached to %s%s",
vty_out (vty, "%24s directly attached to %s%s", "", path->oi->ifp->name, VTY_NEWLINE);
"", path->oi->ifp->name, VTY_NEWLINE); else
else vty_out (vty, "%24s via %s, %s%s", "",
vty_out (vty, "%24s via %s, %s%s", "", inet_ntoa (path->nexthop), path->oi->ifp->name,
inet_ntoa (path->nexthop), path->oi->ifp->name, VTY_NEWLINE);
VTY_NEWLINE); }
} }
}
} }
vty_out (vty, "%s", VTY_NEWLINE); vty_out (vty, "%s", VTY_NEWLINE);
} }
@ -6564,17 +6563,16 @@ show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
(or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""), (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
VTY_NEWLINE); VTY_NEWLINE);
for (pn = listhead (or->path); pn; nextnode (pn)) LIST_LOOP (or->paths, path, pn)
{ {
path = getdata (pn); if (path->nexthop.s_addr == 0)
if (path->nexthop.s_addr == 0) vty_out (vty, "%24s directly attached to %s%s",
vty_out (vty, "%24s directly attached to %s%s", "", path->oi->ifp->name, VTY_NEWLINE);
"", path->oi->ifp->name, VTY_NEWLINE); else
else vty_out (vty, "%24s via %s, %s%s", "",
vty_out (vty, "%24s via %s, %s%s", "", inet_ntoa (path->nexthop), path->oi->ifp->name,
inet_ntoa (path->nexthop), path->oi->ifp->name, VTY_NEWLINE);
VTY_NEWLINE); }
}
} }
} }
vty_out (vty, "%s", VTY_NEWLINE); vty_out (vty, "%s", VTY_NEWLINE);
@ -6609,18 +6607,17 @@ show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
break; break;
} }
for (pnode = listhead (er->path); pnode; nextnode (pnode)) LIST_LOOP (er->paths, path, pnode)
{ {
path = getdata (pnode);
if (path->oi != NULL) if (path->oi != NULL)
{ {
if (path->nexthop.s_addr == 0) if (path->nexthop.s_addr == 0)
vty_out (vty, "%24s directly attached to %s%s", vty_out (vty, "%24s directly attached to %s%s",
"", path->oi->ifp->name, VTY_NEWLINE); "", path->oi->ifp->name, VTY_NEWLINE);
else else
vty_out (vty, "%24s via %s, %s%s", "", vty_out (vty, "%24s via %s, %s%s", "",
inet_ntoa (path->nexthop), path->oi->ifp->name, inet_ntoa (path->nexthop), path->oi->ifp->name,
VTY_NEWLINE); VTY_NEWLINE);
} }
} }
} }
@ -7326,8 +7323,8 @@ ospf_config_write (struct vty *vty)
if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) && if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) &&
oi->params->passive_interface == OSPF_IF_PASSIVE) oi->params->passive_interface == OSPF_IF_PASSIVE)
vty_out (vty, " passive-interface %s %s%s", vty_out (vty, " passive-interface %s %s%s",
oi->ifp->name, oi->ifp->name,
inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE); inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
} }

View File

@ -355,10 +355,10 @@ ospf_zebra_add (struct prefix_ipv4 *p, struct ospf_route *or)
stream_write (s, (u_char *) & p->prefix, psize); stream_write (s, (u_char *) & p->prefix, psize);
/* Nexthop count. */ /* Nexthop count. */
stream_putc (s, or->path->count); stream_putc (s, or->paths->count);
/* Nexthop, ifindex, distance and metric information. */ /* Nexthop, ifindex, distance and metric information. */
for (node = listhead (or->path); node; nextnode (node)) for (node = listhead (or->paths); node; nextnode (node))
{ {
path = getdata (node); path = getdata (node);
@ -419,7 +419,7 @@ ospf_zebra_delete (struct prefix_ipv4 *p, struct ospf_route *or)
api.nexthop_num = 0; api.nexthop_num = 0;
SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP); SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP);
for (node = listhead (or->path); node; nextnode (node)) for (node = listhead (or->paths); node; nextnode (node))
{ {
path = getdata (node); path = getdata (node);

View File

@ -212,7 +212,7 @@ main (int argc, char **argv)
{ {
int opt; int opt;
opt = getopt_long (argc, argv, "df:hA:P:u:rv", longopts, 0); opt = getopt_long (argc, argv, "df:i:hA:P:u:rv", longopts, 0);
if (opt == EOF) if (opt == EOF)
break; break;

View File

@ -214,7 +214,7 @@ main (int argc, char **argv)
{ {
int opt; int opt;
opt = getopt_long (argc, argv, "dlf:hA:P:u:v", longopts, 0); opt = getopt_long (argc, argv, "dlf:i:hA:P:u:v", longopts, 0);
if (opt == EOF) if (opt == EOF)
break; break;

View File

@ -223,7 +223,7 @@ main (int argc, char **argv)
{ {
int opt; int opt;
opt = getopt_long (argc, argv, "bdklf:hA:P:ru:v", longopts, 0); opt = getopt_long (argc, argv, "bdklf:i:hA:P:ru:v", longopts, 0);
if (opt == EOF) if (opt == EOF)
break; break;