summaryrefslogtreecommitdiffstats
path: root/src/vnet/l2
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/l2')
-rw-r--r--src/vnet/l2/l2.api26
-rw-r--r--src/vnet/l2/l2_api.c80
2 files changed, 106 insertions, 0 deletions
diff --git a/src/vnet/l2/l2.api b/src/vnet/l2/l2.api
index 05b250bd885..ae639682a38 100644
--- a/src/vnet/l2/l2.api
+++ b/src/vnet/l2/l2.api
@@ -459,6 +459,32 @@ autoreply define bd_ip_mac_add_del
u8 mac_address[6];
};
+/** \brief bridge domain IP to MAC entry details structure
+ @param bd_id - bridge domain table id
+ @param is_ipv6 - if non-zero, ipv6 address, else ipv4 address
+ @param ip_address - ipv4 or ipv6 address
+ @param mac_address - MAC address
+*/
+define bd_ip_mac_details
+{
+ u32 context;
+ u32 bd_id;
+ u8 is_ipv6;
+ u8 ip_address[16];
+ u8 mac_address[6];
+};
+
+/** \brief Dump bridge domain IP to MAC entries
+ @param client_index - opaque cookie to identify the sender
+ @param bd_id - bridge domain identifier
+*/
+define bd_ip_mac_dump
+{
+ u32 client_index;
+ u32 context;
+ u32 bd_id;
+};
+
/** \brief L2 interface ethernet flow point filtering enable/disable request
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
diff --git a/src/vnet/l2/l2_api.c b/src/vnet/l2/l2_api.c
index be3b75e9658..5ec7581ff3b 100644
--- a/src/vnet/l2/l2_api.c
+++ b/src/vnet/l2/l2_api.c
@@ -63,6 +63,7 @@ _(SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge) \
_(L2_PATCH_ADD_DEL, l2_patch_add_del) \
_(L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter) \
_(BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del) \
+_(BD_IP_MAC_DUMP, bd_ip_mac_dump) \
_(BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del) \
_(BRIDGE_DOMAIN_DUMP, bridge_domain_dump) \
_(BRIDGE_FLAGS, bridge_flags) \
@@ -702,6 +703,85 @@ static void
}
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)
+{
+ vl_api_bd_ip_mac_details_t *mp;
+
+ mp = vl_msg_api_alloc (sizeof (*mp));
+ 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;
+
+ vl_api_send_msg (reg, (u8 *) mp);
+}
+
+static void
+vl_api_bd_ip_mac_dump_t_handler (vl_api_bd_ip_mac_dump_t * mp)
+{
+ vpe_api_main_t *am = &vpe_api_main;
+ bd_main_t *bdm = &bd_main;
+ l2_bridge_domain_t *bd_config;
+ u32 bd_id = ntohl (mp->bd_id);
+ u32 bd_index, start = 1, end;
+ vl_api_registration_t *reg;
+ uword *p;
+
+ reg = vl_api_client_index_to_registration (mp->client_index);
+ if (!reg)
+ return;
+
+ end = vec_len (l2input_main.bd_configs);
+
+ /* see bd_id: ~0 means "any" */
+ if (bd_id == ~0)
+ bd_index = ~0;
+ else
+ {
+ p = hash_get (bdm->bd_index_by_bd_id, bd_id);
+ if (p == 0)
+ return;
+
+ bd_index = p[0];
+ vec_validate (l2input_main.bd_configs, bd_index);
+ start = bd_index;
+ end = start + 1;
+ }
+
+ for (bd_index = start; bd_index < end; bd_index++)
+ {
+ bd_config = vec_elt_at_index (l2input_main.bd_configs, bd_index);
+ if (bd_is_valid (bd_config))
+ {
+ ip4_address_t ip4_addr;
+ ip6_address_t *ip6_addr;
+ u64 mac_addr;
+ bd_id = bd_config->bd_id;
+
+ /* *INDENT-OFF* */
+ hash_foreach (ip4_addr.as_u32, mac_addr, 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);
+ }));
+
+ hash_foreach_mem (ip6_addr, mac_addr, 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);
+ }));
+ /* *INDENT-ON* */
+ }
+ }
+}
+
+static void
vl_api_bd_ip_mac_add_del_t_handler (vl_api_bd_ip_mac_add_del_t * mp)
{
bd_main_t *bdm = &bd_main;