Add cluster_port parameter for Multiple clusters

This commit is contained in:
fendo 2017-05-27 00:09:19 +02:00
parent 7034e6a018
commit 0f20bfda6a
9 changed files with 55 additions and 6 deletions

View file

@ -345,6 +345,11 @@ Multicast cluster address (default: 239.192.13.13). See the section
on <A HREF="#Clustering">Clustering</A> for more information. on <A HREF="#Clustering">Clustering</A> for more information.
</LI> </LI>
<LI><B>cluster_port</B> (int udp port)<BR>
UDP cluster port (default: 32792). See the section on
<A HREF="#Clustering">Clustering</A> for more information.
</LI>
<LI><B>cluster_interface</B> (string)<BR> <LI><B>cluster_interface</B> (string)<BR>
Interface for cluster packets (default: eth0). Interface for cluster packets (default: eth0).
</LI> </LI>
@ -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 will drop all routes (raising them again if all slaves disappear) and
subsequently handle only packets forwarded to it by the slaves.<P> subsequently handle only packets forwarded to it by the slaves.<P>
*Configurable with <B>cluster_master_min_adv</B><P>
Multiple clusters can be run on the same network by just using different
multicast <B>cluster_address</B>. However, for a given host to be part
of multiple clusters without mixing the clusters,
<B>cluster_port</B> must be different for each cluster.<B>
<H2 ID="Routing">Routing</H2> <H2 ID="Routing">Routing</H2>
If you are running a single instance, you may simply statically route If you are running a single instance, you may simply statically route
the IP pools to the <B>bind_address</B> (l2tpns will send a gratuitous the IP pools to the <B>bind_address</B> (l2tpns will send a gratuitous

View file

@ -592,6 +592,16 @@ set boolean true
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><literal>cluster_port</literal> (udp port)</term>
<listitem>
<para>
UDP cluster port (default: 32792).
See <xref linkend="clustering"/> for more information.
</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><literal>cluster_interface</literal> (string)</term> <term><literal>cluster_interface</literal> (string)</term>
<listitem> <listitem>
@ -2089,7 +2099,8 @@ iptables -t nat -L garden -nvx
<para> <para>
An <command>l2tpns</command> cluster consists of one* or more An <command>l2tpns</command> cluster consists of one* or more
servers configured with the same configuration, notably the servers configured with the same configuration, notably the
multicast <literal>cluster_address</literal>. multicast <literal>cluster_address</literal> and the
<literal>cluster_port</literal>
</para> </para>
<para>*A stand-alone server is simply a degraded cluster.</para> <para>*A stand-alone server is simply a degraded cluster.</para>
@ -2098,7 +2109,8 @@ iptables -t nat -L garden -nvx
Initially servers come up as cluster slaves, and periodically Initially servers come up as cluster slaves, and periodically
(every <literal>cluster_hb_interval</literal>/10 seconds) send (every <literal>cluster_hb_interval</literal>/10 seconds) send
out ping packets containing the start time of the process to the out ping packets containing the start time of the process to the
multicast <literal>cluster_address</literal>. multicast <literal>cluster_address</literal> on
<literal>cluster_port</literal>.
</para> </para>
<para> <para>
@ -2140,6 +2152,13 @@ iptables -t nat -L garden -nvx
</para> </para>
<para>*Configurable with <literal>cluster_master_min_adv</literal></para> <para>*Configurable with <literal>cluster_master_min_adv</literal></para>
<para>
Multiple clusters can be run on the same network by just using different
multicast <literal>cluster_address</literal>. However, for a given host to
be part of multiple clusters without mixing the clusters,
<literal>cluster_port</literal> must be different for each cluster.
</para>
</sect1> </sect1>
<sect1 id="routing"> <sect1 id="routing">

View file

@ -133,7 +133,7 @@
.\" ======================================================================== .\" ========================================================================
.\" .\"
.IX Title "STARTUP-CONFIG.5 1" .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 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents. .\" way too many mistakes in technical documents.
.if n .ad l .if n .ad l
@ -199,6 +199,9 @@ example of use with 2 address:
.IP "\fBcluster_address\fR (ip address)" 4 .IP "\fBcluster_address\fR (ip address)" 4
.IX Item "cluster_address (ip address)" .IX Item "cluster_address (ip address)"
Multicast cluster address (default: 239.192.13.13). See the section on Clustering for more information. 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 .IP "\fBcluster_interface\fR (string)" 4
.IX Item "cluster_interface (string)" .IX Item "cluster_interface (string)"
Interface for cluster packets (default: eth0). Interface for cluster packets (default: eth0).

View file

@ -80,6 +80,10 @@ B<set> I<bind_multi_address> "64.14.13.41, 64.14.13.42"
Multicast cluster address (default: 239.192.13.13). See the section on Clustering for more information. Multicast cluster address (default: 239.192.13.13). See the section on Clustering for more information.
=item B<Bcluster_port> (int)
UDP cluster port (default: 32792). See the section on Clustering for more information.
=item B<cluster_interface> (string) =item B<cluster_interface> (string)
Interface for cluster packets (default: eth0). Interface for cluster packets (default: eth0).

View file

@ -98,7 +98,7 @@ int cluster_init()
memset(&addr, 0, sizeof(addr)); memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET; addr.sin_family = AF_INET;
addr.sin_port = htons(CLUSTERPORT); addr.sin_port = htons(config->cluster_port);
addr.sin_addr.s_addr = INADDR_ANY; addr.sin_addr.s_addr = INADDR_ANY;
setsockopt(cluster_sockfd, SOL_SOCKET, SO_REUSEADDR, &addr, sizeof(addr)); 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; if (!config->cluster_address) return 0;
addr.sin_addr.s_addr = config->cluster_address; 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; addr.sin_family = AF_INET;
LOG(5, 0, 0, "Cluster send data: %d bytes\n", datalen); 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; return -1;
addr.sin_addr.s_addr = peer; addr.sin_addr.s_addr = peer;
addr.sin_port = htons(CLUSTERPORT); addr.sin_port = htons(config->cluster_port);
addr.sin_family = AF_INET; addr.sin_family = AF_INET;
LOG_HEX(5, "Peer send", data, size); 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, "My address : %s", fmtaddr(my_address, 0));
cli_print(cli, "VIP address : %s", fmtaddr(config->bind_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, "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); cli_print(cli, "Multicast i'face : %s", config->cluster_interface);
if (!config->cluster_iam_master) { if (!config->cluster_iam_master) {

6
debian/changelog vendored
View file

@ -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 <fendo@sameswifi.fr> Fri, 26 May 2017 23:25:10 +0200
l2tpns (2.2.1.2fdn3.19) unstable; urgency=low l2tpns (2.2.1.2fdn3.19) unstable; urgency=low
* New revision format. * New revision format.

View file

@ -93,6 +93,7 @@ set accounting_dir "/var/run/l2tpns/acct"
# Cluster multicast address, interface # Cluster multicast address, interface
#set cluster_address 239.192.13.13 #set cluster_address 239.192.13.13
#set cluster_port 32792
#set cluster_interface eth0 #set cluster_interface eth0
# Cluster multicast TTL # Cluster multicast TTL

View file

@ -163,6 +163,7 @@ config_descriptt config_values[] = {
CONFIG("icmp_rate", icmp_rate, INT), CONFIG("icmp_rate", icmp_rate, INT),
CONFIG("packet_limit", max_packets, INT), CONFIG("packet_limit", max_packets, INT),
CONFIG("cluster_address", cluster_address, IPv4), CONFIG("cluster_address", cluster_address, IPv4),
CONFIG("cluster_port", cluster_port, INT),
CONFIG("cluster_interface", cluster_interface, STRING), CONFIG("cluster_interface", cluster_interface, STRING),
CONFIG("cluster_mcast_ttl", cluster_mcast_ttl, INT), CONFIG("cluster_mcast_ttl", cluster_mcast_ttl, INT),
CONFIG("cluster_hb_interval", cluster_hb_interval, 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)); memcpy(config->old_plugins, config->plugins, sizeof(config->plugins));
if (!config->multi_read_count) config->multi_read_count = 10; 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_address) config->cluster_address = inet_addr(DEFAULT_MCAST_ADDR);
if (!config->cluster_port) config->cluster_port = CLUSTERPORT;
if (!*config->cluster_interface) if (!*config->cluster_interface)
strncpy(config->cluster_interface, DEFAULT_MCAST_INTERFACE, sizeof(config->cluster_interface) - 1); strncpy(config->cluster_interface, DEFAULT_MCAST_INTERFACE, sizeof(config->cluster_interface) - 1);

View file

@ -731,6 +731,7 @@ typedef struct
char epdis_addr[20]; // MP Endpoint Discriminator address char epdis_addr[20]; // MP Endpoint Discriminator address
in_addr_t cluster_address; // Multicast address of cluster. 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. // Send to this address to have everyone hear.
char cluster_interface[64]; // Which interface to listen for multicast on. char cluster_interface[64]; // Which interface to listen for multicast on.
int cluster_iam_master; // Are we the cluster master??? int cluster_iam_master; // Are we the cluster master???