]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Grow -4, --ipv4only and -6, --ipv6only options.
authorRoy Marples <roy@marples.name>
Wed, 19 Dec 2012 09:32:42 +0000 (09:32 +0000)
committerRoy Marples <roy@marples.name>
Wed, 19 Dec 2012 09:32:42 +0000 (09:32 +0000)
dhcpcd.8.in
dhcpcd.c
dhcpcd.conf.5.in
if-options.c
if-options.h
ipv6rs.c

index d41f6245e5b135eb14b283dfd25d020e9052a380..398bfce4246b8fb8d23e06edd82a4db1e1de0d28 100644 (file)
 .\" 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.
index f6b7e5ed5f475277e93907f818ad8056c3d7e167..7046a4dc4941d0a99e00ecefff46faa81e76c34b 100644 (file)
--- 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;
index a1decb747223ee291208f7a0eb42eef39297ca5e..7b75c97bab484188630d043f350482f4cd189cbc 100644 (file)
@@ -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.
index 36e996589806dfd592629d1414631aa3d3dd3984..69d1a990bb0602941b259f4ad69b6ec235e65d2a 100644 (file)
@@ -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;
index 212cd8d40e74fe33c075d4d565767074545295a0..466e8c3a7a9786d48fcce4c7192eb61d14a8a041 100644 (file)
@@ -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[];
 
index d4877a9c169ca2976871b360a142afa480cc7920..56fe251041914ce92ef265f5e60d62bed6c71dad 100644 (file)
--- 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);