Skip to content

Commit

Permalink
zebra: print rmac and sys mac values
Browse files Browse the repository at this point in the history
"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>
  • Loading branch information
chiragshah6 committed Nov 22, 2019
1 parent b6c34e8 commit 28ad050
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
5 changes: 5 additions & 0 deletions zebra/zebra_vxlan.c
Expand Up @@ -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: ");
Expand All @@ -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)));
Expand Down
38 changes: 38 additions & 0 deletions zebra/zebra_vxlan_private.h
Expand Up @@ -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",
Expand Down

0 comments on commit 28ad050

Please sign in to comment.