summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2021-10-07 21:06:01 -0300
committerRenato Westphal <renato@opensourcerouting.org>2021-10-08 10:03:01 -0300
commit3e63092b83c6710dd978b705537a2bb8c586ea8b (patch)
tree17304c3f72ab98edab9b843f52b36246ecf613b0
parenta792fa7b150831c1d2f70ddae580e6fc38a51ab0 (diff)
ospfd: fix display of plain-text data on "show ... json" commands
Add a 'json' parameter to the 'show_opaque_info' callback definition, and update all instances of that callback to not display plain-text data when the user requested JSON data. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
-rw-r--r--ospfd/ospf_apiserver.c6
-rw-r--r--ospfd/ospf_apiserver.h3
-rw-r--r--ospfd/ospf_ext.c18
-rw-r--r--ospfd/ospf_gr_helper.c9
-rw-r--r--ospfd/ospf_opaque.c8
-rw-r--r--ospfd/ospf_opaque.h3
-rw-r--r--ospfd/ospf_ri.c11
-rw-r--r--ospfd/ospf_te.c9
8 files changed, 51 insertions, 16 deletions
diff --git a/ospfd/ospf_apiserver.c b/ospfd/ospf_apiserver.c
index cbd03441ef..a33ca95777 100644
--- a/ospfd/ospf_apiserver.c
+++ b/ospfd/ospf_apiserver.c
@@ -2059,7 +2059,8 @@ void ospf_apiserver_nsm_change(struct ospf_neighbor *nbr, int old_status)
}
}
-void ospf_apiserver_show_info(struct vty *vty, struct ospf_lsa *lsa)
+void ospf_apiserver_show_info(struct vty *vty, struct json_object *json,
+ struct ospf_lsa *lsa)
{
struct opaque_lsa {
struct lsa_header header;
@@ -2070,6 +2071,9 @@ void ospf_apiserver_show_info(struct vty *vty, struct ospf_lsa *lsa)
struct opaque_lsa *olsa;
int opaquelen;
+ if (json)
+ return;
+
olsa = (struct opaque_lsa *)lsa->data;
if (VALID_OPAQUE_INFO_LEN(lsa->data))
diff --git a/ospfd/ospf_apiserver.h b/ospfd/ospf_apiserver.h
index 89a9474972..544a32a28c 100644
--- a/ospfd/ospf_apiserver.h
+++ b/ospfd/ospf_apiserver.h
@@ -182,7 +182,8 @@ extern void ospf_apiserver_nsm_change(struct ospf_neighbor *nbr,
extern void ospf_apiserver_config_write_router(struct vty *vty);
extern void ospf_apiserver_config_write_if(struct vty *vty,
struct interface *ifp);
-extern void ospf_apiserver_show_info(struct vty *vty, struct ospf_lsa *lsa);
+extern void ospf_apiserver_show_info(struct vty *vty, struct json_object *json,
+ struct ospf_lsa *lsa);
extern int ospf_ospf_apiserver_lsa_originator(void *arg);
extern struct ospf_lsa *ospf_apiserver_lsa_refresher(struct ospf_lsa *lsa);
extern void ospf_apiserver_flush_opaque_lsa(struct ospf_apiserver *apiserv,
diff --git a/ospfd/ospf_ext.c b/ospfd/ospf_ext.c
index 2d08eeece2..ea1506ea27 100644
--- a/ospfd/ospf_ext.c
+++ b/ospfd/ospf_ext.c
@@ -80,7 +80,8 @@ static struct ospf_ext_lp OspfEXT;
*/
/* Extended Prefix Opaque LSA related callback functions */
-static void ospf_ext_pref_show_info(struct vty *vty, struct ospf_lsa *lsa);
+static void ospf_ext_pref_show_info(struct vty *vty, struct json_object *json,
+ struct ospf_lsa *lsa);
static int ospf_ext_pref_lsa_originate(void *arg);
static struct ospf_lsa *ospf_ext_pref_lsa_refresh(struct ospf_lsa *lsa);
static void ospf_ext_pref_lsa_schedule(struct ext_itf *exti,
@@ -90,7 +91,8 @@ static int ospf_ext_link_new_if(struct interface *ifp);
static int ospf_ext_link_del_if(struct interface *ifp);
static void ospf_ext_ism_change(struct ospf_interface *oi, int old_status);
static void ospf_ext_link_nsm_change(struct ospf_neighbor *nbr, int old_status);
-static void ospf_ext_link_show_info(struct vty *vty, struct ospf_lsa *lsa);
+static void ospf_ext_link_show_info(struct vty *vty, struct json_object *json,
+ struct ospf_lsa *lsa);
static int ospf_ext_link_lsa_originate(void *arg);
static struct ospf_lsa *ospf_ext_link_lsa_refresh(struct ospf_lsa *lsa);
static void ospf_ext_link_lsa_schedule(struct ext_itf *exti,
@@ -1846,12 +1848,16 @@ static uint16_t show_vty_link_info(struct vty *vty, struct tlv_header *ext,
}
/* Extended Link TLVs */
-static void ospf_ext_link_show_info(struct vty *vty, struct ospf_lsa *lsa)
+static void ospf_ext_link_show_info(struct vty *vty, struct json_object *json,
+ struct ospf_lsa *lsa)
{
struct lsa_header *lsah = lsa->data;
struct tlv_header *tlvh;
uint16_t length = 0, sum = 0;
+ if (json)
+ return;
+
/* Initialize TLV browsing */
length = lsa->size - OSPF_LSA_HEADER_SIZE;
@@ -1932,12 +1938,16 @@ static uint16_t show_vty_pref_info(struct vty *vty, struct tlv_header *ext,
}
/* Extended Prefix TLVs */
-static void ospf_ext_pref_show_info(struct vty *vty, struct ospf_lsa *lsa)
+static void ospf_ext_pref_show_info(struct vty *vty, struct json_object *json,
+ struct ospf_lsa *lsa)
{
struct lsa_header *lsah = lsa->data;
struct tlv_header *tlvh;
uint16_t length = 0, sum = 0;
+ if (json)
+ return;
+
/* Initialize TLV browsing */
length = lsa->size - OSPF_LSA_HEADER_SIZE;
diff --git a/ospfd/ospf_gr_helper.c b/ospfd/ospf_gr_helper.c
index b3eaf7bbdb..a58a120b6b 100644
--- a/ospfd/ospf_gr_helper.c
+++ b/ospfd/ospf_gr_helper.c
@@ -75,7 +75,8 @@ static const char * const ospf_rejected_reason_desc[] = {
"Router is in the process of graceful restart",
};
-static void show_ospf_grace_lsa_info(struct vty *vty, struct ospf_lsa *lsa);
+static void show_ospf_grace_lsa_info(struct vty *vty, struct json_object *json,
+ struct ospf_lsa *lsa);
static bool ospf_check_change_in_rxmt_list(struct ospf_neighbor *nbr);
static unsigned int ospf_enable_rtr_hash_key(const void *data)
@@ -1012,7 +1013,8 @@ void ospf_gr_helper_set_supported_planned_only_restart(struct ospf *ospf,
* Returns:
* Nothing.
*/
-static void show_ospf_grace_lsa_info(struct vty *vty, struct ospf_lsa *lsa)
+static void show_ospf_grace_lsa_info(struct vty *vty, struct json_object *json,
+ struct ospf_lsa *lsa)
{
struct lsa_header *lsah = NULL;
struct tlv_header *tlvh = NULL;
@@ -1022,6 +1024,9 @@ static void show_ospf_grace_lsa_info(struct vty *vty, struct ospf_lsa *lsa)
uint16_t length = 0;
int sum = 0;
+ if (json)
+ return;
+
lsah = (struct lsa_header *)lsa->data;
if (lsa->size <= OSPF_LSA_HEADER_SIZE) {
diff --git a/ospfd/ospf_opaque.c b/ospfd/ospf_opaque.c
index 955d9168c4..a89e90bf70 100644
--- a/ospfd/ospf_opaque.c
+++ b/ospfd/ospf_opaque.c
@@ -274,7 +274,8 @@ struct ospf_opaque_functab {
void (*config_write_router)(struct vty *vty);
void (*config_write_if)(struct vty *vty, struct interface *ifp);
void (*config_write_debug)(struct vty *vty);
- void (*show_opaque_info)(struct vty *vty, struct ospf_lsa *lsa);
+ void (*show_opaque_info)(struct vty *vty, struct json_object *json,
+ struct ospf_lsa *lsa);
int (*lsa_originator)(void *arg);
struct ospf_lsa *(*lsa_refresher)(struct ospf_lsa *lsa);
int (*new_lsa_hook)(struct ospf_lsa *lsa);
@@ -373,7 +374,8 @@ int ospf_register_opaque_functab(
void (*config_write_router)(struct vty *vty),
void (*config_write_if)(struct vty *vty, struct interface *ifp),
void (*config_write_debug)(struct vty *vty),
- void (*show_opaque_info)(struct vty *vty, struct ospf_lsa *lsa),
+ void (*show_opaque_info)(struct vty *vty, struct json_object *json,
+ struct ospf_lsa *lsa),
int (*lsa_originator)(void *arg),
struct ospf_lsa *(*lsa_refresher)(struct ospf_lsa *lsa),
int (*new_lsa_hook)(struct ospf_lsa *lsa),
@@ -1207,7 +1209,7 @@ void show_opaque_info_detail(struct vty *vty, struct ospf_lsa *lsa,
/* Call individual output functions. */
if ((functab = ospf_opaque_functab_lookup(lsa)) != NULL)
if (functab->show_opaque_info != NULL)
- (*functab->show_opaque_info)(vty, lsa);
+ (*functab->show_opaque_info)(vty, json, lsa);
return;
}
diff --git a/ospfd/ospf_opaque.h b/ospfd/ospf_opaque.h
index 7d401c3dcc..bded32215b 100644
--- a/ospfd/ospf_opaque.h
+++ b/ospfd/ospf_opaque.h
@@ -136,7 +136,8 @@ extern int ospf_register_opaque_functab(
void (*config_write_router)(struct vty *vty),
void (*config_write_if)(struct vty *vty, struct interface *ifp),
void (*config_write_debug)(struct vty *vty),
- void (*show_opaque_info)(struct vty *vty, struct ospf_lsa *lsa),
+ void (*show_opaque_info)(struct vty *vty, struct json_object *json,
+ struct ospf_lsa *lsa),
int (*lsa_originator)(void *arg),
struct ospf_lsa *(*lsa_refresher)(struct ospf_lsa *lsa),
int (*new_lsa_hook)(struct ospf_lsa *lsa),
diff --git a/ospfd/ospf_ri.c b/ospfd/ospf_ri.c
index 602f98d141..0efa6ca4d5 100644
--- a/ospfd/ospf_ri.c
+++ b/ospfd/ospf_ri.c
@@ -73,7 +73,9 @@ static struct ospf_router_info OspfRI;
static void ospf_router_info_ism_change(struct ospf_interface *oi,
int old_status);
static void ospf_router_info_config_write_router(struct vty *vty);
-static void ospf_router_info_show_info(struct vty *vty, struct ospf_lsa *lsa);
+static void ospf_router_info_show_info(struct vty *vty,
+ struct json_object *json,
+ struct ospf_lsa *lsa);
static int ospf_router_info_lsa_originate(void *arg);
static struct ospf_lsa *ospf_router_info_lsa_refresh(struct ospf_lsa *lsa);
static void ospf_router_info_lsa_schedule(struct ospf_ri_area_info *ai,
@@ -1552,12 +1554,17 @@ static uint16_t show_vty_sr_msd(struct vty *vty, struct tlv_header *tlvh)
return TLV_SIZE(tlvh);
}
-static void ospf_router_info_show_info(struct vty *vty, struct ospf_lsa *lsa)
+static void ospf_router_info_show_info(struct vty *vty,
+ struct json_object *json,
+ struct ospf_lsa *lsa)
{
struct lsa_header *lsah = lsa->data;
struct tlv_header *tlvh;
uint16_t length = 0, sum = 0;
+ if (json)
+ return;
+
/* Initialize TLV browsing */
length = lsa->size - OSPF_LSA_HEADER_SIZE;
diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c
index d95e677f6f..03fa572859 100644
--- a/ospfd/ospf_te.c
+++ b/ospfd/ospf_te.c
@@ -87,7 +87,8 @@ static int ospf_mpls_te_del_if(struct interface *ifp);
static void ospf_mpls_te_ism_change(struct ospf_interface *oi, int old_status);
static void ospf_mpls_te_nsm_change(struct ospf_neighbor *nbr, int old_status);
static void ospf_mpls_te_config_write_router(struct vty *vty);
-static void ospf_mpls_te_show_info(struct vty *vty, struct ospf_lsa *lsa);
+static void ospf_mpls_te_show_info(struct vty *vty, struct json_object *json,
+ struct ospf_lsa *lsa);
static int ospf_mpls_te_lsa_originate_area(void *arg);
static int ospf_mpls_te_lsa_inter_as_as(void *arg);
static int ospf_mpls_te_lsa_inter_as_area(void *arg);
@@ -3783,7 +3784,8 @@ static uint16_t ospf_mpls_te_show_link_subtlv(struct vty *vty,
return sum;
}
-static void ospf_mpls_te_show_info(struct vty *vty, struct ospf_lsa *lsa)
+static void ospf_mpls_te_show_info(struct vty *vty, struct json_object *json,
+ struct ospf_lsa *lsa)
{
struct lsa_header *lsah = lsa->data;
struct tlv_header *tlvh, *next;
@@ -3791,6 +3793,9 @@ static void ospf_mpls_te_show_info(struct vty *vty, struct ospf_lsa *lsa)
uint16_t (*subfunc)(struct vty * vty, struct tlv_header * tlvh,
uint16_t subtotal, uint16_t total) = NULL;
+ if (json)
+ return;
+
sum = 0;
total = lsa->size - OSPF_LSA_HEADER_SIZE;