diff options
| author | Roy Marples <roy@marples.name> | 2009-01-26 22:32:42 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2009-01-26 22:32:42 +0000 |
| commit | 16687a3be1f8c1e6d55cdd691e947e5760eef30c (patch) | |
| tree | 81ecc57612e06ddcc51dd29a6473ec5aea736f44 /configure.c | |
| parent | 495c0a77ac4caba2360004b64a1f563d682ac7ee (diff) | |
| download | dhcpcd-16687a3be1f8c1e6d55cdd691e947e5760eef30c.tar.xz | |
We need to ensure that manual route deletions are deleted from our internal routing table also. Partial fix for #159.
Diffstat (limited to 'configure.c')
| -rw-r--r-- | configure.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/configure.c b/configure.c index 3b4b2124..96d8d886 100644 --- a/configure.c +++ b/configure.c @@ -62,6 +62,7 @@ static struct rt *routes; + static int exec_script(char *const *argv, char *const *env) { @@ -388,6 +389,33 @@ desc_route(const char *cmd, const struct rt *rt, const char *ifname) addr, inet_ntocidr(rt->net), inet_ntoa(rt->gate)); } +/* If something other than dhcpcd removes a route, + * we need to remove it from our internal table. */ +int +route_deleted(const struct in_addr *dst, + const struct in_addr *net, + const struct in_addr *gate) +{ + struct rt rt, *f, *l; + + rt.dest.s_addr = dst->s_addr; + rt.net.s_addr = net->s_addr; + rt.gate.s_addr = gate->s_addr; + rt.iface = NULL; + rt.next = NULL; + + f = find_route(routes, &rt, &l, NULL); + if (f == NULL) + return 0; + desc_route("removing", f, f->iface->name); + if (l) + l->next = f->next; + else + routes = f->next; + free(f); + return 1; +} + static int n_route(struct rt *rt, const struct interface *iface) { |
