[Cluster-devel] [PATCH] Make fence_xvm's TTL configurable

Fabio M. Di Nitto <[email protected]>
Newsgroups com.redhat.cluster-devel
Message-ID <Pine.LNX.4.64.0801300607170.6826@trider-g7>
Hi Lon,

On Tue, 29 Jan 2008, Lon Hohberger wrote:

> fence_xvm's multicast TTL is statically set to 2.  On machines where a
> router is in-between, this can cause failures due to the router dropping
> the packets.

do I understand right that we use multicast because we don't know where 
the target of the message is or who is...?

If so, this can be considered _almost_ equivalent to rfc2608.txt that 
suggests different values of TTL in "discovery mode" and strongly 
encourage to have a configurable TTL in the client.

So the patch looks good, I think tho a good compromise would be a TTL of 
4/8 that will address automatically over 99.9% of our userbase without 
the need of a config change.

Fabio

>
> -- Lon
>
> Index: agents/xvm/fence_xvm.c
> ===================================================================
> RCS file: /cvs/cluster/cluster/fence/agents/xvm/fence_xvm.c,v
> retrieving revision 1.7
> diff -u -r1.7 fence_xvm.c
> --- agents/xvm/fence_xvm.c	17 Oct 2007 18:27:27 -0000	1.7
> +++ agents/xvm/fence_xvm.c	29 Jan 2008 21:42:50 -0000
> @@ -155,7 +155,8 @@
> 			mc_sock = ipv4_send_sk(ipa->ipa_address, args->addr,
> 					       args->port,
> 					       (struct sockaddr *)&tgt4,
> -					       sizeof(struct sockaddr_in));
> +					       sizeof(struct sockaddr_in),
> +					       args->ttl);
> 			tgt = (struct sockaddr *)&tgt4;
> 			tgt_len = sizeof(tgt4);
>
> @@ -163,7 +164,8 @@
> 			mc_sock = ipv6_send_sk(ipa->ipa_address, args->addr,
> 					       args->port,
> 					       (struct sockaddr *)&tgt6,
> -					       sizeof(struct sockaddr_in6));
> +					       sizeof(struct sockaddr_in6),
> +					       args->ttl);
> 			tgt = (struct sockaddr *)&tgt6;
> 			tgt_len = sizeof(tgt6);
> 		} else {
> @@ -317,7 +319,7 @@
> main(int argc, char **argv)
> {
> 	fence_xvm_args_t args;
> -	char *my_options = "di:a:p:r:C:c:k:H:uo:t:?hV";
> +	char *my_options = "di:a:p:T:r:C:c:k:H:uo:t:?hV";
>
> 	args_init(&args);
> 	if (argc == 1) {
> Index: agents/xvm/mcast.c
> ===================================================================
> RCS file: /cvs/cluster/cluster/fence/agents/xvm/mcast.c,v
> retrieving revision 1.3
> diff -u -r1.3 mcast.c
> --- agents/xvm/mcast.c	17 Oct 2007 18:27:27 -0000	1.3
> +++ agents/xvm/mcast.c	29 Jan 2008 21:42:50 -0000
> @@ -111,7 +111,7 @@
>  */
> int
> ipv4_send_sk(char *send_addr, char *addr, int port, struct sockaddr *tgt,
> -	     socklen_t tgt_len)
> +	     socklen_t tgt_len, int ttl)
> {
> 	int val;
> 	struct ip_mreq mreq;
> @@ -182,8 +182,8 @@
> 	/*
> 	 * set time to live to 2 hops.
> 	 */
> -	dbg_printf(4, "Setting TTL to 2 for fd%d\n", sock);
> -	val = 2;
> +	dbg_printf(4, "Setting TTL to %d for fd%d\n", ttl, sock);
> +	val = ttl;
> 	if (setsockopt(sock, SOL_IP, IP_MULTICAST_TTL, &val,
> 		       sizeof(val)))
> 		printf("warning: setting TTL failed %s\n", strerror(errno));
> @@ -278,7 +278,7 @@
>  */
> int
> ipv6_send_sk(char *send_addr, char *addr, int port, struct sockaddr *tgt,
> -	     socklen_t tgt_len)
> +	     socklen_t tgt_len, int ttl)
> {
> 	int val;
> 	struct ipv6_mreq mreq;
> @@ -361,7 +361,7 @@
> 	/*
> 	 * set time to live to 2 hops.
> 	 */
> -	val = 2;
> +	val = ttl;
> 	if (setsockopt(sock, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &val,
> 		       sizeof(val)))
> 		printf("warning: setting TTL failed %s\n", strerror(errno));
> Index: agents/xvm/mcast.h
> ===================================================================
> RCS file: /cvs/cluster/cluster/fence/agents/xvm/mcast.h,v
> retrieving revision 1.1
> diff -u -r1.1 mcast.h
> --- agents/xvm/mcast.h	5 Oct 2006 16:11:36 -0000	1.1
> +++ agents/xvm/mcast.h	29 Jan 2008 21:42:50 -0000
> @@ -24,9 +24,11 @@
>
> int ipv4_recv_sk(char *addr, int port);
> int ipv4_send_sk(char *src_addr, char *addr, int port,
> -		 struct sockaddr *src, socklen_t slen);
> +		 struct sockaddr *src, socklen_t slen,
> +		 int ttl);
> int ipv6_recv_sk(char *addr, int port);
> int ipv6_send_sk(char *src_addr, char *addr, int port,
> -		 struct sockaddr *src, socklen_t slen);
> +		 struct sockaddr *src, socklen_t slen,
> +		 int ttl);
>
> #endif
> Index: agents/xvm/options.c
> ===================================================================
> RCS file: /cvs/cluster/cluster/fence/agents/xvm/options.c,v
> retrieving revision 1.6
> diff -u -r1.6 options.c
> --- agents/xvm/options.c	7 Jan 2008 05:52:28 -0000	1.6
> +++ agents/xvm/options.c	29 Jan 2008 21:42:50 -0000
> @@ -96,6 +96,17 @@
>
>
> static inline void
> +assign_ttl(fence_xvm_args_t *args, struct arg_info *arg, char *value)
> +{
> +	int ttl;
> +	ttl = atoi(value);
> +	if (ttl < 1 || ttl > 255)
> +		ttl = 2;
> +	args->ttl = ttl;
> +}
> +
> +
> +static inline void
> assign_port(fence_xvm_args_t *args, struct arg_info *arg, char *value)
> {
> 	args->port = atoi(value);
> @@ -260,6 +271,7 @@
> }
>
>
> +
> /** ALL valid command line and stdin arguments for this fencing agent */
> static struct arg_info _arg_info[] = {
> 	{ '\xff', NULL, "agent",
> @@ -286,6 +298,10 @@
> 	  "Multicast address (default=225.0.0.12 / ff02::3:1)",
> 	  assign_address },
>
> +	{ 'T', "-T <ttl>", "multicast_ttl",
> +	  "Multicast time-to-live (in hops; default=2)",
> +	  assign_ttl },
> +
> 	{ 'p', "-p <port>", "port",
> 	  "IP port (default=1229)",
> 	  assign_port },
> @@ -399,6 +415,7 @@
> 	args->retr_time = 20;
> 	args->flags = 0;
> 	args->debug = 0;
> +	args->ttl = 2;
> }
>
>
> Index: agents/xvm/options.h
> ===================================================================
> RCS file: /cvs/cluster/cluster/fence/agents/xvm/options.h,v
> retrieving revision 1.3
> diff -u -r1.3 options.h
> --- agents/xvm/options.h	26 Jun 2007 17:23:41 -0000	1.3
> +++ agents/xvm/options.h	29 Jan 2008 21:42:50 -0000
> @@ -45,6 +45,7 @@
> 	int retr_time;
> 	arg_flags_t flags;
> 	int debug;
> +	int ttl;
> } fence_xvm_args_t;
>
> /* Private structure for commandline / stdin fencing args */
>
>


--
I'm going to make him an offer he can't refuse.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.