diff options
| author | Roy Marples <roy@marples.name> | 2017-12-07 17:01:39 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2017-12-07 17:01:39 +0000 |
| commit | b86b4ac47fa09edafa6ce3c009751557fe1a6138 (patch) | |
| tree | f24378f908a0b6a9be1f937cb63319a6a2842d83 /src/dhcpcd.c | |
| parent | 1394cd9a65be98a3afb278f6d523dc262a721334 (diff) | |
| download | dhcpcd-b86b4ac47fa09edafa6ce3c009751557fe1a6138.tar.xz | |
dhcp6: don't listen on IPv6 addresses when not using DHCP6
To achieve this we need to learn the addresses AFTER the interface
configuration has been loaded.
Diffstat (limited to 'src/dhcpcd.c')
| -rw-r--r-- | src/dhcpcd.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/dhcpcd.c b/src/dhcpcd.c index a82cc449..6ce077f7 100644 --- a/src/dhcpcd.c +++ b/src/dhcpcd.c @@ -975,6 +975,7 @@ int dhcpcd_handleinterface(void *arg, int action, const char *ifname) { struct dhcpcd_ctx *ctx; + struct ifaddrs *ifaddrs; struct if_head *ifs; struct interface *ifp, *iff, *ifn; const char * const argv[] = { ifname }; @@ -998,7 +999,7 @@ dhcpcd_handleinterface(void *arg, int action, const char *ifname) } i = -1; - ifs = if_discover(ctx, -1, UNCONST(argv)); + ifs = if_discover(ctx, &ifaddrs, -1, UNCONST(argv)); if (ifs == NULL) { logerr(__func__); return -1; @@ -1043,6 +1044,17 @@ dhcpcd_handleinterface(void *arg, int action, const char *ifname) dhcpcd_prestartinterface(iff); } + if_learnaddrs(ctx, ifs, &ifaddrs); + + /* Now we have learned addresses, start the interface */ + TAILQ_FOREACH_SAFE(ifp, ifs, next, ifn) { + if (strcmp(ifp->name, ifname) != 0) + continue; + iff = if_find(ctx->ifaces, ifp->name); + if (action > 0 && iff->active) + dhcpcd_prestartinterface(iff); + } + /* Free our discovered list */ while ((ifp = TAILQ_FIRST(ifs))) { TAILQ_REMOVE(ifs, ifp, next); @@ -1403,6 +1415,7 @@ int main(int argc, char **argv) { struct dhcpcd_ctx ctx; + struct ifaddrs *ifaddrs = NULL; struct if_options *ifo; struct interface *ifp; uint16_t family = 0; @@ -1678,7 +1691,7 @@ printpidfile: if (optind != argc) { /* We need to try and find the interface so we can load * the hardware address to compare automated IAID */ - ctx.ifaces = if_discover(&ctx, + ctx.ifaces = if_discover(&ctx, &ifaddrs, argc - optind, argv + optind); } else { if ((ctx.ifaces = malloc(sizeof(*ctx.ifaces))) != NULL) @@ -1842,7 +1855,7 @@ printpidfile: (DHCPCD_MASTER | DHCPCD_DEV)) dev_start(&ctx); - ctx.ifaces = if_discover(&ctx, ctx.ifc, ctx.ifv); + ctx.ifaces = if_discover(&ctx, &ifaddrs, ctx.ifc, ctx.ifv); if (ctx.ifaces == NULL) { logerr("%s: if_discover", __func__); goto exit_failure; @@ -1878,6 +1891,7 @@ printpidfile: if (ifp->active) dhcpcd_initstate1(ifp, argc, argv, 0); } + if_learnaddrs(&ctx, ctx.ifaces, &ifaddrs); if (ctx.options & DHCPCD_BACKGROUND && dhcpcd_daemonise(&ctx)) goto exit_success; @@ -1948,6 +1962,8 @@ exit_failure: i = EXIT_FAILURE; exit1: + if (ifaddrs != NULL) + freeifaddrs(ifaddrs); if (control_stop(&ctx) == -1) logerr("%s: control_stop", __func__); /* Free memory and close fd's */ |
