* Fri Mar 5 2004 David Parrish <david@dparrish.com> 1.1.0
- Change all strcpy() calls to strncpy() to avoid buffer overflow potential - Add ICMP host unreachable support - Logging to syslog if log_file = "syslog:facility" - Now requires libcli 1.5 - All configuration moves to a config structure - Ability to modify and write config on the fly through command-line interface - Config file support is removed, and now handled by the cli - Show hostname in cli prompt - Keep current state type for tunnels - Add uptime command do CLI, which also shows real-time bandwidth utilisation - Add goodbye command to cluster master, which forces droppping a slave - Cache IP address allocation, so that reconnecting users get the same address - Fix tunnel resend timeouts, so that dead tunnels will be cleaned up - Allocate tunnels and radius without using a linked list which had issues - Fix some off-by-one errors in tunnel and session and radius arrays - Save and reload ip address pool when dieing - Check version and size of reloaded data when restarting - Remove plugin_config support - Remove old support for TBF which didn't work anyway. HTB is required to do throttling now. - Add COPYING and Changes files
This commit is contained in:
parent
b8ae54f127
commit
b43583c01d
22 changed files with 1731 additions and 1248 deletions
72
rl.c
72
rl.c
|
|
@ -1,5 +1,5 @@
|
|||
// L2TPNS Rate Limiting Stuff
|
||||
// $Id: rl.c,v 1.1 2003/12/16 07:07:39 fred_nerk Exp $
|
||||
// $Id: rl.c,v 1.2 2004/03/05 00:09:03 fred_nerk Exp $
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/file.h>
|
||||
|
|
@ -11,47 +11,30 @@
|
|||
#include <malloc.h>
|
||||
#include "l2tpns.h"
|
||||
|
||||
extern char *radiussecret;
|
||||
extern radiust *radius;
|
||||
extern sessiont *session;
|
||||
extern ipt radiusserver[MAXRADSERVER]; // radius servers
|
||||
extern u32 sessionid;
|
||||
extern u8 radiusfree;
|
||||
extern int radfd;
|
||||
extern u8 numradiusservers;
|
||||
extern char debug;
|
||||
extern char *tapdevice;
|
||||
extern tbft *filter_buckets;
|
||||
extern struct configt *config;
|
||||
|
||||
#define DEVICE "tun0"
|
||||
|
||||
unsigned long rl_rate = 0;
|
||||
int next_tbf = 1;
|
||||
|
||||
void init_rl()
|
||||
{
|
||||
#ifdef TC_TBF
|
||||
system("tc qdisc del dev " DEVICE " root");
|
||||
system("tc qdisc add dev " DEVICE " root handle 1: cbq avpkt 10000 bandwidth 100mbit");
|
||||
system("tc filter del dev " DEVICE " protocol ip pref 1 fw");
|
||||
system("iptables -t mangle -N throttle 2>&1 > /dev/null");
|
||||
system("iptables -t mangle -F throttle");
|
||||
system("iptables -t mangle -A l2tpns -j throttle");
|
||||
#endif
|
||||
#ifdef TC_HTB
|
||||
char *commands[] = {
|
||||
"tc qdisc add dev " DEVICE " root handle 1: htb default 1",
|
||||
"tc class add dev " DEVICE " parent 1: classid 1:1 htb rate 100mbit burst 300k",
|
||||
"tc filter del dev " DEVICE " protocol ip pref 1 fw",
|
||||
"iptables -t mangle -N throttle 2>&1 > /dev/null",
|
||||
"iptables -t mangle -F throttle",
|
||||
"iptables -t mangle -A l2tpns -j throttle",
|
||||
"iptables -t mangle -N throttle 2>&1 >/dev/null",
|
||||
"iptables -t mangle -F throttle 2>&1 >/dev/null",
|
||||
"iptables -t mangle -A l2tpns -j throttle 2>&1 >/dev/null",
|
||||
NULL
|
||||
};
|
||||
int i;
|
||||
|
||||
if (!rl_rate) return;
|
||||
|
||||
log(2, 0, 0, 0, "Initializing HTB\n");
|
||||
for (i = 0; commands[i] && *commands[i]; i++)
|
||||
{
|
||||
|
|
@ -59,41 +42,21 @@ void init_rl()
|
|||
system(commands[i]);
|
||||
}
|
||||
log(2, 0, 0, 0, "Done initializing HTB\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
u16 rl_create_tbf()
|
||||
{
|
||||
u16 t;
|
||||
char cmd[2048];
|
||||
if (!rl_rate) return 0;
|
||||
if (!config->rl_rate) return 0;
|
||||
|
||||
if (next_tbf >= MAXSESSION) return 0;
|
||||
t = next_tbf++;
|
||||
snprintf(filter_buckets[t].handle, 9, "1:%d0", t);
|
||||
|
||||
#ifdef TC_TBF
|
||||
log(2, 0, 0, 0, "Creating new tbf %s\n", filter_buckets[t].handle);
|
||||
snprintf(cmd, 2048, "tc class add dev " DEVICE " parent 1: classid 1:%d cbq bandwidth 100Mbit rate 100Mbit "
|
||||
"weight 1 prio 8 allot 1514 cell 8 maxburst 20 avpkt 1000 bounded isolated",
|
||||
t);
|
||||
log(3, 0, 0, 0, "%s\n", cmd);
|
||||
system(cmd);
|
||||
|
||||
snprintf(cmd, 2048, "tc qdisc add dev " DEVICE " parent 1:%d handle %s tbf rate %dkbit buffer 1600 limit 3000",
|
||||
t, filter_buckets[t].handle, rl_rate);
|
||||
log(3, 0, 0, 0, "%s\n", cmd);
|
||||
system(cmd);
|
||||
|
||||
snprintf(cmd, 2048, "tc filter add dev " DEVICE " protocol ip parent 1:0 prio 1 handle %d fw flowid 1:%d",
|
||||
t, t);
|
||||
log(3, 0, 0, 0, "%s\n", cmd);
|
||||
system(cmd);
|
||||
#endif
|
||||
#ifdef TC_HTB
|
||||
log(2, 0, 0, 0, "Creating new htb %s\n", filter_buckets[t].handle);
|
||||
snprintf(cmd, 2048, "tc class add dev " DEVICE " parent 1: classid %s htb rate %lukbit burst 15k",
|
||||
filter_buckets[t].handle, rl_rate);
|
||||
filter_buckets[t].handle, config->rl_rate);
|
||||
log(3, 0, 0, 0, "%s\n", cmd);
|
||||
system(cmd);
|
||||
|
||||
|
|
@ -101,7 +64,6 @@ u16 rl_create_tbf()
|
|||
t, filter_buckets[t].handle);
|
||||
log(3, 0, 0, 0, "%s\n", cmd);
|
||||
system(cmd);
|
||||
#endif
|
||||
|
||||
next_tbf++;
|
||||
return t;
|
||||
|
|
@ -110,7 +72,7 @@ u16 rl_create_tbf()
|
|||
u16 rl_get_tbf()
|
||||
{
|
||||
int i;
|
||||
if (!rl_rate) return 0;
|
||||
if (!config->rl_rate) return 0;
|
||||
|
||||
for (i = 1; i < MAXSESSION; i++)
|
||||
{
|
||||
|
|
@ -129,30 +91,24 @@ u16 rl_get_tbf()
|
|||
void rl_done_tbf(u16 t)
|
||||
{
|
||||
if (!t) return;
|
||||
if (!rl_rate) return;
|
||||
log(2, 0, 0, 0, "Freeing up TBF %s\n", filter_buckets[t].handle);
|
||||
if (!config->rl_rate) return;
|
||||
log(2, 0, 0, 0, "Freeing up HTB %s\n", filter_buckets[t].handle);
|
||||
filter_buckets[t].in_use = 0;
|
||||
}
|
||||
|
||||
void rl_destroy_tbf(u16 t)
|
||||
{
|
||||
char cmd[2048];
|
||||
if (!rl_rate) return;
|
||||
if (!config->rl_rate) return;
|
||||
if (filter_buckets[t].in_use)
|
||||
{
|
||||
log(0, 0, 0, 0, "Trying to destroy an in-use TBF %s\n", filter_buckets[t].handle);
|
||||
log(0, 0, 0, 0, "Trying to destroy an in-use HTB %s\n", filter_buckets[t].handle);
|
||||
return;
|
||||
}
|
||||
#ifdef TC_TBF
|
||||
snprintf(cmd, 2048, "tc qdisc del dev " DEVICE " handle %s", filter_buckets[t].handle);
|
||||
system(cmd);
|
||||
#endif
|
||||
#ifdef TC_HTB
|
||||
snprintf(cmd, 2048, "tc qdisc del dev " DEVICE " handle %s", filter_buckets[t].handle);
|
||||
system(cmd);
|
||||
#endif
|
||||
system("iptables -t mangle -D l2tpns -j throttle");
|
||||
system("iptables -t mangle -X throttle");
|
||||
system("iptables -t mangle -D l2tpns -j throttle 2>&1 >/dev/null");
|
||||
system("iptables -t mangle -X throttle 2>&1 >/dev/null");
|
||||
memset(filter_buckets[t].handle, 0, sizeof(filter_buckets[t].handle));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue