|
||||||||
|
|
|||||||
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
|
Hi,
I send raw Ethernet frames through a PF_PACKET socket (type: SOCK_RAW) and I also use a tap device (tun module). Can the following two operations be performed simultaneously by several threads (e.g. pthreads) in a thread-safe / atomic manner, i.e. that the bytes of two different packets don't get interleaved in the kernel, but are delivered untampered in some order: 1) Two or more threads independently send different Ethernet packets through the same PF_PACKET socket [function send()] . 2) Two or more threads independently write different Ethernet packets through the same file descriptor to a tap device to make the network stack "receive" them [function write()] . Last year, there was a discussion http://tinyurl.com/yphmzl at fa.linux.kernel about a similar topic. From it you could learn that when two threads send data through the same TCP socket, the payload passed by them via send() might get interleaved in the kernel. In my case, we deal with raw Ethernet packets and not with TCP streams, the size of an Ethernet packet is always smaller than PIPE_BUF. I hope, I don't have to allocate a new PF_PACKET socket and a new file descriptor for the tap devive in each thread. Greetings, Max Schmied Max Schmied |
![]() |
| Tags |
| atomicity, descriptor, file, pfpacket, socket, tap, threadsafety |
| Thread Tools | |
| Display Modes | |
|
|