diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2011-09-09 11:02:36 +0200 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2011-09-09 11:48:23 +0200 |
commit | 13f678af89969ff8701b90c5589fdc2044360a17 (patch) | |
tree | a387d2141666b6cf5693146239f260811f1eac12 /pingu_netlink.c | |
parent | f376e4057d9cb944ac17b3bf19f01e153b66c6ec (diff) | |
download | pingu-13f678af89969ff8701b90c5589fdc2044360a17.tar.bz2 pingu-13f678af89969ff8701b90c5589fdc2044360a17.tar.xz |
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.
Diffstat (limited to 'pingu_netlink.c')
-rw-r--r-- | pingu_netlink.c | 12 |
1 files changed, 8 insertions, 4 deletions
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); } |