Add a new "ctdb addtickle" command to manually add tickles to ctdbd
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Wed, 18 Aug 2010 01:09:32 +0000 (11:09 +1000)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Wed, 18 Aug 2010 01:09:32 +0000 (11:09 +1000)
This can be used to set ctdbd up to generate a tickle for non-samba
services.
(samba contains code to set tickles up automatically)

tools/ctdb.c

index a65c525faba3e7fb222d1977d49e3e9fe5479a82..4285ef53023686ce0f82a0c1e4a09c97f4d9148b 100644 (file)
@@ -980,6 +980,43 @@ static int control_recmaster(struct ctdb_context *ctdb, int argc, const char **a
        return 0;
 }
 
+/*
+  add a list of all tickle to a public address
+ */
+static int control_add_tickle(struct ctdb_context *ctdb, int argc, const char **argv)
+{
+       struct ctdb_control_tcp_vnn t;
+       TDB_DATA data;
+       int ret;
+
+       if (argc < 2) {
+               usage();
+       }
+
+       if (parse_ip_port(argv[0], &t.src) == 0) {
+               DEBUG(DEBUG_ERR,("Wrongly formed ip address '%s'\n", argv[0]));
+               return -1;
+       }
+       if (parse_ip_port(argv[1], &t.dest) == 0) {
+               DEBUG(DEBUG_ERR,("Wrongly formed ip address '%s'\n", argv[1]));
+               return -1;
+       }
+
+       data.dptr = (uint8_t *)&t;
+       data.dsize = sizeof(t);
+
+       /* tell all nodes about this tcp connection */
+       ret = ctdb_control(ctdb, options.pnn, 0, CTDB_CONTROL_TCP_ADD,
+                          0, data, ctdb, NULL, NULL, NULL, NULL);
+       if (ret != 0) {
+               DEBUG(DEBUG_ERR,("Failed to add tickle\n"));
+               return -1;
+       }
+       
+       return 0;
+}
+
+
 /*
   get a list of all tickles for this pnn
  */
@@ -4386,6 +4423,7 @@ static const struct {
        { "gratiousarp",     control_gratious_arp,      false,  false, "send a gratious arp", "<ip> <interface>" },
        { "tickle",          tickle_tcp,                false,  false, "send a tcp tickle ack", "<srcip:port> <dstip:port>" },
        { "gettickles",      control_get_tickles,       false,  false, "get the list of tickles registered for this ip", "<ip>" },
+       { "addtickle",       control_add_tickle,        false,  false, "add a tickle for this ip", "<ip>:<port> <ip>:<port>" },
 
        { "regsrvid",        regsrvid,                  false,  false, "register a server id", "<pnn> <type> <id>" },
        { "unregsrvid",      unregsrvid,                false,  false, "unregister a server id", "<pnn> <type> <id>" },