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

.



Relevant Pages

  • atomicity / thread-safety: PF_PACKET socket and tap file descriptor
    ... I send raw Ethernet frames through a PF_PACKET socket ... and I also use a tap device. ... different packets don't get interleaved in the kernel, ... Two or more threads independently write different Ethernet packets ...
    (comp.os.linux.development.system)
  • Re: Driver programming question
    ... You do not even need to understand driver development in Linux. ... least each and every Ethernet packet. ... an Etnernet card to even receive anything besides Ethernet packets. ... packages over Ethernet and that is all the typical cards understand. ...
    (comp.sys.ibm.pc.hardware.misc)
  • Re: AFP protocol
    ... I met, in the 1980s, plenty of workstations hooked up to Ethernet ... AUI socket on the computer. ... reasonable sized black coax cables that use BNC sockets, ... ever used built-in BNC on early third party Mac Ethernet cards, ...
    (uk.comp.sys.mac)
  • Re: Wheres my Ethernet?
    ... All thats left is a Internet connection via Ethernet for my Motorola SurfBoard ... how do I install the Ethernet and what is And how do I install the SM ... see it has a USB socket and an "Ethernet" socket. ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: AFP protocol
    ... if you are using an AUI connector. ... I met, in the 1980s, plenty of workstations hooked up to Ethernet ... AUI socket on the computer. ... reasonable sized black coax cables that use BNC sockets, ...
    (uk.comp.sys.mac)