mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-16 00:25:01 +00:00
zebra: json support for show evpn rmac specific mac command
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
This commit is contained in:
parent
75223c9e4a
commit
316f4ca4d9
@ -2067,24 +2067,26 @@ DEFUN (show_evpn_l3vni_vni,
|
||||
|
||||
DEFUN (show_evpn_rmac_l3vni_mac,
|
||||
show_evpn_rmac_l3vni_mac_cmd,
|
||||
"show evpn rmac l3vni " CMD_VNI_RANGE " mac WORD",
|
||||
"show evpn rmac l3vni " CMD_VNI_RANGE " mac WORD [json]",
|
||||
SHOW_STR
|
||||
"EVPN\n"
|
||||
"RMAC\n"
|
||||
"L3-VNI\n"
|
||||
"VNI number\n"
|
||||
"MAC\n"
|
||||
"mac-address (e.g. 0a:0a:0a:0a:0a:0a)\n")
|
||||
"mac-address (e.g. 0a:0a:0a:0a:0a:0a)\n"
|
||||
JSON_STR)
|
||||
{
|
||||
vni_t l3vni = 0;
|
||||
struct ethaddr mac;
|
||||
u_char uj = use_json(argc, argv);
|
||||
|
||||
l3vni = strtoul(argv[4]->arg, NULL, 10);
|
||||
if (!prefix_str2mac(argv[6]->arg, &mac)) {
|
||||
vty_out(vty, "%% Malformed MAC address\n");
|
||||
return CMD_WARNING;
|
||||
}
|
||||
zebra_vxlan_print_specific_rmac_l3vni(vty, l3vni, &mac);
|
||||
zebra_vxlan_print_specific_rmac_l3vni(vty, l3vni, &mac, uj);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,8 @@ static void zvni_print_neigh_hash_all_vni(struct hash_backet *backet,
|
||||
void **args);
|
||||
static void zl3vni_print_nh(zebra_neigh_t *n, struct vty *vty,
|
||||
json_object *json);
|
||||
static void zl3vni_print_rmac(zebra_mac_t *zrmac, struct vty *vty);
|
||||
static void zl3vni_print_rmac(zebra_mac_t *zrmac, struct vty *vty,
|
||||
json_object *json);
|
||||
static void zvni_print_mac(zebra_mac_t *mac, void *ctxt);
|
||||
static void zvni_print_mac_hash(struct hash_backet *backet, void *ctxt);
|
||||
static void zvni_print_mac_hash_all_vni(struct hash_backet *backet, void *ctxt);
|
||||
@ -466,21 +467,39 @@ static void zl3vni_print_nh(zebra_neigh_t *n,
|
||||
|
||||
/* Print a specific RMAC entry */
|
||||
static void zl3vni_print_rmac(zebra_mac_t *zrmac,
|
||||
struct vty *vty)
|
||||
struct vty *vty,
|
||||
json_object *json)
|
||||
{
|
||||
char buf1[ETHER_ADDR_STRLEN];
|
||||
char buf2[PREFIX_STRLEN];
|
||||
struct listnode *node = NULL;
|
||||
struct prefix *p = NULL;
|
||||
json_object *json_hosts = NULL;
|
||||
|
||||
vty_out(vty, "MAC: %s\n",
|
||||
prefix_mac2str(&zrmac->macaddr, buf1, sizeof(buf1)));
|
||||
vty_out(vty, " Remote VTEP: %s\n",
|
||||
inet_ntoa(zrmac->fwd_info.r_vtep_ip));
|
||||
vty_out(vty, " Host-List:\n");
|
||||
for (ALL_LIST_ELEMENTS_RO(zrmac->host_list, node, p))
|
||||
vty_out(vty, " %s\n",
|
||||
prefix2str(p, buf2, sizeof(buf2)));
|
||||
if (!json) {
|
||||
vty_out(vty, "MAC: %s\n",
|
||||
prefix_mac2str(&zrmac->macaddr, buf1, sizeof(buf1)));
|
||||
vty_out(vty, " Remote VTEP: %s\n",
|
||||
inet_ntoa(zrmac->fwd_info.r_vtep_ip));
|
||||
vty_out(vty, " Host-List:\n");
|
||||
for (ALL_LIST_ELEMENTS_RO(zrmac->host_list, node, p))
|
||||
vty_out(vty, " %s\n",
|
||||
prefix2str(p, buf2, sizeof(buf2)));
|
||||
} else {
|
||||
json_hosts = json_object_new_array();
|
||||
json_object_string_add(json, "Rmac",
|
||||
prefix_mac2str(&zrmac->macaddr,
|
||||
buf1,
|
||||
sizeof(buf1)));
|
||||
json_object_string_add(json, "vtep-ip",
|
||||
inet_ntoa(zrmac->fwd_info.r_vtep_ip));
|
||||
for (ALL_LIST_ELEMENTS_RO(zrmac->host_list, node, p))
|
||||
json_object_array_add(json_hosts,
|
||||
json_object_new_string(
|
||||
prefix2str(p, buf2,
|
||||
sizeof(buf2))));
|
||||
json_object_object_add(json, "hosts", json_hosts);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -3691,29 +3710,50 @@ void zebra_vxlan_evpn_vrf_route_del(vrf_id_t vrf_id,
|
||||
|
||||
void zebra_vxlan_print_specific_rmac_l3vni(struct vty *vty,
|
||||
vni_t l3vni,
|
||||
struct ethaddr *rmac)
|
||||
struct ethaddr *rmac,
|
||||
u_char use_json)
|
||||
{
|
||||
zebra_l3vni_t *zl3vni = NULL;
|
||||
zebra_mac_t *zrmac = NULL;
|
||||
json_object *json = NULL;
|
||||
|
||||
if (!is_evpn_enabled())
|
||||
if (!is_evpn_enabled()) {
|
||||
if (use_json)
|
||||
vty_out(vty, "{}\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (use_json)
|
||||
json = json_object_new_object();
|
||||
|
||||
zl3vni = zl3vni_lookup(l3vni);
|
||||
if (!zl3vni) {
|
||||
vty_out(vty, "%% L3-VNI %u doesnt exist\n",
|
||||
l3vni);
|
||||
if (use_json)
|
||||
vty_out(vty, "{}\n");
|
||||
else
|
||||
vty_out(vty, "%% L3-VNI %u doesnt exist\n",
|
||||
l3vni);
|
||||
return;
|
||||
}
|
||||
|
||||
zrmac = zl3vni_rmac_lookup(zl3vni, rmac);
|
||||
if (!zrmac) {
|
||||
vty_out(vty, "%% Requested RMAC doesnt exist in L3-VNI %u",
|
||||
l3vni);
|
||||
if (use_json)
|
||||
vty_out(vty, "{}\n");
|
||||
else
|
||||
vty_out(vty,
|
||||
"%% Requested RMAC doesnt exist in L3-VNI %u",
|
||||
l3vni);
|
||||
return;
|
||||
}
|
||||
|
||||
zl3vni_print_rmac(zrmac, vty);
|
||||
zl3vni_print_rmac(zrmac, vty, json);
|
||||
|
||||
if (use_json) {
|
||||
vty_out(vty, "%s\n", json_object_to_json_string_ext(
|
||||
json, JSON_C_TO_STRING_PRETTY));
|
||||
json_object_free(json);
|
||||
}
|
||||
}
|
||||
|
||||
void zebra_vxlan_print_rmacs_l3vni(struct vty *vty,
|
||||
|
@ -56,7 +56,8 @@ extern int zebra_vxlan_vrf_delete(struct zebra_vrf *);
|
||||
extern void zebra_vxlan_print_specific_nh_l3vni(struct vty *vty, vni_t l3vni,
|
||||
struct ipaddr *ip, u_char uj);
|
||||
extern void zebra_vxlan_print_specific_rmac_l3vni(struct vty *vty, vni_t l3vni,
|
||||
struct ethaddr *rmac);
|
||||
struct ethaddr *rmac,
|
||||
u_char use_json);
|
||||
extern void zebra_vxlan_print_macs_vni(struct vty *vty, struct zebra_vrf *zvrf,
|
||||
vni_t vni, u_char use_json);
|
||||
extern void zebra_vxlan_print_macs_all_vni(struct vty *vty,
|
||||
|
Loading…
Reference in New Issue
Block a user