#include <vnet/l2/l2_fib.h>
#include <vnet/l2/l2_vtr.h>
#include <vnet/l2/l2_learn.h>
+#include <vnet/l2/l2_bd.h>
+#include <vnet/ip/ip_types_api.h>
+#include <vnet/ethernet/ethernet_types_api.h>
#include <vnet/vnet_msg_enum.h>
vl_api_l2_xconnect_details_t *mp;
mp = vl_msg_api_alloc (sizeof (*mp));
- memset (mp, 0, sizeof (*mp));
+ clib_memset (mp, 0, sizeof (*mp));
mp->_vl_msg_id = ntohs (VL_API_L2_XCONNECT_DETAILS);
mp->context = context;
mp->rx_sw_if_index = htonl (rx_sw_if_index);
vl_api_l2_fib_table_details_t *mp;
mp = vl_msg_api_alloc (sizeof (*mp));
- memset (mp, 0, sizeof (*mp));
+ clib_memset (mp, 0, sizeof (*mp));
mp->_vl_msg_id = ntohs (VL_API_L2_FIB_TABLE_DETAILS);
mp->bd_id =
mp = vl_msg_api_alloc (sizeof (*mp) +
(n_sw_ifs * sizeof (vl_api_bridge_domain_sw_if_t)));
- memset (mp, 0, sizeof (*mp));
+ clib_memset (mp, 0, sizeof (*mp));
mp->_vl_msg_id = ntohs (VL_API_BRIDGE_DOMAIN_DETAILS);
mp->bd_id = ntohl (bd_config->bd_id);
mp->flood = bd_feature_flood (bd_config);
mp->learn = bd_feature_learn (bd_config);
mp->arp_term = bd_feature_arp_term (bd_config);
mp->bvi_sw_if_index = ntohl (bd_config->bvi_sw_if_index);
+ mp->uu_fwd_sw_if_index = ntohl (bd_config->uu_fwd_sw_if_index);
mp->mac_age = bd_config->mac_age;
if (bd_config->bd_tag)
{
}
}
+static bd_flags_t
+bd_flags_decode (vl_api_bd_flags_t v)
+{
+ bd_flags_t f = L2_NONE;
+
+ v = ntohl (v);
+
+ if (v & BRIDGE_API_FLAG_LEARN)
+ f |= L2_LEARN;
+ if (v & BRIDGE_API_FLAG_FWD)
+ f |= L2_FWD;
+ if (v & BRIDGE_API_FLAG_FLOOD)
+ f |= L2_FLOOD;
+ if (v & BRIDGE_API_FLAG_UU_FLOOD)
+ f |= L2_UU_FLOOD;
+ if (v & BRIDGE_API_FLAG_ARP_TERM)
+ f |= L2_ARP_TERM;
+
+ return (f);
+}
+
static void
vl_api_bridge_flags_t_handler (vl_api_bridge_flags_t * mp)
{
vl_api_bridge_flags_reply_t *rmp;
int rv = 0;
- u32 flags = ntohl (mp->feature_bitmap);
+ bd_flags_t flags = bd_flags_decode (mp->flags);
u32 bd_id = ntohl (mp->bd_id);
if (bd_id == 0)
{
{
VALIDATE_TX_SW_IF_INDEX (mp);
rv = set_int_l2_mode (vm, vnm, MODE_L2_XC,
- rx_sw_if_index, 0, 0, 0, tx_sw_if_index);
+ rx_sw_if_index, 0,
+ L2_BD_PORT_TYPE_NORMAL, 0, tx_sw_if_index);
}
else
{
- rv = set_int_l2_mode (vm, vnm, MODE_L3, rx_sw_if_index, 0, 0, 0, 0);
+ rv = set_int_l2_mode (vm, vnm, MODE_L3, rx_sw_if_index, 0,
+ L2_BD_PORT_TYPE_NORMAL, 0, 0);
+ }
+
+ switch (rv)
+ {
+ case MODE_ERROR_ETH:
+ rv = VNET_API_ERROR_NON_ETHERNET;
+ break;
+ case MODE_ERROR_BVI_DEF:
+ rv = VNET_API_ERROR_BD_ALREADY_HAS_BVI;
+ break;
}
BAD_RX_SW_IF_INDEX_LABEL;
REPLY_MACRO (VL_API_SW_INTERFACE_SET_L2_XCONNECT_REPLY);
}
+static int
+l2_bd_port_type_decode (vl_api_l2_port_type_t v, l2_bd_port_type_t * l)
+{
+ v = clib_net_to_host_u32 (v);
+
+ switch (v)
+ {
+ case L2_API_PORT_TYPE_NORMAL:
+ *l = L2_BD_PORT_TYPE_NORMAL;
+ return 0;
+ case L2_API_PORT_TYPE_BVI:
+ *l = L2_BD_PORT_TYPE_BVI;
+ return 0;
+ case L2_API_PORT_TYPE_UU_FWD:
+ *l = L2_BD_PORT_TYPE_UU_FWD;
+ return 0;
+ }
+
+ return (VNET_API_ERROR_INVALID_VALUE);
+}
+
static void
vl_api_sw_interface_set_l2_bridge_t_handler
(vl_api_sw_interface_set_l2_bridge_t * mp)
int rv = 0;
vlib_main_t *vm = vlib_get_main ();
vnet_main_t *vnm = vnet_get_main ();
+ l2_bd_port_type_t pt;
VALIDATE_RX_SW_IF_INDEX (mp);
u32 rx_sw_if_index = ntohl (mp->rx_sw_if_index);
+ rv = l2_bd_port_type_decode (mp->port_type, &pt);
-
+ if (0 != rv)
+ goto out;
if (mp->enable)
{
VALIDATE_BD_ID (mp);
u32 bd_id = ntohl (mp->bd_id);
u32 bd_index = bd_find_or_add_bd_index (bdm, bd_id);
- u32 bvi = mp->bvi;
- u8 shg = mp->shg;
+
rv = set_int_l2_mode (vm, vnm, MODE_L2_BRIDGE,
- rx_sw_if_index, bd_index, bvi, shg, 0);
+ rx_sw_if_index, bd_index, pt, mp->shg, 0);
}
else
{
- rv = set_int_l2_mode (vm, vnm, MODE_L3, rx_sw_if_index, 0, 0, 0, 0);
+ rv = set_int_l2_mode (vm, vnm, MODE_L3, rx_sw_if_index, 0, pt, 0, 0);
+ }
+
+ switch (rv)
+ {
+ case MODE_ERROR_ETH:
+ rv = VNET_API_ERROR_NON_ETHERNET;
+ break;
+ case MODE_ERROR_BVI_DEF:
+ rv = VNET_API_ERROR_BD_ALREADY_HAS_BVI;
+ break;
}
BAD_RX_SW_IF_INDEX_LABEL;
BAD_BD_ID_LABEL;
-
+out:
REPLY_MACRO (VL_API_SW_INTERFACE_SET_L2_BRIDGE_REPLY);
}
vl_api_bd_ip_mac_details_t *mp;
mp = vl_msg_api_alloc (sizeof (*mp));
- memset (mp, 0, sizeof (*mp));
+ clib_memset (mp, 0, sizeof (*mp));
mp->_vl_msg_id = ntohs (VL_API_BD_IP_MAC_DETAILS);
mp->bd_id = ntohl (bd_id);
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;
+ ip46_address_t ip_addr = ip46_address_initializer;
vl_api_bd_ip_mac_add_del_reply_t *rmp;
+ bd_main_t *bdm = &bd_main;
+ u32 bd_index, bd_id;
+ mac_address_t mac;
+ ip46_type_t type;
int rv = 0;
- u32 bd_id = ntohl (mp->bd_id);
- u32 bd_index;
uword *p;
+ bd_id = ntohl (mp->bd_id);
+
if (bd_id == 0)
{
rv = VNET_API_ERROR_BD_NOT_MODIFIABLE;
rv = VNET_API_ERROR_NO_SUCH_ENTRY;
goto out;
}
-
bd_index = p[0];
- if (bd_add_del_ip_mac (bd_index, mp->ip_address,
- mp->mac_address, mp->is_ipv6, mp->is_add))
+
+ type = ip_address_decode (&mp->ip, &ip_addr);
+ mac_address_decode (&mp->mac, &mac);
+
+ if (bd_add_del_ip_mac (bd_index, type, &ip_addr, &mac, mp->is_add))
rv = VNET_API_ERROR_UNSPECIFIED;
out:
/*
* l2_api_hookup
* Add vpe's API message handlers to the table.
- * vlib has alread mapped shared memory and
+ * vlib has already mapped shared memory and
* added the client registration handlers.
* See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
*/