aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/vat/api_format.c37
-rw-r--r--src/vnet/l2/l2.api17
-rw-r--r--src/vnet/l2/l2_api.c44
-rw-r--r--src/vpp/api/custom_dump.c6
4 files changed, 53 insertions, 51 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index 536c4b06ba2..d9a9d223804 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -7300,11 +7300,11 @@ api_bd_ip_mac_add_del (vat_main_t * vam)
M (BD_IP_MAC_ADD_DEL, mp);
- mp->bd_id = ntohl (bd_id);
+ mp->entry.bd_id = ntohl (bd_id);
mp->is_add = is_add;
- clib_memcpy (&mp->ip, &ip, sizeof (ip));
- clib_memcpy (&mp->mac, &mac, sizeof (mac));
+ clib_memcpy (&mp->entry.ip, &ip, sizeof (ip));
+ clib_memcpy (&mp->entry.mac, &mac, sizeof (mac));
S (mp);
W (ret);
@@ -7349,21 +7349,12 @@ static void vl_api_bd_ip_mac_details_t_handler
(vl_api_bd_ip_mac_details_t * mp)
{
vat_main_t *vam = &vat_main;
- u8 *ip = 0;
-
- if (!mp->is_ipv6)
- ip =
- format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
- else
- ip =
- format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
print (vam->ofp,
- "\n%-5d %-7s %-20U %-30s",
- ntohl (mp->bd_id), mp->is_ipv6 ? "ip6" : "ip4",
- format_ethernet_address, mp->mac_address, ip);
-
- vec_free (ip);
+ "\n%-5d %U %U",
+ ntohl (mp->entry.bd_id),
+ format_vl_api_mac_address, mp->entry.mac,
+ format_vl_api_address, &mp->entry.ip);
}
static void vl_api_bd_ip_mac_details_t_handler_json
@@ -7380,19 +7371,13 @@ static void vl_api_bd_ip_mac_details_t_handler_json
node = vat_json_array_add (&vam->json_tree);
vat_json_init_object (node);
- vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
- vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
+ vat_json_object_add_uint (node, "bd_id", ntohl (mp->entry.bd_id));
vat_json_object_add_string_copy (node, "mac_address",
- format (0, "%U", format_ethernet_address,
- &mp->mac_address));
+ format (0, "%U", format_vl_api_mac_address,
+ &mp->entry.mac));
u8 *ip = 0;
- if (!mp->is_ipv6)
- ip =
- format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
- else
- ip =
- format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
+ ip = format (0, "%U", format_vl_api_address, &mp->entry.ip);
vat_json_object_add_string_copy (node, "ip_address", ip);
vec_free (ip);
}
diff --git a/src/vnet/l2/l2.api b/src/vnet/l2/l2.api
index f756b87868c..4b1029d90f8 100644
--- a/src/vnet/l2/l2.api
+++ b/src/vnet/l2/l2.api
@@ -482,14 +482,20 @@ autoreply define sw_interface_set_l2_bridge
@param ip - ipv4 or ipv6 address
@param mac - MAC address
*/
+
+typedef bd_ip_mac
+{
+ u32 bd_id;
+ vl_api_address_t ip;
+ vl_api_mac_address_t mac;
+};
+
autoreply define bd_ip_mac_add_del
{
u32 client_index;
u32 context;
- u32 bd_id;
u8 is_add;
- vl_api_address_t ip;
- vl_api_mac_address_t mac;
+ vl_api_bd_ip_mac_t entry;
};
/** \brief Flush bridge domain IP to MAC entries
@@ -512,10 +518,7 @@ autoreply define bd_ip_mac_flush
define bd_ip_mac_details
{
u32 context;
- u32 bd_id;
- u8 is_ipv6;
- u8 ip_address[16];
- vl_api_mac_address_t mac_address;
+ vl_api_bd_ip_mac_t entry;
};
/** \brief Dump bridge domain IP to MAC entries
diff --git a/src/vnet/l2/l2_api.c b/src/vnet/l2/l2_api.c
index 47942ecfb2a..255e91b2e0a 100644
--- a/src/vnet/l2/l2_api.c
+++ b/src/vnet/l2/l2_api.c
@@ -786,8 +786,10 @@ out:
static void
send_bd_ip_mac_entry (vpe_api_main_t * am,
vl_api_registration_t * reg,
- u32 bd_id, u8 is_ipv6,
- u8 * ip_address, u8 * mac_address, u32 context)
+ u32 bd_id,
+ const ip46_address_t * ip,
+ ip46_type_t itype,
+ const mac_address_t * mac, u32 context)
{
vl_api_bd_ip_mac_details_t *mp;
@@ -795,12 +797,11 @@ send_bd_ip_mac_entry (vpe_api_main_t * am,
clib_memset (mp, 0, sizeof (*mp));
mp->_vl_msg_id = ntohs (VL_API_BD_IP_MAC_DETAILS);
- mp->bd_id = ntohl (bd_id);
-
- clib_memcpy (mp->mac_address, mac_address, 6);
- mp->is_ipv6 = is_ipv6;
- clib_memcpy (mp->ip_address, ip_address, (is_ipv6) ? 16 : 4);
mp->context = context;
+ mp->entry.bd_id = ntohl (bd_id);
+
+ ip_address_encode (ip, itype, &mp->entry.ip);
+ mac_address_encode (mac, mp->entry.mac);
vl_api_send_msg (reg, (u8 *) mp);
}
@@ -845,18 +846,31 @@ vl_api_bd_ip_mac_dump_t_handler (vl_api_bd_ip_mac_dump_t * mp)
{
ip4_address_t ip4_addr;
ip6_address_t *ip6_addr;
- u64 mac_addr;
+ mac_address_t mac;
+ u64 mac64;
bd_id = bd_config->bd_id;
/* *INDENT-OFF* */
- hash_foreach (ip4_addr.as_u32, mac_addr, bd_config->mac_by_ip4,
+ hash_foreach (ip4_addr.as_u32, mac64, bd_config->mac_by_ip4,
({
- send_bd_ip_mac_entry (am, reg, bd_id, 0, (u8 *) &(ip4_addr.as_u8), (u8 *) &mac_addr, mp->context);
+ ip46_address_t ip = {
+ .ip4 = ip4_addr,
+ };
+ mac_address_from_u64(&mac, mac64);
+
+ send_bd_ip_mac_entry (am, reg, bd_id, &ip, IP46_TYPE_IP4,
+ &mac, mp->context);
}));
- hash_foreach_mem (ip6_addr, mac_addr, bd_config->mac_by_ip6,
+ hash_foreach_mem (ip6_addr, mac64, bd_config->mac_by_ip6,
({
- send_bd_ip_mac_entry (am, reg, bd_id, 1, (u8 *) &(ip6_addr->as_u8), (u8 *) &mac_addr, mp->context);
+ ip46_address_t ip = {
+ .ip6 = *ip6_addr,
+ };
+ mac_address_from_u64(&mac, mac64);
+
+ send_bd_ip_mac_entry (am, reg, bd_id, &ip, IP46_TYPE_IP6,
+ &mac, mp->context);
}));
/* *INDENT-ON* */
}
@@ -875,7 +889,7 @@ vl_api_bd_ip_mac_add_del_t_handler (vl_api_bd_ip_mac_add_del_t * mp)
int rv = 0;
uword *p;
- bd_id = ntohl (mp->bd_id);
+ bd_id = ntohl (mp->entry.bd_id);
if (bd_id == 0)
{
@@ -891,8 +905,8 @@ vl_api_bd_ip_mac_add_del_t_handler (vl_api_bd_ip_mac_add_del_t * mp)
}
bd_index = p[0];
- type = ip_address_decode (&mp->ip, &ip_addr);
- mac_address_decode (mp->mac, &mac);
+ type = ip_address_decode (&mp->entry.ip, &ip_addr);
+ mac_address_decode (mp->entry.mac, &mac);
if (bd_add_del_ip_mac (bd_index, type, &ip_addr, &mac, mp->is_add))
rv = VNET_API_ERROR_UNSPECIFIED;
diff --git a/src/vpp/api/custom_dump.c b/src/vpp/api/custom_dump.c
index 494e1ab5cc8..94a868e0353 100644
--- a/src/vpp/api/custom_dump.c
+++ b/src/vpp/api/custom_dump.c
@@ -511,10 +511,10 @@ static void *vl_api_bd_ip_mac_add_del_t_print
u8 *s;
s = format (0, "SCRIPT: bd_ip_mac_add_del ");
- s = format (s, "bd_id %d ", ntohl (mp->bd_id));
+ s = format (s, "bd_id %d ", ntohl (mp->entry.bd_id));
- s = format (s, "%U ", format_vl_api_address, &mp->ip);
- s = format (s, "%U ", format_vl_api_mac_address, &mp->mac);
+ s = format (s, "%U ", format_vl_api_address, &mp->entry.ip);
+ s = format (s, "%U ", format_vl_api_mac_address, &mp->entry.mac);
if (mp->is_add == 0)
s = format (s, "del ");