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 541d2de76da7d1c3fb112a5a759f7eb0a2b891f7..e9534728fdff9d1ae7c42542645dcdcb8df1a352 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 734bb4f5be892be5f95d91a1d29f5c06ad42c702..40bd13618720b3eb04aa543114e2d165d722f86a 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 f136a1bc7482bf7d08855cdfb7cdc3e51bac9199..96c773f15ec0884c63cfa70709da662c72eb901a 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 19ac37a4dd23857200ccd4ca84e91314086afc81..2c5d4be847eba078069795c134f4cce929ff2d64 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 750098e3515523892a29fa74ffdb8a4e2b690360..bceaa7106ebfce0a7cb519755618d8e46b685c88 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 1be4ed84db2e1cc3d3449f8152cc870434001893..9d4a0a2bf6e7bd889fff7b8d554bc9141feb7c56 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 943b7e61097f8f20b7d7260054d6524acad79d1e..fd14c37b37148f7a1c621b43e20b7295925622d3 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 4982e6b25fe3fb2f6773e5b24c8afb98d0a2a30f..56179c6ec19d3576246463c54493b80220cd2c3f 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);