tech-net archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bind() to IPv6 link-local multicast group gives EADDRNOTAVAIL



Hi,

I guess that in6_pcbind_addr() should always reject binding to a multicast
address regardless of a socket type, and bind() should be used to determine
a source address.

Instead, we need to join an IP multicast address group on an interface that
would cause the interface to raise received multicast packets to a kernel.
I am, then, afraid that binding to a multicast address seems not to be useful,
and that the current source is correct.

On Linux, can your code actually receive an IP multicast packet only with
binding to the address (i.e., without joining the group)?

Best regards,
--
Motoyuki OHMORI <ohmori%tottori-u.ac.jp@localhost>

On Wed, Jul 23, 2014 at 19:31:18 -0400, Richard Hansen 
<rhansen%bbn.com@localhost> wrote:

> On 2014-07-23 07:11, Christos Zoulas wrote:
> > In article <53CF5BF8.4000402%bbn.com@localhost>, Richard Hansen  
> > <rhansen%bbn.com@localhost> wrote:
> >> Hi all,
> >>
> >> It seems to me like in6_pcbbind_addr() should have another 'else if'
> >> condition before line 241:
> >>
> >>    } else if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) {
> >>        ...
> >>
> >> Or am I doing something wrong?
> > 
> > Does this work for you? (similar to in_pcbbind_addr())...
> 
> Thanks for the patch.  I'll try it out in a bit, but before I do I have
> some questions.  Some of these will be answered by my testing, but I
> wanted to ask them anyway in case you already know the answer and would
> like to update the patch:
> 
>   * With this patch, in6_pcbind_addr() will set in6p->in6p_laddr to the
>     multicast group address.  Will this cause an outgoing packet sent
>     via the socket to have the source address set to the multicast
>     address (which would violate RFC4291)?
> 
>   * Shouldn't in6_pcbind_addr() ensure that sin6->sin6_scope_id is
>     non-0 if the multicast address is link-local?  (or perhaps
>     non-global?)
> 
>   * How does sin6->sin6_scope_id affect the binding?  Suppose I have two
>     interfaces, wm0 and wm1.  I create two sockets and bind one to
>     ff02::101%wm0 port 123 and the other to ff02:101%wm1 port 123.
>     Each should only receive packets that arrive on the specified
>     interface, but with this patch I'm guessing one of the following
>     will happen:
>       - the second bind() will fail (the call to in6_pcblookup_port()
>         in in6_pcbbind_port() doesn't consider sin6_scope_id, so I
>         think NetBSD will return EADDRINUSE)
>       - both sockets will receive packets destined to either interface
>       - one socket will receive packets destined to both interfaces
>         while the other socket receives nothing
> 
>   * Should in6_pcbind_addr() reject the bind to the multicast address
>     if the socket type is SOCK_STREAM?
> 
> Thanks,
> Richard
> 
> > 
> > christos
> > 
> > Index: in6_pcb.c
> > ===================================================================
> > RCS file: /cvsroot/src/sys/netinet6/in6_pcb.c,v
> > retrieving revision 1.125
> > diff -u -p -u -r1.125 in6_pcb.c
> > --- in6_pcb.c       30 May 2014 01:39:03 -0000      1.125
> > +++ in6_pcb.c       23 Jul 2014 11:10:23 -0000
> > @@ -218,7 +218,9 @@ in6_pcbbind_addr(struct in6pcb *in6p, st
> >     if ((error = sa6_embedscope(sin6, ip6_use_defzone)) != 0)
> >             return (error);
> >  
> > -   if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) {
> > +   if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) {
> > +           /* always succeed */
> > +   } else if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) {
> >             if ((in6p->in6p_flags & IN6P_IPV6_V6ONLY) != 0)
> >                     return (EINVAL);
> >             if (sin6->sin6_addr.s6_addr32[3]) {


Home | Main Index | Thread Index | Old Index