From: Martin Schwenke Date: Fri, 11 Mar 2016 04:37:37 +0000 (+1100) Subject: ctdb-tools: Drop "ctdb killtcp" command X-Git-Tag: tdb-1.3.9~43 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=efd371659f5cdf8d97eece8912e595ef7172f808;p=thirdparty%2Fsamba.git ctdb-tools: Drop "ctdb killtcp" command It is now handled by a standalone helper. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/doc/ctdb.1.xml b/ctdb/doc/ctdb.1.xml index 42012b4ce24..7c5822cd89d 100644 --- a/ctdb/doc/ctdb.1.xml +++ b/ctdb/doc/ctdb.1.xml @@ -1332,26 +1332,6 @@ dbid:0xb775fff6 name:secrets.tdb path:/usr/local/var/lib/ctdb/persistent/secrets - - killtcp - - Read a list of TCP connections, one per line, from standard - input and terminate each connection. A connection is - specified as: - - - SRC-IPADDR:SRC-PORT DST-IPADDR:DST-PORT - - - Each connection is terminated by issuing a TCP RST to the - SRC-IPADDR:SRC-PORT endpoint. - - - A single connection can be specified on the command-line - rather than on standard input. - - - pdelete <parameter>DB</parameter> <parameter>KEY</parameter> diff --git a/ctdb/tests/eventscripts/stubs/ctdb b/ctdb/tests/eventscripts/stubs/ctdb index 825cd042ac3..cd4d3995ffc 100755 --- a/ctdb/tests/eventscripts/stubs/ctdb +++ b/ctdb/tests/eventscripts/stubs/ctdb @@ -59,13 +59,6 @@ setup_tickles () touch "$tickles_file" } -ctdb_killtcp () -{ - while read _src _dst ; do - sed -i -e "/^$_dst $_src\$/d" "$FAKE_NETSTAT_TCP_ESTABLISHED_FILE" - done -} - parse_nodespec () { if [ "$nodespec" = "all" ] ; then @@ -454,7 +447,6 @@ case "$1" in done ;; gratiousarp) : ;; # Do nothing for now - killtcp) ctdb_killtcp "$@" ;; ip) ctdb_ip "$@" ;; pnn|xpnn) ctdb_pnn ;; enable) ctdb_enable "$@";; diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c index 711aad41da3..bc7427cab81 100644 --- a/ctdb/tools/ctdb.c +++ b/ctdb/tools/ctdb.c @@ -2355,144 +2355,6 @@ static int control_delip(struct ctdb_context *ctdb, int argc, const char **argv) return 0; } -static int kill_tcp_from_file(struct ctdb_context *ctdb, - int argc, const char **argv) -{ - struct ctdb_connection *killtcp; - int max_entries, current, i; - struct timeval timeout; - char line[128], src[128], dst[128]; - int linenum; - TDB_DATA data; - struct client_async_data *async_data; - struct ctdb_client_control_state *state; - - if (argc != 0) { - usage(); - } - - linenum = 1; - killtcp = NULL; - max_entries = 0; - current = 0; - while (!feof(stdin)) { - if (fgets(line, sizeof(line), stdin) == NULL) { - continue; - } - - /* Silently skip empty lines */ - if (line[0] == '\n') { - continue; - } - - if (sscanf(line, "%s %s\n", src, dst) != 2) { - DEBUG(DEBUG_ERR, ("Bad line [%d]: '%s'\n", - linenum, line)); - talloc_free(killtcp); - return -1; - } - - if (current >= max_entries) { - max_entries += 1024; - killtcp = talloc_realloc(ctdb, killtcp, - struct ctdb_connection, - max_entries); - CTDB_NO_MEMORY(ctdb, killtcp); - } - - if (!parse_ip_port(src, &killtcp[current].src)) { - DEBUG(DEBUG_ERR, ("Bad IP:port on line [%d]: '%s'\n", - linenum, src)); - talloc_free(killtcp); - return -1; - } - - if (!parse_ip_port(dst, &killtcp[current].dst)) { - DEBUG(DEBUG_ERR, ("Bad IP:port on line [%d]: '%s'\n", - linenum, dst)); - talloc_free(killtcp); - return -1; - } - - current++; - } - - async_data = talloc_zero(ctdb, struct client_async_data); - if (async_data == NULL) { - talloc_free(killtcp); - return -1; - } - - for (i = 0; i < current; i++) { - - data.dsize = sizeof(struct ctdb_connection); - data.dptr = (unsigned char *)&killtcp[i]; - - timeout = TIMELIMIT(); - state = ctdb_control_send(ctdb, options.pnn, 0, - CTDB_CONTROL_KILL_TCP, 0, data, - async_data, &timeout, NULL); - - if (state == NULL) { - DEBUG(DEBUG_ERR, - ("Failed to call async killtcp control to node %u\n", - options.pnn)); - talloc_free(killtcp); - return -1; - } - - ctdb_client_async_add(async_data, state); - } - - if (ctdb_client_async_wait(ctdb, async_data) != 0) { - DEBUG(DEBUG_ERR,("killtcp failed\n")); - talloc_free(killtcp); - return -1; - } - - talloc_free(killtcp); - return 0; -} - - -/* - kill a tcp connection - */ -static int kill_tcp(struct ctdb_context *ctdb, int argc, const char **argv) -{ - int ret; - struct ctdb_connection killtcp; - - assert_single_node_only(); - - if (argc == 0) { - return kill_tcp_from_file(ctdb, argc, argv); - } - - if (argc < 2) { - usage(); - } - - if (!parse_ip_port(argv[0], &killtcp.src)) { - DEBUG(DEBUG_ERR, ("Bad IP:port '%s'\n", argv[0])); - return -1; - } - - if (!parse_ip_port(argv[1], &killtcp.dst)) { - DEBUG(DEBUG_ERR, ("Bad IP:port '%s'\n", argv[1])); - return -1; - } - - ret = ctdb_ctrl_killtcp(ctdb, TIMELIMIT(), options.pnn, &killtcp); - if (ret != 0) { - DEBUG(DEBUG_ERR, ("Unable to killtcp from node %u\n", options.pnn)); - return ret; - } - - return 0; -} - - /* send a gratious arp */ @@ -6238,7 +6100,6 @@ static const struct { { "ipreallocate", control_ipreallocate, false, false, "force the recovery daemon to perform a ip reallocation procedure" }, { "thaw", control_thaw, true, false, "thaw databases", "[priority:1-3]" }, { "isnotrecmaster", control_isnotrecmaster, false, false, "check if the local node is recmaster or not" }, - { "killtcp", kill_tcp, false, false, "kill a tcp connection.", "[<srcip:port> <dstip:port>]" }, { "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> [<port>]" },