summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSusant Sahani <ssahani@users.noreply.github.com>2016-08-04 19:26:39 +0530
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-08-04 09:56:39 -0400
commit3104883ddc2452ae210de3c70576c03023250a51 (patch)
tree8f0084f180f8b3934eddca6ed19414742a69bb14 /src
parent1898a1a5c37ba019c7a5a48505befd64f78071dc (diff)
networkd: remove route if carrier is lost (#3831)
Fixes #3669.
Diffstat (limited to 'src')
-rw-r--r--src/network/networkd-link.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index a0da697707..99784b0ebe 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -2314,6 +2314,35 @@ static int link_drop_foreign_config(Link *link) {
return 0;
}
+static int link_drop_config(Link *link) {
+ Address *address;
+ Route *route;
+ Iterator i;
+ int r;
+
+ SET_FOREACH(address, link->addresses, i) {
+ /* we consider IPv6LL addresses to be managed by the kernel */
+ if (address->family == AF_INET6 && in_addr_is_link_local(AF_INET6, &address->in_addr) == 1)
+ continue;
+
+ r = address_remove(address, link, link_address_remove_handler);
+ if (r < 0)
+ return r;
+ }
+
+ SET_FOREACH(route, link->routes, i) {
+ /* do not touch routes managed by the kernel */
+ if (route->protocol == RTPROT_KERNEL)
+ continue;
+
+ r = route_remove(route, link, link_route_remove_handler);
+ if (r < 0)
+ return r;
+ }
+
+ return 0;
+}
+
static int link_update_lldp(Link *link) {
int r;
@@ -2860,6 +2889,14 @@ static int link_carrier_lost(Link *link) {
return r;
}
+ r = link_drop_config(link);
+ if (r < 0)
+ return r;
+
+ r = link_drop_foreign_config(link);
+ if (r < 0)
+ return r;
+
r = link_handle_bound_by_list(link);
if (r < 0)
return r;