1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-02 09:47:23 +03:00

add a --single-public-ip argument to ctdbd to specify the ip address

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)
This commit is contained in:
Ronnie Sahlberg 2007-10-10 09:42:32 +10:00
parent 7735957693
commit bdd67bba1e
5 changed files with 44 additions and 0 deletions

View File

@ -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"

View File

@ -21,6 +21,14 @@
#
# 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

View 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 */

View 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;

View 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) {