]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
add a private_data field to the killtcp structure and let the system
authorRonnie Sahlberg <sahlberg@ronnie>
Fri, 13 Jul 2007 07:07:10 +0000 (17:07 +1000)
committerRonnie Sahlberg <sahlberg@ronnie>
Fri, 13 Jul 2007 07:07:10 +0000 (17:07 +1000)
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)

ctdb/common/system.c
ctdb/include/ctdb_private.h
ctdb/server/ctdb_takeover.c

index f4f12a168ba91e78e8680ee7433ddc09391a7386..8eebb3933dff296e18dcd043abcfc2331e879d65 100644 (file)
@@ -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
index 9c33747dcd6710b469c2fa13f24071444f008f02..58a146137397c679221a5f93b0d342bf27cf86bb 100644 (file)
@@ -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, 
index a4536e1c9dc53cace23c0a7c7528115c7d3bd8b0..0bd8034674e1e3c2f114477ddb4c1068c1239266 100644 (file)
@@ -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;