projects
/
l2tpns.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e5a7980
)
fold back in changes from production
author
Brendan O'Dea
<bod@optus.net>
Fri, 2 Jul 2004 07:30:43 +0000
(07:30 +0000)
committer
Brendan O'Dea
<bod@optus.net>
Fri, 2 Jul 2004 07:30:43 +0000
(07:30 +0000)
cli.c
patch
|
blob
|
history
cluster.c
patch
|
blob
|
history
diff --git
a/cli.c
b/cli.c
index
902add0
..
777a754
100644
(file)
--- a/
cli.c
+++ b/
cli.c
@@
-2,7
+2,7
@@
// vim: sw=4 ts=8
char const *cvs_name = "$Name: $";
// vim: sw=4 ts=8
char const *cvs_name = "$Name: $";
-char const *cvs_id_cli = "$Id: cli.c,v 1.
6 2004-06-28 02:43:13 fred_nerk
Exp $";
+char const *cvs_id_cli = "$Id: cli.c,v 1.
7 2004-07-02 07:30:43 bodea
Exp $";
#include <stdio.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdarg.h>
@@
-171,13
+171,13
@@
void init_cli()
c = cli_register_command(cli, NULL, "restart", NULL, PRIVILEGE_PRIVILEGED, MODE_EXEC, NULL);
cli_register_command(cli, c, "bgp", cmd_restart_bgp, PRIVILEGE_PRIVILEGED, MODE_EXEC, "Restart BGP");
c = cli_register_command(cli, NULL, "restart", NULL, PRIVILEGE_PRIVILEGED, MODE_EXEC, NULL);
cli_register_command(cli, c, "bgp", cmd_restart_bgp, PRIVILEGE_PRIVILEGED, MODE_EXEC, "Restart BGP");
- c = cli_register_command(cli, NULL, "load", NULL, PRIVILEGE_PRIVILEGED, MODE_
EXEC
, NULL);
- cli_register_command(cli, c, "plugin", cmd_load_plugin, PRIVILEGE_PRIVILEGED, MODE_
EXEC
, "Load a plugin");
+ c = cli_register_command(cli, NULL, "load", NULL, PRIVILEGE_PRIVILEGED, MODE_
CONFIG
, NULL);
+ cli_register_command(cli, c, "plugin", cmd_load_plugin, PRIVILEGE_PRIVILEGED, MODE_
CONFIG
, "Load a plugin");
- c = cli_register_command(cli, NULL, "remove", NULL, PRIVILEGE_PRIVILEGED, MODE_
EXEC
, NULL);
- cli_register_command(cli, c, "plugin", cmd_remove_plugin, PRIVILEGE_PRIVILEGED, MODE_
EXEC
, "Remove a plugin");
+ c = cli_register_command(cli, NULL, "remove", NULL, PRIVILEGE_PRIVILEGED, MODE_
CONFIG
, NULL);
+ cli_register_command(cli, c, "plugin", cmd_remove_plugin, PRIVILEGE_PRIVILEGED, MODE_
CONFIG
, "Remove a plugin");
- cli_register_command(cli, NULL, "set", cmd_set, PRIVILEGE_PRIVILEGED, MODE_
EXEC
, "Set a configuration variable");
+ cli_register_command(cli, NULL, "set", cmd_set, PRIVILEGE_PRIVILEGED, MODE_
CONFIG
, "Set a configuration variable");
// Enable regular processing
cli_regular(cli, regular_stuff);
// Enable regular processing
cli_regular(cli, regular_stuff);
@@
-204,9
+204,9
@@
void init_cli()
}
else
{
}
else
{
- cli_allow_user(cli, buf, p);
- log(3, 0, 0, 0, "Allowing user %s to connect to the CLI\n", buf);
- }
+
cli_allow_user(cli, buf, p);
+
log(3, 0, 0, 0, "Allowing user %s to connect to the CLI\n", buf);
+
}
}
fclose(f);
}
}
fclose(f);
}
@@
-331,7
+331,7
@@
void cli_do_file(FILE *fh)
{
log(3, 0, 0, 0, "Reading configuration file\n");
cli_print_callback(cli, cli_print_log);
{
log(3, 0, 0, 0, "Reading configuration file\n");
cli_print_callback(cli, cli_print_log);
- cli_file(cli, fh, PRIVILEGE_PRIVILEGED);
+ cli_file(cli, fh, PRIVILEGE_PRIVILEGED
, MODE_CONFIG
);
cli_print_callback(cli, NULL);
}
cli_print_callback(cli, NULL);
}
@@
-455,7
+455,7
@@
int cmd_show_session(struct cli_def *cli, char *command, char **argv, int argc)
(unsigned long)session[i].total_cout,
(unsigned long)session[i].total_cin,
abs(time_now - (session[i].last_packet ? session[i].last_packet : time_now)),
(unsigned long)session[i].total_cout,
(unsigned long)session[i].total_cin,
abs(time_now - (session[i].last_packet ? session[i].last_packet : time_now)),
-
tunnelip,
+ tunnelip,
session[i].calling[0] ? session[i].calling : "*");
if (userip) free(userip);
if (tunnelip) free(tunnelip);
session[i].calling[0] ? session[i].calling : "*");
if (userip) free(userip);
if (tunnelip) free(tunnelip);
@@
-1009,9
+1009,10
@@
int cmd_drop_user(struct cli_def *cli, char *command, char **argv, int argc)
if (!config->cluster_iam_master)
{
if (!config->cluster_iam_master)
{
- cli_print(cli, "Can't do this on a slave. Do it on %s", inet_toa(config->cluster_master_address));
+ cli_print(cli, "Can't do this on a slave.
Do it on %s", inet_toa(config->cluster_master_address));
return CLI_OK;
}
return CLI_OK;
}
+
if (!argc)
{
cli_print(cli, "Specify a user to drop");
if (!argc)
{
cli_print(cli, "Specify a user to drop");
@@
-1056,9
+1057,10
@@
int cmd_drop_tunnel(struct cli_def *cli, char *command, char **argv, int argc)
if (!config->cluster_iam_master)
{
if (!config->cluster_iam_master)
{
- cli_print(cli, "Can't do this on a slave. Do it on %s", inet_toa(config->cluster_master_address));
+ cli_print(cli, "Can't do this on a slave.
Do it on %s", inet_toa(config->cluster_master_address));
return CLI_OK;
}
return CLI_OK;
}
+
if (!argc)
{
cli_print(cli, "Specify a tunnel to drop");
if (!argc)
{
cli_print(cli, "Specify a tunnel to drop");
@@
-1112,9
+1114,10
@@
int cmd_drop_session(struct cli_def *cli, char *command, char **argv, int argc)
if (!config->cluster_iam_master)
{
if (!config->cluster_iam_master)
{
- cli_print(cli, "Can't do this on a slave. Do it on %s", inet_toa(config->cluster_master_address));
+ cli_print(cli, "Can't do this on a slave.
Do it on %s", inet_toa(config->cluster_master_address));
return CLI_OK;
}
return CLI_OK;
}
+
if (!argc)
{
cli_print(cli, "Specify a session id to drop");
if (!argc)
{
cli_print(cli, "Specify a session id to drop");
@@
-1232,7
+1235,7
@@
int cmd_no_snoop(struct cli_def *cli, char *command, char **argv, int argc)
if (!config->cluster_iam_master)
{
if (!config->cluster_iam_master)
{
- cli_print(cli, "Can't do this on a slave. Do it on %s", inet_toa(config->cluster_master_address));
+ cli_print(cli, "Can't do this on a slave.
Do it on %s", inet_toa(config->cluster_master_address));
return CLI_OK;
}
return CLI_OK;
}
@@
-1268,9
+1271,10
@@
int cmd_throttle(struct cli_def *cli, char *command, char **argv, int argc)
if (!config->cluster_iam_master)
{
if (!config->cluster_iam_master)
{
- cli_print(cli, "Can't do this on a slave. Do it on %s", inet_toa(config->cluster_master_address));
+ cli_print(cli, "Can't do this on a slave.
Do it on %s", inet_toa(config->cluster_master_address));
return CLI_OK;
}
return CLI_OK;
}
+
if (!argc)
{
cli_print(cli, "Specify a user");
if (!argc)
{
cli_print(cli, "Specify a user");
@@
-1289,6
+1293,7
@@
int cmd_throttle(struct cli_def *cli, char *command, char **argv, int argc)
else
cli_print(cli, "Throttling user %s", argv[i]);
}
else
cli_print(cli, "Throttling user %s", argv[i]);
}
+
return CLI_OK;
}
return CLI_OK;
}
@@
-1303,9
+1308,10
@@
int cmd_no_throttle(struct cli_def *cli, char *command, char **argv, int argc)
if (!config->cluster_iam_master)
{
if (!config->cluster_iam_master)
{
- cli_print(cli, "Can't do this on a slave. Do it on %s", inet_toa(config->cluster_master_address));
+ cli_print(cli, "Can't do this on a slave.
Do it on %s", inet_toa(config->cluster_master_address));
return CLI_OK;
}
return CLI_OK;
}
+
if (!argc)
{
cli_print(cli, "Specify a user");
if (!argc)
{
cli_print(cli, "Specify a user");
@@
-1346,9
+1352,9
@@
int cmd_debug(struct cli_def *cli, char *command, char **argv, int argc)
{
char *p = (char *) &debug_flags;
for (i = 0; i < sizeof(debug_flags); i++)
{
char *p = (char *) &debug_flags;
for (i = 0; i < sizeof(debug_flags); i++)
- {
- if (p[i])
{
{
+ if (p[i])
+ {
cli_print(cli, "Currently debugging:%s%s%s%s%s%s",
(debug_flags.critical) ? " critical" : "",
(debug_flags.error) ? " error" : "",
cli_print(cli, "Currently debugging:%s%s%s%s%s%s",
(debug_flags.critical) ? " critical" : "",
(debug_flags.error) ? " error" : "",
@@
-1357,9
+1363,9
@@
int cmd_debug(struct cli_def *cli, char *command, char **argv, int argc)
(debug_flags.calls) ? " calls" : "",
(debug_flags.data) ? " data" : "");
(debug_flags.calls) ? " calls" : "",
(debug_flags.data) ? " data" : "");
- return CLI_OK;
+ return CLI_OK;
+ }
}
}
- }
cli_print(cli, "Debugging off");
return CLI_OK;
cli_print(cli, "Debugging off");
return CLI_OK;
diff --git
a/cluster.c
b/cluster.c
index
4c4efde
..
3e40d45
100644
(file)
--- a/
cluster.c
+++ b/
cluster.c
@@
-1,6
+1,6
@@
// L2TPNS Clustering Stuff
// L2TPNS Clustering Stuff
-char const *cvs_id_cluster = "$Id: cluster.c,v 1.
4 2004-06-28 02:43:13 fred_nerk
Exp $";
+char const *cvs_id_cluster = "$Id: cluster.c,v 1.
5 2004-07-02 07:30:43 bodea
Exp $";
#include <stdio.h>
#include <sys/file.h>
#include <stdio.h>
#include <sys/file.h>
@@
-343,6
+343,7
@@
static void send_heartbeat(int seq, char * data, int size)
if (size > sizeof(past_hearts[0].data)) {
log(0,0,0,0, "Tried to heartbeat something larger than the maximum packet!\n");
kill(0, SIGTERM);
if (size > sizeof(past_hearts[0].data)) {
log(0,0,0,0, "Tried to heartbeat something larger than the maximum packet!\n");
kill(0, SIGTERM);
+ exit(1);
}
i = seq % HB_HISTORY_SIZE;
past_hearts[i].seq = seq;
}
i = seq % HB_HISTORY_SIZE;
past_hearts[i].seq = seq;
@@
-770,8
+771,8
@@
void cluster_heartbeat(int highsession, int freesession, int hightunnel)
kill(0, SIGTERM);
}
kill(0, SIGTERM);
}
- log(3,0,0,0, "Sending heartbeat with %d changes (%d x-sess, %d x-tunnels, %d highsess, %d hightun size %d)\n",
- config->cluster_num_changes, count, tcount, config->cluster_highest_sessionid,
+ log(3,0,0,0, "Sending heartbeat
#%d
with %d changes (%d x-sess, %d x-tunnels, %d highsess, %d hightun size %d)\n",
+
h.seq,
config->cluster_num_changes, count, tcount, config->cluster_highest_sessionid,
config->cluster_highest_tunnelid, (p-buff));
config->cluster_num_changes = 0;
config->cluster_highest_tunnelid, (p-buff));
config->cluster_num_changes = 0;
@@
-1068,16
+1069,18
@@
static int cluster_process_heartbeat_v2(u8 * data, int size, int more, u8 * p, u
log(0,0,0,0, "I just got a packet claiming to be from a master but _I_ am the master!\n");
if (!h->basetime) {
log(0,0,0,0, "I just got a packet claiming to be from a master but _I_ am the master!\n");
if (!h->basetime) {
- log(0,0,0,0, "Heartbeat from addr %s with zero basetime!\n", inet_toa(
htonl(addr)
) );
+ log(0,0,0,0, "Heartbeat from addr %s with zero basetime!\n", inet_toa(
addr
) );
return -1; // Skip it.
}
if (basetime > h->basetime) {
return -1; // Skip it.
}
if (basetime > h->basetime) {
- log(0,0,0,0, "They're (%s) an older master than me so I'm gone!\n", inet_toa(
htonl(addr)
));
+ log(0,0,0,0, "They're (%s) an older master than me so I'm gone!\n", inet_toa(
addr
));
kill(0, SIGTERM);
kill(0, SIGTERM);
+ exit(1);
}
if (basetime == h->basetime && my_address < addr) { // Tie breaker.
log(0,0,0,0, "They're a higher IP address than me, so I'm gone!\n");
kill(0, SIGTERM);
}
if (basetime == h->basetime && my_address < addr) { // Tie breaker.
log(0,0,0,0, "They're a higher IP address than me, so I'm gone!\n");
kill(0, SIGTERM);
+ exit(1);
}
return -1; // Skip it.
}
}
return -1; // Skip it.
}