From 13f678af89969ff8701b90c5589fdc2044360a17 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Fri, 9 Sep 2011 11:02:36 +0200 Subject: pingu_netlink: do not try remove routes that kernel aready removed When losing an address the kernel will remove the routes with it so we don't need to try remove it. This is only to avoid error messages in log. --- pingu_netlink.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'pingu_netlink.c') diff --git a/pingu_netlink.c b/pingu_netlink.c index c000e06..c35e8f2 100644 --- a/pingu_netlink.c +++ b/pingu_netlink.c @@ -639,7 +639,7 @@ static void netlink_route_cb_action(struct nlmsghdr *msg, int action) struct rtattr *rta[RTA_MAX+1]; struct pingu_gateway route; - int err; + int err = 0; /* ignore route changes that we made ourselves via talk_fd */ if (msg->nlmsg_pid == getpid()) @@ -656,11 +656,15 @@ static void netlink_route_cb_action(struct nlmsghdr *msg, int action) return; log_route_change(&route, iface->name, iface->route_table, action); - err = netlink_route_modify(&talk_fd, action, &route, - iface->index, iface->route_table); + /* Kernel will remove the alternate route when we lose the + * address so we don't need try remove it ourselves */ + if (action != RTM_DELROUTE || iface->has_address) + err = netlink_route_modify(&talk_fd, action, &route, + iface->index, iface->route_table); if (err > 0) log_error("Failed to %s route to table %i", - action == RTM_NEWROUTE ? "add" : "delete", iface->route_table); + action == RTM_NEWROUTE ? "add" : "delete", + iface->route_table); pingu_iface_gw_action(iface, &route, action); } -- cgit v1.2.3