atomicity / thread-safety: PF_PACKET socket and tap file descriptor
- From: "Max Schmied" <Koalabaerchen2000@xxxxxx>
- Date: 28 Feb 2007 03:31:53 -0800
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
.
- Prev by Date: Re: TCP <--> Com port
- Next by Date: Re: lan card driver for "Atheros AR5006EX Wirless Network adpator" on linux
- Previous by thread: lan card driver for "Atheros AR5006EX Wirless Network adpator" on linux
- Index(es):
Relevant Pages
|