From ab6564c83d8ea51b491408f81bd0f1e49e0ecdf9 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Wed, 4 Jul 2007 14:14:48 +1000 Subject: [PATCH] add a killtcp command to the ctdb tool (This used to be ctdb commit 01987b51fed0dc0b9a5e254fa734bdeb19debf6f) --- ctdb/Makefile.in | 4 ++-- ctdb/tools/ctdb.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/ctdb/Makefile.in b/ctdb/Makefile.in index 87adb7e243c..c4bfc79023e 100644 --- a/ctdb/Makefile.in +++ b/ctdb/Makefile.in @@ -83,9 +83,9 @@ bin/scsi_io: $(CLIENT_OBJS) scsi/scsi_io.o @echo Linking $@ @$(CC) $(CFLAGS) -o $@ scsi/scsi_io.o $(CTDB_CLIENT_OBJ) $(LIB_FLAGS) -bin/ctdb: $(CLIENT_OBJS) tools/ctdb.o +bin/ctdb: $(CLIENT_OBJS) tools/ctdb.o takeover/system.o @echo Linking $@ - @$(CC) $(CFLAGS) -o $@ tools/ctdb.o $(CTDB_CLIENT_OBJ) $(LIB_FLAGS) + @$(CC) $(CFLAGS) -o $@ tools/ctdb.o takeover/system.o $(CTDB_CLIENT_OBJ) $(LIB_FLAGS) bin/socketkiller: $(CLIENT_OBJS) tools/socketkiller.o @echo Linking $@ diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c index e6c1b392e45..b2837891035 100644 --- a/ctdb/tools/ctdb.c +++ b/ctdb/tools/ctdb.c @@ -303,6 +303,38 @@ static int control_status(struct ctdb_context *ctdb, int argc, const char **argv return 0; } +/* + kill a tcp connection + */ +static int kill_tcp(struct ctdb_context *ctdb, int argc, const char **argv) +{ + int i, ret; + struct sockaddr_in src, dst; + + if (argc < 4) { + usage(); + } + + src.sin_family=AF_INET; + src.sin_port=htons(atoi(argv[1])); + inet_aton(argv[0], &src.sin_addr); + + dst.sin_family=AF_INET; + dst.sin_port=htons(atoi(argv[3])); + inet_aton(argv[2], &dst.sin_addr); + + for (i=0;i<5;i++) { + ret = ctdb_sys_kill_tcp(ctdb->ev, &src, &dst); + + printf("ret:%d\n", ret); + if (ret==0) { + return 0; + } + } + + return -1; +} + /* display public ip status */ @@ -824,6 +856,7 @@ static const struct { { "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", " " }, }; /* -- 2.47.3