20 #include <sys/ioctl.h> 21 #include <sys/types.h> 77 memset(nif, 0,
sizeof(*nif));
83 u8 is_pipe,
u8 is_master)
93 struct nmreq * req = 0;
99 return VNET_API_ERROR_SUBIF_ALREADY_EXISTS;
101 fd = open(
"/dev/netmap", O_RDWR);
103 return VNET_API_ERROR_SUBIF_ALREADY_EXISTS;
121 snprintf(req->
nr_name, IFNAMSIZ,
"%s", if_name);
126 ret = VNET_API_ERROR_NOT_CONNECTED;
138 if (reg->
mem == MAP_FAILED)
140 ret = VNET_API_ERROR_NOT_CONNECTED;
158 template.file_descriptor = nif->
fd;
159 template.private_data = nif->
if_index;
165 memcpy(hw_addr, hw_addr_set, 6);
170 rnd = (
u32) (now * 1e6);
173 memcpy (hw_addr+2, &rnd,
sizeof(rnd));
185 ret = VNET_API_ERROR_SYSCALL_ERROR_1;
214 clib_warning(
"Host interface %s does not exist", host_if_name);
215 return VNET_API_ERROR_SYSCALL_ERROR_1;
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
unix_file_function_t * read_function
always_inline void mhash_init_vec_string(mhash_t *h, uword n_value_bytes)
void ethernet_delete_interface(vnet_main_t *vnm, u32 hw_if_index)
uword mhash_unset(mhash_t *h, void *key, uword *old_value)
always_inline uword unix_file_add(unix_main_t *um, unix_file_t *template)
always_inline void vlib_node_set_interrupt_pending(vlib_main_t *vm, u32 node_index)
#define clib_error_report(e)
#define VNET_HW_INTERFACE_FLAG_LINK_UP
always_inline vlib_main_t * vlib_get_main(void)
vnet_main_t * vnet_get_main(void)
#define VLIB_INIT_FUNCTION(x)
u32 per_interface_next_index
#define clib_warning(format, args...)
always_inline u32 random_u32(u32 *seed)
32-bit random number generator
#define pool_elt_at_index(p, i)
netmap_mem_region_t * mem_regions
uword mhash_set_mem(mhash_t *h, void *key, uword *new_value, uword *old_value)
always_inline uword * clib_bitmap_set(uword *ai, uword i, uword value)
static u32 netmap_eth_flag_change(vnet_main_t *vnm, vnet_hw_interface_t *hi, u32 flags)
mhash_t if_index_by_host_if_name
#define vec_free(V)
Free vector's memory (no header).
int netmap_create_if(vlib_main_t *vm, u8 *if_name, u8 *hw_addr_set, u8 is_pipe, u8 is_master)
#define NR_ACCEPT_VNET_HDR
static void close_netmap_if(netmap_main_t *nm, netmap_if_t *nif)
always_inline void unix_file_del(unix_main_t *um, unix_file_t *f)
netmap_main_t netmap_main
vlib_node_registration_t netmap_input_node
(constructor) VLIB_REGISTER_NODE (netmap_input_node)
clib_error_t * ethernet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u8 *address, u32 *hw_if_index_return, ethernet_flag_change_function_t flag_change)
static clib_error_t * netmap_fd_read_ready(unix_file_t *uf)
vnet_device_class_t netmap_device_class
uword * pending_input_bitmap
#define NETMAP_IF(_base, _ofs)
always_inline f64 vlib_time_now(vlib_main_t *vm)
static clib_error_t * netmap_init(vlib_main_t *vm)
always_inline uword * mhash_get(mhash_t *h, void *key)
int netmap_delete_if(vlib_main_t *vm, u8 *host_if_name)
always_inline vnet_sw_interface_t * vnet_get_hw_sw_interface(vnet_main_t *vnm, u32 hw_if_index)