Flush the route cache after changing routes
authorFelix Fietkau <nbd@openwrt.org>
Wed, 11 Aug 2010 15:44:21 +0000 (17:44 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Wed, 11 Aug 2010 15:47:54 +0000 (17:47 +0200)
route.c

diff --git a/route.c b/route.c
index f436691..5425d51 100644 (file)
--- a/route.c
+++ b/route.c
 #include <string.h>
 #include <errno.h>
 #include <unistd.h>
 #include <string.h>
 #include <errno.h>
 #include <unistd.h>
+#include <fcntl.h>
 
 #include "relayd.h"
 
 static struct uloop_fd rtnl_sock;
 static unsigned int rtnl_seq, rtnl_dump_seq;
 
 
 #include "relayd.h"
 
 static struct uloop_fd rtnl_sock;
 static unsigned int rtnl_seq, rtnl_dump_seq;
 
+static void rtnl_flush(void)
+{
+       int fd;
+
+       fd = open("/proc/sys/net/ipv4/route/flush", O_WRONLY);
+       if (fd < 0)
+               return;
+
+       write(fd, "-1", 2);
+       close(fd);
+}
+
 static void rtnl_route_set(struct relayd_host *host, bool add)
 {
        static struct {
 static void rtnl_route_set(struct relayd_host *host, bool add)
 {
        static struct {
@@ -70,6 +83,7 @@ static void rtnl_route_set(struct relayd_host *host, bool add)
        }
 
        send(rtnl_sock.fd, &req, sizeof(req), 0);
        }
 
        send(rtnl_sock.fd, &req, sizeof(req), 0);
+       rtnl_flush();
 }
 
 void relayd_add_route(struct relayd_host *host)
 }
 
 void relayd_add_route(struct relayd_host *host)