From 50d9faf2d2c5ddcf9a0bd6591d73d4e45d09641b Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Fri, 9 Sep 2011 14:20:40 +0200 Subject: pingu_netlink: delete multipath route if there are no paths The normal action is to replace but if all ISPs goes down we need to explicit delete the multipath route. Otherwise we will have the last default gw hanging around. --- pingu_netlink.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'pingu_netlink.c') diff --git a/pingu_netlink.c b/pingu_netlink.c index 5c63a51..e9781fa 100644 --- a/pingu_netlink.c +++ b/pingu_netlink.c @@ -375,8 +375,10 @@ static int add_nexthops(struct nlmsghdr *nlh, size_t nlh_size, host = pingu_host_find_by_iface(iface); if ((!iface->balance) || iface->index == 0 || (host != NULL && host->status == PINGU_HOST_STATUS_OFFLINE) - || route == NULL) + || route == NULL) { + iface->has_multipath = 0; continue; + } iface->has_multipath = 1; break; case RTM_DELROUTE: @@ -430,7 +432,7 @@ int netlink_route_multipath(struct netlink_fd *fd, int action_type, count = add_nexthops(&req.nlh, sizeof(req), iface_list, action_type); if (count == 0) - return 0; + req.nlh.nlmsg_type = RTM_DELROUTE; if (!netlink_talk(fd, &req.nlh, sizeof(req), &req.nlh)) return -1; -- cgit v1.2.3