Networking Forums  

Go Back   Networking Forums > Networking Newsgroups > Linux Networking

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

Reply
 
Thread Tools Display Modes
  #1  
Old 02-28-2007, 11:31 AM
Default atomicity / thread-safety: PF_PACKET socket and tap file descriptor



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
Reply With Quote
Reply

Tags
atomicity, descriptor, file, pfpacket, socket, tap, threadsafety

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
Forum Jump


All times are GMT. The time now is 01:11 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.