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?

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