]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Add an option to skip the initial randomised protocol delay.
authorRoy Marples <roy@marples.name>
Wed, 3 Jun 2015 10:34:15 +0000 (10:34 +0000)
committerRoy Marples <roy@marples.name>
Wed, 3 Jun 2015 10:34:15 +0000 (10:34 +0000)
dhcp.c
dhcp6.c
dhcpcd.conf.5.in
if-options.c
if-options.h
ipv6nd.c

diff --git a/dhcp.c b/dhcp.c
index 1bd14775881aba1d4f0312c8d3ccdf7b33976ba2..89eb6a5d575d669cdcddd1cbdc7633d2b000d9a5 100644 (file)
--- a/dhcp.c
+++ b/dhcp.c
@@ -3353,6 +3353,13 @@ dhcp_start(struct interface *ifp)
                return;
 
        /* No point in delaying a static configuration */
+       if (ifp->options->options & DHCPCD_STATIC ||
+           !(ifp->options->options & DHCPCD_INITIAL_DELAY))
+       {
+               dhcp_start1(ifp);
+               return;
+       }
+
        tv.tv_sec = DHCP_MIN_DELAY;
        tv.tv_nsec = (suseconds_t)arc4random_uniform(
            (DHCP_MAX_DELAY - DHCP_MIN_DELAY) * NSEC_PER_SEC);
diff --git a/dhcp6.c b/dhcp6.c
index 2bb2dcf2bbe73f7feaef65ce37dc81f723423059..88b6a939fd3de1f547dbb71956e6bc41bb6e71f5 100644 (file)
--- a/dhcp6.c
+++ b/dhcp6.c
@@ -1054,6 +1054,9 @@ dhcp6_sendmessage(struct interface *ifp, void (*callback)(void *))
                    state->send->xid[1],
                    state->send->xid[2]);
        else {
+               if (state->IMD &&
+                   !(ifp->options->options & DHCPCD_INITIAL_DELAY))
+                       state->IMD = 0;
                if (state->IMD) {
                        /* Some buggy PPP servers close the link too early
                         * after sending an invalid status in their reply
index 80022337737cb727c26682b931bf8b758d256c59..7d9de3f87c2f9c46590889f29cb16a5d66a2800b 100644 (file)
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd May 15, 2015
+.Dd June 3, 2015
 .Dt DHCPCD.CONF 5
 .Os
 .Sh NAME
@@ -412,6 +412,8 @@ Don't send any ARP requests.
 This also disables IPv4LL.
 .It Ic noauthrequired
 Don't require authentication even though we requested it.
+.It Ic nodelay
+Don't delay for an initial randomised time when starting protocols.
 .It Ic nodev
 Don't load
 .Pa /dev
index aa3a351e2645848e0bdbc1370dadcd0cc73d3b72..04b64a3198af3989651b307b29db87aea078c380 100644 (file)
 #define O_IPV6RA_ACCEPT_NOPUBLIC       O_BASE + 41
 #define O_BOOTP                        O_BASE + 42
 #define O_DEFINEND             O_BASE + 43
+#define O_NODELAY              O_BASE + 44
 
 const struct option cf_options[] = {
        {"background",      no_argument,       NULL, 'b'},
@@ -195,6 +196,7 @@ const struct option cf_options[] = {
        {"ia_pd_mix",       no_argument,       NULL, O_PFXDLGMIX},
        {"reject",          required_argument, NULL, O_REJECT},
        {"bootp",           no_argument,       NULL, O_BOOTP},
+       {"nodelay",         no_argument,       NULL, O_NODELAY},
        {NULL,              0,                 NULL, '\0'}
 };
 
@@ -2016,6 +2018,9 @@ err_sla:
        case O_BOOTP:
                ifo->options |= DHCPCD_BOOTP;
                break;
+       case O_NODELAY:
+               ifo->options &= ~DHCPCD_INITIAL_DELAY;
+               break;
        default:
                return 0;
        }
@@ -2115,7 +2120,7 @@ read_config(struct dhcpcd_ctx *ctx,
                logger(ctx, LOG_ERR, "%s: %m", __func__);
                return NULL;
        }
-       ifo->options |= DHCPCD_DAEMONISE | DHCPCD_LINK;
+       ifo->options |= DHCPCD_DAEMONISE | DHCPCD_LINK | DHCPCD_INITIAL_DELAY;
 #ifdef PLUGIN_DEV
        ifo->options |= DHCPCD_DEV;
 #endif
index a84de5f6adb219c2017e8070e44918e07686d95f..c94242d8031e522742244eb58ffe56184d1044f4 100644 (file)
 #define DHCPCD_ROUTER_HOST_ROUTE_WARNED        (1ULL << 55)
 #define DHCPCD_IPV6RA_ACCEPT_NOPUBLIC  (1ULL << 56)
 #define DHCPCD_BOOTP                   (1ULL << 57)
+#define DHCPCD_INITIAL_DELAY           (1ULL << 58)
 
 #define DHCPCD_WAITOPTS (DHCPCD_WAITIP | DHCPCD_WAITIP4 | DHCPCD_WAITIP6)
 
index e8e981b6a3d53c1d838a9451b5a50cecb8e3a26d..eebf867923086de4d6b6e3c956eb686efb119972 100644 (file)
--- a/ipv6nd.c
+++ b/ipv6nd.c
@@ -1697,6 +1697,11 @@ ipv6nd_startrs(struct interface *ifp)
        struct timespec tv;
 
        eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp);
+       if (!(ifp->options->options & DHCPCD_INITIAL_DELAY)) {
+               ipv6nd_startrs1(ifp);
+               return;
+       }
+
        tv.tv_sec = 0;
        tv.tv_nsec = (suseconds_t)arc4random_uniform(
            MAX_RTR_SOLICITATION_DELAY * NSEC_PER_SEC);