Networking Forums

Networking Forums > Computer Networking > Linux Networking > atomicity / thread-safety: PF_PACKET socket and tap file descriptor

Reply
Thread Tools Display Modes

atomicity / thread-safety: PF_PACKET socket and tap file descriptor

 
 
Max Schmied
Guest
Posts: n/a

 
      02-28-2007, 10:31 AM
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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
sending socket descriptor to another pid Beagle Linux Networking 2 07-09-2008 09:56 PM
Closing socket file descriptors Yang Linux Networking 0 05-20-2007 04:26 AM
Raw socket PF_PACKET questions manolinux Linux Networking 1 09-08-2006 05:54 PM
Getting file descriptor associated with a port eyal.susser@gmail.com Linux Networking 1 04-18-2006 10:32 AM
use IPv6 socket to get file from Apache lgl Linux Networking 0 11-19-2003 08:34 AM



1 2 3 4 5 6 7 8 9 10 11