[Spread-cvs] commit: r528 - in libspreadutil/trunk: . src
jonathan at spread.org
jonathan at spread.org
Mon Jun 18 13:26:07 EDT 2012
Author: jonathan
Date: 2012-06-18 13:26:07 -0400 (Mon, 18 Jun 2012)
New Revision: 528
Modified:
libspreadutil/trunk/Changelog
libspreadutil/trunk/src/data_link.c
Log:
Change DL_init_channel selection algorithm for which interface to bind. Fixes bug with how Spread 4.2 was using it
Modified: libspreadutil/trunk/Changelog
===================================================================
--- libspreadutil/trunk/Changelog 2012-05-03 22:15:29 UTC (rev 527)
+++ libspreadutil/trunk/Changelog 2012-06-18 17:26:07 UTC (rev 528)
@@ -1,3 +1,9 @@
+Mon Jun 18 13:24:41 2012 Jonathan Stanton <jonathan at spreadconcepts.com>
+
+ * src/data_link.c (DL_init_channel): Fix DL_init_channels algorithm for selecting which
+ interface to bind for multicast and broadcast receive sockets. Fixes regression in Spread
+ usage of DL for multicast sockets.
+
2012-05-02 Jonathan Stanton <jonathan at laptop5.int.spreadconcepts.com>
* src/data_link.c (DL_init_channel): The version of data_link.c's DL_init_channel function has
Modified: libspreadutil/trunk/src/data_link.c
===================================================================
--- libspreadutil/trunk/src/data_link.c 2012-05-03 22:15:29 UTC (rev 527)
+++ libspreadutil/trunk/src/data_link.c 2012-06-18 17:26:07 UTC (rev 528)
@@ -147,12 +147,21 @@
/* WAS: mreq.imr_interface.s_addr = INADDR_ANY;
* If specified, then want to route through it instead of
* based on routing decisions at the kernel */
- mreq.imr_interface.s_addr = htonl( interface_address );
-
+ /* IP_ADD_MEMBERSHIP requires that the imr_interface be an actual physical interface
+ * or INADDR_ANY. So if this is the special case of binding to multicast or broadcast,
+ * switch the join to use INADDR_ANY. In the case when the passed in interface
+ * is a regular physical interface, then join only on that one.
+ */
+ if ( IS_MCAST_ADDR(interface_address) )
+ mreq.imr_interface.s_addr = htonl( INADDR_ANY );
+ else
+ mreq.imr_interface.s_addr = htonl( interface_address );
+
+
if (setsockopt(chan, IPPROTO_IP, IP_ADD_MEMBERSHIP, (void *)&mreq,
sizeof(mreq)) < 0)
{
- Alarm( EXIT, "DL_init_channel: problem in setsockopt to multicast address " IPF "\n", IP(mcast_address) );
+ Alarm( EXIT, "DL_init_channel: problem (errno %d:%s) in setsockopt to multicast address " IPF "\n", sock_errno, sock_strerror(sock_errno), IP(mcast_address) );
}
if ( channel_type & NO_LOOP )
@@ -160,7 +169,7 @@
if (setsockopt(chan, IPPROTO_IP, IP_MULTICAST_LOOP,
(void *)&off, 1) < 0)
{
- Alarm( EXIT, "DL_init_channel: problem in setsockopt loop setting " IPF "\n", IP(mcast_address));
+ Alarm( EXIT, "DL_init_channel: problem (errno %d:%s) in setsockopt loop setting " IPF "\n", sock_errno, sock_strerror(sock_errno), IP(mcast_address));
}
}
More information about the Spread-cvs
mailing list