summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--interface.c2
-rw-r--r--system-dummy.c5
-rw-r--r--system-linux.c19
-rw-r--r--system.h1
4 files changed, 27 insertions, 0 deletions
diff --git a/interface.c b/interface.c
index 0a85e6f..e0c2c78 100644
--- a/interface.c
+++ b/interface.c
@@ -240,6 +240,7 @@ interface_proto_cb(struct interface_proto_state *state, enum interface_proto_eve
if (iface->state != IFS_SETUP)
return;
+ system_flush_routes();
iface->state = IFS_UP;
iface->start_time = system_get_rtime();
interface_event(iface, IFEV_UP);
@@ -249,6 +250,7 @@ interface_proto_cb(struct interface_proto_state *state, enum interface_proto_eve
if (iface->state == IFS_DOWN)
return;
+ system_flush_routes();
mark_interface_down(iface);
interface_handle_config_change(iface);
if (iface->autostart)
diff --git a/system-dummy.c b/system-dummy.c
index e6187f3..d518d6f 100644
--- a/system-dummy.c
+++ b/system-dummy.c
@@ -172,6 +172,11 @@ int system_del_route(struct device *dev, struct device_route *route)
return 0;
}
+int system_flush_routes(void)
+{
+ return 0;
+}
+
time_t system_get_rtime(void)
{
struct timeval tv;
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;
diff --git a/system.h b/system.h
index 4155281..cfe7c9f 100644
--- a/system.h
+++ b/system.h
@@ -44,6 +44,7 @@ int system_del_address(struct device *dev, struct device_addr *addr);
int system_add_route(struct device *dev, struct device_route *route);
int system_del_route(struct device *dev, struct device_route *route);
+int system_flush_routes(void);
time_t system_get_rtime(void);