]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
add a --single-public-ip argument to ctdbd to specify the ip address
authorRonnie Sahlberg <sahlberg@ronnie>
Tue, 9 Oct 2007 23:42:32 +0000 (09:42 +1000)
committerRonnie Sahlberg <sahlberg@ronnie>
Tue, 9 Oct 2007 23:42:32 +0000 (09:42 +1000)
used in single public ip address mode.
when using this argument, --public-interface must also be used.

add a vnn structure to the ctdb context to describe the single public ip
address

update the killtcp control in the daemon that if a socketpair that is to
be killed does not match a normal public address it checks if the
destination address maches the single public ip address and if so uses
that vnn structure from the ctdb context

this allows killtcp to kill also connections to the single public ip
instead of only normal public addresses

(This used to be ctdb commit 5661ba17b91f62821dec1c76056c78b99752a90b)

ctdb/config/ctdb.init
ctdb/config/ctdb.sysconfig
ctdb/include/ctdb_private.h
ctdb/server/ctdb_takeover.c
ctdb/server/ctdbd.c

index 503c267407de208d75f5d4320b9abcc90a96eb00..724c1a8d1384d4fbd346eac72582e05886c06ef7 100755 (executable)
@@ -57,6 +57,7 @@ CTDB_OPTIONS="$CTDB_OPTIONS --reclock=$CTDB_RECOVERY_LOCK"
 [ -z "$CTDB_SOCKET" ]           || CTDB_OPTIONS="$CTDB_OPTIONS --socket=$CTDB_SOCKET"
 [ -z "$CTDB_PUBLIC_ADDRESSES" ] || CTDB_OPTIONS="$CTDB_OPTIONS --public-addresses=$CTDB_PUBLIC_ADDRESSES"
 [ -z "$CTDB_PUBLIC_INTERFACE" ] || CTDB_OPTIONS="$CTDB_OPTIONS --public-interface=$CTDB_PUBLIC_INTERFACE"
+[ -z "$CTDB_SINGLE_PUBLIC_IP" ] || CTDB_OPTIONS="$CTDB_OPTIONS --single-public-ip=$CTDB_SINGLE_PUBLIC_IP"
 [ -z "$CTDB_DBDIR" ]            || CTDB_OPTIONS="$CTDB_OPTIONS --dbdir=$CTDB_DBDIR"
 [ -z "$CTDB_DBDIR_PERSISTENT" ] || CTDB_OPTIONS="$CTDB_OPTIONS --dbdir-persistent=$CTDB_DBDIR_PERSISTENT"
 [ -z "$CTDB_EVENT_SCRIPT_DIR" ] || CTDB_OPTIONS="$CTDB_OPTIONS --event-script-dir $CTDB_EVENT_SCRIPT_DIR"
index c4b192bec51051dc6347acdddcc1c03fb765fd8b..d290321b99b0553b4bf25ee1af6d0adbb85d52e8 100644 (file)
 #
 # CTDB_PUBLIC_ADDRESSES=/etc/ctdb/public_addresses
 
+# Should ctdb implement a single public ip address across the entire cluster
+# and multiplex incoming connections across the connected nodes
+# When using a single public ip you must also specify the public interface!
+# This makes all incoming traffic go through a single ctdb node which
+# will then forward the packets out acros the other nodes. This will 
+# impact performance.
+# CTDB_SINGLE_PUBLIC_IP=10.1.1.1
+
 # should ctdb manage starting/stopping the Samba service for you?
 # default is to not manage Samba
 # CTDB_MANAGES_SAMBA=yes
index 983871006aff1ba3a7a3800f5bf259e43f094699..5a82988a0b7db852b86eda171bc997abce420727 100644 (file)
@@ -343,6 +343,7 @@ struct ctdb_context {
        uint16_t idr_cnt;
        struct ctdb_node **nodes; /* array of nodes in the cluster - indexed by vnn */
        struct ctdb_vnn *vnn; /* list of public ip addresses and interfaces */
+       struct ctdb_vnn *single_ip_vnn; /* a structure for the single ip */
        char *err_msg;
        const struct ctdb_methods *methods; /* transport methods */
        const struct ctdb_upcalls *upcalls; /* transport upcalls */
index c30e6c57bcb1c09144b6c43246bf9dc5cfeee790..9986714a17be4b85f129327607b74608e39b4e90 100644 (file)
@@ -1356,6 +1356,14 @@ static int ctdb_killtcp_add_connection(struct ctdb_context *ctdb,
        if (vnn == NULL) {
                vnn = find_public_ip_vnn(ctdb, *src);
        }
+       if (vnn == NULL) {
+               /* if it is not a public ip   it could be our 'single ip' */
+               if (ctdb->single_ip_vnn) {
+                       if (ctdb_same_ip(&ctdb->single_ip_vnn->public_address, dst)) {
+                               vnn = ctdb->single_ip_vnn;
+                       }
+               }
+       }
        if (vnn == NULL) {
                DEBUG(0,(__location__ " Could not killtcp, not a public address\n")); 
                return -1;
index 6ba76ffc953cb4148b746377d3a5aa63f92d2731..55b87418f973e2f1877ad6b62d76a65a5a56da5c 100644 (file)
@@ -48,6 +48,7 @@ static struct {
        const char *db_dir;
        const char *db_dir_persistent;
        const char *public_interface;
+       const char *single_public_ip;
        int         no_setsched;
 } options = {
        .nlist = ETCDIR "/ctdb/nodes",
@@ -104,6 +105,7 @@ int main(int argc, const char *argv[])
                { "interactive", 'i', POPT_ARG_NONE, &interactive, 0, "don't fork", NULL },
                { "public-addresses", 0, POPT_ARG_STRING, &options.public_address_list, 0, "public address list file", "filename" },
                { "public-interface", 0, POPT_ARG_STRING, &options.public_interface, 0, "public interface", "interface"},
+               { "single-public-ip", 0, POPT_ARG_STRING, &options.single_public_ip, 0, "single public ip", "ip-address"},
                { "event-script-dir", 0, POPT_ARG_STRING, &options.event_script_dir, 0, "event script directory", "dirname" },
                { "logfile", 0, POPT_ARG_STRING, &options.logfile, 0, "log file location", "filename" },
                { "nlist", 0, POPT_ARG_STRING, &options.nlist, 0, "node list file", "filename" },
@@ -215,6 +217,30 @@ int main(int argc, const char *argv[])
                CTDB_NO_MEMORY(ctdb, ctdb->default_public_interface);
        }
 
+       if (options.single_public_ip) {
+               struct ctdb_vnn *svnn;
+
+               if (options.public_interface == NULL) {
+                       DEBUG(0,("--single_public_ip used but --public_interface is not specified. You must specify the public interface when using single public ip. Exiting\n"));
+                       exit(10);
+               }
+
+               svnn = talloc_zero(ctdb, struct ctdb_vnn);
+               CTDB_NO_MEMORY(ctdb, svnn);
+
+               ctdb->single_ip_vnn = svnn;
+               svnn->iface = talloc_strdup(svnn, options.public_interface);
+               CTDB_NO_MEMORY(ctdb, svnn->iface);
+
+               if (inet_aton(options.single_public_ip, 
+                               &svnn->public_address.sin_addr) == 0) {
+                       DEBUG(0,("Invalid --single-public-ip argument : %s . This is not a valid ip address. Exiting.\n", options.single_public_ip));
+                       exit(10);
+               }
+               svnn->public_address.sin_family = AF_INET;
+               svnn->public_address.sin_port   = 0;
+       }
+
        if (options.public_address_list) {
                ret = ctdb_set_public_addresses(ctdb, options.public_address_list);
                if (ret == -1) {