[SCM] Samba Shared Repository - branch master updated

Amitay Isaacs amitay at samba.org
Fri Apr 1 06:12:06 UTC 2016


The branch, master has been updated
       via  02f4808 ctdb-killtcp: Change default retry interval, batch size and attempts
       via  dd06c79 ctdb-killtcp: Send tickle ACKs in batches
       via  e66cdd8 ctdb-killtcp: Store retry interval in killtcp structure
       via  93f3cd6 ctdb-killtcp: Don't count attempts for individual connections
       via  402f3c0 ctdb-killtcp: Keep track of number of kill attempts and maximum allowed
       via  7e5eab1 ctdb-killtcp: Filter out sent packets
       via  bba3115 ctdb-system: Return window size and RST bit when reading TCP packets
       via  d7fa4b7 ctdb-killtcp: Clarify a debug message
       via  cb2fee2 ctdb-killtcp: Set debug level via environment variable CTDB_DEBUGLEVEL
       via  5492f87 ctdb-killtcp: Don't send initial tickle ACK during setup
       via  4105ca9 ctdb-killtcp: Drop unnecessary casts
       via  7aea3c1 ctdb-killtcp: Drop check to see if capture socket can be read
       via  2e1e1e8 ctdb-killtcp: Merge "common" killtcp code into helper
       via  52cfe76 ctdb-protocol: Drop killtcp protocol support
       via  d8398b0 ctdb-daemon: Remove implementation of CTDB_CONTROL_KILL_TCP
       via  f0a83d8 ctdb-client: Drop killtcp client functions
       via  efd3716 ctdb-tools: Drop "ctdb killtcp" command
       via  83502a7 ctdb-scripts: Use ctdb_killtcp helper to kill connections
       via  b417d79 ctdb-scripts: Add interface argument to kill_tcp_connections()
       via  1924323 ctdb-killtcp: New helper ctdb_killtcp
       via  c561129 ctdb-killtcp: Simplify includes by using ctdb_sock_addr_to_string()
       via  248557b ctdb-killtcp: Avoid unnecessary dependency on lib/util/time.h
       via  51f5faf ctdb-killtcp: Factor out killtcp code into separate file.
       via  f76cb52 ctdb-killtcp: Factor out ctdb_killtcp()
       via  879960b ctdb-killtcp: Change struct ctdb_tcp_kill to store arbitrary destructor data
       via  1bf494f ctdb-killtcp: Avoid CTDB_NO_MEMORY()
       via  32ea7c0 ctdb-killtcp: Determine the interface as soon as vnn is known
       via  380c894 ctdb-killtcp: Use the given event context directly
       via  386cd79 ctdb-system: Add ctdb_parse_connections() function
       via  5433a00 ctdb-tests: Link ctdb-util instead of including
       via  676f42a ctdb-util: Move rb_tree.c to ctdb-util
      from  10054c4 docs: Mention _NO_WINBINDD in idmap_script.8

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 02f48084b7f0cb3abdb1b9d2fd72cff76ffc21ea
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Mar 29 14:58:33 2016 +1100

    ctdb-killtcp: Change default retry interval, batch size and attempts
    
    Testing indicates that these are good reliable defaults that can kill
    many connections in a reasonable amount of time.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    Autobuild-User(master): Amitay Isaacs <amitay at samba.org>
    Autobuild-Date(master): Fri Apr  1 08:10:54 CEST 2016 on sn-devel-144

commit dd06c797b115c900f7e719d119e2eeeab07357bf
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Mar 24 15:11:22 2016 +1100

    ctdb-killtcp: Send tickle ACKs in batches
    
    At the moment the batch size is "all".
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit e66cdd8312416208dbe532577e5b95ff362a9671
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Mar 23 11:03:41 2016 +1100

    ctdb-killtcp: Store retry interval in killtcp structure
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 93f3cd66506373d842dc2dc7a1a678109410ac8e
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Mar 23 08:26:36 2016 +1100

    ctdb-killtcp: Don't count attempts for individual connections
    
    This made sense when connections were individually queued in the
    daemon.  However, they're now done in batch so just keep an overall
    count.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 402f3c0460f072c316bc8f0b28c2adf7164b513c
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Mar 23 08:20:07 2016 +1100

    ctdb-killtcp: Keep track of number of kill attempts and maximum allowed
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 7e5eab139d37819e162188dd474e5d142f3c04c1
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Mar 21 11:11:19 2016 +1100

    ctdb-killtcp: Filter out sent packets
    
    When previously killing TCP connections via the daemon there was some
    latency due to each kill being sent to the daemon via a separate
    control.  This probably meant that when doing a 2-way kill the tickle
    ACKs sent to the client end of a connection would not interfere with
    listening for the reply ACK from the server end.  Now that there is no
    latency, the tickle ACK or RST sent to the client end can be seen as
    the reply to the server end tickle ACK, and vice-versa.
    
    To avoid this, throw away packets that look like we sent them.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit bba31152df279ebf6afa6555544a990d64dbe4b1
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Mar 21 11:07:19 2016 +1100

    ctdb-system: Return window size and RST bit when reading TCP packets
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit d7fa4b76c57358406ddc53569372add7fc57089b
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Mar 21 11:45:10 2016 +1100

    ctdb-killtcp: Clarify a debug message
    
    The end of the connection in parentheses is not the end being killed.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit cb2fee2c43ba1875a2075b952fb625784e03e346
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Mar 21 11:42:40 2016 +1100

    ctdb-killtcp: Set debug level via environment variable CTDB_DEBUGLEVEL
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 5492f874d93698d78fd3d2bcb2fa6cc8e5ad5f2e
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Mar 29 13:49:11 2016 +1100

    ctdb-killtcp: Don't send initial tickle ACK during setup
    
    Since they're being done in batch, just schedule an event to traverse
    all the connections.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 4105ca953e12419cc2f95c49ce72d36a8c17c084
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Mar 23 14:49:05 2016 +1100

    ctdb-killtcp: Drop unnecessary casts
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 7aea3c12fbf8ac70970471bea1459f4de6001e20
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Mar 23 14:18:24 2016 +1100

    ctdb-killtcp: Drop check to see if capture socket can be read
    
    The handler won't be called unless there is something to read.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 2e1e1e8268a2143eb69ea46c9b3335dcd4377914
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Mar 11 16:04:30 2016 +1100

    ctdb-killtcp: Merge "common" killtcp code into helper
    
    ctdb_killtcp.c is now the only place it is needed.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 52cfe76de8495bb9bc7bf5f721c049e5b63fffdf
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Mar 11 15:54:21 2016 +1100

    ctdb-protocol: Drop killtcp protocol support
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit d8398b04b520724d89a4107027e49dfd22f25a43
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Mar 11 15:57:44 2016 +1100

    ctdb-daemon: Remove implementation of CTDB_CONTROL_KILL_TCP
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit f0a83d865c761c76e0adc428cdfed350fc99a7fb
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Mar 11 15:48:26 2016 +1100

    ctdb-client: Drop killtcp client functions
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit efd371659f5cdf8d97eece8912e595ef7172f808
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Mar 11 15:37:37 2016 +1100

    ctdb-tools: Drop "ctdb killtcp" command
    
    It is now handled by a standalone helper.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 83502a79dc3d7907525be01438d0e28dad7285bd
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Mar 11 15:30:47 2016 +1100

    ctdb-scripts: Use ctdb_killtcp helper to kill connections
    
    ctdb_killtcp will take up to 5 seconds to kill connections, so don't
    wait in a loop.  Just check if there are remaining connections on
    completion and log a message either way.
    
    Also add a test stub.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit b417d7993016c11cff1c9c1aa88ac32d6db4345d
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Mar 11 15:27:10 2016 +1100

    ctdb-scripts: Add interface argument to kill_tcp_connections()
    
    This will be needed for a rewrite of the connection killing code but
    it is not used yet.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 1924323af6c6e769c39e4d6716e30eb6f7391b4b
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Mar 3 10:34:48 2016 +1100

    ctdb-killtcp: New helper ctdb_killtcp
    
    This will allow killing of TCP connections without daemon involvement.
    
    It looks strange that the common code for daemon and helper is in the
    server directory.  Having it in the server directory means less
    temporary changes to the build configuration.  This code will move
    into the helper itself and will no longer be used by the daemon.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit c56112949a38ac5238c847073630807747da8f0e
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Mar 17 11:32:49 2016 +1100

    ctdb-killtcp: Simplify includes by using ctdb_sock_addr_to_string()
    
    This allows common.h and ctdb_private.h to be dropped.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 248557bdf54354c71216a125248aefdc885f4ab6
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Mar 7 06:29:19 2016 +1100

    ctdb-killtcp: Avoid unnecessary dependency on lib/util/time.h
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 51f5faf5557bf326a3a45a9851aed99335ddc8c2
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Mar 2 16:27:02 2016 +1100

    ctdb-killtcp: Factor out killtcp code into separate file.
    
    This will be used in a standalone helper.
    
    Don't worry that the API isn't clean and opaque.  All of the code will
    eventually move into the helper and will no longer be used by the
    daemon.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit f76cb52eb5d65ff8c5948e550768983c9548d8fe
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Mar 2 16:06:58 2016 +1100

    ctdb-killtcp: Factor out ctdb_killtcp()
    
    This function knows nothing about CTDB contexts or VNNs, so it can be
    used elsewhere.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 879960b74d805b7491350f86fda6c689ad15bc28
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Mar 2 19:04:18 2016 +1100

    ctdb-killtcp: Change struct ctdb_tcp_kill to store arbitrary destructor data
    
    The destructor used in this instances needs a CTDB context and a VNN.
    However, destructors used in other cases may need different data.
    
    For this instance create a local structure to hold the required data.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 1bf494f6934e96f812f870b5c59ddd49fc9c3148
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Mar 2 15:28:01 2016 +1100

    ctdb-killtcp: Avoid CTDB_NO_MEMORY()
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 32ea7c0d2cf68fcfe7646576e8ba37e79c6e3f93
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Mar 2 13:29:46 2016 +1100

    ctdb-killtcp: Determine the interface as soon as vnn is known
    
    This makes restructuring the code easier.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 380c8944713e5ead1cccfcfd93a90c9d77515dce
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Mar 2 13:20:27 2016 +1100

    ctdb-killtcp: Use the given event context directly
    
    We don't want this code to depend on a CTDB context, so don't go
    looking there for an event context.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 386cd7969c501e62ff0485f7243abc93a301a673
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Mar 11 11:44:12 2016 +1100

    ctdb-system: Add ctdb_parse_connections() function
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 5433a00408866d49951033b8856b26cae85313b9
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Mar 2 16:41:29 2016 +1100

    ctdb-tests: Link ctdb-util instead of including
    
    These are never replaced with stubs.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 676f42a6ba6280b839d4bf22c33ed9f65360670e
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Mar 17 07:05:51 2016 +1100

    ctdb-util: Move rb_tree.c to ctdb-util
    
    It doesn't need struct ctdb_context or similar.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

-----------------------------------------------------------------------

Summary of changes:
 ctdb/client/client.h                               |   5 -
 ctdb/client/client_control_sync.c                  |  29 --
 ctdb/client/ctdb_client.c                          |  25 --
 ctdb/common/system.h                               |  10 +-
 ctdb/common/system_aix.c                           |  20 +-
 ctdb/common/system_freebsd.c                       |  17 +-
 ctdb/common/system_gnu.c                           |  19 +-
 ctdb/common/system_kfreebsd.c                      |  19 +-
 ctdb/common/system_linux.c                         |  19 +-
 ctdb/common/system_util.c                          |  55 +++
 ctdb/config/events.d/10.interface                  |   2 +-
 ctdb/config/events.d/91.lvs                        |   3 +-
 ctdb/config/functions                              |  33 +-
 ctdb/doc/ctdb.1.xml                                |  20 -
 ctdb/include/ctdb_client.h                         |   4 -
 ctdb/include/ctdb_private.h                        |   3 -
 ctdb/packaging/RPM/ctdb.spec.in                    |   1 +
 ctdb/protocol/protocol.h                           |   2 +-
 ctdb/protocol/protocol_api.h                       |   4 -
 ctdb/protocol/protocol_client.c                    |  20 -
 ctdb/protocol/protocol_control.c                   |  16 -
 ctdb/server/ctdb_control.c                         |   5 +-
 ctdb/server/ctdb_takeover.c                        | 337 ----------------
 .../eventscripts/10.interface.releaseip.011.sh     |   5 +-
 ctdb/tests/eventscripts/stubs/ctdb                 |   8 -
 ctdb/tests/eventscripts/stubs/ctdb_killtcp         |   9 +
 ctdb/tests/src/ctdb_test.c                         |   5 -
 ctdb/tests/src/ctdbd_test.c                        |   5 -
 ctdb/tests/src/protocol_client_test.c              |  16 -
 ctdb/tools/ctdb.c                                  | 139 -------
 ctdb/tools/ctdb_killtcp.c                          | 440 +++++++++++++++++++++
 ctdb/wscript                                       |  16 +-
 32 files changed, 623 insertions(+), 688 deletions(-)
 create mode 100755 ctdb/tests/eventscripts/stubs/ctdb_killtcp
 create mode 100644 ctdb/tools/ctdb_killtcp.c


Changeset truncated at 500 lines:

diff --git a/ctdb/client/client.h b/ctdb/client/client.h
index 9869004..1060d2e 100644
--- a/ctdb/client/client.h
+++ b/ctdb/client/client.h
@@ -384,11 +384,6 @@ int ctdb_ctrl_get_all_tunables(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
 			       int destnode, struct timeval timeout,
 			       struct ctdb_tunable_list **tun_list);
 
-int ctdb_ctrl_kill_tcp(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
-		       struct ctdb_client_context *client,
-		       int destnode, struct timeval timeout,
-		       struct ctdb_connection *conn);
-
 int ctdb_ctrl_get_tcp_tickle_list(TALLOC_CTX *mem_ctx,
 				  struct tevent_context *ev,
 				  struct ctdb_client_context *client,
diff --git a/ctdb/client/client_control_sync.c b/ctdb/client/client_control_sync.c
index 7515623..2c71b36 100644
--- a/ctdb/client/client_control_sync.c
+++ b/ctdb/client/client_control_sync.c
@@ -1084,35 +1084,6 @@ int ctdb_ctrl_get_all_tunables(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
 	return 0;
 }
 
-int ctdb_ctrl_kill_tcp(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
-		       struct ctdb_client_context *client,
-		       int destnode, struct timeval timeout,
-		       struct ctdb_connection *conn)
-{
-	struct ctdb_req_control request;
-	struct ctdb_reply_control *reply;
-	int ret;
-
-	ctdb_req_control_kill_tcp(&request, conn);
-	ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
-				  &request, &reply);
-	if (ret != 0) {
-		DEBUG(DEBUG_ERR,
-		      ("Control KILL_TCP failed to node %u, ret=%d\n",
-		       destnode, ret));
-		return ret;
-	}
-
-	ret = ctdb_reply_control_kill_tcp(reply);
-	if (ret != 0) {
-		DEBUG(DEBUG_ERR,
-		      ("Control KILL_TCP failed, ret=%d\n", ret));
-		return ret;
-	}
-
-	return 0;
-}
-
 int ctdb_ctrl_get_tcp_tickle_list(TALLOC_CTX *mem_ctx,
 				  struct tevent_context *ev,
 				  struct ctdb_client_context *client,
diff --git a/ctdb/client/ctdb_client.c b/ctdb/client/ctdb_client.c
index 9fae604..aae3853 100644
--- a/ctdb/client/ctdb_client.c
+++ b/ctdb/client/ctdb_client.c
@@ -3104,31 +3104,6 @@ int ctdb_ctrl_del_public_ip(struct ctdb_context *ctdb,
 }
 
 /*
-  kill a tcp connection
- */
-int ctdb_ctrl_killtcp(struct ctdb_context *ctdb, 
-		      struct timeval timeout, 
-		      uint32_t destnode,
-		      struct ctdb_connection *killtcp)
-{
-	TDB_DATA data;
-	int32_t res;
-	int ret;
-
-	data.dsize = sizeof(struct ctdb_connection);
-	data.dptr  = (unsigned char *)killtcp;
-
-	ret = ctdb_control(ctdb, destnode, 0, CTDB_CONTROL_KILL_TCP, 0, data, NULL,
-			   NULL, &res, &timeout, NULL);
-	if (ret != 0 || res != 0) {
-		DEBUG(DEBUG_ERR,(__location__ " ctdb_control for killtcp failed\n"));
-		return -1;
-	}
-
-	return 0;
-}
-
-/*
   send a gratious arp
  */
 int ctdb_ctrl_gratious_arp(struct ctdb_context *ctdb,
diff --git a/ctdb/common/system.h b/ctdb/common/system.h
index 1229a7e..2b469dc 100644
--- a/ctdb/common/system.h
+++ b/ctdb/common/system.h
@@ -20,6 +20,8 @@
 #ifndef __CTDB_SYSTEM_H__
 #define __CTDB_SYSTEM_H__
 
+#include <talloc.h>
+
 /* From system_common.c */
 
 uint32_t uint16_checksum(uint16_t *data, size_t n);
@@ -35,8 +37,9 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest,
 int ctdb_sys_open_capture_socket(const char *iface, void **private_data);
 int ctdb_sys_close_capture_socket(void *private_data);
 int ctdb_sys_read_tcp_packet(int s, void *private_data,
-			ctdb_sock_addr *src, ctdb_sock_addr *dst,
-			uint32_t *ack_seq, uint32_t *seq);
+			     ctdb_sock_addr *src, ctdb_sock_addr *dst,
+			     uint32_t *ack_seq, uint32_t *seq,
+			     int *rst, uint16_t *window);
 bool ctdb_sys_check_iface_exists(const char *iface);
 int ctdb_get_peer_pid(const int fd, pid_t *peer_pid);
 
@@ -64,4 +67,7 @@ ssize_t sys_write(int fd, const void *buf, size_t count);
 
 void ctdb_wait_for_process_to_exit(pid_t pid);
 
+int ctdb_parse_connections(FILE *fp, TALLOC_CTX *mem_ctx,
+			   int *num_conn, struct ctdb_connection **out);
+
 #endif /* __CTDB_SYSTEM_H__ */
diff --git a/ctdb/common/system_aix.c b/ctdb/common/system_aix.c
index 2d35a22..9b22ff9 100644
--- a/ctdb/common/system_aix.c
+++ b/ctdb/common/system_aix.c
@@ -269,9 +269,10 @@ static int aix_get_mac_addr(const char *device_name, uint8_t mac[6])
 	return -1;
 }
 
-int ctdb_sys_read_tcp_packet(int s, void *private_data, 
-			ctdb_sock_addr *src, ctdb_sock_addr *dst,
-			uint32_t *ack_seq, uint32_t *seq)
+int ctdb_sys_read_tcp_packet(int s, void *private_data,
+			     ctdb_sock_addr *src, ctdb_sock_addr *dst,
+			     uint32_t *ack_seq, uint32_t *seq,
+			     int *rst, uint16_t *window)
 {
 	int ret;
 	struct ether_header *eth;
@@ -326,7 +327,12 @@ int ctdb_sys_read_tcp_packet(int s, void *private_data,
 		dst->ip.sin_port        = tcp->th_dport;
 		*ack_seq                = tcp->th_ack;
 		*seq                    = tcp->th_seq;
-
+		if (window != NULL) {
+			*window = tcp->th_win;
+		}
+		if (rst != NULL) {
+			*rst = tcp->th_flags & TH_RST;
+		}
 
 		return 0;
 #ifndef ETHERTYPE_IP6
@@ -355,6 +361,12 @@ int ctdb_sys_read_tcp_packet(int s, void *private_data,
 
 		*ack_seq             = tcp->th_ack;
 		*seq                 = tcp->th_seq;
+		if (window != NULL) {
+			*window = tcp->th_win;
+		}
+		if (rst != NULL) {
+			*rst = tcp->th_flags & TH_RST;
+		}
 
 		return 0;
 	}
diff --git a/ctdb/common/system_freebsd.c b/ctdb/common/system_freebsd.c
index 37e4bae..3845019 100644
--- a/ctdb/common/system_freebsd.c
+++ b/ctdb/common/system_freebsd.c
@@ -278,8 +278,9 @@ int ctdb_sys_close_capture_socket(void *private_data)
   called when the raw socket becomes readable
  */
 int ctdb_sys_read_tcp_packet(int s, void *private_data, 
-			ctdb_sock_addr *src, ctdb_sock_addr *dst,
-			uint32_t *ack_seq, uint32_t *seq)
+			     ctdb_sock_addr *src, ctdb_sock_addr *dst,
+			     uint32_t *ack_seq, uint32_t *seq,
+			     int *rst, uint16_t *window)
 {
 	int ret;
 #define RCVPKTSIZE 100
@@ -332,6 +333,12 @@ int ctdb_sys_read_tcp_packet(int s, void *private_data,
 		dst->ip.sin_port        = tcp->th_dport;
 		*ack_seq                = tcp->th_ack;
 		*seq                    = tcp->th_seq;
+		if (window != NULL) {
+			*window = tcp->th_win;
+		}
+		if (rst != NULL) {
+			*rst = tcp->th_flags & TH_RST;
+		}
 
 		return 0;
 	} else if (ntohs(eth->ether_type) == ETHERTYPE_IP6) {
@@ -357,6 +364,12 @@ int ctdb_sys_read_tcp_packet(int s, void *private_data,
 
 		*ack_seq             = tcp->th_ack;
 		*seq                 = tcp->th_seq;
+		if (window != NULL) {
+			*window = tcp->th_win;
+		}
+		if (rst != NULL) {
+			*rst = tcp->th_flags & TH_RST;
+		}
 
 		return 0;
 	}
diff --git a/ctdb/common/system_gnu.c b/ctdb/common/system_gnu.c
index e5b8e05..70361d7 100644
--- a/ctdb/common/system_gnu.c
+++ b/ctdb/common/system_gnu.c
@@ -270,9 +270,10 @@ int ctdb_sys_close_capture_socket(void *private_data)
 /*
   called when the raw socket becomes readable
  */
-int ctdb_sys_read_tcp_packet(int s, void *private_data, 
-			ctdb_sock_addr *src, ctdb_sock_addr *dst,
-			uint32_t *ack_seq, uint32_t *seq)
+int ctdb_sys_read_tcp_packet(int s, void *private_data,
+			     ctdb_sock_addr *src, ctdb_sock_addr *dst,
+			     uint32_t *ack_seq, uint32_t *seq,
+			     int *rst, uint16_t *window)
 {
 	int ret;
 #define RCVPKTSIZE 100
@@ -325,6 +326,12 @@ int ctdb_sys_read_tcp_packet(int s, void *private_data,
 		dst->ip.sin_port        = tcp->dest;
 		*ack_seq                = tcp->ack_seq;
 		*seq                    = tcp->seq;
+		if (window != NULL) {
+			*window = tcp->window;
+		}
+		if (rst != NULL) {
+			*rst = tcp->rst;
+		}
 
 		return 0;
 	} else if (ntohs(eth->ether_type) == ETHERTYPE_IP6) {
@@ -350,6 +357,12 @@ int ctdb_sys_read_tcp_packet(int s, void *private_data,
 
 		*ack_seq             = tcp->ack_seq;
 		*seq                 = tcp->seq;
+		if (window != NULL) {
+			*window = tcp->window;
+		}
+		if (rst != NULL) {
+			*rst = tcp->rst;
+		}
 
 		return 0;
 	}
diff --git a/ctdb/common/system_kfreebsd.c b/ctdb/common/system_kfreebsd.c
index 4be678d..9b5c9ce 100644
--- a/ctdb/common/system_kfreebsd.c
+++ b/ctdb/common/system_kfreebsd.c
@@ -270,9 +270,10 @@ int ctdb_sys_close_capture_socket(void *private_data)
 /*
   called when the raw socket becomes readable
  */
-int ctdb_sys_read_tcp_packet(int s, void *private_data, 
-			ctdb_sock_addr *src, ctdb_sock_addr *dst,
-			uint32_t *ack_seq, uint32_t *seq)
+int ctdb_sys_read_tcp_packet(int s, void *private_data,
+			     ctdb_sock_addr *src, ctdb_sock_addr *dst,
+			     uint32_t *ack_seq, uint32_t *seq,
+			     int *rst, uint16_t *window)
 {
 	int ret;
 #define RCVPKTSIZE 100
@@ -325,6 +326,12 @@ int ctdb_sys_read_tcp_packet(int s, void *private_data,
 		dst->ip.sin_port        = tcp->dest;
 		*ack_seq                = tcp->ack_seq;
 		*seq                    = tcp->seq;
+		if (window != NULL) {
+			*window = tcp->window;
+		}
+		if (rst != NULL) {
+			*rst = tcp->rst;
+		}
 
 		return 0;
 	} else if (ntohs(eth->ether_type) == ETHERTYPE_IP6) {
@@ -350,6 +357,12 @@ int ctdb_sys_read_tcp_packet(int s, void *private_data,
 
 		*ack_seq             = tcp->ack_seq;
 		*seq                 = tcp->seq;
+		if (window != NULL) {
+			*window = tcp->window;
+		}
+		if (rst != NULL) {
+			*rst = tcp->rst;
+		}
 
 		return 0;
 	}
diff --git a/ctdb/common/system_linux.c b/ctdb/common/system_linux.c
index 6d01699..b754e91 100644
--- a/ctdb/common/system_linux.c
+++ b/ctdb/common/system_linux.c
@@ -488,9 +488,10 @@ int ctdb_sys_close_capture_socket(void *private_data)
 /*
   called when the raw socket becomes readable
  */
-int ctdb_sys_read_tcp_packet(int s, void *private_data, 
-			ctdb_sock_addr *src, ctdb_sock_addr *dst,
-			uint32_t *ack_seq, uint32_t *seq)
+int ctdb_sys_read_tcp_packet(int s, void *private_data,
+			     ctdb_sock_addr *src, ctdb_sock_addr *dst,
+			     uint32_t *ack_seq, uint32_t *seq,
+			     int *rst, uint16_t *window)
 {
 	int ret;
 #define RCVPKTSIZE 100
@@ -543,6 +544,12 @@ int ctdb_sys_read_tcp_packet(int s, void *private_data,
 		dst->ip.sin_port        = tcp->dest;
 		*ack_seq                = tcp->ack_seq;
 		*seq                    = tcp->seq;
+		if (window != NULL) {
+			*window = tcp->window;
+		}
+		if (rst != NULL) {
+			*rst = tcp->rst;
+		}
 
 		return 0;
 	} else if (ntohs(eth->ether_type) == ETHERTYPE_IP6) {
@@ -568,6 +575,12 @@ int ctdb_sys_read_tcp_packet(int s, void *private_data,
 
 		*ack_seq             = tcp->ack_seq;
 		*seq                 = tcp->seq;
+		if (window != NULL) {
+			*window = tcp->window;
+		}
+		if (rst != NULL) {
+			*rst = tcp->rst;
+		}
 
 		return 0;
 	}
diff --git a/ctdb/common/system_util.c b/ctdb/common/system_util.c
index f47d586..4d56fd3 100644
--- a/ctdb/common/system_util.c
+++ b/ctdb/common/system_util.c
@@ -23,6 +23,7 @@
 #include "system/shmem.h"
 #include "system/network.h"
 
+#include <talloc.h>
 #include <libgen.h>
 
 #include "lib/util/debug.h"
@@ -427,3 +428,57 @@ void ctdb_wait_for_process_to_exit(pid_t pid)
 		sleep(5);
 	}
 }
+
+int ctdb_parse_connections(FILE *fp, TALLOC_CTX *mem_ctx,
+			   int *num_conn, struct ctdb_connection **out)
+{
+	struct ctdb_connection *conn = NULL;
+	char line[128], src[128], dst[128]; /* long enough for IPv6 */
+	int line_num, ret;
+	int num = 0, max = 0;
+
+	line_num = 0;
+	while (! feof(fp)) {
+		if (fgets(line, sizeof(line), fp) == NULL) {
+			break;
+		}
+		line_num += 1;
+
+		/* Skip empty lines */
+		if (line[0] == '\n') {
+			continue;
+		}
+
+		ret = sscanf(line, "%s %s\n", src, dst);
+		if (ret != 2) {
+			DEBUG(DEBUG_ERR, ("Bad line [%d]: %s\n",
+					  line_num, line));
+			return EINVAL;
+		}
+
+		if (num >= max) {
+			max += 1024;
+			conn = talloc_realloc(mem_ctx, conn,
+					      struct ctdb_connection, max);
+			if (conn == NULL) {
+				return ENOMEM;
+			}
+		}
+
+		if (! parse_ip_port(src, &conn[num].src)) {
+			DEBUG(DEBUG_ERR, ("Invalid IP address %s\n", src));
+			return EINVAL;
+		}
+
+		if (! parse_ip_port(dst, &conn[num].dst)) {
+			DEBUG(DEBUG_ERR, ("Invalid IP address %s\n", dst));
+			return EINVAL;
+		}
+
+		num += 1;
+	}
+
+	*num_conn = num;
+	*out = conn;
+	return 0;
+}
diff --git a/ctdb/config/events.d/10.interface b/ctdb/config/events.d/10.interface
index 4fb3524..f65dd5e 100755
--- a/ctdb/config/events.d/10.interface
+++ b/ctdb/config/events.d/10.interface
@@ -161,7 +161,7 @@ case "$1" in
 	# we do an extra delete to cope with the script being killed
 	iptables_wrapper $family -D INPUT -i $iface -d $ip -j DROP 2> /dev/null
 	iptables_wrapper $family -I INPUT -i $iface -d $ip -j DROP
-	kill_tcp_connections $ip
+	kill_tcp_connections "$iface" "$ip"
 
 	delete_ip_from_iface $iface $ip $maskbits || {
 	    iptables_wrapper $family \
diff --git a/ctdb/config/events.d/91.lvs b/ctdb/config/events.d/91.lvs
index 47adf33..57ee2c1 100755
--- a/ctdb/config/events.d/91.lvs
+++ b/ctdb/config/events.d/91.lvs
@@ -44,7 +44,8 @@ case "$1" in
 	# kill off any tcp connections
 	ipvsadm -D -t $CTDB_LVS_PUBLIC_IP:0
 	ipvsadm -D -u $CTDB_LVS_PUBLIC_IP:0
-	kill_tcp_connections_local_only $CTDB_LVS_PUBLIC_IP
+	kill_tcp_connections_local_only \
+		"$CTDB_PUBLIC_INTERFACE" "$CTDB_LVS_PUBLIC_IP"
 
 	ctdb_get_pnn
 	LVSMASTER=`ctdb lvsmaster | sed -e "s/.*Node //" -e "s/ .*//"`
diff --git a/ctdb/config/functions b/ctdb/config/functions
index 9746895..7c28e4c 100755
--- a/ctdb/config/functions
+++ b/ctdb/config/functions
@@ -430,10 +430,11 @@ ctdb_check_command ()
 ################################################
 kill_tcp_connections ()
 {
-    _ip="$1"
+    _iface="$1"
+    _ip="$2"
 
     _oneway=false
-    if [ "$2" = "oneway" ] ; then
+    if [ "$3" = "oneway" ] ; then
 	_oneway=true
     fi
 
@@ -463,29 +464,21 @@ kill_tcp_connections ()
 	    return
 	fi
 
-	echo "$_connections" | ctdb killtcp || {
-	    echo "Failed to send killtcp control"
-	    return
+	echo "$_connections" | \
+		"${CTDB_HELPER_BINDIR}/ctdb_killtcp" "$_iface" || {
+		echo "Failed to kill TCP connections"
+		return
 	}
 
-	_count=0
-	while : ; do
-	    _remaining=$(get_tcp_connections_for_ip $_ip | wc -l)
+	_remaining=$(get_tcp_connections_for_ip $_ip | wc -l)
 
-	    if [ $_remaining -eq 0 ] ; then
+	if [ $_remaining -eq 0 ] ; then
 		echo "Killed $_killcount TCP connections to released IP $_ip"
 		return
-	    fi
-
-	    _count=$(($_count + 1))
-	    if [ $_count -gt 3 ] ; then
-		echo "Timed out killing tcp connections for IP $_ip ($_remaining remaining)"
-		return
-	    fi
+	fi
 
-	    echo "Waiting for $_remaining connections to be killed for IP $_ip"
-	    sleep 1
-	done
+	_t="${_remaining}/${_killcount}"
+	echo "Failed to kill TCP connections for IP $_ip (${_t} remaining)"
     }
 }
 
@@ -494,7 +487,7 @@ kill_tcp_connections ()
 ##################################################################


-- 
Samba Shared Repository



More information about the samba-cvs mailing list