}
+/*
+ kill a tcp connection
+ */
+int ctdb_ctrl_killtcp(struct ctdb_context *ctdb,
+ struct timeval timeout,
+ uint32_t destnode,
+ struct ctdb_control_killtcp *killtcp)
+{
+ TDB_DATA data;
+ int32_t res;
+ int ret;
+
+ data.dsize = sizeof(struct ctdb_control_killtcp);
+ 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(0,(__location__ " ctdb_control for killtcp failed\n"));
+ return -1;
+ }
+
+ return 0;
+}
+
+
/*
initialise the ctdb daemon for client applications
/*
struct for kill_tcp control
*/
-struct ctdb_control_kill_tcp {
+struct ctdb_control_killtcp {
struct sockaddr_in src;
struct sockaddr_in dst;
};
int ctdb_killtcp_add_connection(struct ctdb_context *ctdb, struct sockaddr_in *src, struct sockaddr_in *dst);
int ctdb_sys_read_tcp_packet(struct ctdb_kill_tcp *killtcp);
+int ctdb_ctrl_killtcp(struct ctdb_context *ctdb,
+ struct timeval timeout,
+ uint32_t destnode,
+ struct ctdb_control_killtcp *killtcp);
+
+
#endif
*/
static int kill_tcp(struct ctdb_context *ctdb, int argc, const char **argv)
{
- int i, ret, numrst;
- struct sockaddr_in src, dst;
+ int ret;
+ struct ctdb_control_killtcp killtcp;
- if (argc < 3) {
+ if (argc < 2) {
usage();
}
- if (!parse_ip_port(argv[0], &src)) {
+ if (!parse_ip_port(argv[0], &killtcp.src)) {
printf("Bad IP:port '%s'\n", argv[0]);
return -1;
}
- if (!parse_ip_port(argv[1], &dst)) {
+ if (!parse_ip_port(argv[1], &killtcp.dst)) {
printf("Bad IP:port '%s'\n", argv[1]);
return -1;
}
- numrst = strtoul(argv[2], NULL, 0);
-
- for (i=0;i<numrst;i++) {
- ret = ctdb_sys_kill_tcp(ctdb->ev, &src, &dst);
-
- printf("ret:%d\n", ret);
- if (ret==0) {
- return 0;
- }
+ ret = ctdb_ctrl_killtcp(ctdb, TIMELIMIT(), options.vnn, &killtcp);
+ if (ret != 0) {
+ printf("Unable to killtcp from node %u\n", options.vnn);
+ return ret;
}
return -1;
{ "recover", control_recover, true, "force recovery" },
{ "freeze", control_freeze, true, "freeze all databases" },
{ "thaw", control_thaw, true, "thaw all databases" },
- { "killtcp", kill_tcp, false, "kill a tcp connection. Try <num> times.", "<srcip:port> <dstip:port> <num>" },
+ { "killtcp", kill_tcp, false, "kill a tcp connection.", "<srcip:port> <dstip:port>" },
{ "tickle", tickle_tcp, false, "send a tcp tickle ack", "<srcip:port> <dstip:port>" },
};