From: "Ricardo Tubío" <rtpardavila@gmail.com>
To: netdev@vger.kernel.org
Subject: Re: Single socket with TX_RING and RX_RING
Date: Thu, 16 May 2013 09:18:03 +0000 (UTC) [thread overview]
Message-ID: <loom.20130516T111446-437@post.gmane.org> (raw)
In-Reply-To: 20130515224452.7CAA6224C4@mail.nwl.cc
Phil Sutter <phil <at> nwl.cc> writes:
>
> On Wed, May 15, 2013 at 12:53:55PM +0000, Ricardo Tubío wrote:
> > Once I tell kernel to export the TX_RING through setsockopt() (see code
> > below) I always get an error (EBUSY) if i try to tell kernel to export the
> > RX_RING with the same socket descriptor. Therefore, I have to open an
> > additional socket for the RX_RING and I require of two sockets when I though
> > that I would only require of one socket for both TX and RX using mmap()ed
> > memory.
> >
> > Do I need both sockets or am I doing something wrong?
>
> After requesting the rings, a single mmap() call suffices for both. So
> pseudo-code basically looks like this:
>
> | setsockopt(fd, SOL_PACKET, PACKET_RX_RING, p, sizeof(p));
> | setsockopt(fd, SOL_PACKET, PACKET_TX_RING, p, sizeof(p));
> | rx_ring = mmap(NULL, ring_len * 2, PROT_READ | PROT_WRITE, MAP_SHARED,
fd, 0);
> | tx_ring = rx_ring + ring_len;
>
> Note that packet_mmap() in net/packet/af_packet.c always maps the TX
> ring memory right after the RX one.
>
> HTH, Phil
>
Phil, the issue comes precisely when I try to do that: the second call to
setsockopt() returns an "EBUSY" error message from the kernel. It seems that
if you have initialized one socket for beeing either TX_RING or RX_RING, you
cannot initialize the same socket again for the other option (RX_RING or
TX_RING).
Does anybody really know whether I am right or wrong?
next prev parent reply other threads:[~2013-05-16 9:18 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-15 12:53 Single socket with TX_RING and RX_RING Ricardo Tubío
2013-05-15 13:20 ` Daniel Borkmann
2013-05-15 13:32 ` Ricardo Tubío
2013-05-15 14:47 ` Daniel Borkmann
2013-05-15 14:52 ` Daniel Borkmann
2013-05-15 14:58 ` Ricardo Tubío
2013-05-15 15:04 ` Daniel Borkmann
2013-05-20 20:50 ` Paul Chavent
2013-05-15 22:44 ` Phil Sutter
2013-05-16 9:18 ` Ricardo Tubío [this message]
2013-05-16 10:45 ` Phil Sutter
2013-05-16 11:01 ` Ricardo Tubío
2013-05-16 11:14 ` Daniel Borkmann
2013-05-16 11:52 ` Phil Sutter
2013-05-20 20:54 ` Paul Chavent
2013-05-22 19:36 ` Ricardo Tubío
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=loom.20130516T111446-437@post.gmane.org \
--to=rtpardavila@gmail.com \
--cc=netdev@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).