From: Michal Svoboda <michal.svoboda@agents.felk.cvut.cz>
To: netdev@vger.kernel.org
Subject: Re: SO_REUSEADDR with UDP (again)
Date: Tue, 13 Apr 2010 18:23:26 +0200 [thread overview]
Message-ID: <20100413162326.GD16595@myhost.felk.cvut.cz> (raw)
In-Reply-To: <1271161297.16881.293.camel@edumazet-laptop>
[-- Attachment #1: Type: text/plain, Size: 1469 bytes --]
Eric Dumazet wrote:
> sock1 = socket(AF_INET, SOCK_DGRAM, 0);
> setsockopt(sock1, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
> addr.sin_addr.s_addr = htonl(0x7f000001);
> if (bind(sock1, (struct sockaddr *)&addr, sizeof(addr)))
> perror("bind1");
>
> sock2 = socket(AF_INET, SOCK_DGRAM, 0);
> setsockopt(sock2, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
> addr.sin_addr.s_addr = INADDR_ANY; /* or htonl(0x7f000001); */
> if (bind(sock2, (struct sockaddr *)&addr, sizeof(addr)))
> perror("bind2");
> }
Well, now if I send to 127.0.0.1, who gets the datagram? I guess sock2,
so it steals from sock1. What practical use does this have?
> Therefore, applications should not use REUSEADDR on unicast UDP, unless
> it is a non security issue (for example, if it is able to react to any
> new IP addresses added by the administrator on the machine, and complain
> loudly if another application could bind() before itself)
I don't think that in that case REUSEADDR would be useful because you
can already claim new addresses without it, either by binding a separate
socket to each IP or by binding to 0.0.0.0. Moreover the detection of
the "complain" case would be very tricky, at least on first sight.
> REUSADDR has a meaning for multicast, but for unicast... this is hardly
> useful ?
So would it be somehow possible to deliver the datagram to both sockets
(for example if they would be SO_BROADCAST as well)?
Michal Svoboda
[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]
next prev parent reply other threads:[~2010-04-13 16:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-13 9:34 SO_REUSEADDR with UDP (again) Michal Svoboda
2010-04-13 10:39 ` Eric Dumazet
2010-04-13 11:27 ` Michal Svoboda
2010-04-13 12:21 ` Eric Dumazet
2010-04-13 16:23 ` Michal Svoboda [this message]
2010-04-13 16:36 ` Eric Dumazet
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=20100413162326.GD16595@myhost.felk.cvut.cz \
--to=michal.svoboda@agents.felk.cvut.cz \
--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