add lock_pages option
authorBrendan O'Dea <bod@optus.net>
Mon, 12 Jul 2004 08:21:45 +0000 (08:21 +0000)
committerBrendan O'Dea <bod@optus.net>
Mon, 12 Jul 2004 08:21:45 +0000 (08:21 +0000)
l2tpns.c
l2tpns.h

index b305d9d..9d1454d 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.13 2004-07-11 07:57:35 bodea Exp $";
+char const *cvs_id_l2tpns = "$Id: l2tpns.c,v 1.14 2004-07-12 08:21:45 bodea Exp $";
 
 #include <arpa/inet.h>
 #include <assert.h>
 
 #include <arpa/inet.h>
 #include <assert.h>
@@ -111,6 +111,7 @@ struct config_descriptt config_values[] = {
        CONFIG("cleanup_interval", cleanup_interval, INT),
        CONFIG("multi_read_count", multi_read_count, INT),
        CONFIG("scheduler_fifo", scheduler_fifo, BOOL),
        CONFIG("cleanup_interval", cleanup_interval, INT),
        CONFIG("multi_read_count", multi_read_count, INT),
        CONFIG("scheduler_fifo", scheduler_fifo, BOOL),
+       CONFIG("lock_pages", lock_pages, BOOL),
        CONFIG("icmp_rate", icmp_rate, INT),
        CONFIG("cluster_address", cluster_address, IP),
        CONFIG("cluster_interface", cluster_interface, STRING),
        CONFIG("icmp_rate", icmp_rate, INT),
        CONFIG("cluster_address", cluster_address, IP),
        CONFIG("cluster_interface", cluster_interface, STRING),
@@ -143,10 +144,10 @@ char *plugin_functions[] = {
 
 #define max_plugin_functions (sizeof(plugin_functions) / sizeof(char *))
 
 
 #define max_plugin_functions (sizeof(plugin_functions) / sizeof(char *))
 
-tunnelt *tunnel = NULL;                // Array of tunnel structures.
-sessiont *session = NULL;      // Array of session structures.
+tunnelt *tunnel = NULL;                        // Array of tunnel structures.
+sessiont *session = NULL;              // Array of session structures.
 sessioncountt *sess_count = NULL;      // Array of partial per-session traffic counters.
 sessioncountt *sess_count = NULL;      // Array of partial per-session traffic counters.
-radiust *radius = NULL;                // Array of radius structures.
+radiust *radius = NULL;                        // Array of radius structures.
 ippoolt *ip_address_pool = NULL;       // Array of dynamic IP addresses.
 controlt *controlfree = 0;
 struct Tstats *_statistics = NULL;
 ippoolt *ip_address_pool = NULL;       // Array of dynamic IP addresses.
 controlt *controlfree = 0;
 struct Tstats *_statistics = NULL;
@@ -2955,6 +2956,15 @@ int main(int argc, char *argv[])
        signal(SIGQUIT, sigquit_handler);
        signal(SIGCHLD, sigchild_handler);
 
        signal(SIGQUIT, sigquit_handler);
        signal(SIGCHLD, sigchild_handler);
 
+       // Prevent us from getting paged out
+       if (config->lock_pages)
+       {
+               if (!mlockall(MCL_CURRENT))
+                       log(1, 0, 0, 0, "Locking pages into memory\n");
+               else
+                       log(0, 0, 0, 0, "Can't lock pages: %s\n", strerror(errno));
+       }
+
        alarm(1);
 
        // Drop privileges here
        alarm(1);
 
        // Drop privileges here
index ce36a3c..56cb9a5 100644 (file)
--- a/l2tpns.h
+++ b/l2tpns.h
@@ -1,5 +1,5 @@
 // L2TPNS Global Stuff
 // L2TPNS Global Stuff
-// $Id: l2tpns.h,v 1.11 2004-07-08 16:54:35 bodea Exp $
+// $Id: l2tpns.h,v 1.12 2004-07-12 08:21:45 bodea Exp $
 
 #ifndef __L2TPNS_H__
 #define __L2TPNS_H__
 
 #ifndef __L2TPNS_H__
 #define __L2TPNS_H__
@@ -413,9 +413,9 @@ struct configt
        char            old_plugins[64][MAXPLUGINS];
 
        int             next_tbf;                       // Next HTB id available to use
        char            old_plugins[64][MAXPLUGINS];
 
        int             next_tbf;                       // Next HTB id available to use
-       int             scheduler_fifo;                 // If 1, will force scheduler to use SCHED_FIFO.
-                                                       // Don't use this unless you have a dual processor machine!
-       int             icmp_rate;                      // Max number of ICMP unreachable per second to send
+       int             scheduler_fifo;                 // If the system has multiple CPUs, use FIFO scheduling policy for this process.
+       int             lock_pages;                     // Lock pages into memory.
+       int             icmp_rate;                      // Max number of ICMP unreachable per second to send>
 
        u32             cluster_address;                // Multicast address of cluster.
                                                        // Send to this address to have everyone hear.
 
        u32             cluster_address;                // Multicast address of cluster.
                                                        // Send to this address to have everyone hear.