diff options
| author | Roy Marples <roy@marples.name> | 2013-02-15 20:33:13 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2013-02-15 20:33:13 +0000 |
| commit | fbbb0875dd748a22dcf6d91a7d3cdaed5a90dc58 (patch) | |
| tree | c67f12a8c0734c78e69f12614ec7bbe945547204 /dhcpcd.c | |
| parent | cebe222c56901ba2f943a07eaf815d9660ba836b (diff) | |
| download | dhcpcd-fbbb0875dd748a22dcf6d91a7d3cdaed5a90dc58.tar.xz | |
Instead of opening link, ipv6, ipv6rs and ipv6ns sockets globally,
only open when the first link wanting this features needs it.
Hopefully fixes #263 and #264.
Diffstat (limited to 'dhcpcd.c')
| -rw-r--r-- | dhcpcd.c | 56 |
1 files changed, 30 insertions, 26 deletions
@@ -453,16 +453,45 @@ start_interface(void *arg) dhcp_start(ifp); } +/* ARGSUSED */ +static void +handle_link(_unused void *arg) +{ + + if (manage_link(linkfd) == -1) + syslog(LOG_ERR, "manage_link: %m"); +} + static void init_state(struct interface *ifp, int argc, char **argv) { + struct if_options *ifo; const char *reason = NULL; configure_interface(ifp, argc, argv); + ifo = ifp->options; + + if (if_options->options & DHCPCD_LINK && linkfd == -1) { + linkfd = open_link_socket(); + if (linkfd == -1) { + syslog(LOG_ERR, "open_link_socket: %m"); + ifo->options &= ~DHCPCD_LINK; + } else + eloop_event_add(linkfd, handle_link, NULL); + } + + if (ifo->options & DHCPCD_IPV6RS && !check_ipv6(NULL)) + ifo->options &= ~DHCPCD_IPV6RS; + if (ifo->options & DHCPCD_IPV6RS && ipv6_init() == -1) { + ifo->options &= ~DHCPCD_IPV6RS; + syslog(LOG_ERR, "ipv6_init: %m"); + } + + if (!(options & DHCPCD_TEST)) script_runreason(ifp, "PREINIT"); - if (ifp->options->options & DHCPCD_LINK) { + if (ifo->options & DHCPCD_LINK) { switch (carrier_status(ifp)) { case 0: ifp->carrier = LINK_DOWN; @@ -573,15 +602,6 @@ handle_hwaddr(const char *ifname, unsigned char *hwaddr, size_t hwlen) } #endif -/* ARGSUSED */ -static void -handle_link(_unused void *arg) -{ - - if (manage_link(linkfd) == -1) - syslog(LOG_ERR, "manage_link: %m"); -} - static void if_reboot(struct interface *ifp, int argc, char **argv) { @@ -1105,13 +1125,6 @@ main(int argc, char **argv) syslog(LOG_ERR, "open_sockets: %m"); exit(EXIT_FAILURE); } - if (if_options->options & DHCPCD_LINK) { - linkfd = open_link_socket(); - if (linkfd == -1) - syslog(LOG_ERR, "open_link_socket: %m"); - else - eloop_event_add(linkfd, handle_link, NULL); - } #if 0 if (options & DHCPCD_IPV6RS && disable_rtadv() == -1) { @@ -1120,15 +1133,6 @@ main(int argc, char **argv) } #endif - if (options & DHCPCD_IPV6 && ipv6_init() == -1) { - options &= ~DHCPCD_IPV6; - syslog(LOG_ERR, "ipv6_init: %m"); - } - if (options & DHCPCD_IPV6RS && !check_ipv6(NULL)) - options &= ~DHCPCD_IPV6RS; - if (options & DHCPCD_IPV6RS) - ipv6rs_init(); - ifc = argc - optind; ifv = argv + optind; |
