From: Felix Fietkau Date: Wed, 11 Aug 2010 15:44:21 +0000 (+0200) Subject: Flush the route cache after changing routes X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=6a7581ccbdbc468a6362f100a9393203fedc4700;p=oweals%2Frelayd.git Flush the route cache after changing routes --- diff --git a/route.c b/route.c index f436691..5425d51 100644 --- a/route.c +++ b/route.c @@ -20,12 +20,25 @@ #include #include #include +#include #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)