Purge through the control socket
authorScott Lamb <slamb@slamb.org>
Wed, 7 Nov 2007 02:49:57 +0000 (02:49 +0000)
committerScott Lamb <slamb@slamb.org>
Wed, 7 Nov 2007 02:49:57 +0000 (02:49 +0000)
doc/tinc.texi
doc/tincctl.8.in
doc/tincd.8.in
src/control.c
src/control_common.h
src/net.c
src/net.h
src/tincctl.c

index 541d2de..e953472 100644 (file)
@@ -1569,9 +1569,6 @@ New outgoing connections specified in @file{tinc.conf} will be made.
 Temporarily increases debug level to 5.
 Send this signal again to revert to the original level.
 
 Temporarily increases debug level to 5.
 Send this signal again to revert to the original level.
 
-@item WINCH
-Purges all information remembered about unreachable nodes.
-
 @end table
 
 @c ==================================================================
 @end table
 
 @c ==================================================================
@@ -1854,6 +1851,9 @@ Dump a list of all meta connections with ourself.
 @item dump graph
 Dump a graph of the VPN in dotty format.
 
 @item dump graph
 Dump a graph of the VPN in dotty format.
 
+@item purge
+Purges all information remembered about unreachable nodes.
+
 @end table
 
 
 @end table
 
 
index 734bb4f..40bd136 100644 (file)
@@ -76,6 +76,8 @@ Dump a list of all meta connections with ourself.
 Dump a graph of the VPN in
 .Xr dotty 1
 format.
 Dump a graph of the VPN in
 .Xr dotty 1
 format.
+.It purge
+Purges all information remembered about unreachable nodes.
 .El
 .Sh BUGS
 The "start", "restart", and "reload" commands are not yet implemented.
 .El
 .Sh BUGS
 The "start", "restart", and "reload" commands are not yet implemented.
index f136a1b..96c773f 100644 (file)
@@ -98,8 +98,6 @@ will be made.
 .It INT
 Temporarily increases debug level to 5.
 Send this signal again to revert to the original level.
 .It INT
 Temporarily increases debug level to 5.
 Send this signal again to revert to the original level.
-.It WINCH
-Purges all information remembered about unreachable nodes.
 .El
 .Sh DEBUG LEVELS
 The tinc daemon can send a lot of messages to the syslog.
 .El
 .Sh DEBUG LEVELS
 The tinc daemon can send a lot of messages to the syslog.
index 19ac37a..2c5d4be 100644 (file)
@@ -97,6 +97,12 @@ static void handle_control_data(struct bufferevent *event, void *data) {
                goto respond;
        }
 
                goto respond;
        }
 
+       if(req.type == REQ_PURGE) {
+               logger(LOG_NOTICE, _("Got '%s' command"), "purge");
+               purge();
+               goto respond;
+       }
+
        logger(LOG_DEBUG, _("Malformed control command received"));
        res.res_errno = EINVAL;
 
        logger(LOG_DEBUG, _("Malformed control command received"));
        res.res_errno = EINVAL;
 
index 750098e..bceaa71 100644 (file)
@@ -31,6 +31,7 @@ enum request_type {
        REQ_DUMP_SUBNETS,
        REQ_DUMP_CONNECTIONS,
        REQ_DUMP_GRAPH,
        REQ_DUMP_SUBNETS,
        REQ_DUMP_CONNECTIONS,
        REQ_DUMP_GRAPH,
+       REQ_PURGE,
 };
 
 #define TINC_CTL_VERSION_CURRENT 0
 };
 
 #define TINC_CTL_VERSION_CURRENT 0
index 1be4ed8..9d4a0a2 100644 (file)
--- a/src/net.c
+++ b/src/net.c
@@ -41,7 +41,7 @@
 
 /* Purge edges and subnets of unreachable nodes. Use carefully. */
 
 
 /* Purge edges and subnets of unreachable nodes. Use carefully. */
 
-static void purge(void) {
+void purge(void) {
        splay_node_t *nnode, *nnext, *enode, *enext, *snode, *snext;
        node_t *n;
        edge_t *e;
        splay_node_t *nnode, *nnext, *enode, *enext, *snode, *snext;
        node_t *n;
        edge_t *e;
@@ -252,11 +252,6 @@ static void sigint_handler(int signal, short events, void *data) {
        }
 }
 
        }
 }
 
-static void sigwinch_handler(int signal, short events, void *data) {
-       logger(LOG_NOTICE, _("Got %s signal"), strsignal(signal));
-       purge();
-}
-
 static void sighup_handler(int signal, short events, void *data) {
        connection_t *c;
        splay_node_t *node, *next;
 static void sighup_handler(int signal, short events, void *data) {
        connection_t *c;
        splay_node_t *node, *next;
@@ -333,7 +328,6 @@ int main_loop(void) {
        struct event sigint_event;
        struct event sigterm_event;
        struct event sigquit_event;
        struct event sigint_event;
        struct event sigterm_event;
        struct event sigquit_event;
-       struct event sigwinch_event;
        struct event sigalrm_event;
 
        cp();
        struct event sigalrm_event;
 
        cp();
@@ -348,8 +342,6 @@ int main_loop(void) {
        signal_add(&sigterm_event, NULL);
        signal_set(&sigquit_event, SIGQUIT, sigterm_handler, NULL);
        signal_add(&sigquit_event, NULL);
        signal_add(&sigterm_event, NULL);
        signal_set(&sigquit_event, SIGQUIT, sigterm_handler, NULL);
        signal_add(&sigquit_event, NULL);
-       signal_set(&sigwinch_event, SIGWINCH, sigwinch_handler, NULL);
-       signal_add(&sigwinch_event, NULL);
        signal_set(&sigalrm_event, SIGALRM, sigalrm_handler, NULL);
        signal_add(&sigalrm_event, NULL);
 
        signal_set(&sigalrm_event, SIGALRM, sigalrm_handler, NULL);
        signal_add(&sigalrm_event, NULL);
 
@@ -362,7 +354,6 @@ int main_loop(void) {
        signal_del(&sigint_event);
        signal_del(&sigterm_event);
        signal_del(&sigquit_event);
        signal_del(&sigint_event);
        signal_del(&sigterm_event);
        signal_del(&sigquit_event);
-       signal_del(&sigwinch_event);
        signal_del(&sigalrm_event);
        event_del(&timeout_event);
 
        signal_del(&sigalrm_event);
        event_del(&timeout_event);
 
index 943b7e6..fd14c37 100644 (file)
--- a/src/net.h
+++ b/src/net.h
@@ -126,7 +126,6 @@ extern listen_socket_t listen_socket[MAXSOCKETS];
 extern int listen_sockets;
 extern int keylifetime;
 extern bool do_prune;
 extern int listen_sockets;
 extern int keylifetime;
 extern bool do_prune;
-extern bool do_purge;
 extern char *myport;
 extern EVP_CIPHER_CTX packet_ctx;
 
 extern char *myport;
 extern EVP_CIPHER_CTX packet_ctx;
 
@@ -156,6 +155,7 @@ extern void send_mtu_probe(struct node_t *);
 extern void handle_device_data(int, short, void *);
 extern void handle_meta_connection_data(int, short, void *);
 extern void regenerate_key();
 extern void handle_device_data(int, short, void *);
 extern void handle_meta_connection_data(int, short, void *);
 extern void regenerate_key();
+extern void purge(void);
 
 #ifndef HAVE_MINGW
 #define closesocket(s) close(s)
 
 #ifndef HAVE_MINGW
 #define closesocket(s) close(s)
index 4982e6b..56179c6 100644 (file)
@@ -89,6 +89,7 @@ static void usage(bool status) {
                                "    subnets                  - all known subnets in the VPN\n"
                                "    connections              - all meta connections with ourself\n"
                                "    graph                    - graph of the VPN in dotty format\n"
                                "    subnets                  - all known subnets in the VPN\n"
                                "    connections              - all meta connections with ourself\n"
                                "    graph                    - graph of the VPN in dotty format\n"
+                               "  purge                      Purge unreachable nodes\n"
                                "\n"));
                printf(_("Report bugs to tinc@tinc-vpn.org.\n"));
        }
                                "\n"));
                printf(_("Report bugs to tinc@tinc-vpn.org.\n"));
        }
@@ -578,6 +579,10 @@ int main(int argc, char *argv[], char *envp[]) {
                return 1;
        }
 
                return 1;
        }
 
+       if(!strcasecmp(argv[optind], "purge")) {
+               return send_ctl_request_cooked(fd, REQ_PURGE, NULL, 0) != -1;
+       }
+
        fprintf(stderr, _("Unknown command `%s'.\n"), argv[optind]);
        usage(true);
        
        fprintf(stderr, _("Unknown command `%s'.\n"), argv[optind]);
        usage(true);