Make fence_xvm's TTL configurable
PATCH 1/1 Make fence_xvm's TTL configurable
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.
-- Lon
Index: agents/xvm/fence_xvm.c
===================================================================
RCS file: /cvs/cluster/cluster/fence/agents/xvm/fence_xvm.c,v retrieving revision 1.7
xvm/fence_xvm.c +5 -3
@@ -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
xvm/mcast.c +5 -5
@@ -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
xvm/mcast.h +4 -2
@@ -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
xvm/options.c +17 -0
@@ -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
xvm/options.h +1 -0
@@ -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 */
PATCH 1/1 Make fence_xvm's TTL configurable
Hi Lon,
Quoted 3 lines · Lon Hohberger
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
Quoted 167 lines
-- 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.7fence_xvm.cxvm/fence_xvm.c +5
-3@@ -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.3mcast.cxvm/mcast.c +0
-0@@ -111,7 +111,7 @@*/ int
ipv4_send_sk(char*send_addr, char *addr, int port, struct sockaddr *tgt,xvm/mcast.c +1
-1- socklen_t tgt_len) + socklen_t tgt_len, int ttl){ int val; struct ip_mreq mreq;xvm/mcast.c +2
-2@@ -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,xvm/mcast.c +1
-1- socklen_t tgt_len) + socklen_t tgt_len, int ttl){ int val; struct ipv6_mreq mreq;xvm/mcast.c +1
-1@@ -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.1mcast.hxvm/mcast.h +4
-2@@ -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.6options.cxvm/options.c +0
-0@@ -96,6 +96,17 @@static inline void
xvm/options.c +11
-0+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);xvm/options.c +6
-0@@ -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.3options.h
xvm/options.h line 51
Quoted 7 lines
xvm/options.h +1
-0@@ -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.