]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
we cant have takeover_ctx hanging off ctdb since it is freed/recreated
authorRonnie Sahlberg <sahlberg@ronnie>
Tue, 4 Sep 2007 04:36:52 +0000 (14:36 +1000)
committerRonnie Sahlberg <sahlberg@ronnie>
Tue, 4 Sep 2007 04:36:52 +0000 (14:36 +1000)
everytime we release an ip.
this context is used to hold all resources needed when sending out
gratious arps and tcp tickles during ip takeover.

we hang it off the vnn structure that manages that particular ip address
instead   so that we can have multiple ones going in parallell

this bug (or the same bug in different shape) has probably been in ctdb
for very very long   but is likely to be hard to trigger

(This used to be ctdb commit c58db1cadaba253b2659573673b28c235ef7db76)

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

index 23d8d9d320e7e09280feeb689b36249ff23e0047..fd366d8ce578ccbf3515bc7b43727c8011a4b0ef 100644 (file)
@@ -155,6 +155,9 @@ struct ctdb_vnn {
        /* whether we need to update the other nodes with changes to our list
           of connected clients */
        bool tcp_update_needed;
+
+       /* a context to hang sending gratious arp events off */
+       TALLOC_CTX *takeover_ctx;
 };
 
 struct ctdb_vnn_list {
@@ -356,7 +359,6 @@ struct ctdb_context {
        void *saved_scheduler_param;
        struct _trbt_tree_t *server_ids;        
        const char *event_script_dir;
-       TALLOC_CTX *takeover_ctx;
 };
 
 struct ctdb_db_context {
index 40dd4f6076ce2ad20d9388ead9ff537bbc7f4f5c..b0793bc4fc3583b2172dc19c359b63f920d32c82 100644 (file)
@@ -1,5 +1,5 @@
 /* 
-   ctdb recovery code
+   ctdb ip takeover code
 
    Copyright (C) Ronnie Sahlberg  2007
    Copyright (C) Andrew Tridgell  2007
@@ -108,7 +108,7 @@ static void ctdb_control_send_arp(struct event_context *ev, struct timed_event *
                return;
        }
 
-       event_add_timed(arp->ctdb->ev, arp->ctdb->takeover_ctx, 
+       event_add_timed(arp->ctdb->ev, arp->vnn->takeover_ctx, 
                        timeval_current_ofs(CTDB_ARP_INTERVAL, 0), 
                        ctdb_control_send_arp, arp);
 }
@@ -141,12 +141,14 @@ static void takeover_ip_callback(struct ctdb_context *ctdb, int status,
                return;
        }
 
-       if (!ctdb->takeover_ctx) {
-               ctdb->takeover_ctx = talloc_new(ctdb);
-               if (!ctdb->takeover_ctx) goto failed;
+       if (!state->vnn->takeover_ctx) {
+               state->vnn->takeover_ctx = talloc_new(ctdb);
+               if (!state->vnn->takeover_ctx) {
+                       goto failed;
+               }
        }
 
-       arp = talloc_zero(ctdb->takeover_ctx, struct ctdb_takeover_arp);
+       arp = talloc_zero(state->vnn->takeover_ctx, struct ctdb_takeover_arp);
        if (!arp) goto failed;
        
        arp->ctdb = ctdb;
@@ -163,7 +165,7 @@ static void takeover_ip_callback(struct ctdb_context *ctdb, int status,
                state->vnn->tcp_update_needed = true;
        }
 
-       event_add_timed(arp->ctdb->ev, arp->ctdb->takeover_ctx, 
+       event_add_timed(arp->ctdb->ev, state->vnn->takeover_ctx, 
                        timeval_zero(), ctdb_control_send_arp, arp);
 
        /* the control succeeded */
@@ -335,6 +337,9 @@ int32_t ctdb_control_release_ip(struct ctdb_context *ctdb,
        vnn->pnn = pip->pnn;
 
        if (!ctdb_sys_have_ip(ip)) {
+               DEBUG(0,("Redundant release of IP %s/%u on interface %s (ip not held)\n", 
+                        ip, vnn->public_netmask_bits, 
+                        vnn->vnn_list->iface));
                return 0;
        }
 
@@ -343,8 +348,8 @@ int32_t ctdb_control_release_ip(struct ctdb_context *ctdb,
                 vnn->vnn_list->iface));
 
        /* stop any previous arps */
-       talloc_free(ctdb->takeover_ctx);
-       ctdb->takeover_ctx = NULL;
+       talloc_free(vnn->takeover_ctx);
+       vnn->takeover_ctx = NULL;
 
        state = talloc(ctdb, struct takeover_callback_state);
        CTDB_NO_MEMORY(ctdb, state);