netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: "Michał Mirosław" <mirq@rere.qmqm.pl>
Cc: davem@davemloft.net, netfilter-devel@vger.kernel.org,
	netdev@vger.kernel.org
Subject: Re: [PATCH 08/11] netlink: implement memory mapped sendmsg()
Date: Wed, 07 Sep 2011 17:22:00 +0200	[thread overview]
Message-ID: <4E678C18.1010306@trash.net> (raw)
In-Reply-To: <20110904161822.GA8176@rere.qmqm.pl>

On 04.09.2011 18:18, Michał Mirosław wrote:
> On Sat, Sep 03, 2011 at 07:26:08PM +0200, kaber@trash.net wrote:
>> From: Patrick McHardy <kaber@trash.net>
>>
>> Add support for memory mapped sendmsg() to netlink. Userspace queued to
>> be processed frames into the TX ring and invokes sendmsg with
>> msg.iov.iov_base = NULL to trigger processing of all pending messages.
>>
>> Since the kernel usually performs full message validation before beginning
>> processing, userspace must be prevented from modifying the message
>> contents while the kernel is processing them. In order to do so, the
>> frames contents are copied to an allocated skb in case the the ring is
>> mapped more than once or the file descriptor is shared (f.i. through
>> AF_UNIX file descriptor passing).
>>
>> Otherwise an skb without a data area is allocated, the data pointer set
>> to point to the data area of the ring frame and the skb is processed.
>> Once the skb is freed, the destructor releases the frame back to userspace
>> by setting the status to NL_MMAP_STATUS_UNUSED.
> 
> Is this protected from threads? Like: one thread waits on sendmsg() and
> another (same process) changes the buffer.

Yes, if the ring is mapped multiple times (or the file descriptor
is changed), the contents are copied to an allocated skb.

  reply	other threads:[~2011-09-07 15:22 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-03 17:26 [PATCH RFC 0/11] netlink: memory mapped I/O kaber
2011-09-03 17:26 ` [PATCH 01/11] netlink: add symbolic value for congested state kaber
2011-09-03 17:26 ` [PATCH 02/11] net: add function to allocate skbuff head without data area kaber
2011-09-04  8:12   ` Eric Dumazet
2011-09-07 15:20     ` Patrick McHardy
2011-09-03 17:26 ` [PATCH 03/11] netlink: add helper function for queueing skbs to the receive queue kaber
2011-09-03 17:26 ` [PATCH 04/11] netlink: don't orphan skb in netlink_trim() kaber
2011-09-03 17:26 ` [PATCH 05/11] netlink: add netlink_skb_set_owner_r() kaber
2011-09-03 17:26 ` [PATCH 06/11] netlink: memory mapped netlink: ring setup kaber
2011-09-03 17:26 ` [PATCH 07/11] netlink: add memory mapped netlink helper functions kaber
2011-09-03 17:26 ` [PATCH 08/11] netlink: implement memory mapped sendmsg() kaber
2011-09-04 16:18   ` Michał Mirosław
2011-09-07 15:22     ` Patrick McHardy [this message]
2011-09-07 20:03       ` Michał Mirosław
2011-09-08  9:33         ` Patrick McHardy
2011-09-08 18:08           ` Michał Mirosław
2011-09-03 17:26 ` [PATCH 09/11] netlink: implement memory mapped recvmsg() kaber
2011-09-03 17:26 ` [PATCH 10/11] netlink: add documentation for memory mapped I/O kaber
2011-09-03 17:26 ` [PATCH 11/11] nfnetlink: add support for memory mapped netlink kaber
2011-09-17  5:48 ` [PATCH RFC 0/11] netlink: memory mapped I/O David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E678C18.1010306@trash.net \
    --to=kaber@trash.net \
    --cc=davem@davemloft.net \
    --cc=mirq@rere.qmqm.pl \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).