mirror of
https://github.com/FRRouting/frr.git
synced 2025-04-30 13:37:17 +02:00
zebra: add rtadv information output in vtysh json
Add to "show interface json" output multiple rtadv parameters. if_dump_vty() calls => hook_call(zebra_if_extra_info, vty, ifp); if_dump_vty_json() now do the same call, with additional parameter: hook_call(zebra_if_extra_info, vty, json_if, ifp); Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
This commit is contained in:
parent
942a7c916c
commit
e6d08a89c7
|
@ -40,8 +40,8 @@ DEFINE_MTYPE_STATIC(ZEBRA, ZINFO, "Zebra Interface Information");
|
||||||
|
|
||||||
#define ZEBRA_PTM_SUPPORT
|
#define ZEBRA_PTM_SUPPORT
|
||||||
|
|
||||||
DEFINE_HOOK(zebra_if_extra_info, (struct vty * vty, struct interface *ifp),
|
DEFINE_HOOK(zebra_if_extra_info, (struct vty * vty, json_object *json_if, struct interface *ifp),
|
||||||
(vty, ifp));
|
(vty, json_if, ifp));
|
||||||
|
|
||||||
DEFINE_MTYPE_STATIC(ZEBRA, ZIF_DESC, "Intf desc");
|
DEFINE_MTYPE_STATIC(ZEBRA, ZIF_DESC, "Intf desc");
|
||||||
|
|
||||||
|
@ -2846,7 +2846,7 @@ static void if_dump_vty(struct vty *vty, struct interface *ifp)
|
||||||
&iflp->rmt_ip, iflp->rmt_as);
|
&iflp->rmt_ip, iflp->rmt_as);
|
||||||
}
|
}
|
||||||
|
|
||||||
hook_call(zebra_if_extra_info, vty, ifp);
|
hook_call(zebra_if_extra_info, vty, NULL, ifp);
|
||||||
|
|
||||||
if (listhead(ifp->nbr_connected))
|
if (listhead(ifp->nbr_connected))
|
||||||
vty_out(vty, " Neighbor address(s):\n");
|
vty_out(vty, " Neighbor address(s):\n");
|
||||||
|
@ -3252,6 +3252,8 @@ static void if_dump_vty_json(struct vty *vty, struct interface *ifp,
|
||||||
json_object_int_add(json_te, "neighborAsbrAs", iflp->rmt_as);
|
json_object_int_add(json_te, "neighborAsbrAs", iflp->rmt_as);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hook_call(zebra_if_extra_info, vty, json_if, ifp);
|
||||||
|
|
||||||
if (listhead(ifp->nbr_connected)) {
|
if (listhead(ifp->nbr_connected)) {
|
||||||
json_object *json_nbr_addrs;
|
json_object *json_nbr_addrs;
|
||||||
|
|
||||||
|
|
|
@ -223,8 +223,8 @@ struct zebra_if {
|
||||||
char *desc;
|
char *desc;
|
||||||
};
|
};
|
||||||
|
|
||||||
DECLARE_HOOK(zebra_if_extra_info, (struct vty * vty, struct interface *ifp),
|
DECLARE_HOOK(zebra_if_extra_info, (struct vty * vty, json_object *json_if, struct interface *ifp),
|
||||||
(vty, ifp));
|
(vty, json_if, ifp));
|
||||||
|
|
||||||
#define IS_ZEBRA_IF_VRF(ifp) \
|
#define IS_ZEBRA_IF_VRF(ifp) \
|
||||||
(((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_VRF)
|
(((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_VRF)
|
||||||
|
|
|
@ -1726,7 +1726,7 @@ int rtadv_dnssl_encode(uint8_t *out, const char *in)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Dump interface ND information to vty. */
|
/* Dump interface ND information to vty. */
|
||||||
static int nd_dump_vty(struct vty *vty, struct interface *ifp)
|
static int nd_dump_vty(struct vty *vty, json_object *json_if, struct interface *ifp)
|
||||||
{
|
{
|
||||||
struct zebra_if *zif;
|
struct zebra_if *zif;
|
||||||
struct rtadvconf *rtadv;
|
struct rtadvconf *rtadv;
|
||||||
|
@ -1735,7 +1735,7 @@ static int nd_dump_vty(struct vty *vty, struct interface *ifp)
|
||||||
zif = (struct zebra_if *)ifp->info;
|
zif = (struct zebra_if *)ifp->info;
|
||||||
rtadv = &zif->rtadv;
|
rtadv = &zif->rtadv;
|
||||||
|
|
||||||
if (rtadv->AdvSendAdvertisements) {
|
if (!json_if && rtadv->AdvSendAdvertisements) {
|
||||||
vty_out(vty,
|
vty_out(vty,
|
||||||
" ND advertised reachable time is %d milliseconds\n",
|
" ND advertised reachable time is %d milliseconds\n",
|
||||||
rtadv->AdvReachableTime);
|
rtadv->AdvReachableTime);
|
||||||
|
@ -1792,6 +1792,63 @@ static int nd_dump_vty(struct vty *vty, struct interface *ifp)
|
||||||
vty_out(vty,
|
vty_out(vty,
|
||||||
" ND router advertisements with Adv. Interval option.\n");
|
" ND router advertisements with Adv. Interval option.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (json_if && rtadv->AdvSendAdvertisements) {
|
||||||
|
json_object_int_add(json_if, "ndAdvertisedReachableTimeMsecs",
|
||||||
|
rtadv->AdvReachableTime);
|
||||||
|
json_object_int_add(json_if, "ndAdvertisedRetransmitIntervalMsecs",
|
||||||
|
rtadv->AdvRetransTimer);
|
||||||
|
json_object_int_add(json_if, "ndAdvertisedHopCountLimitHops", rtadv->AdvCurHopLimit);
|
||||||
|
json_object_int_add(json_if, "ndRouterAdvertisementsSent", zif->ra_sent);
|
||||||
|
json_object_int_add(json_if, "ndRouterAdvertisementsRcvd", zif->ra_rcvd);
|
||||||
|
|
||||||
|
interval = rtadv->MaxRtrAdvInterval;
|
||||||
|
if (interval % 1000)
|
||||||
|
json_object_int_add(json_if, "ndRouterAdvertisementsIntervalMsecs",
|
||||||
|
interval);
|
||||||
|
else
|
||||||
|
json_object_int_add(json_if, "ndRouterAdvertisementsIntervalSecs",
|
||||||
|
interval / 1000);
|
||||||
|
|
||||||
|
json_object_boolean_add(json_if, "ndRouterAdvertisementsDoNotUseFastRetransmit",
|
||||||
|
!rtadv->UseFastRexmit);
|
||||||
|
|
||||||
|
if (rtadv->AdvDefaultLifetime != -1)
|
||||||
|
json_object_int_add(json_if, "ndRouterAdvertisementsLiveForSecs",
|
||||||
|
rtadv->AdvDefaultLifetime);
|
||||||
|
else
|
||||||
|
json_object_boolean_add(json_if,
|
||||||
|
"ndRouterAdvertisementsLifetimeTracksRaInterval",
|
||||||
|
true);
|
||||||
|
|
||||||
|
json_object_string_add(json_if, "ndRouterAdvertisementDefaultRouterPreference",
|
||||||
|
rtadv_pref_strs[rtadv->DefaultPreference]);
|
||||||
|
|
||||||
|
if (rtadv->AdvManagedFlag)
|
||||||
|
json_object_boolean_add(json_if, "hostsUseDhcpToObtainRoutableAddresses",
|
||||||
|
true);
|
||||||
|
else
|
||||||
|
json_object_boolean_add(json_if, "hostsUseStatelessAutoconfigForAddresses",
|
||||||
|
true);
|
||||||
|
|
||||||
|
if (rtadv->AdvHomeAgentFlag) {
|
||||||
|
json_object_boolean_add(json_if,
|
||||||
|
"ndRouterAdvertisementsWithHomeAgentFlagBit", true);
|
||||||
|
if (rtadv->HomeAgentLifetime != -1)
|
||||||
|
json_object_int_add(json_if, "homeAgentLifetimeSecs",
|
||||||
|
rtadv->HomeAgentLifetime);
|
||||||
|
else
|
||||||
|
json_object_boolean_add(json_if,
|
||||||
|
"homeAgentLifetimeTracksRaLifetime", true);
|
||||||
|
|
||||||
|
json_object_int_add(json_if, "homeAgentPreference",
|
||||||
|
rtadv->HomeAgentLifetime);
|
||||||
|
}
|
||||||
|
if (rtadv->AdvIntervalOption)
|
||||||
|
json_object_boolean_add(json_if,
|
||||||
|
"ndRouterAdvertisementsWithAdvIntervalOption", true);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue