From: fendo Date: Fri, 26 May 2017 22:09:19 +0000 (+0200) Subject: Add cluster_port parameter for Multiple clusters X-Git-Tag: 2.2.1.2fdn3.20 X-Git-Url: http://git.sameswireless.fr/l2tpns.git/commitdiff_plain/0f20bfda6a2b5c756eeaa235b2eb48d4e4072bd0 Add cluster_port parameter for Multiple clusters --- diff --git a/Docs/manual.html b/Docs/manual.html index 68b3759..060c470 100644 --- a/Docs/manual.html +++ b/Docs/manual.html @@ -345,6 +345,11 @@ Multicast cluster address (default: 239.192.13.13). See the section on Clustering for more information. +
  • cluster_port (int udp port)
    +UDP cluster port (default: 32792). See the section on +Clustering for more information. +
  • +
  • cluster_interface (string)
    Interface for cluster packets (default: eth0).
  • @@ -1150,6 +1155,13 @@ A master, when determining that it has at least one up-to-date slave will drop all routes (raising them again if all slaves disappear) and subsequently handle only packets forwarded to it by the slaves.

    +*Configurable with cluster_master_min_adv

    + +Multiple clusters can be run on the same network by just using different +multicast cluster_address. However, for a given host to be part +of multiple clusters without mixing the clusters, +cluster_port must be different for each cluster. +

    Routing

    If you are running a single instance, you may simply statically route the IP pools to the bind_address (l2tpns will send a gratuitous diff --git a/Docs/manual/manual.xml b/Docs/manual/manual.xml index 38e7b81..f2597c5 100644 --- a/Docs/manual/manual.xml +++ b/Docs/manual/manual.xml @@ -592,6 +592,16 @@ set boolean true + + cluster_port (udp port) + + + UDP cluster port (default: 32792). + See for more information. + + + + cluster_interface (string) @@ -2089,7 +2099,8 @@ iptables -t nat -L garden -nvx An l2tpns cluster consists of one* or more servers configured with the same configuration, notably the - multicast cluster_address. + multicast cluster_address and the + cluster_port *A stand-alone server is simply a degraded cluster. @@ -2098,7 +2109,8 @@ iptables -t nat -L garden -nvx Initially servers come up as cluster slaves, and periodically (every cluster_hb_interval/10 seconds) send out ping packets containing the start time of the process to the - multicast cluster_address. + multicast cluster_address on + cluster_port. @@ -2140,6 +2152,13 @@ iptables -t nat -L garden -nvx *Configurable with cluster_master_min_adv + + + Multiple clusters can be run on the same network by just using different + multicast cluster_address. However, for a given host to + be part of multiple clusters without mixing the clusters, + cluster_port must be different for each cluster. + diff --git a/Docs/startup-config.5 b/Docs/startup-config.5 index e18c69f..4f1500a 100644 --- a/Docs/startup-config.5 +++ b/Docs/startup-config.5 @@ -133,7 +133,7 @@ .\" ======================================================================== .\" .IX Title "STARTUP-CONFIG.5 1" -.TH STARTUP-CONFIG.5 1 "2015-09-22" "perl v5.20.2" "User Contributed Perl Documentation" +.TH STARTUP-CONFIG.5 1 "2017-05-26" "perl v5.20.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -199,6 +199,9 @@ example of use with 2 address: .IP "\fBcluster_address\fR (ip address)" 4 .IX Item "cluster_address (ip address)" Multicast cluster address (default: 239.192.13.13). See the section on Clustering for more information. +.IP "\fBBcluster_port\fR (int)" 4 +.IX Item "Bcluster_port (int)" +\&\s-1UDP\s0 cluster port (default: 32792). See the section on Clustering for more information. .IP "\fBcluster_interface\fR (string)" 4 .IX Item "cluster_interface (string)" Interface for cluster packets (default: eth0). diff --git a/Docs/startup-config.5.pod b/Docs/startup-config.5.pod index f652dda..46a96c4 100644 --- a/Docs/startup-config.5.pod +++ b/Docs/startup-config.5.pod @@ -80,6 +80,10 @@ B I "64.14.13.41, 64.14.13.42" Multicast cluster address (default: 239.192.13.13). See the section on Clustering for more information. +=item B (int) + +UDP cluster port (default: 32792). See the section on Clustering for more information. + =item B (string) Interface for cluster packets (default: eth0). diff --git a/cluster.c b/cluster.c index 26466be..d9b226f 100644 --- a/cluster.c +++ b/cluster.c @@ -98,7 +98,7 @@ int cluster_init() memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; - addr.sin_port = htons(CLUSTERPORT); + addr.sin_port = htons(config->cluster_port); addr.sin_addr.s_addr = INADDR_ANY; setsockopt(cluster_sockfd, SOL_SOCKET, SO_REUSEADDR, &addr, sizeof(addr)); @@ -170,7 +170,7 @@ static int cluster_send_data(void *data, int datalen) if (!config->cluster_address) return 0; addr.sin_addr.s_addr = config->cluster_address; - addr.sin_port = htons(CLUSTERPORT); + addr.sin_port = htons(config->cluster_port); addr.sin_family = AF_INET; LOG(5, 0, 0, "Cluster send data: %d bytes\n", datalen); @@ -253,7 +253,7 @@ static int peer_send_data(in_addr_t peer, uint8_t *data, int size) return -1; addr.sin_addr.s_addr = peer; - addr.sin_port = htons(CLUSTERPORT); + addr.sin_port = htons(config->cluster_port); addr.sin_family = AF_INET; LOG_HEX(5, "Peer send", data, size); @@ -2247,6 +2247,7 @@ int cmd_show_cluster(struct cli_def *cli, const char *command, char **argv, int cli_print(cli, "My address : %s", fmtaddr(my_address, 0)); cli_print(cli, "VIP address : %s", fmtaddr(config->bind_address, 0)); cli_print(cli, "Multicast address: %s", fmtaddr(config->cluster_address, 0)); + cli_print(cli, "UDP port : %u", config->cluster_port); cli_print(cli, "Multicast i'face : %s", config->cluster_interface); if (!config->cluster_iam_master) { diff --git a/debian/changelog b/debian/changelog index 4242297..34605d5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +l2tpns (2.2.1.2fdn3.20) unstable; urgency=low + + * Add cluster_port parameter for Multiple clusters (See clustering section for more informationc). + + -- Fernando Alves Fri, 26 May 2017 23:25:10 +0200 + l2tpns (2.2.1.2fdn3.19) unstable; urgency=low * New revision format. diff --git a/etc/startup-config.default b/etc/startup-config.default index 7545160..fedfe5f 100644 --- a/etc/startup-config.default +++ b/etc/startup-config.default @@ -93,6 +93,7 @@ set accounting_dir "/var/run/l2tpns/acct" # Cluster multicast address, interface #set cluster_address 239.192.13.13 +#set cluster_port 32792 #set cluster_interface eth0 # Cluster multicast TTL diff --git a/l2tpns.c b/l2tpns.c index 1c50a3e..152c8ec 100644 --- a/l2tpns.c +++ b/l2tpns.c @@ -163,6 +163,7 @@ config_descriptt config_values[] = { CONFIG("icmp_rate", icmp_rate, INT), CONFIG("packet_limit", max_packets, INT), CONFIG("cluster_address", cluster_address, IPv4), + CONFIG("cluster_port", cluster_port, INT), CONFIG("cluster_interface", cluster_interface, STRING), CONFIG("cluster_mcast_ttl", cluster_mcast_ttl, INT), CONFIG("cluster_hb_interval", cluster_hb_interval, INT), @@ -5628,6 +5629,7 @@ static void update_config() memcpy(config->old_plugins, config->plugins, sizeof(config->plugins)); if (!config->multi_read_count) config->multi_read_count = 10; if (!config->cluster_address) config->cluster_address = inet_addr(DEFAULT_MCAST_ADDR); + if (!config->cluster_port) config->cluster_port = CLUSTERPORT; if (!*config->cluster_interface) strncpy(config->cluster_interface, DEFAULT_MCAST_INTERFACE, sizeof(config->cluster_interface) - 1); diff --git a/l2tpns.h b/l2tpns.h index 7432a83..86cb664 100644 --- a/l2tpns.h +++ b/l2tpns.h @@ -731,6 +731,7 @@ typedef struct char epdis_addr[20]; // MP Endpoint Discriminator address in_addr_t cluster_address; // Multicast address of cluster. + unsigned short cluster_port; // UDP port of cluster. // Send to this address to have everyone hear. char cluster_interface[64]; // Which interface to listen for multicast on. int cluster_iam_master; // Are we the cluster master???