Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 26 Jun 2013 13:10:03 GMT
From:      Michael Gmelin <freebsd@grem.de>
To:        freebsd-net@FreeBSD.org
Subject:   Re: kern/179901: [netinet] [patch] Multicast SO_REUSEADDR handled incorrectly
Message-ID:  <201306261310.r5QDA3kS018825@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/179901; it has been noted by GNATS.

From: Michael Gmelin <freebsd@grem.de>
To: Mikolaj Golub <trociny@FreeBSD.org>
Cc: bug-followup@FreeBSD.org
Subject: Re: kern/179901: [netinet] [patch] Multicast SO_REUSEADDR handled
 incorrectly
Date: Wed, 26 Jun 2013 15:03:40 +0200

 On Tue, 25 Jun 2013 18:24:55 +0300
 Mikolaj Golub <trociny@FreeBSD.org> wrote:
 
 > On Tue, Jun 25, 2013 at 01:39:38PM +0200, Michael Gmelin wrote:
 > 
 > > Yes, but it seems like your patch is fixing the not all places in
 > > in6_pcb.c, I think you should modify the code at line 246 as well:
 > > 
 > >                         } else if (t && (reuseport == 0 ||
 > >                             (t->inp_flags2 & INP_REUSEPORT) == 0)) {
 > >                                 return (EADDRINUSE);
 > >                         }
 > > 
 > > so it says
 > >                         } else if (t &&
 > >                             (reuseport & inp_so_options(t)) == 0) {
 > > 		
 > 
 > Good catch! I missed this because I was preparing the patch using
 > r227207 as a reference, but this had been missed there too (fixed
 > later in r233272 by glebius).
 > 
 > > Once 1) has been resolved I can test on a machine running
 > > 9.1-RELEASE later (the patch is small enough to apply it manually).
 > > I will run the "unit test" code from multicast.c I sent earlier and
 > > add IPv6 test cases to it as well.
 > 
 > The updated patch is attached. Thanks.
 > 
 
 Hi,
 
 I adapted the test code, you can find it at
 
 http://blog.grem.de/multicast.c
 
 Test output is:
 
 IPv4 Port 5555:
   Bind using SO_REUSEADDR.......OK   (expected)
   Bind using SO_REUSEADDR.......OK   (expected)
   Bind using SO_REUSEPORT.......FAIL (NOT expected): Address already in
 use IPv4 Port 5556:
   Bind using SO_REUSEPORT.......OK   (expected)
   Bind using SO_REUSEPORT.......OK   (expected)
   Bind using SO_REUSEADDR.......OK   (expected)
   Bind using SO_REUSEPORT.......FAIL (NOT expected): Address already in
 use IPv4 Port 5557:
   Bind using SO_REUSEADDR x 2...OK   (expected)
   Bind using SO_REUSEADDR x 2...OK   (expected)
   Bind using SO_REUSEPORT.......FAIL (NOT expected): Address already in
 use Bind using SO_REUSEADDR.......OK   (expected)
   Bind using SO_REUSEPORT.......FAIL (NOT expected): Address already in
 use IPv4 Port 5558:
   Bind without socketopts.......OK   (expected)
   Bind using SO_REUSEADDR.......FAIL (expected): Address already in use
   Bind using SO_REUSEPORT.......FAIL (expected): Address already in use
 IPv4 Port 5559:
   Bind using SO_REUSEADDR.......OK   (expected)
   Bind without socketopts.......FAIL (expected): Address already in use
 IPv4 Port 5560:
   Bind using SO_REUSEPORT.......OK   (expected)
   Bind using SO_REUSEPORT.......OK   (expected)
   Bind without socketopts.......FAIL (expected): Address already in use
 IPv6 Port 5555:
   Bind using SO_REUSEADDR.......OK   (expected)
   Bind using SO_REUSEADDR.......OK   (expected)
   Bind using SO_REUSEPORT.......FAIL (NOT expected): Address already in
 use IPv6 Port 5556:
   Bind using SO_REUSEPORT.......OK   (expected)
   Bind using SO_REUSEPORT.......OK   (expected)
   Bind using SO_REUSEADDR.......OK   (expected)
   Bind using SO_REUSEPORT.......FAIL (NOT expected): Address already in
 use IPv6 Port 5557:
   Bind using SO_REUSEADDR x 2...OK   (expected)
   Bind using SO_REUSEADDR x 2...OK   (expected)
   Bind using SO_REUSEPORT.......FAIL (NOT expected): Address already in
 use Bind using SO_REUSEADDR.......OK   (expected)
   Bind using SO_REUSEPORT.......FAIL (NOT expected): Address already in
 use IPv6 Port 5558:
   Bind without socketopts.......OK   (expected)
   Bind using SO_REUSEADDR.......FAIL (expected): Address already in use
   Bind using SO_REUSEPORT.......FAIL (expected): Address already in use
 IPv6 Port 5559:
   Bind using SO_REUSEADDR.......OK   (expected)
   Bind without socketopts.......FAIL (expected): Address already in use
 IPv6 Port 5560:
   Bind using SO_REUSEPORT.......OK   (expected)
   Bind using SO_REUSEPORT.......OK   (expected)
   Bind without socketopts.......FAIL (expected): Address already in use
 
 So you maintained the old PORT/ADDR behavior, which I think is not such
 a great idea. I would suggest to get another opinion on this, just
 because it's broken now doesn't mean we have to perpetuate it - maybe we
 should compare the behavior with other Unix(like) OSes like the other
 BSDs and Linux to see how their implementations work - usually ported
 software is not changed in that respect, so being compatible is
 valuable.
 
 Besides my rant the code works as designed and seems to resemble the
 behavior before r227207 correctly (I manually applied the patches to
 9.1-RELEASE).
 
 Fun fact: The code in ip6_output.c could have never worked in the first
 place, since it used IN_MULTICAST instead of IN6_IS_ADDR_MULTICAST:
 
 if (IN_MULTICAST(ntohl(in6p->inp_laddr.s_addr)))
 ...
 
 Cheers,
 Michael
 
 
 -- 
 Michael Gmelin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201306261310.r5QDA3kS018825>