Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/dhcp merge dhcp-4.4.1
details: https://anonhg.NetBSD.org/src/rev/851b2596149e
branches: trunk
changeset: 321843:851b2596149e
user: christos <christos%NetBSD.org@localhost>
date: Sat Apr 07 21:19:31 2018 +0000
description:
merge dhcp-4.4.1
diffstat:
external/bsd/dhcp/bin/client/Makefile | 4 +-
external/bsd/dhcp/dist/client/client_tables.c | 7 +-
external/bsd/dhcp/dist/client/dhc6.c | 1450 ++++++++++++--
external/bsd/dhcp/dist/client/dhclient.8 | 102 +-
external/bsd/dhcp/dist/client/dhclient.c | 1436 ++++++++++++--
external/bsd/dhcp/dist/common/alloc.c | 78 +-
external/bsd/dhcp/dist/common/bpf.c | 75 +-
external/bsd/dhcp/dist/common/comapi.c | 27 +-
external/bsd/dhcp/dist/common/conflex.c | 32 +-
external/bsd/dhcp/dist/common/discover.c | 543 +----
external/bsd/dhcp/dist/common/dispatch.c | 43 +-
external/bsd/dhcp/dist/common/dlpi.c | 30 +-
external/bsd/dhcp/dist/common/dns.c | 974 +++++++--
external/bsd/dhcp/dist/common/execute.c | 44 +-
external/bsd/dhcp/dist/common/icmp.c | 14 +-
external/bsd/dhcp/dist/common/lpf.c | 40 +-
external/bsd/dhcp/dist/common/nit.c | 17 +-
external/bsd/dhcp/dist/common/ns_name.c | 15 +-
external/bsd/dhcp/dist/common/options.c | 510 +++-
external/bsd/dhcp/dist/common/packet.c | 33 +-
external/bsd/dhcp/dist/common/parse.c | 21 +-
external/bsd/dhcp/dist/common/raw.c | 18 +-
external/bsd/dhcp/dist/common/socket.c | 121 +-
external/bsd/dhcp/dist/common/tr.c | 14 +-
external/bsd/dhcp/dist/common/tree.c | 32 +-
external/bsd/dhcp/dist/common/upf.c | 16 +-
external/bsd/dhcp/dist/dhcpctl/cltest.c | 49 +-
external/bsd/dhcp/dist/dhcpctl/omshell.c | 73 +-
external/bsd/dhcp/dist/includes/config.h.in | 15 +-
external/bsd/dhcp/dist/includes/dhcpd.h | 228 +-
external/bsd/dhcp/dist/includes/isc-dhcp/dst.h | 143 -
external/bsd/dhcp/dist/includes/minires.h | 47 -
external/bsd/dhcp/dist/includes/omapip/isclib.h | 4 +-
external/bsd/dhcp/dist/includes/omapip/omapip_p.h | 12 +-
external/bsd/dhcp/dist/includes/omapip/result.h | 11 +-
external/bsd/dhcp/dist/omapip/dispatch.c | 18 +-
external/bsd/dhcp/dist/omapip/isclib.c | 120 +-
external/bsd/dhcp/dist/relay/dhcrelay.c | 546 ++++-
external/bsd/dhcp/dist/server/confpars.c | 389 ++-
external/bsd/dhcp/dist/server/ddns.c | 685 +++++-
external/bsd/dhcp/dist/server/dhcp.c | 567 +++++-
external/bsd/dhcp/dist/server/dhcpd.c | 547 ++++-
external/bsd/dhcp/dist/server/dhcpleasequery.c | 31 +-
external/bsd/dhcp/dist/server/dhcpv6.c | 2060 +++++++++++++++++---
external/bsd/dhcp/dist/server/failover.c | 6 +-
external/bsd/dhcp/dist/server/mdb.c | 91 +-
external/bsd/dhcp/dist/server/mdb6.c | 514 ++++-
external/bsd/dhcp/dist/server/omapi.c | 149 +-
external/bsd/dhcp/dist/tests/t_api.c | 13 +-
external/bsd/dhcp/dist/util/bindvar.sh | 35 -
50 files changed, 9303 insertions(+), 2746 deletions(-)
diffs (truncated from 19448 to 300 lines):
diff -r 98162a9aa0b5 -r 851b2596149e external/bsd/dhcp/bin/client/Makefile
--- a/external/bsd/dhcp/bin/client/Makefile Sat Apr 07 20:44:05 2018 +0000
+++ b/external/bsd/dhcp/bin/client/Makefile Sat Apr 07 21:19:31 2018 +0000
@@ -1,9 +1,9 @@
-# $NetBSD: Makefile,v 1.1 2013/03/24 15:54:30 christos Exp $
+# $NetBSD: Makefile,v 1.2 2018/04/07 21:19:31 christos Exp $
BINDIR= /sbin
.include <bsd.own.mk> # for MKDYNAMICROOT definition
-SRCS = dhclient.c clparse.c dhc6.c
+SRCS = dhclient.c clparse.c dhc6.c client_tables.c
PROG = dhclient
MAN = dhclient.8 dhclient.conf.5 dhclient.leases.5 dhclient-script.8
CPPFLAGS += -DCLIENT_PATH='"PATH=/usr/bin:/usr/sbin:/bin:/sbin"'
diff -r 98162a9aa0b5 -r 851b2596149e external/bsd/dhcp/dist/client/client_tables.c
--- a/external/bsd/dhcp/dist/client/client_tables.c Sat Apr 07 20:44:05 2018 +0000
+++ b/external/bsd/dhcp/dist/client/client_tables.c Sat Apr 07 21:19:31 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: client_tables.c,v 1.1.1.1 2018/04/07 20:44:25 christos Exp $ */
+/* $NetBSD: client_tables.c,v 1.2 2018/04/07 21:19:31 christos Exp $ */
/* client_tables.c
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: client_tables.c,v 1.1.1.1 2018/04/07 20:44:25 christos Exp $");
+__RCSID("$NetBSD: client_tables.c,v 1.2 2018/04/07 21:19:31 christos Exp $");
#include "dhcpd.h"
@@ -41,7 +41,8 @@
#define CLIENT_HASH_SIZE (2*(sizeof(client_options) / sizeof(struct option)))
-void initialize_client_option_spaces()
+void initialize_client_option_spaces(void);
+void initialize_client_option_spaces(void)
{
int i;
diff -r 98162a9aa0b5 -r 851b2596149e external/bsd/dhcp/dist/client/dhc6.c
--- a/external/bsd/dhcp/dist/client/dhc6.c Sat Apr 07 20:44:05 2018 +0000
+++ b/external/bsd/dhcp/dist/client/dhc6.c Sat Apr 07 21:19:31 2018 +0000
@@ -1,13 +1,14 @@
-/* $NetBSD: dhc6.c,v 1.7 2016/01/10 20:10:44 christos Exp $ */
+/* $NetBSD: dhc6.c,v 1.8 2018/04/07 21:19:31 christos Exp $ */
+
/* dhc6.c - DHCPv6 client routines. */
/*
- * Copyright (c) 2012-2015 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2012-2017 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2006-2010 by Internet Systems Consortium, Inc. ("ISC")
*
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: dhc6.c,v 1.7 2016/01/10 20:10:44 christos Exp $");
+__RCSID("$NetBSD: dhc6.c,v 1.8 2018/04/07 21:19:31 christos Exp $");
#include "dhcpd.h"
@@ -56,13 +57,16 @@
static void dhc6_ia_destroy(struct dhc6_ia **src, const char *file, int line);
static isc_result_t dhc6_parse_ia_na(struct dhc6_ia **pia,
struct packet *packet,
- struct option_state *options);
+ struct option_state *options,
+ unsigned code);
static isc_result_t dhc6_parse_ia_ta(struct dhc6_ia **pia,
struct packet *packet,
- struct option_state *options);
+ struct option_state *options,
+ unsigned code);
static isc_result_t dhc6_parse_ia_pd(struct dhc6_ia **pia,
struct packet *packet,
- struct option_state *options);
+ struct option_state *options,
+ unsigned code);
static isc_result_t dhc6_parse_addrs(struct dhc6_addr **paddr,
struct packet *packet,
struct option_state *options);
@@ -82,24 +86,42 @@
void do_info_request6(void *input);
void do_confirm6(void *input);
void reply_handler(struct packet *packet, struct client_state *client);
+static isc_result_t dhc6_create_iaid(struct client_state *client,
+ struct data_string *ia,
+ int idx,
+ unsigned len);
+static int dhc6_count_ia(struct dhc6_lease *lease,
+ u_int16_t ia_type);
+static isc_result_t dhc6_bare_ia_xx(struct client_state *client,
+ struct data_string *packet,
+ int wanted,
+ u_int16_t ia_type);
static isc_result_t dhc6_add_ia_na(struct client_state *client,
struct data_string *packet,
struct dhc6_lease *lease,
- u_int8_t message);
+ u_int8_t message,
+ int wanted,
+ int *added);
static isc_result_t dhc6_add_ia_ta(struct client_state *client,
struct data_string *packet,
struct dhc6_lease *lease,
- u_int8_t message);
+ u_int8_t message,
+ int wanted,
+ int *added);
static isc_result_t dhc6_add_ia_pd(struct client_state *client,
struct data_string *packet,
struct dhc6_lease *lease,
- u_int8_t message);
+ u_int8_t message,
+ int wanted,
+ int *added);
static isc_boolean_t stopping_finished(void);
static void dhc6_merge_lease(struct dhc6_lease *src, struct dhc6_lease *dst);
void do_select6(void *input);
void do_refresh6(void *input);
static void do_release6(void *input);
static void start_bound(struct client_state *client);
+static void start_decline6(struct client_state *client);
+static void do_decline6(void *input);
static void start_informed(struct client_state *client);
void informed_handler(struct packet *packet, struct client_state *client);
void bound_handler(struct packet *packet, struct client_state *client);
@@ -116,12 +138,28 @@
static void script_write_requested6(struct client_state *client);
static isc_boolean_t active_prefix(struct client_state *client);
-static int check_timing6(struct client_state *client, u_int8_t msg_type,
- char *msg_str, struct dhc6_lease *lease,
- struct data_string *ds);
+static int check_timing6(struct client_state *client, u_int8_t msg_type,
+ char *msg_str, struct dhc6_lease *lease,
+ struct data_string *ds);
+static isc_result_t dhc6_get_status_code(struct option_state *options,
+ unsigned *code,
+ struct data_string *msg);
+static isc_result_t dhc6_check_status(isc_result_t rval,
+ struct option_state *options,
+ const char *scope,
+ unsigned *code);
+static int dhc6_score_lease(struct client_state *client,
+ struct dhc6_lease *lease);
+static isc_result_t dhc6_add_ia_na_decline(struct client_state *client,
+ struct data_string *packet,
+ struct dhc6_lease *lease);
+static int drop_declined_addrs(struct dhc6_lease *lease);
+static isc_boolean_t unexpired_address_in_lease(struct dhc6_lease *lease);
extern int onetry;
extern int stateless;
+extern int prefix_len_hint;
+extern int address_prefix_len;
/*
* Assign DHCPv6 port numbers as a client.
@@ -366,7 +404,7 @@
if (elapsed.tv_sec >= client->MRD) {
/*
* The desired RT is the time that will be remaining in MRD
- * when the current timeout finishes. We then have
+ * when the current timeout finishes. We then have
* desired RT = MRD - (elapsed time + previous RT); or
* desired RT = MRD - elapsed_plut_rt;
*/
@@ -422,6 +460,12 @@
rval = ISC_FALSE;
}
+ /* clean up pointers to the strings */
+ if (sid.data != NULL)
+ data_string_forget(&sid, MDL);
+ if (cid.data != NULL)
+ data_string_forget(&cid, MDL);
+
return rval;
}
@@ -473,6 +517,10 @@
struct dhc6_addr **insert_addr, *addr;
copy = dmalloc(sizeof(*ia), file, line);
+ if (copy == NULL) {
+ log_error("Out of memory for v6 duplicate IA structure.");
+ return NULL;
+ }
memcpy(copy->iaid, ia->iaid, sizeof(copy->iaid));
@@ -532,13 +580,20 @@
* Form a DHCPv6 lease structure based upon packet contents. Creates and
* populates IA's and any IAADDR/IAPREFIX's they contain.
* Parsed options are deleted in order to not save them in the lease file.
+ *
+ * If we get a status code of NoAddrs or NoPrefix we toss the affected
+ * IAs. If it as at the top level we toss all IAs of that type. If it
+ * is in an IA we only toss that one. According to the spec we shouldn't
+ * get a NoPrefix status at the top level but we will allow it.
+ *
*/
static struct dhc6_lease *
-dhc6_leaseify(struct packet *packet)
+dhc6_leaseify(struct packet *packet, struct client_state* client)
{
struct data_string ds;
struct dhc6_lease *lease;
struct option_cache *oc;
+ unsigned code;
lease = dmalloc(sizeof(*lease), MDL);
if (lease == NULL) {
@@ -572,12 +627,28 @@
}
delete_option(&dhcpv6_universe, lease->options, D6O_PREFERENCE);
+ /* Get the top level status code. If the code is NoAddrsAvail
+ * or NoPrefixAvail strip it from the options as we don't
+ * want it to show up in check_[advertise reply]. We
+ * pass it along to the parse_ia_xx routines and they
+ * will drop the affected IAs for NoAddrs or NoPrefix,
+ * other status codes will be ignored and handled by
+ * the check_[advertise reply] routines.
+ */
+ code = STATUS_Success;
+ if ((dhc6_get_status_code(lease->options, &code, NULL) == ISC_R_SUCCESS)
+ &&
+ ((code == STATUS_NoAddrsAvail) || (code == STATUS_NoPrefixAvail))) {
+ delete_option(&dhcpv6_universe, lease->options,
+ D6O_STATUS_CODE);
+ }
+
/*
* Dig into recursive DHCPv6 pockets for IA_NA and contained IAADDR
* options.
*/
if (dhc6_parse_ia_na(&lease->bindings, packet,
- lease->options) != ISC_R_SUCCESS) {
+ lease->options, code) != ISC_R_SUCCESS) {
/* Error conditions are logged by the caller. */
dhc6_lease_destroy(&lease, MDL);
return NULL;
@@ -587,7 +658,7 @@
* options.
*/
if (dhc6_parse_ia_ta(&lease->bindings, packet,
- lease->options) != ISC_R_SUCCESS) {
+ lease->options, code) != ISC_R_SUCCESS) {
/* Error conditions are logged by the caller. */
dhc6_lease_destroy(&lease, MDL);
return NULL;
@@ -597,7 +668,7 @@
* options.
*/
if (dhc6_parse_ia_pd(&lease->bindings, packet,
- lease->options) != ISC_R_SUCCESS) {
+ lease->options, code) != ISC_R_SUCCESS) {
/* Error conditions are logged by the caller. */
dhc6_lease_destroy(&lease, MDL);
return NULL;
@@ -626,17 +697,23 @@
lease->server_id.data, 52));
}
+ execute_statements_in_scope(NULL, (struct packet *)packet, NULL,
+ client, lease->options, lease->options,
+ &global_scope, client->config->on_receipt,
+ NULL, NULL);
+
return lease;
}
static isc_result_t
dhc6_parse_ia_na(struct dhc6_ia **pia, struct packet *packet,
- struct option_state *options)
+ struct option_state *options, unsigned code)
{
struct data_string ds;
struct dhc6_ia *ia;
struct option_cache *oc;
isc_result_t result;
+ unsigned ia_code;
memset(&ds, 0, sizeof(ds));
Home |
Main Index |
Thread Index |
Old Index