On Mon, Dec 12, 2016 at 16:15 +0100, Martin Pieuchot wrote:
> On 12/12/16(Mon) 16:09, Rafael Zalamena wrote:
> > After trying to run igmpproxy daemon in different rdomains I noted that
> > it fails with the following message:
> > "
> > ERRO: MRT_ADD_VIF; Errno(49): Can't assign requested address
> > "
> > 
> > In the following line:
> > "
> >     if ( setsockopt( MRouterFD, IPPROTO_IP, MRT_ADD_VIF,
> >                      (char *)&VifCtl, sizeof( VifCtl ) ) )
> >         my_log( LOG_ERR, errno, "MRT_ADD_VIF" );
> > "
> > 
> > With some help from mikeb@ we found out that even though the system is
> > configured for multicast (multicast=YES) it is failing to setsockopt(),
> > because it wasn't being able to add the address. We traced where was it
> > failing and found out that the MRT_ADD_VIF wasn't propagating the rdomain
> > so it was always trying to install in the rdomain 0 even when we ran
> > igmpproxy on a different domain.
> > 
> > This diff just makes ip_mrouter_set() propagate the rdomain so the
> > ifa_ifwithaddr() receives the right rdomain and not fail anymore.
> > 
> > ok?
> 
> Why pass the socket to add_vif() when you only need the rdomain?
>

It makes add_vif take same arguments as some other functions called
from ip_mrouter_set in that switch statement (like ip_mrouter_init).

> I'm also confused, if you need a rdomain shouldn't you be using
> rtable_l2()?
>

He has tested with rdomains, but in this particular case you're doing
setsockopt, you don't know what rtable your socket is associated with
and you're just passing the value along.  But besides, ifa_ifwithaddr
will call the rtable_l2 itself (which makes sense I guess as we have
to look up within the whole rdomain).

> > Index: sys/netinet/ip_mroute.c
> > ===================================================================
> > RCS file: /home/obsdcvs/src/sys/netinet/ip_mroute.c,v
> > retrieving revision 1.93
> > diff -u -p -r1.93 ip_mroute.c
> > --- sys/netinet/ip_mroute.c 29 Nov 2016 15:52:12 -0000      1.93
> > +++ sys/netinet/ip_mroute.c 12 Dec 2016 14:51:37 -0000
> > @@ -130,7 +130,7 @@ int get_vif_cnt(struct sioc_vif_req *);
> >  int get_vif_ctl(struct vifctl *);
> >  int ip_mrouter_init(struct socket *, struct mbuf *);
> >  int get_version(struct mbuf *);
> > -int add_vif(struct mbuf *);
> > +int add_vif(struct socket *, struct mbuf *);
> >  int del_vif(struct mbuf *);
> >  void update_mfc_params(struct mfc *, struct mfcctl2 *);
> >  void init_mfc_params(struct mfc *, struct mfcctl2 *);
> > @@ -293,7 +293,7 @@ ip_mrouter_set(struct socket *so, int op
> >                     error = ip_mrouter_done();
> >                     break;
> >             case MRT_ADD_VIF:
> > -                   error = add_vif(*mp);
> > +                   error = add_vif(so, *mp);
> >                     break;
> >             case MRT_DEL_VIF:
> >                     error = del_vif(*mp);
> > @@ -773,8 +773,9 @@ static struct sockaddr_in sin = { sizeof
> >   * Add a vif to the vif table
> >   */
> >  int
> > -add_vif(struct mbuf *m)
> > +add_vif(struct socket *so, struct mbuf *m)
> >  {
> > +   struct inpcb *inp;
> >     struct vifctl *vifcp;
> >     struct vif *vifp;
> >     struct ifaddr *ifa;
> > @@ -809,8 +810,9 @@ add_vif(struct mbuf *m)
> >     } else
> >  #endif
> >     {
> > +           inp = sotoinpcb(so);
> >             sin.sin_addr = vifcp->vifc_lcl_addr;
> > -           ifa = ifa_ifwithaddr(sintosa(&sin), /* XXX */ 0);
> > +           ifa = ifa_ifwithaddr(sintosa(&sin), inp->inp_rtableid);
> >             if (ifa == NULL)
> >                     return (EADDRNOTAVAIL);
> >     }
> > 
> 

Reply via email to