summaryrefslogtreecommitdiff
path: root/ospfd/ospf_vty.c
diff options
context:
space:
mode:
Diffstat (limited to 'ospfd/ospf_vty.c')
-rw-r--r--ospfd/ospf_vty.c109
1 files changed, 98 insertions, 11 deletions
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c
index 1a20eb515f..27cdce13c5 100644
--- a/ospfd/ospf_vty.c
+++ b/ospfd/ospf_vty.c
@@ -2218,6 +2218,56 @@ ALIAS(no_ospf_compatible_rfc1583, no_ospf_rfc1583_flag_cmd,
"OSPF specific commands\n"
"Disable the RFC1583Compatibility flag\n")
+static void ospf_table_reinstall_routes(struct ospf *ospf,
+ struct route_table *rt)
+{
+ struct route_node *rn;
+
+ if (!rt)
+ return;
+
+ for (rn = route_top(rt); rn; rn = route_next(rn)) {
+ struct ospf_route *or;
+
+ or = rn->info;
+ if (!or)
+ continue;
+
+ if (or->type == OSPF_DESTINATION_NETWORK)
+ ospf_zebra_add(ospf, (struct prefix_ipv4 *)&rn->p, or);
+ else if (or->type == OSPF_DESTINATION_DISCARD)
+ ospf_zebra_add_discard(ospf,
+ (struct prefix_ipv4 *)&rn->p);
+ }
+}
+
+static void ospf_reinstall_routes(struct ospf *ospf)
+{
+ ospf_table_reinstall_routes(ospf, ospf->new_table);
+ ospf_table_reinstall_routes(ospf, ospf->new_external_route);
+}
+
+DEFPY (ospf_send_extra_data,
+ ospf_send_extra_data_cmd,
+ "[no] ospf send-extra-data zebra",
+ NO_STR
+ OSPF_STR
+ "Extra data to Zebra for display/use\n"
+ "To zebra\n")
+{
+ VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
+
+ if (no && CHECK_FLAG(ospf->config, OSPF_SEND_EXTRA_DATA_TO_ZEBRA)) {
+ UNSET_FLAG(ospf->config, OSPF_SEND_EXTRA_DATA_TO_ZEBRA);
+ ospf_reinstall_routes(ospf);
+ } else if (!CHECK_FLAG(ospf->config, OSPF_SEND_EXTRA_DATA_TO_ZEBRA)) {
+ SET_FLAG(ospf->config, OSPF_SEND_EXTRA_DATA_TO_ZEBRA);
+ ospf_reinstall_routes(ospf);
+ }
+
+ return CMD_SUCCESS;
+}
+
static int ospf_timers_spf_set(struct vty *vty, unsigned int delay,
unsigned int hold, unsigned int max)
{
@@ -5892,7 +5942,7 @@ static int show_lsa_summary(struct vty *vty, struct ospf_lsa *lsa, int self,
struct as_external_lsa *asel;
struct prefix_ipv4 p;
- if (lsa != NULL)
+ if (lsa != NULL) {
/* If self option is set, check LSA self flag. */
if (self == 0 || IS_LSA_SELF(lsa)) {
@@ -6000,6 +6050,9 @@ static int show_lsa_summary(struct vty *vty, struct ospf_lsa *lsa, int self,
vty_out(vty, "\n");
}
+ return 1;
+ }
+
return 0;
}
@@ -6033,6 +6086,21 @@ static const char * const show_database_desc_json[] = {
"asExternalOpaqueLsa",
};
+static const char *const show_database_desc_count_json[] = {
+ "unknownCount",
+ "routerLinkStatesCount",
+ "networkLinkStatesCount",
+ "summaryLinkStatesCount",
+ "asbrSummaryLinkStatesCount",
+ "asExternalLinkStatesCount",
+ "groupMembershipLsaCount",
+ "nssaExternalLinkStatesCount",
+ "type8LsaCount",
+ "linkLocalOpaqueLsaCount",
+ "areaLocalOpaqueLsaCount",
+ "asExternalOpaqueLsaCount",
+};
+
static const char *const show_database_header[] = {
"",
"Link ID ADV Router Age Seq# CkSum Link count",
@@ -6705,6 +6773,7 @@ void show_ip_ospf_database_summary(struct vty *vty, struct ospf *ospf, int self,
json_object *json_lsa = NULL;
int type;
json_object *json_lsa_array = NULL;
+ uint32_t count;
if (json)
json_areas = json_object_new_object();
@@ -6714,6 +6783,7 @@ void show_ip_ospf_database_summary(struct vty *vty, struct ospf *ospf, int self,
json_area = json_object_new_object();
for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) {
+ count = 0;
switch (type) {
case OSPF_AS_EXTERNAL_LSA:
case OSPF_OPAQUE_AS_LSA:
@@ -6750,12 +6820,19 @@ void show_ip_ospf_database_summary(struct vty *vty, struct ospf *ospf, int self,
json_lsa);
}
- show_lsa_summary(vty, lsa, self,
- json_lsa);
+ count += show_lsa_summary(
+ vty, lsa, self, json_lsa);
}
if (!json)
vty_out(vty, "\n");
+ else
+ json_object_int_add(
+ json_area,
+
+ show_database_desc_count_json
+ [type],
+ count);
}
}
if (json)
@@ -6770,6 +6847,7 @@ void show_ip_ospf_database_summary(struct vty *vty, struct ospf *ospf, int self,
json_object_object_add(json, "areas", json_areas);
for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) {
+ count = 0;
switch (type) {
case OSPF_AS_EXTERNAL_LSA:
case OSPF_OPAQUE_AS_LSA:
@@ -6798,11 +6876,17 @@ void show_ip_ospf_database_summary(struct vty *vty, struct ospf *ospf, int self,
json_lsa);
}
- show_lsa_summary(vty, lsa, self, json_lsa);
+ count += show_lsa_summary(vty, lsa, self,
+ json_lsa);
}
if (!json)
vty_out(vty, "\n");
+ else
+ json_object_int_add(
+ json,
+ show_database_desc_count_json[type],
+ count);
}
}
@@ -11535,12 +11619,8 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf)
if (memcmp(ifp->name, "VLINK", 5) == 0)
continue;
- vty_frame(vty, "!\n");
- if (ifp->vrf->vrf_id == VRF_DEFAULT)
- vty_frame(vty, "interface %s\n", ifp->name);
- else
- vty_frame(vty, "interface %s vrf %s\n", ifp->name,
- vrf->name);
+ if_vty_config_start(vty, ifp);
+
if (ifp->desc)
vty_out(vty, " description %s\n", ifp->desc);
@@ -11750,7 +11830,7 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf)
ospf_opaque_config_write_if(vty, ifp);
- vty_endframe(vty, "exit\n!\n");
+ if_vty_config_end(vty);
}
return write;
@@ -12212,6 +12292,10 @@ static int ospf_config_write_one(struct vty *vty, struct ospf *ospf)
vty_out(vty, " ospf router-id %pI4\n",
&ospf->router_id_static);
+ /* zebra opaque attributes configuration. */
+ if (!CHECK_FLAG(ospf->config, OSPF_SEND_EXTRA_DATA_TO_ZEBRA))
+ vty_out(vty, " no ospf send-extra-data zebra\n");
+
/* ABR type print. */
if (ospf->abr_type != OSPF_ABR_DEFAULT)
vty_out(vty, " ospf abr-type %s\n",
@@ -12663,6 +12747,9 @@ void ospf_vty_init(void)
install_element(OSPF_NODE, &ospf_rfc1583_flag_cmd);
install_element(OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
+ /* "ospf send-extra-data zebra" commands. */
+ install_element(OSPF_NODE, &ospf_send_extra_data_cmd);
+
/* "network area" commands. */
install_element(OSPF_NODE, &ospf_network_area_cmd);
install_element(OSPF_NODE, &no_ospf_network_area_cmd);