Skip to content

Commit

Permalink
Merge pull request #16195 from opensourcerouting/fix/drop_recent_conf…
Browse files Browse the repository at this point in the history
…date

ospfd: Drop `interfaceIp` from `show ip ospf neigh json`
  • Loading branch information
riw777 authored Jun 18, 2024
2 parents 045029e + e8f5caa commit b94fc2d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 215 deletions.
198 changes: 26 additions & 172 deletions ospfd/ospf_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -3576,8 +3576,6 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,
struct route_node *rn;
uint32_t bandwidth = ifp->bandwidth ? ifp->bandwidth : ifp->speed;
struct ospf_if_params *params;
json_object *json_ois = NULL;
json_object *json_oi = NULL;

/* Is interface up? */
if (use_json) {
Expand Down Expand Up @@ -3628,33 +3626,17 @@ 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)) {
struct ospf_interface *oi = rn->info;

if (oi == NULL)
continue;

#if CONFDATE > 20240601
CPP_NOTICE(
"Use all fields following ospfEnabled from interfaceIp hierarchy")
#endif

if (use_json)
json_oi = json_object_new_object();

if (CHECK_FLAG(oi->connected->flags, ZEBRA_IFA_UNNUMBERED)) {
if (use_json) {
if (use_json)
json_object_boolean_true_add(json_interface_sub,
"ifUnnumbered");
json_object_boolean_true_add(json_oi,
"ifUnnumbered");
} else
else
vty_out(vty, " This interface is UNNUMBERED,");
} else {
struct in_addr dest;
Expand All @@ -3668,13 +3650,6 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,
json_object_int_add(json_interface_sub,
"ipAddressPrefixlen",
oi->address->prefixlen);

json_object_string_addf(
json_oi, "ipAddress", "%pI4",
&oi->address->u.prefix4);
json_object_int_add(json_oi,
"ipAddressPrefixlen",
oi->address->prefixlen);
} else
vty_out(vty, " Internet Address %pFX,",
oi->address);
Expand All @@ -3700,26 +3675,14 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,
json_object_string_add(json_interface_sub,
"ospfIfType", dstr);

json_object_string_add(json_oi, "ospfIfType",
dstr);

if (oi->type == OSPF_IFTYPE_VIRTUALLINK) {
if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
json_object_string_addf(
json_interface_sub, "vlinkPeer",
"%pI4", &dest);

json_object_string_addf(json_oi,
"vlinkPeer",
"%pI4", &dest);
} else {
else
json_object_string_addf(
json_interface_sub,
"localIfUsed", "%pI4", &dest);

json_object_string_addf(json_oi,
"localIfUsed",
"%pI4", &dest);
}
} else
vty_out(vty, " %s %pI4,", dstr,
&dest);
Expand All @@ -3728,16 +3691,10 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,
json_object_string_add(json_interface_sub, "area",
ospf_area_desc_string(oi->area));

json_object_string_add(json_oi, "area",
ospf_area_desc_string(oi->area));

if (OSPF_IF_PARAM(oi, mtu_ignore)) {
json_object_boolean_true_add(
json_oi, "mtuMismatchDetect");
if (OSPF_IF_PARAM(oi, mtu_ignore))
json_object_boolean_true_add(
json_interface_sub,
"mtuMismatchDetect");
}

json_object_string_addf(json_interface_sub, "routerId",
"%pI4", &ospf->router_id);
Expand All @@ -3754,18 +3711,6 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,
oi->state, NULL));
json_object_int_add(json_interface_sub, "priority",
PRIORITY(oi));

json_object_string_addf(json_oi, "routerId", "%pI4",
&ospf->router_id);
json_object_string_add(json_oi, "networkType",
ospf_network_type_str[oi->type]);
json_object_int_add(json_oi, "cost", oi->output_cost);
json_object_int_add(json_oi, "transmitDelaySecs",
OSPF_IF_PARAM(oi, transmit_delay));
json_object_string_add(json_oi, "state",
lookup_msg(ospf_ism_state_msg,
oi->state, NULL));
json_object_int_add(json_oi, "priority", PRIORITY(oi));
json_object_boolean_add(
json_interface_sub, "opaqueCapable",
OSPF_IF_PARAM(oi, opaque_capable));
Expand Down Expand Up @@ -3809,13 +3754,6 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,
json_interface_sub, "drAddress",
"%pI4",
&nbr->address.u.prefix4);

json_object_string_addf(
json_oi, "drId", "%pI4",
&nbr->router_id);
json_object_string_addf(
json_oi, "drAddress", "%pI4",
&nbr->address.u.prefix4);
} else {
vty_out(vty,
" Designated Router (ID) %pI4",
Expand All @@ -3841,13 +3779,6 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,
json_interface_sub,
"bdrAddress", "%pI4",
&nbr->address.u.prefix4);

json_object_string_addf(
json_oi, "bdrId", "%pI4",
&nbr->router_id);
json_object_string_addf(
json_oi, "bdrAddress", "%pI4",
&nbr->address.u.prefix4);
} else {
vty_out(vty,
" Backup Designated Router (ID) %pI4,",
Expand All @@ -3863,43 +3794,28 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,
if (oi->params
&& ntohl(oi->params->network_lsa_seqnum)
!= OSPF_INITIAL_SEQUENCE_NUMBER) {
if (use_json) {
if (use_json)
json_object_int_add(
json_interface_sub,
"networkLsaSequence",
ntohl(oi->params->network_lsa_seqnum));

json_object_int_add(
json_oi, "networkLsaSequence",
ntohl(oi->params->network_lsa_seqnum));
} else {
else
vty_out(vty,
" Saved Network-LSA sequence number 0x%x\n",
ntohl(oi->params->network_lsa_seqnum));
}
}

if (use_json) {
if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)
|| 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_interface_sub,
"mcastMemberOspfAllRouters");

json_object_boolean_true_add(
json_oi,
"mcastMemberOspfAllRouters");
}
if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) {
if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
json_object_boolean_true_add(
json_interface_sub,
"mcastMemberOspfDesignatedRouters");

json_object_boolean_true_add(
json_oi,
"mcastMemberOspfDesignatedRouters");
}
}
} else {
vty_out(vty, " Multicast group memberships:");
Expand All @@ -3915,38 +3831,21 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,
}

if (use_json) {
if (OSPF_IF_PARAM(oi, fast_hello) == 0) {
if (OSPF_IF_PARAM(oi, fast_hello) == 0)
json_object_int_add(
json_interface_sub, "timerMsecs",
OSPF_IF_PARAM(oi, v_hello) * 1000);

json_object_int_add(json_oi, "timerMsecs",
OSPF_IF_PARAM(oi, v_hello) *
1000);
} else {
else
json_object_int_add(
json_interface_sub, "timerMsecs",
1000 / OSPF_IF_PARAM(oi, fast_hello));

json_object_int_add(
json_oi, "timerMsecs",
1000 / OSPF_IF_PARAM(oi, fast_hello));
}
json_object_int_add(json_interface_sub, "timerDeadSecs",
OSPF_IF_PARAM(oi, v_wait));
json_object_int_add(json_interface_sub, "timerWaitSecs",
OSPF_IF_PARAM(oi, v_wait));
json_object_int_add(
json_interface_sub, "timerRetransmitSecs",
OSPF_IF_PARAM(oi, retransmit_interval));

json_object_int_add(json_oi, "timerDeadSecs",
OSPF_IF_PARAM(oi, v_wait));
json_object_int_add(json_oi, "timerWaitSecs",
OSPF_IF_PARAM(oi, v_wait));
json_object_int_add(
json_oi, "timerRetransmitSecs",
OSPF_IF_PARAM(oi, retransmit_interval));
} else {
vty_out(vty, " Timer intervals configured,");
vty_out(vty, " Hello ");
Expand Down Expand Up @@ -3975,23 +3874,17 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,
json_object_int_add(json_interface_sub,
"timerHelloInMsecs",
time_store);
json_object_int_add(json_oi,
"timerHelloInMsecs",
time_store);
} else
vty_out(vty, " Hello due in %s\n",
ospf_timer_dump(oi->t_hello, timebuf,
sizeof(timebuf)));
} else /* passive-interface is set */
{
if (use_json) {
if (use_json)
json_object_boolean_true_add(
json_interface_sub,
"timerPassiveIface");

json_object_boolean_true_add(
json_oi, "timerPassiveIface");
} else
else
vty_out(vty,
" No Hellos (Passive interface)\n");
}
Expand All @@ -4002,11 +3895,6 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,
json_object_int_add(json_interface_sub,
"nbrAdjacentCount",
ospf_nbr_count(oi, NSM_Full));

json_object_int_add(json_oi, "nbrCount",
ospf_nbr_count(oi, 0));
json_object_int_add(json_oi, "nbrAdjacentCount",
ospf_nbr_count(oi, NSM_Full));
} else
vty_out(vty,
" Neighbor Count is %d, Adjacent neighbor count is %d\n",
Expand All @@ -4016,99 +3904,65 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,
params = IF_DEF_PARAMS(ifp);
if (params &&
OSPF_IF_PARAM_CONFIGURED(params, v_gr_hello_delay)) {
if (use_json) {
if (use_json)
json_object_int_add(json_interface_sub,
"grHelloDelaySecs",
params->v_gr_hello_delay);

json_object_int_add(json_oi, "grHelloDelaySecs",
params->v_gr_hello_delay);
} else
else
vty_out(vty,
" Graceful Restart hello delay: %us\n",
params->v_gr_hello_delay);
}

ospf_interface_bfd_show(vty, ifp, json_interface_sub);

if (use_json) {
if (use_json)
json_object_boolean_add(json_interface_sub,
"prefixSuppression",
OSPF_IF_PARAM(oi,
prefix_suppression));
json_object_boolean_add(json_oi, "prefixSuppression",
OSPF_IF_PARAM(oi,
prefix_suppression));
} else {
if (OSPF_IF_PARAM(oi, prefix_suppression))
vty_out(vty,
" Suppress advertisement of interface IP prefix\n");
}
else if (OSPF_IF_PARAM(oi, prefix_suppression))
vty_out(vty,
" Suppress advertisement of interface IP prefix\n");

/* OSPF Authentication information */
ospf_interface_auth_show(vty, oi, json_interface_sub, use_json);

ospf_interface_auth_show(vty, oi, json_oi, use_json);

/* Point-to-Multipoint Interface options. */
if (oi->type == OSPF_IFTYPE_POINTOMULTIPOINT) {
if (use_json) {
if (use_json)
json_object_boolean_add(json_interface_sub,
"p2mpDelayReflood",
oi->p2mp_delay_reflood);

json_object_boolean_add(json_oi,
"p2mpDelayReflood",
oi->p2mp_delay_reflood);
} else {
else
vty_out(vty,
" %sDelay reflooding LSAs received on P2MP interface\n",
oi->p2mp_delay_reflood ? "" : "Don't ");
}
if (use_json) {
if (use_json)
json_object_boolean_add(json_interface_sub,
"p2mpNonBroadcast",
oi->p2mp_non_broadcast);

json_object_boolean_add(json_oi,
"p2mpNonBroadcast",
oi->p2mp_non_broadcast);
} else {
else
vty_out(vty,
" P2MP interface does %ssupport broadcast\n",
oi->p2mp_non_broadcast ? "not " : "");
}
}

/* 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);

if (oi->nbr_filter) {
if (use_json) {
if (use_json)
json_object_string_add(json_interface_sub,
"nbrFilterPrefixList",
prefix_list_name(
oi->nbr_filter));
json_object_string_add(json_oi,
"nbrFilterPrefixList",
prefix_list_name(
oi->nbr_filter));
} else
else
vty_out(vty,
" Neighbor filter prefix-list: %s\n",
prefix_list_name(oi->nbr_filter));
} else {
if (use_json) {
if (use_json)
json_object_string_add(json_interface_sub,
"nbrFilterPrefixList",
"N/A");
json_object_string_add(json_oi,
"nbrFilterPrefixList",
"N/A");
}
}
}
}
Expand Down
Loading

0 comments on commit b94fc2d

Please sign in to comment.