kern/179901: [netinet] [patch] Multicast SO_REUSEADDR handled incorrectly
Mikolaj Golub
trociny at FreeBSD.org
Sun Jun 30 07:30:01 UTC 2013
The following reply was made to PR kern/179901; it has been noted by GNATS.
From: Mikolaj Golub <trociny at FreeBSD.org>
To: bug-followup at FreeBSD.org
Cc: Michael Gmelin <freebsd at grem.de>
Subject: Re: kern/179901: [netinet] [patch] Multicast SO_REUSEADDR handled
incorrectly
Date: Sun, 30 Jun 2013 10:17:05 +0300
--EeQfGwPcQSOJBaQU
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
On Thu, Jun 27, 2013 at 11:00:16PM +0300, Mikolaj Golub wrote:
> I don't insist on maintaining the old behaviour. But as actually we
> have 2 issues here (regression introduced by me in FreeBSD9 and
> historical behavior that looks wrong), with different priority, I
> would like to fix the issues separately. This way it will be easier to
> track the changes, e.g. when after a year it turns out that the second
> change has broken some other case.
Here is a patch for the second issue.
--
Mikolaj Golub
--EeQfGwPcQSOJBaQU
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="pr179901.2.1.patch"
commit 7cf3a6a95d74ae91c80350fc1ae8e96fe59c3c65
Author: Mikolaj Golub <trociny at freebsd.org>
Date: Sun Jun 30 00:09:20 2013 +0300
A complete duplication of binding should be allowed if on both new and
duplicated sockets a multicast address is bound and either
SO_REUSEPORT or SO_REUSEADDR is set.
But actually it works for the following combinations:
* SO_REUSEPORT is set for the fist socket and SO_REUSEPORT for the new;
* SO_REUSEADDR is set for the fist socket and SO_REUSEADDR for the new;
* SO_REUSEPORT is set for the fist socket and SO_REUSEADDR for the new;
and fails for this:
* SO_REUSEADDR is set for the fist socket and SO_REUSEPORT for the new.
Fix the last case.
PR: 179901
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index 3506b74..eb15a38 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -554,7 +554,7 @@ in_pcbbind_setup(struct inpcb *inp, struct sockaddr *nam, in_addr_t *laddrp,
* and a multicast address is bound on both
* new and duplicated sockets.
*/
- if (so->so_options & SO_REUSEADDR)
+ if ((so->so_options & (SO_REUSEADDR|SO_REUSEPORT)) != 0)
reuseport = SO_REUSEADDR|SO_REUSEPORT;
} else if (sin->sin_addr.s_addr != INADDR_ANY) {
sin->sin_port = 0; /* yech... */
diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c
index a0a6874..fb84279 100644
--- a/sys/netinet6/in6_pcb.c
+++ b/sys/netinet6/in6_pcb.c
@@ -156,7 +156,7 @@ in6_pcbbind(register struct inpcb *inp, struct sockaddr *nam,
* and a multicast address is bound on both
* new and duplicated sockets.
*/
- if (so->so_options & SO_REUSEADDR)
+ if ((so->so_options & (SO_REUSEADDR|SO_REUSEPORT)) != 0)
reuseport = SO_REUSEADDR|SO_REUSEPORT;
} else if (!IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) {
struct ifaddr *ifa;
--EeQfGwPcQSOJBaQU--
More information about the freebsd-net
mailing list