]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: print rmac and sys mac values
authorChirag Shah <chirag@cumulusnetworks.com>
Tue, 15 Oct 2019 00:46:10 +0000 (17:46 -0700)
committerChirag Shah <chirag@cumulusnetworks.com>
Fri, 22 Nov 2019 15:53:35 +0000 (07:53 -0800)
"show vrf vni" and "show evpn vni <l3vni>" commands
need to display correct router mac value.

"show evpn vni <l3vni>" 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 <chirag@cumulusnetworks.com>
zebra/zebra_vxlan.c
zebra/zebra_vxlan_private.h

index 14df91f40ffde2f08822d0fd36556d9f08ef7150..1da419040ed6c352cd30daee20595d698487b63b 100644 (file)
@@ -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)));
index f0bda44fb923028a34add59a65b1f3e52aafa024..989ea464e700685164abac0ef3677c5257d6ba21 100644 (file)
@@ -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",