ctdbd_conn: Accept msgs to all registered srvids
authorVolker Lendecke <vl@samba.org>
Fri, 21 Nov 2014 15:20:10 +0000 (16:20 +0100)
committerJeremy Allison <jra@samba.org>
Sat, 6 Dec 2014 23:12:07 +0000 (00:12 +0100)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/lib/ctdbd_conn.c

index a26f41023685509fd85bedaaa6c72c89dea3fe59..5dc007bf5cba7ac77ebcb90a5fe922e6de4cb812 100644 (file)
@@ -54,6 +54,7 @@ struct ctdbd_connection {
        uint32_t reqid;
        uint32_t our_vnn;
        uint64_t rand_srvid;
+       uint64_t *srvids;
        int fd;
        struct tevent_fd *fde;
 
@@ -109,10 +110,43 @@ static void ctdb_packet_dump(struct ctdb_req_header *hdr)
 NTSTATUS register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid)
 {
 
+       NTSTATUS status;
        int cstatus;
-       return ctdbd_control(conn, CTDB_CURRENT_NODE,
-                            CTDB_CONTROL_REGISTER_SRVID, srvid, 0,
-                            tdb_null, NULL, NULL, &cstatus);
+       size_t num_srvids;
+       uint64_t *tmp;
+
+       status = ctdbd_control(conn, CTDB_CURRENT_NODE,
+                              CTDB_CONTROL_REGISTER_SRVID, srvid, 0,
+                              tdb_null, NULL, NULL, &cstatus);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+
+       num_srvids = talloc_array_length(conn->srvids);
+
+       tmp = talloc_realloc(conn, conn->srvids, uint64_t,
+                            num_srvids + 1);
+       if (tmp == NULL) {
+               return NT_STATUS_NO_MEMORY;
+       }
+       conn->srvids = tmp;
+
+       conn->srvids[num_srvids] = srvid;
+       return NT_STATUS_OK;
+}
+
+static bool ctdb_is_our_srvid(struct ctdbd_connection *conn, uint64_t srvid)
+{
+       size_t i, num_srvids;
+
+       num_srvids = talloc_array_length(conn->srvids);
+
+       for (i=0; i<num_srvids; i++) {
+               if (srvid == conn->srvids[i]) {
+                       return true;
+               }
+       }
+       return false;
 }
 
 /*
@@ -661,8 +695,7 @@ static NTSTATUS ctdb_handle_message(struct messaging_context *msg_ctx,
                return NT_STATUS_OK;
        }
 
-       /* only messages to our pid or the broadcast are valid here */
-       if (msg->srvid != getpid() && msg->srvid != MSG_SRVID_SAMBA) {
+       if (!ctdb_is_our_srvid(conn, msg->srvid)) {
                DEBUG(0,("Got unexpected message with srvid=%llu\n", 
                         (unsigned long long)msg->srvid));
                return NT_STATUS_OK;