s3: Add "smbcontrol winbindd ip-dropped <local-ip>"
authorVolker Lendecke <vl@samba.org>
Wed, 29 Sep 2010 10:17:05 +0000 (12:17 +0200)
committerMichael Adam <obnox@samba.org>
Thu, 30 Sep 2010 10:30:46 +0000 (12:30 +0200)
This is supposed to improve the winbind reconnect time after an ip address
has been moved away from a box. Any kind of HA scenario will benefit from
this, because winbindd does not have to wait for the TCP timeout to kick in
when a local IP address has been dropped and DC replies are not received
anymore.

source3/librpc/gen_ndr/messaging.h
source3/librpc/gen_ndr/ndr_messaging.c
source3/librpc/idl/messaging.idl
source3/utils/smbcontrol.c
source3/winbindd/winbindd.c
source3/winbindd/winbindd_cm.c
source3/winbindd/winbindd_dual.c
source3/winbindd/winbindd_proto.h

index 913201345a4b6ebb9f5c5bc7a3eff08c8f7a4f2c..bfb32429540fcee39f6b18acf0948475c1912b7c 100644 (file)
@@ -61,6 +61,7 @@ enum messaging_type
        MSG_WINBIND_FAILED_TO_GO_ONLINE=0x0407,
        MSG_WINBIND_VALIDATE_CACHE=0x0408,
        MSG_WINBIND_DUMP_DOMAIN_LIST=0x0409,
+       MSG_WINBIND_IP_DROPPED=0x040A,
        MSG_DUMP_EVENT_LIST=0x0500,
        MSG_DBWRAP_TDB2_CHANGES=4001,
        MSG_DBWRAP_G_LOCK_RETRY=4002
@@ -117,6 +118,7 @@ enum messaging_type
 #define MSG_WINBIND_FAILED_TO_GO_ONLINE ( 0x0407 )
 #define MSG_WINBIND_VALIDATE_CACHE ( 0x0408 )
 #define MSG_WINBIND_DUMP_DOMAIN_LIST ( 0x0409 )
+#define MSG_WINBIND_IP_DROPPED ( 0x040A )
 #define MSG_DUMP_EVENT_LIST ( 0x0500 )
 #define MSG_DBWRAP_TDB2_CHANGES ( 4001 )
 #define MSG_DBWRAP_G_LOCK_RETRY ( 4002 )
index 02ff382197c6147cfa5b1182728bf435291d6536..6f84caf1260d4f9117db394cd0513c896e917260 100644 (file)
@@ -72,6 +72,7 @@ _PUBLIC_ void ndr_print_messaging_type(struct ndr_print *ndr, const char *name,
                case MSG_WINBIND_FAILED_TO_GO_ONLINE: val = "MSG_WINBIND_FAILED_TO_GO_ONLINE"; break;
                case MSG_WINBIND_VALIDATE_CACHE: val = "MSG_WINBIND_VALIDATE_CACHE"; break;
                case MSG_WINBIND_DUMP_DOMAIN_LIST: val = "MSG_WINBIND_DUMP_DOMAIN_LIST"; break;
+               case MSG_WINBIND_IP_DROPPED: val = "MSG_WINBIND_IP_DROPPED"; break;
                case MSG_DUMP_EVENT_LIST: val = "MSG_DUMP_EVENT_LIST"; break;
                case MSG_DBWRAP_TDB2_CHANGES: val = "MSG_DBWRAP_TDB2_CHANGES"; break;
                case MSG_DBWRAP_G_LOCK_RETRY: val = "MSG_DBWRAP_G_LOCK_RETRY"; break;
index 08caa5950888b2d99510708432edb431212274b7..9041d2284d15568fb3ba09df08e7e39d44c25a67 100644 (file)
@@ -83,6 +83,7 @@ interface messaging
                MSG_WINBIND_FAILED_TO_GO_ONLINE = 0x0407,
                MSG_WINBIND_VALIDATE_CACHE      = 0x0408,
                MSG_WINBIND_DUMP_DOMAIN_LIST    = 0x0409,
+               MSG_WINBIND_IP_DROPPED          = 0x040A,
 
                /* event messages */
                MSG_DUMP_EVENT_LIST             = 0x0500,
index 1c2bb5003de08243fb3d0f703073393815208b84..b27b8cb5610a095cca78d159bef5c67dfef1f846 100644 (file)
@@ -714,6 +714,22 @@ static bool do_closeshare(struct messaging_context *msg_ctx,
                            strlen(argv[1]) + 1);
 }
 
+/* Tell winbindd an IP got dropped */
+
+static bool do_ip_dropped(struct messaging_context *msg_ctx,
+                         const struct server_id pid,
+                         const int argc, const char **argv)
+{
+       if (argc != 2) {
+               fprintf(stderr, "Usage: smbcontrol <dest> ip-dropped "
+                       "<ip-address>\n");
+               return False;
+       }
+
+       return send_message(msg_ctx, pid, MSG_WINBIND_IP_DROPPED, argv[1],
+                           strlen(argv[1]) + 1);
+}
+
 /* force a blocking lock retry */
 
 static bool do_lockretry(struct messaging_context *msg_ctx,
@@ -1181,6 +1197,7 @@ static const struct {
        { "debuglevel", do_debuglevel, "Display current debuglevels" },
        { "printnotify", do_printnotify, "Send a print notify message" },
        { "close-share", do_closeshare, "Forcibly disconnect a share" },
+       { "ip-dropped", do_ip_dropped, "Tell winbind that an IP got dropped" },
        { "lockretry", do_lockretry, "Force a blocking lock retry" },
        { "brl-revalidate", do_brl_revalidate, "Revalidate all brl entries" },
         { "samsync", do_samsync, "Initiate SAM synchronisation" },
index fbaa10c5c49afde071e5206a95eefc6cb10c6d73..ee40187fd29ebab640d7dc2dcd98586d68923f7e 100644 (file)
@@ -1376,6 +1376,10 @@ int main(int argc, char **argv, char **envp)
                           MSG_WINBIND_DUMP_DOMAIN_LIST,
                           winbind_msg_dump_domain_list);
 
+       messaging_register(winbind_messaging_context(), NULL,
+                          MSG_WINBIND_IP_DROPPED,
+                          winbind_msg_ip_dropped_parent);
+
        /* Register handler for MSG_DEBUG. */
        messaging_register(winbind_messaging_context(), NULL,
                           MSG_DEBUG,
index e3a0b59934451fca09dd19b1d100e19b725ee742..ece68f1a1d3f55f0fbf16649792883e83ce2d8d9 100644 (file)
@@ -2485,3 +2485,56 @@ NTSTATUS cm_connect_netlogon(struct winbindd_domain *domain,
        *cli = conn->netlogon_pipe;
        return NT_STATUS_OK;
 }
+
+void winbind_msg_ip_dropped(struct messaging_context *msg_ctx,
+                           void *private_data,
+                           uint32_t msg_type,
+                           struct server_id server_id,
+                           DATA_BLOB *data)
+{
+       struct winbindd_domain *domain;
+
+       if ((data == NULL)
+           || (data->data == NULL)
+           || (data->length == 0)
+           || (data->data[data->length-1] != '\0')
+           || !is_ipaddress((char *)data->data)) {
+               DEBUG(1, ("invalid msg_ip_dropped message\n"));
+               return;
+       }
+       for (domain = domain_list(); domain != NULL; domain = domain->next) {
+               char sockaddr[INET6_ADDRSTRLEN];
+               if (domain->conn.cli == NULL) {
+                       continue;
+               }
+               if (domain->conn.cli->fd == -1) {
+                       continue;
+               }
+               client_socket_addr(domain->conn.cli->fd, sockaddr,
+                                  sizeof(sockaddr));
+               if (strequal(sockaddr, (char *)data->data)) {
+                       close(domain->conn.cli->fd);
+                       domain->conn.cli->fd = -1;
+               }
+       }
+}
+
+extern struct winbindd_child *children;
+
+void winbind_msg_ip_dropped_parent(struct messaging_context *msg_ctx,
+                                  void *private_data,
+                                  uint32_t msg_type,
+                                  struct server_id server_id,
+                                  DATA_BLOB *data)
+{
+       struct winbindd_child *child;
+
+       winbind_msg_ip_dropped(msg_ctx, private_data, msg_type,
+                              server_id, data);
+
+
+       for (child = children; child != NULL; child = child->next) {
+               messaging_send_buf(msg_ctx, pid_to_procid(child->pid),
+                                  msg_type, data->data, data->length);
+       }
+}
index a5ba9e0116cf6e6a6ac1b56522cd4ad0b5ba7532..efe15138bb936369ed8ea1b26bcc9e9918202b09 100644 (file)
@@ -1390,6 +1390,10 @@ static bool fork_domain_child(struct winbindd_child *child)
                           MSG_DUMP_EVENT_LIST, child_msg_dump_event_list);
        messaging_register(winbind_messaging_context(), NULL,
                           MSG_DEBUG, debug_message);
+       messaging_register(winbind_messaging_context(), NULL,
+                          MSG_WINBIND_IP_DROPPED,
+                          winbind_msg_ip_dropped);
+
 
        primary_domain = find_our_domain();
 
index d9421ecbf971f81b7f4382b74039d77f0f7272c9..d666639420b5bd0fc508da067e236d7d67373a2b 100644 (file)
@@ -342,6 +342,16 @@ void winbind_msg_dump_domain_list(struct messaging_context *msg_ctx,
                                  uint32_t msg_type,
                                  struct server_id server_id,
                                  DATA_BLOB *data);
+void winbind_msg_ip_dropped(struct messaging_context *msg_ctx,
+                           void *private_data,
+                           uint32_t msg_type,
+                           struct server_id server_id,
+                           DATA_BLOB *data);
+void winbind_msg_ip_dropped_parent(struct messaging_context *msg_ctx,
+                                  void *private_data,
+                                  uint32_t msg_type,
+                                  struct server_id server_id,
+                                  DATA_BLOB *data);
 bool winbindd_reinit_after_fork(const char *logfilename);
 
 /* The following definitions come from winbindd/winbindd_group.c  */