Date: Wed, 7 Nov 2007 22:45:04 +0000 From: Marko Zec <zec@icir.org> To: freebsd-current@freebsd.org Cc: Robert Watson <rwatson@freebsd.org>, bms@freebsd.org, Reinhard Haller <reinhard.haller@interactive-net.de> Subject: Re: 7.0-BETA2 routed and multicast registration Message-ID: <200711072245.05430.zec@icir.org> In-Reply-To: <4732110D.3090808@interactive-net.de> References: <4732110D.3090808@interactive-net.de>
next in thread | previous in thread | raw e-mail | index | archive | help
--Boundary-00=_x/jMHfp8V78I2pA
Content-Type: text/plain;
charset="iso-8859-15"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
On Wednesday 07 November 2007 19:25:01 Reinhard Haller wrote:
> Hi,
>
> routed has problems with setsockopt registering itself for multicast.
> The trace contains the following messages:
>
> IP_ADD_MEMBERSHIP ALLROUTERS: Can't assign requested address
> turn on RIP
> setsockopt(IP_ADD_MEMBERSHIP RIP): Can't assign requested address
> setsockopt(rdisc_sock,IP_MULTICAST_IF): Can't assign requested
> address
>
> Any suggestions?
Perhaps the attached kernel patch could help?
Cheers,
Marko
--Boundary-00=_x/jMHfp8V78I2pA
Content-Type: text/x-diff;
charset="iso-8859-15";
name="in_mcast.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="in_mcast.diff"
--- sys/netinet/in_mcast.c.org 2007-11-07 22:36:23.000000000 +0000
+++ sys/netinet/in_mcast.c 2007-11-07 22:37:16.000000000 +0000
@@ -113,6 +113,8 @@ static int inp_join_group(struct inpcb *
static int inp_leave_group(struct inpcb *, struct sockopt *);
static int inp_set_multicast_if(struct inpcb *, struct sockopt *);
static int inp_set_source_filters(struct inpcb *, struct sockopt *);
+static struct ifnet *
+ ip_multicast_if(struct in_addr *a);
/*
* Resize the ip_moptions vector to the next power-of-two minus 1.
@@ -1019,7 +1021,7 @@ inp_join_group(struct inpcb *inp, struct
* reject the IPv4 multicast join.
*/
if (mreqs.imr_interface.s_addr != INADDR_ANY)
- INADDR_TO_IFP(mreqs.imr_interface, ifp);
+ ifp = ip_multicast_if(&mreqs.imr_interface);
else {
struct route ro;
@@ -1435,7 +1437,7 @@ inp_set_multicast_if(struct inpcb *inp,
if (addr.s_addr == INADDR_ANY) {
ifp = NULL;
} else {
- INADDR_TO_IFP(addr, ifp);
+ ifp = ip_multicast_if(&addr);
if (ifp == NULL)
return (EADDRNOTAVAIL);
}
@@ -1820,3 +1822,23 @@ inp_setmoptions(struct inpcb *inp, struc
return (error);
}
+
+/*
+ * following RFC1724 section 3.3, 0.0.0.0/8 is interpreted as interface index.
+ */
+static struct ifnet *
+ip_multicast_if(struct in_addr *a)
+{
+ int ifindex;
+ struct ifnet *ifp;
+
+ if (ntohl(a->s_addr) >> 24 == 0) {
+ ifindex = ntohl(a->s_addr) & 0xffffff;
+ if (ifindex < 0 || if_index < ifindex)
+ return NULL;
+ ifp = ifnet_byindex(ifindex);
+ } else
+ INADDR_TO_IFP(*a, ifp);
+ return ifp;
+}
+
--Boundary-00=_x/jMHfp8V78I2pA--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200711072245.05430.zec>
