aboutsummaryrefslogtreecommitdiffstats
path: root/pingu_netlink.c
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2011-09-07 13:40:48 +0200
committerNatanael Copa <ncopa@alpinelinux.org>2011-09-07 13:40:48 +0200
commit5721a306b0140fab29447f72c64e4428bbc7fe16 (patch)
tree14e53c0ab5966fd58030e82c27d7b740ef71d5d5 /pingu_netlink.c
parentb93d20680b379e2d13091a055eb61ed4b2e06e3b (diff)
downloadpingu-5721a306b0140fab29447f72c64e4428bbc7fe16.tar.bz2
pingu-5721a306b0140fab29447f72c64e4428bbc7fe16.tar.xz
pingu_{iface,netlink}: only remove route rules that we actually created
Diffstat (limited to 'pingu_netlink.c')
-rw-r--r--pingu_netlink.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/pingu_netlink.c b/pingu_netlink.c
index c232f28..c685df2 100644
--- a/pingu_netlink.c
+++ b/pingu_netlink.c
@@ -550,6 +550,8 @@ static void netlink_addr_new_cb(struct nlmsghdr *msg)
RTA_PAYLOAD(rta[IFA_LOCAL]));
pingu_iface_bind_socket(iface, 1);
err = netlink_rule_replace_or_add(&talk_fd, iface);
+ if (err == 0)
+ iface->has_route_rule = 1;
if (err > 0)
log_error("%s: Failed to add route rule: %s", iface->name,
strerror(err));
@@ -784,9 +786,16 @@ err_close_all:
return FALSE;
}
-void kernel_cleanup_iface(struct pingu_iface *iface)
+void kernel_cleanup_iface_routes(struct pingu_iface *iface)
{
- netlink_rule_del(&talk_fd, iface);
+ int err = 0;
+ if (iface->has_route_rule) {
+ err = netlink_rule_del(&talk_fd, iface);
+ if (err == 0)
+ iface->has_route_rule = 0;
+ if (err > 0)
+ log_error("Failed to delete route rule for %s", iface->name);
+ }
}
void kernel_close(void)