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 f4366912f2d2f991237bc73a0b1bdce4a41550d3..5425d5192ee78bdd7dbd8c052e30b4f0e4c7b2f2 100644 (file)
--- a/route.c
+++ b/route.c
 #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;
 
+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 {
@@ -70,6 +83,7 @@ static void rtnl_route_set(struct relayd_host *host, bool add)
        }
 
        send(rtnl_sock.fd, &req, sizeof(req), 0);
+       rtnl_flush();
 }
 
 void relayd_add_route(struct relayd_host *host)