Add a debian/changelog entry for version 2.2.1-1fdn3
[l2tpns.git] / cluster.c
index d8a2e68..f5e6de8 100644 (file)
--- a/cluster.c
+++ b/cluster.c
@@ -1,6 +1,6 @@
 // L2TPNS Clustering Stuff
 
-char const *cvs_id_cluster = "$Id: cluster.c,v 1.52 2006/06/11 12:46:18 bodea Exp $";
+char const *cvs_id_cluster = "$Id: cluster.c,v 1.55 2009/12/08 14:49:28 bodea Exp $";
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -402,7 +402,7 @@ void cluster_send_ping(time_t basetime)
 
        x.ver = 1;
        x.addr = config->bind_address;
-       x.undef = config->cluster_undefined_sessions + config->cluster_undefined_tunnels;
+       x.undef = config->cluster_undefined_sessions + config->cluster_undefined_tunnels + config->cluster_undefined_bundles;
        x.basetime = basetime;
 
        add_type(&p, C_PING, basetime, (uint8_t *) &x, sizeof(x));
@@ -522,7 +522,7 @@ void cluster_check_slaves(void)
 //
 void cluster_check_master(void)
 {
-       int i, count, tcount, bcount, high_unique_id = 0;
+       int i, count, high_unique_id = 0;
        int last_free = 0;
        clockt t = TIME;
        static int probed = 0;
@@ -608,7 +608,7 @@ void cluster_check_master(void)
                // Count the highest used tunnel number as well.
                //
        config->cluster_highest_tunnelid = 0;
-       for (i = 0, tcount = 0; i < MAXTUNNEL; ++i) {
+       for (i = 0; i < MAXTUNNEL; ++i) {
                if (tunnel[i].state == TUNNELUNDEF)
                        tunnel[i].state = TUNNELFREE;
 
@@ -621,7 +621,7 @@ void cluster_check_master(void)
                 // Count the highest used bundle number as well.
                 //
         config->cluster_highest_bundleid = 0;
-        for (i = 0, bcount = 0; i < MAXBUNDLE; ++i) {
+        for (i = 0; i < MAXBUNDLE; ++i) {
                 if (bundle[i].state == BUNDLEUNDEF)
                         bundle[i].state = BUNDLEFREE;
 
@@ -940,9 +940,8 @@ void cluster_heartbeat()
                if (bcount >= config->cluster_highest_bundleid)
                        break;
 
-               hb_add_type(&p, C_CTUNNEL, walk_bundle_number);
-               walk_tunnel_number = (1+walk_bundle_number)%(config->cluster_highest_bundleid+1);       // +1 avoids divide by zero.
-
+               hb_add_type(&p, C_CBUNDLE, walk_bundle_number);
+               walk_bundle_number = (1+walk_bundle_number)%(config->cluster_highest_bundleid+1);       // +1 avoids divide by zero.
                ++bcount;
         }
 
@@ -1453,7 +1452,11 @@ static int cluster_process_heartbeat(uint8_t *data, int size, int more, uint8_t
                return -1; // Ignore it??
        }
 
-               // Ok. It's a heartbeat packet from a cluster master!
+       if (size > sizeof(past_hearts[0].data)) {
+               LOG(0, 0, 0, "Received an oversize heartbeat from %s (%d)!\n", fmtaddr(addr, 0), size);
+               return -1;
+       }
+
        if (s < sizeof(*h))
                goto shortpacket;
 
@@ -1770,7 +1773,7 @@ int processcluster(uint8_t *data, int size, in_addr_t addr)
        case C_FORWARD_DAE: // Forwarded DAE packet. pass off to processdae.
                if (!config->cluster_iam_master)
                {
-                       LOG(0, 0, 0, "I'm not the master, but I got a C_FORWARD_%s from %s?\n",
+                       LOG(0, 0, 0, "I'm not the master, but I got a C_FORWARD%s from %s?\n",
                                type == C_FORWARD_DAE ? "_DAE" : "", fmtaddr(addr, 0));
 
                        return -1;