Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/dhcpcd/dist Import dhcpcd-8.0.0 with the follow...



details:   https://anonhg.NetBSD.org/src/rev/7ded99bd1ca6
branches:  trunk
changeset: 1000391:7ded99bd1ca6
user:      roy <roy%NetBSD.org@localhost>
date:      Wed Jul 24 09:54:48 2019 +0000

description:
Import dhcpcd-8.0.0 with the following changes:

  *  ARP now supports many requests
  *  Routing tables now use Red-Black Trees
  *  Script variables are no longer allocated manually

diffstat:

 external/bsd/dhcpcd/dist/compat/crypt/sha256.c   |     2 +-
 external/bsd/dhcpcd/dist/compat/rb.c             |  1345 ++++++++++++++++++++++
 external/bsd/dhcpcd/dist/compat/rbtree.h         |   206 +++
 external/bsd/dhcpcd/dist/configure               |    86 +-
 external/bsd/dhcpcd/dist/hooks/10-wpa_supplicant |     2 +-
 external/bsd/dhcpcd/dist/src/arp.c               |   269 ++-
 external/bsd/dhcpcd/dist/src/arp.h               |    18 +-
 external/bsd/dhcpcd/dist/src/auth.c              |     2 +
 external/bsd/dhcpcd/dist/src/auth.h              |     1 +
 external/bsd/dhcpcd/dist/src/bpf.h               |     3 +
 external/bsd/dhcpcd/dist/src/common.c            |    49 +-
 external/bsd/dhcpcd/dist/src/common.h            |    34 +-
 external/bsd/dhcpcd/dist/src/control.c           |     1 +
 external/bsd/dhcpcd/dist/src/control.h           |     1 +
 external/bsd/dhcpcd/dist/src/defs.h              |     3 +-
 external/bsd/dhcpcd/dist/src/dev.c               |     1 +
 external/bsd/dhcpcd/dist/src/dev.h               |     1 +
 external/bsd/dhcpcd/dist/src/dev/udev.c          |     1 +
 external/bsd/dhcpcd/dist/src/dhcp-common.c       |   355 +---
 external/bsd/dhcpcd/dist/src/dhcp-common.h       |    14 +-
 external/bsd/dhcpcd/dist/src/dhcp.h              |    15 +-
 external/bsd/dhcpcd/dist/src/dhcp6.h             |     3 +-
 external/bsd/dhcpcd/dist/src/dhcpcd.8.in         |     6 +-
 external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in    |     8 +
 external/bsd/dhcpcd/dist/src/dhcpcd.h            |    20 +-
 external/bsd/dhcpcd/dist/src/duid.c              |     1 +
 external/bsd/dhcpcd/dist/src/duid.h              |     1 +
 external/bsd/dhcpcd/dist/src/eloop.c             |     1 +
 external/bsd/dhcpcd/dist/src/eloop.h             |     1 +
 external/bsd/dhcpcd/dist/src/if-linux-wext.c     |     1 +
 external/bsd/dhcpcd/dist/src/if-linux.c          |   157 +-
 external/bsd/dhcpcd/dist/src/if-options.h        |     3 +-
 external/bsd/dhcpcd/dist/src/if-sun.c            |    77 +-
 external/bsd/dhcpcd/dist/src/if.c                |    83 +-
 external/bsd/dhcpcd/dist/src/if.h                |     4 +-
 external/bsd/dhcpcd/dist/src/ipv4.c              |   135 +-
 external/bsd/dhcpcd/dist/src/ipv4.h              |    11 +-
 external/bsd/dhcpcd/dist/src/ipv4ll.c            |   432 +++---
 external/bsd/dhcpcd/dist/src/ipv4ll.h            |    13 +-
 external/bsd/dhcpcd/dist/src/ipv6.c              |    87 +-
 external/bsd/dhcpcd/dist/src/ipv6.h              |     5 +-
 external/bsd/dhcpcd/dist/src/ipv6nd.h            |     5 +-
 external/bsd/dhcpcd/dist/src/logerr.c            |    61 +-
 external/bsd/dhcpcd/dist/src/logerr.h            |     1 +
 external/bsd/dhcpcd/dist/src/route.c             |   412 ++++-
 external/bsd/dhcpcd/dist/src/route.h             |    34 +-
 external/bsd/dhcpcd/dist/src/sa.c                |    33 +
 external/bsd/dhcpcd/dist/src/sa.h                |     7 +
 external/bsd/dhcpcd/dist/src/script.c            |   592 +++------
 external/bsd/dhcpcd/dist/src/script.h            |     2 +
 50 files changed, 3085 insertions(+), 1520 deletions(-)

diffs (truncated from 6906 to 300 lines):

diff -r c5788533a729 -r 7ded99bd1ca6 external/bsd/dhcpcd/dist/compat/crypt/sha256.c
--- a/external/bsd/dhcpcd/dist/compat/crypt/sha256.c    Wed Jul 24 09:28:29 2019 +0000
+++ b/external/bsd/dhcpcd/dist/compat/crypt/sha256.c    Wed Jul 24 09:54:48 2019 +0000
@@ -37,7 +37,7 @@
 #  endif
 #endif
 
-#include "common.h"
+#include "config.h"
 #include "sha256.h"
 
 #if BYTE_ORDER == BIG_ENDIAN
diff -r c5788533a729 -r 7ded99bd1ca6 external/bsd/dhcpcd/dist/compat/rb.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/dhcpcd/dist/compat/rb.c      Wed Jul 24 09:54:48 2019 +0000
@@ -0,0 +1,1345 @@
+/*     $NetBSD: rb.c,v 1.1.1.1 2019/07/24 09:54:48 roy Exp $   */
+
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas <matt%3am-software.com@localhost>.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "common.h"
+
+#if !defined(_KERNEL) && !defined(_STANDALONE)
+#include <sys/types.h>
+#include <stddef.h>
+#include <assert.h>
+#include <stdbool.h>
+#ifdef RBDEBUG
+#define        KASSERT(s)      assert(s)
+#define        __rbt_unused
+#else
+#define KASSERT(s)     do { } while (/*CONSTCOND*/ 0)
+#define        __rbt_unused    __unused
+#endif
+__RCSID("$NetBSD: rb.c,v 1.1.1.1 2019/07/24 09:54:48 roy Exp $");
+#else
+#include <lib/libkern/libkern.h>
+__KERNEL_RCSID(0, "$NetBSD: rb.c,v 1.1.1.1 2019/07/24 09:54:48 roy Exp $");
+#ifndef DIAGNOSTIC
+#define        __rbt_unused    __unused
+#else
+#define        __rbt_unused
+#endif
+#endif
+
+#ifdef _LIBC
+__weak_alias(rb_tree_init, _rb_tree_init)
+__weak_alias(rb_tree_find_node, _rb_tree_find_node)
+__weak_alias(rb_tree_find_node_geq, _rb_tree_find_node_geq)
+__weak_alias(rb_tree_find_node_leq, _rb_tree_find_node_leq)
+__weak_alias(rb_tree_insert_node, _rb_tree_insert_node)
+__weak_alias(rb_tree_remove_node, _rb_tree_remove_node)
+__weak_alias(rb_tree_iterate, _rb_tree_iterate)
+#ifdef RBDEBUG
+__weak_alias(rb_tree_check, _rb_tree_check)
+__weak_alias(rb_tree_depths, _rb_tree_depths)
+#endif
+
+#include "namespace.h"
+#endif
+
+#ifdef RBTEST
+#include "rbtree.h"
+#else
+#include <sys/rbtree.h>
+#endif
+
+static void rb_tree_insert_rebalance(struct rb_tree *, struct rb_node *);
+static void rb_tree_removal_rebalance(struct rb_tree *, struct rb_node *,
+       unsigned int);
+#ifdef RBDEBUG
+static const struct rb_node *rb_tree_iterate_const(const struct rb_tree *,
+       const struct rb_node *, const unsigned int);
+static bool rb_tree_check_node(const struct rb_tree *, const struct rb_node *,
+       const struct rb_node *, bool);
+#else
+#define        rb_tree_check_node(a, b, c, d)  true
+#endif
+
+#define        RB_NODETOITEM(rbto, rbn)        \
+    ((void *)((uintptr_t)(rbn) - (rbto)->rbto_node_offset))
+#define        RB_ITEMTONODE(rbto, rbn)        \
+    ((rb_node_t *)((uintptr_t)(rbn) + (rbto)->rbto_node_offset))
+
+#define        RB_SENTINEL_NODE        NULL
+
+void
+rb_tree_init(struct rb_tree *rbt, const rb_tree_ops_t *ops)
+{
+
+       rbt->rbt_ops = ops;
+       rbt->rbt_root = RB_SENTINEL_NODE;
+       RB_TAILQ_INIT(&rbt->rbt_nodes);
+#ifndef RBSMALL
+       rbt->rbt_minmax[RB_DIR_LEFT] = rbt->rbt_root;   /* minimum node */
+       rbt->rbt_minmax[RB_DIR_RIGHT] = rbt->rbt_root;  /* maximum node */
+#endif
+#ifdef RBSTATS
+       rbt->rbt_count = 0;
+       rbt->rbt_insertions = 0;
+       rbt->rbt_removals = 0;
+       rbt->rbt_insertion_rebalance_calls = 0;
+       rbt->rbt_insertion_rebalance_passes = 0;
+       rbt->rbt_removal_rebalance_calls = 0;
+       rbt->rbt_removal_rebalance_passes = 0;
+#endif
+}
+
+void *
+rb_tree_find_node(struct rb_tree *rbt, const void *key)
+{
+       const rb_tree_ops_t *rbto = rbt->rbt_ops;
+       rbto_compare_key_fn compare_key = rbto->rbto_compare_key;
+       struct rb_node *parent = rbt->rbt_root;
+
+       while (!RB_SENTINEL_P(parent)) {
+               void *pobj = RB_NODETOITEM(rbto, parent);
+               const signed int diff = (*compare_key)(rbto->rbto_context,
+                   pobj, key);
+               if (diff == 0)
+                       return pobj;
+               parent = parent->rb_nodes[diff < 0];
+       }
+
+       return NULL;
+}
+
+void *
+rb_tree_find_node_geq(struct rb_tree *rbt, const void *key)
+{
+       const rb_tree_ops_t *rbto = rbt->rbt_ops;
+       rbto_compare_key_fn compare_key = rbto->rbto_compare_key;
+       struct rb_node *parent = rbt->rbt_root, *last = NULL;
+
+       while (!RB_SENTINEL_P(parent)) {
+               void *pobj = RB_NODETOITEM(rbto, parent);
+               const signed int diff = (*compare_key)(rbto->rbto_context,
+                   pobj, key);
+               if (diff == 0)
+                       return pobj;
+               if (diff > 0)
+                       last = parent;
+               parent = parent->rb_nodes[diff < 0];
+       }
+
+       return last == NULL ? NULL : RB_NODETOITEM(rbto, last);
+}
+
+void *
+rb_tree_find_node_leq(struct rb_tree *rbt, const void *key)
+{
+       const rb_tree_ops_t *rbto = rbt->rbt_ops;
+       rbto_compare_key_fn compare_key = rbto->rbto_compare_key;
+       struct rb_node *parent = rbt->rbt_root, *last = NULL;
+
+       while (!RB_SENTINEL_P(parent)) {
+               void *pobj = RB_NODETOITEM(rbto, parent);
+               const signed int diff = (*compare_key)(rbto->rbto_context,
+                   pobj, key);
+               if (diff == 0)
+                       return pobj;
+               if (diff < 0)
+                       last = parent;
+               parent = parent->rb_nodes[diff < 0];
+       }
+
+       return last == NULL ? NULL : RB_NODETOITEM(rbto, last);
+}
+
+void *
+rb_tree_insert_node(struct rb_tree *rbt, void *object)
+{
+       const rb_tree_ops_t *rbto = rbt->rbt_ops;
+       rbto_compare_nodes_fn compare_nodes = rbto->rbto_compare_nodes;
+       struct rb_node *parent, *tmp, *self = RB_ITEMTONODE(rbto, object);
+       unsigned int position;
+       bool rebalance;
+
+       RBSTAT_INC(rbt->rbt_insertions);
+
+       tmp = rbt->rbt_root;
+       /*
+        * This is a hack.  Because rbt->rbt_root is just a struct rb_node *,
+        * just like rb_node->rb_nodes[RB_DIR_LEFT], we can use this fact to
+        * avoid a lot of tests for root and know that even at root,
+        * updating RB_FATHER(rb_node)->rb_nodes[RB_POSITION(rb_node)] will
+        * update rbt->rbt_root.
+        */
+       parent = (struct rb_node *)(void *)&rbt->rbt_root;
+       position = RB_DIR_LEFT;
+
+       /*
+        * Find out where to place this new leaf.
+        */
+       while (!RB_SENTINEL_P(tmp)) {
+               void *tobj = RB_NODETOITEM(rbto, tmp);
+               const signed int diff = (*compare_nodes)(rbto->rbto_context,
+                   tobj, object);
+               if (__predict_false(diff == 0)) {
+                       /*
+                        * Node already exists; return it.
+                        */
+                       return tobj;
+               }
+               parent = tmp;
+               position = (diff < 0);
+               tmp = parent->rb_nodes[position];
+       }
+
+#ifdef RBDEBUG
+       {
+               struct rb_node *prev = NULL, *next = NULL;
+
+               if (position == RB_DIR_RIGHT)
+                       prev = parent;
+               else if (tmp != rbt->rbt_root)
+                       next = parent;
+
+               /*
+                * Verify our sequential position
+                */
+               KASSERT(prev == NULL || !RB_SENTINEL_P(prev));
+               KASSERT(next == NULL || !RB_SENTINEL_P(next));
+               if (prev != NULL && next == NULL)
+                       next = TAILQ_NEXT(prev, rb_link);
+               if (prev == NULL && next != NULL)
+                       prev = TAILQ_PREV(next, rb_node_qh, rb_link);
+               KASSERT(prev == NULL || !RB_SENTINEL_P(prev));
+               KASSERT(next == NULL || !RB_SENTINEL_P(next));
+               KASSERT(prev == NULL || (*compare_nodes)(rbto->rbto_context,
+                   RB_NODETOITEM(rbto, prev), RB_NODETOITEM(rbto, self)) < 0);
+               KASSERT(next == NULL || (*compare_nodes)(rbto->rbto_context,
+                   RB_NODETOITEM(rbto, self), RB_NODETOITEM(rbto, next)) < 0);
+       }
+#endif
+
+       /*
+        * Initialize the node and insert as a leaf into the tree.
+        */
+       RB_SET_FATHER(self, parent);
+       RB_SET_POSITION(self, position);
+       if (__predict_false(parent == (struct rb_node *)(void *)&rbt->rbt_root)) {
+               RB_MARK_BLACK(self);            /* root is always black */
+#ifndef RBSMALL
+               rbt->rbt_minmax[RB_DIR_LEFT] = self;
+               rbt->rbt_minmax[RB_DIR_RIGHT] = self;
+#endif
+               rebalance = false;
+       } else {
+               KASSERT(position == RB_DIR_LEFT || position == RB_DIR_RIGHT);
+#ifndef RBSMALL
+               /*
+                * Keep track of the minimum and maximum nodes.  If our
+                * parent is a minmax node and we on their min/max side,
+                * we must be the new min/max node.
+                */
+               if (parent == rbt->rbt_minmax[position])
+                       rbt->rbt_minmax[position] = self;
+#endif /* !RBSMALL */
+               /*
+                * All new nodes are colored red.  We only need to rebalance
+                * if our parent is also red.
+                */
+               RB_MARK_RED(self);
+               rebalance = RB_RED_P(parent);
+       }
+       KASSERT(RB_SENTINEL_P(parent->rb_nodes[position]));
+       self->rb_left = parent->rb_nodes[position];
+       self->rb_right = parent->rb_nodes[position];
+       parent->rb_nodes[position] = self;
+       KASSERT(RB_CHILDLESS_P(self));
+
+       /*



Home | Main Index | Thread Index | Old Index