cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] [PATCH] cman-preconfig: allow cman to configure corosync multicast ttl
@ 2011-03-15  8:15 Fabio M. Di Nitto
  2011-03-15 10:22 ` Christine Caulfield
  0 siblings, 1 reply; 2+ messages in thread
From: Fabio M. Di Nitto @ 2011-03-15  8:15 UTC (permalink / raw)
  To: cluster-devel.redhat.com

syntax:

<cman...>
 <multicast ttl=".."/>
</cman>

Resolves: rhbz#684020

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
---
 cman/daemon/cman-preconfig.c    |   24 +++++++++++++++++++++---
 config/tools/xml/cluster.rng.in |   17 +++++++++++++++--
 2 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/cman/daemon/cman-preconfig.c b/cman/daemon/cman-preconfig.c
index 5239d89..0b3e7fd 100644
--- a/cman/daemon/cman-preconfig.c
+++ b/cman/daemon/cman-preconfig.c
@@ -276,7 +276,7 @@ static int add_udpu_members(struct objdb_iface_ver0 *objdb, hdb_handle_t interfa
 	return 0;
 }
 
-static int add_ifaddr(struct objdb_iface_ver0 *objdb, char *mcast, char *ifaddr, int port, enum tx_mech transport)
+static int add_ifaddr(struct objdb_iface_ver0 *objdb, char *mcast, char *ifaddr, int port, int ttl, enum tx_mech transport)
 {
 	hdb_handle_t totem_object_handle;
 	hdb_handle_t find_handle;
@@ -353,6 +353,19 @@ static int add_ifaddr(struct objdb_iface_ver0 *objdb, char *mcast, char *ifaddr,
 		objdb->object_key_create_typed(interface_object_handle, "mcastport",
 					       tmp, strlen(tmp)+1, OBJDB_VALUETYPE_STRING);
 
+		/* paranoia check. corosync already does it */
+		if ((ttl < 0) || (ttl > 255)) {
+			sprintf(error_reason, "TTL value (%u) out of range (0 - 255)", ttl);
+			return -1;
+		}
+
+		/* add the key to the objdb only if value is not default */
+		if (ttl != 1) {
+			sprintf(tmp, "%d", ttl);
+			objdb->object_key_create_typed(interface_object_handle, "ttl",
+						       tmp, strlen(tmp)+1, OBJDB_VALUETYPE_STRING);
+		}
+
 		num_interfaces++;
 	}
 	return ret;
@@ -592,6 +605,7 @@ static int get_nodename(struct objdb_iface_ver0 *objdb)
 	enum tx_mech transport = TX_MECH_UDP;
 	char *str;
 	int error;
+	unsigned int ttl = 1;
 
 	if (!getenv("CMAN_NOCONFIG")) {
 		/* our nodename */
@@ -661,6 +675,7 @@ static int get_nodename(struct objdb_iface_ver0 *objdb)
 			if (objdb->object_find_next(find_handle2, &mcast_handle) == 0) {
 
 				objdb_get_string(objdb, mcast_handle, "addr", &mcast_name);
+				objdb_get_int(objdb, mcast_handle, "ttl", &ttl, 0);
 			}
 			objdb->object_find_destroy(find_handle2);
 		}
@@ -730,7 +745,7 @@ static int get_nodename(struct objdb_iface_ver0 *objdb)
 		}
 	}
 
-	if (add_ifaddr(objdb, mcast_name, nodename, portnum, transport)) {
+	if (add_ifaddr(objdb, mcast_name, nodename, portnum, ttl, transport)) {
 		write_cman_pipe(error_reason);
 		return -1;
 	}
@@ -740,6 +755,7 @@ static int get_nodename(struct objdb_iface_ver0 *objdb)
 	objdb->object_find_create(node_object_handle,"altname", strlen("altname"), &find_handle);
 	while (objdb->object_find_next(find_handle, &alt_object) == 0) {
 		unsigned int port;
+		unsigned int altttl = 1;
 		char *node;
 		char *mcast;
 
@@ -749,11 +765,13 @@ static int get_nodename(struct objdb_iface_ver0 *objdb)
 
 		objdb_get_int(objdb, alt_object, "port", &port, portnum);
 
+		objdb_get_int(objdb, alt_object, "ttl", &altttl, ttl);
+
 		if (objdb_get_string(objdb, alt_object, "mcast", &mcast)) {
 			mcast = mcast_name;
 		}
 
-		if (add_ifaddr(objdb, mcast, node, portnum, transport)) {
+		if (add_ifaddr(objdb, mcast, node, portnum, altttl, transport)) {
 			write_cman_pipe(error_reason);
 			return -1;
 		}
diff --git a/config/tools/xml/cluster.rng.in b/config/tools/xml/cluster.rng.in
index 04906c9..c873cae 100644
--- a/config/tools/xml/cluster.rng.in
+++ b/config/tools/xml/cluster.rng.in
@@ -147,14 +147,22 @@ To validate your cluster.conf against this schema, run:
          instead of using the multicast address generated by cman. If
          a user does not specify a multicast address, cman creates one. It
          forms the upper 16 bits of the multicast address with 239.192 and
-         forms the lower 16 bits based on the cluster ID."> <attribute
-         name="addr" rha:description="A multicast address specified
+         forms the lower 16 bits based on the cluster ID.">
+      <optional>
+       <attribute name="addr" rha:description="A multicast address specified
          by a user. If you do specify a multicast address, you should
          use the 239.192.x.x series that cman uses. Otherwise, using a
          multicast address outside that range may cause unpredictable
          results. For example, using 224.0.0.x (All hosts on the network)
          may not be routed correctly, or even routed@all by some
          hardware." rha:sample="239.192.0.1"/>
+      </optional>
+      <optional>
+       <attribute name="ttl" rha:description="Define the TTL (time to live) of
+         a multicast packets. Useful only if nodes are on different subnets and
+         a multicast router is available in between." rha:default="1"
+         rha:sample="24"/>
+      </optional>
      </element>
     </optional>
    </element>
@@ -734,6 +742,11 @@ To validate your cluster.conf against this schema, run:
       <attribute name="mcast" rha:description="The multicast address
           to use on the second interface. cman(5)"/>
      </optional>
+
+     <optional>
+      <attribute name="ttl" rha:description="The multicast TTL 
+          to use on the second interface. cman(5)"/>
+     </optional>
     </element>
    </optional>
 
-- 
1.7.4



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [Cluster-devel] [PATCH] cman-preconfig: allow cman to configure corosync multicast ttl
  2011-03-15  8:15 [Cluster-devel] [PATCH] cman-preconfig: allow cman to configure corosync multicast ttl Fabio M. Di Nitto
@ 2011-03-15 10:22 ` Christine Caulfield
  0 siblings, 0 replies; 2+ messages in thread
From: Christine Caulfield @ 2011-03-15 10:22 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On 15/03/11 08:15, Fabio M. Di Nitto wrote:
> syntax:
>
> <cman...>
>   <multicast ttl=".."/>
> </cman>
>
> Resolves: rhbz#684020
>
> Signed-off-by: Fabio M. Di Nitto<fdinitto@redhat.com>

ACK

> ---
>   cman/daemon/cman-preconfig.c    |   24 +++++++++++++++++++++---
>   config/tools/xml/cluster.rng.in |   17 +++++++++++++++--
>   2 files changed, 36 insertions(+), 5 deletions(-)
>
> diff --git a/cman/daemon/cman-preconfig.c b/cman/daemon/cman-preconfig.c
> index 5239d89..0b3e7fd 100644
> --- a/cman/daemon/cman-preconfig.c
> +++ b/cman/daemon/cman-preconfig.c
> @@ -276,7 +276,7 @@ static int add_udpu_members(struct objdb_iface_ver0 *objdb, hdb_handle_t interfa
>   	return 0;
>   }
>
> -static int add_ifaddr(struct objdb_iface_ver0 *objdb, char *mcast, char *ifaddr, int port, enum tx_mech transport)
> +static int add_ifaddr(struct objdb_iface_ver0 *objdb, char *mcast, char *ifaddr, int port, int ttl, enum tx_mech transport)
>   {
>   	hdb_handle_t totem_object_handle;
>   	hdb_handle_t find_handle;
> @@ -353,6 +353,19 @@ static int add_ifaddr(struct objdb_iface_ver0 *objdb, char *mcast, char *ifaddr,
>   		objdb->object_key_create_typed(interface_object_handle, "mcastport",
>   					       tmp, strlen(tmp)+1, OBJDB_VALUETYPE_STRING);
>
> +		/* paranoia check. corosync already does it */
> +		if ((ttl<  0) || (ttl>  255)) {
> +			sprintf(error_reason, "TTL value (%u) out of range (0 - 255)", ttl);
> +			return -1;
> +		}
> +
> +		/* add the key to the objdb only if value is not default */
> +		if (ttl != 1) {
> +			sprintf(tmp, "%d", ttl);
> +			objdb->object_key_create_typed(interface_object_handle, "ttl",
> +						       tmp, strlen(tmp)+1, OBJDB_VALUETYPE_STRING);
> +		}
> +
>   		num_interfaces++;
>   	}
>   	return ret;
> @@ -592,6 +605,7 @@ static int get_nodename(struct objdb_iface_ver0 *objdb)
>   	enum tx_mech transport = TX_MECH_UDP;
>   	char *str;
>   	int error;
> +	unsigned int ttl = 1;
>
>   	if (!getenv("CMAN_NOCONFIG")) {
>   		/* our nodename */
> @@ -661,6 +675,7 @@ static int get_nodename(struct objdb_iface_ver0 *objdb)
>   			if (objdb->object_find_next(find_handle2,&mcast_handle) == 0) {
>
>   				objdb_get_string(objdb, mcast_handle, "addr",&mcast_name);
> +				objdb_get_int(objdb, mcast_handle, "ttl",&ttl, 0);
>   			}
>   			objdb->object_find_destroy(find_handle2);
>   		}
> @@ -730,7 +745,7 @@ static int get_nodename(struct objdb_iface_ver0 *objdb)
>   		}
>   	}
>
> -	if (add_ifaddr(objdb, mcast_name, nodename, portnum, transport)) {
> +	if (add_ifaddr(objdb, mcast_name, nodename, portnum, ttl, transport)) {
>   		write_cman_pipe(error_reason);
>   		return -1;
>   	}
> @@ -740,6 +755,7 @@ static int get_nodename(struct objdb_iface_ver0 *objdb)
>   	objdb->object_find_create(node_object_handle,"altname", strlen("altname"),&find_handle);
>   	while (objdb->object_find_next(find_handle,&alt_object) == 0) {
>   		unsigned int port;
> +		unsigned int altttl = 1;
>   		char *node;
>   		char *mcast;
>
> @@ -749,11 +765,13 @@ static int get_nodename(struct objdb_iface_ver0 *objdb)
>
>   		objdb_get_int(objdb, alt_object, "port",&port, portnum);
>
> +		objdb_get_int(objdb, alt_object, "ttl",&altttl, ttl);
> +
>   		if (objdb_get_string(objdb, alt_object, "mcast",&mcast)) {
>   			mcast = mcast_name;
>   		}
>
> -		if (add_ifaddr(objdb, mcast, node, portnum, transport)) {
> +		if (add_ifaddr(objdb, mcast, node, portnum, altttl, transport)) {
>   			write_cman_pipe(error_reason);
>   			return -1;
>   		}
> diff --git a/config/tools/xml/cluster.rng.in b/config/tools/xml/cluster.rng.in
> index 04906c9..c873cae 100644
> --- a/config/tools/xml/cluster.rng.in
> +++ b/config/tools/xml/cluster.rng.in
> @@ -147,14 +147,22 @@ To validate your cluster.conf against this schema, run:
>            instead of using the multicast address generated by cman. If
>            a user does not specify a multicast address, cman creates one. It
>            forms the upper 16 bits of the multicast address with 239.192 and
> -         forms the lower 16 bits based on the cluster ID.">  <attribute
> -         name="addr" rha:description="A multicast address specified
> +         forms the lower 16 bits based on the cluster ID.">
> +<optional>
> +<attribute name="addr" rha:description="A multicast address specified
>            by a user. If you do specify a multicast address, you should
>            use the 239.192.x.x series that cman uses. Otherwise, using a
>            multicast address outside that range may cause unpredictable
>            results. For example, using 224.0.0.x (All hosts on the network)
>            may not be routed correctly, or even routed at all by some
>            hardware." rha:sample="239.192.0.1"/>
> +</optional>
> +<optional>
> +<attribute name="ttl" rha:description="Define the TTL (time to live) of
> +         a multicast packets. Useful only if nodes are on different subnets and
> +         a multicast router is available in between." rha:default="1"
> +         rha:sample="24"/>
> +</optional>
>        </element>
>       </optional>
>      </element>
> @@ -734,6 +742,11 @@ To validate your cluster.conf against this schema, run:
>         <attribute name="mcast" rha:description="The multicast address
>             to use on the second interface. cman(5)"/>
>        </optional>
> +
> +<optional>
> +<attribute name="ttl" rha:description="The multicast TTL
> +          to use on the second interface. cman(5)"/>
> +</optional>
>       </element>
>      </optional>
>



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-03-15 10:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-15  8:15 [Cluster-devel] [PATCH] cman-preconfig: allow cman to configure corosync multicast ttl Fabio M. Di Nitto
2011-03-15 10:22 ` Christine Caulfield

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).