[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Linux-cluster] [PATCH] Make fence_xvm[d]'s multicast TTL configurabl; e



Lets you set TTL for fence_xvm from the command line (or cluster.conf)

-- Lon

Index: 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
--- fence_xvm.c	17 Oct 2007 18:27:27 -0000	1.7
+++ fence_xvm.c	22 Jan 2008 19:56:56 -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: mcast.c
===================================================================
RCS file: /cvs/cluster/cluster/fence/agents/xvm/mcast.c,v
retrieving revision 1.3
diff -u -r1.3 mcast.c
--- mcast.c	17 Oct 2007 18:27:27 -0000	1.3
+++ mcast.c	22 Jan 2008 19:56:56 -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: mcast.h
===================================================================
RCS file: /cvs/cluster/cluster/fence/agents/xvm/mcast.h,v
retrieving revision 1.1
diff -u -r1.1 mcast.h
--- mcast.h	5 Oct 2006 16:11:36 -0000	1.1
+++ mcast.h	22 Jan 2008 19:56:56 -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: options.c
===================================================================
RCS file: /cvs/cluster/cluster/fence/agents/xvm/options.c,v
retrieving revision 1.6
diff -u -r1.6 options.c
--- options.c	7 Jan 2008 05:52:28 -0000	1.6
+++ options.c	22 Jan 2008 19:56:57 -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: options.h
===================================================================
RCS file: /cvs/cluster/cluster/fence/agents/xvm/options.h,v
retrieving revision 1.3
diff -u -r1.3 options.h
--- options.h	26 Jun 2007 17:23:41 -0000	1.3
+++ options.h	22 Jan 2008 19:56:57 -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 */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]