mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-15 05:18:47 +00:00
ospfd: add oi to show ip ospf interface json
Currently "show ip ospf interface json" will walk all oi's bound to a given interface, but every oi overwrites the same json keys. This adds a new hierarchy to the json output which will allow each oi to have its info displayed separately (instead of stomping on each other). Before: ``` tor-11# show ip ospf interface swp2 json { "interfaces":{ "swp2":{ "ifUp":true, "ifIndex":4, "mtuBytes":9216, "bandwidthMbit":10000, "ifFlags":"<UP,BROADCAST,RUNNING,MULTICAST>", "ospfEnabled":true, "ipAddress":"100.64.3.15", "ipAddressPrefixlen":24, "ospfIfType":"Broadcast", "localIfUsed":"100.64.3.255", "area":"0.0.0.1", "routerId":"6.0.0.15", "networkType":"NBMA", "cost":10, "transmitDelaySecs":1, "state":"Backup", "priority":100, "bdrId":"6.0.0.15", "bdrAddress":"100.64.3.15", "mcastMemberOspfAllRouters":true, "timerMsecs":10000, "timerDeadSecs":40, "timerWaitSecs":40, "timerRetransmitSecs":5, "timerHelloInMsecs":2502, "nbrCount":1, "nbrAdjacentCount":1 } } } ``` After: ``` leaf-12# show ip ospf interface swp3 json { "interfaces":{ "swp3":{ "ifUp":true, "ifIndex":5, "mtuBytes":9216, "bandwidthMbit":10000, "ifFlags":"<UP,BROADCAST,RUNNING,MULTICAST>", "ospfEnabled":true, "interfaceIp":{ "100.64.2.6":{ "ipAddress":"100.64.2.6", "ipAddressPrefixlen":24, "ospfIfType":"Broadcast", "localIfUsed":"100.64.2.255", "area":"0.0.0.0", "routerId":"6.0.0.6", "networkType":"NBMA", "cost":10, "transmitDelaySecs":1, "state":"DR", "priority":2, "bdrId":"6.0.0.15", "bdrAddress":"100.64.2.15", "networkLsaSequence":2147483652, "mcastMemberOspfAllRouters":true, "timerMsecs":10000, "timerDeadSecs":40, "timerWaitSecs":40, "timerRetransmitSecs":5, "timerHelloInMsecs":1559, "nbrCount":1, "nbrAdjacentCount":1 }, "100.64.3.6":{ "ipAddress":"100.64.3.6", "ipAddressPrefixlen":24, "ospfIfType":"Broadcast", "localIfUsed":"100.64.3.255", "area":"0.0.0.1", "routerId":"6.0.0.6", "networkType":"NBMA", "cost":10, "transmitDelaySecs":1, "state":"DR", "priority":222, "bdrId":"6.0.0.15", "bdrAddress":"100.64.3.15", "networkLsaSequence":2147483651, "mcastMemberOspfAllRouters":true, "timerMsecs":10000, "timerDeadSecs":40, "timerWaitSecs":40, "timerRetransmitSecs":5, "timerHelloInMsecs":1559, "nbrCount":1, "nbrAdjacentCount":1 } } } } } ``` Signed-off-by: Trey Aspelund <taspelund@nvidia.com>
This commit is contained in:
parent
254feba0a5
commit
72eab6953d
105
ospfd/ospf_vty.c
105
ospfd/ospf_vty.c
@ -3621,6 +3621,8 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,
|
|||||||
struct route_node *rn;
|
struct route_node *rn;
|
||||||
uint32_t bandwidth = ifp->bandwidth ? ifp->bandwidth : ifp->speed;
|
uint32_t bandwidth = ifp->bandwidth ? ifp->bandwidth : ifp->speed;
|
||||||
struct ospf_if_params *params;
|
struct ospf_if_params *params;
|
||||||
|
json_object *json_ois = NULL;
|
||||||
|
json_object *json_oi = NULL;
|
||||||
|
|
||||||
/* Is interface up? */
|
/* Is interface up? */
|
||||||
if (use_json) {
|
if (use_json) {
|
||||||
@ -3671,15 +3673,23 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (use_json) {
|
||||||
|
json_ois = json_object_new_object();
|
||||||
|
json_object_object_add(json_interface_sub, "interfaceIp",
|
||||||
|
json_ois);
|
||||||
|
}
|
||||||
|
|
||||||
for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next(rn)) {
|
for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next(rn)) {
|
||||||
struct ospf_interface *oi = rn->info;
|
struct ospf_interface *oi = rn->info;
|
||||||
|
|
||||||
if (oi == NULL)
|
if (oi == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
json_oi = json_object_new_object();
|
||||||
|
|
||||||
if (CHECK_FLAG(oi->connected->flags, ZEBRA_IFA_UNNUMBERED)) {
|
if (CHECK_FLAG(oi->connected->flags, ZEBRA_IFA_UNNUMBERED)) {
|
||||||
if (use_json)
|
if (use_json)
|
||||||
json_object_boolean_true_add(json_interface_sub,
|
json_object_boolean_true_add(json_oi,
|
||||||
"ifUnnumbered");
|
"ifUnnumbered");
|
||||||
else
|
else
|
||||||
vty_out(vty, " This interface is UNNUMBERED,");
|
vty_out(vty, " This interface is UNNUMBERED,");
|
||||||
@ -3690,9 +3700,9 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,
|
|||||||
/* Show OSPF interface information. */
|
/* Show OSPF interface information. */
|
||||||
if (use_json) {
|
if (use_json) {
|
||||||
json_object_string_addf(
|
json_object_string_addf(
|
||||||
json_interface_sub, "ipAddress", "%pI4",
|
json_oi, "ipAddress", "%pI4",
|
||||||
&oi->address->u.prefix4);
|
&oi->address->u.prefix4);
|
||||||
json_object_int_add(json_interface_sub,
|
json_object_int_add(json_oi,
|
||||||
"ipAddressPrefixlen",
|
"ipAddressPrefixlen",
|
||||||
oi->address->prefixlen);
|
oi->address->prefixlen);
|
||||||
} else
|
} else
|
||||||
@ -3717,43 +3727,37 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (use_json) {
|
if (use_json) {
|
||||||
json_object_string_add(
|
json_object_string_add(json_oi, "ospfIfType",
|
||||||
json_interface_sub,
|
dstr);
|
||||||
"ospfIfType", dstr);
|
|
||||||
if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
|
if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
|
||||||
json_object_string_addf(
|
json_object_string_addf(json_oi,
|
||||||
json_interface_sub, "vlinkPeer",
|
"vlinkPeer",
|
||||||
"%pI4", &dest);
|
"%pI4", &dest);
|
||||||
else
|
else
|
||||||
json_object_string_addf(
|
json_object_string_addf(json_oi,
|
||||||
json_interface_sub,
|
"localIfUsed",
|
||||||
"localIfUsed", "%pI4", &dest);
|
"%pI4", &dest);
|
||||||
} else
|
} else
|
||||||
vty_out(vty, " %s %pI4,", dstr,
|
vty_out(vty, " %s %pI4,", dstr,
|
||||||
&dest);
|
&dest);
|
||||||
}
|
}
|
||||||
if (use_json) {
|
if (use_json) {
|
||||||
json_object_string_add(json_interface_sub, "area",
|
json_object_string_add(json_oi, "area",
|
||||||
ospf_area_desc_string(oi->area));
|
ospf_area_desc_string(oi->area));
|
||||||
if (OSPF_IF_PARAM(oi, mtu_ignore))
|
if (OSPF_IF_PARAM(oi, mtu_ignore))
|
||||||
json_object_boolean_true_add(
|
json_object_boolean_true_add(
|
||||||
json_interface_sub,
|
json_oi, "mtuMismatchDetect");
|
||||||
"mtuMismatchDetect");
|
json_object_string_addf(json_oi, "routerId", "%pI4",
|
||||||
json_object_string_addf(json_interface_sub, "routerId",
|
&ospf->router_id);
|
||||||
"%pI4", &ospf->router_id);
|
json_object_string_add(json_oi, "networkType",
|
||||||
json_object_string_add(json_interface_sub,
|
|
||||||
"networkType",
|
|
||||||
ospf_network_type_str[oi->type]);
|
ospf_network_type_str[oi->type]);
|
||||||
json_object_int_add(json_interface_sub, "cost",
|
json_object_int_add(json_oi, "cost", oi->output_cost);
|
||||||
oi->output_cost);
|
json_object_int_add(json_oi, "transmitDelaySecs",
|
||||||
json_object_int_add(
|
OSPF_IF_PARAM(oi, transmit_delay));
|
||||||
json_interface_sub, "transmitDelaySecs",
|
json_object_string_add(json_oi, "state",
|
||||||
OSPF_IF_PARAM(oi, transmit_delay));
|
|
||||||
json_object_string_add(json_interface_sub, "state",
|
|
||||||
lookup_msg(ospf_ism_state_msg,
|
lookup_msg(ospf_ism_state_msg,
|
||||||
oi->state, NULL));
|
oi->state, NULL));
|
||||||
json_object_int_add(json_interface_sub, "priority",
|
json_object_int_add(json_oi, "priority", PRIORITY(oi));
|
||||||
PRIORITY(oi));
|
|
||||||
} else {
|
} else {
|
||||||
vty_out(vty, " Area %s\n",
|
vty_out(vty, " Area %s\n",
|
||||||
ospf_area_desc_string(oi->area));
|
ospf_area_desc_string(oi->area));
|
||||||
@ -3810,11 +3814,10 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,
|
|||||||
} else {
|
} else {
|
||||||
if (use_json) {
|
if (use_json) {
|
||||||
json_object_string_addf(
|
json_object_string_addf(
|
||||||
json_interface_sub, "bdrId",
|
json_oi, "bdrId", "%pI4",
|
||||||
"%pI4", &nbr->router_id);
|
&nbr->router_id);
|
||||||
json_object_string_addf(
|
json_object_string_addf(
|
||||||
json_interface_sub,
|
json_oi, "bdrAddress", "%pI4",
|
||||||
"bdrAddress", "%pI4",
|
|
||||||
&nbr->address.u.prefix4);
|
&nbr->address.u.prefix4);
|
||||||
} else {
|
} else {
|
||||||
vty_out(vty,
|
vty_out(vty,
|
||||||
@ -3833,8 +3836,7 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,
|
|||||||
!= OSPF_INITIAL_SEQUENCE_NUMBER) {
|
!= OSPF_INITIAL_SEQUENCE_NUMBER) {
|
||||||
if (use_json)
|
if (use_json)
|
||||||
json_object_int_add(
|
json_object_int_add(
|
||||||
json_interface_sub,
|
json_oi, "networkLsaSequence",
|
||||||
"networkLsaSequence",
|
|
||||||
ntohl(oi->params->network_lsa_seqnum));
|
ntohl(oi->params->network_lsa_seqnum));
|
||||||
else
|
else
|
||||||
vty_out(vty,
|
vty_out(vty,
|
||||||
@ -3847,11 +3849,11 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,
|
|||||||
|| OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) {
|
|| OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) {
|
||||||
if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS))
|
if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS))
|
||||||
json_object_boolean_true_add(
|
json_object_boolean_true_add(
|
||||||
json_interface_sub,
|
json_oi,
|
||||||
"mcastMemberOspfAllRouters");
|
"mcastMemberOspfAllRouters");
|
||||||
if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
|
if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
|
||||||
json_object_boolean_true_add(
|
json_object_boolean_true_add(
|
||||||
json_interface_sub,
|
json_oi,
|
||||||
"mcastMemberOspfDesignatedRouters");
|
"mcastMemberOspfDesignatedRouters");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -3869,21 +3871,19 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,
|
|||||||
|
|
||||||
if (use_json) {
|
if (use_json) {
|
||||||
if (OSPF_IF_PARAM(oi, fast_hello) == 0)
|
if (OSPF_IF_PARAM(oi, fast_hello) == 0)
|
||||||
json_object_int_add(
|
json_object_int_add(json_oi, "timerMsecs",
|
||||||
json_interface_sub, "timerMsecs",
|
OSPF_IF_PARAM(oi, v_hello) *
|
||||||
OSPF_IF_PARAM(oi, v_hello) * 1000);
|
1000);
|
||||||
else
|
else
|
||||||
json_object_int_add(
|
json_object_int_add(
|
||||||
json_interface_sub, "timerMsecs",
|
json_oi, "timerMsecs",
|
||||||
1000 / OSPF_IF_PARAM(oi, fast_hello));
|
1000 / OSPF_IF_PARAM(oi, fast_hello));
|
||||||
json_object_int_add(json_interface_sub,
|
json_object_int_add(json_oi, "timerDeadSecs",
|
||||||
"timerDeadSecs",
|
|
||||||
OSPF_IF_PARAM(oi, v_wait));
|
OSPF_IF_PARAM(oi, v_wait));
|
||||||
json_object_int_add(json_interface_sub,
|
json_object_int_add(json_oi, "timerWaitSecs",
|
||||||
"timerWaitSecs",
|
|
||||||
OSPF_IF_PARAM(oi, v_wait));
|
OSPF_IF_PARAM(oi, v_wait));
|
||||||
json_object_int_add(
|
json_object_int_add(
|
||||||
json_interface_sub, "timerRetransmitSecs",
|
json_oi, "timerRetransmitSecs",
|
||||||
OSPF_IF_PARAM(oi, retransmit_interval));
|
OSPF_IF_PARAM(oi, retransmit_interval));
|
||||||
} else {
|
} else {
|
||||||
vty_out(vty, " Timer intervals configured,");
|
vty_out(vty, " Timer intervals configured,");
|
||||||
@ -3910,7 +3910,7 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,
|
|||||||
&oi->t_hello->u.sands,
|
&oi->t_hello->u.sands,
|
||||||
NULL)
|
NULL)
|
||||||
/ 1000LL;
|
/ 1000LL;
|
||||||
json_object_int_add(json_interface_sub,
|
json_object_int_add(json_oi,
|
||||||
"timerHelloInMsecs",
|
"timerHelloInMsecs",
|
||||||
time_store);
|
time_store);
|
||||||
} else
|
} else
|
||||||
@ -3921,18 +3921,16 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,
|
|||||||
{
|
{
|
||||||
if (use_json)
|
if (use_json)
|
||||||
json_object_boolean_true_add(
|
json_object_boolean_true_add(
|
||||||
json_interface_sub,
|
json_oi, "timerPassiveIface");
|
||||||
"timerPassiveIface");
|
|
||||||
else
|
else
|
||||||
vty_out(vty,
|
vty_out(vty,
|
||||||
" No Hellos (Passive interface)\n");
|
" No Hellos (Passive interface)\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_json) {
|
if (use_json) {
|
||||||
json_object_int_add(json_interface_sub, "nbrCount",
|
json_object_int_add(json_oi, "nbrCount",
|
||||||
ospf_nbr_count(oi, 0));
|
ospf_nbr_count(oi, 0));
|
||||||
json_object_int_add(json_interface_sub,
|
json_object_int_add(json_oi, "nbrAdjacentCount",
|
||||||
"nbrAdjacentCount",
|
|
||||||
ospf_nbr_count(oi, NSM_Full));
|
ospf_nbr_count(oi, NSM_Full));
|
||||||
} else
|
} else
|
||||||
vty_out(vty,
|
vty_out(vty,
|
||||||
@ -3940,7 +3938,6 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,
|
|||||||
ospf_nbr_count(oi, 0),
|
ospf_nbr_count(oi, 0),
|
||||||
ospf_nbr_count(oi, NSM_Full));
|
ospf_nbr_count(oi, NSM_Full));
|
||||||
|
|
||||||
|
|
||||||
params = IF_DEF_PARAMS(ifp);
|
params = IF_DEF_PARAMS(ifp);
|
||||||
if (params &&
|
if (params &&
|
||||||
OSPF_IF_PARAM_CONFIGURED(params, v_gr_hello_delay)) {
|
OSPF_IF_PARAM_CONFIGURED(params, v_gr_hello_delay)) {
|
||||||
@ -3968,6 +3965,12 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,
|
|||||||
" %sDelay reflooding LSAs received on P2MP interface\n",
|
" %sDelay reflooding LSAs received on P2MP interface\n",
|
||||||
oi->p2mp_delay_reflood ? "" : "Don't ");
|
oi->p2mp_delay_reflood ? "" : "Don't ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Add ospf_interface object to main json blob using SIP as key
|
||||||
|
*/
|
||||||
|
if (use_json)
|
||||||
|
json_object_object_addf(json_ois, json_oi, "%pI4",
|
||||||
|
&oi->address->u.prefix4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user