41 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) 48 #define foreach_vpe_api_msg \ 49 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \ 50 _(SW_INTERFACE_SET_MTU, sw_interface_set_mtu) \ 51 _(WANT_INTERFACE_EVENTS, want_interface_events) \ 52 _(SW_INTERFACE_DUMP, sw_interface_dump) \ 53 _(SW_INTERFACE_DETAILS, sw_interface_details) \ 54 _(SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address) \ 55 _(SW_INTERFACE_SET_TABLE, sw_interface_set_table) \ 56 _(SW_INTERFACE_GET_TABLE, sw_interface_get_table) \ 57 _(SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered) \ 58 _(SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats) \ 59 _(SW_INTERFACE_TAG_ADD_DEL, sw_interface_tag_add_del) 103 rv = VNET_API_ERROR_FEATURE_DISABLED;
104 goto bad_sw_if_index;
107 if (mtu < hi->min_supported_packet_bytes)
109 rv = VNET_API_ERROR_INVALID_VALUE;
110 goto bad_sw_if_index;
115 rv = VNET_API_ERROR_INVALID_VALUE;
116 goto bad_sw_if_index;
133 u8 * interface_name,
u32 context)
143 memset (mp, 0,
sizeof (*mp));
144 mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_DETAILS);
187 u32 vtr_push_dot1q = 0, vtr_tag1 = 0, vtr_tag2 = 0;
190 &vtr_op, &vtr_push_dot1q, &vtr_tag1, &vtr_tag2) != 0)
194 clib_warning (
"cannot get vlan tag rewrite for sw_if_index %d",
199 mp->
vtr_op = ntohl (vtr_op);
219 u8 *filter_string = 0, *name_string = 0;
221 char *strcasestr (
char *,
char *);
237 name_string = format (name_string,
"%U%c",
238 format_vnet_sw_interface_name,
239 am->vnet_main, swif, 0);
241 if (mp->name_filter_valid == 0 ||
242 strcasestr((char *) name_string, (char *) filter_string)) {
244 send_sw_interface_details (am, q, swif, name_string, mp->context);
246 _vec_len (name_string) = 0;
280 REPLY_MACRO (VL_API_SW_INTERFACE_ADD_DEL_ADDRESS_REPLY);
334 u32 context,
int retval,
u32 vrf_id)
339 memset (mp, 0,
sizeof (*mp));
340 mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_GET_TABLE_REPLY);
342 mp->
retval = htonl (retval);
343 mp->
vrf_id = htonl (vrf_id);
353 u32 sw_if_index = ~0;
389 u32 sw_if_index, unnumbered_sw_if_index;
400 unnumbered_sw_if_index))
402 rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
410 rv = VNET_API_ERROR_INVALID_SW_IF_INDEX_2;
432 REPLY_MACRO (VL_API_SW_INTERFACE_SET_UNNUMBERED_REPLY);
446 int i, j, n_counters;
465 for (j = 0; j < n_counters; j++)
467 for (i = 0; i <
vec_len (my_vnet_mains); i++)
480 for (j = 0; j < n_counters; j++)
482 for (i = 0; i <
vec_len (my_vnet_mains); i++)
495 REPLY_MACRO (VL_API_SW_INTERFACE_CLEAR_STATS_REPLY);
498 #define API_LINK_STATE_EVENT 1 499 #define API_ADMIN_UP_DOWN_EVENT 2 521 memset (mp, 0,
sizeof (*mp));
522 mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_SET_FLAGS);
537 uword *event_data = 0;
540 u32 prev_sw_if_index;
558 prev_sw_if_index = ~0;
560 for (i = 0; i <
vec_len (event_data); i++)
563 if (prev_sw_if_index == event_data[i])
565 prev_sw_if_index = event_data[
i];
570 q = vl_api_client_index_to_input_queue (reg->client_index);
574 if (!pool_is_free_index (vnm->interface_main.sw_interfaces,
577 swif = vnet_get_sw_interface (vnm, event_data[i]);
578 send_sw_interface_flags (vam, q, swif);
593 u32 hw_if_index,
u32 flags);
599 .name =
"vpe-link-state-process",
614 link_state_process_node.index,
631 link_state_process_node.index,
651 rv = VNET_API_ERROR_INVALID_VALUE;
664 REPLY_MACRO (VL_API_SW_INTERFACE_TAG_ADD_DEL_REPLY);
680 #define vl_msg_name_crc_list 681 #include <vnet/interface.api.h> 682 #undef vl_msg_name_crc_list 687 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id); 688 foreach_vl_msg_name_crc_interface;
700 vl_msg_api_set_handlers(VL_API_##N, #n, \ 701 vl_api_##n##_t_handler, \ 703 vl_api_##n##_t_endian, \ 704 vl_api_##n##_t_print, \ 705 sizeof(vl_api_##n##_t), 1);
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
#define VNET_SW_INTERFACE_FLAG_UNNUMBERED
static int event_data_cmp(void *a1, void *a2)
sll srl srl sll sra u16x4 i
static uword * vlib_process_wait_for_event(vlib_main_t *vm)
void vl_msg_api_send_shmem(unix_shared_memory_queue_t *q, u8 *elem)
static vlib_main_t * vlib_get_main(void)
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
void stats_dsunlock(void)
VNET_HW_INTERFACE_LINK_UP_DOWN_FUNCTION(link_up_down_function)
ethernet_main_t * ethernet_get_main(vlib_main_t *vm)
Set flags on the interface.
vnet_interface_main_t interface_main
static void vl_api_sw_interface_add_del_address_t_handler(vl_api_sw_interface_add_del_address_t *mp)
u32 fib_table_get_index_for_sw_if_index(fib_protocol_t proto, u32 sw_if_index)
Get the index of the FIB bound to the interface.
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
vnet_main_t ** vnet_mains
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
static void vnet_clear_sw_interface_tag(vnet_main_t *vnm, u32 sw_if_index)
unix_shared_memory_queue_t * vl_api_client_index_to_input_queue(u32 index)
VLIB_API_INIT_FUNCTION(interface_api_hookup)
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
Reply to sw_interface_clear_stats.
u32 * fib_index_by_sw_if_index
Table index indexed by software interface.
static void vl_api_sw_interface_set_unnumbered_t_handler(vl_api_sw_interface_set_unnumbered_t *mp)
#define clib_error_report(e)
#define VNET_HW_INTERFACE_FLAG_LINK_UP
static void send_sw_interface_details(vpe_api_main_t *am, unix_shared_memory_queue_t *q, vnet_sw_interface_t *swif, u8 *interface_name, u32 context)
static void vl_api_sw_interface_dump_t_handler(vl_api_sw_interface_dump_t *mp)
#define VNET_HW_INTERFACE_FLAG_DUPLEX_MASK
static clib_error_t * interface_api_hookup(vlib_main_t *vm)
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
static uword link_state_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
Reply to set / clear software interface tag.
static void send_sw_interface_get_table_reply(unix_shared_memory_queue_t *q, u32 context, int retval, u32 vrf_id)
#define VNET_HW_INTERFACE_FLAG_SPEED_MASK
ethernet_main_t ethernet_main
vnet_main_t * vnet_get_main(void)
Reply to sw_interface_set_table.
void vlib_clear_combined_counters(vlib_combined_counter_main_t *cm)
Clear a collection of combined counters.
Clear interface statistics.
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
struct vnet_sub_interface_t::@154::@155::@157 flags
vlib_combined_counter_main_t * combined_sw_if_counters
Get VRF id assigned to interface.
#define clib_warning(format, args...)
A collection of simple counters.
u32 max_supported_packet_bytes
clib_error_t * ip4_add_del_interface_address(vlib_main_t *vm, u32 sw_if_index, ip4_address_t *address, u32 address_length, u32 is_del)
static clib_error_t * link_up_down_function(vnet_main_t *vm, u32 hw_if_index, u32 flags)
#define VNET_HW_INTERFACE_FLAG_DUPLEX_SHIFT
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static void vlib_zero_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
Clear a combined counter Clears the set of per-thread u16 counters, and the shared vlib_counter_t...
void ip4_sw_interface_enable_disable(u32 sw_if_index, u32 is_enable)
static void vl_api_sw_interface_get_table_t_handler(vl_api_sw_interface_get_table_t *mp)
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
static void vl_api_sw_interface_details_t_handler(vl_api_sw_interface_details_t *mp)
#define VNET_HW_INTERFACE_FLAG_SPEED_SHIFT
Reply to get_sw_interface_vrf.
vlib_simple_counter_main_t * sw_if_counters
void ip_del_all_interface_addresses(vlib_main_t *vm, u32 sw_if_index)
Set unnumbered interface add / del response.
Set or delete one or all ip addresses on a specified interface.
Reply to sw_interface_set_flags.
vnet_hw_interface_class_t ethernet_hw_interface_class
static void setup_message_id_table(api_main_t *am)
static uword vlib_process_get_events_with_type(vlib_main_t *vm, uword **data_vector, uword with_type_opaque)
#define BAD_SW_IF_INDEX_LABEL
void * vl_msg_api_alloc(int nbytes)
static void vl_api_sw_interface_set_flags_t_handler(vl_api_sw_interface_set_flags_t *mp)
u32 ft_table_id
Table ID (hash key) for this FIB.
void stats_dslock_with_hint(int hint, int tag)
#define vec_free(V)
Free vector's memory (no header).
static clib_error_t * admin_up_down_function(vnet_main_t *vm, u32 hw_if_index, u32 flags)
#define API_ADMIN_UP_DOWN_EVENT
#define clib_memcpy(a, b, c)
#define ETHERNET_INTERFACE_FLAG_MTU
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
#define foreach_vpe_api_msg
VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION(admin_up_down_function)
u32 unnumbered_sw_if_index
foreach_registration_hash u8 link_state_process_up
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
static void vnet_set_sw_interface_tag(vnet_main_t *vnm, u8 *tag, u32 sw_if_index)
static void vl_api_sw_interface_tag_add_del_t_handler(vl_api_sw_interface_tag_add_del_t *mp)
#define API_LINK_STATE_EVENT
u32 fib_table_find_or_create_and_lock(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
static void vlib_zero_simple_counter(vlib_simple_counter_main_t *cm, u32 index)
Clear a simple counter Clears the set of per-thread u16 counters, and the u64 counter.
static u8 * vnet_get_sw_interface_tag(vnet_main_t *vnm, u32 sw_if_index)
static void vl_api_sw_interface_clear_stats_t_handler(vl_api_sw_interface_clear_stats_t *mp)
static void vl_api_sw_interface_set_mtu_t_handler(vl_api_sw_interface_set_mtu_t *mp)
ethernet_interface_t * ethernet_get_interface(ethernet_main_t *em, u32 hw_if_index)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
struct vnet_sub_interface_t::@154 eth
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
vnet_sw_interface_t * sw_interfaces
Reply to sw_interface_add_del_address.
Set unnumbered interface add / del request.
fib_table_t * fib_table_get(fib_node_index_t index, fib_protocol_t proto)
Get a pointer to a FIB table.
A collection of combined counters.
u32 l2vtr_get(vlib_main_t *vlib_main, vnet_main_t *vnet_main, u32 sw_if_index, u32 *vtr_op, u32 *push_dot1q, u32 *vtr_tag1, u32 *vtr_tag2)
Get vtag tag rewrite on the given interface.
void vlib_clear_simple_counters(vlib_simple_counter_main_t *cm)
Clear a collection of simple counters.
#define VLIB_REGISTER_NODE(x,...)
ip4_main_t ip4_main
Global ip4 main structure.
pub_sub_handler(interface_events, INTERFACE_EVENTS)
static void send_sw_interface_flags(vpe_api_main_t *am, unix_shared_memory_queue_t *q, vnet_sw_interface_t *swif)
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, u32 flags)
clib_error_t * ip6_add_del_interface_address(vlib_main_t *vm, u32 sw_if_index, ip6_address_t *address, u32 address_length, u32 is_del)
Interface details structure (fix this)
static void vl_api_sw_interface_set_table_t_handler(vl_api_sw_interface_set_table_t *mp)
Set / clear software interface tag.
ethernet_interface_t * interfaces
vpe_api_main_t vpe_api_main
Associate the specified interface with a fib table.
u32 * fib_index_by_sw_if_index
void ip6_sw_interface_enable_disable(u32 sw_if_index, u32 is_enable)
#define VALIDATE_SW_IF_INDEX(mp)
A protocol Independent FIB table.
u32 unnumbered_sw_if_index
struct _unix_shared_memory_queue unix_shared_memory_queue_t
Reply to sw_interface_set_mtu.
u32 ethernet_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)