From 28ad0501b9758080d23cf581d0210eeceeec9ded Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Mon, 14 Oct 2019 17:46:10 -0700 Subject: [PATCH] zebra: print rmac and sys mac values "show vrf vni" and "show evpn vni " commands need to display correct router mac value. "show evpn vni " detail l3vni needs to display system mac as in PIP scenario value can be different. Syste MAC would be derived from SVI interface MAC wherelse Router MAC would be derived from macvlan interface MAC value. Ticket:CM-26710 Reviewed By:CCR-9334 Testing Done: TORC11# show evpn vni 4001 VNI: 4001 Type: L3 Tenant VRF: vrf1 Local Vtep Ip: 36.0.0.11 Vxlan-Intf: vx-4001 SVI-If: vlan4001 State: Up VNI Filter: none System MAC: 00:02:00:00:00:2e Router MAC: 44:38:39:ff:ff:01 L2 VNIs: 1000 TORC11# show vrf vni VRF VNI VxLAN IF L3-SVI State Rmac vrf1 4001 vx-4001 vlan4001 Up 44:38:39:ff:ff:01 TORC11# show evpn vni 4001 json { "vni":4001, "type":"L3", "localVtepIp":"36.0.0.11", "vxlanIntf":"vx-4001", "sviIntf":"vlan4001", "state":"Up", "vrf":"vrf1", "sysMac":"00:02:00:00:00:2e", "routerMac":"44:38:39:ff:ff:01", "vniFilter":"none", "l2Vnis":[ 1000, ] } Signed-off-by: Chirag Shah --- zebra/zebra_vxlan.c | 5 +++++ zebra/zebra_vxlan_private.h | 38 +++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index 14df91f40ffd..1da419040ed6 100644 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@ -1816,6 +1816,8 @@ static void zl3vni_print(zebra_l3vni_t *zl3vni, void **ctx) CHECK_FLAG(zl3vni->filter, PREFIX_ROUTES_ONLY) ? "prefix-routes-only" : "none"); + vty_out(vty, " System MAC: %s\n", + zl3vni_sysmac2str(zl3vni, buf, sizeof(buf))); vty_out(vty, " Router MAC: %s\n", zl3vni_rmac2str(zl3vni, buf, sizeof(buf))); vty_out(vty, " L2 VNIs: "); @@ -1834,6 +1836,9 @@ static void zl3vni_print(zebra_l3vni_t *zl3vni, void **ctx) zl3vni_svi_if_name(zl3vni)); json_object_string_add(json, "state", zl3vni_state2str(zl3vni)); json_object_string_add(json, "vrf", zl3vni_vrf_name(zl3vni)); + json_object_string_add( + json, "sysMac", + zl3vni_sysmac2str(zl3vni, buf, sizeof(buf))); json_object_string_add( json, "routerMac", zl3vni_rmac2str(zl3vni, buf, sizeof(buf))); diff --git a/zebra/zebra_vxlan_private.h b/zebra/zebra_vxlan_private.h index f0bda44fb923..989ea464e700 100644 --- a/zebra/zebra_vxlan_private.h +++ b/zebra/zebra_vxlan_private.h @@ -169,6 +169,44 @@ static inline const char *zl3vni_rmac2str(zebra_l3vni_t *zl3vni, char *buf, ptr = buf; } + if (zl3vni->mac_vlan_if) + snprintf(ptr, (ETHER_ADDR_STRLEN), + "%02x:%02x:%02x:%02x:%02x:%02x", + (uint8_t)zl3vni->mac_vlan_if->hw_addr[0], + (uint8_t)zl3vni->mac_vlan_if->hw_addr[1], + (uint8_t)zl3vni->mac_vlan_if->hw_addr[2], + (uint8_t)zl3vni->mac_vlan_if->hw_addr[3], + (uint8_t)zl3vni->mac_vlan_if->hw_addr[4], + (uint8_t)zl3vni->mac_vlan_if->hw_addr[5]); + else if (zl3vni->svi_if) + snprintf(ptr, (ETHER_ADDR_STRLEN), + "%02x:%02x:%02x:%02x:%02x:%02x", + (uint8_t)zl3vni->svi_if->hw_addr[0], + (uint8_t)zl3vni->svi_if->hw_addr[1], + (uint8_t)zl3vni->svi_if->hw_addr[2], + (uint8_t)zl3vni->svi_if->hw_addr[3], + (uint8_t)zl3vni->svi_if->hw_addr[4], + (uint8_t)zl3vni->svi_if->hw_addr[5]); + else + snprintf(ptr, ETHER_ADDR_STRLEN, "None"); + + return ptr; +} + +/* get the sys mac string */ +static inline const char *zl3vni_sysmac2str(zebra_l3vni_t *zl3vni, char *buf, + int size) +{ + char *ptr; + + if (!buf) + ptr = (char *)XMALLOC(MTYPE_TMP, + ETHER_ADDR_STRLEN * sizeof(char)); + else { + assert(size >= ETHER_ADDR_STRLEN); + ptr = buf; + } + if (zl3vni->svi_if) snprintf(ptr, (ETHER_ADDR_STRLEN), "%02x:%02x:%02x:%02x:%02x:%02x",