mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-07-10 13:34:33 +00:00
bgpd: 'show ip bgp summary json' shows large negative value for "peerUptimeMsec"
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com> Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com> Reviewed-by: Don Slice <dslice@cumulusnetworks.com> Ticket: CM-13239
This commit is contained in:
parent
7b8def580a
commit
c6a7d59c20
30
bgpd/bgpd.c
30
bgpd/bgpd.c
@ -6193,7 +6193,6 @@ peer_clear_soft (struct peer *peer, afi_t afi, safi_t safi,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Display peer uptime.*/
|
/* Display peer uptime.*/
|
||||||
/* XXX: why does this function return char * when it takes buffer? */
|
|
||||||
char *
|
char *
|
||||||
peer_uptime (time_t uptime2, char *buf, size_t len, u_char use_json, json_object *json)
|
peer_uptime (time_t uptime2, char *buf, size_t len, u_char use_json, json_object *json)
|
||||||
{
|
{
|
||||||
@ -6216,7 +6215,10 @@ peer_uptime (time_t uptime2, char *buf, size_t len, u_char use_json, json_object
|
|||||||
if (uptime2 == 0)
|
if (uptime2 == 0)
|
||||||
{
|
{
|
||||||
if (use_json)
|
if (use_json)
|
||||||
json_object_string_add(json, "peerUptime", "never");
|
{
|
||||||
|
json_object_string_add(json, "peerUptime", "never");
|
||||||
|
json_object_int_add(json, "peerUptimeMsec", 0);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
snprintf (buf, len, "never");
|
snprintf (buf, len, "never");
|
||||||
return buf;
|
return buf;
|
||||||
@ -6232,24 +6234,6 @@ peer_uptime (time_t uptime2, char *buf, size_t len, u_char use_json, json_object
|
|||||||
#define ONE_WEEK_SECOND ONE_DAY_SECOND*7
|
#define ONE_WEEK_SECOND ONE_DAY_SECOND*7
|
||||||
#define ONE_YEAR_SECOND ONE_DAY_SECOND*365
|
#define ONE_YEAR_SECOND ONE_DAY_SECOND*365
|
||||||
|
|
||||||
if (use_json)
|
|
||||||
{
|
|
||||||
unsigned long time_store;
|
|
||||||
unsigned long sec_msec = 1000;
|
|
||||||
unsigned long minute_msec = sec_msec * 60;
|
|
||||||
unsigned long hour_msec = minute_msec * 60;
|
|
||||||
unsigned long day_msec = hour_msec * 24;
|
|
||||||
unsigned long year_msec = day_msec *365;
|
|
||||||
|
|
||||||
time_store =
|
|
||||||
year_msec * tm->tm_year +
|
|
||||||
day_msec * tm->tm_yday +
|
|
||||||
hour_msec * tm->tm_hour +
|
|
||||||
minute_msec * tm->tm_min +
|
|
||||||
sec_msec * tm->tm_sec;
|
|
||||||
json_object_int_add(json, "peerUptimeMsec", time_store);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (uptime1 < ONE_DAY_SECOND)
|
if (uptime1 < ONE_DAY_SECOND)
|
||||||
snprintf (buf, len, "%02d:%02d:%02d",
|
snprintf (buf, len, "%02d:%02d:%02d",
|
||||||
tm->tm_hour, tm->tm_min, tm->tm_sec);
|
tm->tm_hour, tm->tm_min, tm->tm_sec);
|
||||||
@ -6264,6 +6248,12 @@ peer_uptime (time_t uptime2, char *buf, size_t len, u_char use_json, json_object
|
|||||||
tm->tm_year - 70, tm->tm_yday/7,
|
tm->tm_year - 70, tm->tm_yday/7,
|
||||||
tm->tm_yday - ((tm->tm_yday/7) * 7));
|
tm->tm_yday - ((tm->tm_yday/7) * 7));
|
||||||
|
|
||||||
|
if (use_json)
|
||||||
|
{
|
||||||
|
json_object_string_add(json, "peerUptime", buf);
|
||||||
|
json_object_long_add(json, "peerUptimeMsec", uptime1 * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +53,12 @@ json_object_int_add(struct json_object* obj, const char *key, int32_t i)
|
|||||||
json_object_object_add(obj, key, json_object_new_int(i));
|
json_object_object_add(obj, key, json_object_new_int(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
json_object_long_add(struct json_object* obj, const char *key, int64_t i)
|
||||||
|
{
|
||||||
|
json_object_object_add(obj, key, json_object_new_int64(i));
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
json_object_boolean_false_add(struct json_object* obj, const char *key)
|
json_object_boolean_false_add(struct json_object* obj, const char *key)
|
||||||
{
|
{
|
||||||
|
@ -39,6 +39,8 @@ extern void json_object_string_add(struct json_object* obj, const char *key,
|
|||||||
const char *s);
|
const char *s);
|
||||||
extern void json_object_int_add(struct json_object* obj, const char *key,
|
extern void json_object_int_add(struct json_object* obj, const char *key,
|
||||||
int32_t i);
|
int32_t i);
|
||||||
|
extern void json_object_long_add(struct json_object* obj, const char *key,
|
||||||
|
int64_t i);
|
||||||
extern void json_object_boolean_false_add(struct json_object* obj,
|
extern void json_object_boolean_false_add(struct json_object* obj,
|
||||||
const char *key);
|
const char *key);
|
||||||
extern void json_object_boolean_true_add(struct json_object* obj,
|
extern void json_object_boolean_true_add(struct json_object* obj,
|
||||||
|
Loading…
Reference in New Issue
Block a user