mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-16 13:41:46 +00:00
pbrd: json added to show pbr interface [json]
Signed-off-by: Wesley Coakley <wcoakley@cumulusnetworks.com>
This commit is contained in:
parent
eeec40ba69
commit
7a7b0c13f9
@ -27,6 +27,7 @@
|
|||||||
#include "nexthop_group.h"
|
#include "nexthop_group.h"
|
||||||
#include "nexthop_group_private.h"
|
#include "nexthop_group_private.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
#include "json.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "pbr.h"
|
#include "pbr.h"
|
||||||
|
|
||||||
@ -638,19 +639,28 @@ DEFPY(show_pbr_nexthop_group,
|
|||||||
|
|
||||||
DEFPY (show_pbr_interface,
|
DEFPY (show_pbr_interface,
|
||||||
show_pbr_interface_cmd,
|
show_pbr_interface_cmd,
|
||||||
"show pbr interface [NAME$name]",
|
"show pbr interface [NAME$name] [json$json]",
|
||||||
SHOW_STR
|
SHOW_STR
|
||||||
PBR_STR
|
PBR_STR
|
||||||
"PBR Interface\n"
|
"PBR Interface\n"
|
||||||
"PBR Interface Name\n")
|
"PBR Interface Name\n"
|
||||||
|
JSON_STR)
|
||||||
{
|
{
|
||||||
struct interface *ifp;
|
struct interface *ifp;
|
||||||
struct vrf *vrf;
|
struct vrf *vrf;
|
||||||
struct pbr_interface *pbr_ifp;
|
struct pbr_interface *pbr_ifp;
|
||||||
|
json_object *j = NULL;
|
||||||
|
|
||||||
|
if (json)
|
||||||
|
j = json_object_new_object();
|
||||||
|
|
||||||
RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name) {
|
RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name) {
|
||||||
FOR_ALL_INTERFACES(vrf, ifp) {
|
FOR_ALL_INTERFACES(vrf, ifp) {
|
||||||
struct pbr_map *pbrm;
|
struct pbr_map *pbrm;
|
||||||
|
json_object *this_iface = NULL;
|
||||||
|
|
||||||
|
if (j)
|
||||||
|
this_iface = json_object_new_object();
|
||||||
|
|
||||||
if (!ifp->info)
|
if (!ifp->info)
|
||||||
continue;
|
continue;
|
||||||
@ -664,6 +674,22 @@ DEFPY (show_pbr_interface,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
pbrm = pbrm_find(pbr_ifp->mapname);
|
pbrm = pbrm_find(pbr_ifp->mapname);
|
||||||
|
|
||||||
|
if (this_iface) {
|
||||||
|
json_object_string_add(this_iface, "name",
|
||||||
|
ifp->name);
|
||||||
|
json_object_int_add(this_iface, "index",
|
||||||
|
ifp->ifindex);
|
||||||
|
json_object_string_add(this_iface, "policy",
|
||||||
|
pbr_ifp->mapname);
|
||||||
|
json_object_boolean_add(this_iface, "valid",
|
||||||
|
pbrm);
|
||||||
|
|
||||||
|
json_object_object_add(j, ifp->name,
|
||||||
|
this_iface);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
vty_out(vty, " %s(%d) with pbr-policy %s", ifp->name,
|
vty_out(vty, " %s(%d) with pbr-policy %s", ifp->name,
|
||||||
ifp->ifindex, pbr_ifp->mapname);
|
ifp->ifindex, pbr_ifp->mapname);
|
||||||
if (!pbrm)
|
if (!pbrm)
|
||||||
@ -672,6 +698,13 @@ DEFPY (show_pbr_interface,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (j) {
|
||||||
|
vty_out(vty, "%s\n",
|
||||||
|
json_object_to_json_string_ext(
|
||||||
|
j, JSON_C_TO_STRING_PRETTY));
|
||||||
|
json_object_free(j);
|
||||||
|
}
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user