Skip to content

Commit

Permalink
Merge pull request #13576 from chiragshah6/mdev1
Browse files Browse the repository at this point in the history
zebra:returns empty dict when evpn is disabled II
  • Loading branch information
ton31337 authored Oct 30, 2023
2 parents f969bc0 + 28eaac0 commit 73914a3
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 57 deletions.
9 changes: 6 additions & 3 deletions lib/vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,11 +383,14 @@ int vty_json_no_pretty(struct vty *vty, struct json_object *json)
return vty_json_helper(vty, json, JSON_C_TO_STRING_NOSLASHESCAPE);
}

void vty_json_empty(struct vty *vty)
void vty_json_empty(struct vty *vty, struct json_object *json)
{
json_object *json = json_object_new_object();
json_object *jsonobj = json;

vty_json(vty, json);
if (!json)
jsonobj = json_object_new_object();

vty_json(vty, jsonobj);
}

/* Output current time to the vty. */
Expand Down
2 changes: 1 addition & 1 deletion lib/vty.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ extern bool vty_set_include(struct vty *vty, const char *regexp);
*/
extern int vty_json(struct vty *vty, struct json_object *json);
extern int vty_json_no_pretty(struct vty *vty, struct json_object *json);
extern void vty_json_empty(struct vty *vty);
extern void vty_json_empty(struct vty *vty, struct json_object *json);
/* post fd to be passed to the vtysh client
* fd is owned by the VTY code after this and will be closed when done
*/
Expand Down
8 changes: 4 additions & 4 deletions ospfd/ospf_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -5709,7 +5709,7 @@ DEFPY(show_ip_ospf_neighbor_id,
"%% OSPF is not enabled in vrf %s\n",
vrf_name);
else
vty_json_empty(vty);
vty_json_empty(vty, NULL);
return CMD_SUCCESS;
}
ret = show_ip_ospf_neighbor_id_common(
Expand Down Expand Up @@ -6210,7 +6210,7 @@ DEFPY(show_ip_ospf_neighbor_int,

if (!ospf || !ospf->oi_running) {
if (json)
vty_json_empty(vty);
vty_json_empty(vty, NULL);
return ret;
}

Expand All @@ -6220,7 +6220,7 @@ DEFPY(show_ip_ospf_neighbor_int,
ifp = if_lookup_by_name(ifname, vrf_id);
if (!ifp) {
if (json)
vty_json_empty(vty);
vty_json_empty(vty, NULL);
else
vty_out(vty, "No such interface.\n");
return ret;
Expand Down Expand Up @@ -6257,7 +6257,7 @@ DEFPY(show_ip_ospf_neighbor_int_detail,
"%% OSPF is not enabled in vrf %s\n",
vrf_name);
else
vty_json_empty(vty);
vty_json_empty(vty, NULL);
return CMD_SUCCESS;
}
return show_ip_ospf_neighbor_int_detail_common(
Expand Down
2 changes: 1 addition & 1 deletion pimd/pim_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static struct vrf *pim_cmd_lookup_vrf(struct vty *vty, struct cmd_token *argv[],

if (!vrf) {
if (uj)
vty_json_empty(vty);
vty_json_empty(vty, NULL);
else
vty_out(vty, "Specified VRF: %s does not exist\n",
argv[*idx]->arg);
Expand Down
Loading

0 comments on commit 73914a3

Please sign in to comment.