Mercurial > hg > dhcpcd
changeset 1815:34f85c3e563b draft
Grow -4, --ipv4only and -6, --ipv6only options.
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Wed, 19 Dec 2012 09:32:42 +0000 |
| parents | 4a3829cb4406 |
| children | e321a7642d75 |
| files | dhcpcd.8.in dhcpcd.c dhcpcd.conf.5.in if-options.c if-options.h ipv6rs.c |
| diffstat | 6 files changed, 37 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/dhcpcd.8.in Wed Dec 19 09:04:18 2012 +0000 +++ b/dhcpcd.8.in Wed Dec 19 09:32:42 2012 +0000 @@ -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 @@ 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.
--- a/dhcpcd.c Wed Dec 19 09:04:18 2012 +0000 +++ b/dhcpcd.c Wed Dec 19 09:32:42 2012 +0000 @@ -819,6 +819,9 @@ 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_static(iface); return; } + if (!(ifo->options & DHCPCD_IPV4)) + return; if (ifo->options & DHCPCD_INFORM) { start_inform(iface); return;
--- a/dhcpcd.conf.5.in Wed Dec 19 09:04:18 2012 +0000 +++ b/dhcpcd.conf.5.in Wed Dec 19 09:32:42 2012 +0000 @@ -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 @@ 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 @@ 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.
--- a/if-options.c Wed Dec 19 09:04:18 2012 +0000 +++ b/if-options.c Wed Dec 19 09:32:42 2012 +0000 @@ -115,6 +115,8 @@ {"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 @@ 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 @@ /* 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;
--- a/if-options.h Wed Dec 19 09:04:18 2012 +0000 +++ b/if-options.h Wed Dec 19 09:32:42 2012 +0000 @@ -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[];
--- a/ipv6rs.c Wed Dec 19 09:04:18 2012 +0000 +++ b/ipv6rs.c Wed Dec 19 09:32:42 2012 +0000 @@ -800,7 +800,8 @@ 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);
