61 const static u8 ethernet_mcast_dst_mac[] = {
62 0x1, 0x0, 0x5e, 0x0, 0x0, 0x0,
65 return (ethernet_mcast_dst_mac);
71 const static u8 ethernet_mcast_dst_mac[] = {
72 0x33, 0x33, 0x00, 0x0, 0x0, 0x0,
75 return (ethernet_mcast_dst_mac);
94 uword n_bytes =
sizeof (h[0]);
101 if (sub_sw != sup_sw)
134 #define _(a,b) case VNET_LINK_##a: type = ETHERNET_TYPE_##b; break 166 clib_host_to_net_u16 (ETHERNET_TYPE_DOT1AD) :
167 clib_host_to_net_u16 (ETHERNET_TYPE_VLAN);
170 outer->
type = clib_host_to_net_u16 (type);
179 clib_host_to_net_u16 (ETHERNET_TYPE_DOT1AD) :
180 clib_host_to_net_u16 (ETHERNET_TYPE_VLAN);
183 outer->
type = clib_host_to_net_u16 (ETHERNET_TYPE_VLAN);
186 inner->
type = clib_host_to_net_u16 (type);
191 h->
type = clib_host_to_net_u16 (type);
226 adj->rewrite_header.sw_if_index,
252 offset =
vec_len (rewrite) - 2;
313 u32 *result = va_arg (*args,
u32 *);
324 *result = hw_if_index;
335 u32 * hw_if_index_return,
349 dev_class_index, dev_instance,
351 *hw_if_index_return = hw_if_index;
478 u32 n_left_from, *from;
487 u32 new_rx_sw_if_index = ~0;
488 u32 new_tx_sw_if_index = ~0;
505 while (n_left_from >= 4)
507 u32 sw_if_index0, sw_if_index1, sw_if_index2, sw_if_index3;
508 u32 not_all_match_config;
525 not_all_match_config = (sw_if_index0 ^ sw_if_index1)
526 ^ (sw_if_index2 ^ sw_if_index3);
527 not_all_match_config += sw_if_index0 ^ new_rx_sw_if_index;
532 next[0] = next_index;
533 next[1] = next_index;
534 next[2] = next_index;
535 next[3] = next_index;
560 thread_index, new_rx_sw_if_index,
578 != new_rx_sw_if_index))
588 next[0] = next_index;
597 thread_index, new_rx_sw_if_index,
601 != new_rx_sw_if_index))
611 next[1] = next_index;
620 thread_index, new_rx_sw_if_index,
624 != new_rx_sw_if_index))
634 next[2] = next_index;
643 thread_index, new_rx_sw_if_index,
647 != new_rx_sw_if_index))
657 next[3] = next_index;
666 thread_index, new_rx_sw_if_index,
672 while (n_left_from > 0)
675 != new_rx_sw_if_index))
685 next[0] = next_index;
694 thread_index, new_rx_sw_if_index,
709 u32 dev_instance = va_arg (*args,
u32);
710 return format (s,
"loop%d", dev_instance);
746 #define LOOPBACK_MAX_INSTANCE (16 * 1024) 817 u8 is_specified,
u32 user_instance)
831 *sw_if_indexp = (
u32) ~ 0;
842 return VNET_API_ERROR_INVALID_REGISTRATION;
850 if (memcmp (address, mac_address,
sizeof (address)))
851 clib_memcpy (address, mac_address,
sizeof (address));
861 ethernet_simulated_device_class.index, instance, address, &hw_if_index,
866 rv = VNET_API_ERROR_INVALID_REGISTRATION;
903 u32 user_instance = 0;
905 clib_memset (mac_address, 0,
sizeof (mac_address));
911 if (
unformat (input,
"instance %d", &user_instance))
918 is_specified, user_instance);
941 .path =
"loopback create-interface",
942 .short_help =
"loopback create-interface [mac <mac-addr>] [instance <instance>]",
960 .path =
"create loopback interface",
961 .short_help =
"create loopback interface [mac <mac-addr>] [instance <instance>]",
1029 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
1032 if (hw == 0 || hw->
dev_class_index != ethernet_simulated_device_class.index)
1033 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
1036 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
1046 u32 * sub_sw_if_index)
1051 u64 sup_and_sub_key = ((
u64) (sw_if_index) << 32) | (
u64)
id;
1061 return (VNET_API_ERROR_VLAN_ALREADY_EXISTS);
1068 template.sub.id =
id;
1069 template.sub.eth.raw_flags =
flags;
1070 template.sub.eth.outer_vlan_id = outer_vlan_id;
1071 template.sub.eth.inner_vlan_id = inner_vlan_id;
1074 return (VNET_API_ERROR_UNSPECIFIED);
1077 *kp = sup_and_sub_key;
1093 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
1102 u64 sup_and_sub_key =
1109 rv = VNET_API_ERROR_INVALID_SUB_SW_IF_INDEX;
1132 if (sw_if_index == ~0)
1159 if (sw_if_index == ~0)
1163 rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
1183 .path =
"loopback delete-interface",
1184 .short_help =
"loopback delete-interface intfc <interface>",
1201 .path =
"delete loopback interface",
1202 .short_help =
"delete loopback interface intfc <interface>",
1216 .path =
"delete sub-interface",
1217 .short_help =
"delete sub-interface <interface>",
unformat_function_t unformat_vnet_hw_interface
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
ethernet_address_change_ctx_t * address_change_callbacks
Functions to call when interface hw address changes.
int vnet_delete_loopback_interface(u32 sw_if_index)
#define VNET_REWRITE_FOR_SW_INTERFACE_ADDRESS_BROADCAST
#define CLIB_MEM_UNPOISON(a, s)
#define hash_set(h, key, value)
static clib_error_t * delete_simulated_ethernet_interfaces(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define hash_unset(h, key)
vl_api_wireguard_peer_flags_t flags
static void vlib_increment_combined_counter(vlib_combined_counter_main_t *cm, u32 thread_index, u32 index, u64 n_packets, u64 n_bytes)
Increment a combined counter.
mac_address_t * secondary_addrs
An indication that the rewrite is complete, i.e.
vnet_main_t * vnet_get_main(void)
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
vnet_interface_main_t interface_main
vnet_p2p_sub_interface_t p2p
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
ethernet_interface_t * interfaces
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
This packet is to be rewritten and forwarded to the next processing node.
static const u8 * ethernet_ip4_mcast_dst_addr(void)
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
int vnet_delete_sub_interface(u32 sw_if_index)
static uword * clib_bitmap_set(uword *ai, uword i, uword value)
Sets the ith bit of a bitmap to new_value Removes trailing zeros from the bitmap. ...
#define hash_set_mem(h, key, value)
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
uword * sub_interface_sw_if_index_by_id
unformat_function_t unformat_vnet_sw_interface
clib_error_t * ethernet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, const u8 *address, u32 *hw_if_index_return, ethernet_flag_change_function_t flag_change)
#define ETHERNET_INTERFACE_FLAG_DEFAULT_L3
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
format_function_t format_vnet_sw_if_index_name
struct vnet_sub_interface_t::@356::@357::@359 flags
#define VNET_SIMULATED_ETHERNET_TX_NEXT_L2_INPUT
vnet_link_t ia_link
link/ether-type 1 bytes
static vnet_sw_interface_t * vnet_get_hw_sw_interface(vnet_main_t *vnm, u32 hw_if_index)
#define clib_memcpy(d, s, n)
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
Adjacency to punt this packet.
void adj_glean_update_rewrite(adj_index_t adj_index)
adj_glean_update_rewrite
ethernet_main_t ethernet_main
static ip_adjacency_t * adj_get(adj_index_t adj_index)
Get a pointer to an adjacency object from its index.
vnet_flood_class_t flood_class
static clib_error_t * ethernet_config(vlib_main_t *vm, unformat_input_t *input)
void default_update_adjacency(vnet_main_t *vnm, u32 sw_if_index, u32 ai)
Default adjacency update function.
u8 * format_ethernet_address(u8 *s, va_list *args)
vlib_combined_counter_main_t * combined_sw_if_counters
vnet_hw_interface_flags_t flags
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
static vnet_sw_interface_t * vnet_get_sup_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
#define clib_error_return(e, args...)
ethernet_flag_change_function_t * flag_change
static clib_error_t * simulated_ethernet_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
u32 vnet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u32 hw_class_index, u32 hw_instance)
#define ETHERNET_INTERFACE_FLAGS_STATUS_MASK
u32 max_supported_packet_bytes
vl_api_fib_path_type_t type
void adj_mcast_update_rewrite(adj_index_t adj_index, u8 *rewrite, u8 offset)
adj_mcast_update_rewrite
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static clib_error_t * ethernet_mac_change(vnet_hw_interface_t *hi, const u8 *old_address, const u8 *mac_address)
static u32 loopback_instance_alloc(u8 is_specified, u32 want)
#define LOOPBACK_MAX_INSTANCE
struct vnet_sub_interface_t::@356 eth
#define pool_put(P, E)
Free an object E in pool P.
uword * sw_if_index_by_sup_and_sub
static int loopback_instance_free(u32 instance)
#define ETHERNET_INTERFACE_FLAG_STATUS_L3
#define VLIB_CONFIG_FUNCTION(x, n,...)
This packet matches an "interface route" and packets need to be passed to ARP to find rewrite string ...
vl_api_address_union_t src_address
static const u8 * ethernet_ip6_mcast_dst_addr(void)
u32 default_mtu
Default interface MTU.
vnet_hw_interface_class_t ethernet_hw_interface_class
uword unformat_ethernet_interface(unformat_input_t *input, va_list *args)
static clib_error_t * create_simulated_ethernet_interfaces(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u8 * format_ethernet_header_with_length(u8 *s, va_list *args)
VNET_HW_INTERFACE_CLASS(ethernet_hw_interface_class)
uword vlib_node_add_named_next_with_slot(vlib_main_t *vm, uword node, char *name, uword slot)
This packet matches an "incomplete adjacency" and packets need to be passed to ARP to find rewrite st...
Adjacency to drop this packet.
mac_address_t * ethernet_interface_add_del_address(ethernet_main_t *em, u32 hw_if_index, const u8 *address, u8 is_add)
static_always_inline void vlib_buffer_enqueue_to_next(vlib_main_t *vm, vlib_node_runtime_t *node, u32 *buffers, u16 *nexts, uword count)
sll srl srl sll sra u16x4 i
Multicast Midchain Adjacency.
static int ethernet_mac_address_equal(const u8 *a, const u8 *b)
#define VNET_SIMULATED_ETHERNET_TX_NEXT_ETHERNET_INPUT
#define ETHERNET_INTERFACE_FLAG_MTU
#define ETHERNET_INTERFACE_FLAG_ACCEPT_ALL
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
uword * bm_loopback_instances
static uword clib_bitmap_get(uword *ai, uword i)
Gets the ith bit value from a bitmap.
int vnet_create_loopback_interface(u32 *sw_if_indexp, u8 *mac_address, u8 is_specified, u32 user_instance)
vlib_main_t vlib_node_runtime_t * node
#define VLIB_CLI_COMMAND(x,...)
static u8 * format_simulated_ethernet_name(u8 *s, va_list *args)
This packets follow a mid-chain adjacency.
void ethernet_delete_interface(vnet_main_t *vnm, u32 hw_if_index)
static uword simulated_ethernet_interface_tx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Echo packets back to ethernet/l2-input.
ethernet_address_change_function_t * function
uword unformat_ethernet_address(unformat_input_t *input, va_list *args)
#define pool_put_index(p, i)
Free pool element with given index.
u32() ethernet_flag_change_function_t(vnet_main_t *vnm, struct vnet_hw_interface_t *hi, u32 flags)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
manual_print typedef address
#define vec_delete(V, N, M)
Delete N elements starting at element M.
enum vnet_link_t_ vnet_link_t
Link Type: A description of the protocol of packets on the link.
#define vec_is_member(v, e)
True if given pointer is within given vector.
#define clib_error_report(e)
static void hash_unset_mem_free(uword **h, const void *key)
vlan_intf_t vlans[ETHERNET_N_VLAN]
static void * clib_mem_alloc(uword size)
static vlib_main_t * vlib_get_main(void)
void vnet_delete_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
int vnet_create_sub_interface(u32 sw_if_index, u32 id, u32 flags, u16 inner_vlan_id, u16 outer_vlan_id, u32 *sub_sw_if_index)
This packets needs to go to ICMP error.
This packet is for one of our own IP addresses.
fib_protocol_t ia_nh_proto
The protocol of the neighbor/peer.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
ip_lookup_next_t lookup_next_index
Next hop after ip4-lookup.
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, vnet_hw_interface_flags_t flags)
VLIB buffer representation.
vnet_sw_interface_t * sw_interfaces
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
u32 ethernet_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
u8 * ethernet_build_rewrite(vnet_main_t *vnm, u32 sw_if_index, vnet_link_t link_type, const void *dst_address)
build a rewrite string to use for sending packets of type 'link_type' to 'dst_address' ...
void vnet_sw_interface_set_mtu(vnet_main_t *vnm, u32 sw_if_index, u32 mtu)
#define ETHERNET_INTERFACE_FLAGS_SET_OPN_MASK
#define hash_get_mem(h, key)
struct clib_bihash_value offset
template key/value backing page structure
u32 min_supported_packet_bytes
vnet_sw_interface_type_t type
#define STRUCT_SIZE_OF(t, f)
#define ETHERNET_MAX_PACKET_BYTES
#define vec_foreach(var, vec)
Vector iterator.
void vnet_delete_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
ethernet_interface_t * ethernet_get_interface(ethernet_main_t *em, u32 hw_if_index)
VNET_DEVICE_CLASS(ethernet_simulated_device_class)
clib_error_t * vnet_create_sw_interface(vnet_main_t *vnm, vnet_sw_interface_t *template, u32 *sw_if_index)
manual_print typedef u8 mac_address[6]
static_always_inline void vlib_get_buffers(vlib_main_t *vm, u32 *bi, vlib_buffer_t **b, int count)
Translate array of buffer indices into buffer pointers.
static uword clib_bitmap_first_clear(uword *ai)
Return the lowest numbered clear bit in a bitmap.
#define ETHERNET_MIN_PACKET_BYTES
void adj_nbr_update_rewrite(adj_index_t adj_index, adj_nbr_rewrite_flag_t flags, u8 *rewrite)
adj_nbr_update_rewrite
void ethernet_update_adjacency(vnet_main_t *vnm, u32 sw_if_index, u32 ai)
static clib_error_t * delete_sub_interface(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * simulated_ethernet_mac_change(vnet_hw_interface_t *hi, const u8 *old_address, const u8 *mac_address)
static void ethernet_setup_node(vlib_main_t *vm, u32 node_index)
vl_api_interface_index_t sw_if_index
void ip_neighbor_update(vnet_main_t *vnm, adj_index_t ai)
uword unformat_ethernet_header(unformat_input_t *input, va_list *args)