Mercurial > hg > dhcpcd
changeset 2249:1eab8a5c0194 draft
Add nodhcp and nodhcp6 directives.
Thanks to Sebastian Huber for the initial patch and testing.
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Wed, 29 Jan 2014 14:05:58 +0000 |
| parents | ab9f78ee23f2 |
| children | 169555327af9 |
| files | arp.c dhcp.c dhcp6.c dhcpcd.conf.5.in if-options.c if-options.h ipv4ll.c |
| diffstat | 7 files changed, 49 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/arp.c Mon Jan 27 11:34:26 2014 +0000 +++ b/arp.c Wed Jan 29 14:05:58 2014 +0000 @@ -245,6 +245,9 @@ return; } if (state->new->cookie != htonl(MAGIC_COOKIE)) { + /* Check if doing DHCP */ + if (!(ifp->options->options & DHCPCD_DHCP)) + return; /* We should pretend to be at the end * of the DHCP negotation cycle unless we rebooted */ if (state->interval != 0)
--- a/dhcp.c Mon Jan 27 11:34:26 2014 +0000 +++ b/dhcp.c Wed Jan 29 14:05:58 2014 +0000 @@ -2660,7 +2660,7 @@ return; } - if (dhcp_open(ifp) == -1) + if (ifo->options & DHCPCD_DHCP && dhcp_open(ifp) == -1) return; if (ifo->options & DHCPCD_INFORM) { @@ -2709,10 +2709,21 @@ } } } + + if (!(ifo->options & DHCPCD_DHCP)) { + if (ifo->options & DHCPCD_IPV4LL) { + if (state->offer && state->offer->cookie != 0) { + free(state->offer); + state->offer = NULL; + } + ipv4ll_start(ifp); + } + return; + } + if (state->offer == NULL) dhcp_discover(ifp); - else if (state->offer->cookie == 0 && - ifp->options->options & DHCPCD_IPV4LL) + else if (state->offer->cookie == 0 && ifo->options & DHCPCD_IPV4LL) ipv4ll_start(ifp); else dhcp_reboot(ifp);
--- a/dhcp6.c Mon Jan 27 11:34:26 2014 +0000 +++ b/dhcp6.c Wed Jan 29 14:05:58 2014 +0000 @@ -2491,6 +2491,9 @@ return 0; } + if (!(ifp->options->options & DHCPCD_DHCP6)) + return 0; + if (sock == -1 && dhcp6_open() == -1) return -1;
--- a/dhcpcd.conf.5.in Mon Jan 27 11:34:26 2014 +0000 +++ b/dhcpcd.conf.5.in Wed Jan 29 14:05:58 2014 +0000 @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd January 24, 2014 +.Dd January 29, 2014 .Dt DHCPCD.CONF 5 .Os .Sh NAME @@ -323,6 +323,12 @@ Don't load .Pa /dev management modules. +.It Ic nodhcp +Don't start DHCP or listen to DHCP messages. +This is only useful when allowing IPv4LL. +.It Ic nodhcp6 +Don't start DHCPv6 or listen to DHCPv6 messages. +Normally DHCPv6 is started by a RA instruction or configuration. .It Ic nogateway Don't install any default routes. .It Ic nohook Ar script
--- a/if-options.c Mon Jan 27 11:34:26 2014 +0000 +++ b/if-options.c Wed Jan 29 14:05:58 2014 +0000 @@ -84,6 +84,8 @@ #define O_AUTHPROTOCOL O_BASE + 25 #define O_AUTHTOKEN O_BASE + 26 #define O_AUTHNOTREQUIRED O_BASE + 27 +#define O_NODHCP O_BASE + 28 +#define O_NODHCP6 O_BASE + 29 char *dev_load; @@ -162,6 +164,8 @@ {"authprotocol", required_argument, NULL, O_AUTHPROTOCOL}, {"authtoken", required_argument, NULL, O_AUTHTOKEN}, {"noauthrequired", no_argument, NULL, O_AUTHNOTREQUIRED}, + {"nodhcp", no_argument, NULL, O_NODHCP}, + {"nodhcp6", no_argument, NULL, O_NODHCP6}, {NULL, 0, NULL, '\0'} }; @@ -1697,6 +1701,12 @@ case O_AUTHNOTREQUIRED: ifo->auth.options &= ~DHCPCD_AUTH_REQUIRE; break; + case O_NODHCP: + ifo->options &= ~DHCPCD_DHCP; + break; + case O_NODHCP6: + ifo->options &= ~DHCPCD_DHCP6; + break; default: return 0; } @@ -1773,11 +1783,12 @@ ifo->options |= DHCPCD_DEV; #endif #ifdef INET - ifo->options |= DHCPCD_IPV4 | DHCPCD_IPV4LL; + ifo->options |= DHCPCD_IPV4 | DHCPCD_DHCP | DHCPCD_IPV4LL; ifo->options |= DHCPCD_GATEWAY | DHCPCD_ARP; #endif #ifdef INET6 ifo->options |= DHCPCD_IPV6 | DHCPCD_IPV6RS | DHCPCD_IPV6RA_REQRDNSS; + ifo->options |= DHCPCD_DHCP6; ifo->dadtransmits = ipv6_dadtransmits(ifname); #endif ifo->timeout = DEFAULT_TIMEOUT;
--- a/if-options.h Mon Jan 27 11:34:26 2014 +0000 +++ b/if-options.h Wed Jan 29 14:05:58 2014 +0000 @@ -1,6 +1,6 @@ /* * dhcpcd - DHCP client daemon - * Copyright (c) 2006-2013 Roy Marples <roy@marples.name> + * Copyright (c) 2006-2014 Roy Marples <roy@marples.name> * All rights reserved * Redistribution and use in source and binary forms, with or without @@ -100,6 +100,8 @@ #define DHCPCD_WAITIP6 (1ULL << 46) #define DHCPCD_DEV (1ULL << 47) #define DHCPCD_IAID (1ULL << 48) +#define DHCPCD_DHCP (1ULL << 49) +#define DHCPCD_DHCP6 (1ULL << 50) extern const struct option cf_options[];
--- a/ipv4ll.c Mon Jan 27 11:34:26 2014 +0000 +++ b/ipv4ll.c Wed Jan 29 14:05:58 2014 +0000 @@ -1,6 +1,6 @@ /* * dhcpcd - DHCP client daemon - * Copyright (c) 2006-2013 Roy Marples <roy@marples.name> + * Copyright (c) 2006-2014 Roy Marples <roy@marples.name> * All rights reserved * Redistribution and use in source and binary forms, with or without @@ -158,8 +158,12 @@ if (++state->conflicts > MAX_CONFLICTS) { syslog(LOG_ERR, "%s: failed to acquire an IPv4LL address", ifp->name); - state->interval = RATE_LIMIT_INTERVAL / 2; - dhcp_discover(ifp); + if (ifp->options->options & DHCPCD_DHCP) { + state->interval = RATE_LIMIT_INTERVAL / 2; + dhcp_discover(ifp); + } else + eloop_add_timeout_sec(RATE_LIMIT_INTERVAL, + ipv4ll_start, ifp); } else { eloop_timeout_add_sec(PROBE_WAIT, ipv4ll_start, ifp); }
