linux - setsockopt() returns EBUSY -


i have succesfully opened raw socket , trying export kernel tx , rx rings function below. however, setsockopt() returns ebusy (device or resource busy) when trying tell kernel export second of rings. is, executing code below once works fine, can first of rings (either tx or rx). problem comes when try export second ring (for tx if first rx or viceceversa).

cannot application use same socket both tx , rx mmap()ed memory? is, have open 1 socket tx , 1 socket rx?

/* init_ring */ void *init_ring(ll_socket_t *ll_socket, int type) {      void *ring = null; int ring_len = 0; int ring_access_flags = prot_read | prot_write; struct tpacket_req tp;  // 1) tell kernel export data through mmap()ped ring tp.tp_block_size = frames_per_ring * getpagesize(); tp.tp_block_nr = 1; tp.tp_frame_size = getpagesize(); tp.tp_frame_nr = frames_per_ring;  ring_len = tp.tp_block_size * tp.tp_block_nr;  if ( setsockopt(ll_socket->socket_fd, sol_packet, type, &tp, sizeof(struct tpacket_req) ) < 0 )     { handle_sys_error("setting socket options ring"); }  // 2) open ring if ( ( ring = mmap(null, ring_len, ring_access_flags, map_shared, ll_socket->socket_fd, 0) ) == null )     { handle_sys_error("mmap()ing error"); }  return(ring); 

}


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -