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_iface.c | 4 ++-- pingu_netlink.c | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pingu_iface.c b/pingu_iface.c index 9f63587..c7388b0 100644 --- a/pingu_iface.c +++ b/pingu_iface.c @@ -163,7 +163,7 @@ void pingu_iface_gw_action(struct pingu_iface *iface, break; } if (is_default_gw(gw)) - kernel_route_multipath(action, &iface_list, RT_TABLE_MAIN); + kernel_route_multipath(RTM_NEWROUTE, &iface_list, RT_TABLE_MAIN); } void pingu_iface_update_routes(struct pingu_iface *iface, int action) @@ -173,7 +173,7 @@ void pingu_iface_update_routes(struct pingu_iface *iface, int action) if (is_default_gw(route) && iface->has_address) kernel_route_modify(action, route, iface, RT_TABLE_MAIN); } - kernel_route_multipath(action, &iface_list, RT_TABLE_MAIN); + kernel_route_multipath(RTM_NEWROUTE, &iface_list, RT_TABLE_MAIN); } int pingu_iface_set_route_table(struct pingu_iface *iface, int table) 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