[ospf6d] Import GNU Zebra CVSps#3559: Fix inter-area as-ext bug, cleanup debug

2005-10-06  Yasuhiro Ohara  <yasu@sfc.wide.ad.jp>

	* 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
This commit is contained in:
Paul Jakma 2006-05-15 10:39:30 +00:00
parent b2518c1e88
commit cb4b88452e
7 changed files with 286 additions and 70 deletions

View File

@ -1,3 +1,10 @@
2005-10-06 Yasuhiro Ohara <yasu@sfc.wide.ad.jp>
* 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
2005-10-01 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* ospf6_asbr.c: Remove local hard-coded tables zroute_name and

View File

@ -294,45 +294,43 @@ ospf6_asbr_lsa_remove (struct ospf6_lsa *lsa)
void
ospf6_asbr_lsentry_add (struct ospf6_route *asbr_entry)
{
char buf[64];
struct ospf6_lsa *lsa;
u_int16_t type;
u_int32_t router;
if (IS_OSPF6_DEBUG_EXAMIN (AS_EXTERNAL))
if (! CHECK_FLAG (asbr_entry->flag, OSPF6_ROUTE_BEST))
{
ospf6_linkstate_prefix2str (&asbr_entry->prefix, buf, sizeof (buf));
zlog_debug ("New ASBR %s found", buf);
char buf[16];
inet_ntop (AF_INET, &ADV_ROUTER_IN_PREFIX (&asbr_entry->prefix),
buf, sizeof (buf));
zlog_info ("ignore non-best path: lsentry %s add", buf);
return;
}
type = htons (OSPF6_LSTYPE_AS_EXTERNAL);
router = ospf6_linkstate_prefix_adv_router (&asbr_entry->prefix);
for (lsa = ospf6_lsdb_type_router_head (type, router, ospf6->lsdb);
lsa; lsa = ospf6_lsdb_type_router_next (type, router, lsa))
for (lsa = ospf6_lsdb_type_router_head (type, router, ospf6->lsdb); lsa;
lsa = ospf6_lsdb_type_router_next (type, router, lsa))
{
if (! OSPF6_LSA_IS_MAXAGE (lsa))
ospf6_asbr_lsa_add (lsa);
}
if (IS_OSPF6_DEBUG_EXAMIN (AS_EXTERNAL))
{
ospf6_linkstate_prefix2str (&asbr_entry->prefix, buf, sizeof (buf));
zlog_debug ("Calculation for new ASBR %s done", buf);
}
}
void
ospf6_asbr_lsentry_remove (struct ospf6_route *asbr_entry)
{
char buf[64];
struct ospf6_lsa *lsa;
u_int16_t type;
u_int32_t router;
if (IS_OSPF6_DEBUG_EXAMIN (AS_EXTERNAL))
if (! CHECK_FLAG (asbr_entry->flag, OSPF6_ROUTE_BEST))
{
ospf6_linkstate_prefix2str (&asbr_entry->prefix, buf, sizeof (buf));
zlog_debug ("ASBR %s disappeared", buf);
char buf[16];
inet_ntop (AF_INET, &ADV_ROUTER_IN_PREFIX (&asbr_entry->prefix),
buf, sizeof (buf));
zlog_info ("ignore non-best path: lsentry %s remove", buf);
return;
}
type = htons (OSPF6_LSTYPE_AS_EXTERNAL);
@ -340,12 +338,6 @@ ospf6_asbr_lsentry_remove (struct ospf6_route *asbr_entry)
for (lsa = ospf6_lsdb_type_router_head (type, router, ospf6->lsdb);
lsa; lsa = ospf6_lsdb_type_router_next (type, router, lsa))
ospf6_asbr_lsa_remove (lsa);
if (IS_OSPF6_DEBUG_EXAMIN (AS_EXTERNAL))
{
ospf6_linkstate_prefix2str (&asbr_entry->prefix, buf, sizeof (buf));
zlog_debug ("Calculation for old ASBR %s done", buf);
}
}

View File

@ -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 (&copy->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);
}

View File

@ -22,6 +22,52 @@
#ifndef OSPF6_INTRA_H
#define OSPF6_INTRA_H
/* Debug option */
extern unsigned char conf_debug_ospf6_brouter;
extern u_int32_t conf_debug_ospf6_brouter_specific_router_id;
extern u_int32_t conf_debug_ospf6_brouter_specific_area_id;
#define OSPF6_DEBUG_BROUTER_SUMMARY 0x01
#define OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER 0x02
#define OSPF6_DEBUG_BROUTER_SPECIFIC_AREA 0x04
#define OSPF6_DEBUG_BROUTER_ON() \
(conf_debug_ospf6_brouter |= OSPF6_DEBUG_BROUTER_SUMMARY)
#define OSPF6_DEBUG_BROUTER_OFF() \
(conf_debug_ospf6_brouter &= ~OSPF6_DEBUG_BROUTER_SUMMARY)
#define IS_OSPF6_DEBUG_BROUTER \
(conf_debug_ospf6_brouter & OSPF6_DEBUG_BROUTER_SUMMARY)
#define OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ON(router_id) \
do { \
conf_debug_ospf6_brouter_specific_router_id = (router_id); \
conf_debug_ospf6_brouter |= OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER; \
} while (0)
#define OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_OFF() \
do { \
conf_debug_ospf6_brouter_specific_router_id = 0; \
conf_debug_ospf6_brouter &= ~OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER; \
} while (0)
#define IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER \
(conf_debug_ospf6_brouter & OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER)
#define IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ID(router_id) \
(IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER && \
conf_debug_ospf6_brouter_specific_router_id == (router_id))
#define OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ON(area_id) \
do { \
conf_debug_ospf6_brouter_specific_area_id = (area_id); \
conf_debug_ospf6_brouter |= OSPF6_DEBUG_BROUTER_SPECIFIC_AREA; \
} while (0)
#define OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_OFF() \
do { \
conf_debug_ospf6_brouter_specific_area_id = 0; \
conf_debug_ospf6_brouter &= ~OSPF6_DEBUG_BROUTER_SPECIFIC_AREA; \
} while (0)
#define IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA \
(conf_debug_ospf6_brouter & OSPF6_DEBUG_BROUTER_SPECIFIC_AREA)
#define IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ID(area_id) \
(IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA && \
conf_debug_ospf6_brouter_specific_area_id == (area_id))
/* Router-LSA */
struct ospf6_router_lsa
{
@ -161,5 +207,8 @@ void ospf6_intra_brouter_calculation (struct ospf6_area *oa);
void ospf6_intra_init ();
int config_write_ospf6_debug_brouter (struct vty *vty);
void install_element_ospf6_debug_brouter ();
#endif /* OSPF6_LSA_H */

View File

@ -549,6 +549,29 @@ DEFUN (show_ipv6_ospf6_route_match_detail,
return CMD_SUCCESS;
}
ALIAS (show_ipv6_ospf6_route_match,
show_ipv6_ospf6_route_longer_cmd,
"show ipv6 ospf6 route X:X::X:X/M longer",
SHOW_STR
IP6_STR
OSPF6_STR
ROUTE_STR
"Specify IPv6 prefix\n"
"Display routes longer than the specified route\n"
);
DEFUN (show_ipv6_ospf6_route_match_detail,
show_ipv6_ospf6_route_longer_detail_cmd,
"show ipv6 ospf6 route X:X::X:X/M longer detail",
SHOW_STR
IP6_STR
OSPF6_STR
ROUTE_STR
"Specify IPv6 prefix\n"
"Display routes longer than the specified route\n"
"Detailed information\n"
);
ALIAS (show_ipv6_ospf6_route,
show_ipv6_ospf6_route_type_cmd,
"show ipv6 ospf6 route (intra-area|inter-area|external-1|external-2)",
@ -646,12 +669,16 @@ ospf6_top_init ()
install_element (VIEW_NODE, &show_ipv6_ospf6_route_detail_cmd);
install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_cmd);
install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_detail_cmd);
install_element (VIEW_NODE, &show_ipv6_ospf6_route_longer_cmd);
install_element (VIEW_NODE, &show_ipv6_ospf6_route_longer_detail_cmd);
install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_cmd);
install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_detail_cmd);
install_element (ENABLE_NODE, &show_ipv6_ospf6_route_cmd);
install_element (ENABLE_NODE, &show_ipv6_ospf6_route_detail_cmd);
install_element (ENABLE_NODE, &show_ipv6_ospf6_route_match_cmd);
install_element (ENABLE_NODE, &show_ipv6_ospf6_route_match_detail_cmd);
install_element (ENABLE_NODE, &show_ipv6_ospf6_route_longer_cmd);
install_element (ENABLE_NODE, &show_ipv6_ospf6_route_longer_detail_cmd);
install_element (ENABLE_NODE, &show_ipv6_ospf6_route_type_cmd);
install_element (ENABLE_NODE, &show_ipv6_ospf6_route_type_detail_cmd);

View File

@ -114,6 +114,7 @@ config_write_ospf6_debug (struct vty *vty)
config_write_ospf6_debug_neighbor (vty);
config_write_ospf6_debug_spf (vty);
config_write_ospf6_debug_route (vty);
config_write_ospf6_debug_brouter (vty);
config_write_ospf6_debug_asbr (vty);
config_write_ospf6_debug_abr (vty);
config_write_ospf6_debug_flood (vty);
@ -1783,6 +1784,7 @@ ospf6_init ()
install_element_ospf6_debug_zebra ();
install_element_ospf6_debug_spf ();
install_element_ospf6_debug_route ();
install_element_ospf6_debug_brouter ();
install_element_ospf6_debug_asbr ();
install_element_ospf6_debug_abr ();
install_element_ospf6_debug_flood ();

View File

@ -22,7 +22,7 @@
#ifndef OSPF6D_H
#define OSPF6D_H
#define OSPF6_DAEMON_VERSION "0.9.7o"
#define OSPF6_DAEMON_VERSION "0.9.7p"
/* global variables */
extern int errno;