From: Fabio M. Di Nitto <fdinitto@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH] cman-preconfig: allow cman to configure corosync multicast ttl
Date: Tue, 15 Mar 2011 09:15:41 +0100 [thread overview]
Message-ID: <1300176941-16032-1-git-send-email-fdinitto@redhat.com> (raw)
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
next reply other threads:[~2011-03-15 8:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-15 8:15 Fabio M. Di Nitto [this message]
2011-03-15 10:22 ` [Cluster-devel] [PATCH] cman-preconfig: allow cman to configure corosync multicast ttl Christine Caulfield
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1300176941-16032-1-git-send-email-fdinitto@redhat.com \
--to=fdinitto@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).