2 *------------------------------------------------------------------
3 * l2_api.c - layer 2 forwarding api
5 * Copyright (c) 2016 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
20 #include <vnet/vnet.h>
21 #include <vlibmemory/api.h>
23 #include <vnet/interface.h>
24 #include <vnet/api_errno.h>
25 #include <vnet/l2/l2_input.h>
26 #include <vnet/l2/l2_fib.h>
27 #include <vnet/l2/l2_vtr.h>
28 #include <vnet/l2/l2_learn.h>
30 #include <vnet/vnet_msg_enum.h>
32 #define vl_typedefs /* define message structures */
33 #include <vnet/vnet_all_api_h.h>
36 #define vl_endianfun /* define message structures */
37 #include <vnet/vnet_all_api_h.h>
40 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
41 #define vl_api_bridge_domain_details_t_print vl_noop_handler
43 /* instantiate all the print functions we know about */
44 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
46 #include <vnet/vnet_all_api_h.h>
49 #include <vlibapi/api_helper_macros.h>
51 #define foreach_vpe_api_msg \
52 _(L2_XCONNECT_DUMP, l2_xconnect_dump) \
53 _(L2_FIB_CLEAR_TABLE, l2_fib_clear_table) \
54 _(L2_FIB_TABLE_DUMP, l2_fib_table_dump) \
55 _(L2FIB_FLUSH_ALL, l2fib_flush_all) \
56 _(L2FIB_FLUSH_INT, l2fib_flush_int) \
57 _(L2FIB_FLUSH_BD, l2fib_flush_bd) \
58 _(L2FIB_ADD_DEL, l2fib_add_del) \
59 _(WANT_L2_MACS_EVENTS, want_l2_macs_events) \
60 _(L2_FLAGS, l2_flags) \
61 _(SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect) \
62 _(SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge) \
63 _(L2_PATCH_ADD_DEL, l2_patch_add_del) \
64 _(L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter) \
65 _(BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del) \
66 _(BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del) \
67 _(BRIDGE_DOMAIN_DUMP, bridge_domain_dump) \
68 _(BRIDGE_FLAGS, bridge_flags) \
69 _(L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite) \
70 _(L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite) \
71 _(BRIDGE_DOMAIN_SET_MAC_AGE, bridge_domain_set_mac_age) \
72 _(SW_INTERFACE_SET_VPATH, sw_interface_set_vpath)
75 send_l2_xconnect_details (vl_api_registration_t * reg, u32 context,
76 u32 rx_sw_if_index, u32 tx_sw_if_index)
78 vl_api_l2_xconnect_details_t *mp;
80 mp = vl_msg_api_alloc (sizeof (*mp));
81 memset (mp, 0, sizeof (*mp));
82 mp->_vl_msg_id = ntohs (VL_API_L2_XCONNECT_DETAILS);
83 mp->context = context;
84 mp->rx_sw_if_index = htonl (rx_sw_if_index);
85 mp->tx_sw_if_index = htonl (tx_sw_if_index);
87 vl_api_send_msg (reg, (u8 *) mp);
91 vl_api_l2_xconnect_dump_t_handler (vl_api_l2_xconnect_dump_t * mp)
93 vl_api_registration_t *reg;
94 vnet_main_t *vnm = vnet_get_main ();
95 vnet_interface_main_t *im = &vnm->interface_main;
96 l2input_main_t *l2im = &l2input_main;
97 vnet_sw_interface_t *swif;
98 l2_input_config_t *config;
100 reg = vl_api_client_index_to_registration (mp->client_index);
105 pool_foreach (swif, im->sw_interfaces,
107 config = vec_elt_at_index (l2im->configs, swif->sw_if_index);
108 if (config->xconnect)
109 send_l2_xconnect_details (reg, mp->context, swif->sw_if_index,
110 config->output_sw_if_index);
116 vl_api_l2_fib_clear_table_t_handler (vl_api_l2_fib_clear_table_t * mp)
119 vl_api_l2_fib_clear_table_reply_t *rmp;
121 /* Clear all MACs including static MACs */
122 l2fib_clear_table ();
124 REPLY_MACRO (VL_API_L2_FIB_CLEAR_TABLE_REPLY);
128 send_l2fib_table_entry (vpe_api_main_t * am,
129 vl_api_registration_t * reg,
130 l2fib_entry_key_t * l2fe_key,
131 l2fib_entry_result_t * l2fe_res, u32 context)
133 vl_api_l2_fib_table_details_t *mp;
135 mp = vl_msg_api_alloc (sizeof (*mp));
136 memset (mp, 0, sizeof (*mp));
137 mp->_vl_msg_id = ntohs (VL_API_L2_FIB_TABLE_DETAILS);
140 ntohl (l2input_main.bd_configs[l2fe_key->fields.bd_index].bd_id);
142 clib_memcpy (mp->mac, l2fe_key->fields.mac, 6);
143 mp->sw_if_index = ntohl (l2fe_res->fields.sw_if_index);
144 mp->static_mac = l2fe_res->fields.static_mac;
145 mp->filter_mac = l2fe_res->fields.filter;
146 mp->bvi_mac = l2fe_res->fields.bvi;
147 mp->context = context;
149 vl_api_send_msg (reg, (u8 *) mp);
153 vl_api_l2_fib_table_dump_t_handler (vl_api_l2_fib_table_dump_t * mp)
155 vpe_api_main_t *am = &vpe_api_main;
156 bd_main_t *bdm = &bd_main;
157 l2fib_entry_key_t *l2fe_key = NULL;
158 l2fib_entry_result_t *l2fe_res = NULL;
159 u32 ni, bd_id = ntohl (mp->bd_id);
161 vl_api_registration_t *reg;
164 reg = vl_api_client_index_to_registration (mp->client_index);
168 /* see l2fib_table_dump: ~0 means "any" */
173 p = hash_get (bdm->bd_index_by_bd_id, bd_id);
180 l2fib_table_dump (bd_index, &l2fe_key, &l2fe_res);
182 vec_foreach_index (ni, l2fe_key)
184 send_l2fib_table_entry (am, reg, vec_elt_at_index (l2fe_key, ni),
185 vec_elt_at_index (l2fe_res, ni), mp->context);
192 vl_api_l2fib_add_del_t_handler (vl_api_l2fib_add_del_t * mp)
194 bd_main_t *bdm = &bd_main;
195 l2input_main_t *l2im = &l2input_main;
196 vl_api_l2fib_add_del_reply_t *rmp;
198 u32 bd_id = ntohl (mp->bd_id);
199 uword *p = hash_get (bdm->bd_index_by_bd_id, bd_id);
203 rv = VNET_API_ERROR_NO_SUCH_ENTRY;
204 goto bad_sw_if_index;
210 clib_memcpy (mac, mp->mac, 6);
214 l2fib_add_filter_entry (mac, bd_index);
217 u32 sw_if_index = ntohl (mp->sw_if_index);
218 VALIDATE_SW_IF_INDEX (mp);
219 if (vec_len (l2im->configs) <= sw_if_index)
221 rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
222 goto bad_sw_if_index;
226 l2_input_config_t *config;
227 config = vec_elt_at_index (l2im->configs, sw_if_index);
228 if (config->bridge == 0)
230 rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
231 goto bad_sw_if_index;
234 u8 static_mac = mp->static_mac ? 1 : 0;
235 u8 bvi_mac = mp->bvi_mac ? 1 : 0;
236 l2fib_add_fwd_entry (mac, bd_index, sw_if_index, static_mac,
242 u32 sw_if_index = ntohl (mp->sw_if_index);
243 if (l2fib_del_entry (mac, bd_index, sw_if_index))
244 rv = VNET_API_ERROR_NO_SUCH_ENTRY;
247 BAD_SW_IF_INDEX_LABEL;
249 REPLY_MACRO (VL_API_L2FIB_ADD_DEL_REPLY);
253 vl_api_want_l2_macs_events_t_handler (vl_api_want_l2_macs_events_t * mp)
256 vl_api_want_l2_macs_events_reply_t *rmp;
257 l2learn_main_t *lm = &l2learn_main;
258 l2fib_main_t *fm = &l2fib_main;
259 u32 pid = ntohl (mp->pid);
260 u32 learn_limit = ntohl (mp->learn_limit);
262 if (mp->enable_disable)
264 if (lm->client_pid == 0)
266 lm->client_pid = pid;
267 lm->client_index = mp->client_index;
269 if (mp->max_macs_in_event)
270 fm->max_macs_in_event = mp->max_macs_in_event * 10;
272 fm->max_macs_in_event = L2FIB_EVENT_MAX_MACS_DEFAULT;
275 fm->event_scan_delay = (f64) (mp->scan_delay) * 10e-3;
277 fm->event_scan_delay = L2FIB_EVENT_SCAN_DELAY_DEFAULT;
279 /* change learn limit and flush all learned MACs */
280 if (learn_limit && (learn_limit < L2LEARN_DEFAULT_LIMIT))
281 lm->global_learn_limit = learn_limit;
283 lm->global_learn_limit = L2FIB_EVENT_LEARN_LIMIT_DEFAULT;
285 l2fib_flush_all_mac (vlib_get_main ());
287 else if (lm->client_pid != pid)
289 rv = VNET_API_ERROR_L2_MACS_EVENT_CLINET_PRESENT;
293 else if (lm->client_pid)
296 lm->client_index = 0;
297 if (learn_limit && (learn_limit < L2LEARN_DEFAULT_LIMIT))
298 lm->global_learn_limit = learn_limit;
300 lm->global_learn_limit = L2LEARN_DEFAULT_LIMIT;
304 REPLY_MACRO (VL_API_WANT_L2_MACS_EVENTS_REPLY);
308 vl_api_l2fib_flush_int_t_handler (vl_api_l2fib_flush_int_t * mp)
311 vlib_main_t *vm = vlib_get_main ();
312 vl_api_l2fib_flush_int_reply_t *rmp;
314 VALIDATE_SW_IF_INDEX (mp);
316 u32 sw_if_index = ntohl (mp->sw_if_index);
317 l2fib_flush_int_mac (vm, sw_if_index);
319 BAD_SW_IF_INDEX_LABEL;
320 REPLY_MACRO (VL_API_L2FIB_FLUSH_INT_REPLY);
324 vl_api_l2fib_flush_all_t_handler (vl_api_l2fib_flush_all_t * mp)
327 vl_api_l2fib_flush_all_reply_t *rmp;
329 l2fib_flush_all_mac (vlib_get_main ());
330 REPLY_MACRO (VL_API_L2FIB_FLUSH_ALL_REPLY);
334 vl_api_l2fib_flush_bd_t_handler (vl_api_l2fib_flush_bd_t * mp)
337 vlib_main_t *vm = vlib_get_main ();
338 bd_main_t *bdm = &bd_main;
339 vl_api_l2fib_flush_bd_reply_t *rmp;
341 u32 bd_id = ntohl (mp->bd_id);
342 uword *p = hash_get (bdm->bd_index_by_bd_id, bd_id);
345 rv = VNET_API_ERROR_NO_SUCH_ENTRY;
348 l2fib_flush_bd_mac (vm, *p);
350 REPLY_MACRO (VL_API_L2FIB_FLUSH_BD_REPLY);
354 vl_api_l2_flags_t_handler (vl_api_l2_flags_t * mp)
356 vl_api_l2_flags_reply_t *rmp;
360 VALIDATE_SW_IF_INDEX (mp);
362 u32 sw_if_index = ntohl (mp->sw_if_index);
363 u32 flags = ntohl (mp->feature_bitmap);
366 if (flags & L2_LEARN)
367 bitmap |= L2INPUT_FEAT_LEARN;
370 bitmap |= L2INPUT_FEAT_FWD;
372 if (flags & L2_FLOOD)
373 bitmap |= L2INPUT_FEAT_FLOOD;
375 if (flags & L2_UU_FLOOD)
376 bitmap |= L2INPUT_FEAT_UU_FLOOD;
378 if (flags & L2_ARP_TERM)
379 bitmap |= L2INPUT_FEAT_ARP_TERM;
381 rbm = l2input_intf_bitmap_enable (sw_if_index, bitmap, mp->is_set);
383 BAD_SW_IF_INDEX_LABEL;
386 REPLY_MACRO2(VL_API_L2_FLAGS_REPLY,
388 rmp->resulting_feature_bitmap = ntohl(rbm);
394 vl_api_bridge_domain_set_mac_age_t_handler (vl_api_bridge_domain_set_mac_age_t
397 vlib_main_t *vm = vlib_get_main ();
398 bd_main_t *bdm = &bd_main;
399 vl_api_bridge_domain_set_mac_age_reply_t *rmp;
401 u32 bd_id = ntohl (mp->bd_id);
406 rv = VNET_API_ERROR_BD_NOT_MODIFIABLE;
410 p = hash_get (bdm->bd_index_by_bd_id, bd_id);
413 rv = VNET_API_ERROR_NO_SUCH_ENTRY;
416 bd_set_mac_age (vm, *p, mp->mac_age);
418 REPLY_MACRO (VL_API_BRIDGE_DOMAIN_SET_MAC_AGE_REPLY);
422 vl_api_bridge_domain_add_del_t_handler (vl_api_bridge_domain_add_del_t * mp)
424 l2_bridge_domain_add_del_args_t a = {
425 .is_add = mp->is_add,
427 .uu_flood = mp->uu_flood,
428 .forward = mp->forward,
430 .arp_term = mp->arp_term,
431 .mac_age = mp->mac_age,
432 .bd_id = ntohl (mp->bd_id),
436 int rv = bd_add_del (&a);
438 vl_api_bridge_domain_add_del_reply_t *rmp;
439 REPLY_MACRO (VL_API_BRIDGE_DOMAIN_ADD_DEL_REPLY);
443 send_bridge_domain_details (l2input_main_t * l2im,
444 vl_api_registration_t * reg,
445 l2_bridge_domain_t * bd_config,
446 u32 n_sw_ifs, u32 context)
448 vl_api_bridge_domain_details_t *mp;
449 l2_flood_member_t *m;
450 vl_api_bridge_domain_sw_if_t *sw_ifs;
451 l2_input_config_t *input_cfg;
453 mp = vl_msg_api_alloc (sizeof (*mp) +
454 (n_sw_ifs * sizeof (vl_api_bridge_domain_sw_if_t)));
455 memset (mp, 0, sizeof (*mp));
456 mp->_vl_msg_id = ntohs (VL_API_BRIDGE_DOMAIN_DETAILS);
457 mp->bd_id = ntohl (bd_config->bd_id);
458 mp->flood = bd_feature_flood (bd_config);
459 mp->uu_flood = bd_feature_uu_flood (bd_config);
460 mp->forward = bd_feature_forward (bd_config);
461 mp->learn = bd_feature_learn (bd_config);
462 mp->arp_term = bd_feature_arp_term (bd_config);
463 mp->bvi_sw_if_index = ntohl (bd_config->bvi_sw_if_index);
464 mp->mac_age = bd_config->mac_age;
465 if (bd_config->bd_tag)
467 strncpy ((char *) mp->bd_tag, (char *) bd_config->bd_tag,
468 ARRAY_LEN (mp->bd_tag) - 1);
469 mp->bd_tag[ARRAY_LEN (mp->bd_tag) - 1] = 0;
472 mp->context = context;
474 sw_ifs = (vl_api_bridge_domain_sw_if_t *) mp->sw_if_details;
475 vec_foreach (m, bd_config->members)
477 sw_ifs->sw_if_index = ntohl (m->sw_if_index);
478 input_cfg = vec_elt_at_index (l2im->configs, m->sw_if_index);
479 sw_ifs->shg = input_cfg->shg;
483 mp->n_sw_ifs = htonl (mp->n_sw_ifs);
485 vl_api_send_msg (reg, (u8 *) mp);
489 vl_api_bridge_domain_dump_t_handler (vl_api_bridge_domain_dump_t * mp)
491 bd_main_t *bdm = &bd_main;
492 l2input_main_t *l2im = &l2input_main;
493 vl_api_registration_t *reg;
494 u32 bd_id, bd_index, end;
496 reg = vl_api_client_index_to_registration (mp->client_index);
500 bd_id = ntohl (mp->bd_id);
505 bd_index = 0, end = vec_len (l2im->bd_configs);
508 bd_index = bd_find_index (bdm, bd_id);
515 for (; bd_index < end; bd_index++)
517 l2_bridge_domain_t *bd_config =
518 l2input_bd_config_from_index (l2im, bd_index);
519 /* skip dummy bd_id 0 */
520 if (bd_config && (bd_config->bd_id > 0))
521 send_bridge_domain_details (l2im, reg, bd_config,
522 vec_len (bd_config->members),
528 vl_api_bridge_flags_t_handler (vl_api_bridge_flags_t * mp)
530 vlib_main_t *vm = vlib_get_main ();
531 bd_main_t *bdm = &bd_main;
532 vl_api_bridge_flags_reply_t *rmp;
535 u32 flags = ntohl (mp->feature_bitmap);
536 u32 bd_id = ntohl (mp->bd_id);
539 rv = VNET_API_ERROR_BD_NOT_MODIFIABLE;
543 u32 bd_index = bd_find_index (bdm, bd_id);
546 rv = VNET_API_ERROR_NO_SUCH_ENTRY;
550 u32 bitmap = bd_set_flags (vm, bd_index, flags, mp->is_set);
554 REPLY_MACRO2(VL_API_BRIDGE_FLAGS_REPLY,
556 rmp->resulting_feature_bitmap = ntohl(bitmap);
562 vl_api_l2_interface_vlan_tag_rewrite_t_handler
563 (vl_api_l2_interface_vlan_tag_rewrite_t * mp)
566 vl_api_l2_interface_vlan_tag_rewrite_reply_t *rmp;
567 vnet_main_t *vnm = vnet_get_main ();
568 vlib_main_t *vm = vlib_get_main ();
571 VALIDATE_SW_IF_INDEX (mp);
573 vtr_op = ntohl (mp->vtr_op);
575 /* The L2 code is unsuspicious */
578 case L2_VTR_DISABLED:
583 case L2_VTR_TRANSLATE_1_1:
584 case L2_VTR_TRANSLATE_1_2:
585 case L2_VTR_TRANSLATE_2_1:
586 case L2_VTR_TRANSLATE_2_2:
590 rv = VNET_API_ERROR_INVALID_VALUE;
591 goto bad_sw_if_index;
594 rv = l2vtr_configure (vm, vnm, ntohl (mp->sw_if_index), vtr_op,
595 ntohl (mp->push_dot1q), ntohl (mp->tag1),
598 BAD_SW_IF_INDEX_LABEL;
600 REPLY_MACRO (VL_API_L2_INTERFACE_VLAN_TAG_REWRITE_REPLY);
604 vl_api_l2_interface_pbb_tag_rewrite_t_handler
605 (vl_api_l2_interface_pbb_tag_rewrite_t * mp)
607 vl_api_l2_interface_pbb_tag_rewrite_reply_t *rmp;
608 vnet_main_t *vnm = vnet_get_main ();
609 vlib_main_t *vm = vlib_get_main ();
613 VALIDATE_SW_IF_INDEX (mp);
615 vtr_op = ntohl (mp->vtr_op);
619 case L2_VTR_DISABLED:
622 case L2_VTR_TRANSLATE_2_1:
626 rv = VNET_API_ERROR_INVALID_VALUE;
627 goto bad_sw_if_index;
630 rv = l2pbb_configure (vm, vnm, ntohl (mp->sw_if_index), vtr_op,
631 mp->b_dmac, mp->b_smac, ntohs (mp->b_vlanid),
632 ntohl (mp->i_sid), ntohs (mp->outer_tag));
634 BAD_SW_IF_INDEX_LABEL;
636 REPLY_MACRO (VL_API_L2_INTERFACE_PBB_TAG_REWRITE_REPLY);
640 vl_api_sw_interface_set_l2_xconnect_t_handler
641 (vl_api_sw_interface_set_l2_xconnect_t * mp)
643 vl_api_sw_interface_set_l2_xconnect_reply_t *rmp;
645 u32 rx_sw_if_index = ntohl (mp->rx_sw_if_index);
646 u32 tx_sw_if_index = ntohl (mp->tx_sw_if_index);
647 vlib_main_t *vm = vlib_get_main ();
648 vnet_main_t *vnm = vnet_get_main ();
650 VALIDATE_RX_SW_IF_INDEX (mp);
654 VALIDATE_TX_SW_IF_INDEX (mp);
655 rv = set_int_l2_mode (vm, vnm, MODE_L2_XC,
656 rx_sw_if_index, 0, 0, 0, tx_sw_if_index);
660 rv = set_int_l2_mode (vm, vnm, MODE_L3, rx_sw_if_index, 0, 0, 0, 0);
663 BAD_RX_SW_IF_INDEX_LABEL;
664 BAD_TX_SW_IF_INDEX_LABEL;
666 REPLY_MACRO (VL_API_SW_INTERFACE_SET_L2_XCONNECT_REPLY);
670 vl_api_sw_interface_set_l2_bridge_t_handler
671 (vl_api_sw_interface_set_l2_bridge_t * mp)
673 bd_main_t *bdm = &bd_main;
674 vl_api_sw_interface_set_l2_bridge_reply_t *rmp;
676 vlib_main_t *vm = vlib_get_main ();
677 vnet_main_t *vnm = vnet_get_main ();
679 VALIDATE_RX_SW_IF_INDEX (mp);
680 u32 rx_sw_if_index = ntohl (mp->rx_sw_if_index);
686 u32 bd_id = ntohl (mp->bd_id);
687 u32 bd_index = bd_find_or_add_bd_index (bdm, bd_id);
690 rv = set_int_l2_mode (vm, vnm, MODE_L2_BRIDGE,
691 rx_sw_if_index, bd_index, bvi, shg, 0);
695 rv = set_int_l2_mode (vm, vnm, MODE_L3, rx_sw_if_index, 0, 0, 0, 0);
698 BAD_RX_SW_IF_INDEX_LABEL;
701 REPLY_MACRO (VL_API_SW_INTERFACE_SET_L2_BRIDGE_REPLY);
705 vl_api_bd_ip_mac_add_del_t_handler (vl_api_bd_ip_mac_add_del_t * mp)
707 bd_main_t *bdm = &bd_main;
708 vl_api_bd_ip_mac_add_del_reply_t *rmp;
710 u32 bd_id = ntohl (mp->bd_id);
716 rv = VNET_API_ERROR_BD_NOT_MODIFIABLE;
720 p = hash_get (bdm->bd_index_by_bd_id, bd_id);
723 rv = VNET_API_ERROR_NO_SUCH_ENTRY;
728 if (bd_add_del_ip_mac (bd_index, mp->ip_address,
729 mp->mac_address, mp->is_ipv6, mp->is_add))
730 rv = VNET_API_ERROR_UNSPECIFIED;
733 REPLY_MACRO (VL_API_BD_IP_MAC_ADD_DEL_REPLY);
736 extern void l2_efp_filter_configure (vnet_main_t * vnet_main,
737 u32 sw_if_index, u8 enable);
740 vl_api_l2_interface_efp_filter_t_handler (vl_api_l2_interface_efp_filter_t *
744 vl_api_l2_interface_efp_filter_reply_t *rmp;
745 vnet_main_t *vnm = vnet_get_main ();
747 VALIDATE_SW_IF_INDEX (mp);
749 // enable/disable the feature
750 l2_efp_filter_configure (vnm, ntohl (mp->sw_if_index), mp->enable_disable);
753 BAD_SW_IF_INDEX_LABEL;
754 REPLY_MACRO (VL_API_L2_INTERFACE_EFP_FILTER_REPLY);
758 vl_api_l2_patch_add_del_t_handler (vl_api_l2_patch_add_del_t * mp)
760 extern int vnet_l2_patch_add_del (u32 rx_sw_if_index, u32 tx_sw_if_index,
762 vl_api_l2_patch_add_del_reply_t *rmp;
763 int vnet_l2_patch_add_del (u32 rx_sw_if_index, u32 tx_sw_if_index,
767 VALIDATE_RX_SW_IF_INDEX (mp);
768 VALIDATE_TX_SW_IF_INDEX (mp);
770 rv = vnet_l2_patch_add_del (ntohl (mp->rx_sw_if_index),
771 ntohl (mp->tx_sw_if_index),
772 (int) (mp->is_add != 0));
774 BAD_RX_SW_IF_INDEX_LABEL;
775 BAD_TX_SW_IF_INDEX_LABEL;
777 REPLY_MACRO (VL_API_L2_PATCH_ADD_DEL_REPLY);
781 vl_api_sw_interface_set_vpath_t_handler (vl_api_sw_interface_set_vpath_t * mp)
783 vl_api_sw_interface_set_vpath_reply_t *rmp;
785 u32 sw_if_index = ntohl (mp->sw_if_index);
787 VALIDATE_SW_IF_INDEX (mp);
789 l2input_intf_bitmap_enable (sw_if_index, L2INPUT_FEAT_VPATH, mp->enable);
790 vnet_feature_enable_disable ("ip4-unicast", "vpath-input-ip4",
791 sw_if_index, mp->enable, 0, 0);
792 vnet_feature_enable_disable ("ip4-multicast", "vpath-input-ip4",
793 sw_if_index, mp->enable, 0, 0);
794 vnet_feature_enable_disable ("ip6-unicast", "vpath-input-ip6",
795 sw_if_index, mp->enable, 0, 0);
796 vnet_feature_enable_disable ("ip6-multicast", "vpath-input-ip6",
797 sw_if_index, mp->enable, 0, 0);
799 BAD_SW_IF_INDEX_LABEL;
801 REPLY_MACRO (VL_API_SW_INTERFACE_SET_VPATH_REPLY);
806 * Add vpe's API message handlers to the table.
807 * vlib has alread mapped shared memory and
808 * added the client registration handlers.
809 * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
811 #define vl_msg_name_crc_list
812 #include <vnet/vnet_all_api_h.h>
813 #undef vl_msg_name_crc_list
816 setup_message_id_table (api_main_t * am)
818 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
819 foreach_vl_msg_name_crc_l2;
823 static clib_error_t *
824 l2_api_hookup (vlib_main_t * vm)
826 api_main_t *am = &api_main;
829 vl_msg_api_set_handlers(VL_API_##N, #n, \
830 vl_api_##n##_t_handler, \
832 vl_api_##n##_t_endian, \
833 vl_api_##n##_t_print, \
834 sizeof(vl_api_##n##_t), 1);
839 * Set up the (msg_name, crc, message-id) table
841 setup_message_id_table (am);
846 VLIB_API_INIT_FUNCTION (l2_api_hookup);
849 * fd.io coding-style-patch-verification: ON
852 * eval: (c-set-style "gnu")