Good Work Reviewed-by: me
Regards -steve On 11/23/2010 06:42 PM, Angus Salkeld wrote: > This adds a per-interface config option to > adjust the TTL. > > Signed-off-by: Angus Salkeld <[email protected]> > --- > conf/corosync.conf.example | 1 + > conf/corosync.conf.example.udpu | 1 + > conf/lenses/corosync.aug | 1 + > conf/lenses/tests/test_corosync.aug | 2 ++ > exec/totemconfig.c | 20 ++++++++++++++++++-- > exec/totemudp.c | 15 ++++++++++----- > exec/totemudpu.c | 21 +++++++++++++++++++++ > include/corosync/totem/totem.h | 1 + > man/corosync.conf.5 | 6 ++++++ > 9 files changed, 61 insertions(+), 7 deletions(-) > > diff --git a/conf/corosync.conf.example b/conf/corosync.conf.example > index 3305366..9dfd873 100644 > --- a/conf/corosync.conf.example > +++ b/conf/corosync.conf.example > @@ -10,6 +10,7 @@ totem { > bindnetaddr: 192.168.1.1 > mcastaddr: 226.94.1.1 > mcastport: 5405 > + ttl: 1 > } > } > > diff --git a/conf/corosync.conf.example.udpu b/conf/corosync.conf.example.udpu > index 8bfbc6e..45c24ca 100644 > --- a/conf/corosync.conf.example.udpu > +++ b/conf/corosync.conf.example.udpu > @@ -56,6 +56,7 @@ totem { > ringnumber: 0 > bindnetaddr: 10.16.35.0 > mcastport: 5405 > + ttl: 1 > } > transport: udpu > } > diff --git a/conf/lenses/corosync.aug b/conf/lenses/corosync.aug > index 46a474b..61ed46e 100644 > --- a/conf/lenses/corosync.aug > +++ b/conf/lenses/corosync.aug > @@ -48,6 +48,7 @@ let interface = > let setting = > kv "ringnumber" Rx.integer > |kv "mcastport" Rx.integer > + |kv "ttl" Rx.integer > |qstr /bindnetaddr|mcastaddr/ > |member in > section "interface" setting > diff --git a/conf/lenses/tests/test_corosync.aug > b/conf/lenses/tests/test_corosync.aug > index b396fca..fe1cef0 100644 > --- a/conf/lenses/tests/test_corosync.aug > +++ b/conf/lenses/tests/test_corosync.aug > @@ -18,6 +18,7 @@ totem { > bindnetaddr: 192.168.122.1 > mcastaddr: 226.94.1.1 > mcastport: 5405 > + ttl: 45 > member { > memberaddr: 10.16.35.101 > } > @@ -103,6 +104,7 @@ test Corosync.lns get conf = > { "bindnetaddr" = "192.168.122.1" } > { "mcastaddr" = "226.94.1.1" } > { "mcastport" = "5405" } > + { "ttl" = "45" } > { "member" > { "memberaddr" = "10.16.35.101" } } > { "member" > diff --git a/exec/totemconfig.c b/exec/totemconfig.c > index 7a30afd..de1d1e4 100644 > --- a/exec/totemconfig.c > +++ b/exec/totemconfig.c > @@ -370,8 +370,6 @@ printf ("couldn't find totem handle\n"); > > &totem_config->interfaces[ringnumber].mcast_addr, > "255.255.255.255", 0); > } > - > - > } > > /* > @@ -389,6 +387,19 @@ printf ("couldn't find totem handle\n"); > res = totemip_parse > (&totem_config->interfaces[ringnumber].bindnet, str, > > totem_config->interfaces[ringnumber].mcast_addr.family); > } > + > + /* > + * Get the TTL > + */ > + if (totem_config->interfaces[ringnumber].mcast_addr.family == > AF_INET6) { > + totem_config->interfaces[ringnumber].ttl = 255; > + } else { > + totem_config->interfaces[ringnumber].ttl = 1; > + } > + if (!objdb_get_string (objdb, object_interface_handle, "ttl", > &str)) { > + totem_config->interfaces[ringnumber].ttl = atoi (str); > + } > + > objdb->object_find_create ( > object_interface_handle, > "member", > @@ -463,6 +474,11 @@ int totem_config_validate ( > goto parse_error; > } > > + if (totem_config->interfaces[i].ttl > 255 || > totem_config->interfaces[i].ttl < 1) { > + error_reason = "Invalid TTL (should be 1..255)"; > + goto parse_error; > + } > + > if (totem_config->interfaces[i].mcast_addr.family == AF_INET6 && > totem_config->node_id == 0) { > > diff --git a/exec/totemudp.c b/exec/totemudp.c > index 23d7efb..b96bdbd 100644 > --- a/exec/totemudp.c > +++ b/exec/totemudp.c > @@ -1642,14 +1642,19 @@ static int totemudp_build_sockets_ip ( > /* > * Set multicast packets TTL > */ > - > - if ( bindnet_address->family == AF_INET6 ) > - { > - flag = 255; > + flag = instance->totem_interface->ttl; > + if (bindnet_address->family == AF_INET6) { > res = setsockopt (sockets->mcast_send, IPPROTO_IPV6, > IPV6_MULTICAST_HOPS, > &flag, sizeof (flag)); > if (res == -1) { > - perror ("setp mcast hops"); > + perror ("set mcast v6 TTL"); > + return (-1); > + } > + } else { > + res = setsockopt(sockets->mcast_send, IPPROTO_IP, > IP_MULTICAST_TTL, > + &flag, sizeof(flag)); > + if (res == -1) { > + perror ("set mcast v4 TTL"); > return (-1); > } > } > diff --git a/exec/totemudpu.c b/exec/totemudpu.c > index dc30a12..dc74510 100644 > --- a/exec/totemudpu.c > +++ b/exec/totemudpu.c > @@ -1316,6 +1316,7 @@ static int totemudpu_build_sockets_ip ( > struct sockaddr_storage sockaddr; > int addrlen; > int res; > + int flag; > > /* > * Setup unicast socket > @@ -1337,6 +1338,26 @@ static int totemudpu_build_sockets_ip ( > } > > /* > + * Set packets TTL > + */ > + flag = instance->totem_interface->ttl; > + if (bindnet_address->family == AF_INET6) { > + res = setsockopt (instance->token_socket, IPPROTO_IPV6, > + IPV6_UNICAST_HOPS, &flag, sizeof (flag)); > + if (res == -1) { > + perror ("set udpu v6 TTL"); > + return (-1); > + } > + } else { > + res = setsockopt(instance->token_socket, IPPROTO_IP, IP_TTL, > + &flag, sizeof(flag)); > + if (res == -1) { > + perror ("set udpu v4 TTL"); > + return (-1); > + } > + } > + > + /* > * Bind to unicast socket used for token send/receives > * This has the side effect of binding to the correct interface > */ > diff --git a/include/corosync/totem/totem.h b/include/corosync/totem/totem.h > index b84d9ba..4e2e475 100644 > --- a/include/corosync/totem/totem.h > +++ b/include/corosync/totem/totem.h > @@ -57,6 +57,7 @@ struct totem_interface { > struct totem_ip_address boundto; > struct totem_ip_address mcast_addr; > uint16_t ip_port; > + uint16_t ttl; > int member_count; > struct totem_ip_address member_list[PROCESSOR_COUNT_MAX]; > > diff --git a/man/corosync.conf.5 b/man/corosync.conf.5 > index 8fc3dc6..79fb5a2 100644 > --- a/man/corosync.conf.5 > +++ b/man/corosync.conf.5 > @@ -128,6 +128,12 @@ If you have multiple clusters on the same network using > the same mcastaddr > please configure the mcastports with a gap. > > .TP > +ttl > +This specifies the Time To Live (TTL). If you run your cluster on a routed > +network then the default of "1" will be too small. This option provides > +a way to increase this up to 255. > + > +.TP > member > This specifies a member on the interface and used with the udpu transport > only. > Every node that should be a member of the membership should be specified as _______________________________________________ Openais mailing list [email protected] https://lists.linux-foundation.org/mailman/listinfo/openais
