Cleanups and sync

This commit is contained in:
David Parrish 2004-09-02 04:18:07 +00:00
parent 133cc062ad
commit d52f68e6d3
12 changed files with 1008 additions and 997 deletions

View file

@ -3,4 +3,5 @@ l2tpns
nsctl nsctl
state.dump state.dump
*.swp *.swp
cluster_master bounce
generateload

View file

@ -15,6 +15,7 @@
- Per-user upload and download throttle rates - Yuri - Per-user upload and download throttle rates - Yuri
- Make autothrottle.so understand cisco lcp:interface-config - Yuri - Make autothrottle.so understand cisco lcp:interface-config - Yuri
- Show filter stats in show session - Yuri - Show filter stats in show session - Yuri
- Cleanup from Michael to change sid to unique_id
* Tue Jul 13 2004 Brendan O'Dea <bod@optusnet.com.au> 2.0.1 * Tue Jul 13 2004 Brendan O'Dea <bod@optusnet.com.au> 2.0.1
- Update INSTALL, Docs/manual.html documentation. - Update INSTALL, Docs/manual.html documentation.

11
bgp.c
View file

@ -10,7 +10,7 @@
* nor RFC2385 (which requires a kernel patch on 2.4 kernels). * nor RFC2385 (which requires a kernel patch on 2.4 kernels).
*/ */
char const *cvs_id_bgp = "$Id: bgp.c,v 1.3 2004-08-13 00:02:50 fred_nerk Exp $"; char const *cvs_id_bgp = "$Id: bgp.c,v 1.4 2004-09-02 04:18:07 fred_nerk Exp $";
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
@ -63,7 +63,8 @@ int bgp_setup(int as)
peer->sock = -1; peer->sock = -1;
peer->state = peer->next_state = Disabled; peer->state = peer->next_state = Disabled;
if (!((peer->outbuf = malloc(sizeof(*peer->outbuf))) && (peer->inbuf = malloc(sizeof(*peer->inbuf))))) if (!((peer->outbuf = malloc(sizeof(*peer->outbuf)))
&& (peer->inbuf = malloc(sizeof(*peer->inbuf)))))
{ {
log(0, 0, 0, 0, "Can't allocate buffers for bgp peer (%s)\n", log(0, 0, 0, 0, "Can't allocate buffers for bgp peer (%s)\n",
strerror(errno)); strerror(errno));
@ -107,7 +108,8 @@ int bgp_start(struct bgp_peer *peer, char *name, int as, int enable)
if (!(h = gethostbyname(name)) || h->h_addrtype != AF_INET) if (!(h = gethostbyname(name)) || h->h_addrtype != AF_INET)
{ {
log(0, 0, 0, 0, "Can't get address for BGP peer %s (%s)\n", name, h ? "no address" : hstrerror(h_errno)); log(0, 0, 0, 0, "Can't get address for BGP peer %s (%s)\n",
name, h ? "no address" : hstrerror(h_errno));
return 0; return 0;
} }
@ -1318,7 +1320,8 @@ int cmd_restart_bgp(struct cli_def *cli, char *command, char **argv, int argc)
continue; continue;
addr = inet_toa(bgp_peers[i].addr); addr = inet_toa(bgp_peers[i].addr);
if (argc && strcmp(addr, argv[0]) && strncmp(bgp_peers[i].name, argv[0], strlen(argv[0]))) if (argc && strcmp(addr, argv[0]) &&
strncmp(bgp_peers[i].name, argv[0], strlen(argv[0])))
continue; continue;
bgp_peers[i].cli_flag = BGP_CLI_RESTART; bgp_peers[i].cli_flag = BGP_CLI_RESTART;

4
cli.c
View file

@ -2,7 +2,7 @@
// vim: sw=8 ts=8 // vim: sw=8 ts=8
char const *cvs_name = "$Name: $"; char const *cvs_name = "$Name: $";
char const *cvs_id_cli = "$Id: cli.c,v 1.14 2004-08-26 06:24:12 fred_nerk Exp $"; char const *cvs_id_cli = "$Id: cli.c,v 1.15 2004-09-02 04:18:07 fred_nerk Exp $";
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
@ -397,7 +397,7 @@ int cmd_show_session(struct cli_def *cli, char *command, char **argv, int argc)
cli_print(cli, " Called Num: %s", session[s].called); cli_print(cli, " Called Num: %s", session[s].called);
cli_print(cli, " Tunnel ID: %d", session[s].tunnel); cli_print(cli, " Tunnel ID: %d", session[s].tunnel);
cli_print(cli, " IP address: %s", inet_toa(htonl(session[s].ip))); cli_print(cli, " IP address: %s", inet_toa(htonl(session[s].ip)));
cli_print(cli, " HSD sid: %lu", session[s].sid); cli_print(cli, " Unique SID: %lu", session[s].unique_id);
cli_print(cli, " Idle time: %u seconds", abs(time_now - session[s].last_packet)); cli_print(cli, " Idle time: %u seconds", abs(time_now - session[s].last_packet));
cli_print(cli, " Next Recv: %u", session[s].nr); cli_print(cli, " Next Recv: %u", session[s].nr);
cli_print(cli, " Next Send: %u", session[s].ns); cli_print(cli, " Next Send: %u", session[s].ns);

View file

@ -1,6 +1,6 @@
// L2TPNS Clustering Stuff // L2TPNS Clustering Stuff
char const *cvs_id_cluster = "$Id: cluster.c,v 1.10 2004-08-02 06:06:28 fred_nerk Exp $"; char const *cvs_id_cluster = "$Id: cluster.c,v 1.11 2004-09-02 04:18:07 fred_nerk Exp $";
#include <stdio.h> #include <stdio.h>
#include <sys/file.h> #include <sys/file.h>
@ -470,7 +470,7 @@ void cluster_check_slaves(void)
// //
void cluster_check_master(void) void cluster_check_master(void)
{ {
int i, count, tcount, high_sid = 0; int i, count, tcount, high_unique_id = 0;
int last_free = 0; int last_free = 0;
clockt t = TIME; clockt t = TIME;
static int probed = 0; static int probed = 0;
@ -557,7 +557,7 @@ void cluster_check_master(void)
// Re-string the free list. // Re-string the free list.
// Find the ID of the highest session. // Find the ID of the highest session.
last_free = 0; last_free = 0;
high_sid = 0; high_unique_id = 0;
config->cluster_highest_sessionid = 0; config->cluster_highest_sessionid = 0;
for (i = 0, count = 0; i < MAXSESSION; ++i) { for (i = 0, count = 0; i < MAXSESSION; ++i) {
if (session[i].tunnel == T_UNDEF) { if (session[i].tunnel == T_UNDEF) {
@ -584,8 +584,8 @@ void cluster_check_master(void)
session[i].radius = 0; // Reset authentication as the radius blocks aren't up to date. session[i].radius = 0; // Reset authentication as the radius blocks aren't up to date.
if (session[i].sid >= high_sid) // This is different to the index into the session table!!! if (session[i].unique_id >= high_unique_id) // This is different to the index into the session table!!!
high_sid = session[i].sid+1; high_unique_id = session[i].unique_id+1;
session[i].tbf_in = session[i].tbf_out = 0; // Remove stale pointers from old master. session[i].tbf_in = session[i].tbf_out = 0; // Remove stale pointers from old master.
@ -603,7 +603,7 @@ void cluster_check_master(void)
} }
session[last_free].next = 0; // End of chain. session[last_free].next = 0; // End of chain.
last_sid = high_sid; // Keep track of the highest used session ID. last_id = high_unique_id; // Keep track of the highest used session ID.
become_master(); become_master();
@ -1389,7 +1389,7 @@ int processcluster(char * data, int size, u32 addr)
return 0; return 0;
shortpacket: shortpacket:
log(0,0,0,0, "I got an cluster heartbeat packet! This means I'm probably out of sync!!\n"); log(0,0,0,0, "I got a _short_ cluster heartbeat packet! This means I'm probably out of sync!!\n");
return -1; return -1;
} }

View file

@ -4,7 +4,7 @@
// Copyright (c) 2002 FireBrick (Andrews & Arnold Ltd / Watchfront Ltd) - GPL licenced // Copyright (c) 2002 FireBrick (Andrews & Arnold Ltd / Watchfront Ltd) - GPL licenced
// vim: sw=8 ts=8 // vim: sw=8 ts=8
char const *cvs_id_l2tpns = "$Id: l2tpns.c,v 1.24 2004-08-26 06:22:37 fred_nerk Exp $"; char const *cvs_id_l2tpns = "$Id: l2tpns.c,v 1.25 2004-09-02 04:18:07 fred_nerk Exp $";
#include <arpa/inet.h> #include <arpa/inet.h>
#include <assert.h> #include <assert.h>
@ -63,7 +63,7 @@ u32 sessionid = 0; // session id for radius accounting
int syslog_log = 0; // are we logging to syslog int syslog_log = 0; // are we logging to syslog
FILE *log_stream = NULL; // file handle for direct logging (i.e. direct into file, not via syslog). FILE *log_stream = NULL; // file handle for direct logging (i.e. direct into file, not via syslog).
extern int cluster_sockfd; // Intra-cluster communications socket. extern int cluster_sockfd; // Intra-cluster communications socket.
u32 last_sid = 0; // Last used PPP SID. Can I kill this?? -- mo u32 last_id = 0; // Last used PPP SID. Can I kill this?? -- mo
int clifd = 0; // Socket listening for CLI connections. int clifd = 0; // Socket listening for CLI connections.
struct cli_session_actions *cli_session_actions = NULL; // Pending session changes requested by CLI struct cli_session_actions *cli_session_actions = NULL; // Pending session changes requested by CLI
@ -1811,7 +1811,7 @@ void processudp(u8 * buf, int len, struct sockaddr_in *addr)
// TBA // TBA
break; break;
case 12: // ICCN case 12: // ICCN
if ( amagic == 0) amagic = time_now; if (amagic == 0) amagic = time_now;
session[s].magic = amagic; // set magic number session[s].magic = amagic; // set magic number
session[s].l2tp_flags = aflags; // set flags received session[s].l2tp_flags = aflags; // set flags received
log(3, ntohl(addr->sin_addr.s_addr), s, t, "Magic %X Flags %X\n", amagic, aflags); log(3, ntohl(addr->sin_addr.s_addr), s, t, "Magic %X Flags %X\n", amagic, aflags);
@ -2449,74 +2449,69 @@ void initdata(void)
{ {
int i; int i;
_statistics = mmap(NULL, sizeof(struct Tstats), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); if ((_statistics = shared_malloc(sizeof(struct Tstats))) == MAP_FAILED)
if (_statistics == MAP_FAILED)
{ {
log(0, 0, 0, 0, "Error doing mmap for _statistics: %s\n", strerror(errno)); log(0, 0, 0, 0, "Error doing malloc for _statistics: %s\n", strerror(errno));
exit(1); exit(1);
} }
config = mmap(NULL, sizeof(struct configt), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); if ((config = shared_malloc(sizeof(struct configt))) == MAP_FAILED)
if (config == MAP_FAILED)
{ {
log(0, 0, 0, 0, "Error doing mmap for configuration: %s\n", strerror(errno)); log(0, 0, 0, 0, "Error doing malloc for configuration: %s\n", strerror(errno));
exit(1); exit(1);
} }
memset(config, 0, sizeof(struct configt)); memset(config, 0, sizeof(struct configt));
time(&config->start_time); time(&config->start_time);
strncpy(config->config_file, CONFIGFILE, sizeof(config->config_file) - 1); strncpy(config->config_file, CONFIGFILE, sizeof(config->config_file) - 1);
tunnel = mmap(NULL, sizeof(tunnelt) * MAXTUNNEL, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); if ((tunnel = shared_malloc(sizeof(tunnelt) * MAXTUNNEL)) == MAP_FAILED);
if (tunnel == MAP_FAILED)
{ {
log(0, 0, 0, 0, "Error doing mmap for tunnels: %s\n", strerror(errno)); log(0, 0, 0, 0, "Error doing malloc for tunnels: %s\n", strerror(errno));
exit(1); exit(1);
} }
session = mmap(NULL, sizeof(sessiont) * MAXSESSION, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); if ((session = shared_malloc(sizeof(sessiont) * MAXSESSION)) == MAP_FAILED)
if (session == MAP_FAILED)
{ {
log(0, 0, 0, 0, "Error doing mmap for sessions: %s\n", strerror(errno)); log(0, 0, 0, 0, "Error doing malloc for sessions: %s\n", strerror(errno));
exit(1); exit(1);
} }
sess_count = mmap(NULL, sizeof(sessioncountt) * MAXSESSION, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); if ((sess_count = shared_malloc(sizeof(sessioncountt) * MAXSESSION)) == MAP_FAILED)
if (sess_count == MAP_FAILED)
{ {
log(0, 0, 0, 0, "Error doing mmap for sessions_count: %s\n", strerror(errno)); log(0, 0, 0, 0, "Error doing malloc for sessions_count: %s\n", strerror(errno));
exit(1); exit(1);
} }
radius = mmap(NULL, sizeof(radiust) * MAXRADIUS, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); if ((radius = shared_malloc(sizeof(radiust) * MAXRADIUS)) == MAP_FAILED)
if (radius == MAP_FAILED)
{ {
log(0, 0, 0, 0, "Error doing mmap for radius: %s\n", strerror(errno)); log(0, 0, 0, 0, "Error doing malloc for radius: %s\n", strerror(errno));
exit(1); exit(1);
} }
ip_address_pool = mmap(NULL, sizeof(ippoolt) * MAXIPPOOL, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0);
if (ip_address_pool == MAP_FAILED) if ((ip_address_pool = shared_malloc(sizeof(ippoolt) * MAXIPPOOL)) == MAP_FAILED)
{ {
log(0, 0, 0, 0, "Error doing mmap for ip_address_pool: %s\n", strerror(errno)); log(0, 0, 0, 0, "Error doing malloc for ip_address_pool: %s\n", strerror(errno));
exit(1); exit(1);
} }
#ifdef RINGBUFFER #ifdef RINGBUFFER
ringbuffer = mmap(NULL, sizeof(struct Tringbuffer), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); if ((ringbuffer = shared_malloc(sizeof(struct Tringbuffer))) == MAP_FAILED)
if (ringbuffer == MAP_FAILED)
{ {
log(0, 0, 0, 0, "Error doing mmap for ringbuffer: %s\n", strerror(errno)); log(0, 0, 0, 0, "Error doing malloc for ringbuffer: %s\n", strerror(errno));
exit(1); exit(1);
} }
memset(ringbuffer, 0, sizeof(struct Tringbuffer)); memset(ringbuffer, 0, sizeof(struct Tringbuffer));
#endif #endif
cli_session_actions = mmap(NULL, sizeof(struct cli_session_actions) * MAXSESSION, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); if ((cli_session_actions = shared_malloc(sizeof(struct cli_session_actions) * MAXSESSION))
if (cli_session_actions == MAP_FAILED) == MAP_FAILED)
{ {
log(0, 0, 0, 0, "Error doing mmap for cli session actions: %s\n", strerror(errno)); log(0, 0, 0, 0, "Error doing malloc for cli session actions: %s\n", strerror(errno));
exit(1); exit(1);
} }
memset(cli_session_actions, 0, sizeof(struct cli_session_actions) * MAXSESSION); memset(cli_session_actions, 0, sizeof(struct cli_session_actions) * MAXSESSION);
cli_tunnel_actions = mmap(NULL, sizeof(struct cli_tunnel_actions) * MAXSESSION, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0);
if (cli_tunnel_actions == MAP_FAILED) if ((cli_tunnel_actions = shared_malloc(sizeof(struct cli_tunnel_actions) * MAXSESSION))
== MAP_FAILED)
{ {
log(0, 0, 0, 0, "Error doing mmap for cli tunnel actions: %s\n", strerror(errno)); log(0, 0, 0, 0, "Error doing malloc for cli tunnel actions: %s\n", strerror(errno));
exit(1); exit(1);
} }
memset(cli_tunnel_actions, 0, sizeof(struct cli_tunnel_actions) * MAXSESSION); memset(cli_tunnel_actions, 0, sizeof(struct cli_tunnel_actions) * MAXSESSION);
@ -2549,10 +2544,9 @@ void initdata(void)
_statistics->start_time = _statistics->last_reset = time(NULL); _statistics->start_time = _statistics->last_reset = time(NULL);
#ifdef BGP #ifdef BGP
bgp_peers = mmap(NULL, sizeof(struct bgp_peer) * BGP_NUM_PEERS, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); if ((bgp_peers = shared_malloc(sizeof(struct bgp_peer) * BGP_NUM_PEERS)) == MAP_FAILED)
if (bgp_peers == MAP_FAILED)
{ {
log(0, 0, 0, 0, "Error doing mmap for bgp: %s\n", strerror(errno)); log(0, 0, 0, 0, "Error doing malloc for bgp: %s\n", strerror(errno));
exit(1); exit(1);
} }
#endif /* BGP */ #endif /* BGP */
@ -3567,12 +3561,12 @@ int sessionsetup(tunnelidt t, sessionidt s)
for (r = 0; r < MAXROUTE && session[s].route[r].ip; r++) for (r = 0; r < MAXROUTE && session[s].route[r].ip; r++)
routeset(s, session[s].route[r].ip, session[s].route[r].mask, session[s].ip, 1); routeset(s, session[s].route[r].ip, session[s].route[r].mask, session[s].ip, 1);
if (!session[s].sid) if (!session[s].unique_id)
{ {
// did this session just finish radius? // did this session just finish radius?
log(3, session[s].ip, s, t, "Sending initial IPCP to client\n"); log(3, session[s].ip, s, t, "Sending initial IPCP to client\n");
sendipcp(t, s); sendipcp(t, s);
session[s].sid = ++last_sid; session[s].unique_id = ++last_id;
} }
// Run the plugin's against this new session. // Run the plugin's against this new session.

View file

@ -1,5 +1,5 @@
// L2TPNS Global Stuff // L2TPNS Global Stuff
// $Id: l2tpns.h,v 1.16 2004-08-26 04:44:26 fred_nerk Exp $ // $Id: l2tpns.h,v 1.17 2004-09-02 04:18:07 fred_nerk Exp $
#ifndef __L2TPNS_H__ #ifndef __L2TPNS_H__
#define __L2TPNS_H__ #define __L2TPNS_H__
@ -24,7 +24,7 @@
#define RADIUS_SHIFT 5 #define RADIUS_SHIFT 5
#define RADIUS_MASK ((unsigned short)(((unsigned short)~0) >> (16 - RADIUS_SHIFT))) #define RADIUS_MASK ((unsigned short)(((unsigned short)~0) >> (16 - RADIUS_SHIFT)))
#define MAXRADIUS ((2 << (RADIUS_SHIFT - 1)) * 255) #define MAXRADIUS ((unsigned long)(1L << RADIUS_SHIFT) * 255)
#define T_UNDEF (0xffff) // A tunnel ID that won't ever be used. Mark session as undefined. #define T_UNDEF (0xffff) // A tunnel ID that won't ever be used. Mark session as undefined.
#define T_FREE (0) // A tunnel ID that won't ever be used. Mark session as free. #define T_FREE (0) // A tunnel ID that won't ever be used. Mark session as free.
@ -149,10 +149,10 @@ typedef struct sessions
{ {
sessionidt next; // next session in linked list sessionidt next; // next session in linked list
sessionidt far; // far end session ID sessionidt far; // far end session ID
tunnelidt tunnel; // tunnel ID tunnelidt tunnel; // near end tunnel ID
ipt ip; // IP of session set by RADIUS response (host byte order). ipt ip; // IP of session set by RADIUS response (host byte order).
int ip_pool_index; // index to IP pool int ip_pool_index; // index to IP pool
unsigned long sid; // session id for hsddb unsigned long unique_id; // unique session id
u16 nr; // next receive u16 nr; // next receive
u16 ns; // next send u16 ns; // next send
u32 magic; // ppp magic number u32 magic; // ppp magic number
@ -172,6 +172,7 @@ typedef struct sessions
u16 tbf_in; // filter bucket for throttling in from the user. u16 tbf_in; // filter bucket for throttling in from the user.
u16 tbf_out; // filter bucket for throttling out to the user. u16 tbf_out; // filter bucket for throttling out to the user.
u8 l2tp_flags; // various bit flags from the ICCN on the l2tp tunnel. u8 l2tp_flags; // various bit flags from the ICCN on the l2tp tunnel.
u8 reserved_old_snoop; // No longer used - remove at some time
u8 walled_garden; // is this session gardened? u8 walled_garden; // is this session gardened?
u8 flags1; // additional flags (currently unused); u8 flags1; // additional flags (currently unused);
char random_vector[MAXTEL]; char random_vector[MAXTEL];
@ -184,7 +185,8 @@ typedef struct sessions
u32 flags; // Various session flags. u32 flags; // Various session flags.
ipt snoop_ip; // Interception destination IP ipt snoop_ip; // Interception destination IP
u16 snoop_port; // Interception destination port u16 snoop_port; // Interception destination port
char reserved[28]; // Space to expand structure without changing HB_VERSION u16 sid; // near end session id.
char reserved[20]; // Space to expand structure without changing HB_VERSION
} }
sessiont; sessiont;
@ -589,7 +591,7 @@ if (count++ < max) { \
extern struct configt *config; extern struct configt *config;
extern time_t basetime; // Time when this process started. extern time_t basetime; // Time when this process started.
extern time_t time_now; // Seconds since EPOCH. extern time_t time_now; // Seconds since EPOCH.
extern u32 last_sid; extern u32 last_id;
extern struct Tstats *_statistics; extern struct Tstats *_statistics;
extern ipt my_address; extern ipt my_address;
extern int tun_write(u8 *data, int size); extern int tun_write(u8 *data, int size);

5
ppp.c
View file

@ -1,6 +1,6 @@
// L2TPNS PPP Stuff // L2TPNS PPP Stuff
char const *cvs_id_ppp = "$Id: ppp.c,v 1.13 2004-08-26 04:44:26 fred_nerk Exp $"; char const *cvs_id_ppp = "$Id: ppp.c,v 1.14 2004-09-02 04:18:07 fred_nerk Exp $";
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -676,7 +676,7 @@ void processipin(tunnelidt t, sessionidt s, u8 * p, u16 l)
if (session[s].snoop_ip && session[s].snoop_port) if (session[s].snoop_ip && session[s].snoop_port)
{ {
// Snooping this session, send it to ASIO // Snooping this session
snoop_send_packet(p, l, session[s].snoop_ip, session[s].snoop_port); snoop_send_packet(p, l, session[s].snoop_ip, session[s].snoop_port);
} }
STAT(tun_tx_packets); STAT(tun_tx_packets);
@ -814,7 +814,6 @@ void sendchap(tunnelidt t, sessionidt s)
// returns start of PPP frame // returns start of PPP frame
u8 *makeppp(u8 * b, int size, u8 * p, int l, tunnelidt t, sessionidt s, u16 mtype) u8 *makeppp(u8 * b, int size, u8 * p, int l, tunnelidt t, sessionidt s, u16 mtype)
{ {
if (size < 12) if (size < 12)
return NULL; // Need more space than this!! return NULL; // Need more space than this!!

View file

@ -1,6 +1,6 @@
// L2TPNS Radius Stuff // L2TPNS Radius Stuff
char const *cvs_id_radius = "$Id: radius.c,v 1.9 2004-07-26 00:20:41 fred_nerk Exp $"; char const *cvs_id_radius = "$Id: radius.c,v 1.10 2004-09-02 04:18:07 fred_nerk Exp $";
#include <time.h> #include <time.h>
#include <stdio.h> #include <stdio.h>
@ -606,7 +606,7 @@ void processrad(u8 *buf, int len, char socket_index)
} }
// Valid Session, set it up // Valid Session, set it up
session[s].sid = 0; session[s].unique_id = 0;
sessionsetup(t, s); sessionsetup(t, s);
} }
else else

5
tbf.c
View file

@ -1,6 +1,6 @@
// L2TPNS: token bucket filters // L2TPNS: token bucket filters
char const *cvs_id_tbf = "$Id: tbf.c,v 1.5 2004-08-26 06:22:37 fred_nerk Exp $"; char const *cvs_id_tbf = "$Id: tbf.c,v 1.6 2004-09-02 04:18:07 fred_nerk Exp $";
#define _GNU_SOURCE #define _GNU_SOURCE
@ -21,8 +21,7 @@ static void tbf_run_queue(int tbf_id);
void init_tbf(void) void init_tbf(void)
{ {
filter_list = mmap(NULL, sizeof(*filter_list) * MAXTBFS, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); if ((filter_list = shared_malloc(sizeof(*filter_list) * MAXTBFS)) == MAP_FAILED)
if (!filter_list)
return; return;
filter_list_size = MAXTBFS; filter_list_size = MAXTBFS;

13
util.c
View file

@ -1,6 +1,6 @@
/* Misc util functions */ /* Misc util functions */
char const *cvs_id_util = "$Id: util.c,v 1.2 2004-06-28 02:43:13 fred_nerk Exp $"; char const *cvs_id_util = "$Id: util.c,v 1.3 2004-09-02 04:18:07 fred_nerk Exp $";
#include "l2tpns.h" #include "l2tpns.h"
@ -8,6 +8,7 @@ char const *cvs_id_util = "$Id: util.c,v 1.2 2004-06-28 02:43:13 fred_nerk Exp $
#include <netinet/in.h> #include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <string.h> #include <string.h>
#include <sys/mman.h>
char *inet_toa(unsigned long addr) char *inet_toa(unsigned long addr)
{ {
@ -16,3 +17,13 @@ char *inet_toa(unsigned long addr)
return inet_ntoa(in); return inet_ntoa(in);
} }
void *shared_malloc(unsigned int size)
{
void * p;
p = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0);
if (p == MAP_FAILED)
p = NULL;
return p;
}

1
util.h
View file

@ -2,5 +2,6 @@
#define __UTIL_H__ #define __UTIL_H__
char *inet_toa(unsigned long addr); char *inet_toa(unsigned long addr);
void *shared_malloc(unsigned int size);
#endif /* __UTIL_H__ */ #endif /* __UTIL_H__ */