From: Ronnie Sahlberg Date: Fri, 13 Jul 2007 07:07:10 +0000 (+1000) Subject: add a private_data field to the killtcp structure and let the system X-Git-Tag: tevent-0.9.20~348^2~2450^2~13 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f09566a81a32bc42fa507b38c6e78206bf5226b4;p=thirdparty%2Fsamba.git add a private_data field to the killtcp structure and let the system specific routines populate it as it see fit when creating a capture socket. pass this structure to read_tcp and close capture socket as parameter (This used to be ctdb commit 79bbfcfb2223889126fe307d5bbfd24917da07ee) --- diff --git a/ctdb/common/system.c b/ctdb/common/system.c index f4f12a168ba..8eebb3933df 100644 --- a/ctdb/common/system.c +++ b/ctdb/common/system.c @@ -259,7 +259,7 @@ bool ctdb_sys_have_ip(const char *ip) /* This function is used to open a raw socket to capture from */ -int ctdb_sys_open_capture_socket(void) +int ctdb_sys_open_capture_socket(const char *iface, void **private_data) { int s; @@ -276,6 +276,16 @@ int ctdb_sys_open_capture_socket(void) return s; } +/* + This function is used to do any additional cleanup required when closing + a capture socket. + Note that the socket itself is closed automatically in the caller. + */ +int ctdb_sys_close_capture_socket(void *private_data) +{ + return 0; +} + /* This function is used to open a raw socket to send tickles from */ @@ -308,8 +318,9 @@ int ctdb_sys_open_sending_socket(void) /* called when the raw socket becomes readable */ -int ctdb_sys_read_tcp_packet(int s, struct sockaddr_in *src, struct sockaddr_in *dst, - uint32_t *ack_seq, uint32_t *seq) +int ctdb_sys_read_tcp_packet(int s, void *private_data, + struct sockaddr_in *src, struct sockaddr_in *dst, + uint32_t *ack_seq, uint32_t *seq) { int ret; #define RCVPKTSIZE 100 diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index 9c33747dcd6..58a14613739 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -1044,9 +1044,10 @@ void ctdb_start_freeze(struct ctdb_context *ctdb); bool parse_ip_port(const char *s, struct sockaddr_in *ip); -int ctdb_sys_open_capture_socket(void); +int ctdb_sys_open_capture_socket(const char *iface, void **private_data); +int ctdb_sys_close_capture_socket(void *private_data); int ctdb_sys_open_sending_socket(void); -int ctdb_sys_read_tcp_packet(int s, struct sockaddr_in *src, struct sockaddr_in *dst, +int ctdb_sys_read_tcp_packet(int s, void *private_data, struct sockaddr_in *src, struct sockaddr_in *dst, uint32_t *ack_seq, uint32_t *seq); int ctdb_ctrl_killtcp(struct ctdb_context *ctdb, diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c index a4536e1c9dc..0bd8034674e 100644 --- a/ctdb/server/ctdb_takeover.c +++ b/ctdb/server/ctdb_takeover.c @@ -856,6 +856,7 @@ struct ctdb_kill_tcp { int sending_fd; struct fd_event *fde; struct ctdb_killtcp_connection *connections; + void *private_data; }; /* @@ -873,8 +874,10 @@ static void capture_tcp_handler(struct event_context *ev, struct fd_event *fde, return; } - if (ctdb_sys_read_tcp_packet(killtcp->capture_fd, &src, &dst, - &ack_seq, &seq) != 0) { + if (ctdb_sys_read_tcp_packet(killtcp->capture_fd, + killtcp->private_data, + &src, &dst, + &ack_seq, &seq) != 0) { /* probably a non-tcp ACK packet */ return; } @@ -1011,7 +1014,7 @@ static int ctdb_killtcp_add_connection(struct ctdb_context *ctdb, If we dont have a socket to listen on yet we must create it */ if (killtcp->capture_fd == -1) { - killtcp->capture_fd = ctdb_sys_open_capture_socket(); + killtcp->capture_fd = ctdb_sys_open_capture_socket(ctdb->takeover.interface, &killtcp->private_data); if (killtcp->capture_fd == -1) { DEBUG(0,(__location__ " Failed to open capturing socket for killtcp\n")); goto failed;