Fix deletion of routing policy rules when terminating due to a signal
[project/relayd.git] / main.c
diff --git a/main.c b/main.c
index a78076c..24435b4 100644 (file)
--- a/main.c
+++ b/main.c
@@ -252,6 +252,7 @@ static void send_arp_reply(struct relayd_interface *rif, const uint8_t spa[4],
 static void host_entry_timeout(struct uloop_timeout *timeout)
 {
        struct relayd_host *host = container_of(timeout, struct relayd_host, timeout);
+       struct relayd_interface *rif;
 
        /*
         * When a host is behind a managed interface, we must not expire its host
@@ -261,7 +262,9 @@ static void host_entry_timeout(struct uloop_timeout *timeout)
         * giving up on it.
         */
        if (host->rif->managed && host->cleanup_pending < host_ping_tries) {
-               send_arp_request(host->rif, host->ipaddr);
+               list_for_each_entry(rif, &interfaces, list) {
+                       send_arp_request(rif, host->ipaddr);
+               }
                host->cleanup_pending++;
                uloop_timeout_set(&host->timeout, 1000);
                return;
@@ -667,9 +670,7 @@ static void die(int signo)
         * When we hit SIGTERM, clean up interfaces directly, so that we
         * won't leave our routing in an invalid state.
         */
-       cleanup_hosts();
-       free_interfaces();
-       exit(1);
+       uloop_end();
 }
 
 static int usage(const char *progname)