summaryrefslogtreecommitdiff
path: root/ospf6d
diff options
context:
space:
mode:
Diffstat (limited to 'ospf6d')
-rw-r--r--ospf6d/ospf6_area.c8
-rw-r--r--ospf6d/ospf6_asbr.c39
-rw-r--r--ospf6d/ospf6_bfd.c2
-rw-r--r--ospf6d/ospf6_flood.c20
-rw-r--r--ospf6d/ospf6_flood.h2
-rw-r--r--ospf6d/ospf6_gr_helper.c8
-rw-r--r--ospf6d/ospf6_interface.c48
-rw-r--r--ospf6d/ospf6_intra.c22
-rw-r--r--ospf6d/ospf6_lsa.c62
-rw-r--r--ospf6d/ospf6_lsa.h3
-rw-r--r--ospf6d/ospf6_message.c55
-rw-r--r--ospf6d/ospf6_neighbor.c22
-rw-r--r--ospf6d/ospf6_route.c45
-rw-r--r--ospf6d/ospf6_route.h15
-rw-r--r--ospf6d/ospf6_snmp.c9
-rw-r--r--ospf6d/ospf6_top.c23
-rw-r--r--ospf6d/ospf6_top.h1
-rw-r--r--ospf6d/ospf6d.c14
18 files changed, 119 insertions, 279 deletions
diff --git a/ospf6d/ospf6_area.c b/ospf6d/ospf6_area.c
index f35971ba8c..7e8e34a221 100644
--- a/ospf6d/ospf6_area.c
+++ b/ospf6d/ospf6_area.c
@@ -1045,12 +1045,8 @@ static int ipv6_ospf6_spf_tree_common(struct vty *vty, struct ospf6 *ospf6,
}
}
- if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (uj)
+ vty_json(vty, json);
return CMD_SUCCESS;
}
diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c
index b439f947de..99f30a4a06 100644
--- a/ospf6d/ospf6_asbr.c
+++ b/ospf6d/ospf6_asbr.c
@@ -1410,7 +1410,6 @@ void ospf6_asbr_redistribute_add(int type, ifindex_t ifindex,
struct ospf6_route *route, *match;
struct ospf6_external_info *info;
struct prefix prefix_id;
- struct route_node *node;
char ibuf[16];
struct ospf6_redist *red;
@@ -1497,13 +1496,6 @@ void ospf6_asbr_redistribute_add(int type, ifindex_t ifindex,
else
ospf6_route_add_nexthop(match, ifindex, NULL);
- /* create/update binding in external_id_table */
- prefix_id.family = AF_INET;
- prefix_id.prefixlen = IPV4_MAX_BITLEN;
- prefix_id.u.prefix4.s_addr = htonl(info->id);
- node = route_node_get(ospf6->external_id_table, &prefix_id);
- node->info = match;
-
if (IS_OSPF6_DEBUG_ASBR) {
inet_ntop(AF_INET, &prefix_id.u.prefix4, ibuf,
sizeof(ibuf));
@@ -2553,10 +2545,7 @@ DEFUN(show_ipv6_ospf6_redistribute, show_ipv6_ospf6_redistribute_cmd,
if (uj) {
json_object_object_add(json, "routes",
json_array_routes);
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
}
if (!all_vrf)
@@ -2787,7 +2776,6 @@ static void ospf6_originate_new_aggr_lsa(struct ospf6 *ospf6,
struct ospf6_external_aggr_rt *aggr)
{
struct prefix prefix_id;
- struct route_node *node;
struct ospf6_lsa *lsa = NULL;
if (IS_OSPF6_DEBUG_AGGR)
@@ -2796,13 +2784,6 @@ static void ospf6_originate_new_aggr_lsa(struct ospf6 *ospf6,
aggr->id = ospf6->external_id++;
- /* create/update binding in external_id_table */
- prefix_id.family = AF_INET;
- prefix_id.prefixlen = 32;
- prefix_id.u.prefix4.s_addr = htonl(aggr->id);
- node = route_node_get(ospf6->external_id_table, &prefix_id);
- node->info = aggr;
-
if (IS_OSPF6_DEBUG_AGGR)
zlog_debug(
"Advertise AS-External Id:%pI4 prefix %pFX metric %u",
@@ -3014,8 +2995,6 @@ static void ospf6_aggr_handle_external_info(void *data)
struct ospf6_lsa *lsa = NULL;
struct ospf6_external_info *info;
struct ospf6 *ospf6 = NULL;
- struct prefix prefix_id;
- struct route_node *node;
rt->aggr_route = NULL;
@@ -3055,13 +3034,6 @@ static void ospf6_aggr_handle_external_info(void *data)
info->id = ospf6->external_id++;
rt->path.origin.id = htonl(info->id);
- /* create/update binding in external_id_table */
- prefix_id.family = AF_INET;
- prefix_id.prefixlen = 32;
- prefix_id.u.prefix4.s_addr = htonl(info->id);
- node = route_node_get(ospf6->external_id_table, &prefix_id);
- node->info = rt;
-
(void)ospf6_originate_type5_type7_lsas(rt, ospf6);
}
@@ -3642,7 +3614,6 @@ void ospf6_handle_external_lsa_origination(struct ospf6 *ospf6,
struct ospf6_external_aggr_rt *aggr;
struct ospf6_external_info *info;
struct prefix prefix_id;
- struct route_node *node;
if (!is_default_prefix(p)) {
aggr = ospf6_external_aggr_match(ospf6,
@@ -3678,14 +3649,6 @@ void ospf6_handle_external_lsa_origination(struct ospf6 *ospf6,
*/
if (!info->id) {
info->id = ospf6->external_id++;
-
- /* create/update binding in external_id_table */
- prefix_id.family = AF_INET;
- prefix_id.prefixlen = 32;
- prefix_id.u.prefix4.s_addr = htonl(info->id);
- node = route_node_get(ospf6->external_id_table, &prefix_id);
- node->info = rt;
-
} else {
prefix_id.family = AF_INET;
prefix_id.prefixlen = 32;
diff --git a/ospf6d/ospf6_bfd.c b/ospf6d/ospf6_bfd.c
index fc1e718540..c124f17e34 100644
--- a/ospf6d/ospf6_bfd.c
+++ b/ospf6d/ospf6_bfd.c
@@ -143,7 +143,7 @@ void ospf6_bfd_info_nbr_create(struct ospf6_interface *oi,
bfd_sess_set_ipv6_addrs(on->bfd_session, on->ospf6_if->linklocal_addr,
&on->linklocal_addr);
bfd_sess_set_interface(on->bfd_session, oi->interface->name);
- bfd_sess_set_vrf(on->bfd_session, oi->interface->vrf_id);
+ bfd_sess_set_vrf(on->bfd_session, oi->interface->vrf->vrf_id);
bfd_sess_set_profile(on->bfd_session, oi->bfd_config.profile);
}
diff --git a/ospf6d/ospf6_flood.c b/ospf6d/ospf6_flood.c
index 6e00bd766f..5fed6dfe17 100644
--- a/ospf6d/ospf6_flood.c
+++ b/ospf6d/ospf6_flood.c
@@ -151,24 +151,6 @@ void ospf6_lsa_originate_interface(struct ospf6_lsa *lsa,
ospf6_lsa_originate(oi->area->ospf6, lsa);
}
-void ospf6_remove_id_from_external_id_table(struct ospf6 *ospf6,
- uint32_t id)
-{
- struct prefix prefix_id;
- struct route_node *node;
-
- /* remove binding in external_id_table */
- prefix_id.family = AF_INET;
- prefix_id.prefixlen = 32;
- prefix_id.u.prefix4.s_addr = id;
- node = route_node_lookup(ospf6->external_id_table, &prefix_id);
- assert(node);
- node->info = NULL;
- route_unlock_node(node); /* to free the lookup lock */
- route_unlock_node(node); /* to free the original lock */
-
-}
-
void ospf6_external_lsa_purge(struct ospf6 *ospf6, struct ospf6_lsa *lsa)
{
uint32_t id = lsa->header->id;
@@ -177,8 +159,6 @@ void ospf6_external_lsa_purge(struct ospf6 *ospf6, struct ospf6_lsa *lsa)
ospf6_lsa_purge(lsa);
- ospf6_remove_id_from_external_id_table(ospf6, id);
-
/* Delete the corresponding NSSA LSA */
for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, lnode, oa)) {
lsa = ospf6_lsdb_lookup(htons(OSPF6_LSTYPE_TYPE_7), id,
diff --git a/ospf6d/ospf6_flood.h b/ospf6d/ospf6_flood.h
index 775d0d289d..75f3c065bb 100644
--- a/ospf6d/ospf6_flood.h
+++ b/ospf6d/ospf6_flood.h
@@ -39,8 +39,6 @@ extern void ospf6_lsa_originate_area(struct ospf6_lsa *lsa,
struct ospf6_area *oa);
extern void ospf6_lsa_originate_interface(struct ospf6_lsa *lsa,
struct ospf6_interface *oi);
-void ospf6_remove_id_from_external_id_table(struct ospf6 *ospf6,
- uint32_t id);
void ospf6_external_lsa_purge(struct ospf6 *ospf6, struct ospf6_lsa *lsa);
extern void ospf6_lsa_purge(struct ospf6_lsa *lsa);
diff --git a/ospf6d/ospf6_gr_helper.c b/ospf6d/ospf6_gr_helper.c
index 4dc2d8af83..84ee35a3ed 100644
--- a/ospf6d/ospf6_gr_helper.c
+++ b/ospf6d/ospf6_gr_helper.c
@@ -1188,12 +1188,8 @@ DEFPY(show_ipv6_ospf6_gr_helper,
show_ospf6_gr_helper_details(vty, ospf6, json, uj, detail);
- if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (uj)
+ vty_json(vty, json);
return CMD_SUCCESS;
}
diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c
index 4205be38ba..a0c921f419 100644
--- a/ospf6d/ospf6_interface.c
+++ b/ospf6d/ospf6_interface.c
@@ -127,7 +127,7 @@ static uint8_t ospf6_default_iftype(struct interface *ifp)
{
if (if_is_pointopoint(ifp))
return OSPF_IFTYPE_POINTOPOINT;
- else if (if_is_loopback_or_vrf(ifp))
+ else if (if_is_loopback(ifp))
return OSPF_IFTYPE_LOOPBACK;
else
return OSPF_IFTYPE_BROADCAST;
@@ -150,7 +150,7 @@ static uint32_t ospf6_interface_get_cost(struct ospf6_interface *oi)
: OSPF6_INTERFACE_BANDWIDTH;
}
- ospf6 = ospf6_lookup_by_vrf_id(oi->interface->vrf_id);
+ ospf6 = oi->interface->vrf->info;
refbw = ospf6 ? ospf6->ref_bandwidth : OSPF6_REFERENCE_BANDWIDTH;
/* A specifed ip ospf cost overrides a calculated one. */
@@ -387,7 +387,7 @@ void ospf6_interface_state_update(struct interface *ifp)
if (if_is_operative(ifp)
&& (ospf6_interface_get_linklocal_address(oi->interface)
- || if_is_loopback_or_vrf(oi->interface)))
+ || if_is_loopback(oi->interface)))
thread_execute(master, interface_up, oi, 0);
else
thread_execute(master, interface_down, oi, 0);
@@ -750,7 +750,7 @@ int interface_up(struct thread *thread)
/* check interface has a link-local address */
if (!(ospf6_interface_get_linklocal_address(oi->interface)
- || if_is_loopback_or_vrf(oi->interface))) {
+ || if_is_loopback(oi->interface))) {
zlog_warn(
"Interface %s has no link local address, can't execute [InterfaceUp]",
oi->interface->name);
@@ -819,7 +819,7 @@ int interface_up(struct thread *thread)
/* Schedule Hello */
if (!CHECK_FLAG(oi->flag, OSPF6_INTERFACE_PASSIVE)
- && !if_is_loopback_or_vrf(oi->interface)) {
+ && !if_is_loopback(oi->interface)) {
thread_add_event(master, ospf6_hello_send, oi, 0,
&oi->thread_send_hello);
}
@@ -1277,10 +1277,7 @@ static int show_ospf6_interface_common(struct vty *vty, vrf_id_t vrf_id,
if (ifp == NULL) {
json_object_string_add(json, "noSuchInterface",
argv[idx_ifname]->arg);
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
json_object_free(json_int);
return CMD_WARNING;
}
@@ -1294,10 +1291,7 @@ static int show_ospf6_interface_common(struct vty *vty, vrf_id_t vrf_id,
json_int);
}
}
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
} else {
if (argc == intf_idx) {
ifp = if_lookup_by_name(argv[idx_ifname]->arg, vrf_id);
@@ -1361,11 +1355,6 @@ static int ospf6_interface_show_traffic(struct vty *vty,
struct ospf6_interface *oi = NULL;
json_object *json_interface;
- if (intf_ifp)
- vrf = vrf_lookup_by_id(intf_ifp->vrf_id);
- else
- vrf = vrf_lookup_by_id(vrf_id);
-
if (!display_once && !use_json) {
vty_out(vty, "\n");
vty_out(vty, "%-12s%-17s%-17s%-17s%-17s%-17s\n", "Interface",
@@ -1379,6 +1368,7 @@ static int ospf6_interface_show_traffic(struct vty *vty,
}
if (intf_ifp == NULL) {
+ vrf = vrf_lookup_by_id(vrf_id);
FOR_ALL_INTERFACES (vrf, ifp) {
if (ifp->info)
oi = (struct ospf6_interface *)ifp->info;
@@ -1488,10 +1478,7 @@ static int ospf6_interface_show_traffic_common(struct vty *vty, int argc,
"No Such Interface");
json_object_string_add(json, "interface",
intf_name);
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
return CMD_WARNING;
}
if (ifp->info == NULL) {
@@ -1500,10 +1487,7 @@ static int ospf6_interface_show_traffic_common(struct vty *vty, int argc,
"OSPF not enabled on this interface");
json_object_string_add(json, "interface",
intf_name);
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
return 0;
}
} else {
@@ -1523,12 +1507,8 @@ static int ospf6_interface_show_traffic_common(struct vty *vty, int argc,
ospf6_interface_show_traffic(vty, ifp, display_once, json, uj, vrf_id);
- if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (uj)
+ vty_json(vty, json);
return CMD_SUCCESS;
}
@@ -1685,7 +1665,7 @@ void ospf6_interface_start(struct ospf6_interface *oi)
if (oi->area)
return;
- ospf6 = ospf6_lookup_by_vrf_id(oi->interface->vrf_id);
+ ospf6 = oi->interface->vrf->info;
if (!ospf6)
return;
@@ -2315,7 +2295,7 @@ DEFUN (no_ipv6_ospf6_passive,
THREAD_OFF(oi->thread_sso);
/* don't send hellos over loopback interface */
- if (!if_is_loopback_or_vrf(oi->interface))
+ if (!if_is_loopback(oi->interface))
thread_add_event(master, ospf6_hello_send, oi, 0,
&oi->thread_send_hello);
diff --git a/ospf6d/ospf6_intra.c b/ospf6d/ospf6_intra.c
index 6abc1c7d09..6626b4bed5 100644
--- a/ospf6d/ospf6_intra.c
+++ b/ospf6d/ospf6_intra.c
@@ -142,19 +142,15 @@ static int ospf6_router_lsa_show(struct vty *vty, struct ospf6_lsa *lsa,
json_object_string_add(json_loop, "type", name);
json_object_int_add(json_loop, "metric",
ntohs(lsdesc->metric));
- json_object_string_add(json_loop, "interfaceId",
- inet_ntop(AF_INET,
- &lsdesc->interface_id,
- buf, sizeof(buf)));
- json_object_string_add(
- json_loop, "neighborInterfaceId",
- inet_ntop(AF_INET,
- &lsdesc->neighbor_interface_id, buf,
- sizeof(buf)));
- json_object_string_add(
- json_loop, "neighborRouterId",
- inet_ntop(AF_INET, &lsdesc->neighbor_router_id,
- buf, sizeof(buf)));
+ json_object_string_addf(
+ json_loop, "interfaceId", "%pI4",
+ (in_addr_t *)&lsdesc->interface_id);
+ json_object_string_addf(
+ json_loop, "neighborInterfaceId", "%pI4",
+ (in_addr_t *)&lsdesc->neighbor_interface_id);
+ json_object_string_addf(json_loop, "neighborRouterId",
+ "%pI4",
+ &lsdesc->neighbor_router_id);
json_object_array_add(json_arr, json_loop);
} else {
vty_out(vty, " Type: %s Metric: %d\n", name,
diff --git a/ospf6d/ospf6_lsa.c b/ospf6d/ospf6_lsa.c
index 77f0f8f4e5..99d0de39cf 100644
--- a/ospf6d/ospf6_lsa.c
+++ b/ospf6d/ospf6_lsa.c
@@ -54,7 +54,7 @@ DEFINE_MTYPE_STATIC(OSPF6D, OSPF6_LSA, "OSPF6 LSA");
DEFINE_MTYPE_STATIC(OSPF6D, OSPF6_LSA_HEADER, "OSPF6 LSA header");
DEFINE_MTYPE_STATIC(OSPF6D, OSPF6_LSA_SUMMARY, "OSPF6 LSA summary");
-vector ospf6_lsa_handler_vector;
+static struct ospf6_lsa_handler *lsa_handlers[OSPF6_LSTYPE_SIZE];
struct ospf6 *ospf6_get_by_lsdb(struct ospf6_lsa *lsa)
{
@@ -115,8 +115,13 @@ static struct ospf6_lsa_handler unknown_handler = {
void ospf6_install_lsa_handler(struct ospf6_lsa_handler *handler)
{
/* type in handler is host byte order */
- int index = handler->lh_type & OSPF6_LSTYPE_FCODE_MASK;
- vector_set_index(ospf6_lsa_handler_vector, index, (void *)handler);
+ unsigned int index = handler->lh_type & OSPF6_LSTYPE_FCODE_MASK;
+
+ assertf(index < array_size(lsa_handlers), "index=%x", index);
+ assertf(lsa_handlers[index] == NULL, "old=%s, new=%s",
+ lsa_handlers[index]->lh_name, handler->lh_name);
+
+ lsa_handlers[index] = handler;
}
struct ospf6_lsa_handler *ospf6_get_lsa_handler(uint16_t type)
@@ -124,10 +129,8 @@ struct ospf6_lsa_handler *ospf6_get_lsa_handler(uint16_t type)
struct ospf6_lsa_handler *handler = NULL;
unsigned int index = ntohs(type) & OSPF6_LSTYPE_FCODE_MASK;
- if (index >= vector_active(ospf6_lsa_handler_vector))
- handler = &unknown_handler;
- else
- handler = vector_slot(ospf6_lsa_handler_vector, index);
+ if (index < array_size(lsa_handlers))
+ handler = lsa_handlers[index];
if (handler == NULL)
handler = &unknown_handler;
@@ -989,13 +992,11 @@ int ospf6_lsa_checksum_valid(struct ospf6_lsa_header *lsa_header)
void ospf6_lsa_init(void)
{
- ospf6_lsa_handler_vector = vector_init(0);
ospf6_install_lsa_handler(&unknown_handler);
}
void ospf6_lsa_terminate(void)
{
- vector_free(ospf6_lsa_handler_vector);
}
static char *ospf6_lsa_handler_name(const struct ospf6_lsa_handler *h)
@@ -1020,27 +1021,32 @@ static char *ospf6_lsa_handler_name(const struct ospf6_lsa_handler *h)
return buf;
}
-DEFPY (debug_ospf6_lsa_all,
- debug_ospf6_lsa_all_cmd,
- "[no$no] debug ospf6 lsa all",
- NO_STR
- DEBUG_STR
- OSPF6_STR
- "Debug Link State Advertisements (LSAs)\n"
- "Display for all types of LSAs\n")
+void ospf6_lsa_debug_set_all(bool val)
{
unsigned int i;
struct ospf6_lsa_handler *handler = NULL;
- for (i = 0; i < vector_active(ospf6_lsa_handler_vector); i++) {
- handler = vector_slot(ospf6_lsa_handler_vector, i);
+ for (i = 0; i < array_size(lsa_handlers); i++) {
+ handler = lsa_handlers[i];
if (handler == NULL)
continue;
- if (!no)
+ if (val)
SET_FLAG(handler->lh_debug, OSPF6_LSA_DEBUG_ALL);
else
UNSET_FLAG(handler->lh_debug, OSPF6_LSA_DEBUG_ALL);
}
+}
+
+DEFPY (debug_ospf6_lsa_all,
+ debug_ospf6_lsa_all_cmd,
+ "[no$no] debug ospf6 lsa all",
+ NO_STR
+ DEBUG_STR
+ OSPF6_STR
+ "Debug Link State Advertisements (LSAs)\n"
+ "Display for all types of LSAs\n")
+{
+ ospf6_lsa_debug_set_all(!no);
return CMD_SUCCESS;
}
@@ -1092,8 +1098,8 @@ DEFUN (debug_ospf6_lsa_type,
unsigned int i;
struct ospf6_lsa_handler *handler = NULL;
- for (i = 0; i < vector_active(ospf6_lsa_handler_vector); i++) {
- handler = vector_slot(ospf6_lsa_handler_vector, i);
+ for (i = 0; i < array_size(lsa_handlers); i++) {
+ handler = lsa_handlers[i];
if (handler == NULL)
continue;
if (strncmp(argv[idx_lsa]->arg, ospf6_lsa_handler_name(handler),
@@ -1146,8 +1152,8 @@ DEFUN (no_debug_ospf6_lsa_type,
unsigned int i;
struct ospf6_lsa_handler *handler = NULL;
- for (i = 0; i < vector_active(ospf6_lsa_handler_vector); i++) {
- handler = vector_slot(ospf6_lsa_handler_vector, i);
+ for (i = 0; i < array_size(lsa_handlers); i++) {
+ handler = lsa_handlers[i];
if (handler == NULL)
continue;
if (strncmp(argv[idx_lsa]->arg, ospf6_lsa_handler_name(handler),
@@ -1194,8 +1200,8 @@ int config_write_ospf6_debug_lsa(struct vty *vty)
const struct ospf6_lsa_handler *handler;
bool debug_all = true;
- for (i = 0; i < vector_active(ospf6_lsa_handler_vector); i++) {
- handler = vector_slot(ospf6_lsa_handler_vector, i);
+ for (i = 0; i < array_size(lsa_handlers); i++) {
+ handler = lsa_handlers[i];
if (handler == NULL)
continue;
if (CHECK_FLAG(handler->lh_debug, OSPF6_LSA_DEBUG_ALL)
@@ -1210,8 +1216,8 @@ int config_write_ospf6_debug_lsa(struct vty *vty)
return 0;
}
- for (i = 0; i < vector_active(ospf6_lsa_handler_vector); i++) {
- handler = vector_slot(ospf6_lsa_handler_vector, i);
+ for (i = 0; i < array_size(lsa_handlers); i++) {
+ handler = lsa_handlers[i];
if (handler == NULL)
continue;
if (CHECK_FLAG(handler->lh_debug, OSPF6_LSA_DEBUG))
diff --git a/ospf6d/ospf6_lsa.h b/ospf6d/ospf6_lsa.h
index c0d3cc149b..aa1150afca 100644
--- a/ospf6d/ospf6_lsa.h
+++ b/ospf6d/ospf6_lsa.h
@@ -173,8 +173,6 @@ struct ospf6_lsa_handler {
#define OSPF6_LSA_IS_KNOWN(t) \
(ospf6_get_lsa_handler(t)->lh_type != OSPF6_LSTYPE_UNKNOWN ? 1 : 0)
-extern vector ospf6_lsa_handler_vector;
-
/* Macro for LSA Origination */
/* addr is (struct prefix *) */
#define CONTINUE_IF_ADDRESS_LINKLOCAL(debug, addr) \
@@ -268,6 +266,7 @@ extern int ospf6_lsa_prohibited_duration(uint16_t type, uint32_t id,
extern void ospf6_install_lsa_handler(struct ospf6_lsa_handler *handler);
extern struct ospf6_lsa_handler *ospf6_get_lsa_handler(uint16_t type);
+extern void ospf6_lsa_debug_set_all(bool val);
extern void ospf6_lsa_init(void);
extern void ospf6_lsa_terminate(void);
diff --git a/ospf6d/ospf6_message.c b/ospf6d/ospf6_message.c
index 49a379aa17..352cb137ed 100644
--- a/ospf6d/ospf6_message.c
+++ b/ospf6d/ospf6_message.c
@@ -409,9 +409,8 @@ static void ospf6_hello_recv(struct in6_addr *src, struct in6_addr *dst,
if (ntohs(hello->hello_interval) != oi->hello_interval) {
zlog_warn(
"VRF %s: I/F %s HelloInterval mismatch: (my %d, rcvd %d)",
- vrf_id_to_name(oi->interface->vrf_id),
- oi->interface->name, oi->hello_interval,
- ntohs(hello->hello_interval));
+ oi->interface->vrf->name, oi->interface->name,
+ oi->hello_interval, ntohs(hello->hello_interval));
return;
}
@@ -419,9 +418,8 @@ static void ospf6_hello_recv(struct in6_addr *src, struct in6_addr *dst,
if (ntohs(hello->dead_interval) != oi->dead_interval) {
zlog_warn(
"VRF %s: I/F %s DeadInterval mismatch: (my %d, rcvd %d)",
- vrf_id_to_name(oi->interface->vrf_id),
- oi->interface->name, oi->dead_interval,
- ntohs(hello->dead_interval));
+ oi->interface->vrf->name, oi->interface->name,
+ oi->dead_interval, ntohs(hello->dead_interval));
return;
}
@@ -429,8 +427,15 @@ static void ospf6_hello_recv(struct in6_addr *src, struct in6_addr *dst,
if (OSPF6_OPT_ISSET(hello->options, OSPF6_OPT_E)
!= OSPF6_OPT_ISSET(oi->area->options, OSPF6_OPT_E)) {
zlog_warn("VRF %s: IF %s E-bit mismatch",
- vrf_id_to_name(oi->interface->vrf_id),
- oi->interface->name);
+ oi->interface->vrf->name, oi->interface->name);
+ return;
+ }
+
+ /* N-bit check */
+ if (OSPF6_OPT_ISSET(hello->options, OSPF6_OPT_N)
+ != OSPF6_OPT_ISSET(oi->area->options, OSPF6_OPT_N)) {
+ zlog_warn("VRF %s: IF %s N-bit mismatch",
+ oi->interface->vrf->name, oi->interface->name);
return;
}
@@ -622,10 +627,8 @@ static void ospf6_dbdesc_recv_master(struct ospf6_header *oh,
memcpy(on->options, dbdesc->options,
sizeof(on->options));
} else {
- zlog_warn(
- "VRF %s: Nbr %s: Negotiation failed",
- vrf_id_to_name(on->ospf6_if->interface->vrf_id),
- on->name);
+ zlog_warn("VRF %s: Nbr %s: Negotiation failed",
+ on->ospf6_if->interface->vrf->name, on->name);
return;
}
/* fall through to exchange */
@@ -838,10 +841,8 @@ static void ospf6_dbdesc_recv_slave(struct ospf6_header *oh,
memcpy(on->options, dbdesc->options,
sizeof(on->options));
} else {
- zlog_warn(
- "VRF %s: Nbr %s Negotiation failed",
- vrf_id_to_name(on->ospf6_if->interface->vrf_id),
- on->name);
+ zlog_warn("VRF %s: Nbr %s Negotiation failed",
+ on->ospf6_if->interface->vrf->name, on->name);
return;
}
break;
@@ -1008,8 +1009,8 @@ static void ospf6_dbdesc_recv(struct in6_addr *src, struct in6_addr *dst,
/* Interface MTU check */
if (!oi->mtu_ignore && ntohs(dbdesc->ifmtu) != oi->ifmtu) {
zlog_warn("VRF %s: I/F %s MTU mismatch (my %d rcvd %d)",
- vrf_id_to_name(oi->interface->vrf_id),
- oi->interface->name, oi->ifmtu, ntohs(dbdesc->ifmtu));
+ oi->interface->vrf->name, oi->interface->name,
+ oi->ifmtu, ntohs(dbdesc->ifmtu));
return;
}
@@ -1515,14 +1516,12 @@ static int ospf6_rxpacket_examin(struct ospf6_interface *oi,
if (oh->area_id == OSPF_AREA_BACKBONE)
zlog_warn(
"VRF %s: I/F %s Message may be via Virtual Link: not supported",
- vrf_id_to_name(oi->interface->vrf_id),
- oi->interface->name);
+ oi->interface->vrf->name, oi->interface->name);
else
zlog_warn(
"VRF %s: I/F %s Area-ID mismatch (my %pI4, rcvd %pI4)",
- vrf_id_to_name(oi->interface->vrf_id),
- oi->interface->name, &oi->area->area_id,
- &oh->area_id);
+ oi->interface->vrf->name, oi->interface->name,
+ &oi->area->area_id, &oh->area_id);
return MSG_NG;
}
@@ -1530,16 +1529,16 @@ static int ospf6_rxpacket_examin(struct ospf6_interface *oi,
if (oh->instance_id != oi->instance_id) {
zlog_warn(
"VRF %s: I/F %s Instance-ID mismatch (my %u, rcvd %u)",
- vrf_id_to_name(oi->interface->vrf_id),
- oi->interface->name, oi->instance_id, oh->instance_id);
+ oi->interface->vrf->name, oi->interface->name,
+ oi->instance_id, oh->instance_id);
return MSG_NG;
}
/* Router-ID check */
if (oh->router_id == oi->area->ospf6->router_id) {
zlog_warn("VRF %s: I/F %s Duplicate Router-ID (%pI4)",
- vrf_id_to_name(oi->interface->vrf_id),
- oi->interface->name, &oh->router_id);
+ oi->interface->vrf->name, oi->interface->name,
+ &oh->router_id);
return MSG_NG;
}
return MSG_OK;
@@ -1769,7 +1768,7 @@ static int ospf6_read_helper(int sockfd, struct ospf6 *ospf6)
* Drop packet destined to another VRF.
* This happens when raw_l3mdev_accept is set to 1.
*/
- if (ospf6->vrf_id != oi->interface->vrf_id)
+ if (ospf6->vrf_id != oi->interface->vrf->vrf_id)
return OSPF6_READ_CONTINUE;
oh = (struct ospf6_header *)recvbuf;
diff --git a/ospf6d/ospf6_neighbor.c b/ospf6d/ospf6_neighbor.c
index 3d0dde8c65..1a8fedea0c 100644
--- a/ospf6d/ospf6_neighbor.c
+++ b/ospf6d/ospf6_neighbor.c
@@ -1073,10 +1073,7 @@ static void ospf6_neighbor_show_detail_common(struct vty *vty,
json_object_object_add(json, "neighbors", json_array);
else
json_object_free(json_array);
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
}
}
@@ -1148,12 +1145,8 @@ static int ospf6_neighbor_show_common(struct vty *vty, int argc,
(*showfunc)(vty, on, json, uj);
}
- if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (uj)
+ vty_json(vty, json);
return CMD_SUCCESS;
}
@@ -1254,7 +1247,6 @@ DEFUN (no_debug_ospf6,
OSPF6_STR)
{
unsigned int i;
- struct ospf6_lsa_handler *handler = NULL;
OSPF6_DEBUG_ABR_OFF();
OSPF6_DEBUG_ASBR_OFF();
@@ -1264,13 +1256,7 @@ DEFUN (no_debug_ospf6,
OSPF6_DEBUG_FLOODING_OFF();
OSPF6_DEBUG_INTERFACE_OFF();
- for (i = 0; i < vector_active(ospf6_lsa_handler_vector); i++) {
- handler = vector_slot(ospf6_lsa_handler_vector, i);
-
- if (handler != NULL) {
- UNSET_FLAG(handler->lh_debug, OSPF6_LSA_DEBUG);
- }
- }
+ ospf6_lsa_debug_set_all(false);
for (i = 0; i < 6; i++)
OSPF6_DEBUG_MESSAGE_OFF(i,
diff --git a/ospf6d/ospf6_route.c b/ospf6d/ospf6_route.c
index 35b567c768..f5d60d80fa 100644
--- a/ospf6d/ospf6_route.c
+++ b/ospf6d/ospf6_route.c
@@ -704,27 +704,6 @@ struct ospf6_route *ospf6_route_add(struct ospf6_route *route,
}
if (old) {
- /* if route does not actually change, return unchanged */
- if (ospf6_route_is_identical(old, route)) {
- if (IS_OSPF6_DEBUG_ROUTE(MEMORY))
- zlog_debug(
- "%s %p: route add %p: needless update of %p old cost %u",
- ospf6_route_table_name(table),
- (void *)table, (void *)route,
- (void *)old, old->path.cost);
- else if (IS_OSPF6_DEBUG_ROUTE(TABLE))
- zlog_debug("%s: route add: needless update",
- ospf6_route_table_name(table));
-
- ospf6_route_delete(route);
- SET_FLAG(old->flag, OSPF6_ROUTE_ADD);
- ospf6_route_table_assert(table);
-
- /* to free the lookup lock */
- route_unlock_node(node);
- return old;
- }
-
if (IS_OSPF6_DEBUG_ROUTE(MEMORY))
zlog_debug(
"%s %p: route add %p cost %u paths %u nh %u: update of %p cost %u paths %u nh %u",
@@ -1631,12 +1610,8 @@ int ospf6_route_table_show(struct vty *vty, int argc_start, int argc,
/* Give summary of this route table */
if (summary) {
ospf6_route_show_table_summary(vty, table, json, use_json);
- if (use_json) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (use_json)
+ vty_json(vty, json);
return CMD_SUCCESS;
}
@@ -1650,12 +1625,8 @@ int ospf6_route_table_show(struct vty *vty, int argc_start, int argc,
ospf6_route_show_table_prefix(vty, &prefix, table, json,
use_json);
- if (use_json) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (use_json)
+ vty_json(vty, json);
return CMD_SUCCESS;
}
@@ -1668,12 +1639,8 @@ int ospf6_route_table_show(struct vty *vty, int argc_start, int argc,
else
ospf6_route_show_table(vty, detail, table, json, use_json);
- if (use_json) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (use_json)
+ vty_json(vty, json);
return CMD_SUCCESS;
}
diff --git a/ospf6d/ospf6_route.h b/ospf6d/ospf6_route.h
index fd8b6a9c1d..633b8d77cd 100644
--- a/ospf6d/ospf6_route.h
+++ b/ospf6d/ospf6_route.h
@@ -291,20 +291,13 @@ extern const char *const ospf6_path_type_substr[OSPF6_PATH_TYPE_MAX];
#define OSPF6_ROUTE_PREFIX_STR "Display the route\n"
#define OSPF6_ROUTE_MATCH_STR "Display the route matches the prefix\n"
-#define ospf6_route_is_prefix(p, r) \
- (memcmp(p, &(r)->prefix, sizeof(struct prefix)) == 0)
+#define ospf6_route_is_prefix(p, r) (prefix_same(p, &(r)->prefix))
#define ospf6_route_is_same(ra, rb) (prefix_same(&(ra)->prefix, &(rb)->prefix))
#define ospf6_route_is_same_origin(ra, rb) \
((ra)->path.area_id == (rb)->path.area_id \
- && memcmp(&(ra)->path.origin, &(rb)->path.origin, \
- sizeof(struct ospf6_ls_origin)) \
- == 0)
-#define ospf6_route_is_identical(ra, rb) \
- ((ra)->type == (rb)->type \
- && memcmp(&(ra)->prefix, &(rb)->prefix, sizeof(struct prefix)) == 0 \
- && memcmp(&(ra)->path, &(rb)->path, sizeof(struct ospf6_path)) == 0 \
- && listcount(ra->paths) == listcount(rb->paths) \
- && ospf6_route_cmp_nexthops(ra, rb) == 0)
+ && (ra)->path.origin.type == (rb)->path.origin.type \
+ && (ra)->path.origin.id == (rb)->path.origin.id \
+ && (ra)->path.origin.adv_router == (rb)->path.origin.adv_router)
#define ospf6_route_is_best(r) (CHECK_FLAG ((r)->flag, OSPF6_ROUTE_BEST))
diff --git a/ospf6d/ospf6_snmp.c b/ospf6d/ospf6_snmp.c
index fb8c5d6950..1070474d0f 100644
--- a/ospf6d/ospf6_snmp.c
+++ b/ospf6d/ospf6_snmp.c
@@ -971,8 +971,7 @@ static uint8_t *ospfv3WwLsdbEntry(struct variable *v, oid *name, size_t *length,
for (ALL_LIST_ELEMENTS_RO(ifslist, node, iif)) {
if (!iif->ifindex)
continue;
- oi = ospf6_interface_lookup_by_ifindex(
- iif->ifindex, iif->vrf_id);
+ oi = iif->info;
if (!oi)
continue;
if (iif->ifindex < ifindex)
@@ -1106,8 +1105,7 @@ static uint8_t *ospfv3IfEntry(struct variable *v, oid *name, size_t *length,
for (ALL_LIST_ELEMENTS_RO(ifslist, i, iif)) {
if (!iif->ifindex)
continue;
- oi = ospf6_interface_lookup_by_ifindex(iif->ifindex,
- iif->vrf_id);
+ oi = iif->info;
if (!oi)
continue;
if (iif->ifindex > ifindex
@@ -1272,8 +1270,7 @@ static uint8_t *ospfv3NbrEntry(struct variable *v, oid *name, size_t *length,
for (ALL_LIST_ELEMENTS_RO(ifslist, i, iif)) {
if (!iif->ifindex)
continue;
- oi = ospf6_interface_lookup_by_ifindex(iif->ifindex,
- iif->vrf_id);
+ oi = iif->info;
if (!oi)
continue;
for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, j, on)) {
diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c
index 7e9ed4160d..6bff52fc56 100644
--- a/ospf6d/ospf6_top.c
+++ b/ospf6d/ospf6_top.c
@@ -423,7 +423,6 @@ static struct ospf6 *ospf6_create(const char *name)
* 1::1, this happened because of LS ID 0.
*/
o->external_id = OSPF6_EXT_INIT_LS_ID;
- o->external_id_table = route_table_init();
o->write_oi_count = OSPF6_WRITE_INTERFACE_COUNT_DEFAULT;
o->ref_bandwidth = OSPF6_REFERENCE_BANDWIDTH;
@@ -515,7 +514,6 @@ void ospf6_delete(struct ospf6 *o)
ospf6_route_table_delete(o->brouter_table);
ospf6_route_table_delete(o->external_table);
- route_table_finish(o->external_id_table);
ospf6_distance_reset(o);
route_table_finish(o->distance_table);
@@ -562,6 +560,8 @@ static void ospf6_disable(struct ospf6 *o)
THREAD_OFF(o->t_ospf6_receive);
THREAD_OFF(o->t_external_aggr);
THREAD_OFF(o->gr_info.t_grace_period);
+ THREAD_OFF(o->t_write);
+ THREAD_OFF(o->t_abr_task);
}
}
@@ -583,8 +583,6 @@ static int ospf6_maxage_remover(struct thread *thread)
struct listnode *i, *j, *k;
int reschedule = 0;
- o->maxage_remover = (struct thread *)NULL;
-
for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) {
for (ALL_LIST_ELEMENTS_RO(oa->if_list, j, oi)) {
for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, k, on)) {
@@ -1482,9 +1480,8 @@ DEFUN(show_ipv6_ospf6_vrfs, show_ipv6_ospf6_vrfs_cmd,
if (uj) {
json_object_int_add(json_vrf, "vrfId", vrf_id_ui);
- json_object_string_add(json_vrf, "routerId",
- inet_ntop(AF_INET, &router_id,
- buf, sizeof(buf)));
+ json_object_string_addf(json_vrf, "routerId", "%pI4",
+ &router_id);
json_object_object_add(json_vrfs, name, json_vrf);
} else {
@@ -1499,10 +1496,7 @@ DEFUN(show_ipv6_ospf6_vrfs, show_ipv6_ospf6_vrfs_cmd,
json_object_object_add(json, "vrfs", json_vrfs);
json_object_int_add(json, "totalVrfs", count);
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
} else {
if (count)
vty_out(vty, "\nTotal number of OSPF VRFs: %d\n",
@@ -2094,9 +2088,7 @@ DEFPY (show_ipv6_ospf6_external_aggregator,
}
if (uj) {
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
}
return CMD_SUCCESS;
@@ -2104,9 +2096,8 @@ DEFPY (show_ipv6_ospf6_external_aggregator,
static void ospf6_stub_router_config_write(struct vty *vty, struct ospf6 *ospf6)
{
- if (CHECK_FLAG(ospf6->flag, OSPF6_STUB_ROUTER)) {
+ if (CHECK_FLAG(ospf6->flag, OSPF6_STUB_ROUTER))
vty_out(vty, " stub-router administrative\n");
- }
return;
}
diff --git a/ospf6d/ospf6_top.h b/ospf6d/ospf6_top.h
index 55cab72307..4cc0923e93 100644
--- a/ospf6d/ospf6_top.h
+++ b/ospf6d/ospf6_top.h
@@ -136,7 +136,6 @@ struct ospf6 {
struct ospf6_route_table *brouter_table;
struct ospf6_route_table *external_table;
- struct route_table *external_id_table;
#define OSPF6_EXT_INIT_LS_ID 1
uint32_t external_id;
diff --git a/ospf6d/ospf6d.c b/ospf6d/ospf6d.c
index 5e6dcde991..d9f730586b 100644
--- a/ospf6d/ospf6d.c
+++ b/ospf6d/ospf6d.c
@@ -292,10 +292,7 @@ static void ospf6_lsdb_show_wrapper(struct vty *vty,
json_object_array_add(json_array, json_obj);
json_object_object_add(json, "asScopedLinkStateDb", json_array);
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
} else
vty_out(vty, "\n");
}
@@ -386,12 +383,9 @@ static void ospf6_lsdb_type_show_wrapper(struct vty *vty,
assert(0);
break;
}
- if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- } else
+ if (uj)
+ vty_json(vty, json);
+ else
vty_out(vty, "\n");
}