#include <vnet/api_errno.h>
#include <vnet/l2/l2_input.h>
#include <vnet/l2/l2_fib.h>
+#include <vnet/l2/l2_vtr.h>
#include <vnet/vnet_msg_enum.h>
_(L2_XCONNECT_DUMP, l2_xconnect_dump) \
_(L2_FIB_CLEAR_TABLE, l2_fib_clear_table) \
_(L2_FIB_TABLE_DUMP, l2_fib_table_dump) \
-_(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
+_(L2FIB_FLUSH_INT, l2fib_flush_int) \
+_(L2FIB_FLUSH_BD, l2fib_flush_bd) \
_(L2FIB_ADD_DEL, l2fib_add_del) \
_(L2_FLAGS, l2_flags) \
_(BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del) \
_(BRIDGE_DOMAIN_DUMP, bridge_domain_dump) \
-_(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
-_(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
-_(BRIDGE_FLAGS, bridge_flags)
+_(BRIDGE_FLAGS, bridge_flags) \
+_(L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite) \
+_(L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite) \
+_(BRIDGE_DOMAIN_SET_MAC_AGE, bridge_domain_set_mac_age)
static void
send_l2_xconnect_details (unix_shared_memory_queue_t * q, u32 context,
vl_msg_api_send_shmem (q, (u8 *) & mp);
}
-static void
-vl_api_l2_fib_table_entry_t_handler (vl_api_l2_fib_table_entry_t * mp)
-{
- clib_warning ("BUG");
-}
-
static void
vl_api_l2_fib_table_dump_t_handler (vl_api_l2_fib_table_dump_t * mp)
{
REPLY_MACRO (VL_API_L2FIB_ADD_DEL_REPLY);
}
+static void
+vl_api_l2fib_flush_int_t_handler (vl_api_l2fib_flush_int_t * mp)
+{
+ int rv = 0;
+ vlib_main_t *vm = vlib_get_main ();
+ vl_api_l2fib_flush_int_reply_t *rmp;
+
+ VALIDATE_SW_IF_INDEX (mp);
+
+ u32 sw_if_index = ntohl (mp->sw_if_index);
+ l2fib_flush_int_mac (vm, sw_if_index);
+
+ BAD_SW_IF_INDEX_LABEL;
+ REPLY_MACRO (VL_API_L2FIB_FLUSH_INT_REPLY);
+}
+
+static void
+vl_api_l2fib_flush_bd_t_handler (vl_api_l2fib_flush_bd_t * mp)
+{
+ int rv = 0;
+ vlib_main_t *vm = vlib_get_main ();
+ bd_main_t *bdm = &bd_main;
+ vl_api_l2fib_flush_bd_reply_t *rmp;
+
+ u32 bd_id = ntohl (mp->bd_id);
+ uword *p = hash_get (bdm->bd_index_by_bd_id, bd_id);
+ if (p == 0)
+ {
+ rv = VNET_API_ERROR_NO_SUCH_ENTRY;
+ goto out;
+ }
+ l2fib_flush_bd_mac (vm, *p);
+out:
+ REPLY_MACRO (VL_API_L2FIB_FLUSH_BD_REPLY);
+}
+
static void
vl_api_l2_flags_t_handler (vl_api_l2_flags_t * mp)
{
vl_api_l2_flags_reply_t *rmp;
int rv = 0;
- u32 sw_if_index = ntohl (mp->sw_if_index);
- u32 flags = ntohl (mp->feature_bitmap);
u32 rbm = 0;
VALIDATE_SW_IF_INDEX (mp);
-#define _(a,b) \
- if (flags & L2INPUT_FEAT_ ## a) \
- rbm = l2input_intf_bitmap_enable (sw_if_index, L2INPUT_FEAT_ ## a, mp->is_set);
- foreach_l2input_feat;
-#undef _
+ u32 sw_if_index = ntohl (mp->sw_if_index);
+ u32 flags = ntohl (mp->feature_bitmap) & L2INPUT_VALID_MASK;
+ rbm = l2input_intf_bitmap_enable (sw_if_index, flags, mp->is_set);
BAD_SW_IF_INDEX_LABEL;
}
static void
-vl_api_bridge_domain_add_del_t_handler (vl_api_bridge_domain_add_del_t * mp)
+vl_api_bridge_domain_set_mac_age_t_handler (vl_api_bridge_domain_set_mac_age_t
+ * mp)
{
vlib_main_t *vm = vlib_get_main ();
bd_main_t *bdm = &bd_main;
- vl_api_bridge_domain_add_del_reply_t *rmp;
+ vl_api_bridge_domain_set_mac_age_reply_t *rmp;
int rv = 0;
- u32 enable_flags = 0, disable_flags = 0;
u32 bd_id = ntohl (mp->bd_id);
- u32 bd_index;
-
- if (mp->is_add)
+ uword *p = hash_get (bdm->bd_index_by_bd_id, bd_id);
+ if (p == 0)
{
- bd_index = bd_find_or_add_bd_index (bdm, bd_id);
-
- if (mp->flood)
- enable_flags |= L2_FLOOD;
- else
- disable_flags |= L2_FLOOD;
-
- if (mp->uu_flood)
- enable_flags |= L2_UU_FLOOD;
- else
- disable_flags |= L2_UU_FLOOD;
-
- if (mp->forward)
- enable_flags |= L2_FWD;
- else
- disable_flags |= L2_FWD;
-
- if (mp->arp_term)
- enable_flags |= L2_ARP_TERM;
- else
- disable_flags |= L2_ARP_TERM;
-
- if (mp->learn)
- enable_flags |= L2_LEARN;
- else
- disable_flags |= L2_LEARN;
-
- if (enable_flags)
- bd_set_flags (vm, bd_index, enable_flags, 1 /* enable */ );
-
- if (disable_flags)
- bd_set_flags (vm, bd_index, disable_flags, 0 /* disable */ );
-
- bd_set_mac_age (vm, bd_index, mp->mac_age);
+ rv = VNET_API_ERROR_NO_SUCH_ENTRY;
+ goto out;
}
- else
- rv = bd_delete_bd_index (bdm, bd_id);
-
- REPLY_MACRO (VL_API_BRIDGE_DOMAIN_ADD_DEL_REPLY);
+ bd_set_mac_age (vm, *p, mp->mac_age);
+out:
+ REPLY_MACRO (VL_API_BRIDGE_DOMAIN_SET_MAC_AGE_REPLY);
}
static void
-vl_api_bridge_domain_details_t_handler (vl_api_bridge_domain_details_t * mp)
+vl_api_bridge_domain_add_del_t_handler (vl_api_bridge_domain_add_del_t * mp)
{
- clib_warning ("BUG");
-}
+ l2_bridge_domain_add_del_args_t a = {
+ .is_add = mp->is_add,
+ .flood = mp->flood,
+ .uu_flood = mp->uu_flood,
+ .forward = mp->forward,
+ .learn = mp->learn,
+ .arp_term = mp->arp_term,
+ .mac_age = mp->mac_age,
+ .bd_id = ntohl (mp->bd_id),
+ };
+
+ int rv = bd_add_del (&a);
-static void
- vl_api_bridge_domain_sw_if_details_t_handler
- (vl_api_bridge_domain_sw_if_details_t * mp)
-{
- clib_warning ("BUG");
+ vl_api_bridge_domain_add_del_reply_t *rmp;
+ REPLY_MACRO (VL_API_BRIDGE_DOMAIN_ADD_DEL_REPLY);
}
static void
bd_id = ntohl (mp->bd_id);
- bd_index = (bd_id == ~0) ? 0 : bd_find_or_add_bd_index (bdm, bd_id);
+ bd_index = (bd_id == ~0) ? 0 : bd_find_index (bdm, bd_id);
+ ASSERT (bd_index != ~0);
end = (bd_id == ~0) ? vec_len (l2im->bd_configs) : bd_index + 1;
for (; bd_index < end; bd_index++)
{
/* *INDENT-ON* */
}
+static void
+ vl_api_l2_interface_vlan_tag_rewrite_t_handler
+ (vl_api_l2_interface_vlan_tag_rewrite_t * mp)
+{
+ int rv = 0;
+ vl_api_l2_interface_vlan_tag_rewrite_reply_t *rmp;
+ vnet_main_t *vnm = vnet_get_main ();
+ vlib_main_t *vm = vlib_get_main ();
+ u32 vtr_op;
+
+ VALIDATE_SW_IF_INDEX (mp);
+
+ vtr_op = ntohl (mp->vtr_op);
+
+ /* The L2 code is unsuspicious */
+ switch (vtr_op)
+ {
+ case L2_VTR_DISABLED:
+ case L2_VTR_PUSH_1:
+ case L2_VTR_PUSH_2:
+ case L2_VTR_POP_1:
+ case L2_VTR_POP_2:
+ case L2_VTR_TRANSLATE_1_1:
+ case L2_VTR_TRANSLATE_1_2:
+ case L2_VTR_TRANSLATE_2_1:
+ case L2_VTR_TRANSLATE_2_2:
+ break;
+
+ default:
+ rv = VNET_API_ERROR_INVALID_VALUE;
+ goto bad_sw_if_index;
+ }
+
+ rv = l2vtr_configure (vm, vnm, ntohl (mp->sw_if_index), vtr_op,
+ ntohl (mp->push_dot1q), ntohl (mp->tag1),
+ ntohl (mp->tag2));
+
+ BAD_SW_IF_INDEX_LABEL;
+
+ REPLY_MACRO (VL_API_L2_INTERFACE_VLAN_TAG_REWRITE_REPLY);
+}
+
+static void
+ vl_api_l2_interface_pbb_tag_rewrite_t_handler
+ (vl_api_l2_interface_pbb_tag_rewrite_t * mp)
+{
+ vl_api_l2_interface_pbb_tag_rewrite_reply_t *rmp;
+ vnet_main_t *vnm = vnet_get_main ();
+ vlib_main_t *vm = vlib_get_main ();
+ u32 vtr_op;
+ int rv = 0;
+
+ VALIDATE_SW_IF_INDEX (mp);
+
+ vtr_op = ntohl (mp->vtr_op);
+
+ switch (vtr_op)
+ {
+ case L2_VTR_DISABLED:
+ case L2_VTR_PUSH_2:
+ case L2_VTR_POP_2:
+ case L2_VTR_TRANSLATE_2_1:
+ break;
+
+ default:
+ rv = VNET_API_ERROR_INVALID_VALUE;
+ goto bad_sw_if_index;
+ }
+
+ rv = l2pbb_configure (vm, vnm, ntohl (mp->sw_if_index), vtr_op,
+ mp->b_dmac, mp->b_smac, ntohs (mp->b_vlanid),
+ ntohl (mp->i_sid), ntohs (mp->outer_tag));
+
+ BAD_SW_IF_INDEX_LABEL;
+
+ REPLY_MACRO (VL_API_L2_INTERFACE_PBB_TAG_REWRITE_REPLY);
+}
+
/*
* l2_api_hookup
* Add vpe's API message handlers to the table.