1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-28 01:58:17 +03:00

make the ctdb tool use the killtcp control in the daemon instead of

calling killtcp directly

(This used to be ctdb commit d21e3e9cf11bdcba6234302e033d6549c557dd69)
This commit is contained in:
Ronnie Sahlberg 2007-07-12 08:30:04 +10:00
parent 1ed0c3a9f7
commit 76ab80104a
5 changed files with 45 additions and 18 deletions

View File

@ -2094,6 +2094,32 @@ int ctdb_ctrl_get_all_tunables(struct ctdb_context *ctdb,
}
/*
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

View File

@ -446,7 +446,7 @@ struct ctdb_control_tcp {
/*
struct for kill_tcp control
*/
struct ctdb_control_kill_tcp {
struct ctdb_control_killtcp {
struct sockaddr_in src;
struct sockaddr_in dst;
};
@ -1068,4 +1068,10 @@ int ctdb_sys_open_capture_socket(void);
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

View File

@ -287,7 +287,7 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
return ctdb_control_modflags(ctdb, indata);
case CTDB_CONTROL_KILL_TCP:
CHECK_CONTROL_DATA_SIZE(sizeof(struct ctdb_control_kill_tcp));
CHECK_CONTROL_DATA_SIZE(sizeof(struct ctdb_control_killtcp));
return ctdb_control_kill_tcp(ctdb, indata);
default:

View File

@ -687,7 +687,7 @@ int32_t ctdb_control_tcp_add(struct ctdb_context *ctdb, TDB_DATA indata)
*/
int32_t ctdb_control_kill_tcp(struct ctdb_context *ctdb, TDB_DATA indata)
{
struct ctdb_control_kill_tcp *killtcp = (struct ctdb_control_kill_tcp *)indata.dptr;
struct ctdb_control_killtcp *killtcp = (struct ctdb_control_killtcp *)indata.dptr;
ctdb_killtcp_add_connection(ctdb, &killtcp->src, &killtcp->dst);

View File

@ -307,32 +307,27 @@ static int control_status(struct ctdb_context *ctdb, int argc, const char **argv
*/
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;
@ -890,7 +885,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. 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>" },
};