From: Alban Crequy <alban.crequy@collabora.co.uk>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Stephen Hemminger <shemminger@vyatta.com>,
Cyrill Gorcunov <gorcunov@openvz.org>,
Alexey Dobriyan <adobriyan@gmail.com>,
Lennart Poettering <lennart@poettering.net>,
Kay Sievers <kay.sievers@vrfy.org>,
Ian Molton <ian.molton@collabora.co.uk>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/5] AF_UNIX: find peers on multicast Unix stream sockets
Date: Thu, 30 Sep 2010 20:24:29 +0100 [thread overview]
Message-ID: <20100930202429.42808a38@chocolatine.cbg.collabora.co.uk> (raw)
In-Reply-To: <1285351237.2478.7.camel@edumazet-laptop>
Le Fri, 24 Sep 2010 20:00:37 +0200,
Eric Dumazet <eric.dumazet@gmail.com> a écrit :
> Le vendredi 24 septembre 2010 à 18:25 +0100, Alban Crequy a écrit :
>
> > @@ -1612,7 +1671,12 @@ static int unix_stream_sendmsg(struct kiocb
> > *kiocb, struct socket *sock, } else {
> > sunaddr = NULL;
> > err = -ENOTCONN;
> > - other = NULL; /* FIXME: get the list of other
> > connection */
> > + max_others = atomic_read(&unix_nr_multicast_socks);
> > + others = kzalloc((max_others + 1) * sizeof(void
> > *), GFP_KERNEL);
> > + unix_find_other(sock_net(sk), u->addr->name,
> > + u->addr->len, 0, u->addr->hash, 1, others,
> > max_others, &err);
> > + other = others[0];
> > + kfree(others);
> > if (!other)
> > goto out_err;
> > }
>
> Seriously, this block sizing against unix_nr_multicast_socks is not
> scalable. What happens if we have 1000 sockets ?
> kzalloc() to clear 8000 bytes ?
> Its also unsafe.
>
> (say you kzalloc() a buffer for 2 sockets, and another cpu inserts a
> new socket. unix_find_socket_byname() can overflow the buffer)
>
>
> You should use a list, and allocates elements in
> unix_find_socket_byname()
>
> struct item {
> struct item *next;
> struct sock *s;
> };
Thanks for your review.
I cannot allocate elements directly in unix_find_socket_byname()
iteration after iteration because the spinlock "unix_table_lock" is
held. If I release the spinlock to allocate, the number of sockets in
the table may change.
I changed the code to count the sockets with the lock held and then
allocate. In the unfortunate case where the allocation is not big
enough (if another process inserts a new socket), it just tries again.
The code is available here. Please pull from:
git://git.collabora.co.uk/git/user/alban/linux-2.6.35.y/.git unix-multicast2
It is still a work in progress. Missing pieces:
- The flow control does not work correctly: poll/select does not match
the reality
- Atomic delivery: if a process is killed or interrupted in the middle
of a delivery, only a subset of the recipients will get the message
- Some locking to provide the same delivery order to all the recipients
when several senders run concurrently.
Feedback welcome,
Alban Crequy
next prev parent reply other threads:[~2010-09-30 19:24 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20100924182257.11abd9a6@chocolatine.cbg.collabora.co.uk>
2010-09-24 17:25 ` [PATCH 1/5] AF_UNIX: add getsockopt and setsockopt on stream sockets Alban Crequy
2010-09-24 17:25 ` [PATCH 2/5] AF_UNIX: enable/disable multicast with getsockopt/setsockopt Alban Crequy
2010-09-24 17:46 ` Eric Dumazet
2010-09-24 18:02 ` Eric Dumazet
2010-09-24 17:25 ` [PATCH 3/5] AF_UNIX: implement connect() on multicast Unix stream socket Alban Crequy
2010-09-24 17:25 ` [PATCH 4/5] AF_UNIX: find peers on multicast Unix stream sockets Alban Crequy
2010-09-24 18:00 ` Eric Dumazet
2010-09-30 19:24 ` Alban Crequy [this message]
2010-09-24 17:25 ` [PATCH 5/5] AF_UNIX: deliver the data to all the multicast peers Alban Crequy
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=20100930202429.42808a38@chocolatine.cbg.collabora.co.uk \
--to=alban.crequy@collabora.co.uk \
--cc=adobriyan@gmail.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=gorcunov@openvz.org \
--cc=ian.molton@collabora.co.uk \
--cc=kay.sievers@vrfy.org \
--cc=lennart@poettering.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=shemminger@vyatta.com \
/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