diff options
author | paul <paul> | 2003-08-10 02:51:22 +0000 |
---|---|---|
committer | paul <paul> | 2003-08-10 02:51:22 +0000 |
commit | 96735eeafe4713b60700915dd2fb6dcbd0f09c8f (patch) | |
tree | 49b7f583956e3d7ad91dcfa006d18e20f57efe15 | |
parent | 286e1e71538440ed0bef4576aded1745191490d3 (diff) |
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
-rw-r--r-- | bgpd/bgp_main.c | 2 | ||||
-rw-r--r-- | ospf6d/ospf6_main.c | 2 | ||||
-rw-r--r-- | ospfd/ospf_abr.c | 8 | ||||
-rw-r--r-- | ospfd/ospf_ase.c | 9 | ||||
-rw-r--r-- | ospfd/ospf_ia.c | 165 | ||||
-rw-r--r-- | ospfd/ospf_main.c | 2 | ||||
-rw-r--r-- | ospfd/ospf_route.c | 74 | ||||
-rw-r--r-- | ospfd/ospf_route.h | 14 | ||||
-rw-r--r-- | ospfd/ospf_spf.c | 2 | ||||
-rw-r--r-- | ospfd/ospf_vty.c | 69 | ||||
-rw-r--r-- | ospfd/ospf_zebra.c | 6 | ||||
-rw-r--r-- | ripd/rip_main.c | 2 | ||||
-rw-r--r-- | ripngd/ripng_main.c | 2 | ||||
-rw-r--r-- | zebra/main.c | 2 |
14 files changed, 169 insertions, 190 deletions
diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c index 933ca571..ce4503d9 100644 --- a/bgpd/bgp_main.c +++ b/bgpd/bgp_main.c @@ -217,7 +217,7 @@ main (int argc, char **argv) /* Command line argument treatment. */ 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) break; diff --git a/ospf6d/ospf6_main.c b/ospf6d/ospf6_main.c index 519cde77..1279b5ba 100644 --- a/ospf6d/ospf6_main.c +++ b/ospf6d/ospf6_main.c @@ -254,7 +254,7 @@ main (int argc, char *argv[], char *envp[]) /* Command line argument treatment. */ 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) break; diff --git a/ospfd/ospf_abr.c b/ospfd/ospf_abr.c index 92282514..46fb7aaf 100644 --- a/ospfd/ospf_abr.c +++ b/ospfd/ospf_abr.c @@ -779,15 +779,15 @@ ospf_abr_nexthops_belong_to_area (struct ospf_route *or, struct ospf_area *area) { 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; if (oi != NULL) - if (oi->area == area) - return 1; + if (oi->area == area) + return 1; } return 0; diff --git a/ospfd/ospf_ase.c b/ospfd/ospf_ase.c index 5605933b..db43e102 100644 --- a/ospfd/ospf_ase.c +++ b/ospfd/ospf_ase.c @@ -141,7 +141,7 @@ ospf_ase_complete_direct_routes (struct ospf_route *ro, struct in_addr nexthop) listnode node; 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->nexthop.s_addr == 0) 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->path = list_new (); new->u.ext.origin = lsa; new->u.ext.tag = ntohl (al->e[0].route_tag); new->u.ext.asbr = asbr_route; @@ -511,7 +510,7 @@ ospf_ase_calculate_route (struct ospf *ospf, struct ospf_lsa * lsa) else { 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) 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; } - if (or->path->count != newor->path->count) + if (or->paths->count != newor->paths->count) return 0; /* 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)) { op = getdata (n1); diff --git a/ospfd/ospf_ia.c b/ospfd/ospf_ia.c index 32c8d86b..e4c14686 100644 --- a/ospfd/ospf_ia.c +++ b/ospfd/ospf_ia.c @@ -71,8 +71,9 @@ ospf_find_abr_route (struct route_table *rtrs, } void -ospf_ia_network_route (struct route_table *rt, struct prefix_ipv4 *p, - struct ospf_route *new_or, struct ospf_route *abr_or) +ospf_ia_network_route (struct ospf *ospf, struct route_table *rt, + struct prefix_ipv4 *p, struct ospf_route *new_or, + struct ospf_route *abr_or) { struct route_node *rn1; 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(): " "Found a route to the same network"); /* 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. */ 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. */ route_lock_node (rn1); - ospf_route_copy_nexthops (or, abr_or->path); + ospf_route_copy_nexthops (or, abr_or->paths); route_unlock_node (rn1); /* 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 -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 route_node *rn; struct ospf_route *or = NULL; + struct route_node *rn; int ret; if (IS_DEBUG_OSPF_EVENT) zlog_info ("ospf_ia_router_route(): considering %s/%d", inet_ntoa (p->prefix), p->prefixlen); /* 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) /* This is a new route */ @@ -146,11 +148,11 @@ ospf_ia_router_route (struct route_table *rt, struct prefix_ipv4 *p, else { 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); /* This is an additional route */ 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) @@ -159,7 +161,7 @@ ospf_ia_router_route (struct route_table *rt, struct prefix_ipv4 *p, zlog_info ("ospf_ia_router_route(): " "a route to the same ABR through the same area exists"); /* 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); 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) 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); 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) 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 -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_route *abr_or, *new_or; struct summary_lsa *sl; struct prefix_ipv4 p, abr; u_int32_t metric; - struct ia_args *args; - if (l == NULL) + if (lsa == NULL) return 0; - args = (struct ia_args *) v; - sl = (struct summary_lsa *) l->data; + sl = (struct summary_lsa *) lsa->data; if (IS_DEBUG_OSPF_EVENT) 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) return 0; - if (IS_LSA_MAXAGE (l)) + if (IS_LSA_MAXAGE (lsa)) return 0; - if (ospf_lsa_is_self_originated (l)) + if (ospf_lsa_is_self_originated (area->ospf, lsa)) return 0; p.family = AF_INET; @@ -242,12 +237,12 @@ process_summary_lsa (struct ospf_lsa *l, void *v, int i) apply_mask_ipv4 (&p); 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)) return 0; - if (ospf_top->abr_type != OSPF_ABR_STAND && - args->area->external_routing != OSPF_AREA_DEFAULT && + if (ospf->abr_type != OSPF_ABR_STAND && + area->external_routing != OSPF_AREA_DEFAULT && p.prefix.s_addr == OSPF_DEFAULT_DESTINATION && p.prefixlen == 0) 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; 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) 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.origin = (struct lsa_header *) sl; 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 - new_or->u.std.external_routing = args->area->external_routing; + new_or->u.std.external_routing = area->external_routing; #endif /* HAVE_NSSA */ new_or->path_type = OSPF_PATH_INTER_AREA; 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 { new_or->type = OSPF_DESTINATION_ROUTER; 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; } void -ospf_examine_summaries (struct ospf_area * area, +ospf_examine_summaries (struct ospf_area *area, struct route_table *lsdb_rt, struct route_table *rt, struct route_table *rtrs) { - struct ia_args args = {rt, rtrs, area}; - foreach_lsa (lsdb_rt, &args, 0, process_summary_lsa); + struct ospf_lsa *lsa; + struct route_node *rn; + + LSDB_LOOP (lsdb_rt, rn, lsa) + process_summary_lsa (area, rt, rtrs, lsa); } int @@ -305,7 +303,8 @@ ospf_area_is_transit (struct ospf_area *area) } 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 summary_lsa *lsa, struct prefix_ipv4 *p, @@ -336,7 +335,7 @@ ospf_update_network_route (struct route_table *rt, 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 backbone paths */ if (IS_DEBUG_OSPF_EVENT) @@ -375,7 +374,7 @@ ospf_update_network_route (struct route_table *rt, return; } - if (ospf_top->abr_type == OSPF_ABR_SHORTCUT) + if (ospf->abr_type == OSPF_ABR_SHORTCUT) { if (or->path_type == OSPF_PATH_INTRA_AREA && !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) zlog_info ("ospf_update_network_route(): " "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) @@ -417,10 +416,10 @@ ospf_update_network_route (struct route_table *rt, if (IS_DEBUG_OSPF_EVENT) zlog_info ("ospf_update_network_route(): " "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; - 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)) { or->path_type = OSPF_PATH_INTER_AREA; @@ -437,7 +436,8 @@ ospf_update_network_route (struct route_table *rt, } 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 prefix_ipv4 *p, struct ospf_area *area) @@ -465,17 +465,17 @@ ospf_update_router_route (struct route_table *rtrs, /* First try to find a backbone path, because standard ABR can update only BB-associated paths */ - if ((ospf_top->backbone == NULL) && - (ospf_top->abr_type != OSPF_ABR_SHORTCUT)) + if ((ospf->backbone == NULL) && + (ospf->abr_type != OSPF_ABR_SHORTCUT)) /* no BB area, not Shortcut ABR, exiting */ 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 (ospf_top->abr_type != OSPF_ABR_SHORTCUT) + if (ospf->abr_type != OSPF_ABR_SHORTCUT) /* route to ASBR through the BB not found the router is not Shortcut ABR, exiting */ @@ -500,7 +500,7 @@ ospf_update_router_route (struct route_table *rtrs, #endif /* HAVE_NSSA */ new_or->path_type = OSPF_PATH_INTER_AREA; 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; } @@ -523,11 +523,11 @@ ospf_update_router_route (struct route_table *rtrs, return; 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) { - ospf_route_subst_nexthops (or, abr_or->path); + ospf_route_subst_nexthops (or, abr_or->paths); or->cost = cost; /* 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 -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 prefix_ipv4 p; u_int32_t metric; - struct ia_args *args; - if (l == NULL) + if (lsa == NULL) return 0; - args = (struct ia_args *) v; - sl = (struct summary_lsa *) l->data; + sl = (struct summary_lsa *) lsa->data; if (IS_DEBUG_OSPF_EVENT) zlog_info ("process_transit_summaries(): LS ID: %s", - inet_ntoa (l->data->id)); + inet_ntoa (lsa->data->id)); metric = GET_METRIC (sl->metric); if (metric == OSPF_LS_INFINITY) @@ -562,14 +562,14 @@ process_transit_summary_lsa (struct ospf_lsa *l, void *v, int i) return 0; } - if (IS_LSA_MAXAGE (l)) + if (IS_LSA_MAXAGE (lsa)) { if (IS_DEBUG_OSPF_EVENT) zlog_info ("process_transit_summaries(): This LSA is too old"); return 0; } - if (ospf_lsa_is_self_originated (l)) + if (ospf_lsa_is_self_originated (area->ospf, lsa)) { if (IS_DEBUG_OSPF_EVENT) 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); 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 - ospf_update_router_route (args->rtrs, sl, &p, args->area); + ospf_update_router_route (ospf, rtrs, sl, &p, area); return 0; } void ospf_examine_transit_summaries (struct ospf_area *area, - /* struct ospf_lsdb *lsdb, */ struct route_table *lsdb_rt, struct route_table *rt, 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); */ - foreach_lsa (lsdb_rt, &args, 0, process_transit_summary_lsa); + LSDB_LOOP (lsdb_rt, rn, lsa) + process_transit_summary_lsa (area, rt, rtrs, lsa); } void -ospf_ia_routing (struct route_table *rt, +ospf_ia_routing (struct ospf *ospf, + struct route_table *rt, struct route_table *rtrs) { struct ospf_area * area; @@ -616,18 +617,18 @@ ospf_ia_routing (struct route_table *rt, if (IS_DEBUG_OSPF_EVENT) zlog_info ("ospf_ia_routing():start"); - if (OSPF_IS_ABR) + if (IS_OSPF_ABR (ospf)) { listnode node; struct ospf_area *area; - switch (ospf_top->abr_type) + switch (ospf->abr_type) { case OSPF_ABR_STAND: if (IS_DEBUG_OSPF_EVENT) zlog_info ("ospf_ia_routing():Standard ABR"); - if ((area = ospf_top->backbone)) + if ((area = ospf->backbone)) { listnode node; @@ -639,9 +640,9 @@ ospf_ia_routing (struct route_table *rt, 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 != ospf_top->backbone) + if (area != ospf->backbone) if (ospf_area_is_transit (area)) OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL (area, rt, rtrs); } @@ -653,10 +654,10 @@ ospf_ia_routing (struct route_table *rt, case OSPF_ABR_CISCO: if (IS_DEBUG_OSPF_EVENT) 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 (area && ospf_act_bb_connection ()) + if (area && ospf_act_bb_connection (ospf)) { if (IS_DEBUG_OSPF_EVENT) { @@ -666,9 +667,9 @@ ospf_ia_routing (struct route_table *rt, 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 != ospf_top->backbone) + if (area != ospf->backbone) if (ospf_area_is_transit (area)) OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL (area, rt, rtrs); } @@ -677,7 +678,7 @@ ospf_ia_routing (struct route_table *rt, if (IS_DEBUG_OSPF_EVENT) zlog_info ("ospf_ia_routing(): " "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) OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs); } @@ -685,10 +686,10 @@ ospf_ia_routing (struct route_table *rt, case OSPF_ABR_SHORTCUT: if (IS_DEBUG_OSPF_EVENT) 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 (area && ospf_act_bb_connection ()) + if (area && ospf_act_bb_connection (ospf)) { if (IS_DEBUG_OSPF_EVENT) { @@ -698,12 +699,12 @@ ospf_ia_routing (struct route_table *rt, 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 != ospf_top->backbone) + if (area != ospf->backbone) if (ospf_area_is_transit (area) || ((area->shortcut_configured != OSPF_SHORTCUT_DISABLE) && - ((ospf_top->backbone == NULL) || + ((ospf->backbone == NULL) || ((area->shortcut_configured == OSPF_SHORTCUT_ENABLE) && area->shortcut_capability)))) OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL (area, rt, rtrs); @@ -719,7 +720,7 @@ ospf_ia_routing (struct route_table *rt, if (IS_DEBUG_OSPF_EVENT) 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) OSPF_EXAMINE_SUMMARIES_ALL (area, rt, rtrs); } diff --git a/ospfd/ospf_main.c b/ospfd/ospf_main.c index 236d8c28..211aa78a 100644 --- a/ospfd/ospf_main.c +++ b/ospfd/ospf_main.c @@ -232,7 +232,7 @@ main (int argc, char **argv) { 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) break; diff --git a/ospfd/ospf_route.c b/ospfd/ospf_route.c index 0de415ee..e1e1e390 100644 --- a/ospfd/ospf_route.c +++ b/ospfd/ospf_route.c @@ -49,6 +49,8 @@ ospf_route_new () new->ctime = time (NULL); new->mtime = new->ctime; + new->paths = list_new (); + new->paths->del = (void (*) (void *))ospf_path_free; return new; } @@ -56,15 +58,8 @@ ospf_route_new () void ospf_route_free (struct ospf_route *or) { - listnode node; - - if (or->path) - { - for (node = listhead (or->path); node; nextnode (node)) - ospf_path_free (node->data); - - list_delete (or->path); - } + if (or->paths) + list_delete (or->paths); 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->path->count != newor->path->count) + if (or->paths->count != newor->paths->count) return 0; /* 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)) { op = getdata (n1); @@ -310,15 +305,14 @@ ospf_intra_route_add (struct route_table *rt, struct vertex *v, if (v->type == OSPF_VERTEX_NETWORK) { or->type = OSPF_DESTINATION_NETWORK; - or->path = list_new (); - for (nnode = listhead (v->nexthop); nnode; nextnode (nnode)) - { - nexthop = getdata (nnode); - path = ospf_path_new (); - path->nexthop = nexthop->router; - listnode_add (or->path, path); - } + LIST_LOOP (v->nexthop, nexthop, nnode) + { + nexthop = getdata (nnode); + path = ospf_path_new (); + path->nexthop = nexthop->router; + listnode_add (or->paths, path); + } } else 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; - list_delete (cur_or->path); - cur_or->path = NULL; + list_delete (cur_or->paths); + cur_or->paths = NULL; 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->type = OSPF_DESTINATION_NETWORK; or->u.std.origin = (struct lsa_header *) lsa; - or->path = list_new (); /* Nexthop is depend on connection type. */ 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->nexthop.s_addr = 0; path->oi = oi; - listnode_add (or->path, path); + listnode_add (or->paths, path); } else { @@ -691,7 +684,7 @@ ospf_route_table_dump (struct route_table *rt) BUFSIZ), ospf_path_type_str[or->path_type], or->cost); - for (pnode = listhead (or->path); pnode; nextnode (pnode)) + for (pnode = listhead (or->paths); pnode; nextnode (pnode)) { path = getdata (pnode); 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 vertex_nexthop *nexthop; - if (to->path == NULL) - to->path = list_new (); + assert (to->paths); 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 (! ospf_path_exist (to->path, nexthop->router, nexthop->oi)) + if (! ospf_path_exist (to->paths, nexthop->router, nexthop->oi)) { path = ospf_path_new (); path->nexthop = nexthop->router; 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; - if (to->path == NULL) - to->path = list_new (); + assert (to->paths); for (node = listhead (from); node; nextnode (node)) /* The same routes are just discarded. */ - if (!ospf_path_lookup (to->path, node->data)) - listnode_add (to->path, ospf_path_dup (node->data)); + if (!ospf_path_lookup (to->paths, node->data)) + listnode_add (to->paths, ospf_path_dup (node->data)); } void ospf_route_subst_nexthops (struct ospf_route *to, list from) { - listnode node; - struct ospf_path *op; - - for (node = listhead (to->path); node; nextnode (node)) - if ((op = getdata (node)) != NULL) - { - ospf_path_free (op); - node->data = NULL; - } - list_delete_all_node (to->path); + list_delete_all_node (to->paths); 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); 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; 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); - ospf_route_copy_nexthops (new_or, over->path); + ospf_route_copy_nexthops (new_or, over->paths); if (rn->info) { @@ -937,7 +919,7 @@ ospf_prune_unreachable_networks (struct route_table *rt) if (rn->info != NULL) { or = rn->info; - if (listcount (or->path) == 0) + if (listcount (or->paths) == 0) { if (IS_DEBUG_OSPF_EVENT) zlog_info ("Pruning route to %s/%d", @@ -974,7 +956,7 @@ ospf_prune_unreachable_routers (struct route_table *rtrs) or = getdata (node); - if (listcount (or->path) == 0) + if (listcount (or->paths) == 0) { if (IS_DEBUG_OSPF_EVENT) { diff --git a/ospfd/ospf_route.h b/ospfd/ospf_route.h index 81f59c48..8d05be22 100644 --- a/ospfd/ospf_route.h +++ b/ospfd/ospf_route.h @@ -110,7 +110,7 @@ struct ospf_route u_char path_type; /* List of Paths. */ - list path; + list paths; /* Link State Cost. */ u_int32_t cost; /* i.e. metric. */ @@ -124,14 +124,14 @@ struct ospf_route }; 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_route *ospf_route_new (); -void ospf_route_free (struct ospf_route *or); -void ospf_route_delete (struct route_table *rt); -void ospf_route_table_free (struct route_table *rt); +void ospf_route_free (struct ospf_route *); +void ospf_route_delete (struct route_table *); +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_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 *, 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_from_vertex (struct ospf_route *, struct vertex * ); diff --git a/ospfd/ospf_spf.c b/ospfd/ospf_spf.c index 9e6690ae..8399e18e 100644 --- a/ospfd/ospf_spf.c +++ b/ospfd/ospf_spf.c @@ -898,7 +898,7 @@ ospf_rtrs_print (struct route_table *rtrs) break; } - for (pnode = listhead (or->path); pnode; nextnode (pnode)) + for (pnode = listhead (or->paths); pnode; nextnode (pnode)) { path = getdata (pnode); if (path->nexthop.s_addr == 0) diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index c22aa453..5e2c3a2e 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -6513,20 +6513,19 @@ show_ip_ospf_route_network (struct vty *vty, struct route_table *rt) } if (or->type == OSPF_DESTINATION_NETWORK) - for (pnode = listhead (or->path); pnode; nextnode (pnode)) - { - path = getdata (pnode); - if (path->oi != NULL) - { - if (path->nexthop.s_addr == 0) - vty_out (vty, "%24s directly attached to %s%s", - "", path->oi->ifp->name, VTY_NEWLINE); - else - vty_out (vty, "%24s via %s, %s%s", "", - inet_ntoa (path->nexthop), path->oi->ifp->name, - VTY_NEWLINE); - } - } + LIST_LOOP (or->paths, path, pnode) + { + if (path->oi != NULL) + { + if (path->nexthop.s_addr == 0) + vty_out (vty, "%24s directly attached to %s%s", + "", path->oi->ifp->name, VTY_NEWLINE); + else + vty_out (vty, "%24s via %s, %s%s", "", + inet_ntoa (path->nexthop), path->oi->ifp->name, + VTY_NEWLINE); + } + } } vty_out (vty, "%s", VTY_NEWLINE); } @@ -6563,18 +6562,17 @@ show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs) (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""), (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""), VTY_NEWLINE); - - for (pn = listhead (or->path); pn; nextnode (pn)) - { - path = getdata (pn); - if (path->nexthop.s_addr == 0) - vty_out (vty, "%24s directly attached to %s%s", - "", path->oi->ifp->name, VTY_NEWLINE); - else - vty_out (vty, "%24s via %s, %s%s", "", - inet_ntoa (path->nexthop), path->oi->ifp->name, - VTY_NEWLINE); - } + + LIST_LOOP (or->paths, path, pn) + { + if (path->nexthop.s_addr == 0) + vty_out (vty, "%24s directly attached to %s%s", + "", path->oi->ifp->name, VTY_NEWLINE); + else + vty_out (vty, "%24s via %s, %s%s", "", + inet_ntoa (path->nexthop), path->oi->ifp->name, + 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; } - for (pnode = listhead (er->path); pnode; nextnode (pnode)) + LIST_LOOP (er->paths, path, pnode) { - path = getdata (pnode); if (path->oi != NULL) { if (path->nexthop.s_addr == 0) - vty_out (vty, "%24s directly attached to %s%s", - "", path->oi->ifp->name, VTY_NEWLINE); - else - vty_out (vty, "%24s via %s, %s%s", "", - inet_ntoa (path->nexthop), path->oi->ifp->name, - VTY_NEWLINE); + vty_out (vty, "%24s directly attached to %s%s", + "", path->oi->ifp->name, VTY_NEWLINE); + else + vty_out (vty, "%24s via %s, %s%s", "", + inet_ntoa (path->nexthop), path->oi->ifp->name, + VTY_NEWLINE); } } } @@ -7326,8 +7323,8 @@ ospf_config_write (struct vty *vty) if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) && oi->params->passive_interface == OSPF_IF_PASSIVE) - vty_out (vty, " passive-interface %s %s%s", - oi->ifp->name, + vty_out (vty, " passive-interface %s %s%s", + oi->ifp->name, inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE); } diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index a17f893d..3594b17c 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -355,10 +355,10 @@ ospf_zebra_add (struct prefix_ipv4 *p, struct ospf_route *or) stream_write (s, (u_char *) & p->prefix, psize); /* Nexthop count. */ - stream_putc (s, or->path->count); + stream_putc (s, or->paths->count); /* 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); @@ -419,7 +419,7 @@ ospf_zebra_delete (struct prefix_ipv4 *p, struct ospf_route *or) api.nexthop_num = 0; 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); diff --git a/ripd/rip_main.c b/ripd/rip_main.c index 84ea75c5..d5713208 100644 --- a/ripd/rip_main.c +++ b/ripd/rip_main.c @@ -212,7 +212,7 @@ main (int argc, char **argv) { 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) break; diff --git a/ripngd/ripng_main.c b/ripngd/ripng_main.c index 5fb04448..6c335252 100644 --- a/ripngd/ripng_main.c +++ b/ripngd/ripng_main.c @@ -214,7 +214,7 @@ main (int argc, char **argv) { 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) break; diff --git a/zebra/main.c b/zebra/main.c index c47b83e3..c9a19eda 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -223,7 +223,7 @@ main (int argc, char **argv) { 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) break; |