Rev 609: - don't allow the registration of clients with IPs we don't hold in http://samba.org/~tridge/ctdb

tridge at samba.org tridge at samba.org
Wed Sep 12 03:22:31 GMT 2007


------------------------------------------------------------
revno: 609
revision-id: tridge at samba.org-20070912032231-a2dx5fg9ib8u0rep
parent: tridge at samba.org-20070912032119-2b203v4evthp7mpo
committer: Andrew Tridgell <tridge at samba.org>
branch nick: tridge.test2
timestamp: Wed 2007-09-12 13:22:31 +1000
message:
  - don't allow the registration of clients with IPs we don't hold
  - change some debug levels to make tracking of IP release problems easier
modified:
  server/ctdb_takeover.c         ctdb_takeover.c-20070525071636-a5n1ihghjtppy08r-2
=== modified file 'server/ctdb_takeover.c'
--- a/server/ctdb_takeover.c	2007-09-10 10:45:27 +0000
+++ b/server/ctdb_takeover.c	2007-09-12 03:22:31 +0000
@@ -276,11 +276,17 @@
 {
 	struct ctdb_client_ip *ip;
 
+	DEBUG(1,("release_kill_clients for ip %s\n", inet_ntoa(in.sin_addr)));
+
 	for (ip=ctdb->client_ip_list; ip; ip=ip->next) {
+		DEBUG(2,("checking for client %u with IP %s\n", 
+			 ip->client_id, inet_ntoa(ip->ip.sin_addr)));
 		if (ctdb_same_ip(&ip->ip, &in)) {
 			struct ctdb_client *client = ctdb_reqid_find(ctdb, 
 								     ip->client_id, 
 								     struct ctdb_client);
+			DEBUG(1,("matched client %u with IP %s and pid %u\n", 
+				 ip->client_id, inet_ntoa(ip->ip.sin_addr), client->pid));
 			if (client->pid != 0) {
 				DEBUG(0,(__location__ " Killing client pid %u for IP %s on client_id %u\n",
 					 (unsigned)client->pid, inet_ntoa(in.sin_addr),
@@ -346,6 +352,10 @@
 	}
 	vnn->pnn = pip->pnn;
 
+	/* stop any previous arps */
+	talloc_free(vnn->takeover_ctx);
+	vnn->takeover_ctx = NULL;
+
 	have_ip = ctdb_sys_have_ip(pip->sin, &is_loopback, tmp_ctx, &ifname);
 	if ( (!have_ip) || is_loopback) { 
 		DEBUG(0,("Redundant release of IP %s/%u on interface %s (ip not held)\n", 
@@ -359,10 +369,6 @@
 		 inet_ntoa(pip->sin.sin_addr), vnn->public_netmask_bits, 
 		 vnn->iface));
 
-	/* stop any previous arps */
-	talloc_free(vnn->takeover_ctx);
-	vnn->takeover_ctx = NULL;
-
 	state = talloc(ctdb, struct takeover_callback_state);
 	CTDB_NO_MEMORY(ctdb, state);
 
@@ -866,6 +872,8 @@
  */
 static int ctdb_client_ip_destructor(struct ctdb_client_ip *ip)
 {
+	DEBUG(3,("destroying client tcp for %s:%u (client_id %u)\n",
+		 inet_ntoa(ip->ip.sin_addr), ntohs(ip->ip.sin_port), ip->client_id));
 	DLIST_REMOVE(ip->ctdb->client_ip_list, ip);
 	return 0;
 }
@@ -888,10 +896,21 @@
 
 	vnn = find_public_ip_vnn(ctdb, p->dest);
 	if (vnn == NULL) {
-		DEBUG(3,("Could not add client IP %s. This is not a public address.\n", inet_ntoa(p->dest.sin_addr))); 
+		if (ntohl(p->dest.sin_addr.s_addr) != INADDR_LOOPBACK) {
+			DEBUG(0,("Could not add client IP %s. This is not a public address.\n", 
+				 inet_ntoa(p->dest.sin_addr))); 
+		}
 		return 0;
 	}
 
+	if (vnn->pnn != ctdb->pnn) {
+		DEBUG(0,("Attempt to register tcp client for IP %s we don't hold - failing (client_id %u pid %u)\n",
+			 inet_ntoa(p->dest.sin_addr),
+			 client_id, client->pid));
+		/* failing this call will tell smbd to die */
+		return -1;
+	}
+
 	ip = talloc(client, struct ctdb_client_ip);
 	CTDB_NO_MEMORY(ctdb, ip);
 
@@ -915,10 +934,10 @@
 	data.dptr = (uint8_t *)&t;
 	data.dsize = sizeof(t);
 
-	DEBUG(2,("registered tcp client for %u->%s:%u\n",
+	DEBUG(1,("registered tcp client for %u->%s:%u (client_id %u pid %u)\n",
 		 (unsigned)ntohs(p->dest.sin_port), 
 		 inet_ntoa(p->src.sin_addr),
-		 (unsigned)ntohs(p->src.sin_port)));
+		 (unsigned)ntohs(p->src.sin_port), client_id, client->pid));
 
 	/* tell all nodes about this tcp connection */
 	ret = ctdb_daemon_send_control(ctdb, CTDB_BROADCAST_CONNECTED, 0, 



More information about the samba-cvs mailing list