From cb4b88452e04a0102fedff4f01a2246f5e70dea9 Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Mon, 15 May 2006 10:39:30 +0000 Subject: [ospf6d] Import GNU Zebra CVSps#3559: Fix inter-area as-ext bug, cleanup debug 2005-10-06 Yasuhiro Ohara * ospf6_asbr.c: fix bug of calculating AS-External routes in other areas. Add debugging function for border-router calculation. * ospf6d.h: version 0.9.7p --- ospf6d/ospf6_intra.c | 233 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 186 insertions(+), 47 deletions(-) (limited to 'ospf6d/ospf6_intra.c') diff --git a/ospf6d/ospf6_intra.c b/ospf6d/ospf6_intra.c index 21693dbc..0be88f01 100644 --- a/ospf6d/ospf6_intra.c +++ b/ospf6d/ospf6_intra.c @@ -47,6 +47,11 @@ #include "ospf6_flood.h" #include "ospf6d.h" + +unsigned char conf_debug_ospf6_brouter = 0; +u_int32_t conf_debug_ospf6_brouter_specific_router_id; +u_int32_t conf_debug_ospf6_brouter_specific_area_id; + /******************************/ /* RFC2740 3.4.3.1 Router-LSA */ /******************************/ @@ -1236,91 +1241,102 @@ ospf6_intra_route_calculation (struct ospf6_area *oa) void ospf6_intra_brouter_calculation (struct ospf6_area *oa) { - struct ospf6_route *lsentry, *copy; + struct ospf6_route *brouter, *copy; void (*hook_add) (struct ospf6_route *) = NULL; void (*hook_remove) (struct ospf6_route *) = NULL; - char buf[16]; - - if (IS_OSPF6_DEBUG_ROUTE (INTRA)) - zlog_debug ("Border-router calculation for area %s", oa->name); - + u_int32_t brouter_id; + char brouter_name[16]; + + if (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ID (oa->area_id)) + zlog_info ("border-router calculation for area %s", oa->name); + hook_add = oa->ospf6->brouter_table->hook_add; hook_remove = oa->ospf6->brouter_table->hook_remove; oa->ospf6->brouter_table->hook_add = NULL; oa->ospf6->brouter_table->hook_remove = NULL; /* withdraw the previous router entries for the area */ - for (lsentry = ospf6_route_head (oa->ospf6->brouter_table); lsentry; - lsentry = ospf6_route_next (lsentry)) + for (brouter = ospf6_route_head (oa->ospf6->brouter_table); brouter; + brouter = ospf6_route_next (brouter)) { - if (lsentry->path.area_id != oa->area_id) + if (brouter->path.area_id != oa->area_id) continue; - lsentry->flag = OSPF6_ROUTE_REMOVE; + brouter->flag = OSPF6_ROUTE_REMOVE; } - for (lsentry = ospf6_route_head (oa->spf_table); lsentry; - lsentry = ospf6_route_next (lsentry)) + for (brouter = ospf6_route_head (oa->spf_table); brouter; + brouter = ospf6_route_next (brouter)) { - if (lsentry->type != OSPF6_DEST_TYPE_LINKSTATE) + if (brouter->type != OSPF6_DEST_TYPE_LINKSTATE) continue; - if (ospf6_linkstate_prefix_id (&lsentry->prefix) != htonl (0)) + if (ospf6_linkstate_prefix_id (&brouter->prefix) != htonl (0)) continue; - if (! CHECK_FLAG (lsentry->path.router_bits, OSPF6_ROUTER_BIT_E) && - ! CHECK_FLAG (lsentry->path.router_bits, OSPF6_ROUTER_BIT_B)) + if (! CHECK_FLAG (brouter->path.router_bits, OSPF6_ROUTER_BIT_E) && + ! CHECK_FLAG (brouter->path.router_bits, OSPF6_ROUTER_BIT_B)) continue; - copy = ospf6_route_copy (lsentry); + copy = ospf6_route_copy (brouter); copy->type = OSPF6_DEST_TYPE_ROUTER; copy->path.area_id = oa->area_id; ospf6_route_add (copy, oa->ospf6->brouter_table); - - if (IS_OSPF6_DEBUG_ROUTE (INTRA)) - { - inet_ntop (AF_INET, &ADV_ROUTER_IN_PREFIX (©->prefix), - buf, sizeof (buf)); - zlog_debug ("Re-install router entry %s", buf); - } } oa->ospf6->brouter_table->hook_add = hook_add; oa->ospf6->brouter_table->hook_remove = hook_remove; - for (lsentry = ospf6_route_head (oa->ospf6->brouter_table); lsentry; - lsentry = ospf6_route_next (lsentry)) + for (brouter = ospf6_route_head (oa->ospf6->brouter_table); brouter; + brouter = ospf6_route_next (brouter)) { - if (lsentry->path.area_id != oa->area_id) + brouter_id = ADV_ROUTER_IN_PREFIX (&brouter->prefix); + inet_ntop (AF_INET, &brouter_id, brouter_name, sizeof (brouter_name)); + + if (brouter->path.area_id != oa->area_id) continue; - if (CHECK_FLAG (lsentry->flag, OSPF6_ROUTE_WAS_REMOVED)) + if (CHECK_FLAG (brouter->flag, OSPF6_ROUTE_WAS_REMOVED)) continue; - if (CHECK_FLAG (lsentry->flag, OSPF6_ROUTE_REMOVE) && - CHECK_FLAG (lsentry->flag, OSPF6_ROUTE_ADD)) + if (CHECK_FLAG (brouter->flag, OSPF6_ROUTE_REMOVE) && + CHECK_FLAG (brouter->flag, OSPF6_ROUTE_ADD)) { - UNSET_FLAG (lsentry->flag, OSPF6_ROUTE_REMOVE); - UNSET_FLAG (lsentry->flag, OSPF6_ROUTE_ADD); + UNSET_FLAG (brouter->flag, OSPF6_ROUTE_REMOVE); + UNSET_FLAG (brouter->flag, OSPF6_ROUTE_ADD); } - if (CHECK_FLAG (lsentry->flag, OSPF6_ROUTE_REMOVE)) - ospf6_route_remove (lsentry, oa->ospf6->brouter_table); - else if (CHECK_FLAG (lsentry->flag, OSPF6_ROUTE_ADD) || - CHECK_FLAG (lsentry->flag, OSPF6_ROUTE_CHANGE)) + if (CHECK_FLAG (brouter->flag, OSPF6_ROUTE_REMOVE)) { - if (IS_OSPF6_DEBUG_ROUTE (INTRA)) - { - inet_ntop (AF_INET, &ADV_ROUTER_IN_PREFIX (&lsentry->prefix), - buf, sizeof (buf)); - zlog_debug ("Call hook for router entry %s", buf); - } + if (IS_OSPF6_DEBUG_BROUTER || + IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ID (brouter_id) || + IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ID (oa->area_id)) + zlog_info ("brouter %s disappears via area %s", + brouter_name, oa->name); + ospf6_route_remove (brouter, oa->ospf6->brouter_table); + } + else if (CHECK_FLAG (brouter->flag, OSPF6_ROUTE_ADD) || + CHECK_FLAG (brouter->flag, OSPF6_ROUTE_CHANGE)) + { + if (IS_OSPF6_DEBUG_BROUTER || + IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ID (brouter_id) || + IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ID (oa->area_id)) + zlog_info ("brouter %s appears via area %s", + brouter_name, oa->name); + /* newly added */ if (hook_add) - (*hook_add) (lsentry); + (*hook_add) (brouter); + } + else + { + if (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ID (brouter_id) || + IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ID (oa->area_id)) + zlog_info ("brouter %s still exists via area %s", + brouter_name, oa->name); } - lsentry->flag = 0; + brouter->flag = 0; } - if (IS_OSPF6_DEBUG_ROUTE (INTRA)) - zlog_debug ("Border-router calculation for area %s: Done", oa->name); + if (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ID (oa->area_id)) + zlog_info ("border-router calculation for area %s: done", oa->name); } struct ospf6_lsa_handler router_handler = @@ -1352,7 +1368,7 @@ struct ospf6_lsa_handler intra_prefix_handler = }; void -ospf6_intra_init () +ospf6_intra_init (void) { ospf6_install_lsa_handler (&router_handler); ospf6_install_lsa_handler (&network_handler); @@ -1360,4 +1376,127 @@ ospf6_intra_init () ospf6_install_lsa_handler (&intra_prefix_handler); } +DEFUN (debug_ospf6_brouter, + debug_ospf6_brouter_cmd, + "debug ospf6 border-routers", + DEBUG_STR + OSPF6_STR + "Debug border router\n" + ) +{ + OSPF6_DEBUG_BROUTER_ON (); + return CMD_SUCCESS; +} + +DEFUN (no_debug_ospf6_brouter, + no_debug_ospf6_brouter_cmd, + "no debug ospf6 border-routers", + NO_STR + DEBUG_STR + OSPF6_STR + "Debug border router\n" + ) +{ + OSPF6_DEBUG_BROUTER_OFF (); + return CMD_SUCCESS; +} + +DEFUN (debug_ospf6_brouter_router, + debug_ospf6_brouter_router_cmd, + "debug ospf6 border-routers router-id A.B.C.D", + DEBUG_STR + OSPF6_STR + "Debug border router\n" + "Debug specific border router\n" + "Specify border-router's router-id\n" + ) +{ + u_int32_t router_id; + inet_pton (AF_INET, argv[0], &router_id); + OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ON (router_id); + return CMD_SUCCESS; +} + +DEFUN (no_debug_ospf6_brouter_router, + no_debug_ospf6_brouter_router_cmd, + "no debug ospf6 border-routers router-id", + NO_STR + DEBUG_STR + OSPF6_STR + "Debug border router\n" + "Debug specific border router\n" + ) +{ + OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_OFF (); + return CMD_SUCCESS; +} + +DEFUN (debug_ospf6_brouter_area, + debug_ospf6_brouter_area_cmd, + "debug ospf6 border-routers area-id A.B.C.D", + DEBUG_STR + OSPF6_STR + "Debug border router\n" + "Debug border routers in specific Area\n" + "Specify Area-ID\n" + ) +{ + u_int32_t area_id; + inet_pton (AF_INET, argv[0], &area_id); + OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ON (area_id); + return CMD_SUCCESS; +} + +DEFUN (no_debug_ospf6_brouter_area, + no_debug_ospf6_brouter_area_cmd, + "no debug ospf6 border-routers area-id", + NO_STR + DEBUG_STR + OSPF6_STR + "Debug border router\n" + "Debug border routers in specific Area\n" + ) +{ + OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_OFF (); + return CMD_SUCCESS; +} + +int +config_write_ospf6_debug_brouter (struct vty *vty) +{ + char buf[16]; + if (IS_OSPF6_DEBUG_BROUTER) + vty_out (vty, "debug ospf6 border-routers%s", VNL); + if (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER) + { + inet_ntop (AF_INET, &conf_debug_ospf6_brouter_specific_router_id, + buf, sizeof (buf)); + vty_out (vty, "debug ospf6 border-routers router-id %s%s", buf, VNL); + } + if (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA) + { + inet_ntop (AF_INET, &conf_debug_ospf6_brouter_specific_area_id, + buf, sizeof (buf)); + vty_out (vty, "debug ospf6 border-routers area-id %s%s", buf, VNL); + } + return 0; +} + +void +install_element_ospf6_debug_brouter (void) +{ + install_element (ENABLE_NODE, &debug_ospf6_brouter_cmd); + install_element (ENABLE_NODE, &debug_ospf6_brouter_router_cmd); + install_element (ENABLE_NODE, &debug_ospf6_brouter_area_cmd); + install_element (ENABLE_NODE, &no_debug_ospf6_brouter_cmd); + install_element (ENABLE_NODE, &no_debug_ospf6_brouter_router_cmd); + install_element (ENABLE_NODE, &no_debug_ospf6_brouter_area_cmd); + install_element (CONFIG_NODE, &debug_ospf6_brouter_cmd); + install_element (CONFIG_NODE, &debug_ospf6_brouter_router_cmd); + install_element (CONFIG_NODE, &debug_ospf6_brouter_area_cmd); + install_element (CONFIG_NODE, &no_debug_ospf6_brouter_cmd); + install_element (CONFIG_NODE, &no_debug_ospf6_brouter_router_cmd); + install_element (CONFIG_NODE, &no_debug_ospf6_brouter_area_cmd); +} + -- cgit v1.2.3 From cf1ce250d20003ae94c835e73e95e7442d7a5b53 Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Mon, 15 May 2006 10:46:07 +0000 Subject: [ospf6d] GNU Zebra #3562: ABR Crash fix, memory fixes, route table debugs 2006-02-22 Yasuhiro Ohara * valgrind check and memory fix * route table identification string added * ospf6d.h: version 0.9.7q --- ospf6d/ospf6_intra.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 76 insertions(+), 2 deletions(-) (limited to 'ospf6d/ospf6_intra.c') diff --git a/ospf6d/ospf6_intra.c b/ospf6d/ospf6_intra.c index 0be88f01..ffd9c725 100644 --- a/ospf6d/ospf6_intra.c +++ b/ospf6d/ospf6_intra.c @@ -721,7 +721,7 @@ ospf6_intra_prefix_lsa_originate_stub (struct thread *thread) intra_prefix_lsa->ref_id = htonl (0); intra_prefix_lsa->ref_adv_router = oa->ospf6->router_id; - route_advertise = ospf6_route_table_create (); + route_advertise = ospf6_route_table_create (0, 0); for (ALL_LIST_ELEMENTS_RO (oa->if_list, i, oi)) { @@ -900,7 +900,7 @@ ospf6_intra_prefix_lsa_originate_transit (struct thread *thread) } /* connected prefix to advertise */ - route_advertise = ospf6_route_table_create (); + route_advertise = ospf6_route_table_create (0, 0); type = ntohs (OSPF6_LSTYPE_LINK); for (lsa = ospf6_lsdb_type_head (type, oi->lsdb); lsa; @@ -1238,6 +1238,58 @@ ospf6_intra_route_calculation (struct ospf6_area *oa) zlog_debug ("Re-examin intra-routes for area %s: Done", oa->name); } +void +ospf6_brouter_debug_print (struct ospf6_route *brouter) +{ + u_int32_t brouter_id; + char brouter_name[16]; + char area_name[16]; + char destination[64]; + char installed[16], changed[16]; + struct timeval now, res; + char id[16], adv_router[16]; + char capa[16], options[16]; + + brouter_id = ADV_ROUTER_IN_PREFIX (&brouter->prefix); + inet_ntop (AF_INET, &brouter_id, brouter_name, sizeof (brouter_name)); + inet_ntop (AF_INET, &brouter->path.area_id, area_name, sizeof (area_name)); + ospf6_linkstate_prefix2str (&brouter->prefix, destination, + sizeof (destination)); + + gettimeofday (&now, (struct timezone *) NULL); + timersub (&now, &brouter->installed, &res); + timerstring (&res, installed, sizeof (installed)); + + gettimeofday (&now, (struct timezone *) NULL); + timersub (&now, &brouter->changed, &res); + timerstring (&res, changed, sizeof (changed)); + + inet_ntop (AF_INET, &brouter->path.origin.id, id, sizeof (id)); + inet_ntop (AF_INET, &brouter->path.origin.adv_router, adv_router, + sizeof (adv_router)); + + ospf6_options_printbuf (brouter->path.options, options, sizeof (options)); + ospf6_capability_printbuf (brouter->path.router_bits, capa, sizeof (capa)); + + zlog_info ("Brouter: %s via area %s", brouter_name, area_name); + zlog_info (" memory: prev: %p this: %p next: %p parent rnode: %p", + brouter->prev, brouter, brouter->next, brouter->rnode); + zlog_info (" type: %d prefix: %s installed: %s changed: %s", + brouter->type, destination, installed, changed); + zlog_info (" lock: %d flags: %s%s%s%s", brouter->lock, + (CHECK_FLAG (brouter->flag, OSPF6_ROUTE_BEST) ? "B" : "-"), + (CHECK_FLAG (brouter->flag, OSPF6_ROUTE_ADD) ? "A" : "-"), + (CHECK_FLAG (brouter->flag, OSPF6_ROUTE_REMOVE) ? "R" : "-"), + (CHECK_FLAG (brouter->flag, OSPF6_ROUTE_CHANGE) ? "C" : "-")); + zlog_info (" path type: %s ls-origin %s id: %s adv-router %s", + OSPF6_PATH_TYPE_NAME (brouter->path.type), + ospf6_lstype_name (brouter->path.origin.type), + id, adv_router); + zlog_info (" options: %s router-bits: %s metric-type: %d metric: %d/%d", + options, capa, brouter->path.metric_type, + brouter->path.cost, brouter->path.cost_e2); +} + void ospf6_intra_brouter_calculation (struct ospf6_area *oa) { @@ -1259,14 +1311,27 @@ ospf6_intra_brouter_calculation (struct ospf6_area *oa) for (brouter = ospf6_route_head (oa->ospf6->brouter_table); brouter; brouter = ospf6_route_next (brouter)) { + brouter_id = ADV_ROUTER_IN_PREFIX (&brouter->prefix); + inet_ntop (AF_INET, &brouter_id, brouter_name, sizeof (brouter_name)); if (brouter->path.area_id != oa->area_id) continue; brouter->flag = OSPF6_ROUTE_REMOVE; + + if (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ID (brouter_id) || + IS_OSPF6_DEBUG_ROUTE (MEMORY)) + { + zlog_info ("%p: mark as removing: area %s brouter %s", + brouter, oa->name, brouter_name); + ospf6_brouter_debug_print (brouter); + } } for (brouter = ospf6_route_head (oa->spf_table); brouter; brouter = ospf6_route_next (brouter)) { + brouter_id = ADV_ROUTER_IN_PREFIX (&brouter->prefix); + inet_ntop (AF_INET, &brouter_id, brouter_name, sizeof (brouter_name)); + if (brouter->type != OSPF6_DEST_TYPE_LINKSTATE) continue; if (ospf6_linkstate_prefix_id (&brouter->prefix) != htonl (0)) @@ -1279,6 +1344,14 @@ ospf6_intra_brouter_calculation (struct ospf6_area *oa) copy->type = OSPF6_DEST_TYPE_ROUTER; copy->path.area_id = oa->area_id; ospf6_route_add (copy, oa->ospf6->brouter_table); + + if (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ID (brouter_id) || + IS_OSPF6_DEBUG_ROUTE (MEMORY)) + { + zlog_info ("%p: transfer: area %s brouter %s", + brouter, oa->name, brouter_name); + ospf6_brouter_debug_print (brouter); + } } oa->ospf6->brouter_table->hook_add = hook_add; @@ -1320,6 +1393,7 @@ ospf6_intra_brouter_calculation (struct ospf6_area *oa) IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ID (oa->area_id)) zlog_info ("brouter %s appears via area %s", brouter_name, oa->name); + /* newly added */ if (hook_add) (*hook_add) (brouter); -- cgit v1.2.3 From 6ac29a51075def99217a4ab1015635db3b3e83ed Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Fri, 15 Aug 2008 13:45:30 +0100 Subject: [trivia] finish off static'ification of ospf6d and ripngd 2008-08-15 Paul Jakma * {ospf6d,ripngd}/*: Finish job of marking functions as static, or exporting declarations for them, to quell warning noise with Quagga's GCC default high-level of warning flags. Thus allowing remaining, more useful warnings to be more easily seen. --- ospf6d/ospf6_intra.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'ospf6d/ospf6_intra.c') diff --git a/ospf6d/ospf6_intra.c b/ospf6d/ospf6_intra.c index ffd9c725..103e8fc2 100644 --- a/ospf6d/ospf6_intra.c +++ b/ospf6d/ospf6_intra.c @@ -56,7 +56,7 @@ u_int32_t conf_debug_ospf6_brouter_specific_area_id; /* RFC2740 3.4.3.1 Router-LSA */ /******************************/ -int +static int ospf6_router_lsa_show (struct vty *vty, struct ospf6_lsa *lsa) { char *start, *end, *current; @@ -316,7 +316,7 @@ ospf6_router_lsa_originate (struct thread *thread) /* RFC2740 3.4.3.2 Network-LSA */ /*******************************/ -int +static int ospf6_network_lsa_show (struct vty *vty, struct ospf6_lsa *lsa) { char *start, *end, *current; @@ -462,7 +462,7 @@ ospf6_network_lsa_originate (struct thread *thread) /* RFC2740 3.4.3.6 Link-LSA */ /****************************/ -int +static int ospf6_link_lsa_show (struct vty *vty, struct ospf6_lsa *lsa) { char *start, *end, *current; @@ -615,7 +615,7 @@ ospf6_link_lsa_originate (struct thread *thread) /* RFC2740 3.4.3.7 Intra-Area-Prefix-LSA */ /*****************************************/ -int +static int ospf6_intra_prefix_lsa_show (struct vty *vty, struct ospf6_lsa *lsa) { char *start, *end, *current; @@ -1238,7 +1238,7 @@ ospf6_intra_route_calculation (struct ospf6_area *oa) zlog_debug ("Re-examin intra-routes for area %s: Done", oa->name); } -void +static void ospf6_brouter_debug_print (struct ospf6_route *brouter) { u_int32_t brouter_id; -- cgit v1.2.3