From ca3f00d45e72c4b28b2ce39afc9543fa2f225020 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Fri, 14 Oct 2011 04:40:44 +0200 Subject: flush routes after bringing up/down an interface --- system-linux.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'system-linux.c') diff --git a/system-linux.c b/system-linux.c index cf4e9c7..bb834a2 100644 --- a/system-linux.c +++ b/system-linux.c @@ -446,6 +446,25 @@ int system_del_route(struct device *dev, struct device_route *route) return system_rt(dev, route, RTM_DELROUTE); } +int system_flush_routes(void) +{ + const char *names[] = { + "/proc/sys/net/ipv4/route/flush", + "/proc/sys/net/ipv6/route/flush" + }; + int fd, i; + + for (i = 0; i < ARRAY_SIZE(names); i++) { + fd = open(names[i], O_WRONLY); + if (fd < 0) + continue; + + write(fd, "-1", 2); + close(fd); + } + return 0; +} + time_t system_get_rtime(void) { struct timespec ts; -- cgit v1.2.3