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;
330 u32 *result = va_arg (*args,
u32 *);
341 *result = hw_if_index;
352 u32 * hw_if_index_return,
366 dev_class_index, dev_instance,
368 *hw_if_index_return = hw_if_index;
493 u32 n_left_from, *from;
502 u32 new_rx_sw_if_index = ~0;
503 u32 new_tx_sw_if_index = ~0;
520 while (n_left_from >= 4)
522 u32 sw_if_index0, sw_if_index1, sw_if_index2, sw_if_index3;
523 u32 not_all_match_config;
540 not_all_match_config = (sw_if_index0 ^ sw_if_index1)
541 ^ (sw_if_index2 ^ sw_if_index3);
542 not_all_match_config += sw_if_index0 ^ new_rx_sw_if_index;
547 next[0] = next_index;
548 next[1] = next_index;
549 next[2] = next_index;
550 next[3] = next_index;
575 thread_index, new_rx_sw_if_index,
593 != new_rx_sw_if_index))
603 next[0] = next_index;
612 thread_index, new_rx_sw_if_index,
616 != new_rx_sw_if_index))
626 next[1] = next_index;
635 thread_index, new_rx_sw_if_index,
639 != new_rx_sw_if_index))
649 next[2] = next_index;
658 thread_index, new_rx_sw_if_index,
662 != new_rx_sw_if_index))
672 next[3] = next_index;
681 thread_index, new_rx_sw_if_index,
687 while (n_left_from > 0)
690 != new_rx_sw_if_index))
700 next[0] = next_index;
709 thread_index, new_rx_sw_if_index,
724 u32 dev_instance = va_arg (*args,
u32);
725 return format (s,
"loop%d", dev_instance);
761 #define LOOPBACK_MAX_INSTANCE (16 * 1024) 832 u8 is_specified,
u32 user_instance)
846 *sw_if_indexp = (
u32) ~ 0;
857 return VNET_API_ERROR_INVALID_REGISTRATION;
865 if (memcmp (address, mac_address,
sizeof (address)))
866 clib_memcpy (address, mac_address,
sizeof (address));
876 ethernet_simulated_device_class.index, instance, address, &hw_if_index,
881 rv = VNET_API_ERROR_INVALID_REGISTRATION;
918 u32 user_instance = 0;
920 clib_memset (mac_address, 0,
sizeof (mac_address));
926 if (
unformat (input,
"instance %d", &user_instance))
933 is_specified, user_instance);
956 .path =
"loopback create-interface",
957 .short_help =
"loopback create-interface [mac <mac-addr>] [instance <instance>]",
975 .path =
"create loopback interface",
976 .short_help =
"create loopback interface [mac <mac-addr>] [instance <instance>]",
1022 return &if_addr->
mac;
1038 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
1041 if (hw == 0 || hw->
dev_class_index != ethernet_simulated_device_class.index)
1042 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
1045 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
1055 u32 * sub_sw_if_index)
1060 u64 sup_and_sub_key = ((
u64) (sw_if_index) << 32) | (
u64)
id;
1070 return (VNET_API_ERROR_VLAN_ALREADY_EXISTS);
1077 template.sub.id =
id;
1078 template.sub.eth.raw_flags =
flags;
1079 template.sub.eth.outer_vlan_id = outer_vlan_id;
1080 template.sub.eth.inner_vlan_id = inner_vlan_id;
1083 return (VNET_API_ERROR_UNSPECIFIED);
1086 *kp = sup_and_sub_key;
1102 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
1111 u64 sup_and_sub_key =
1118 rv = VNET_API_ERROR_INVALID_SUB_SW_IF_INDEX;
1141 if (sw_if_index == ~0)
1168 if (sw_if_index == ~0)
1172 rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
1192 .path =
"loopback delete-interface",
1193 .short_help =
"loopback delete-interface intfc <interface>",
1210 .path =
"delete loopback interface",
1211 .short_help =
"delete loopback interface intfc <interface>",
1225 .path =
"delete sub-interface",
1226 .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) ...
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' ...
uword unformat_ethernet_interface(unformat_input_t *input, va_list *args)
ethernet_address_change_ctx_t * address_change_callbacks
Functions to call when interface hw address changes.
#define VNET_REWRITE_FOR_SW_INTERFACE_ADDRESS_BROADCAST
#define hash_set(h, key, value)
static clib_error_t * ethernet_mac_change(vnet_hw_interface_t *hi, const u8 *old_address, const u8 *mac_address)
int vnet_create_loopback_interface(u32 *sw_if_indexp, u8 *mac_address, u8 is_specified, u32 user_instance)
#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.
void default_update_adjacency(vnet_main_t *vnm, u32 sw_if_index, u32 ai)
Default adjacency update function.
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)
static void ethernet_set_mac(vnet_hw_interface_t *hi, ethernet_interface_t *ei, const u8 *mac_address)
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.
void vnet_sw_interface_set_mtu(vnet_main_t *vnm, u32 sw_if_index, u32 mtu)
vnet_interface_main_t interface_main
vnet_p2p_sub_interface_t p2p
static clib_error_t * ethernet_config(vlib_main_t *vm, unformat_input_t *input)
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.
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
mac_address_t * ethernet_interface_add_del_address(ethernet_main_t *em, u32 hw_if_index, const u8 *address, u8 is_add)
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
u32 vnet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u32 hw_class_index, u32 hw_instance)
unformat_function_t unformat_vnet_sw_interface
#define LOOPBACK_MAX_INSTANCE
#define ETHERNET_INTERFACE_FLAG_DEFAULT_L3
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, vnet_hw_interface_flags_t flags)
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
static int loopback_instance_free(u32 instance)
#define VNET_SIMULATED_ETHERNET_TX_NEXT_L2_INPUT
vnet_link_t ia_link
link/ether-type 1 bytes
VNET_DEVICE_CLASS(ethernet_simulated_device_class)
static vnet_sw_interface_t * vnet_get_hw_sw_interface(vnet_main_t *vnm, u32 hw_if_index)
#define clib_memcpy(d, s, n)
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 void ethernet_interface_address_copy(ethernet_interface_address_t *dst, const u8 *mac)
u8 * format_ethernet_address(u8 *s, va_list *args)
int vnet_delete_loopback_interface(u32 sw_if_index)
vlib_combined_counter_main_t * combined_sw_if_counters
description fragment has unexpected format
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
ethernet_interface_t * ethernet_get_interface(ethernet_main_t *em, u32 hw_if_index)
void vnet_delete_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
#define ETHERNET_INTERFACE_FLAGS_STATUS_MASK
ethernet_interface_address_t * secondary_addrs
u32 max_supported_packet_bytes
vl_api_fib_path_type_t type
u32 ethernet_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
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 * simulated_ethernet_mac_change(vnet_hw_interface_t *hi, const u8 *old_address, const u8 *mac_address)
struct vnet_sub_interface_t::@376::@377::@379 flags
void ethernet_delete_interface(vnet_main_t *vnm, u32 hw_if_index)
#define pool_put(P, E)
Free an object E in pool P.
uword * sw_if_index_by_sup_and_sub
#define ETHERNET_INTERFACE_FLAG_STATUS_L3
ethernet_interface_address_t address
#define VLIB_CONFIG_FUNCTION(x, n,...)
This packet matches an "interface route" and packets need to be passed to ARP to find rewrite string ...
clib_error_t * vnet_create_sw_interface(vnet_main_t *vnm, vnet_sw_interface_t *template, u32 *sw_if_index)
static clib_error_t * delete_simulated_ethernet_interfaces(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u32 default_mtu
Default interface MTU.
struct vnet_sub_interface_t::@376 eth
vnet_hw_interface_class_t ethernet_hw_interface_class
u8 * format_ethernet_header_with_length(u8 *s, va_list *args)
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.
static const u8 * ethernet_ip4_mcast_dst_addr(void)
static_always_inline void vlib_buffer_enqueue_to_next(vlib_main_t *vm, vlib_node_runtime_t *node, u32 *buffers, u16 *nexts, uword count)
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)
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.
vlib_main_t vlib_node_runtime_t * node
#define VLIB_CLI_COMMAND(x,...)
This packets follow a mid-chain adjacency.
static clib_error_t * create_simulated_ethernet_interfaces(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static const u8 * ethernet_ip6_mcast_dst_addr(void)
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.
void vnet_delete_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
VNET_HW_INTERFACE_CLASS(ethernet_hw_interface_class)
static u8 * format_simulated_ethernet_name(u8 *s, va_list *args)
int vnet_delete_sub_interface(u32 sw_if_index)
#define clib_error_report(e)
static void hash_unset_mem_free(uword **h, const void *key)
vlan_intf_t vlans[ETHERNET_N_VLAN]
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)
static void * clib_mem_alloc(uword size)
static vlib_main_t * vlib_get_main(void)
static clib_error_t * delete_sub_interface(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
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
VLIB buffer representation.
void ethernet_update_adjacency(vnet_main_t *vnm, u32 sw_if_index, u32 ai)
vnet_sw_interface_t * sw_interfaces
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
#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
static clib_error_t * simulated_ethernet_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
#define ETHERNET_MAX_PACKET_BYTES
#define vec_foreach(var, vec)
Vector iterator.
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
static u32 loopback_instance_alloc(u8 is_specified, u32 want)
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)