Instead of specifying mcastaddr, broadcast: yes can be set in
openais.conf to allow openais to use the broadcast address instead of a
multicast address.
Regards
-steve
Index: exec/totemnet.c
===================================================================
--- exec/totemnet.c (revision 1923)
+++ exec/totemnet.c (working copy)
@@ -1007,30 +1007,45 @@
totemip_totemip_to_sockaddr_convert(mcast_address, instance->totem_interface->ip_port, &mcast_ss, &addrlen);
totemip_totemip_to_sockaddr_convert(bound_to, instance->totem_interface->ip_port, &boundto_ss, &addrlen);
- switch ( bindnet_address->family ) {
- case AF_INET:
- memset(&mreq, 0, sizeof(mreq));
- mreq.imr_multiaddr.s_addr = mcast_sin->sin_addr.s_addr;
- mreq.imr_interface.s_addr = boundto_sin->sin_addr.s_addr;
- res = setsockopt (sockets->mcast_recv, IPPROTO_IP, IP_ADD_MEMBERSHIP,
- &mreq, sizeof (mreq));
- if (res == -1) {
- perror ("join ipv4 multicast group failed");
- return (-1);
+ if (instance->totem_config->broadcast_use == 1) {
+ unsigned int broadcast = 1;
+
+ if ((setsockopt(sockets->mcast_recv, SOL_SOCKET,
+ SO_BROADCAST, &broadcast, sizeof (broadcast))) == -1) {
+ perror("setting broadcast option");
+ exit(1);
}
- break;
- case AF_INET6:
- memset(&mreq6, 0, sizeof(mreq6));
- memcpy(&mreq6.ipv6mr_multiaddr, &mcast_sin6->sin6_addr, sizeof(struct in6_addr));
- mreq6.ipv6mr_interface = interface_num;
+ if ((setsockopt(sockets->mcast_send, SOL_SOCKET,
+ SO_BROADCAST, &broadcast, sizeof (broadcast))) == -1) {
+ perror("setting broadcast option");
+ exit(1);
+ }
+ } else {
+ switch (bindnet_address->family) {
+ case AF_INET:
+ memset(&mreq, 0, sizeof(mreq));
+ mreq.imr_multiaddr.s_addr = mcast_sin->sin_addr.s_addr;
+ mreq.imr_interface.s_addr = boundto_sin->sin_addr.s_addr;
+ res = setsockopt (sockets->mcast_recv, IPPROTO_IP, IP_ADD_MEMBERSHIP,
+ &mreq, sizeof (mreq));
+ if (res == -1) {
+ perror ("join ipv4 multicast group failed");
+ return (-1);
+ }
+ break;
+ case AF_INET6:
+ memset(&mreq6, 0, sizeof(mreq6));
+ memcpy(&mreq6.ipv6mr_multiaddr, &mcast_sin6->sin6_addr, sizeof(struct in6_addr));
+ mreq6.ipv6mr_interface = interface_num;
- res = setsockopt (sockets->mcast_recv, IPPROTO_IPV6, IPV6_JOIN_GROUP,
- &mreq6, sizeof (mreq6));
- if (res == -1) {
- perror ("join ipv6 multicast group failed");
- return (-1);
+ res = setsockopt (sockets->mcast_recv, IPPROTO_IPV6, IPV6_JOIN_GROUP,
+ &mreq6, sizeof (mreq6));
+ if (res == -1) {
+ perror ("join ipv6 multicast group failed");
+ return (-1);
+ }
+ break;
}
- break;
}
/*
Index: exec/totemconfig.c
===================================================================
--- exec/totemconfig.c (revision 1923)
+++ exec/totemconfig.c (working copy)
@@ -233,7 +233,18 @@
if (!objdb_get_string (objdb, object_interface_handle, "mcastaddr", &str)) {
res = totemip_parse (&totem_config->interfaces[ringnumber].mcast_addr, str, 0);
}
+ totem_config->broadcast_use = 0;
+ if (!objdb_get_string (objdb, object_interface_handle, "broadcast", &str)) {
+ if (strcmp (str, "yes") == 0) {
+ totem_config->broadcast_use = 1;
+ totemip_parse (
+ &totem_config->interfaces[ringnumber].mcast_addr,
+ "255.255.255.255", 0);
+ }
+
+ }
+
/*
* Get mcast port
*/
@@ -293,14 +304,16 @@
goto parse_error;
}
- if (totem_config->interfaces[i].mcast_addr.family != totem_config->interfaces[i].bindnet.family) {
- error_reason = "Multicast address family does not match bind address family";
- goto parse_error;
- }
+ if (totem_config->broadcast_use == 0) {
+ if (totem_config->interfaces[i].mcast_addr.family != totem_config->interfaces[i].bindnet.family) {
+ error_reason = "Multicast address family does not match bind address family";
+ goto parse_error;
+ }
- if (totem_config->interfaces[i].mcast_addr.family != totem_config->interfaces[i].bindnet.family) {
- error_reason = "Not all bind address belong to the same IP family";
- goto parse_error;
+ if (totem_config->interfaces[i].mcast_addr.family != totem_config->interfaces[i].bindnet.family) {
+ error_reason = "Not all bind address belong to the same IP family";
+ goto parse_error;
+ }
}
}
Index: exec/totem.h
===================================================================
--- exec/totem.h (revision 1923)
+++ exec/totem.h (working copy)
@@ -128,6 +128,8 @@
unsigned int max_messages;
char *vsf_type;
+
+ unsigned int broadcast_use;
};
enum totem_configuration_type {
Index: man/openais.conf.5
===================================================================
--- man/openais.conf.5 (revision 1923)
+++ man/openais.conf.5 (working copy)
@@ -91,6 +91,12 @@
If IPv6 networking is used, the nodeid field must be specified.
.TP
+broadcast
+This is optional and can be set to yes. If it is set to yes, the broadcast
+address will be used for communication. If this option is set, mcastaddr
+should not be set.
+
+.TP
mcastaddr
This is the multicast address used by openais executive. The default
should work for most networks, but the network administrator should be queried
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais