From: Roy Marples Date: Wed, 19 Dec 2012 09:32:42 +0000 (+0000) Subject: Grow -4, --ipv4only and -6, --ipv6only options. X-Git-Tag: v5.6.6~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=02c0b119e099ee49ab14c7a227d92550f5286cdd;p=thirdparty%2Fdhcpcd.git Grow -4, --ipv4only and -6, --ipv6only options. --- diff --git a/dhcpcd.8.in b/dhcpcd.8.in index d41f6245..398bfce4 100644 --- a/dhcpcd.8.in +++ b/dhcpcd.8.in @@ -22,15 +22,15 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd June 7, 2012 +.Dd October 11, 2012 .Dt DHCPCD 8 .Os .Sh NAME .Nm dhcpcd -.Nd an RFC 2131 compliant DHCP client +.Nd a DHCP client .Sh SYNOPSIS .Nm -.Op Fl ABbDdEGgHJKkLnpqTVw +.Op Fl 46ABbDdEGgHJKkLnpqTVw .Op Fl C , Fl Fl nohook Ar hook .Op Fl c , Fl Fl script Ar script .Op Fl e , Fl Fl env Ar value @@ -424,6 +424,10 @@ However, there are sometimes situations where you don't want the things to be configured exactly how the the DHCP server wants. Here are some options that deal with turning these bits off. .Bl -tag -width indent +.It Fl 4 , Fl Fl ipv4only +Only configure IPv4. +.It Fl 6 , Fl Fl ipv6only +Only configure IPv6. .It Fl A , Fl Fl noarp Don't request or claim the address by ARP. This also disables IPv4LL. diff --git a/dhcpcd.c b/dhcpcd.c index f6b7e5ed..7046a4dc 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -819,6 +819,9 @@ configure_interface1(struct interface *iface) free(iface->clientid); iface->clientid = NULL; + if (!(ifo->options & DHCPCD_IPV4)) + return; + if (*ifo->clientid) { iface->clientid = xmalloc(ifo->clientid[0] + 1); memcpy(iface->clientid, ifo->clientid, ifo->clientid[0] + 1); @@ -1206,6 +1209,8 @@ start_interface(void *arg) start_static(iface); return; } + if (!(ifo->options & DHCPCD_IPV4)) + return; if (ifo->options & DHCPCD_INFORM) { start_inform(iface); return; diff --git a/dhcpcd.conf.5.in b/dhcpcd.conf.5.in index a1decb74..7b75c97b 100644 --- a/dhcpcd.conf.5.in +++ b/dhcpcd.conf.5.in @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd May 21, 2012 +.Dd October 11, 2012 .Dt DHCPCD.CONF 5 SMM .Os .Sh NAME @@ -133,6 +133,10 @@ is an empty string then the current system hostname is sent. If .Ar hostname is a FQDN (ie, contains a .) then it will be encoded as such. +.It Ic ipv4only +Only configure IPv4. +.It Ic ipv6only +Only configure IPv6. .It Ic fqdn Op none | ptr | both none disables FQDN encoding, ptr just asks the DHCP server to update the PTR record of the host in DNS whereas both also updates the A record. @@ -154,15 +158,15 @@ RDNSS option. Set this option so to make .Nm dhcpcd always fork on an RA. -.It ic ipv6ra_own +.It Ic ipv6ra_own Disables kernel IPv6 Router Advertisment processing so dhcpcd can manage addresses and routes. -.It ic ipv6ra_own_default +.It Ic ipv6ra_own_default Each time dhcpcd receives an IPv6 Router Adveristment, dhcpcd will manage the default route only. This allows dhcpcd to prefer an interface for outbound traffic based on metric and/or user selection rather than the kernel. -.It ic ipv6rs +.It Ic ipv6rs Enables IPv6 Router Advertisment solicitation. This is on by default, but is documented here in the case where it is disabled globally but needs to be enabled for one interface. diff --git a/if-options.c b/if-options.c index 36e99658..69d1a990 100644 --- a/if-options.c +++ b/if-options.c @@ -115,6 +115,8 @@ const struct option cf_options[] = { {"ipv6ra_fork", no_argument, NULL, O_IPV6RA_FORK}, {"ipv6ra_own", no_argument, NULL, O_IPV6RA_OWN}, {"ipv6ra_own_default", no_argument, NULL, O_IPV6RA_OWN_D}, + {"ipv4only", no_argument, NULL, '4'}, + {"ipv6only", no_argument, NULL, '6'}, {NULL, 0, NULL, '\0'} }; @@ -731,6 +733,14 @@ parse_option(struct if_options *ifo, int opt, const char *arg) case 'Z': ifdv = splitv(&ifdc, ifdv, arg); break; + case '4': + ifo->options &= ~(DHCPCD_IPV6 | DHCPCD_IPV6RS); + ifo->options |= DHCPCD_IPV4; + break; + case '6': + ifo->options &= ~DHCPCD_IPV4; + ifo->options |= DHCPCD_IPV6 | DHCPCD_IPV6RS; + break; case O_ARPING: if (parse_addr(&addr, NULL, arg) != 0) return -1; @@ -810,9 +820,10 @@ read_config(const char *file, /* Seed our default options */ ifo = xzalloc(sizeof(*ifo)); + ifo->options |= DHCPCD_IPV4 | DHCPCD_IPV4LL; ifo->options |= DHCPCD_GATEWAY | DHCPCD_DAEMONISE | DHCPCD_LINK; - ifo->options |= DHCPCD_ARP | DHCPCD_IPV4LL; - ifo->options |= DHCPCD_IPV6RS | DHCPCD_IPV6RA_REQRDNSS; + ifo->options |= DHCPCD_ARP; + ifo->options |= DHCPCD_IPV6 | DHCPCD_IPV6RS | DHCPCD_IPV6RA_REQRDNSS; ifo->timeout = DEFAULT_TIMEOUT; ifo->reboot = DEFAULT_REBOOT; ifo->metric = -1; diff --git a/if-options.h b/if-options.h index 212cd8d4..466e8c3a 100644 --- a/if-options.h +++ b/if-options.h @@ -37,7 +37,7 @@ /* Don't set any optional arguments here so we retain POSIX * compatibility with getopt */ -#define IF_OPTS "bc:de:f:gh:i:kl:m:no:pqr:s:t:u:v:wxy:z:ABC:DEF:GHI:JKLO:Q:S:TUVW:X:Z:" +#define IF_OPTS "46bc:de:f:gh:i:kl:m:no:pqr:s:t:u:v:wxy:z:ABC:DEF:GHI:JKLO:Q:S:TUVW:X:Z:" #define DEFAULT_TIMEOUT 30 #define DEFAULT_REBOOT 5 @@ -83,6 +83,7 @@ #define DHCPCD_IPV6RA_OWN_DEFAULT (1ULL << 34) #define DHCPCD_IPV4 (1ULL << 35) #define DHCPCD_FORKED (1ULL << 36) +#define DHCPCD_IPV6 (1ULL << 37) extern const struct option cf_options[]; diff --git a/ipv6rs.c b/ipv6rs.c index d4877a9c..56fe2510 100644 --- a/ipv6rs.c +++ b/ipv6rs.c @@ -800,7 +800,8 @@ ipv6rs_handledata(_unused void *arg) handle_flag: if (rap->flags & (ND_RA_FLAG_MANAGED | ND_RA_FLAG_OTHER)) { if (new_data) - syslog(LOG_WARNING, "%s: no support for DHCPv6 management", + syslog(LOG_WARNING, + "%s: no support for DHCPv6 management", ifp->name); if (options & DHCPCD_TEST) exit(EXIT_SUCCESS);