count select_called, multi_read_used and multi_read_exceeded release_2_0_13
authorbodea <bodea>
Fri, 17 Dec 2004 00:28:00 +0000 (00:28 +0000)
committerbodea <bodea>
Fri, 17 Dec 2004 00:28:00 +0000 (00:28 +0000)
Changes
cli.c
l2tpns.c
l2tpns.h

diff --git a/Changes b/Changes
index ceabd76..32e9a2b 100644 (file)
--- a/Changes
+++ b/Changes
@@ -10,7 +10,7 @@
   startup-config (from Jonathan's Debian package patches).
 - Read multiple packets off cluster_sockfd as well as udpfd, tunfd in an
   attempt to avoid losing the cluster in high load (DoS) conditions.
   startup-config (from Jonathan's Debian package patches).
 - Read multiple packets off cluster_sockfd as well as udpfd, tunfd in an
   attempt to avoid losing the cluster in high load (DoS) conditions.
-- Add counters for select_called, select_ready and select_processed.
+- Add counters for select_called, multi_read_used and multi_read_exceeded.
 - Compress logs.
 - Retain counters of shutdown sessions to dump once per minute.
 - Use standard uintN_t types for portability.
 - Compress logs.
 - Retain counters of shutdown sessions to dump once per minute.
 - Use standard uintN_t types for portability.
diff --git a/cli.c b/cli.c
index 32fdd0d..c1fc29b 100644 (file)
--- a/cli.c
+++ b/cli.c
@@ -2,7 +2,7 @@
 // vim: sw=8 ts=8
 
 char const *cvs_name = "$Name:  $";
 // vim: sw=8 ts=8
 
 char const *cvs_name = "$Name:  $";
-char const *cvs_id_cli = "$Id: cli.c,v 1.42 2004/12/16 23:40:30 bodea Exp $";
+char const *cvs_id_cli = "$Id: cli.c,v 1.43 2004/12/17 00:28:00 bodea Exp $";
 
 #include <stdio.h>
 #include <stdarg.h>
 
 #include <stdio.h>
 #include <stdarg.h>
@@ -686,8 +686,8 @@ static int cmd_show_counters(struct cli_def *cli, char *command, char **argv, in
        cli_print(cli, "%-30s%u", "cluster_forwarded",          GET_STAT(c_forwarded));
        cli_print(cli, "%-30s%u", "recv_forward",               GET_STAT(recv_forward));
        cli_print(cli, "%-30s%u", "select_called",              GET_STAT(select_called));
        cli_print(cli, "%-30s%u", "cluster_forwarded",          GET_STAT(c_forwarded));
        cli_print(cli, "%-30s%u", "recv_forward",               GET_STAT(recv_forward));
        cli_print(cli, "%-30s%u", "select_called",              GET_STAT(select_called));
-       cli_print(cli, "%-30s%u", "select_ready",               GET_STAT(select_ready));
-       cli_print(cli, "%-30s%u", "select_processed",           GET_STAT(select_processed));
+       cli_print(cli, "%-30s%u", "multi_read_used",            GET_STAT(multi_read_used));
+       cli_print(cli, "%-30s%u", "multi_read_exceeded",        GET_STAT(multi_read_exceeded));
 
 
 #ifdef STATISTICS
 
 
 #ifdef STATISTICS
index 341cf74..a02be1d 100644 (file)
--- a/l2tpns.c
+++ b/l2tpns.c
@@ -4,7 +4,7 @@
 // Copyright (c) 2002 FireBrick (Andrews & Arnold Ltd / Watchfront Ltd) - GPL licenced
 // vim: sw=8 ts=8
 
 // Copyright (c) 2002 FireBrick (Andrews & Arnold Ltd / Watchfront Ltd) - GPL licenced
 // vim: sw=8 ts=8
 
-char const *cvs_id_l2tpns = "$Id: l2tpns.c,v 1.72 2004/12/16 23:40:31 bodea Exp $";
+char const *cvs_id_l2tpns = "$Id: l2tpns.c,v 1.73 2004/12/17 00:28:00 bodea Exp $";
 
 #include <arpa/inet.h>
 #include <assert.h>
 
 #include <arpa/inet.h>
 #include <assert.h>
@@ -2367,14 +2367,11 @@ static void mainloop(void)
                        int tun_pkts = 0;
                        int cluster_pkts = 0;
 
                        int tun_pkts = 0;
                        int cluster_pkts = 0;
 
-                       INC_STAT(select_ready, n);
-
                        // nsctl commands
                        if (FD_ISSET(controlfd, &r))
                        {
                                alen = sizeof(addr);
                                processcontrol(buf, recvfrom(controlfd, buf, sizeof(buf), MSG_WAITALL, (void *) &addr, &alen), &addr, alen);
                        // nsctl commands
                        if (FD_ISSET(controlfd, &r))
                        {
                                alen = sizeof(addr);
                                processcontrol(buf, recvfrom(controlfd, buf, sizeof(buf), MSG_WAITALL, (void *) &addr, &alen), &addr, alen);
-                               STAT(select_processed);
                                n--;
                        }
 
                                n--;
                        }
 
@@ -2386,7 +2383,6 @@ static void mainloop(void)
                                        if (FD_ISSET(radfds[i], &r))
                                        {
                                                processrad(buf, recv(radfds[i], buf, sizeof(buf), 0), i);
                                        if (FD_ISSET(radfds[i], &r))
                                        {
                                                processrad(buf, recv(radfds[i], buf, sizeof(buf), 0), i);
-                                               STAT(select_processed);
                                                n--;
                                        }
                                }
                                                n--;
                                        }
                                }
@@ -2406,21 +2402,17 @@ static void mainloop(void)
                                else
                                        LOG(0, 0, 0, "accept error: %s\n", strerror(errno));
 
                                else
                                        LOG(0, 0, 0, "accept error: %s\n", strerror(errno));
 
-                               STAT(select_processed);
                                n--;
                        }
 
 #ifdef BGP
                        for (i = 0; i < BGP_NUM_PEERS; i++)
                        {
                                n--;
                        }
 
 #ifdef BGP
                        for (i = 0; i < BGP_NUM_PEERS; i++)
                        {
-                               int isr = bgp_set[i] ? !!FD_ISSET(bgp_peers[i].sock, &r) : 0;
-                               int isw = bgp_set[i] ? !!FD_ISSET(bgp_peers[i].sock, &w) : 0;
+                               int isr = bgp_set[i] ? FD_ISSET(bgp_peers[i].sock, &r) : 0;
+                               int isw = bgp_set[i] ? FD_ISSET(bgp_peers[i].sock, &w) : 0;
                                bgp_process(&bgp_peers[i], isr, isw);
                                bgp_process(&bgp_peers[i], isr, isw);
-                               if (isr || isw)
-                               {
-                                       INC_STAT(select_processed, isr + isw);
-                                       n -= (isr + isw);
-                               }
+                               if (isr) n--;
+                               if (isw) n--;
                        }
 #endif /* BGP */
 
                        }
 #endif /* BGP */
 
@@ -2433,7 +2425,6 @@ static void mainloop(void)
                                        if ((s = recvfrom(udpfd, buf, sizeof(buf), 0, (void *) &addr, &alen)) > 0)
                                        {
                                                processudp(buf, s, &addr);
                                        if ((s = recvfrom(udpfd, buf, sizeof(buf), 0, (void *) &addr, &alen)) > 0)
                                        {
                                                processudp(buf, s, &addr);
-                                               STAT(select_processed);
                                                udp_pkts++;
                                        }
                                        else
                                                udp_pkts++;
                                        }
                                        else
@@ -2449,7 +2440,6 @@ static void mainloop(void)
                                        if ((s = read(tunfd, buf, sizeof(buf))) > 0)
                                        {
                                                processtun(buf, s);
                                        if ((s = read(tunfd, buf, sizeof(buf))) > 0)
                                        {
                                                processtun(buf, s);
-                                               STAT(select_processed);
                                                tun_pkts++;
                                        }
                                        else
                                                tun_pkts++;
                                        }
                                        else
@@ -2466,7 +2456,6 @@ static void mainloop(void)
                                        if ((s = recvfrom(cluster_sockfd, buf, sizeof(buf), MSG_WAITALL, (void *) &addr, &alen)) > 0)
                                        {
                                                processcluster(buf, s, addr.sin_addr.s_addr);
                                        if ((s = recvfrom(cluster_sockfd, buf, sizeof(buf), MSG_WAITALL, (void *) &addr, &alen)) > 0)
                                        {
                                                processcluster(buf, s, addr.sin_addr.s_addr);
-                                               STAT(select_processed);
                                                cluster_pkts++;
                                        }
                                        else
                                                cluster_pkts++;
                                        }
                                        else
@@ -2477,9 +2466,16 @@ static void mainloop(void)
                                }
                        }
 
                                }
                        }
 
+                       if (udp_pkts > 1 || tun_pkts > 1 || cluster_pkts > 1)
+                               STAT(multi_read_used);
+
                        if (c >= config->multi_read_count)
                        if (c >= config->multi_read_count)
+                       {
                                LOG(3, 0, 0, "Reached multi_read_count (%d); processed %d udp, %d tun and %d cluster packets\n",
                                        config->multi_read_count, udp_pkts, tun_pkts, cluster_pkts);
                                LOG(3, 0, 0, "Reached multi_read_count (%d); processed %d udp, %d tun and %d cluster packets\n",
                                        config->multi_read_count, udp_pkts, tun_pkts, cluster_pkts);
+
+                               STAT(multi_read_exceeded);
+                       }
                }
 
                        // Runs on every machine (master and slaves).
                }
 
                        // Runs on every machine (master and slaves).
index 1229096..2654cdc 100644 (file)
--- a/l2tpns.h
+++ b/l2tpns.h
@@ -1,5 +1,5 @@
 // L2TPNS Global Stuff
 // L2TPNS Global Stuff
-// $Id: l2tpns.h,v 1.48 2004/12/16 23:40:31 bodea Exp $
+// $Id: l2tpns.h,v 1.49 2004/12/17 00:28:00 bodea Exp $
 
 #ifndef __L2TPNS_H__
 #define __L2TPNS_H__
 
 #ifndef __L2TPNS_H__
 #define __L2TPNS_H__
@@ -346,9 +346,9 @@ struct Tstats
     uint32_t   c_forwarded;
     uint32_t   recv_forward;
 
     uint32_t   c_forwarded;
     uint32_t   recv_forward;
 
-    uint32_t   select_called;          // number of times select called
-    uint32_t   select_ready;           // number of fds returned by select
-    uint32_t   select_processed;       // number of read/writes handled per select
+    uint32_t   select_called;
+    uint32_t   multi_read_used;
+    uint32_t   multi_read_exceeded;
 
 #ifdef STATISTICS
     uint32_t   call_processtun;
 
 #ifdef STATISTICS
     uint32_t   call_processtun;