From f1dbb1c7e1d2ac5c2f419db0326b8477c9a3ffd1 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 26 Oct 2020 16:46:03 -0400 Subject: [PATCH] zebra: Add uptime to `show evpn mac vni ... detail` Add the uptime a mac entry has been in the system. New Output: eva# show evpn mac vni all detail VNI 1000 #MACs (local and remote) 16 MAC: 4e:2d:f3:75:ff:db ESI: 03:44:38:39:ff:ff:01:00:00:02 Intf: hostbond2(10) VLAN: 1000 Sync-info: neigh#: 0 peer-active Local Seq: 0 Remote Seq: 0 Uptime: 00:00:28 Neighbors: No Neighbors MAC: 7a:a4:f2:30:dd:5d ESI: 03:44:38:39:ff:ff:01:00:00:01 Intf: hostbond1(9) VLAN: 1000 Sync-info: neigh#: 0 peer-active Local Seq: 0 Remote Seq: 0 Uptime: 00:00:28 Neighbors: No Neighbors MAC: 66:9e:d7:3a:f1:f1 Remote VTEP: 192.168.100.18 Sync-info: neigh#: 0 Local Seq: 0 Remote Seq: 0 Uptime: 00:00:26 Neighbors: 45.0.0.5 Active fe80::649e:d7ff:fe3a:f1f1 Active MAC: 26:f1:bd:5f:e1:77 Remote ES: 03:44:38:39:ff:ff:02:00:00:02 Sync-info: neigh#: 0 Local Seq: 0 Remote Seq: 0 Uptime: 00:00:23 Neighbors: No Neighbors MAC: 16:80:eb:c4:43:6d ESI: 03:44:38:39:ff:ff:01:00:00:01 Intf: hostbond1(9) VLAN: 1000 Sync-info: neigh#: 0 peer-active Local Seq: 0 Remote Seq: 0 Uptime: 00:00:28 Neighbors: No Neighbors MAC: 00:00:00:00:00:22 Remote ES: 03:44:38:39:ff:ff:02:00:00:02 Sync-info: neigh#: 0 Local Seq: 0 Remote Seq: 0 Uptime: 00:00:26 Neighbors: No Neighbors Signed-off-by: Donald Sharp --- zebra/zebra_evpn_mac.c | 15 +++++++++++++-- zebra/zebra_evpn_mac.h | 2 ++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/zebra/zebra_evpn_mac.c b/zebra/zebra_evpn_mac.c index 8e9a1a4e8e..4a2d8db422 100644 --- a/zebra/zebra_evpn_mac.c +++ b/zebra/zebra_evpn_mac.c @@ -490,6 +490,8 @@ void zebra_evpn_print_mac(zebra_mac_t *mac, void *ctxt, json_object *json) struct timeval detect_start_time = {0, 0}; char timebuf[MONOTIME_STRLEN]; char thread_buf[THREAD_TIMER_STRLEN]; + time_t uptime; + char up_str[MONOTIME_STRLEN]; zvrf = zebra_vrf_get_evpn(); if (!zvrf) @@ -498,6 +500,11 @@ void zebra_evpn_print_mac(zebra_mac_t *mac, void *ctxt, json_object *json) vty = (struct vty *)ctxt; prefix_mac2str(&mac->macaddr, buf1, sizeof(buf1)); + uptime = monotime(NULL); + uptime -= mac->uptime; + + frrtime_to_interval(uptime, up_str, sizeof(up_str)); + if (json) { json_object *json_mac = json_object_new_object(); @@ -535,6 +542,7 @@ void zebra_evpn_print_mac(zebra_mac_t *mac, void *ctxt, json_object *json) json_object_boolean_true_add(json_mac, "remoteGatewayMac"); + json_object_string_add(json_mac, "uptime", up_str); json_object_int_add(json_mac, "localSequence", mac->loc_seq); json_object_int_add(json_mac, "remoteSequence", mac->rem_seq); @@ -648,9 +656,9 @@ void zebra_evpn_print_mac(zebra_mac_t *mac, void *ctxt, json_object *json) sizeof(thread_buf), mac->hold_timer)); vty_out(vty, "\n"); - vty_out(vty, " Local Seq: %u Remote Seq: %u", mac->loc_seq, + vty_out(vty, " Local Seq: %u Remote Seq: %u\n", mac->loc_seq, mac->rem_seq); - vty_out(vty, "\n"); + vty_out(vty, " Uptime: %s\n", up_str); if (CHECK_FLAG(mac->flags, ZEBRA_MAC_DUPLICATE)) { vty_out(vty, " Duplicate, detected at %s", @@ -972,6 +980,7 @@ zebra_mac_t *zebra_evpn_mac_add(zebra_evpn_t *zevpn, struct ethaddr *macaddr) mac->neigh_list = list_new(); mac->neigh_list->cmp = neigh_list_cmp; + mac->uptime = monotime(NULL); if (IS_ZEBRA_DEBUG_VXLAN || IS_ZEBRA_DEBUG_EVPN_MH_MAC) { char buf[ETHER_ADDR_STRLEN]; @@ -1459,6 +1468,8 @@ zebra_evpn_proc_sync_mac_update(zebra_evpn_t *zevpn, struct ethaddr *macaddr, bool sticky; bool remote_gw; + mac->uptime = monotime(NULL); + old_flags = mac->flags; sticky = !!CHECK_FLAG(old_flags, ZEBRA_MAC_STICKY); remote_gw = !!CHECK_FLAG(old_flags, ZEBRA_MAC_REMOTE_DEF_GW); diff --git a/zebra/zebra_evpn_mac.h b/zebra/zebra_evpn_mac.h index f9ca81445f..596fd0faad 100644 --- a/zebra/zebra_evpn_mac.h +++ b/zebra/zebra_evpn_mac.h @@ -129,6 +129,8 @@ struct zebra_mac_t_ { * ZEBRA_MAC_ES_PEER_ACTIVE or ZEBRA_NEIGH_ES_PEER_PROXY */ uint32_t sync_neigh_cnt; + + time_t uptime; }; /* -- 2.39.5