Update version
[l2tpns.git] / garden.c
index a023399..0e6880c 100644 (file)
--- a/garden.c
+++ b/garden.c
@@ -3,14 +3,14 @@
 #include <stdlib.h>
 #include <sys/wait.h>
 #include <sys/types.h>
+#include <netinet/ip6.h>
+#include "dhcp6.h"
 #include "l2tpns.h"
 #include "plugin.h"
 #include "control.h"
 
 /* walled garden */
 
-char const *cvs_id = "$Id: garden.c,v 1.24 2005-10-11 09:04:53 bodea Exp $";
-
 int plugin_api_version = PLUGIN_API_VERSION;
 static struct pluginfuncs *f = 0;
 
@@ -23,7 +23,8 @@ char *up_commands[] = {
     "iptables -t nat -N garden_users >/dev/null 2>&1",         // Empty chain, users added/removed by garden_session
     "iptables -t nat -F garden_users",
     "iptables -t nat -A PREROUTING -j garden_users",           // DNAT any users on the garden_users chain
-    "sysctl -w net.ipv4.ip_conntrack_max=512000 >/dev/null",   // lots of entries
+    "sysctl -w net.ipv4.netfilter.ip_conntrack_max=512000"     // lots of entries
+            " net.ipv4.netfilter.ip_conntrack_tcp_timeout_established=18000 >/dev/null", // 5hrs
     NULL,
 };
 
@@ -158,7 +159,7 @@ int plugin_become_master(void)
     for (i = 0; up_commands[i] && *up_commands[i]; i++)
     {
        f->log(3, 0, 0, "Running %s\n", up_commands[i]);
-       system(up_commands[i]);
+       if (-1 == system(up_commands[i])) f->log(0, 0, 0, "error command %s\n", up_commands[i]);
     }
 
     return PLUGIN_RET_OK;
@@ -177,6 +178,7 @@ int garden_session(sessiont *s, int flag, char *newuser)
 {
     char cmd[2048];
     sessionidt sess;
+       int status;
 
     if (!s) return 0;
     if (!s->opened) return 0;
@@ -192,7 +194,7 @@ int garden_session(sessiont *s, int flag, char *newuser)
            f->fmtaddr(htonl(s->ip), 0));
 
        f->log(3, sess, s->tunnel, "%s\n", cmd);
-       system(cmd);
+       status = system(cmd);
        s->walled_garden = 1;
     }
     else
@@ -230,7 +232,7 @@ int garden_session(sessiont *s, int flag, char *newuser)
        f->log(3, sess, s->tunnel, "%s\n", cmd);
        while (--count)
        {
-           int status = system(cmd);
+           status = system(cmd);
            if (WEXITSTATUS(status) != 0) break;
        }
 
@@ -273,7 +275,7 @@ int plugin_init(struct pluginfuncs *funcs)
        for (i = 0; down_commands[i] && *down_commands[i]; i++)
        {
            f->log(3, 0, 0, "Running %s\n", down_commands[i]);
-           system(down_commands[i]);
+           if (-1 == system(down_commands[i])) f->log(0, 0, 0, "error command %s\n", down_commands[i]);
        }
     }
 
@@ -290,7 +292,7 @@ void plugin_done()
     for (i = 0; down_commands[i] && *down_commands[i]; i++)
     {
        f->log(3, 0, 0, "Running %s\n", down_commands[i]);
-       system(down_commands[i]);
+       if (-1 == system(down_commands[i])) f->log(0, 0, 0, "error command %s\n", down_commands[i]);
     }
 }