]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
change the takoverip/releaseip controls to pass a structure containing
authorRonnie Sahlberg <sahlberg@ronnie>
Mon, 4 Jun 2007 10:07:37 +0000 (20:07 +1000)
committerRonnie Sahlberg <sahlberg@ronnie>
Mon, 4 Jun 2007 10:07:37 +0000 (20:07 +1000)
both the nodenumber and the id of the node that has taken over that
address in addition to the public address itself    so that all nodes
can learn which node is currently hosting each of the public addresses

(This used to be ctdb commit 53e9ff790387b85a36fa9c3c44cd4c95cbdf35da)

ctdb/common/ctdb_client.c
ctdb/common/ctdb_control.c
ctdb/include/ctdb_private.h
ctdb/takeover/ctdb_takeover.c

index 154ce86129c23265ad2f3792c05ddb8b8d72861e..0f3396dda431e7ea178b2388228041a3709f51e1 100644 (file)
@@ -1825,23 +1825,14 @@ int ctdb_ctrl_delete_low_rsn(struct ctdb_context *ctdb, struct timeval timeout,
   sent to a node to make it take over an ip address
 */
 int ctdb_ctrl_takeover_ip(struct ctdb_context *ctdb, struct timeval timeout, 
-                         uint32_t destnode, const char *ip)
+                         uint32_t destnode, struct ctdb_public_ip *ip)
 {
        TDB_DATA data;
        int ret;
        int32_t res;
-       struct sockaddr sa;
-       struct sockaddr_in *sin = (struct sockaddr_in *)&sa;
 
-       ZERO_STRUCT(sa);
-#ifdef HAVE_SOCK_SIN_LEN
-       sin->sin_len = sizeof(*sin);
-#endif
-       sin->sin_family = AF_INET;
-       inet_aton(ip, &sin->sin_addr);
-
-       data.dsize = sizeof(sa);
-       data.dptr  = (uint8_t *)&sa;
+       data.dsize = sizeof(*ip);
+       data.dptr  = (uint8_t *)ip;
 
        ret = ctdb_control(ctdb, destnode, 0, CTDB_CONTROL_TAKEOVER_IP, 0, data, NULL,
                           NULL, &res, &timeout, NULL);
@@ -1859,23 +1850,14 @@ int ctdb_ctrl_takeover_ip(struct ctdb_context *ctdb, struct timeval timeout,
   sent to a node to make it release an ip address
 */
 int ctdb_ctrl_release_ip(struct ctdb_context *ctdb, struct timeval timeout, 
-                        uint32_t destnode, const char *ip)
+                        uint32_t destnode, struct ctdb_public_ip *ip)
 {
        TDB_DATA data;
        int ret;
        int32_t res;
-       struct sockaddr sa;
-       struct sockaddr_in *sin = (struct sockaddr_in *)&sa;
-
-       ZERO_STRUCT(sa);
-#ifdef HAVE_SOCK_SIN_LEN
-       sin->sin_len = sizeof(*sin);
-#endif
-       sin->sin_family = AF_INET;
-       inet_aton(ip, &sin->sin_addr);
-
-       data.dsize = sizeof(sa);
-       data.dptr  = (uint8_t *)&sa;
+
+       data.dsize = sizeof(*ip);
+       data.dptr  = (uint8_t *)ip;
 
        ret = ctdb_control(ctdb, destnode, 0, CTDB_CONTROL_RELEASE_IP, 0, data, NULL,
                           NULL, &res, &timeout, NULL);
index f73672796e6de4a8e2708c7314b432cf18a28e78..2cd3ac57a7b6cab810231f0e24bf6c0c555f7b45 100644 (file)
@@ -265,11 +265,11 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
                return ctdb_control_set_rsn_nonempty(ctdb, indata, outdata);
 
        case CTDB_CONTROL_TAKEOVER_IP:
-               CHECK_CONTROL_DATA_SIZE(sizeof(struct sockaddr));
+               CHECK_CONTROL_DATA_SIZE(sizeof(struct ctdb_public_ip));
                return ctdb_control_takeover_ip(ctdb, c, indata, async_reply);
 
        case CTDB_CONTROL_RELEASE_IP:
-               CHECK_CONTROL_DATA_SIZE(sizeof(struct sockaddr));
+               CHECK_CONTROL_DATA_SIZE(sizeof(struct ctdb_public_ip));
                return ctdb_control_release_ip(ctdb, c, indata, async_reply);
 
        case CTDB_CONTROL_DELETE_LOW_RSN: 
index 9f0224288f29cbf9566006a98368f70c79b87fe0..86bee8b4bccf06ec26c47e93e8edbfc634940546 100644 (file)
@@ -942,14 +942,20 @@ int32_t ctdb_control_takeover_ip(struct ctdb_context *ctdb,
                                 struct ctdb_req_control *c,
                                 TDB_DATA indata, 
                                 bool *async_reply);
-int ctdb_ctrl_takeover_ip(struct ctdb_context *ctdb, struct timeval timeout, 
-                         uint32_t destnode, const char *ip);
 int32_t ctdb_control_release_ip(struct ctdb_context *ctdb, 
                                 struct ctdb_req_control *c,
                                 TDB_DATA indata, 
                                 bool *async_reply);
+
+struct ctdb_public_ip {
+       uint32_t vnn;
+       uint32_t takeover_vnn;
+       struct sockaddr_in sin;
+};
+int ctdb_ctrl_takeover_ip(struct ctdb_context *ctdb, struct timeval timeout, 
+                         uint32_t destnode, struct ctdb_public_ip *ip);
 int ctdb_ctrl_release_ip(struct ctdb_context *ctdb, struct timeval timeout, 
-                        uint32_t destnode, const char *ip);
+                        uint32_t destnode, struct ctdb_public_ip *ip);
 
 /* from takeover/system.c */
 int ctdb_sys_send_arp(const struct sockaddr_in *saddr, const char *iface);
index af250f570bc425a2eed46603fe0f988e2d855ecc..d4c51dcd5e0e92bf78877fa8809061cd5864b915 100644 (file)
@@ -162,8 +162,12 @@ int32_t ctdb_control_takeover_ip(struct ctdb_context *ctdb,
 {
        int ret;
        struct takeover_callback_state *state;
-       struct sockaddr_in *sin = (struct sockaddr_in *)indata.dptr;
-       char *ip = inet_ntoa(sin->sin_addr);
+       struct ctdb_public_ip *pip = (struct ctdb_public_ip *)indata.dptr;
+       char *ip = inet_ntoa(pip->sin.sin_addr);
+
+
+       /* update out node table */
+       ctdb->nodes[pip->vnn]->takeover_vnn = pip->takeover_vnn;
 
        /* if our kernel already has this IP, do nothing */
        if (ctdb_sys_have_ip(ip)) {
@@ -256,8 +260,11 @@ int32_t ctdb_control_release_ip(struct ctdb_context *ctdb,
 {
        int ret;
        struct takeover_callback_state *state;
-       struct sockaddr_in *sin = (struct sockaddr_in *)indata.dptr;
-       char *ip = inet_ntoa(sin->sin_addr);
+       struct ctdb_public_ip *pip = (struct ctdb_public_ip *)indata.dptr;
+       char *ip = inet_ntoa(pip->sin.sin_addr);
+
+       /* update out node table */
+       ctdb->nodes[pip->vnn]->takeover_vnn = pip->takeover_vnn;
 
        if (!ctdb_sys_have_ip(ip)) {
                return 0;
@@ -392,6 +399,7 @@ int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap)
 {
        int i, j;
        int ret;
+       struct ctdb_public_ip ip;
 
        /* work out which node will look after each public IP */
        for (i=0;i<nodemap->num;i++) {
@@ -431,9 +439,17 @@ int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap)
                /* tell this node to delete all of the aliases that it should not have */
                for (j=0;j<nodemap->num;j++) {
                        if (ctdb->nodes[j]->takeover_vnn != nodemap->nodes[i].vnn) {
+                               ip.vnn = j;
+                               ip.takeover_vnn = ctdb->nodes[j]->takeover_vnn;
+#ifdef HAVE_SOCK_SIN_LEN
+                               ip.sin.sin_len = sizeof(*sin);
+#endif
+                               ip.sin.sin_family = AF_INET;
+                               inet_aton(ctdb->nodes[j]->public_address, &ip.sin.sin_addr);
+
                                ret = ctdb_ctrl_release_ip(ctdb, TAKEOVER_TIMEOUT(),
                                                           nodemap->nodes[i].vnn, 
-                                                          ctdb->nodes[j]->public_address);
+                                                          &ip);
                                if (ret != 0) {
                                        DEBUG(0,("Failed to tell vnn %u to release IP %s\n",
                                                 nodemap->nodes[i].vnn,
@@ -450,9 +466,17 @@ int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap)
                        /* this IP won't be taken over */
                        continue;
                }
+               ip.vnn = i;
+               ip.takeover_vnn = ctdb->nodes[i]->takeover_vnn;
+#ifdef HAVE_SOCK_SIN_LEN
+               ip.sin.sin_len = sizeof(*sin);
+#endif
+               ip.sin.sin_family = AF_INET;
+               inet_aton(ctdb->nodes[i]->public_address, &ip.sin.sin_addr);
+
                ret = ctdb_ctrl_takeover_ip(ctdb, TAKEOVER_TIMEOUT(), 
                                            ctdb->nodes[i]->takeover_vnn, 
-                                           ctdb->nodes[i]->public_address);
+                                           &ip);
                if (ret != 0) {
                        DEBUG(0,("Failed asking vnn %u to take over IP %s\n",
                                 ctdb->nodes[i]->takeover_vnn,