sync with OpenBSD -current

This commit is contained in:
purplerain 2024-04-14 02:31:08 +00:00
parent 137d408ac1
commit e0d126d03b
Signed by: purplerain
GPG Key ID: F42C07F07E2E35B7
143 changed files with 5355 additions and 3727 deletions

View File

@ -1,4 +1,4 @@
/* $OpenBSD: dsa_ameth.c,v 1.57 2024/01/04 17:01:26 tb Exp $ */ /* $OpenBSD: dsa_ameth.c,v 1.59 2024/04/13 14:02:51 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2006. * project 2006.
*/ */
@ -71,6 +71,7 @@
#include "bn_local.h" #include "bn_local.h"
#include "dsa_local.h" #include "dsa_local.h"
#include "evp_local.h" #include "evp_local.h"
#include "x509_local.h"
static int static int
dsa_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey) dsa_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey)
@ -634,11 +635,11 @@ dsa_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2)
hnid = OBJ_obj2nid(alg1->algorithm); hnid = OBJ_obj2nid(alg1->algorithm);
if (hnid == NID_undef) if (hnid == NID_undef)
return -1; return -1;
if (!OBJ_find_sigid_by_algs(&snid, hnid, if (!OBJ_find_sigid_by_algs(&snid, hnid, EVP_PKEY_id(pkey)))
EVP_PKEY_id(pkey))) return -1;
if (!X509_ALGOR_set0_by_nid(alg2, snid, V_ASN1_UNDEF,
NULL))
return -1; return -1;
X509_ALGOR_set0(alg2, OBJ_nid2obj(snid), V_ASN1_UNDEF,
0);
} }
return 1; return 1;
@ -656,7 +657,9 @@ dsa_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2)
return -1; return -1;
if (!OBJ_find_sigid_by_algs(&snid, hnid, EVP_PKEY_id(pkey))) if (!OBJ_find_sigid_by_algs(&snid, hnid, EVP_PKEY_id(pkey)))
return -1; return -1;
X509_ALGOR_set0(alg2, OBJ_nid2obj(snid), V_ASN1_UNDEF, 0); if (!X509_ALGOR_set0_by_nid(alg2, snid, V_ASN1_UNDEF,
NULL))
return -1;
} }
return 1; return 1;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ec_ameth.c,v 1.51 2024/01/04 17:01:26 tb Exp $ */ /* $OpenBSD: ec_ameth.c,v 1.52 2024/04/13 14:02:51 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2006. * project 2006.
*/ */
@ -69,6 +69,7 @@
#include "asn1_local.h" #include "asn1_local.h"
#include "ec_local.h" #include "ec_local.h"
#include "evp_local.h" #include "evp_local.h"
#include "x509_local.h"
#ifndef OPENSSL_NO_CMS #ifndef OPENSSL_NO_CMS
static int ecdh_cms_decrypt(CMS_RecipientInfo *ri); static int ecdh_cms_decrypt(CMS_RecipientInfo *ri);
@ -637,7 +638,9 @@ ec_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2)
return -1; return -1;
if (!OBJ_find_sigid_by_algs(&snid, hnid, EVP_PKEY_id(pkey))) if (!OBJ_find_sigid_by_algs(&snid, hnid, EVP_PKEY_id(pkey)))
return -1; return -1;
X509_ALGOR_set0(alg2, OBJ_nid2obj(snid), V_ASN1_UNDEF, 0); if (!X509_ALGOR_set0_by_nid(alg2, snid, V_ASN1_UNDEF,
NULL))
return -1;
} }
return 1; return 1;
@ -655,7 +658,9 @@ ec_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2)
return -1; return -1;
if (!OBJ_find_sigid_by_algs(&snid, hnid, EVP_PKEY_id(pkey))) if (!OBJ_find_sigid_by_algs(&snid, hnid, EVP_PKEY_id(pkey)))
return -1; return -1;
X509_ALGOR_set0(alg2, OBJ_nid2obj(snid), V_ASN1_UNDEF, 0); if (!X509_ALGOR_set0_by_nid(alg2, snid, V_ASN1_UNDEF,
NULL))
return -1;
} }
return 1; return 1;

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: iked.conf.5,v 1.95 2022/07/22 20:31:39 jmc Exp $ .\" $OpenBSD: iked.conf.5,v 1.96 2024/04/13 12:11:08 jmc Exp $
.\" .\"
.\" Copyright (c) 2010 - 2014 Reyk Floeter <reyk@openbsd.org> .\" Copyright (c) 2010 - 2014 Reyk Floeter <reyk@openbsd.org>
.\" Copyright (c) 2004 Mathieu Sauve-Frankel All rights reserved. .\" Copyright (c) 2004 Mathieu Sauve-Frankel All rights reserved.
@ -15,7 +15,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\" .\"
.Dd $Mdocdate: July 22 2022 $ .Dd $Mdocdate: April 13 2024 $
.Dt IKED.CONF 5 .Dt IKED.CONF 5
.Os .Os
.Sh NAME .Sh NAME
@ -663,6 +663,10 @@ Use ECDSA with a 521-bit elliptic curve key and SHA2-512 for authentication.
Use a pre-shared key Use a pre-shared key
.Ar string .Ar string
or hex value (starting with 0x) for authentication. or hex value (starting with 0x) for authentication.
.It Ic psk file Ar path
Use a pre-shared hex key (without leading 0x) read from
.Ar path
for authentication.
.It Ic rfc7427 .It Ic rfc7427
Only use RFC 7427 signatures for authentication. Only use RFC 7427 signatures for authentication.
RFC 7427 signatures currently only support SHA2-256 as the hash. RFC 7427 signatures currently only support SHA2-256 as the hash.

View File

@ -1,4 +1,4 @@
/* $OpenBSD: parse.y,v 1.144 2023/08/11 11:24:55 tobhe Exp $ */ /* $OpenBSD: parse.y,v 1.145 2024/04/13 15:58:10 jrick Exp $ */
/* /*
* Copyright (c) 2019 Tobias Heider <tobias.heider@stusta.de> * Copyright (c) 2019 Tobias Heider <tobias.heider@stusta.de>
@ -1950,8 +1950,8 @@ parsekeyfile(char *filename, struct iked_auth *auth)
if ((fd = open(filename, O_RDONLY)) == -1) if ((fd = open(filename, O_RDONLY)) == -1)
err(1, "open %s", filename); err(1, "open %s", filename);
if (fstat(fd, &sb) == -1) if (check_file_secrecy(fd, filename) == -1)
err(1, "parsekeyfile: stat %s", filename); exit(1);
if ((sb.st_size > KEYSIZE_LIMIT) || (sb.st_size == 0)) if ((sb.st_size > KEYSIZE_LIMIT) || (sb.st_size == 0))
errx(1, "%s: key too %s", filename, sb.st_size ? "large" : errx(1, "%s: key too %s", filename, sb.st_size ? "large" :
"small"); "small");

View File

@ -329,9 +329,6 @@
/* Define to 1 if you have the `if_nametoindex' function. */ /* Define to 1 if you have the `if_nametoindex' function. */
#define HAVE_IF_NAMETOINDEX 1 #define HAVE_IF_NAMETOINDEX 1
/* Define to 1 if you have the `if_nametoindex' function. */
#define HAVE_IF_NAMETOINDEX 1
/* Define to 1 if you have the `inet_aton' function. */ /* Define to 1 if you have the `inet_aton' function. */
#define HAVE_INET_ATON 1 #define HAVE_INET_ATON 1
@ -776,7 +773,7 @@
#define PACKAGE_NAME "unbound" #define PACKAGE_NAME "unbound"
/* Define to the full name and version of this package. */ /* Define to the full name and version of this package. */
#define PACKAGE_STRING "unbound 1.18.0" #define PACKAGE_STRING "unbound 1.19.3"
/* Define to the one symbol short name of this package. */ /* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "unbound" #define PACKAGE_TARNAME "unbound"
@ -785,7 +782,7 @@
#define PACKAGE_URL "" #define PACKAGE_URL ""
/* Define to the version of this package. */ /* Define to the version of this package. */
#define PACKAGE_VERSION "1.18.0" #define PACKAGE_VERSION "1.19.3"
/* default pidfile location */ /* default pidfile location */
#define PIDFILE "" #define PIDFILE ""
@ -808,7 +805,7 @@
#define ROOT_CERT_FILE "/var/unbound/etc/icannbundle.pem" #define ROOT_CERT_FILE "/var/unbound/etc/icannbundle.pem"
/* version number for resource files */ /* version number for resource files */
#define RSRC_PACKAGE_VERSION 1,18,0,0 #define RSRC_PACKAGE_VERSION 1,19,3,0
/* Directory to chdir to */ /* Directory to chdir to */
#define RUN_DIR "/var/unbound/etc" #define RUN_DIR "/var/unbound/etc"
@ -889,7 +886,7 @@
/* #undef USE_ED448 */ /* #undef USE_ED448 */
/* Define this to enable GOST support. */ /* Define this to enable GOST support. */
#define USE_GOST 1 /* #undef USE_GOST */
/* Define to 1 to use ipsecmod support. */ /* Define to 1 to use ipsecmod support. */
/* #undef USE_IPSECMOD */ /* #undef USE_IPSECMOD */

View File

@ -573,28 +573,29 @@ static enum module_ext_state
handle_event_pass(struct module_qstate* qstate, int id) handle_event_pass(struct module_qstate* qstate, int id)
{ {
struct dns64_qstate* iq = (struct dns64_qstate*)qstate->minfo[id]; struct dns64_qstate* iq = (struct dns64_qstate*)qstate->minfo[id];
if (iq && iq->state == DNS64_NEW_QUERY int synth_all_cfg = qstate->env->cfg->dns64_synthall;
&& qstate->qinfo.qtype == LDNS_RR_TYPE_PTR int synth_qname = 0;
&& qstate->qinfo.qname_len == 74
&& !strcmp((char*)&qstate->qinfo.qname[64], "\03ip6\04arpa"))
/* Handle PTR queries for IPv6 addresses. */
return handle_ipv6_ptr(qstate, id);
if (qstate->env->cfg->dns64_synthall && if(iq && iq->state == DNS64_NEW_QUERY
iq && iq->state == DNS64_NEW_QUERY && qstate->qinfo.qtype == LDNS_RR_TYPE_PTR
&& qstate->qinfo.qtype == LDNS_RR_TYPE_AAAA) && qstate->qinfo.qname_len == 74
return generate_type_A_query(qstate, id); && !strcmp((char*)&qstate->qinfo.qname[64], "\03ip6\04arpa")) {
/* Handle PTR queries for IPv6 addresses. */
return handle_ipv6_ptr(qstate, id);
}
if(dns64_always_synth_for_qname(qstate, id) && if(iq && iq->state == DNS64_NEW_QUERY &&
iq && iq->state == DNS64_NEW_QUERY qstate->qinfo.qtype == LDNS_RR_TYPE_AAAA &&
&& !(qstate->query_flags & BIT_CD) (synth_all_cfg ||
&& qstate->qinfo.qtype == LDNS_RR_TYPE_AAAA) { (synth_qname=(dns64_always_synth_for_qname(qstate, id)
verbose(VERB_ALGO, "dns64: ignore-aaaa and synthesize anyway"); && !(qstate->query_flags & BIT_CD))))) {
if(synth_qname)
verbose(VERB_ALGO, "dns64: ignore-aaaa and synthesize anyway");
return generate_type_A_query(qstate, id); return generate_type_A_query(qstate, id);
} }
/* We are finished when our sub-query is finished. */ /* We are finished when our sub-query is finished. */
if (iq && iq->state == DNS64_SUBQUERY_FINISHED) if(iq && iq->state == DNS64_SUBQUERY_FINISHED)
return module_finished; return module_finished;
/* Otherwise, pass request to next module. */ /* Otherwise, pass request to next module. */
@ -627,32 +628,37 @@ handle_event_moddone(struct module_qstate* qstate, int id)
* synthesize in (sec 5.1.2 of RFC6147). * synthesize in (sec 5.1.2 of RFC6147).
* - A successful AAAA query with an answer. * - A successful AAAA query with an answer.
*/ */
if((!iq || iq->state != DNS64_INTERNAL_QUERY)
&& qstate->qinfo.qtype == LDNS_RR_TYPE_AAAA
&& !(qstate->query_flags & BIT_CD)
&& !(qstate->return_msg &&
qstate->return_msg->rep &&
reply_find_answer_rrset(&qstate->qinfo,
qstate->return_msg->rep)))
/* not internal, type AAAA, not CD, and no answer RRset,
* So, this is a AAAA noerror/nodata answer */
return generate_type_A_query(qstate, id);
if((!iq || iq->state != DNS64_INTERNAL_QUERY) /* When an AAAA query completes check if we want to perform DNS64
&& qstate->qinfo.qtype == LDNS_RR_TYPE_AAAA * synthesis. We skip queries with DNSSEC enabled (!CD) and
&& !(qstate->query_flags & BIT_CD) * ones generated by us to retrive the A/PTR record to use for
&& dns64_always_synth_for_qname(qstate, id)) { * synth. */
/* if it is not internal, AAAA, not CD and listed domain, int could_synth =
* generate from A record and ignore AAAA */ qstate->qinfo.qtype == LDNS_RR_TYPE_AAAA &&
verbose(VERB_ALGO, "dns64: ignore-aaaa and synthesize anyway"); (!iq || iq->state != DNS64_INTERNAL_QUERY) &&
!(qstate->query_flags & BIT_CD);
int has_data = /* whether query returned non-empty rrset */
qstate->return_msg &&
qstate->return_msg->rep &&
reply_find_answer_rrset(&qstate->qinfo, qstate->return_msg->rep);
int synth_qname = 0;
if(could_synth &&
(!has_data ||
(synth_qname=dns64_always_synth_for_qname(qstate, id)))) {
if(synth_qname)
verbose(VERB_ALGO, "dns64: ignore-aaaa and synthesize anyway");
return generate_type_A_query(qstate, id); return generate_type_A_query(qstate, id);
} }
/* Store the response in cache. */ /* Store the response in cache. */
if ( (!iq || !iq->started_no_cache_store) && if( (!iq || !iq->started_no_cache_store) &&
qstate->return_msg && qstate->return_msg->rep && qstate->return_msg &&
!dns_cache_store(qstate->env, &qstate->qinfo, qstate->return_msg->rep, qstate->return_msg->rep &&
0, 0, 0, NULL, qstate->query_flags, qstate->qstarttime)) !dns_cache_store(
qstate->env, &qstate->qinfo, qstate->return_msg->rep,
0, 0, 0, NULL,
qstate->query_flags, qstate->qstarttime))
log_err("out of memory"); log_err("out of memory");
/* do nothing */ /* do nothing */
@ -969,10 +975,19 @@ dns64_inform_super(struct module_qstate* qstate, int id,
} }
super_dq->state = DNS64_SUBQUERY_FINISHED; super_dq->state = DNS64_SUBQUERY_FINISHED;
/* If there is no successful answer, we're done. */ /* If there is no successful answer, we're done.
if (qstate->return_rcode != LDNS_RCODE_NOERROR * Guarantee that we have at least a NOERROR reply further on. */
|| !qstate->return_msg if(qstate->return_rcode != LDNS_RCODE_NOERROR
|| !qstate->return_msg->rep) { || !qstate->return_msg
|| !qstate->return_msg->rep) {
return;
}
/* When no A record is found for synthesis fall back to AAAA again. */
if(qstate->qinfo.qtype == LDNS_RR_TYPE_A &&
!reply_find_answer_rrset(&qstate->qinfo,
qstate->return_msg->rep)) {
super_dq->state = DNS64_INTERNAL_QUERY;
return; return;
} }

View File

@ -133,6 +133,7 @@ dt_msg_send_client_query(struct dt_env *env,
struct sockaddr_storage *qsock, struct sockaddr_storage *qsock,
struct sockaddr_storage *rsock, struct sockaddr_storage *rsock,
enum comm_point_type cptype, enum comm_point_type cptype,
void *cpssl,
struct sldns_buffer *qmsg, struct sldns_buffer *qmsg,
struct timeval* tstamp); struct timeval* tstamp);
@ -149,6 +150,7 @@ dt_msg_send_client_response(struct dt_env *env,
struct sockaddr_storage *qsock, struct sockaddr_storage *qsock,
struct sockaddr_storage *rsock, struct sockaddr_storage *rsock,
enum comm_point_type cptype, enum comm_point_type cptype,
void *cpssl,
struct sldns_buffer *rmsg); struct sldns_buffer *rmsg);
/** /**
@ -168,6 +170,7 @@ dt_msg_send_outside_query(struct dt_env *env,
struct sockaddr_storage *rsock, struct sockaddr_storage *rsock,
struct sockaddr_storage *qsock, struct sockaddr_storage *qsock,
enum comm_point_type cptype, enum comm_point_type cptype,
void *cpssl,
uint8_t *zone, size_t zone_len, uint8_t *zone, size_t zone_len,
struct sldns_buffer *qmsg); struct sldns_buffer *qmsg);
@ -192,6 +195,7 @@ dt_msg_send_outside_response(struct dt_env *env,
struct sockaddr_storage *rsock, struct sockaddr_storage *rsock,
struct sockaddr_storage *qsock, struct sockaddr_storage *qsock,
enum comm_point_type cptype, enum comm_point_type cptype,
void *cpssl,
uint8_t *zone, size_t zone_len, uint8_t *zone, size_t zone_len,
uint8_t *qbuf, size_t qbuf_len, uint8_t *qbuf, size_t qbuf_len,
const struct timeval *qtime, const struct timeval *qtime,

View File

@ -523,4 +523,3 @@ forwards_delete_stub_hole(struct iter_forwards* fwd, uint16_t c, uint8_t* nm)
fwd_zone_free(z); fwd_zone_free(z);
fwd_init_parents(fwd); fwd_init_parents(fwd);
} }

View File

@ -129,7 +129,7 @@ compile_time_root_prime(int do_ip4, int do_ip6)
dp->has_parent_side_NS = 1; dp->has_parent_side_NS = 1;
if(do_ip4) { if(do_ip4) {
if(!ah(dp, "A.ROOT-SERVERS.NET.", "198.41.0.4")) goto failed; if(!ah(dp, "A.ROOT-SERVERS.NET.", "198.41.0.4")) goto failed;
if(!ah(dp, "B.ROOT-SERVERS.NET.", "199.9.14.201")) goto failed; if(!ah(dp, "B.ROOT-SERVERS.NET.", "170.247.170.2")) goto failed;
if(!ah(dp, "C.ROOT-SERVERS.NET.", "192.33.4.12")) goto failed; if(!ah(dp, "C.ROOT-SERVERS.NET.", "192.33.4.12")) goto failed;
if(!ah(dp, "D.ROOT-SERVERS.NET.", "199.7.91.13")) goto failed; if(!ah(dp, "D.ROOT-SERVERS.NET.", "199.7.91.13")) goto failed;
if(!ah(dp, "E.ROOT-SERVERS.NET.", "192.203.230.10")) goto failed; if(!ah(dp, "E.ROOT-SERVERS.NET.", "192.203.230.10")) goto failed;
@ -144,7 +144,7 @@ compile_time_root_prime(int do_ip4, int do_ip6)
} }
if(do_ip6) { if(do_ip6) {
if(!ah(dp, "A.ROOT-SERVERS.NET.", "2001:503:ba3e::2:30")) goto failed; if(!ah(dp, "A.ROOT-SERVERS.NET.", "2001:503:ba3e::2:30")) goto failed;
if(!ah(dp, "B.ROOT-SERVERS.NET.", "2001:500:200::b")) goto failed; if(!ah(dp, "B.ROOT-SERVERS.NET.", "2801:1b8:10::b")) goto failed;
if(!ah(dp, "C.ROOT-SERVERS.NET.", "2001:500:2::c")) goto failed; if(!ah(dp, "C.ROOT-SERVERS.NET.", "2001:500:2::c")) goto failed;
if(!ah(dp, "D.ROOT-SERVERS.NET.", "2001:500:2d::d")) goto failed; if(!ah(dp, "D.ROOT-SERVERS.NET.", "2001:500:2d::d")) goto failed;
if(!ah(dp, "E.ROOT-SERVERS.NET.", "2001:500:a8::e")) goto failed; if(!ah(dp, "E.ROOT-SERVERS.NET.", "2001:500:a8::e")) goto failed;
@ -560,4 +560,3 @@ hints_delete_stub(struct iter_hints* hints, uint16_t c, uint8_t* nm)
hints_stub_free(z); hints_stub_free(z);
name_tree_init_parents(&hints->tree); name_tree_init_parents(&hints->tree);
} }

View File

@ -207,28 +207,6 @@ size_t priv_get_mem(struct iter_priv* priv)
return sizeof(*priv) + regional_get_mem(priv->region); return sizeof(*priv) + regional_get_mem(priv->region);
} }
/** remove RR from msgparse RRset, return true if rrset is entirely bad */
static int
remove_rr(const char* str, sldns_buffer* pkt, struct rrset_parse* rrset,
struct rr_parse* prev, struct rr_parse** rr, struct sockaddr_storage* addr, socklen_t addrlen)
{
if(verbosity >= VERB_QUERY && rrset->dname_len <= LDNS_MAX_DOMAINLEN && str) {
uint8_t buf[LDNS_MAX_DOMAINLEN+1];
dname_pkt_copy(pkt, buf, rrset->dname);
log_name_addr(VERB_QUERY, str, buf, addr, addrlen);
}
if(prev)
prev->next = (*rr)->next;
else rrset->rr_first = (*rr)->next;
if(rrset->rr_last == *rr)
rrset->rr_last = prev;
rrset->rr_count --;
rrset->size -= (*rr)->size;
/* rr struct still exists, but is unlinked, so that in the for loop
* the rr->next works fine to continue. */
return rrset->rr_count == 0;
}
int priv_rrset_bad(struct iter_priv* priv, sldns_buffer* pkt, int priv_rrset_bad(struct iter_priv* priv, sldns_buffer* pkt,
struct rrset_parse* rrset) struct rrset_parse* rrset)
{ {
@ -261,7 +239,7 @@ int priv_rrset_bad(struct iter_priv* priv, sldns_buffer* pkt,
INET_SIZE); INET_SIZE);
memmove(&addr, &sa, len); memmove(&addr, &sa, len);
if(priv_lookup_addr(priv, &addr, len)) { if(priv_lookup_addr(priv, &addr, len)) {
if(remove_rr("sanitize: removing public name with private address", pkt, rrset, prev, &rr, &addr, len)) if(msgparse_rrset_remove_rr("sanitize: removing public name with private address", pkt, rrset, prev, rr, &addr, len))
return 1; return 1;
continue; continue;
} }
@ -284,7 +262,7 @@ int priv_rrset_bad(struct iter_priv* priv, sldns_buffer* pkt,
INET6_SIZE); INET6_SIZE);
memmove(&addr, &sa, len); memmove(&addr, &sa, len);
if(priv_lookup_addr(priv, &addr, len)) { if(priv_lookup_addr(priv, &addr, len)) {
if(remove_rr("sanitize: removing public name with private address", pkt, rrset, prev, &rr, &addr, len)) if(msgparse_rrset_remove_rr("sanitize: removing public name with private address", pkt, rrset, prev, rr, &addr, len))
return 1; return 1;
continue; continue;
} }

View File

@ -42,6 +42,7 @@
#include "config.h" #include "config.h"
#include "iterator/iter_resptype.h" #include "iterator/iter_resptype.h"
#include "iterator/iter_delegpt.h" #include "iterator/iter_delegpt.h"
#include "iterator/iterator.h"
#include "services/cache/dns.h" #include "services/cache/dns.h"
#include "util/net_help.h" #include "util/net_help.h"
#include "util/data/dname.h" #include "util/data/dname.h"
@ -105,7 +106,8 @@ response_type_from_cache(struct dns_msg* msg,
enum response_type enum response_type
response_type_from_server(int rdset, response_type_from_server(int rdset,
struct dns_msg* msg, struct query_info* request, struct delegpt* dp) struct dns_msg* msg, struct query_info* request, struct delegpt* dp,
int* empty_nodata_found)
{ {
uint8_t* origzone = (uint8_t*)"\000"; /* the default */ uint8_t* origzone = (uint8_t*)"\000"; /* the default */
struct ub_packed_rrset_key* s; struct ub_packed_rrset_key* s;
@ -284,13 +286,22 @@ response_type_from_server(int rdset,
/* If we've gotten this far, this is NOERROR/NODATA (which could /* If we've gotten this far, this is NOERROR/NODATA (which could
* be an entirely empty message) */ * be an entirely empty message) */
/* but ignore entirely empty messages, noerror/nodata has a soa /* For entirely empty messages, try again, at first, then accept
* negative ttl value in the authority section, this makes it try * it it happens more. A regular noerror/nodata response has a soa
* again at another authority. And turns it from a 5 second empty * negative ttl value in the authority section. This makes it try
* message into a 5 second servfail response. */ * again at another authority. And decides between storing a 5 second
* empty message or a 5 second servfail response. */
if(msg->rep->an_numrrsets == 0 && msg->rep->ns_numrrsets == 0 && if(msg->rep->an_numrrsets == 0 && msg->rep->ns_numrrsets == 0 &&
msg->rep->ar_numrrsets == 0) msg->rep->ar_numrrsets == 0) {
return RESPONSE_TYPE_THROWAWAY; if(empty_nodata_found) {
/* detect as throwaway at first, but accept later. */
(*empty_nodata_found)++;
if(*empty_nodata_found < EMPTY_NODATA_RETRY_COUNT)
return RESPONSE_TYPE_THROWAWAY;
return RESPONSE_TYPE_ANSWER;
}
return RESPONSE_TYPE_ANSWER;
}
/* check if recursive answer; saying it has empty cache */ /* check if recursive answer; saying it has empty cache */
if( (msg->rep->flags&BIT_RA) && !(msg->rep->flags&BIT_AA) && !rdset) if( (msg->rep->flags&BIT_RA) && !(msg->rep->flags&BIT_AA) && !rdset)
return RESPONSE_TYPE_REC_LAME; return RESPONSE_TYPE_REC_LAME;

View File

@ -119,9 +119,11 @@ enum response_type response_type_from_cache(struct dns_msg* msg,
* @param request: the request that generated the response. * @param request: the request that generated the response.
* @param dp: The delegation point that was being queried * @param dp: The delegation point that was being queried
* when the response was returned. * when the response was returned.
* @param empty_nodata_found: flag to keep track of empty nodata detection.
* @return the response type (CNAME or ANSWER). * @return the response type (CNAME or ANSWER).
*/ */
enum response_type response_type_from_server(int rdset, enum response_type response_type_from_server(int rdset,
struct dns_msg* msg, struct query_info* request, struct delegpt* dp); struct dns_msg* msg, struct query_info* request, struct delegpt* dp,
int* empty_nodata_found);
#endif /* ITERATOR_ITER_RESPTYPE_H */ #endif /* ITERATOR_ITER_RESPTYPE_H */

View File

@ -283,7 +283,8 @@ synth_cname_rrset(uint8_t** sname, size_t* snamelen, uint8_t* alias,
sizeof(uint32_t)+sizeof(uint16_t)+aliaslen); sizeof(uint32_t)+sizeof(uint16_t)+aliaslen);
if(!cn->rr_first->ttl_data) if(!cn->rr_first->ttl_data)
return NULL; return NULL;
sldns_write_uint32(cn->rr_first->ttl_data, 0); /* TTL = 0 */ memmove(cn->rr_first->ttl_data, rrset->rr_first->ttl_data,
sizeof(uint32_t)); /* RFC6672: synth CNAME TTL == DNAME TTL */
sldns_write_uint16(cn->rr_first->ttl_data+4, aliaslen); sldns_write_uint16(cn->rr_first->ttl_data+4, aliaslen);
memmove(cn->rr_first->ttl_data+6, alias, aliaslen); memmove(cn->rr_first->ttl_data+6, alias, aliaslen);
cn->rr_first->size = sizeof(uint16_t)+aliaslen; cn->rr_first->size = sizeof(uint16_t)+aliaslen;
@ -716,6 +717,56 @@ static int sanitize_nsec_is_overreach(sldns_buffer* pkt,
return 0; return 0;
} }
/** Remove individual RRs, if the length is wrong. Returns true if the RRset
* has been removed. */
static int
scrub_sanitize_rr_length(sldns_buffer* pkt, struct msg_parse* msg,
struct rrset_parse* prev, struct rrset_parse** rrset, int* added_ede,
struct module_qstate* qstate)
{
struct rr_parse* rr, *rr_prev = NULL;
for(rr = (*rrset)->rr_first; rr; rr = rr->next) {
/* Sanity check for length of records
* An A record should be 6 bytes only
* (2 bytes for length and 4 for IPv4 addr)*/
if((*rrset)->type == LDNS_RR_TYPE_A && rr->size != 6 ) {
if(!*added_ede) {
*added_ede = 1;
errinf_ede(qstate, "sanitize: records of inappropriate length have been removed.",
LDNS_EDE_OTHER);
}
if(msgparse_rrset_remove_rr("sanitize: removing type A RR of inappropriate length:",
pkt, *rrset, rr_prev, rr, NULL, 0)) {
remove_rrset("sanitize: removing type A RRset of inappropriate length:",
pkt, msg, prev, rrset);
return 1;
}
continue;
}
/* Sanity check for length of records
* An AAAA record should be 18 bytes only
* (2 bytes for length and 16 for IPv6 addr)*/
if((*rrset)->type == LDNS_RR_TYPE_AAAA && rr->size != 18 ) {
if(!*added_ede) {
*added_ede = 1;
errinf_ede(qstate, "sanitize: records of inappropriate length have been removed.",
LDNS_EDE_OTHER);
}
if(msgparse_rrset_remove_rr("sanitize: removing type AAAA RR of inappropriate length:",
pkt, *rrset, rr_prev, rr, NULL, 0)) {
remove_rrset("sanitize: removing type AAAA RRset of inappropriate length:",
pkt, msg, prev, rrset);
return 1;
}
continue;
}
rr_prev = rr;
}
return 0;
}
/** /**
* Given a response event, remove suspect RRsets from the response. * Given a response event, remove suspect RRsets from the response.
* "Suspect" rrsets are potentially poison. Note that this routine expects * "Suspect" rrsets are potentially poison. Note that this routine expects
@ -728,15 +779,17 @@ static int sanitize_nsec_is_overreach(sldns_buffer* pkt,
* @param zonename: name of server zone. * @param zonename: name of server zone.
* @param env: module environment with config and cache. * @param env: module environment with config and cache.
* @param ie: iterator environment with private address data. * @param ie: iterator environment with private address data.
* @param qstate: for setting errinf for EDE error messages.
* @return 0 on error. * @return 0 on error.
*/ */
static int static int
scrub_sanitize(sldns_buffer* pkt, struct msg_parse* msg, scrub_sanitize(sldns_buffer* pkt, struct msg_parse* msg,
struct query_info* qinfo, uint8_t* zonename, struct module_env* env, struct query_info* qinfo, uint8_t* zonename, struct module_env* env,
struct iter_env* ie) struct iter_env* ie, struct module_qstate* qstate)
{ {
int del_addi = 0; /* if additional-holding rrsets are deleted, we int del_addi = 0; /* if additional-holding rrsets are deleted, we
do not trust the normalized additional-A-AAAA any more */ do not trust the normalized additional-A-AAAA any more */
int added_rrlen_ede = 0;
struct rrset_parse* rrset, *prev; struct rrset_parse* rrset, *prev;
prev = NULL; prev = NULL;
rrset = msg->rrset_first; rrset = msg->rrset_first;
@ -781,6 +834,14 @@ scrub_sanitize(sldns_buffer* pkt, struct msg_parse* msg,
rrset = msg->rrset_first; rrset = msg->rrset_first;
while(rrset) { while(rrset) {
/* Sanity check for length of records */
if(rrset->type == LDNS_RR_TYPE_A ||
rrset->type == LDNS_RR_TYPE_AAAA) {
if(scrub_sanitize_rr_length(pkt, msg, prev, &rrset,
&added_rrlen_ede, qstate))
continue;
}
/* remove private addresses */ /* remove private addresses */
if( (rrset->type == LDNS_RR_TYPE_A || if( (rrset->type == LDNS_RR_TYPE_A ||
rrset->type == LDNS_RR_TYPE_AAAA)) { rrset->type == LDNS_RR_TYPE_AAAA)) {
@ -854,7 +915,8 @@ scrub_sanitize(sldns_buffer* pkt, struct msg_parse* msg,
int int
scrub_message(sldns_buffer* pkt, struct msg_parse* msg, scrub_message(sldns_buffer* pkt, struct msg_parse* msg,
struct query_info* qinfo, uint8_t* zonename, struct regional* region, struct query_info* qinfo, uint8_t* zonename, struct regional* region,
struct module_env* env, struct iter_env* ie) struct module_env* env, struct module_qstate* qstate,
struct iter_env* ie)
{ {
/* basic sanity checks */ /* basic sanity checks */
log_nametypeclass(VERB_ALGO, "scrub for", zonename, LDNS_RR_TYPE_NS, log_nametypeclass(VERB_ALGO, "scrub for", zonename, LDNS_RR_TYPE_NS,
@ -886,7 +948,7 @@ scrub_message(sldns_buffer* pkt, struct msg_parse* msg,
if(!scrub_normalize(pkt, msg, qinfo, region, env)) if(!scrub_normalize(pkt, msg, qinfo, region, env))
return 0; return 0;
/* delete all out-of-zone information */ /* delete all out-of-zone information */
if(!scrub_sanitize(pkt, msg, qinfo, zonename, env, ie)) if(!scrub_sanitize(pkt, msg, qinfo, zonename, env, ie, qstate))
return 0; return 0;
return 1; return 1;
} }

View File

@ -48,6 +48,7 @@ struct query_info;
struct regional; struct regional;
struct module_env; struct module_env;
struct iter_env; struct iter_env;
struct module_qstate;
/** /**
* Cleanup the passed dns message. * Cleanup the passed dns message.
@ -59,11 +60,13 @@ struct iter_env;
* Used to determine out of bailiwick information. * Used to determine out of bailiwick information.
* @param regional: where to allocate (new) parts of the message. * @param regional: where to allocate (new) parts of the message.
* @param env: module environment with config settings and cache. * @param env: module environment with config settings and cache.
* @param qstate: for setting errinf for EDE error messages.
* @param ie: iterator module environment data. * @param ie: iterator module environment data.
* @return: false if the message is total waste. true if scrubbed with success. * @return: false if the message is total waste. true if scrubbed with success.
*/ */
int scrub_message(struct sldns_buffer* pkt, struct msg_parse* msg, int scrub_message(struct sldns_buffer* pkt, struct msg_parse* msg,
struct query_info* qinfo, uint8_t* zonename, struct regional* regional, struct query_info* qinfo, uint8_t* zonename, struct regional* regional,
struct module_env* env, struct iter_env* ie); struct module_env* env, struct module_qstate* qstate,
struct iter_env* ie);
#endif /* ITERATOR_ITER_SCRUB_H */ #endif /* ITERATOR_ITER_SCRUB_H */

View File

@ -1449,6 +1449,39 @@ processInitRequest(struct module_qstate* qstate, struct iter_qstate* iq,
} }
iq->qchase.qname = sname; iq->qchase.qname = sname;
iq->qchase.qname_len = slen; iq->qchase.qname_len = slen;
if(qstate->env->auth_zones) {
/* apply rpz qname triggers after cname */
struct dns_msg* forged_response =
rpz_callback_from_iterator_cname(qstate, iq);
while(forged_response && reply_find_rrset_section_an(
forged_response->rep, iq->qchase.qname,
iq->qchase.qname_len, LDNS_RR_TYPE_CNAME,
iq->qchase.qclass)) {
/* another cname to follow */
if(!handle_cname_response(qstate, iq, forged_response,
&sname, &slen)) {
errinf(qstate, "malloc failure, CNAME info");
return error_response(qstate, id, LDNS_RCODE_SERVFAIL);
}
iq->qchase.qname = sname;
iq->qchase.qname_len = slen;
forged_response =
rpz_callback_from_iterator_cname(qstate, iq);
}
if(forged_response != NULL) {
qstate->ext_state[id] = module_finished;
qstate->return_rcode = LDNS_RCODE_NOERROR;
qstate->return_msg = forged_response;
iq->response = forged_response;
next_state(iq, FINISHED_STATE);
if(!iter_prepend(iq, qstate->return_msg, qstate->region)) {
log_err("rpz: after cached cname, prepend rrsets: out of memory");
return error_response(qstate, id, LDNS_RCODE_SERVFAIL);
}
qstate->return_msg->qinfo = qstate->qinfo;
return 0;
}
}
/* This *is* a query restart, even if it is a cheap /* This *is* a query restart, even if it is a cheap
* one. */ * one. */
iq->dp = NULL; iq->dp = NULL;
@ -2875,7 +2908,8 @@ processQueryTargets(struct module_qstate* qstate, struct iter_qstate* iq,
/* unset CD if to forwarder(RD set) and not dnssec retry /* unset CD if to forwarder(RD set) and not dnssec retry
* (blacklist nonempty) and no trust-anchors are configured * (blacklist nonempty) and no trust-anchors are configured
* above the qname or on the first attempt when dnssec is on */ * above the qname or on the first attempt when dnssec is on */
EDNS_DO| ((iq->chase_to_rd||(iq->chase_flags&BIT_RD)!=0)&& (qstate->env->cfg->disable_edns_do?0:EDNS_DO)|
((iq->chase_to_rd||(iq->chase_flags&BIT_RD)!=0)&&
!qstate->blacklist&&(!iter_qname_indicates_dnssec(qstate->env, !qstate->blacklist&&(!iter_qname_indicates_dnssec(qstate->env,
&iq->qinfo_out)||target->attempts==1)?0:BIT_CD), &iq->qinfo_out)||target->attempts==1)?0:BIT_CD),
iq->dnssec_expected, iq->caps_fallback || is_caps_whitelisted( iq->dnssec_expected, iq->caps_fallback || is_caps_whitelisted(
@ -2940,7 +2974,7 @@ static int
processQueryResponse(struct module_qstate* qstate, struct iter_qstate* iq, processQueryResponse(struct module_qstate* qstate, struct iter_qstate* iq,
struct iter_env* ie, int id) struct iter_env* ie, int id)
{ {
int dnsseclame = 0, origtypecname = 0; int dnsseclame = 0, origtypecname = 0, orig_empty_nodata_found;
enum response_type type; enum response_type type;
iq->num_current_queries--; iq->num_current_queries--;
@ -2960,12 +2994,25 @@ processQueryResponse(struct module_qstate* qstate, struct iter_qstate* iq,
return next_state(iq, QUERYTARGETS_STATE); return next_state(iq, QUERYTARGETS_STATE);
} }
iq->timeout_count = 0; iq->timeout_count = 0;
orig_empty_nodata_found = iq->empty_nodata_found;
type = response_type_from_server( type = response_type_from_server(
(int)((iq->chase_flags&BIT_RD) || iq->chase_to_rd), (int)((iq->chase_flags&BIT_RD) || iq->chase_to_rd),
iq->response, &iq->qinfo_out, iq->dp); iq->response, &iq->qinfo_out, iq->dp, &iq->empty_nodata_found);
iq->chase_to_rd = 0; iq->chase_to_rd = 0;
/* remove TC flag, if this is erroneously set by TCP upstream */ /* remove TC flag, if this is erroneously set by TCP upstream */
iq->response->rep->flags &= ~BIT_TC; iq->response->rep->flags &= ~BIT_TC;
if(orig_empty_nodata_found != iq->empty_nodata_found &&
iq->empty_nodata_found < EMPTY_NODATA_RETRY_COUNT) {
/* try to search at another server */
if(qstate->reply) {
struct delegpt_addr* a = delegpt_find_addr(
iq->dp, &qstate->reply->remote_addr,
qstate->reply->remote_addrlen);
/* make selection disprefer it */
if(a) a->lame = 1;
}
return next_state(iq, QUERYTARGETS_STATE);
}
if(type == RESPONSE_TYPE_REFERRAL && (iq->chase_flags&BIT_RD) && if(type == RESPONSE_TYPE_REFERRAL && (iq->chase_flags&BIT_RD) &&
!iq->auth_zone_response) { !iq->auth_zone_response) {
/* When forwarding (RD bit is set), we handle referrals /* When forwarding (RD bit is set), we handle referrals
@ -3501,7 +3548,7 @@ processPrimeResponse(struct module_qstate* qstate, int id)
iq->response->rep->flags &= ~(BIT_RD|BIT_RA); /* ignore rec-lame */ iq->response->rep->flags &= ~(BIT_RD|BIT_RA); /* ignore rec-lame */
type = response_type_from_server( type = response_type_from_server(
(int)((iq->chase_flags&BIT_RD) || iq->chase_to_rd), (int)((iq->chase_flags&BIT_RD) || iq->chase_to_rd),
iq->response, &iq->qchase, iq->dp); iq->response, &iq->qchase, iq->dp, NULL);
if(type == RESPONSE_TYPE_ANSWER) { if(type == RESPONSE_TYPE_ANSWER) {
qstate->return_rcode = LDNS_RCODE_NOERROR; qstate->return_rcode = LDNS_RCODE_NOERROR;
qstate->return_msg = iq->response; qstate->return_msg = iq->response;
@ -3874,6 +3921,23 @@ processFinished(struct module_qstate* qstate, struct iter_qstate* iq,
/* explicitly set the EDE string to NULL */ /* explicitly set the EDE string to NULL */
iq->response->rep->reason_bogus_str = NULL; iq->response->rep->reason_bogus_str = NULL;
if((qstate->env->cfg->val_log_level >= 2 ||
qstate->env->cfg->log_servfail) && qstate->errinf &&
!qstate->env->cfg->val_log_squelch) {
char* err_str = errinf_to_str_misc(qstate);
if(err_str) {
size_t err_str_len = strlen(err_str);
verbose(VERB_ALGO, "iterator EDE: %s", err_str);
/* allocate space and store the error
* string */
iq->response->rep->reason_bogus_str = regional_alloc(
qstate->region,
sizeof(char) * (err_str_len+1));
memcpy(iq->response->rep->reason_bogus_str,
err_str, err_str_len+1);
}
free(err_str);
}
/* we have finished processing this query */ /* we have finished processing this query */
qstate->ext_state[id] = module_finished; qstate->ext_state[id] = module_finished;
@ -4087,10 +4151,10 @@ process_response(struct module_qstate* qstate, struct iter_qstate* iq,
/* like packet got dropped */ /* like packet got dropped */
goto handle_it; goto handle_it;
} }
if(!inplace_cb_edns_back_parsed_call(qstate->env, qstate)) { }
log_err("unable to call edns_back_parsed callback"); if(!inplace_cb_edns_back_parsed_call(qstate->env, qstate)) {
goto handle_it; log_err("unable to call edns_back_parsed callback");
} goto handle_it;
} }
/* remove CD-bit, we asked for in case we handle validation ourself */ /* remove CD-bit, we asked for in case we handle validation ourself */
@ -4098,7 +4162,7 @@ process_response(struct module_qstate* qstate, struct iter_qstate* iq,
/* normalize and sanitize: easy to delete items from linked lists */ /* normalize and sanitize: easy to delete items from linked lists */
if(!scrub_message(pkt, prs, &iq->qinfo_out, iq->dp->name, if(!scrub_message(pkt, prs, &iq->qinfo_out, iq->dp->name,
qstate->env->scratch, qstate->env, ie)) { qstate->env->scratch, qstate->env, qstate, ie)) {
/* if 0x20 enabled, start fallback, but we have no message */ /* if 0x20 enabled, start fallback, but we have no message */
if(event == module_event_capsfail && !iq->caps_fallback) { if(event == module_event_capsfail && !iq->caps_fallback) {
iq->caps_fallback = 1; iq->caps_fallback = 1;

View File

@ -101,6 +101,8 @@ extern int BLACKLIST_PENALTY;
* Chosen so that the UNKNOWN_SERVER_NICENESS falls within the band of a * Chosen so that the UNKNOWN_SERVER_NICENESS falls within the band of a
* fast server, this causes server exploration as a side benefit. msec. */ * fast server, this causes server exploration as a side benefit. msec. */
#define RTT_BAND 400 #define RTT_BAND 400
/** Number of retries for empty nodata packets before it is accepted. */
#define EMPTY_NODATA_RETRY_COUNT 2
/** /**
* Global state for the iterator. * Global state for the iterator.
@ -415,6 +417,11 @@ struct iter_qstate {
*/ */
int refetch_glue; int refetch_glue;
/**
* This flag detects that a completely empty nodata was received,
* already so that it is accepted later. */
int empty_nodata_found;
/** list of pending queries to authoritative servers. */ /** list of pending queries to authoritative servers. */
struct outbound_list outlist; struct outbound_list outlist;

View File

@ -62,6 +62,7 @@
#include "util/random.h" #include "util/random.h"
#include "util/config_file.h" #include "util/config_file.h"
#include "util/netevent.h" #include "util/netevent.h"
#include "util/proxy_protocol.h"
#include "util/storage/lookup3.h" #include "util/storage/lookup3.h"
#include "util/storage/slabhash.h" #include "util/storage/slabhash.h"
#include "util/net_help.h" #include "util/net_help.h"
@ -168,6 +169,7 @@ libworker_setup(struct ub_ctx* ctx, int is_bg, struct ub_event_base* eb)
hints_delete(w->env->hints); hints_delete(w->env->hints);
w->env->hints = NULL; w->env->hints = NULL;
} }
#ifdef HAVE_SSL
w->sslctx = connect_sslctx_create(NULL, NULL, w->sslctx = connect_sslctx_create(NULL, NULL,
cfg->tls_cert_bundle, cfg->tls_win_cert); cfg->tls_cert_bundle, cfg->tls_win_cert);
if(!w->sslctx) { if(!w->sslctx) {
@ -175,6 +177,7 @@ libworker_setup(struct ub_ctx* ctx, int is_bg, struct ub_event_base* eb)
hints_delete(w->env->hints); hints_delete(w->env->hints);
w->env->hints = NULL; w->env->hints = NULL;
} }
#endif
if(!w->is_bg || w->is_bg_thread) { if(!w->is_bg || w->is_bg_thread) {
lock_basic_unlock(&ctx->cfglock); lock_basic_unlock(&ctx->cfglock);
} }
@ -263,6 +266,7 @@ libworker_setup(struct ub_ctx* ctx, int is_bg, struct ub_event_base* eb)
w->env->kill_sub = &mesh_state_delete; w->env->kill_sub = &mesh_state_delete;
w->env->detect_cycle = &mesh_detect_cycle; w->env->detect_cycle = &mesh_detect_cycle;
comm_base_timept(w->base, &w->env->now, &w->env->now_tv); comm_base_timept(w->base, &w->env->now, &w->env->now_tv);
pp_init(&sldns_write_uint16, &sldns_write_uint32);
return w; return w;
} }

View File

@ -2475,6 +2475,7 @@ az_find_ce(struct auth_zone* z, struct query_info* qinfo,
struct auth_rrset** rrset) struct auth_rrset** rrset)
{ {
struct auth_data* n = node; struct auth_data* n = node;
struct auth_rrset* lookrrset;
*ce = NULL; *ce = NULL;
*rrset = NULL; *rrset = NULL;
if(!node_exact) { if(!node_exact) {
@ -2497,21 +2498,23 @@ az_find_ce(struct auth_zone* z, struct query_info* qinfo,
/* see if the current candidate has issues */ /* see if the current candidate has issues */
/* not zone apex and has type NS */ /* not zone apex and has type NS */
if(n->namelen != z->namelen && if(n->namelen != z->namelen &&
(*rrset=az_domain_rrset(n, LDNS_RR_TYPE_NS)) && (lookrrset=az_domain_rrset(n, LDNS_RR_TYPE_NS)) &&
/* delegate here, but DS at exact the dp has notype */ /* delegate here, but DS at exact the dp has notype */
(qinfo->qtype != LDNS_RR_TYPE_DS || (qinfo->qtype != LDNS_RR_TYPE_DS ||
n->namelen != qinfo->qname_len)) { n->namelen != qinfo->qname_len)) {
/* referral */ /* referral */
/* this is ce and the lowernode is nonexisting */ /* this is ce and the lowernode is nonexisting */
*ce = n; *ce = n;
return 0; *rrset = lookrrset;
node_exact = 0;
} }
/* not equal to qname and has type DNAME */ /* not equal to qname and has type DNAME */
if(n->namelen != qinfo->qname_len && if(n->namelen != qinfo->qname_len &&
(*rrset=az_domain_rrset(n, LDNS_RR_TYPE_DNAME))) { (lookrrset=az_domain_rrset(n, LDNS_RR_TYPE_DNAME))) {
/* this is ce and the lowernode is nonexisting */ /* this is ce and the lowernode is nonexisting */
*ce = n; *ce = n;
return 0; *rrset = lookrrset;
node_exact = 0;
} }
if(*ce == NULL && !domain_has_only_nsec3(n)) { if(*ce == NULL && !domain_has_only_nsec3(n)) {
@ -2699,7 +2702,7 @@ create_synth_cname(uint8_t* qname, size_t qname_len, struct regional* region,
if(!d) if(!d)
return 0; /* out of memory */ return 0; /* out of memory */
(*cname)->entry.data = d; (*cname)->entry.data = d;
d->ttl = 0; /* 0 for synthesized CNAME TTL */ d->ttl = dname->data->ttl; /* RFC6672: synth CNAME TTL == DNAME TTL */
d->count = 1; d->count = 1;
d->rrsig_count = 0; d->rrsig_count = 0;
d->trust = rrset_trust_ans_noAA; d->trust = rrset_trust_ans_noAA;

View File

@ -80,6 +80,7 @@ store_rrsets(struct module_env* env, struct reply_info* rep, time_t now,
struct regional* region, time_t qstarttime) struct regional* region, time_t qstarttime)
{ {
size_t i; size_t i;
time_t ttl, min_ttl = rep->ttl;
/* see if rrset already exists in cache, if not insert it. */ /* see if rrset already exists in cache, if not insert it. */
for(i=0; i<rep->rrset_count; i++) { for(i=0; i<rep->rrset_count; i++) {
rep->ref[i].key = rep->rrsets[i]; rep->ref[i].key = rep->rrsets[i];
@ -112,6 +113,15 @@ store_rrsets(struct module_env* env, struct reply_info* rep, time_t now,
case 1: /* ref updated, item inserted */ case 1: /* ref updated, item inserted */
rep->rrsets[i] = rep->ref[i].key; rep->rrsets[i] = rep->ref[i].key;
} }
/* if ref was updated make sure the message ttl is updated to
* the minimum of the current rrsets. */
ttl = ((struct packed_rrset_data*)rep->rrsets[i]->entry.data)->ttl;
if(ttl < min_ttl) min_ttl = ttl;
}
if(min_ttl < rep->ttl) {
rep->ttl = min_ttl;
rep->prefetch_ttl = PREFETCH_TTL_CALC(rep->ttl);
rep->serve_expired_ttl = rep->ttl + SERVE_EXPIRED_TTL;
} }
} }
@ -818,7 +828,7 @@ synth_dname_msg(struct ub_packed_rrset_key* rrset, struct regional* region,
if(!newd) if(!newd)
return NULL; return NULL;
ck->entry.data = newd; ck->entry.data = newd;
newd->ttl = 0; /* 0 for synthesized CNAME TTL */ newd->ttl = d->ttl - now; /* RFC6672: synth CNAME TTL == DNAME TTL */
newd->count = 1; newd->count = 1;
newd->rrsig_count = 0; newd->rrsig_count = 0;
newd->trust = rrset_trust_ans_noAA; newd->trust = rrset_trust_ans_noAA;

View File

@ -1327,7 +1327,9 @@ ports_create_if(const char* ifname, int do_auto, int do_udp, int do_tcp,
log_warn("socket timestamping is not available"); log_warn("socket timestamping is not available");
} }
if(!port_insert(list, s, is_dnscrypt if(!port_insert(list, s, is_dnscrypt
?listen_type_udp_dnscrypt:listen_type_udp, ?listen_type_udp_dnscrypt :
(sock_queue_timeout ?
listen_type_udpancil:listen_type_udp),
is_pp2, ub_sock)) { is_pp2, ub_sock)) {
sock_close(s); sock_close(s);
if(ub_sock->addr) if(ub_sock->addr)
@ -1498,9 +1500,13 @@ listen_create(struct comm_base* base, struct listen_port* ports,
} }
} else if(ports->ftype == listen_type_udpancil || } else if(ports->ftype == listen_type_udpancil ||
ports->ftype == listen_type_udpancil_dnscrypt) { ports->ftype == listen_type_udpancil_dnscrypt) {
#if defined(AF_INET6) && defined(IPV6_PKTINFO) && defined(HAVE_RECVMSG)
cp = comm_point_create_udp_ancil(base, ports->fd, cp = comm_point_create_udp_ancil(base, ports->fd,
front->udp_buff, ports->pp2_enabled, cb, front->udp_buff, ports->pp2_enabled, cb,
cb_arg, ports->socket); cb_arg, ports->socket);
#else
log_warn("This system does not support UDP ancilliary data.");
#endif
} }
if(!cp) { if(!cp) {
log_err("can't create commpoint"); log_err("can't create commpoint");

View File

@ -1532,7 +1532,7 @@ local_data_answer(struct local_zone* z, struct module_env* env,
return 0; /* invalid cname */ return 0; /* invalid cname */
if(dname_is_wild(ctarget)) { if(dname_is_wild(ctarget)) {
/* synthesize cname target */ /* synthesize cname target */
struct packed_rrset_data* d; struct packed_rrset_data* d, *lr_d;
/* -3 for wildcard label and root label from qname */ /* -3 for wildcard label and root label from qname */
size_t newtargetlen = qinfo->qname_len + ctargetlen - 3; size_t newtargetlen = qinfo->qname_len + ctargetlen - 3;
@ -1560,8 +1560,10 @@ local_data_answer(struct local_zone* z, struct module_env* env,
+ newtargetlen); + newtargetlen);
if(!d) if(!d)
return 0; /* out of memory */ return 0; /* out of memory */
lr_d = (struct packed_rrset_data*)lr->rrset->entry.data;
qinfo->local_alias->rrset->entry.data = d; qinfo->local_alias->rrset->entry.data = d;
d->ttl = 0; /* 0 for synthesized CNAME TTL */ d->ttl = lr_d->rr_ttl[0]; /* RFC6672-like behavior:
synth CNAME TTL uses original TTL*/
d->count = 1; d->count = 1;
d->rrsig_count = 0; d->rrsig_count = 0;
d->trust = rrset_trust_ans_noAA; d->trust = rrset_trust_ans_noAA;

View File

@ -69,6 +69,12 @@
#include "edns-subnet/subnetmod.h" #include "edns-subnet/subnetmod.h"
#include "edns-subnet/edns-subnet.h" #include "edns-subnet/edns-subnet.h"
#endif #endif
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif
/** /**
* Compare two response-ip client info entries for the purpose of mesh state * Compare two response-ip client info entries for the purpose of mesh state
@ -1197,6 +1203,8 @@ mesh_do_callback(struct mesh_state* m, int rcode, struct reply_info* rep,
r->edns.udp_size = EDNS_ADVERTISED_SIZE; r->edns.udp_size = EDNS_ADVERTISED_SIZE;
r->edns.ext_rcode = 0; r->edns.ext_rcode = 0;
r->edns.bits &= EDNS_DO; r->edns.bits &= EDNS_DO;
if(m->s.env->cfg->disable_edns_do && (r->edns.bits&EDNS_DO))
r->edns.edns_present = 0;
if(!inplace_cb_reply_call(m->s.env, &m->s.qinfo, &m->s, rep, if(!inplace_cb_reply_call(m->s.env, &m->s.qinfo, &m->s, rep,
LDNS_RCODE_NOERROR, &r->edns, NULL, m->s.region, start_time) || LDNS_RCODE_NOERROR, &r->edns, NULL, m->s.region, start_time) ||
@ -1224,11 +1232,12 @@ static inline int
mesh_is_rpz_respip_tcponly_action(struct mesh_state const* m) mesh_is_rpz_respip_tcponly_action(struct mesh_state const* m)
{ {
struct respip_action_info const* respip_info = m->s.respip_action_info; struct respip_action_info const* respip_info = m->s.respip_action_info;
return respip_info == NULL return (respip_info == NULL
? 0 ? 0
: (respip_info->rpz_used : (respip_info->rpz_used
&& !respip_info->rpz_disabled && !respip_info->rpz_disabled
&& respip_info->action == respip_truncate); && respip_info->action == respip_truncate))
|| m->s.tcp_required;
} }
static inline int static inline int
@ -1371,6 +1380,8 @@ mesh_send_reply(struct mesh_state* m, int rcode, struct reply_info* rep,
r->edns.udp_size = EDNS_ADVERTISED_SIZE; r->edns.udp_size = EDNS_ADVERTISED_SIZE;
r->edns.ext_rcode = 0; r->edns.ext_rcode = 0;
r->edns.bits &= EDNS_DO; r->edns.bits &= EDNS_DO;
if(m->s.env->cfg->disable_edns_do && (r->edns.bits&EDNS_DO))
r->edns.edns_present = 0;
m->s.qinfo.qname = r->qname; m->s.qinfo.qname = r->qname;
m->s.qinfo.local_alias = r->local_alias; m->s.qinfo.local_alias = r->local_alias;
@ -1424,7 +1435,9 @@ mesh_send_reply(struct mesh_state* m, int rcode, struct reply_info* rep,
if(m->s.env->cfg->log_replies) { if(m->s.env->cfg->log_replies) {
log_reply_info(NO_VERBOSE, &m->s.qinfo, log_reply_info(NO_VERBOSE, &m->s.qinfo,
&r->query_reply.client_addr, &r->query_reply.client_addr,
r->query_reply.client_addrlen, duration, 0, r_buffer); r->query_reply.client_addrlen, duration, 0, r_buffer,
(m->s.env->cfg->log_destaddr?(void*)r->query_reply.c->socket->addr->ai_addr:NULL),
r->query_reply.c->type);
} }
} }

View File

@ -550,7 +550,6 @@ reuse_tcp_find(struct outside_network* outnet, struct sockaddr_storage* addr,
log_assert(&key_p.reuse != (struct reuse_tcp*)result); log_assert(&key_p.reuse != (struct reuse_tcp*)result);
log_assert(&key_p != ((struct reuse_tcp*)result)->pending); log_assert(&key_p != ((struct reuse_tcp*)result)->pending);
} }
/* not found, return null */
/* It is possible that we search for something before the first element /* It is possible that we search for something before the first element
* in the tree. Replace a null pointer with the first element. * in the tree. Replace a null pointer with the first element.
@ -560,6 +559,7 @@ reuse_tcp_find(struct outside_network* outnet, struct sockaddr_storage* addr,
result = rbtree_first(&outnet->tcp_reuse); result = rbtree_first(&outnet->tcp_reuse);
} }
/* not found, return null */
if(!result || result == RBTREE_NULL) if(!result || result == RBTREE_NULL)
return NULL; return NULL;
@ -1009,7 +1009,7 @@ use_free_buffer(struct outside_network* outnet)
sldns_buffer tmp; sldns_buffer tmp;
sldns_buffer_init_frm_data(&tmp, w->pkt, w->pkt_len); sldns_buffer_init_frm_data(&tmp, w->pkt, w->pkt_len);
dt_msg_send_outside_query(outnet->dtenv, &w->sq->addr, dt_msg_send_outside_query(outnet->dtenv, &w->sq->addr,
&pend_tcp->pi->addr, comm_tcp, w->sq->zone, &pend_tcp->pi->addr, comm_tcp, NULL, w->sq->zone,
w->sq->zonelen, &tmp); w->sq->zonelen, &tmp);
} }
#endif #endif
@ -2237,7 +2237,7 @@ randomize_and_send_udp(struct pending* pend, sldns_buffer* packet, int timeout)
outnet->dtenv->log_forwarder_query_messages)) { outnet->dtenv->log_forwarder_query_messages)) {
log_addr(VERB_ALGO, "from local addr", &pend->pc->pif->addr, pend->pc->pif->addrlen); log_addr(VERB_ALGO, "from local addr", &pend->pc->pif->addr, pend->pc->pif->addrlen);
log_addr(VERB_ALGO, "request to upstream", &pend->addr, pend->addrlen); log_addr(VERB_ALGO, "request to upstream", &pend->addr, pend->addrlen);
dt_msg_send_outside_query(outnet->dtenv, &pend->addr, &pend->pc->pif->addr, comm_udp, dt_msg_send_outside_query(outnet->dtenv, &pend->addr, &pend->pc->pif->addr, comm_udp, NULL,
pend->sq->zone, pend->sq->zonelen, packet); pend->sq->zone, pend->sq->zonelen, packet);
} }
#endif #endif
@ -2517,7 +2517,7 @@ pending_tcp_query(struct serviced_query* sq, sldns_buffer* packet,
sldns_buffer tmp; sldns_buffer tmp;
sldns_buffer_init_frm_data(&tmp, w->pkt, w->pkt_len); sldns_buffer_init_frm_data(&tmp, w->pkt, w->pkt_len);
dt_msg_send_outside_query(sq->outnet->dtenv, &sq->addr, dt_msg_send_outside_query(sq->outnet->dtenv, &sq->addr,
&pend->pi->addr, comm_tcp, sq->zone, &pend->pi->addr, comm_tcp, NULL, sq->zone,
sq->zonelen, &tmp); sq->zonelen, &tmp);
} }
#endif #endif
@ -2820,6 +2820,25 @@ serviced_perturb_qname(struct ub_randstate* rnd, uint8_t* qbuf, size_t len)
} }
} }
static uint16_t
serviced_query_udp_size(struct serviced_query* sq, enum serviced_query_status status) {
uint16_t udp_size;
if(status == serviced_query_UDP_EDNS_FRAG) {
if(addr_is_ip6(&sq->addr, sq->addrlen)) {
if(EDNS_FRAG_SIZE_IP6 < EDNS_ADVERTISED_SIZE)
udp_size = EDNS_FRAG_SIZE_IP6;
else udp_size = EDNS_ADVERTISED_SIZE;
} else {
if(EDNS_FRAG_SIZE_IP4 < EDNS_ADVERTISED_SIZE)
udp_size = EDNS_FRAG_SIZE_IP4;
else udp_size = EDNS_ADVERTISED_SIZE;
}
} else {
udp_size = EDNS_ADVERTISED_SIZE;
}
return udp_size;
}
/** put serviced query into a buffer */ /** put serviced query into a buffer */
static void static void
serviced_encode(struct serviced_query* sq, sldns_buffer* buff, int with_edns) serviced_encode(struct serviced_query* sq, sldns_buffer* buff, int with_edns)
@ -2843,19 +2862,7 @@ serviced_encode(struct serviced_query* sq, sldns_buffer* buff, int with_edns)
edns.opt_list_in = NULL; edns.opt_list_in = NULL;
edns.opt_list_out = sq->opt_list; edns.opt_list_out = sq->opt_list;
edns.opt_list_inplace_cb_out = NULL; edns.opt_list_inplace_cb_out = NULL;
if(sq->status == serviced_query_UDP_EDNS_FRAG) { edns.udp_size = serviced_query_udp_size(sq, sq->status);
if(addr_is_ip6(&sq->addr, sq->addrlen)) {
if(EDNS_FRAG_SIZE_IP6 < EDNS_ADVERTISED_SIZE)
edns.udp_size = EDNS_FRAG_SIZE_IP6;
else edns.udp_size = EDNS_ADVERTISED_SIZE;
} else {
if(EDNS_FRAG_SIZE_IP4 < EDNS_ADVERTISED_SIZE)
edns.udp_size = EDNS_FRAG_SIZE_IP4;
else edns.udp_size = EDNS_ADVERTISED_SIZE;
}
} else {
edns.udp_size = EDNS_ADVERTISED_SIZE;
}
edns.bits = 0; edns.bits = 0;
if(sq->dnssec & EDNS_DO) if(sq->dnssec & EDNS_DO)
edns.bits = EDNS_DO; edns.bits = EDNS_DO;
@ -3083,7 +3090,7 @@ serviced_tcp_callback(struct comm_point* c, void* arg, int error,
log_addr(VERB_ALGO, "response from upstream", &sq->addr, sq->addrlen); log_addr(VERB_ALGO, "response from upstream", &sq->addr, sq->addrlen);
log_addr(VERB_ALGO, "to local addr", &pi->addr, pi->addrlen); log_addr(VERB_ALGO, "to local addr", &pi->addr, pi->addrlen);
dt_msg_send_outside_response(sq->outnet->dtenv, &sq->addr, dt_msg_send_outside_response(sq->outnet->dtenv, &sq->addr,
&pi->addr, c->type, sq->zone, sq->zonelen, sq->qbuf, &pi->addr, c->type, c->ssl, sq->zone, sq->zonelen, sq->qbuf,
sq->qbuflen, &sq->last_sent_time, sq->outnet->now_tv, sq->qbuflen, &sq->last_sent_time, sq->outnet->now_tv,
c->buffer); c->buffer);
} }
@ -3252,7 +3259,8 @@ serviced_udp_callback(struct comm_point* c, void* arg, int error,
sq->pending = NULL; /* removed after callback */ sq->pending = NULL; /* removed after callback */
if(error == NETEVENT_TIMEOUT) { if(error == NETEVENT_TIMEOUT) {
if(sq->status == serviced_query_UDP_EDNS && sq->last_rtt < 5000) { if(sq->status == serviced_query_UDP_EDNS && sq->last_rtt < 5000 &&
(serviced_query_udp_size(sq, serviced_query_UDP_EDNS_FRAG) < serviced_query_udp_size(sq, serviced_query_UDP_EDNS))) {
/* fallback to 1480/1280 */ /* fallback to 1480/1280 */
sq->status = serviced_query_UDP_EDNS_FRAG; sq->status = serviced_query_UDP_EDNS_FRAG;
log_name_addr(VERB_ALGO, "try edns1xx0", sq->qbuf+10, log_name_addr(VERB_ALGO, "try edns1xx0", sq->qbuf+10,
@ -3296,7 +3304,7 @@ serviced_udp_callback(struct comm_point* c, void* arg, int error,
log_addr(VERB_ALGO, "to local addr", &p->pc->pif->addr, log_addr(VERB_ALGO, "to local addr", &p->pc->pif->addr,
p->pc->pif->addrlen); p->pc->pif->addrlen);
dt_msg_send_outside_response(outnet->dtenv, &sq->addr, dt_msg_send_outside_response(outnet->dtenv, &sq->addr,
&p->pc->pif->addr, c->type, sq->zone, sq->zonelen, &p->pc->pif->addr, c->type, c->ssl, sq->zone, sq->zonelen,
sq->qbuf, sq->qbuflen, &sq->last_sent_time, sq->qbuf, sq->qbuflen, &sq->last_sent_time,
sq->outnet->now_tv, c->buffer); sq->outnet->now_tv, c->buffer);
} }

View File

@ -2162,7 +2162,7 @@ rpz_apply_nsip_trigger(struct module_qstate* ms, struct rpz* r,
case RPZ_TCP_ONLY_ACTION: case RPZ_TCP_ONLY_ACTION:
/* basically a passthru here but the tcp-only will be /* basically a passthru here but the tcp-only will be
* honored before the query gets sent. */ * honored before the query gets sent. */
ms->respip_action_info->action = respip_truncate; ms->tcp_required = 1;
ret = NULL; ret = NULL;
break; break;
case RPZ_DROP_ACTION: case RPZ_DROP_ACTION:
@ -2217,7 +2217,7 @@ rpz_apply_nsdname_trigger(struct module_qstate* ms, struct rpz* r,
case RPZ_TCP_ONLY_ACTION: case RPZ_TCP_ONLY_ACTION:
/* basically a passthru here but the tcp-only will be /* basically a passthru here but the tcp-only will be
* honored before the query gets sent. */ * honored before the query gets sent. */
ms->respip_action_info->action = respip_truncate; ms->tcp_required = 1;
ret = NULL; ret = NULL;
break; break;
case RPZ_DROP_ACTION: case RPZ_DROP_ACTION:
@ -2428,7 +2428,7 @@ struct dns_msg* rpz_callback_from_iterator_cname(struct module_qstate* ms,
case RPZ_TCP_ONLY_ACTION: case RPZ_TCP_ONLY_ACTION:
/* basically a passthru here but the tcp-only will be /* basically a passthru here but the tcp-only will be
* honored before the query gets sent. */ * honored before the query gets sent. */
ms->respip_action_info->action = respip_truncate; ms->tcp_required = 1;
ret = NULL; ret = NULL;
break; break;
case RPZ_DROP_ACTION: case RPZ_DROP_ACTION:
@ -2448,6 +2448,10 @@ struct dns_msg* rpz_callback_from_iterator_cname(struct module_qstate* ms,
rpz_action_to_string(localzone_type_to_rpz_action(lzt))); rpz_action_to_string(localzone_type_to_rpz_action(lzt)));
ret = NULL; ret = NULL;
} }
if(r->log)
log_rpz_apply("qname", (z?z->name:NULL), NULL,
localzone_type_to_rpz_action(lzt),
&is->qchase, NULL, ms, r->log_name);
lock_rw_unlock(&z->lock); lock_rw_unlock(&z->lock);
lock_rw_unlock(&a->lock); lock_rw_unlock(&a->lock);
return ret; return ret;

View File

@ -196,8 +196,8 @@ enum sldns_enum_rr_type
LDNS_RR_TYPE_OPENPGPKEY = 61, /* RFC 7929 */ LDNS_RR_TYPE_OPENPGPKEY = 61, /* RFC 7929 */
LDNS_RR_TYPE_CSYNC = 62, /* RFC 7477 */ LDNS_RR_TYPE_CSYNC = 62, /* RFC 7477 */
LDNS_RR_TYPE_ZONEMD = 63, /* draft-ietf-dnsop-dns-zone-digest-12 */ LDNS_RR_TYPE_ZONEMD = 63, /* draft-ietf-dnsop-dns-zone-digest-12 */
LDNS_RR_TYPE_SVCB = 64, /* draft-ietf-dnsop-svcb-https-04 */ LDNS_RR_TYPE_SVCB = 64, /* draft-ietf-dnsop-svcb-https-04 */
LDNS_RR_TYPE_HTTPS = 65, /* draft-ietf-dnsop-svcb-https-04 */ LDNS_RR_TYPE_HTTPS = 65, /* draft-ietf-dnsop-svcb-https-04 */
LDNS_RR_TYPE_SPF = 99, /* RFC 4408 */ LDNS_RR_TYPE_SPF = 99, /* RFC 4408 */

View File

@ -2459,12 +2459,13 @@ int sldns_str2wire_wks_buf(const char* str, uint8_t* rd, size_t* len)
(void)strlcpy(proto_str, token, sizeof(proto_str)); (void)strlcpy(proto_str, token, sizeof(proto_str));
} else { } else {
int serv_port; int serv_port;
struct servent *serv = getservbyname(token, proto_str); if(atoi(token) != 0) serv_port=atoi(token);
if(serv) serv_port=(int)ntohs((uint16_t)serv->s_port); else if(strcmp(token, "0") == 0) serv_port=0;
else if(strcasecmp(token, "domain")==0) serv_port=53; else if(strcasecmp(token, "domain")==0) serv_port=53;
else { else {
serv_port = atoi(token); struct servent *serv = getservbyname(token, proto_str);
if(serv_port == 0 && strcmp(token, "0") != 0) { if(serv) serv_port=(int)ntohs((uint16_t)serv->s_port);
else {
#ifdef HAVE_ENDSERVENT #ifdef HAVE_ENDSERVENT
endservent(); endservent();
#endif #endif
@ -2474,16 +2475,16 @@ int sldns_str2wire_wks_buf(const char* str, uint8_t* rd, size_t* len)
return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX, return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX,
sldns_buffer_position(&strbuf)); sldns_buffer_position(&strbuf));
} }
if(serv_port < 0 || serv_port > 65535) { }
if(serv_port < 0 || serv_port > 65535) {
#ifdef HAVE_ENDSERVENT #ifdef HAVE_ENDSERVENT
endservent(); endservent();
#endif #endif
#ifdef HAVE_ENDPROTOENT #ifdef HAVE_ENDPROTOENT
endprotoent(); endprotoent();
#endif #endif
return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX, return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX,
sldns_buffer_position(&strbuf)); sldns_buffer_position(&strbuf));
}
} }
if(rd_len < 1+serv_port/8+1) { if(rd_len < 1+serv_port/8+1) {
/* bitmap is larger, init new bytes at 0 */ /* bitmap is larger, init new bytes at 0 */

View File

@ -192,6 +192,7 @@ static sldns_lookup_table sldns_edns_options_data[] = {
{ 6, "DHU" }, { 6, "DHU" },
{ 7, "N3U" }, { 7, "N3U" },
{ 8, "edns-client-subnet" }, { 8, "edns-client-subnet" },
{ 10, "COOKIE" },
{ 11, "edns-tcp-keepalive"}, { 11, "edns-tcp-keepalive"},
{ 12, "Padding" }, { 12, "Padding" },
{ 15, "EDE"}, { 15, "EDE"},
@ -199,6 +200,38 @@ static sldns_lookup_table sldns_edns_options_data[] = {
}; };
sldns_lookup_table* sldns_edns_options = sldns_edns_options_data; sldns_lookup_table* sldns_edns_options = sldns_edns_options_data;
/* From RFC8914 5.2 Table 3, the "Extended DNS Error Codes" registry. */
static sldns_lookup_table sldns_edns_ede_codes_data[] = {
{ LDNS_EDE_NONE, "None" },
{ LDNS_EDE_OTHER, "Other Error" },
{ LDNS_EDE_UNSUPPORTED_DNSKEY_ALG, "Unsupported DNSKEY Algorithm" },
{ LDNS_EDE_UNSUPPORTED_DS_DIGEST, "Unsupported DS Digest Type" },
{ LDNS_EDE_STALE_ANSWER, "Stale Answer" },
{ LDNS_EDE_FORGED_ANSWER, "Forged Answer" },
{ LDNS_EDE_DNSSEC_INDETERMINATE, "DNSSEC Indeterminate" },
{ LDNS_EDE_DNSSEC_BOGUS, "DNSSEC Bogus" },
{ LDNS_EDE_SIGNATURE_EXPIRED, "Signature Expired" },
{ LDNS_EDE_SIGNATURE_NOT_YET_VALID, "Signature Not Yet Valid" },
{ LDNS_EDE_DNSKEY_MISSING, "DNSKEY Missing" },
{ LDNS_EDE_RRSIGS_MISSING, "RRSIGs Missing" },
{ LDNS_EDE_NO_ZONE_KEY_BIT_SET, "No Zone Key Bit Set" },
{ LDNS_EDE_NSEC_MISSING, "NSEC Missing" },
{ LDNS_EDE_CACHED_ERROR, "Cached Error" },
{ LDNS_EDE_NOT_READY, "Not Ready" },
{ LDNS_EDE_BLOCKED, "Blocked" },
{ LDNS_EDE_CENSORED, "Censored" },
{ LDNS_EDE_FILTERED, "Filtered" },
{ LDNS_EDE_PROHIBITED, "Prohibited" },
{ LDNS_EDE_STALE_NXDOMAIN_ANSWER, "Stale NXDOMAIN Answer" },
{ LDNS_EDE_NOT_AUTHORITATIVE, "Not Authoritative" },
{ LDNS_EDE_NOT_SUPPORTED, "Not Supported" },
{ LDNS_EDE_NO_REACHABLE_AUTHORITY, "No Reachable Authority" },
{ LDNS_EDE_NETWORK_ERROR, "Network Error" },
{ LDNS_EDE_INVALID_DATA, "Invalid Data" },
{ 0, NULL}
};
sldns_lookup_table* sldns_edns_ede_codes = sldns_edns_ede_codes_data;
static sldns_lookup_table sldns_tsig_errors_data[] = { static sldns_lookup_table sldns_tsig_errors_data[] = {
{ LDNS_TSIG_ERROR_NOERROR, "NOERROR" }, { LDNS_TSIG_ERROR_NOERROR, "NOERROR" },
{ LDNS_RCODE_FORMERR, "FORMERR" }, { LDNS_RCODE_FORMERR, "FORMERR" },
@ -2234,6 +2267,52 @@ static int sldns_wire2str_edns_keepalive_print(char** s, size_t* sl,
return w; return w;
} }
int sldns_wire2str_edns_ede_print(char** s, size_t* sl,
uint8_t* data, size_t len)
{
uint16_t ede_code;
int w = 0;
sldns_lookup_table *lt;
size_t i;
int printable;
if(len < 2) {
w += sldns_str_print(s, sl, "malformed ede ");
w += print_hex_buf(s, sl, data, len);
return w;
}
ede_code = sldns_read_uint16(data);
lt = sldns_lookup_by_id(sldns_edns_ede_codes, (int)ede_code);
if(lt && lt->name)
w += sldns_str_print(s, sl, "%s", lt->name);
else w += sldns_str_print(s, sl, "%d", (int)ede_code);
if(len == 2)
return w;
w += sldns_str_print(s, sl, " ");
/* If it looks like text, show it as text. */
printable=1;
for(i=2; i<len; i++) {
if(isprint((unsigned char)data[i]) || data[i] == '\t')
continue;
printable = 0;
break;
}
if(printable) {
w += sldns_str_print(s, sl, "\"");
for(i=2; i<len; i++) {
w += str_char_print(s, sl, data[i]);
}
w += sldns_str_print(s, sl, "\"");
} else {
w += print_hex_buf(s, sl, data+2, len-2);
}
return w;
}
int sldns_wire2str_edns_option_print(char** s, size_t* sl, int sldns_wire2str_edns_option_print(char** s, size_t* sl,
uint16_t option_code, uint8_t* optdata, size_t optlen) uint16_t option_code, uint8_t* optdata, size_t optlen)
{ {
@ -2268,6 +2347,9 @@ int sldns_wire2str_edns_option_print(char** s, size_t* sl,
case LDNS_EDNS_PADDING: case LDNS_EDNS_PADDING:
w += print_hex_buf(s, sl, optdata, optlen); w += print_hex_buf(s, sl, optdata, optlen);
break; break;
case LDNS_EDNS_EDE:
w += sldns_wire2str_edns_ede_print(s, sl, optdata, optlen);
break;
default: default:
/* unknown option code */ /* unknown option code */
w += print_hex_buf(s, sl, optdata, optlen); w += print_hex_buf(s, sl, optdata, optlen);

View File

@ -36,6 +36,8 @@ extern struct sldns_struct_lookup_table* sldns_opcodes;
extern struct sldns_struct_lookup_table* sldns_edns_flags; extern struct sldns_struct_lookup_table* sldns_edns_flags;
/** EDNS option codes */ /** EDNS option codes */
extern struct sldns_struct_lookup_table* sldns_edns_options; extern struct sldns_struct_lookup_table* sldns_edns_options;
/** EDNS EDE codes */
extern struct sldns_struct_lookup_table* sldns_edns_ede_codes;
/** error string from wireparse */ /** error string from wireparse */
extern struct sldns_struct_lookup_table* sldns_wireparse_errors; extern struct sldns_struct_lookup_table* sldns_wireparse_errors;
/** tsig errors are the rcodes with extra (higher) values */ /** tsig errors are the rcodes with extra (higher) values */
@ -1020,6 +1022,17 @@ int sldns_wire2str_edns_n3u_print(char** str, size_t* str_len,
int sldns_wire2str_edns_subnet_print(char** str, size_t* str_len, int sldns_wire2str_edns_subnet_print(char** str, size_t* str_len,
uint8_t* option_data, size_t option_len); uint8_t* option_data, size_t option_len);
/**
* Print EDNS EDE option data to string. User buffers, moves string pointers.
* @param str: string buffer.
* @param str_len: length of string buffer.
* @param option_data: buffer with EDNS option code data.
* @param option_len: length of the data for this option.
* @return number of characters (except null) needed to print.
*/
int sldns_wire2str_edns_ede_print(char** str, size_t* str_len,
uint8_t* option_data, size_t option_len);
/** /**
* Print an EDNS option as OPT: VALUE. User buffers, moves string pointers. * Print an EDNS option as OPT: VALUE. User buffers, moves string pointers.
* @param str: string buffer. * @param str: string buffer.

View File

@ -142,6 +142,7 @@ config_create(void)
cfg->log_tag_queryreply = 0; cfg->log_tag_queryreply = 0;
cfg->log_local_actions = 0; cfg->log_local_actions = 0;
cfg->log_servfail = 0; cfg->log_servfail = 0;
cfg->log_destaddr = 0;
#ifndef USE_WINSOCK #ifndef USE_WINSOCK
# ifdef USE_MINI_EVENT # ifdef USE_MINI_EVENT
/* select max 1024 sockets */ /* select max 1024 sockets */
@ -271,6 +272,7 @@ config_create(void)
cfg->val_permissive_mode = 0; cfg->val_permissive_mode = 0;
cfg->aggressive_nsec = 1; cfg->aggressive_nsec = 1;
cfg->ignore_cd = 0; cfg->ignore_cd = 0;
cfg->disable_edns_do = 0;
cfg->serve_expired = 0; cfg->serve_expired = 0;
cfg->serve_expired_ttl = 0; cfg->serve_expired_ttl = 0;
cfg->serve_expired_ttl_reset = 0; cfg->serve_expired_ttl_reset = 0;
@ -381,6 +383,7 @@ config_create(void)
#ifdef USE_CACHEDB #ifdef USE_CACHEDB
if(!(cfg->cachedb_backend = strdup("testframe"))) goto error_exit; if(!(cfg->cachedb_backend = strdup("testframe"))) goto error_exit;
if(!(cfg->cachedb_secret = strdup("default"))) goto error_exit; if(!(cfg->cachedb_secret = strdup("default"))) goto error_exit;
cfg->cachedb_no_store = 0;
#ifdef USE_REDIS #ifdef USE_REDIS
if(!(cfg->redis_server_host = strdup("127.0.0.1"))) goto error_exit; if(!(cfg->redis_server_host = strdup("127.0.0.1"))) goto error_exit;
cfg->redis_server_path = NULL; cfg->redis_server_path = NULL;
@ -388,6 +391,7 @@ config_create(void)
cfg->redis_timeout = 100; cfg->redis_timeout = 100;
cfg->redis_server_port = 6379; cfg->redis_server_port = 6379;
cfg->redis_expire_records = 0; cfg->redis_expire_records = 0;
cfg->redis_logical_db = 0;
#endif /* USE_REDIS */ #endif /* USE_REDIS */
#endif /* USE_CACHEDB */ #endif /* USE_CACHEDB */
#ifdef USE_IPSET #ifdef USE_IPSET
@ -687,9 +691,11 @@ int config_set_option(struct config_file* cfg, const char* opt,
else S_YNO("log-tag-queryreply:", log_tag_queryreply) else S_YNO("log-tag-queryreply:", log_tag_queryreply)
else S_YNO("log-local-actions:", log_local_actions) else S_YNO("log-local-actions:", log_local_actions)
else S_YNO("log-servfail:", log_servfail) else S_YNO("log-servfail:", log_servfail)
else S_YNO("log-destaddr:", log_destaddr)
else S_YNO("val-permissive-mode:", val_permissive_mode) else S_YNO("val-permissive-mode:", val_permissive_mode)
else S_YNO("aggressive-nsec:", aggressive_nsec) else S_YNO("aggressive-nsec:", aggressive_nsec)
else S_YNO("ignore-cd-flag:", ignore_cd) else S_YNO("ignore-cd-flag:", ignore_cd)
else S_YNO("disable-edns-do:", disable_edns_do)
else if(strcmp(opt, "serve-expired:") == 0) else if(strcmp(opt, "serve-expired:") == 0)
{ IS_YES_OR_NO; cfg->serve_expired = (strcmp(val, "yes") == 0); { IS_YES_OR_NO; cfg->serve_expired = (strcmp(val, "yes") == 0);
SERVE_EXPIRED = cfg->serve_expired; } SERVE_EXPIRED = cfg->serve_expired; }
@ -819,6 +825,9 @@ int config_set_option(struct config_file* cfg, const char* opt,
{ IS_NUMBER_OR_ZERO; cfg->ipsecmod_max_ttl = atoi(val); } { IS_NUMBER_OR_ZERO; cfg->ipsecmod_max_ttl = atoi(val); }
else S_YNO("ipsecmod-strict:", ipsecmod_strict) else S_YNO("ipsecmod-strict:", ipsecmod_strict)
#endif #endif
#ifdef USE_CACHEDB
else S_YNO("cachedb-no-store:", cachedb_no_store)
#endif /* USE_CACHEDB */
else if(strcmp(opt, "define-tag:") ==0) { else if(strcmp(opt, "define-tag:") ==0) {
return config_add_tag(cfg, val); return config_add_tag(cfg, val);
/* val_sig_skew_min, max and val_max_restart are copied into val_env /* val_sig_skew_min, max and val_max_restart are copied into val_env
@ -1120,6 +1129,7 @@ config_get_option(struct config_file* cfg, const char* opt,
else O_YNO(opt, "log-tag-queryreply", log_tag_queryreply) else O_YNO(opt, "log-tag-queryreply", log_tag_queryreply)
else O_YNO(opt, "log-local-actions", log_local_actions) else O_YNO(opt, "log-local-actions", log_local_actions)
else O_YNO(opt, "log-servfail", log_servfail) else O_YNO(opt, "log-servfail", log_servfail)
else O_YNO(opt, "log-destaddr", log_destaddr)
else O_STR(opt, "pidfile", pidfile) else O_STR(opt, "pidfile", pidfile)
else O_YNO(opt, "hide-identity", hide_identity) else O_YNO(opt, "hide-identity", hide_identity)
else O_YNO(opt, "hide-version", hide_version) else O_YNO(opt, "hide-version", hide_version)
@ -1149,6 +1159,7 @@ config_get_option(struct config_file* cfg, const char* opt,
else O_YNO(opt, "val-permissive-mode", val_permissive_mode) else O_YNO(opt, "val-permissive-mode", val_permissive_mode)
else O_YNO(opt, "aggressive-nsec", aggressive_nsec) else O_YNO(opt, "aggressive-nsec", aggressive_nsec)
else O_YNO(opt, "ignore-cd-flag", ignore_cd) else O_YNO(opt, "ignore-cd-flag", ignore_cd)
else O_YNO(opt, "disable-edns-do", disable_edns_do)
else O_YNO(opt, "serve-expired", serve_expired) else O_YNO(opt, "serve-expired", serve_expired)
else O_DEC(opt, "serve-expired-ttl", serve_expired_ttl) else O_DEC(opt, "serve-expired-ttl", serve_expired_ttl)
else O_YNO(opt, "serve-expired-ttl-reset", serve_expired_ttl_reset) else O_YNO(opt, "serve-expired-ttl-reset", serve_expired_ttl_reset)
@ -1306,6 +1317,7 @@ config_get_option(struct config_file* cfg, const char* opt,
#ifdef USE_CACHEDB #ifdef USE_CACHEDB
else O_STR(opt, "backend", cachedb_backend) else O_STR(opt, "backend", cachedb_backend)
else O_STR(opt, "secret-seed", cachedb_secret) else O_STR(opt, "secret-seed", cachedb_secret)
else O_YNO(opt, "cachedb-no-store", cachedb_no_store)
#ifdef USE_REDIS #ifdef USE_REDIS
else O_STR(opt, "redis-server-host", redis_server_host) else O_STR(opt, "redis-server-host", redis_server_host)
else O_DEC(opt, "redis-server-port", redis_server_port) else O_DEC(opt, "redis-server-port", redis_server_port)
@ -1313,6 +1325,7 @@ config_get_option(struct config_file* cfg, const char* opt,
else O_STR(opt, "redis-server-password", redis_server_password) else O_STR(opt, "redis-server-password", redis_server_password)
else O_DEC(opt, "redis-timeout", redis_timeout) else O_DEC(opt, "redis-timeout", redis_timeout)
else O_YNO(opt, "redis-expire-records", redis_expire_records) else O_YNO(opt, "redis-expire-records", redis_expire_records)
else O_DEC(opt, "redis-logical-db", redis_logical_db)
#endif /* USE_REDIS */ #endif /* USE_REDIS */
#endif /* USE_CACHEDB */ #endif /* USE_CACHEDB */
#ifdef USE_IPSET #ifdef USE_IPSET

View File

@ -349,6 +349,8 @@ struct config_file {
int log_servfail; int log_servfail;
/** log identity to report */ /** log identity to report */
char* log_identity; char* log_identity;
/** log dest addr for log_replies */
int log_destaddr;
/** do not report identity (id.server, hostname.bind) */ /** do not report identity (id.server, hostname.bind) */
int hide_identity; int hide_identity;
@ -409,6 +411,8 @@ struct config_file {
int aggressive_nsec; int aggressive_nsec;
/** ignore the CD flag in incoming queries and refuse them bogus data */ /** ignore the CD flag in incoming queries and refuse them bogus data */
int ignore_cd; int ignore_cd;
/** disable EDNS DO flag in outgoing requests */
int disable_edns_do;
/** serve expired entries and prefetch them */ /** serve expired entries and prefetch them */
int serve_expired; int serve_expired;
/** serve expired entries until TTL after expiration */ /** serve expired entries until TTL after expiration */
@ -699,6 +703,8 @@ struct config_file {
char* cachedb_backend; char* cachedb_backend;
/** secret seed for hash key calculation */ /** secret seed for hash key calculation */
char* cachedb_secret; char* cachedb_secret;
/** cachedb that does not store, but only reads from database, if on */
int cachedb_no_store;
#ifdef USE_REDIS #ifdef USE_REDIS
/** redis server's IP address or host name */ /** redis server's IP address or host name */
char* redis_server_host; char* redis_server_host;
@ -712,6 +718,8 @@ struct config_file {
int redis_timeout; int redis_timeout;
/** set timeout on redis records based on DNS response ttl */ /** set timeout on redis records based on DNS response ttl */
int redis_expire_records; int redis_expire_records;
/** set the redis logical database upon connection */
int redis_logical_db;
#endif #endif
#endif #endif
/** Downstream DNS Cookies */ /** Downstream DNS Cookies */

File diff suppressed because it is too large Load Diff

View File

@ -403,6 +403,7 @@ val-clean-additional{COLON} { YDVAR(1, VAR_VAL_CLEAN_ADDITIONAL) }
val-permissive-mode{COLON} { YDVAR(1, VAR_VAL_PERMISSIVE_MODE) } val-permissive-mode{COLON} { YDVAR(1, VAR_VAL_PERMISSIVE_MODE) }
aggressive-nsec{COLON} { YDVAR(1, VAR_AGGRESSIVE_NSEC) } aggressive-nsec{COLON} { YDVAR(1, VAR_AGGRESSIVE_NSEC) }
ignore-cd-flag{COLON} { YDVAR(1, VAR_IGNORE_CD_FLAG) } ignore-cd-flag{COLON} { YDVAR(1, VAR_IGNORE_CD_FLAG) }
disable-edns-do{COLON} { YDVAR(1, VAR_DISABLE_EDNS_DO) }
serve-expired{COLON} { YDVAR(1, VAR_SERVE_EXPIRED) } serve-expired{COLON} { YDVAR(1, VAR_SERVE_EXPIRED) }
serve-expired-ttl{COLON} { YDVAR(1, VAR_SERVE_EXPIRED_TTL) } serve-expired-ttl{COLON} { YDVAR(1, VAR_SERVE_EXPIRED_TTL) }
serve-expired-ttl-reset{COLON} { YDVAR(1, VAR_SERVE_EXPIRED_TTL_RESET) } serve-expired-ttl-reset{COLON} { YDVAR(1, VAR_SERVE_EXPIRED_TTL_RESET) }
@ -433,6 +434,7 @@ log-replies{COLON} { YDVAR(1, VAR_LOG_REPLIES) }
log-tag-queryreply{COLON} { YDVAR(1, VAR_LOG_TAG_QUERYREPLY) } log-tag-queryreply{COLON} { YDVAR(1, VAR_LOG_TAG_QUERYREPLY) }
log-local-actions{COLON} { YDVAR(1, VAR_LOG_LOCAL_ACTIONS) } log-local-actions{COLON} { YDVAR(1, VAR_LOG_LOCAL_ACTIONS) }
log-servfail{COLON} { YDVAR(1, VAR_LOG_SERVFAIL) } log-servfail{COLON} { YDVAR(1, VAR_LOG_SERVFAIL) }
log-destaddr{COLON} { YDVAR(1, VAR_LOG_DESTADDR) }
local-zone{COLON} { YDVAR(2, VAR_LOCAL_ZONE) } local-zone{COLON} { YDVAR(2, VAR_LOCAL_ZONE) }
local-data{COLON} { YDVAR(1, VAR_LOCAL_DATA) } local-data{COLON} { YDVAR(1, VAR_LOCAL_DATA) }
local-data-ptr{COLON} { YDVAR(1, VAR_LOCAL_DATA_PTR) } local-data-ptr{COLON} { YDVAR(1, VAR_LOCAL_DATA_PTR) }
@ -557,12 +559,14 @@ ipsecmod-strict{COLON} { YDVAR(1, VAR_IPSECMOD_STRICT) }
cachedb{COLON} { YDVAR(0, VAR_CACHEDB) } cachedb{COLON} { YDVAR(0, VAR_CACHEDB) }
backend{COLON} { YDVAR(1, VAR_CACHEDB_BACKEND) } backend{COLON} { YDVAR(1, VAR_CACHEDB_BACKEND) }
secret-seed{COLON} { YDVAR(1, VAR_CACHEDB_SECRETSEED) } secret-seed{COLON} { YDVAR(1, VAR_CACHEDB_SECRETSEED) }
cachedb-no-store{COLON} { YDVAR(1, VAR_CACHEDB_NO_STORE) }
redis-server-host{COLON} { YDVAR(1, VAR_CACHEDB_REDISHOST) } redis-server-host{COLON} { YDVAR(1, VAR_CACHEDB_REDISHOST) }
redis-server-port{COLON} { YDVAR(1, VAR_CACHEDB_REDISPORT) } redis-server-port{COLON} { YDVAR(1, VAR_CACHEDB_REDISPORT) }
redis-server-path{COLON} { YDVAR(1, VAR_CACHEDB_REDISPATH) } redis-server-path{COLON} { YDVAR(1, VAR_CACHEDB_REDISPATH) }
redis-server-password{COLON} { YDVAR(1, VAR_CACHEDB_REDISPASSWORD) } redis-server-password{COLON} { YDVAR(1, VAR_CACHEDB_REDISPASSWORD) }
redis-timeout{COLON} { YDVAR(1, VAR_CACHEDB_REDISTIMEOUT) } redis-timeout{COLON} { YDVAR(1, VAR_CACHEDB_REDISTIMEOUT) }
redis-expire-records{COLON} { YDVAR(1, VAR_CACHEDB_REDISEXPIRERECORDS) } redis-expire-records{COLON} { YDVAR(1, VAR_CACHEDB_REDISEXPIRERECORDS) }
redis-logical-db{COLON} { YDVAR(1, VAR_CACHEDB_REDISLOGICALDB) }
ipset{COLON} { YDVAR(0, VAR_IPSET) } ipset{COLON} { YDVAR(0, VAR_IPSET) }
name-v4{COLON} { YDVAR(1, VAR_IPSET_NAME_V4) } name-v4{COLON} { YDVAR(1, VAR_IPSET_NAME_V4) }
name-v6{COLON} { YDVAR(1, VAR_IPSET_NAME_V6) } name-v6{COLON} { YDVAR(1, VAR_IPSET_NAME_V6) }

View File

@ -283,64 +283,68 @@
#define VAR_CACHEDB_REDISEXPIRERECORDS 539 #define VAR_CACHEDB_REDISEXPIRERECORDS 539
#define VAR_CACHEDB_REDISPATH 540 #define VAR_CACHEDB_REDISPATH 540
#define VAR_CACHEDB_REDISPASSWORD 541 #define VAR_CACHEDB_REDISPASSWORD 541
#define VAR_UDP_UPSTREAM_WITHOUT_DOWNSTREAM 542 #define VAR_CACHEDB_REDISLOGICALDB 542
#define VAR_FOR_UPSTREAM 543 #define VAR_UDP_UPSTREAM_WITHOUT_DOWNSTREAM 543
#define VAR_AUTH_ZONE 544 #define VAR_FOR_UPSTREAM 544
#define VAR_ZONEFILE 545 #define VAR_AUTH_ZONE 545
#define VAR_MASTER 546 #define VAR_ZONEFILE 546
#define VAR_URL 547 #define VAR_MASTER 547
#define VAR_FOR_DOWNSTREAM 548 #define VAR_URL 548
#define VAR_FALLBACK_ENABLED 549 #define VAR_FOR_DOWNSTREAM 549
#define VAR_TLS_ADDITIONAL_PORT 550 #define VAR_FALLBACK_ENABLED 550
#define VAR_LOW_RTT 551 #define VAR_TLS_ADDITIONAL_PORT 551
#define VAR_LOW_RTT_PERMIL 552 #define VAR_LOW_RTT 552
#define VAR_FAST_SERVER_PERMIL 553 #define VAR_LOW_RTT_PERMIL 553
#define VAR_FAST_SERVER_NUM 554 #define VAR_FAST_SERVER_PERMIL 554
#define VAR_ALLOW_NOTIFY 555 #define VAR_FAST_SERVER_NUM 555
#define VAR_TLS_WIN_CERT 556 #define VAR_ALLOW_NOTIFY 556
#define VAR_TCP_CONNECTION_LIMIT 557 #define VAR_TLS_WIN_CERT 557
#define VAR_ANSWER_COOKIE 558 #define VAR_TCP_CONNECTION_LIMIT 558
#define VAR_COOKIE_SECRET 559 #define VAR_ANSWER_COOKIE 559
#define VAR_IP_RATELIMIT_COOKIE 560 #define VAR_COOKIE_SECRET 560
#define VAR_FORWARD_NO_CACHE 561 #define VAR_IP_RATELIMIT_COOKIE 561
#define VAR_STUB_NO_CACHE 562 #define VAR_FORWARD_NO_CACHE 562
#define VAR_LOG_SERVFAIL 563 #define VAR_STUB_NO_CACHE 563
#define VAR_DENY_ANY 564 #define VAR_LOG_SERVFAIL 564
#define VAR_UNKNOWN_SERVER_TIME_LIMIT 565 #define VAR_DENY_ANY 565
#define VAR_LOG_TAG_QUERYREPLY 566 #define VAR_UNKNOWN_SERVER_TIME_LIMIT 566
#define VAR_STREAM_WAIT_SIZE 567 #define VAR_LOG_TAG_QUERYREPLY 567
#define VAR_TLS_CIPHERS 568 #define VAR_STREAM_WAIT_SIZE 568
#define VAR_TLS_CIPHERSUITES 569 #define VAR_TLS_CIPHERS 569
#define VAR_TLS_USE_SNI 570 #define VAR_TLS_CIPHERSUITES 570
#define VAR_IPSET 571 #define VAR_TLS_USE_SNI 571
#define VAR_IPSET_NAME_V4 572 #define VAR_IPSET 572
#define VAR_IPSET_NAME_V6 573 #define VAR_IPSET_NAME_V4 573
#define VAR_TLS_SESSION_TICKET_KEYS 574 #define VAR_IPSET_NAME_V6 574
#define VAR_RPZ 575 #define VAR_TLS_SESSION_TICKET_KEYS 575
#define VAR_TAGS 576 #define VAR_RPZ 576
#define VAR_RPZ_ACTION_OVERRIDE 577 #define VAR_TAGS 577
#define VAR_RPZ_CNAME_OVERRIDE 578 #define VAR_RPZ_ACTION_OVERRIDE 578
#define VAR_RPZ_LOG 579 #define VAR_RPZ_CNAME_OVERRIDE 579
#define VAR_RPZ_LOG_NAME 580 #define VAR_RPZ_LOG 580
#define VAR_DYNLIB 581 #define VAR_RPZ_LOG_NAME 581
#define VAR_DYNLIB_FILE 582 #define VAR_DYNLIB 582
#define VAR_EDNS_CLIENT_STRING 583 #define VAR_DYNLIB_FILE 583
#define VAR_EDNS_CLIENT_STRING_OPCODE 584 #define VAR_EDNS_CLIENT_STRING 584
#define VAR_NSID 585 #define VAR_EDNS_CLIENT_STRING_OPCODE 585
#define VAR_ZONEMD_PERMISSIVE_MODE 586 #define VAR_NSID 586
#define VAR_ZONEMD_CHECK 587 #define VAR_ZONEMD_PERMISSIVE_MODE 587
#define VAR_ZONEMD_REJECT_ABSENCE 588 #define VAR_ZONEMD_CHECK 588
#define VAR_RPZ_SIGNAL_NXDOMAIN_RA 589 #define VAR_ZONEMD_REJECT_ABSENCE 589
#define VAR_INTERFACE_AUTOMATIC_PORTS 590 #define VAR_RPZ_SIGNAL_NXDOMAIN_RA 590
#define VAR_EDE 591 #define VAR_INTERFACE_AUTOMATIC_PORTS 591
#define VAR_INTERFACE_ACTION 592 #define VAR_EDE 592
#define VAR_INTERFACE_VIEW 593 #define VAR_INTERFACE_ACTION 593
#define VAR_INTERFACE_TAG 594 #define VAR_INTERFACE_VIEW 594
#define VAR_INTERFACE_TAG_ACTION 595 #define VAR_INTERFACE_TAG 595
#define VAR_INTERFACE_TAG_DATA 596 #define VAR_INTERFACE_TAG_ACTION 596
#define VAR_PROXY_PROTOCOL_PORT 597 #define VAR_INTERFACE_TAG_DATA 597
#define VAR_STATISTICS_INHIBIT_ZERO 598 #define VAR_PROXY_PROTOCOL_PORT 598
#define VAR_HARDEN_UNKNOWN_ADDITIONAL 599 #define VAR_STATISTICS_INHIBIT_ZERO 599
#define VAR_HARDEN_UNKNOWN_ADDITIONAL 600
#define VAR_DISABLE_EDNS_DO 601
#define VAR_CACHEDB_NO_STORE 602
#define VAR_LOG_DESTADDR 603
#ifndef YYSTYPE_DEFINED #ifndef YYSTYPE_DEFINED
#define YYSTYPE_DEFINED #define YYSTYPE_DEFINED
typedef union { typedef union {

View File

@ -179,6 +179,7 @@ extern struct config_parser_state* cfg_parser;
%token VAR_CACHEDB VAR_CACHEDB_BACKEND VAR_CACHEDB_SECRETSEED %token VAR_CACHEDB VAR_CACHEDB_BACKEND VAR_CACHEDB_SECRETSEED
%token VAR_CACHEDB_REDISHOST VAR_CACHEDB_REDISPORT VAR_CACHEDB_REDISTIMEOUT %token VAR_CACHEDB_REDISHOST VAR_CACHEDB_REDISPORT VAR_CACHEDB_REDISTIMEOUT
%token VAR_CACHEDB_REDISEXPIRERECORDS VAR_CACHEDB_REDISPATH VAR_CACHEDB_REDISPASSWORD %token VAR_CACHEDB_REDISEXPIRERECORDS VAR_CACHEDB_REDISPATH VAR_CACHEDB_REDISPASSWORD
%token VAR_CACHEDB_REDISLOGICALDB
%token VAR_UDP_UPSTREAM_WITHOUT_DOWNSTREAM VAR_FOR_UPSTREAM %token VAR_UDP_UPSTREAM_WITHOUT_DOWNSTREAM VAR_FOR_UPSTREAM
%token VAR_AUTH_ZONE VAR_ZONEFILE VAR_MASTER VAR_URL VAR_FOR_DOWNSTREAM %token VAR_AUTH_ZONE VAR_ZONEFILE VAR_MASTER VAR_URL VAR_FOR_DOWNSTREAM
%token VAR_FALLBACK_ENABLED VAR_TLS_ADDITIONAL_PORT VAR_LOW_RTT VAR_LOW_RTT_PERMIL %token VAR_FALLBACK_ENABLED VAR_TLS_ADDITIONAL_PORT VAR_LOW_RTT VAR_LOW_RTT_PERMIL
@ -198,7 +199,8 @@ extern struct config_parser_state* cfg_parser;
%token VAR_INTERFACE_ACTION VAR_INTERFACE_VIEW VAR_INTERFACE_TAG %token VAR_INTERFACE_ACTION VAR_INTERFACE_VIEW VAR_INTERFACE_TAG
%token VAR_INTERFACE_TAG_ACTION VAR_INTERFACE_TAG_DATA %token VAR_INTERFACE_TAG_ACTION VAR_INTERFACE_TAG_DATA
%token VAR_PROXY_PROTOCOL_PORT VAR_STATISTICS_INHIBIT_ZERO %token VAR_PROXY_PROTOCOL_PORT VAR_STATISTICS_INHIBIT_ZERO
%token VAR_HARDEN_UNKNOWN_ADDITIONAL %token VAR_HARDEN_UNKNOWN_ADDITIONAL VAR_DISABLE_EDNS_DO VAR_CACHEDB_NO_STORE
%token VAR_LOG_DESTADDR
%% %%
toplevelvars: /* empty */ | toplevelvars toplevelvar ; toplevelvars: /* empty */ | toplevelvars toplevelvar ;
@ -332,7 +334,8 @@ content_server: server_num_threads | server_verbosity | server_port |
server_tcp_reuse_timeout | server_tcp_auth_query_timeout | server_tcp_reuse_timeout | server_tcp_auth_query_timeout |
server_interface_automatic_ports | server_ede | server_interface_automatic_ports | server_ede |
server_proxy_protocol_port | server_statistics_inhibit_zero | server_proxy_protocol_port | server_statistics_inhibit_zero |
server_harden_unknown_additional server_harden_unknown_additional | server_disable_edns_do |
server_log_destaddr
; ;
stubstart: VAR_STUB_ZONE stubstart: VAR_STUB_ZONE
{ {
@ -1249,6 +1252,15 @@ server_log_servfail: VAR_LOG_SERVFAIL STRING_ARG
free($2); free($2);
} }
; ;
server_log_destaddr: VAR_LOG_DESTADDR STRING_ARG
{
OUTYY(("P(server_log_destaddr:%s)\n", $2));
if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
yyerror("expected yes or no.");
else cfg_parser->cfg->log_destaddr = (strcmp($2, "yes")==0);
free($2);
}
;
server_log_local_actions: VAR_LOG_LOCAL_ACTIONS STRING_ARG server_log_local_actions: VAR_LOG_LOCAL_ACTIONS STRING_ARG
{ {
OUTYY(("P(server_log_local_actions:%s)\n", $2)); OUTYY(("P(server_log_local_actions:%s)\n", $2));
@ -2060,6 +2072,15 @@ server_ignore_cd_flag: VAR_IGNORE_CD_FLAG STRING_ARG
free($2); free($2);
} }
; ;
server_disable_edns_do: VAR_DISABLE_EDNS_DO STRING_ARG
{
OUTYY(("P(server_disable_edns_do:%s)\n", $2));
if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
yyerror("expected yes or no.");
else cfg_parser->cfg->disable_edns_do = (strcmp($2, "yes")==0);
free($2);
}
;
server_serve_expired: VAR_SERVE_EXPIRED STRING_ARG server_serve_expired: VAR_SERVE_EXPIRED STRING_ARG
{ {
OUTYY(("P(server_serve_expired:%s)\n", $2)); OUTYY(("P(server_serve_expired:%s)\n", $2));
@ -3701,7 +3722,8 @@ contents_cachedb: contents_cachedb content_cachedb
| ; | ;
content_cachedb: cachedb_backend_name | cachedb_secret_seed | content_cachedb: cachedb_backend_name | cachedb_secret_seed |
redis_server_host | redis_server_port | redis_timeout | redis_server_host | redis_server_port | redis_timeout |
redis_expire_records | redis_server_path | redis_server_password redis_expire_records | redis_server_path | redis_server_password |
cachedb_no_store | redis_logical_db
; ;
cachedb_backend_name: VAR_CACHEDB_BACKEND STRING_ARG cachedb_backend_name: VAR_CACHEDB_BACKEND STRING_ARG
{ {
@ -3727,6 +3749,19 @@ cachedb_secret_seed: VAR_CACHEDB_SECRETSEED STRING_ARG
#endif #endif
} }
; ;
cachedb_no_store: VAR_CACHEDB_NO_STORE STRING_ARG
{
#ifdef USE_CACHEDB
OUTYY(("P(cachedb_no_store:%s)\n", $2));
if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
yyerror("expected yes or no.");
else cfg_parser->cfg->cachedb_no_store = (strcmp($2, "yes")==0);
#else
OUTYY(("P(Compiled without cachedb, ignoring)\n"));
#endif
free($2);
}
;
redis_server_host: VAR_CACHEDB_REDISHOST STRING_ARG redis_server_host: VAR_CACHEDB_REDISHOST STRING_ARG
{ {
#if defined(USE_CACHEDB) && defined(USE_REDIS) #if defined(USE_CACHEDB) && defined(USE_REDIS)
@ -3804,6 +3839,21 @@ redis_expire_records: VAR_CACHEDB_REDISEXPIRERECORDS STRING_ARG
free($2); free($2);
} }
; ;
redis_logical_db: VAR_CACHEDB_REDISLOGICALDB STRING_ARG
{
#if defined(USE_CACHEDB) && defined(USE_REDIS)
int db;
OUTYY(("P(redis_logical_db:%s)\n", $2));
db = atoi($2);
if((db == 0 && strcmp($2, "0") != 0) || db < 0)
yyerror("valid redis logical database index expected");
else cfg_parser->cfg->redis_logical_db = db;
#else
OUTYY(("P(Compiled without cachedb or redis, ignoring)\n"));
#endif
free($2);
}
;
server_tcp_connection_limit: VAR_TCP_CONNECTION_LIMIT STRING_ARG STRING_ARG server_tcp_connection_limit: VAR_TCP_CONNECTION_LIMIT STRING_ARG STRING_ARG
{ {
OUTYY(("P(server_tcp_connection_limit:%s %s)\n", $2, $3)); OUTYY(("P(server_tcp_connection_limit:%s %s)\n", $2, $3));

View File

@ -886,6 +886,9 @@ ede_trim_text(struct edns_option** list)
curr->opt_len = 2; curr->opt_len = 2;
prev = curr; prev = curr;
curr = curr->next; curr = curr->next;
} else {
prev = curr;
curr = curr->next;
} }
} else { } else {
/* continue */ /* continue */
@ -1012,8 +1015,10 @@ reply_info_answer_encode(struct query_info* qinf, struct reply_info* rep,
ede_size = calc_ede_option_size(edns, &ede_txt_size); ede_size = calc_ede_option_size(edns, &ede_txt_size);
if(sldns_buffer_capacity(pkt) < udpsize) if(sldns_buffer_capacity(pkt) < udpsize)
udpsize = sldns_buffer_capacity(pkt); udpsize = sldns_buffer_capacity(pkt);
if(!edns || !edns->edns_present) {
attach_edns = 0;
/* EDEs are optional, try to fit anything else before them */ /* EDEs are optional, try to fit anything else before them */
if(udpsize < LDNS_HEADER_SIZE + edns_field_size - ede_size) { } else if(udpsize < LDNS_HEADER_SIZE + edns_field_size - ede_size) {
/* packet too small to contain edns, omit it. */ /* packet too small to contain edns, omit it. */
attach_edns = 0; attach_edns = 0;
} else { } else {

View File

@ -47,6 +47,7 @@
#include "util/regional.h" #include "util/regional.h"
#include "util/rfc_1982.h" #include "util/rfc_1982.h"
#include "util/edns.h" #include "util/edns.h"
#include "util/net_help.h"
#include "sldns/rrdef.h" #include "sldns/rrdef.h"
#include "sldns/sbuffer.h" #include "sldns/sbuffer.h"
#include "sldns/parseutil.h" #include "sldns/parseutil.h"
@ -1306,3 +1307,27 @@ log_edns_opt_list(enum verbosity_value level, const char* info_str,
} }
} }
/** remove RR from msgparse RRset, return true if rrset is entirely bad */
int
msgparse_rrset_remove_rr(const char* str, sldns_buffer* pkt, struct rrset_parse* rrset,
struct rr_parse* prev, struct rr_parse* rr, struct sockaddr_storage* addr, socklen_t addrlen)
{
if(verbosity >= VERB_QUERY && rrset->dname_len <= LDNS_MAX_DOMAINLEN && str) {
uint8_t buf[LDNS_MAX_DOMAINLEN+1];
dname_pkt_copy(pkt, buf, rrset->dname);
if(addr)
log_name_addr(VERB_QUERY, str, buf, addr, addrlen);
else log_nametypeclass(VERB_QUERY, str, buf,
rrset->type, ntohs(rrset->rrset_class));
}
if(prev)
prev->next = rr->next;
else rrset->rr_first = rr->next;
if(rrset->rr_last == rr)
rrset->rr_last = prev;
rrset->rr_count --;
rrset->size -= rr->size;
/* rr struct still exists, but is unlinked, so that in the for loop
* the rr->next works fine to continue. */
return rrset->rr_count == 0;
}

View File

@ -371,4 +371,22 @@ void msgparse_bucket_remove(struct msg_parse* msg, struct rrset_parse* rrset);
void log_edns_opt_list(enum verbosity_value level, const char* info_str, void log_edns_opt_list(enum verbosity_value level, const char* info_str,
struct edns_option* list); struct edns_option* list);
/**
* Remove RR from msgparse RRset.
* @param str: this string is used for logging if verbose. If NULL, there is
* no logging of the remove.
* @param pkt: packet in buffer that is removed from. Used to log the name
* of the item removed.
* @param rrset: RRset that the RR is removed from.
* @param prev: previous RR in list, or NULL.
* @param rr: RR that is removed.
* @param addr: address used for logging, if verbose, or NULL then it is not
* used.
* @param addrlen: length of addr, if that is not NULL.
* @return true if rrset is entirely bad, it would then need to be removed.
*/
int msgparse_rrset_remove_rr(const char* str, struct sldns_buffer* pkt,
struct rrset_parse* rrset, struct rr_parse* prev, struct rr_parse* rr,
struct sockaddr_storage* addr, socklen_t addrlen);
#endif /* UTIL_DATA_MSGPARSE_H */ #endif /* UTIL_DATA_MSGPARSE_H */

View File

@ -918,13 +918,15 @@ log_dns_msg(const char* str, struct query_info* qinfo, struct reply_info* rep)
void void
log_reply_info(enum verbosity_value v, struct query_info *qinf, log_reply_info(enum verbosity_value v, struct query_info *qinf,
struct sockaddr_storage *addr, socklen_t addrlen, struct timeval dur, struct sockaddr_storage *addr, socklen_t addrlen, struct timeval dur,
int cached, struct sldns_buffer *rmsg) int cached, struct sldns_buffer *rmsg, struct sockaddr_storage* daddr,
enum comm_point_type tp)
{ {
char qname_buf[LDNS_MAX_DOMAINLEN+1]; char qname_buf[LDNS_MAX_DOMAINLEN+1];
char clientip_buf[128]; char clientip_buf[128];
char rcode_buf[16]; char rcode_buf[16];
char type_buf[16]; char type_buf[16];
char class_buf[16]; char class_buf[16];
char dest_buf[160];
size_t pktlen; size_t pktlen;
uint16_t rcode = FLAGS_GET_RCODE(sldns_buffer_read_u16_at(rmsg, 2)); uint16_t rcode = FLAGS_GET_RCODE(sldns_buffer_read_u16_at(rmsg, 2));
@ -933,11 +935,46 @@ log_reply_info(enum verbosity_value v, struct query_info *qinf,
sldns_wire2str_rcode_buf((int)rcode, rcode_buf, sizeof(rcode_buf)); sldns_wire2str_rcode_buf((int)rcode, rcode_buf, sizeof(rcode_buf));
addr_to_str(addr, addrlen, clientip_buf, sizeof(clientip_buf)); addr_to_str(addr, addrlen, clientip_buf, sizeof(clientip_buf));
if(daddr) {
char da[128];
int port = 0;
char* comm;
if(daddr->ss_family == AF_INET6) {
struct sockaddr_in6 *d = (struct sockaddr_in6 *)daddr;
if(inet_ntop(d->sin6_family, &d->sin6_addr, da,
sizeof(*d)) == 0)
snprintf(dest_buf, sizeof(dest_buf),
"(inet_ntop_error)");
port = ntohs(d->sin6_port);
} else if(daddr->ss_family == AF_INET) {
struct sockaddr_in *d = (struct sockaddr_in *)daddr;
if(inet_ntop(d->sin_family, &d->sin_addr, da,
sizeof(*d)) == 0)
snprintf(dest_buf, sizeof(dest_buf),
"(inet_ntop_error)");
port = ntohs(d->sin_port);
} else {
snprintf(da, sizeof(da), "socket%d",
(int)daddr->ss_family);
}
comm = "udp";
if(tp == comm_tcp) comm = "tcp";
else if(tp == comm_tcp_accept) comm = "tcp";
else if(tp == comm_http) comm = "dot";
else if(tp == comm_local) comm = "unix";
else if(tp == comm_raw) comm = "raw";
snprintf(dest_buf, sizeof(dest_buf), " on %s %s %d",
comm, da, port);
} else {
dest_buf[0]=0;
}
if(rcode == LDNS_RCODE_FORMERR) if(rcode == LDNS_RCODE_FORMERR)
{ {
if(LOG_TAG_QUERYREPLY) if(LOG_TAG_QUERYREPLY)
log_reply("%s - - - %s - - - ", clientip_buf, rcode_buf); log_reply("%s - - - %s - - -%s", clientip_buf,
else log_info("%s - - - %s - - - ", clientip_buf, rcode_buf); rcode_buf, dest_buf);
else log_info("%s - - - %s - - -%s", clientip_buf,
rcode_buf, dest_buf);
} else { } else {
if(qinf->qname) if(qinf->qname)
dname_str(qinf->qname, qname_buf); dname_str(qinf->qname, qname_buf);
@ -946,12 +983,14 @@ log_reply_info(enum verbosity_value v, struct query_info *qinf,
sldns_wire2str_type_buf(qinf->qtype, type_buf, sizeof(type_buf)); sldns_wire2str_type_buf(qinf->qtype, type_buf, sizeof(type_buf));
sldns_wire2str_class_buf(qinf->qclass, class_buf, sizeof(class_buf)); sldns_wire2str_class_buf(qinf->qclass, class_buf, sizeof(class_buf));
if(LOG_TAG_QUERYREPLY) if(LOG_TAG_QUERYREPLY)
log_reply("%s %s %s %s %s " ARG_LL "d.%6.6d %d %d", log_reply("%s %s %s %s %s " ARG_LL "d.%6.6d %d %d%s",
clientip_buf, qname_buf, type_buf, class_buf, clientip_buf, qname_buf, type_buf, class_buf,
rcode_buf, (long long)dur.tv_sec, (int)dur.tv_usec, cached, (int)pktlen); rcode_buf, (long long)dur.tv_sec, (int)dur.tv_usec,
else log_info("%s %s %s %s %s " ARG_LL "d.%6.6d %d %d", cached, (int)pktlen, dest_buf);
else log_info("%s %s %s %s %s " ARG_LL "d.%6.6d %d %d%s",
clientip_buf, qname_buf, type_buf, class_buf, clientip_buf, qname_buf, type_buf, class_buf,
rcode_buf, (long long)dur.tv_sec, (int)dur.tv_usec, cached, (int)pktlen); rcode_buf, (long long)dur.tv_sec, (int)dur.tv_usec,
cached, (int)pktlen, dest_buf);
} }
} }

View File

@ -58,6 +58,7 @@ struct msg_parse;
struct rrset_parse; struct rrset_parse;
struct local_rrset; struct local_rrset;
struct dns_msg; struct dns_msg;
enum comm_point_type;
/** calculate the prefetch TTL as 90% of original. Calculation /** calculate the prefetch TTL as 90% of original. Calculation
* without numerical overflow (uin32_t) */ * without numerical overflow (uin32_t) */
@ -520,10 +521,13 @@ void log_dns_msg(const char* str, struct query_info* qinfo,
* @param cached: whether or not the reply is coming from * @param cached: whether or not the reply is coming from
* the cache, or an outside network. * the cache, or an outside network.
* @param rmsg: sldns buffer packet. * @param rmsg: sldns buffer packet.
* @param daddr: if not NULL, the destination address and port are logged.
* @param tp: type of the comm point for logging destination connection type.
*/ */
void log_reply_info(enum verbosity_value v, struct query_info *qinf, void log_reply_info(enum verbosity_value v, struct query_info *qinf,
struct sockaddr_storage *addr, socklen_t addrlen, struct timeval dur, struct sockaddr_storage *addr, socklen_t addrlen, struct timeval dur,
int cached, struct sldns_buffer *rmsg); int cached, struct sldns_buffer *rmsg, struct sockaddr_storage* daddr,
enum comm_point_type tp);
/** /**
* Print string with neat domain name, type, class from query info. * Print string with neat domain name, type, class from query info.

View File

@ -275,6 +275,7 @@ int packed_rr_to_string(struct ub_packed_rrset_key* rrset, size_t i,
struct packed_rrset_data* d = (struct packed_rrset_data*)rrset-> struct packed_rrset_data* d = (struct packed_rrset_data*)rrset->
entry.data; entry.data;
uint8_t rr[65535]; uint8_t rr[65535];
size_t wlen;
size_t rlen = rrset->rk.dname_len + 2 + 2 + 4 + d->rr_len[i]; size_t rlen = rrset->rk.dname_len + 2 + 2 + 4 + d->rr_len[i];
time_t adjust = 0; time_t adjust = 0;
log_assert(dest_len > 0 && dest); log_assert(dest_len > 0 && dest);
@ -292,7 +293,9 @@ int packed_rr_to_string(struct ub_packed_rrset_key* rrset, size_t i,
sldns_write_uint32(rr+rrset->rk.dname_len+4, sldns_write_uint32(rr+rrset->rk.dname_len+4,
(uint32_t)(d->rr_ttl[i]-adjust)); (uint32_t)(d->rr_ttl[i]-adjust));
memmove(rr+rrset->rk.dname_len+8, d->rr_data[i], d->rr_len[i]); memmove(rr+rrset->rk.dname_len+8, d->rr_data[i], d->rr_len[i]);
if(sldns_wire2str_rr_buf(rr, rlen, dest, dest_len) == -1) { wlen = (size_t)sldns_wire2str_rr_buf(rr, rlen, dest, dest_len);
if(wlen >= dest_len) {
/* the output string was truncated */
log_info("rrbuf failure %d %s", (int)d->rr_len[i], dest); log_info("rrbuf failure %d %s", (int)d->rr_len[i], dest);
dest[0] = 0; dest[0] = 0;
return 0; return 0;

View File

@ -169,7 +169,9 @@ int
fptr_whitelist_event(void (*fptr)(int, short, void *)) fptr_whitelist_event(void (*fptr)(int, short, void *))
{ {
if(fptr == &comm_point_udp_callback) return 1; if(fptr == &comm_point_udp_callback) return 1;
#if defined(AF_INET6) && defined(IPV6_PKTINFO) && defined(HAVE_RECVMSG)
else if(fptr == &comm_point_udp_ancil_callback) return 1; else if(fptr == &comm_point_udp_ancil_callback) return 1;
#endif
else if(fptr == &comm_point_tcp_accept_callback) return 1; else if(fptr == &comm_point_tcp_accept_callback) return 1;
else if(fptr == &comm_point_tcp_handle_callback) return 1; else if(fptr == &comm_point_tcp_handle_callback) return 1;
else if(fptr == &comm_timer_callback) return 1; else if(fptr == &comm_timer_callback) return 1;

View File

@ -258,7 +258,6 @@
356, 356,
357, 357,
358, 358,
359,
360, 360,
361, 361,
362, 362,

View File

@ -187,7 +187,7 @@ void log_ident_set_default(const char* id)
default_ident = id; default_ident = id;
} }
void log_ident_revert_to_default() void log_ident_revert_to_default(void)
{ {
ident = default_ident; ident = default_ident;
} }

View File

@ -194,6 +194,24 @@ char* errinf_to_str_servfail(struct module_qstate* qstate)
return p; return p;
} }
char* errinf_to_str_misc(struct module_qstate* qstate)
{
char buf[20480];
char* p = buf;
size_t left = sizeof(buf);
struct errinf_strlist* s;
if(!qstate->errinf)
snprintf(p, left, "misc failure");
else for(s=qstate->errinf; s; s=s->next) {
snprintf(p, left, "%s%s", (s==qstate->errinf?"":" "), s->str);
left -= strlen(p); p += strlen(p);
}
p = strdup(buf);
if(!p)
log_err("malloc failure in errinf_to_str");
return p;
}
void errinf_rrset(struct module_qstate* qstate, struct ub_packed_rrset_key *rr) void errinf_rrset(struct module_qstate* qstate, struct ub_packed_rrset_key *rr)
{ {
char buf[1024]; char buf[1024];

View File

@ -691,6 +691,8 @@ struct module_qstate {
struct respip_action_info* respip_action_info; struct respip_action_info* respip_action_info;
/** if the query is rpz passthru, no further rpz processing for it */ /** if the query is rpz passthru, no further rpz processing for it */
int rpz_passthru; int rpz_passthru;
/* Flag tcp required. */
int tcp_required;
/** whether the reply should be dropped */ /** whether the reply should be dropped */
int is_drop; int is_drop;
@ -842,6 +844,14 @@ sldns_ede_code errinf_to_reason_bogus(struct module_qstate* qstate);
*/ */
char* errinf_to_str_servfail(struct module_qstate* qstate); char* errinf_to_str_servfail(struct module_qstate* qstate);
/**
* Create error info in string. For misc failures that are not servfail.
* @param qstate: query state.
* @return string or NULL on malloc failure (already logged).
* This string is malloced and has to be freed by caller.
*/
char* errinf_to_str_misc(struct module_qstate* qstate);
/** /**
* Initialize the edns known options by allocating the required space. * Initialize the edns known options by allocating the required space.
* @param env: the module environment. * @param env: the module environment.

View File

@ -952,6 +952,111 @@ void log_crypto_err_code(const char* str, unsigned long err)
#endif /* HAVE_SSL */ #endif /* HAVE_SSL */
} }
#ifdef HAVE_SSL
/** Print crypt erro with SSL_get_error want code and err_get_error code */
static void log_crypto_err_io_code_arg(const char* str, int r,
unsigned long err, int err_present)
{
int print_errno = 0, print_crypto_err = 0;
const char* inf = NULL;
switch(r) {
case SSL_ERROR_NONE:
inf = "no error";
break;
case SSL_ERROR_ZERO_RETURN:
inf = "channel closed";
break;
case SSL_ERROR_WANT_READ:
inf = "want read";
break;
case SSL_ERROR_WANT_WRITE:
inf = "want write";
break;
case SSL_ERROR_WANT_CONNECT:
inf = "want connect";
break;
case SSL_ERROR_WANT_ACCEPT:
inf = "want accept";
break;
case SSL_ERROR_WANT_X509_LOOKUP:
inf = "want X509 lookup";
break;
#ifdef SSL_ERROR_WANT_ASYNC
case SSL_ERROR_WANT_ASYNC:
inf = "want async";
break;
#endif
#ifdef SSL_ERROR_WANT_ASYNC_JOB
case SSL_ERROR_WANT_ASYNC_JOB:
inf = "want async job";
break;
#endif
#ifdef SSL_ERROR_WANT_CLIENT_HELLO_CB
case SSL_ERROR_WANT_CLIENT_HELLO_CB:
inf = "want client hello cb";
break;
#endif
case SSL_ERROR_SYSCALL:
print_errno = 1;
inf = "syscall";
break;
case SSL_ERROR_SSL:
print_crypto_err = 1;
inf = "SSL, usually protocol, error";
break;
default:
inf = "unknown SSL_get_error result code";
print_errno = 1;
print_crypto_err = 1;
}
if(print_crypto_err) {
if(print_errno) {
char buf[1024];
snprintf(buf, sizeof(buf), "%s with errno %s",
str, strerror(errno));
if(err_present)
log_crypto_err_code(buf, err);
else log_crypto_err(buf);
} else {
if(err_present)
log_crypto_err_code(str, err);
else log_crypto_err(str);
}
} else {
if(print_errno) {
if(errno == 0)
log_err("str: syscall error with errno %s",
strerror(errno));
else log_err("str: %s", strerror(errno));
} else {
log_err("str: %s", inf);
}
}
}
#endif /* HAVE_SSL */
void log_crypto_err_io(const char* str, int r)
{
#ifdef HAVE_SSL
log_crypto_err_io_code_arg(str, r, 0, 0);
#else
(void)str;
(void)r;
#endif /* HAVE_SSL */
}
void log_crypto_err_io_code(const char* str, int r, unsigned long err)
{
#ifdef HAVE_SSL
log_crypto_err_io_code_arg(str, r, err, 1);
#else
(void)str;
(void)r;
(void)err;
#endif /* HAVE_SSL */
}
#ifdef HAVE_SSL #ifdef HAVE_SSL
/** log certificate details */ /** log certificate details */
void void

View File

@ -429,6 +429,24 @@ void log_crypto_err(const char* str);
*/ */
void log_crypto_err_code(const char* str, unsigned long err); void log_crypto_err_code(const char* str, unsigned long err);
/**
* Log an error from libcrypto that came from SSL_write and so on, with
* a value from SSL_get_error, calls log_err. If that fails it logs with
* log_crypto_err.
* @param str: what failed
* @param r: output of SSL_get_error on the I/O operation result.
*/
void log_crypto_err_io(const char* str, int r);
/**
* Log an error from libcrypt that came from an I/O routine with the
* errcode from ERR_get_error. Calls log_err() and log_crypto_err_code.
* @param str: what failed
* @param r: output of SSL_get_error on the I/O operation result.
* @param err: error code from ERR_get_error
*/
void log_crypto_err_io_code(const char* str, int r, unsigned long err);
/** /**
* Log certificate details verbosity, string, of X509 cert * Log certificate details verbosity, string, of X509 cert
* @param level: verbosity level * @param level: verbosity level

View File

@ -892,15 +892,18 @@ static int udp_recv_needs_log(int err)
static int consume_pp2_header(struct sldns_buffer* buf, struct comm_reply* rep, static int consume_pp2_header(struct sldns_buffer* buf, struct comm_reply* rep,
int stream) { int stream) {
size_t size; size_t size;
struct pp2_header *header = pp2_read_header(buf); struct pp2_header *header;
if(header == NULL) return 0; int err = pp2_read_header(sldns_buffer_begin(buf),
sldns_buffer_remaining(buf));
if(err) return 0;
header = (struct pp2_header*)sldns_buffer_begin(buf);
size = PP2_HEADER_SIZE + ntohs(header->len); size = PP2_HEADER_SIZE + ntohs(header->len);
if((header->ver_cmd & 0xF) == PP2_CMD_LOCAL) { if((header->ver_cmd & 0xF) == PP2_CMD_LOCAL) {
/* A connection from the proxy itself. /* A connection from the proxy itself.
* No need to do anything with addresses. */ * No need to do anything with addresses. */
goto done; goto done;
} }
if(header->fam_prot == 0x00) { if(header->fam_prot == PP2_UNSPEC_UNSPEC) {
/* Unspecified family and protocol. This could be used for /* Unspecified family and protocol. This could be used for
* health checks by proxies. * health checks by proxies.
* No need to do anything with addresses. */ * No need to do anything with addresses. */
@ -908,8 +911,8 @@ static int consume_pp2_header(struct sldns_buffer* buf, struct comm_reply* rep,
} }
/* Read the proxied address */ /* Read the proxied address */
switch(header->fam_prot) { switch(header->fam_prot) {
case 0x11: /* AF_INET|STREAM */ case PP2_INET_STREAM:
case 0x12: /* AF_INET|DGRAM */ case PP2_INET_DGRAM:
{ {
struct sockaddr_in* addr = struct sockaddr_in* addr =
(struct sockaddr_in*)&rep->client_addr; (struct sockaddr_in*)&rep->client_addr;
@ -920,8 +923,8 @@ static int consume_pp2_header(struct sldns_buffer* buf, struct comm_reply* rep,
} }
/* Ignore the destination address; it should be us. */ /* Ignore the destination address; it should be us. */
break; break;
case 0x21: /* AF_INET6|STREAM */ case PP2_INET6_STREAM:
case 0x22: /* AF_INET6|DGRAM */ case PP2_INET6_DGRAM:
{ {
struct sockaddr_in6* addr = struct sockaddr_in6* addr =
(struct sockaddr_in6*)&rep->client_addr; (struct sockaddr_in6*)&rep->client_addr;
@ -934,6 +937,10 @@ static int consume_pp2_header(struct sldns_buffer* buf, struct comm_reply* rep,
} }
/* Ignore the destination address; it should be us. */ /* Ignore the destination address; it should be us. */
break; break;
default:
log_err("proxy_protocol: unsupported family and "
"protocol 0x%x", (int)header->fam_prot);
return 0;
} }
rep->is_proxied = 1; rep->is_proxied = 1;
done: done:
@ -948,10 +955,10 @@ done:
return 1; return 1;
} }
#if defined(AF_INET6) && defined(IPV6_PKTINFO) && defined(HAVE_RECVMSG)
void void
comm_point_udp_ancil_callback(int fd, short event, void* arg) comm_point_udp_ancil_callback(int fd, short event, void* arg)
{ {
#if defined(AF_INET6) && defined(IPV6_PKTINFO) && defined(HAVE_RECVMSG)
struct comm_reply rep; struct comm_reply rep;
struct msghdr msg; struct msghdr msg;
struct iovec iov[1]; struct iovec iov[1];
@ -1063,21 +1070,21 @@ comm_point_udp_ancil_callback(int fd, short event, void* arg)
fptr_ok(fptr_whitelist_comm_point(rep.c->callback)); fptr_ok(fptr_whitelist_comm_point(rep.c->callback));
if((*rep.c->callback)(rep.c, rep.c->cb_arg, NETEVENT_NOERROR, &rep)) { if((*rep.c->callback)(rep.c, rep.c->cb_arg, NETEVENT_NOERROR, &rep)) {
/* send back immediate reply */ /* send back immediate reply */
(void)comm_point_send_udp_msg_if(rep.c, rep.c->buffer, struct sldns_buffer *buffer;
#ifdef USE_DNSCRYPT
buffer = rep.c->dnscrypt_buffer;
#else
buffer = rep.c->buffer;
#endif
(void)comm_point_send_udp_msg_if(rep.c, buffer,
(struct sockaddr*)&rep.remote_addr, (struct sockaddr*)&rep.remote_addr,
rep.remote_addrlen, &rep); rep.remote_addrlen, &rep);
} }
if(!rep.c || rep.c->fd == -1) /* commpoint closed */ if(!rep.c || rep.c->fd == -1) /* commpoint closed */
break; break;
} }
#else
(void)fd;
(void)event;
(void)arg;
fatal_exit("recvmsg: No support for IPV6_PKTINFO; IP_PKTINFO or IP_RECVDSTADDR. "
"Please disable interface-automatic");
#endif /* AF_INET6 && IPV6_PKTINFO && HAVE_RECVMSG */
} }
#endif /* AF_INET6 && IPV6_PKTINFO && HAVE_RECVMSG */
void void
comm_point_udp_callback(int fd, short event, void* arg) comm_point_udp_callback(int fd, short event, void* arg)
@ -1665,7 +1672,13 @@ ssl_handshake(struct comm_point* c)
} else { } else {
unsigned long err = ERR_get_error(); unsigned long err = ERR_get_error();
if(!squelch_err_ssl_handshake(err)) { if(!squelch_err_ssl_handshake(err)) {
log_crypto_err_code("ssl handshake failed", err); long vr;
log_crypto_err_io_code("ssl handshake failed",
want, err);
if((vr=SSL_get_verify_result(c->ssl)) != 0)
log_err("ssl handshake cert error: %s",
X509_verify_cert_error_string(
vr));
log_addr(VERB_OPS, "ssl handshake failed", log_addr(VERB_OPS, "ssl handshake failed",
&c->repinfo.remote_addr, &c->repinfo.remote_addr,
c->repinfo.remote_addrlen); c->repinfo.remote_addrlen);
@ -1740,6 +1753,9 @@ ssl_handshake(struct comm_point* c)
/* connection upgraded to HTTP2 */ /* connection upgraded to HTTP2 */
c->tcp_do_toggle_rw = 0; c->tcp_do_toggle_rw = 0;
c->use_h2 = 1; c->use_h2 = 1;
} else {
verbose(VERB_ALGO, "client doesn't support HTTP/2");
return 0;
} }
} }
#endif #endif
@ -1815,23 +1831,30 @@ ssl_handle_read(struct comm_point* c)
strerror(errno)); strerror(errno));
return 0; return 0;
} }
log_crypto_err("could not SSL_read"); log_crypto_err_io("could not SSL_read",
want);
return 0; return 0;
} }
c->tcp_byte_count += r; c->tcp_byte_count += r;
sldns_buffer_skip(c->buffer, r);
if(c->tcp_byte_count != current_read_size) return 1; if(c->tcp_byte_count != current_read_size) return 1;
c->pp2_header_state = pp2_header_init; c->pp2_header_state = pp2_header_init;
} }
} }
if(c->pp2_header_state == pp2_header_init) { if(c->pp2_header_state == pp2_header_init) {
header = pp2_read_header(c->buffer); int err;
if(!header) { err = pp2_read_header(
sldns_buffer_begin(c->buffer),
sldns_buffer_limit(c->buffer));
if(err) {
log_err("proxy_protocol: could not parse " log_err("proxy_protocol: could not parse "
"PROXYv2 header"); "PROXYv2 header (%s)",
pp_lookup_error(err));
return 0; return 0;
} }
header = (struct pp2_header*)sldns_buffer_begin(c->buffer);
want_read_size = ntohs(header->len); want_read_size = ntohs(header->len);
if(sldns_buffer_remaining(c->buffer) < if(sldns_buffer_limit(c->buffer) <
PP2_HEADER_SIZE + want_read_size) { PP2_HEADER_SIZE + want_read_size) {
log_err_addr("proxy_protocol: not enough " log_err_addr("proxy_protocol: not enough "
"buffer size to read PROXYv2 header", "", "buffer size to read PROXYv2 header", "",
@ -1876,10 +1899,12 @@ ssl_handle_read(struct comm_point* c)
strerror(errno)); strerror(errno));
return 0; return 0;
} }
log_crypto_err("could not SSL_read"); log_crypto_err_io("could not SSL_read",
want);
return 0; return 0;
} }
c->tcp_byte_count += r; c->tcp_byte_count += r;
sldns_buffer_skip(c->buffer, r);
if(c->tcp_byte_count != current_read_size) return 1; if(c->tcp_byte_count != current_read_size) return 1;
c->pp2_header_state = pp2_header_done; c->pp2_header_state = pp2_header_done;
} }
@ -1890,6 +1915,7 @@ ssl_handle_read(struct comm_point* c)
c->repinfo.remote_addrlen); c->repinfo.remote_addrlen);
return 0; return 0;
} }
sldns_buffer_flip(c->buffer);
if(!consume_pp2_header(c->buffer, &c->repinfo, 1)) { if(!consume_pp2_header(c->buffer, &c->repinfo, 1)) {
log_err_addr("proxy_protocol: could not consume " log_err_addr("proxy_protocol: could not consume "
"PROXYv2 header", "", &c->repinfo.remote_addr, "PROXYv2 header", "", &c->repinfo.remote_addr,
@ -1934,7 +1960,7 @@ ssl_handle_read(struct comm_point* c)
strerror(errno)); strerror(errno));
return 0; return 0;
} }
log_crypto_err("could not SSL_read"); log_crypto_err_io("could not SSL_read", want);
return 0; return 0;
} }
c->tcp_byte_count += r; c->tcp_byte_count += r;
@ -1984,7 +2010,7 @@ ssl_handle_read(struct comm_point* c)
strerror(errno)); strerror(errno));
return 0; return 0;
} }
log_crypto_err("could not SSL_read"); log_crypto_err_io("could not SSL_read", want);
return 0; return 0;
} }
sldns_buffer_skip(c->buffer, (ssize_t)r); sldns_buffer_skip(c->buffer, (ssize_t)r);
@ -2075,7 +2101,7 @@ ssl_handle_write(struct comm_point* c)
strerror(errno)); strerror(errno));
return 0; return 0;
} }
log_crypto_err("could not SSL_write"); log_crypto_err_io("could not SSL_write", want);
return 0; return 0;
} }
if(c->tcp_write_and_read) { if(c->tcp_write_and_read) {
@ -2127,7 +2153,7 @@ ssl_handle_write(struct comm_point* c)
strerror(errno)); strerror(errno));
return 0; return 0;
} }
log_crypto_err("could not SSL_write"); log_crypto_err_io("could not SSL_write", want);
return 0; return 0;
} }
if(c->tcp_write_and_read) { if(c->tcp_write_and_read) {
@ -2211,19 +2237,25 @@ comm_point_tcp_handle_read(int fd, struct comm_point* c, int short_ok)
goto recv_error_initial; goto recv_error_initial;
} }
c->tcp_byte_count += r; c->tcp_byte_count += r;
sldns_buffer_skip(c->buffer, r);
if(c->tcp_byte_count != current_read_size) return 1; if(c->tcp_byte_count != current_read_size) return 1;
c->pp2_header_state = pp2_header_init; c->pp2_header_state = pp2_header_init;
} }
} }
if(c->pp2_header_state == pp2_header_init) { if(c->pp2_header_state == pp2_header_init) {
header = pp2_read_header(c->buffer); int err;
if(!header) { err = pp2_read_header(
sldns_buffer_begin(c->buffer),
sldns_buffer_limit(c->buffer));
if(err) {
log_err("proxy_protocol: could not parse " log_err("proxy_protocol: could not parse "
"PROXYv2 header"); "PROXYv2 header (%s)",
pp_lookup_error(err));
return 0; return 0;
} }
header = (struct pp2_header*)sldns_buffer_begin(c->buffer);
want_read_size = ntohs(header->len); want_read_size = ntohs(header->len);
if(sldns_buffer_remaining(c->buffer) < if(sldns_buffer_limit(c->buffer) <
PP2_HEADER_SIZE + want_read_size) { PP2_HEADER_SIZE + want_read_size) {
log_err_addr("proxy_protocol: not enough " log_err_addr("proxy_protocol: not enough "
"buffer size to read PROXYv2 header", "", "buffer size to read PROXYv2 header", "",
@ -2250,6 +2282,7 @@ comm_point_tcp_handle_read(int fd, struct comm_point* c, int short_ok)
goto recv_error; goto recv_error;
} }
c->tcp_byte_count += r; c->tcp_byte_count += r;
sldns_buffer_skip(c->buffer, r);
if(c->tcp_byte_count != current_read_size) return 1; if(c->tcp_byte_count != current_read_size) return 1;
c->pp2_header_state = pp2_header_done; c->pp2_header_state = pp2_header_done;
} }
@ -2260,6 +2293,7 @@ comm_point_tcp_handle_read(int fd, struct comm_point* c, int short_ok)
c->repinfo.remote_addrlen); c->repinfo.remote_addrlen);
return 0; return 0;
} }
sldns_buffer_flip(c->buffer);
if(!consume_pp2_header(c->buffer, &c->repinfo, 1)) { if(!consume_pp2_header(c->buffer, &c->repinfo, 1)) {
log_err_addr("proxy_protocol: could not consume " log_err_addr("proxy_protocol: could not consume "
"PROXYv2 header", "", &c->repinfo.remote_addr, "PROXYv2 header", "", &c->repinfo.remote_addr,
@ -2913,7 +2947,7 @@ ssl_http_read_more(struct comm_point* c)
strerror(errno)); strerror(errno));
return 0; return 0;
} }
log_crypto_err("could not SSL_read"); log_crypto_err_io("could not SSL_read", want);
return 0; return 0;
} }
verbose(VERB_ALGO, "ssl http read more skip to %d + %d", verbose(VERB_ALGO, "ssl http read more skip to %d + %d",
@ -3364,7 +3398,7 @@ ssize_t http2_recv_cb(nghttp2_session* ATTR_UNUSED(session), uint8_t* buf,
strerror(errno)); strerror(errno));
return NGHTTP2_ERR_CALLBACK_FAILURE; return NGHTTP2_ERR_CALLBACK_FAILURE;
} }
log_crypto_err("could not SSL_read"); log_crypto_err_io("could not SSL_read", want);
return NGHTTP2_ERR_CALLBACK_FAILURE; return NGHTTP2_ERR_CALLBACK_FAILURE;
} }
return r; return r;
@ -3619,7 +3653,7 @@ ssl_http_write_more(struct comm_point* c)
strerror(errno)); strerror(errno));
return 0; return 0;
} }
log_crypto_err("could not SSL_write"); log_crypto_err_io("could not SSL_write", want);
return 0; return 0;
} }
sldns_buffer_skip(c->buffer, (ssize_t)r); sldns_buffer_skip(c->buffer, (ssize_t)r);
@ -3692,7 +3726,7 @@ ssize_t http2_send_cb(nghttp2_session* ATTR_UNUSED(session), const uint8_t* buf,
strerror(errno)); strerror(errno));
return NGHTTP2_ERR_CALLBACK_FAILURE; return NGHTTP2_ERR_CALLBACK_FAILURE;
} }
log_crypto_err("could not SSL_write"); log_crypto_err_io("could not SSL_write", want);
return NGHTTP2_ERR_CALLBACK_FAILURE; return NGHTTP2_ERR_CALLBACK_FAILURE;
} }
return r; return r;
@ -3958,11 +3992,7 @@ comm_point_create_udp(struct comm_base *base, int fd, sldns_buffer* buffer,
evbits = UB_EV_READ | UB_EV_PERSIST; evbits = UB_EV_READ | UB_EV_PERSIST;
/* ub_event stuff */ /* ub_event stuff */
c->ev->ev = ub_event_new(base->eb->base, c->fd, evbits, c->ev->ev = ub_event_new(base->eb->base, c->fd, evbits,
#ifdef USE_WINSOCK
comm_point_udp_callback, c); comm_point_udp_callback, c);
#else
comm_point_udp_ancil_callback, c);
#endif
if(c->ev->ev == NULL) { if(c->ev->ev == NULL) {
log_err("could not baseset udp event"); log_err("could not baseset udp event");
comm_point_delete(c); comm_point_delete(c);
@ -3977,6 +4007,7 @@ comm_point_create_udp(struct comm_base *base, int fd, sldns_buffer* buffer,
return c; return c;
} }
#if defined(AF_INET6) && defined(IPV6_PKTINFO) && defined(HAVE_RECVMSG)
struct comm_point* struct comm_point*
comm_point_create_udp_ancil(struct comm_base *base, int fd, comm_point_create_udp_ancil(struct comm_base *base, int fd,
sldns_buffer* buffer, int pp2_enabled, sldns_buffer* buffer, int pp2_enabled,
@ -4039,6 +4070,7 @@ comm_point_create_udp_ancil(struct comm_base *base, int fd,
c->event_added = 1; c->event_added = 1;
return c; return c;
} }
#endif
static struct comm_point* static struct comm_point*
comm_point_create_tcp_handler(struct comm_base *base, comm_point_create_tcp_handler(struct comm_base *base,
@ -4742,7 +4774,7 @@ comm_point_send_reply(struct comm_reply *repinfo)
if(repinfo->c->dtenv != NULL && repinfo->c->dtenv->log_client_response_messages) { if(repinfo->c->dtenv != NULL && repinfo->c->dtenv->log_client_response_messages) {
log_addr(VERB_ALGO, "from local addr", (void*)repinfo->c->socket->addr->ai_addr, repinfo->c->socket->addr->ai_addrlen); log_addr(VERB_ALGO, "from local addr", (void*)repinfo->c->socket->addr->ai_addr, repinfo->c->socket->addr->ai_addrlen);
log_addr(VERB_ALGO, "response to client", &repinfo->client_addr, repinfo->client_addrlen); log_addr(VERB_ALGO, "response to client", &repinfo->client_addr, repinfo->client_addrlen);
dt_msg_send_client_response(repinfo->c->dtenv, &repinfo->client_addr, (void*)repinfo->c->socket->addr->ai_addr, repinfo->c->type, repinfo->c->buffer); dt_msg_send_client_response(repinfo->c->dtenv, &repinfo->client_addr, (void*)repinfo->c->socket->addr->ai_addr, repinfo->c->type, repinfo->c->ssl, repinfo->c->buffer);
} }
#endif #endif
} else { } else {
@ -4753,7 +4785,7 @@ comm_point_send_reply(struct comm_reply *repinfo)
if(repinfo->c->tcp_parent->dtenv != NULL && repinfo->c->tcp_parent->dtenv->log_client_response_messages) { if(repinfo->c->tcp_parent->dtenv != NULL && repinfo->c->tcp_parent->dtenv->log_client_response_messages) {
log_addr(VERB_ALGO, "from local addr", (void*)repinfo->c->socket->addr->ai_addr, repinfo->c->socket->addr->ai_addrlen); log_addr(VERB_ALGO, "from local addr", (void*)repinfo->c->socket->addr->ai_addr, repinfo->c->socket->addr->ai_addrlen);
log_addr(VERB_ALGO, "response to client", &repinfo->client_addr, repinfo->client_addrlen); log_addr(VERB_ALGO, "response to client", &repinfo->client_addr, repinfo->client_addrlen);
dt_msg_send_client_response(repinfo->c->tcp_parent->dtenv, &repinfo->client_addr, (void*)repinfo->c->socket->addr->ai_addr, repinfo->c->type, dt_msg_send_client_response(repinfo->c->tcp_parent->dtenv, &repinfo->client_addr, (void*)repinfo->c->socket->addr->ai_addr, repinfo->c->type, repinfo->c->ssl,
( repinfo->c->tcp_req_info? repinfo->c->tcp_req_info->spool_buffer: repinfo->c->buffer )); ( repinfo->c->tcp_req_info? repinfo->c->tcp_req_info->spool_buffer: repinfo->c->buffer ));
} }
#endif #endif

View File

@ -38,102 +38,162 @@
* *
* This file contains PROXY protocol functions. * This file contains PROXY protocol functions.
*/ */
#include "config.h"
#include "util/log.h"
#include "util/proxy_protocol.h" #include "util/proxy_protocol.h"
int /**
pp2_write_to_buf(struct sldns_buffer* buf, struct sockaddr_storage* src, * Internal struct initialized with function pointers for writing uint16 and
* uint32.
*/
struct proxy_protocol_data {
void (*write_uint16)(void* buf, uint16_t data);
void (*write_uint32)(void* buf, uint32_t data);
};
struct proxy_protocol_data pp_data;
/**
* Internal lookup table; could be further generic like sldns_lookup_table
* for all the future generic stuff.
*/
struct proxy_protocol_lookup_table {
int id;
const char *text;
};
/**
* Internal parsing error text; could be exposed with pp_lookup_error.
*/
static struct proxy_protocol_lookup_table pp_parse_errors_data[] = {
{ PP_PARSE_NOERROR, "no parse error" },
{ PP_PARSE_SIZE, "not enough space for header" },
{ PP_PARSE_WRONG_HEADERv2, "could not match PROXYv2 header" },
{ PP_PARSE_UNKNOWN_CMD, "unknown command" },
{ PP_PARSE_UNKNOWN_FAM_PROT, "unknown family and protocol" },
};
void
pp_init(void (*write_uint16)(void* buf, uint16_t data),
void (*write_uint32)(void* buf, uint32_t data)) {
pp_data.write_uint16 = write_uint16;
pp_data.write_uint32 = write_uint32;
}
const char*
pp_lookup_error(enum pp_parse_errors error) {
return pp_parse_errors_data[error].text;
}
size_t
pp2_write_to_buf(uint8_t* buf, size_t buflen,
#ifdef INET6
struct sockaddr_storage* src,
#else
struct sockaddr_in* src,
#endif
int stream) int stream)
{ {
int af; int af;
size_t expected_size;
if(!src) return 0; if(!src) return 0;
af = (int)((struct sockaddr_in*)src)->sin_family; af = (int)((struct sockaddr_in*)src)->sin_family;
if(sldns_buffer_remaining(buf) < expected_size = PP2_HEADER_SIZE + (af==AF_INET?12:36);
PP2_HEADER_SIZE + (af==AF_INET?12:36)) { if(buflen < expected_size) {
return 0; return 0;
} }
/* sig */ /* sig */
sldns_buffer_write(buf, PP2_SIG, PP2_SIG_LEN); memcpy(buf, PP2_SIG, PP2_SIG_LEN);
buf += PP2_SIG_LEN;
/* version and command */ /* version and command */
sldns_buffer_write_u8(buf, (PP2_VERSION << 4) | PP2_CMD_PROXY); *buf = (PP2_VERSION << 4) | PP2_CMD_PROXY;
if(af==AF_INET) { buf++;
switch(af) {
case AF_INET:
/* family and protocol */ /* family and protocol */
sldns_buffer_write_u8(buf, *buf = (PP2_AF_INET<<4) |
(PP2_AF_INET<<4) | (stream?PP2_PROT_STREAM:PP2_PROT_DGRAM);
(stream?PP2_PROT_STREAM:PP2_PROT_DGRAM)); buf++;
/* length */ /* length */
sldns_buffer_write_u16(buf, 12); (*pp_data.write_uint16)(buf, 12);
buf += 2;
/* src addr */ /* src addr */
sldns_buffer_write(buf, memcpy(buf,
&((struct sockaddr_in*)src)->sin_addr.s_addr, 4); &((struct sockaddr_in*)src)->sin_addr.s_addr, 4);
buf += 4;
/* dst addr */ /* dst addr */
sldns_buffer_write_u32(buf, 0); (*pp_data.write_uint32)(buf, 0);
buf += 4;
/* src port */ /* src port */
sldns_buffer_write(buf, memcpy(buf,
&((struct sockaddr_in*)src)->sin_port, 2); &((struct sockaddr_in*)src)->sin_port, 2);
/* dst port */ buf += 2;
sldns_buffer_write_u16(buf, 0);
} else {
/* family and protocol */
sldns_buffer_write_u8(buf,
(PP2_AF_INET6<<4) |
(stream?PP2_PROT_STREAM:PP2_PROT_DGRAM));
/* length */
sldns_buffer_write_u16(buf, 36);
/* src addr */
sldns_buffer_write(buf,
&((struct sockaddr_in6*)src)->sin6_addr, 16);
/* dst addr */ /* dst addr */
sldns_buffer_set_at(buf,
sldns_buffer_position(buf), 0, 16);
sldns_buffer_skip(buf, 16);
/* src port */
sldns_buffer_write(buf,
&((struct sockaddr_in6*)src)->sin6_port, 2);
/* dst port */ /* dst port */
sldns_buffer_write_u16(buf, 0); (*pp_data.write_uint16)(buf, 12);
break;
#ifdef INET6
case AF_INET6:
/* family and protocol */
*buf = (PP2_AF_INET6<<4) |
(stream?PP2_PROT_STREAM:PP2_PROT_DGRAM);
buf++;
/* length */
(*pp_data.write_uint16)(buf, 36);
buf += 2;
/* src addr */
memcpy(buf,
&((struct sockaddr_in6*)src)->sin6_addr, 16);
buf += 16;
/* dst addr */
memset(buf, 0, 16);
buf += 16;
/* src port */
memcpy(buf, &((struct sockaddr_in6*)src)->sin6_port, 2);
buf += 2;
/* dst port */
(*pp_data.write_uint16)(buf, 0);
break;
#endif /* INET6 */
case AF_UNIX:
/* fallthrough */
default:
return 0;
} }
return 1; return expected_size;
} }
struct pp2_header* int
pp2_read_header(struct sldns_buffer* buf) pp2_read_header(uint8_t* buf, size_t buflen)
{ {
size_t size; size_t size;
struct pp2_header* header = (struct pp2_header*)sldns_buffer_begin(buf); struct pp2_header* header = (struct pp2_header*)buf;
/* Try to fail all the unsupported cases first. */ /* Try to fail all the unsupported cases first. */
if(sldns_buffer_remaining(buf) < PP2_HEADER_SIZE) { if(buflen < PP2_HEADER_SIZE) {
log_err("proxy_protocol: not enough space for header"); return PP_PARSE_SIZE;
return NULL;
} }
/* Check for PROXYv2 header */ /* Check for PROXYv2 header */
if(memcmp(header, PP2_SIG, PP2_SIG_LEN) != 0 || if(memcmp(header, PP2_SIG, PP2_SIG_LEN) != 0 ||
((header->ver_cmd & 0xF0)>>4) != PP2_VERSION) { ((header->ver_cmd & 0xF0)>>4) != PP2_VERSION) {
log_err("proxy_protocol: could not match PROXYv2 header"); return PP_PARSE_WRONG_HEADERv2;
return NULL;
} }
/* Check the length */ /* Check the length */
size = PP2_HEADER_SIZE + ntohs(header->len); size = PP2_HEADER_SIZE + ntohs(header->len);
if(sldns_buffer_remaining(buf) < size) { if(buflen < size) {
log_err("proxy_protocol: not enough space for header"); return PP_PARSE_SIZE;
return NULL;
} }
/* Check for supported commands */ /* Check for supported commands */
if((header->ver_cmd & 0xF) != PP2_CMD_LOCAL && if((header->ver_cmd & 0xF) != PP2_CMD_LOCAL &&
(header->ver_cmd & 0xF) != PP2_CMD_PROXY) { (header->ver_cmd & 0xF) != PP2_CMD_PROXY) {
log_err("proxy_protocol: unsupported command"); return PP_PARSE_UNKNOWN_CMD;
return NULL;
} }
/* Check for supported family and protocol */ /* Check for supported family and protocol */
if(header->fam_prot != 0x00 /* AF_UNSPEC|UNSPEC */ && if(header->fam_prot != PP2_UNSPEC_UNSPEC &&
header->fam_prot != 0x11 /* AF_INET|STREAM */ && header->fam_prot != PP2_INET_STREAM &&
header->fam_prot != 0x12 /* AF_INET|DGRAM */ && header->fam_prot != PP2_INET_DGRAM &&
header->fam_prot != 0x21 /* AF_INET6|STREAM */ && header->fam_prot != PP2_INET6_STREAM &&
header->fam_prot != 0x22 /* AF_INET6|DGRAM */) { header->fam_prot != PP2_INET6_DGRAM &&
log_err("proxy_protocol: unsupported family and protocol"); header->fam_prot != PP2_UNIX_STREAM &&
return NULL; header->fam_prot != PP2_UNIX_DGRAM) {
return PP_PARSE_UNKNOWN_FAM_PROT;
} }
/* We have a correct header */ /* We have a correct header */
return header; return PP_PARSE_NOERROR;
} }

View File

@ -42,7 +42,7 @@
#ifndef PROXY_PROTOCOL_H #ifndef PROXY_PROTOCOL_H
#define PROXY_PROTOCOL_H #define PROXY_PROTOCOL_H
#include "sldns/sbuffer.h" #include "config.h"
/** PROXYv2 minimum header size */ /** PROXYv2 minimum header size */
#define PP2_HEADER_SIZE 16 #define PP2_HEADER_SIZE 16
@ -51,11 +51,11 @@
#define PP2_SIG "\x0D\x0A\x0D\x0A\x00\x0D\x0A\x51\x55\x49\x54\x0A" #define PP2_SIG "\x0D\x0A\x0D\x0A\x00\x0D\x0A\x51\x55\x49\x54\x0A"
#define PP2_SIG_LEN 12 #define PP2_SIG_LEN 12
/** PROXYv2 version */ /** PROXYv2 version (protocol value) */
#define PP2_VERSION 0x2 #define PP2_VERSION 0x2
/** /**
* PROXYv2 command. * PROXYv2 command (protocol value).
*/ */
enum pp2_command { enum pp2_command {
PP2_CMD_LOCAL = 0x0, PP2_CMD_LOCAL = 0x0,
@ -63,7 +63,7 @@ enum pp2_command {
}; };
/** /**
* PROXYv2 address family. * PROXYv2 address family (protocol value).
*/ */
enum pp2_af { enum pp2_af {
PP2_AF_UNSPEC = 0x0, PP2_AF_UNSPEC = 0x0,
@ -73,7 +73,7 @@ enum pp2_af {
}; };
/** /**
* PROXYv2 protocol. * PROXYv2 protocol (protocol value).
*/ */
enum pp2_protocol { enum pp2_protocol {
PP2_PROT_UNSPEC = 0x0, PP2_PROT_UNSPEC = 0x0,
@ -81,6 +81,19 @@ enum pp2_protocol {
PP2_PROT_DGRAM = 0x2 PP2_PROT_DGRAM = 0x2
}; };
/**
* Expected combinations of address family and protocol values used in checks.
*/
enum pp2_af_protocol_combination {
PP2_UNSPEC_UNSPEC = (PP2_AF_UNSPEC<<4)|PP2_PROT_UNSPEC,
PP2_INET_STREAM = (PP2_AF_INET<<4)|PP2_PROT_STREAM,
PP2_INET_DGRAM = (PP2_AF_INET<<4)|PP2_PROT_DGRAM,
PP2_INET6_STREAM = (PP2_AF_INET6<<4)|PP2_PROT_STREAM,
PP2_INET6_DGRAM = (PP2_AF_INET6<<4)|PP2_PROT_DGRAM,
PP2_UNIX_STREAM = (PP2_AF_UNIX<<4)|PP2_PROT_STREAM,
PP2_UNIX_DGRAM = (PP2_AF_UNIX<<4)|PP2_PROT_DGRAM
};
/** /**
* PROXYv2 header. * PROXYv2 header.
*/ */
@ -109,23 +122,56 @@ struct pp2_header {
} addr; } addr;
}; };
/**
* PROXY parse errors.
*/
enum pp_parse_errors {
PP_PARSE_NOERROR = 0,
PP_PARSE_SIZE,
PP_PARSE_WRONG_HEADERv2,
PP_PARSE_UNKNOWN_CMD,
PP_PARSE_UNKNOWN_FAM_PROT,
};
/**
* Initialize the internal proxy structure.
* @param write_uint16: pointer to a function that can write uint16.
* @param write_uint32: pointer to a function that can write uint32.
*/
void pp_init(void (*write_uint16)(void* buf, uint16_t data),
void (*write_uint32)(void* buf, uint32_t data));
/**
* Lookup the parsing error description.
* @param error: parsing error from pp2_read_header.
* @return the description.
*/
const char* pp_lookup_error(enum pp_parse_errors error);
/** /**
* Write a PROXYv2 header at the current position of the buffer. * Write a PROXYv2 header at the current position of the buffer.
* @param buf: the buffer to write to. * @param buf: pointer to the buffer to write data to.
* @param buflen: available size on the buffer.
* @param src: the source address. * @param src: the source address.
* @param stream: if the protocol is stream or datagram. * @param stream: if the protocol is stream or datagram.
* @return 1 on success, 0 on failure. * @return 1 on success, 0 on failure.
*/ */
int pp2_write_to_buf(struct sldns_buffer* buf, struct sockaddr_storage* src, size_t pp2_write_to_buf(uint8_t* buf, size_t buflen,
#ifdef INET6
struct sockaddr_storage* src,
#else
struct sockaddr_in* src,
#endif
int stream); int stream);
/** /**
* Read a PROXYv2 header from the current position of the buffer. * Read a PROXYv2 header from the current position of the buffer.
* It does initial validation and returns a pointer to the buffer position on * It does initial validation and returns a pointer to the buffer position on
* success. * success.
* @param buf: the buffer to read from. * @param buf: pointer to the buffer data to read from.
* @return the pointer to the buffer position on success, NULL on error. * @param buflen: available size on the buffer.
* @return parsing error, 0 on success.
*/ */
struct pp2_header* pp2_read_header(struct sldns_buffer* buf); int pp2_read_header(uint8_t* buf, size_t buflen);
#endif /* PROXY_PROTOCOL_H */ #endif /* PROXY_PROTOCOL_H */

View File

@ -353,17 +353,21 @@ autr_tp_create(struct val_anchors* anchors, uint8_t* own, size_t own_len,
lock_basic_lock(&anchors->lock); lock_basic_lock(&anchors->lock);
if(!rbtree_insert(anchors->tree, &tp->node)) { if(!rbtree_insert(anchors->tree, &tp->node)) {
char buf[LDNS_MAX_DOMAINLEN+1];
lock_basic_unlock(&anchors->lock); lock_basic_unlock(&anchors->lock);
log_err("trust anchor presented twice"); dname_str(tp->name, buf);
log_err("trust anchor for '%s' presented twice", buf);
free(tp->name); free(tp->name);
free(tp->autr); free(tp->autr);
free(tp); free(tp);
return NULL; return NULL;
} }
if(!rbtree_insert(&anchors->autr->probe, &tp->autr->pnode)) { if(!rbtree_insert(&anchors->autr->probe, &tp->autr->pnode)) {
char buf[LDNS_MAX_DOMAINLEN+1];
(void)rbtree_delete(anchors->tree, tp); (void)rbtree_delete(anchors->tree, tp);
lock_basic_unlock(&anchors->lock); lock_basic_unlock(&anchors->lock);
log_err("trust anchor in probetree twice"); dname_str(tp->name, buf);
log_err("trust anchor for '%s' in probetree twice", buf);
free(tp->name); free(tp->name);
free(tp->autr); free(tp->autr);
free(tp); free(tp);

View File

@ -1322,3 +1322,24 @@ anchor_has_keytag(struct val_anchors* anchors, uint8_t* name, int namelabs,
free(taglist); free(taglist);
return 0; return 0;
} }
struct trust_anchor*
anchors_find_any_noninsecure(struct val_anchors* anchors)
{
struct trust_anchor* ta, *next;
lock_basic_lock(&anchors->lock);
ta=(struct trust_anchor*)rbtree_first(anchors->tree);
while((rbnode_type*)ta != RBTREE_NULL) {
next = (struct trust_anchor*)rbtree_next(&ta->node);
lock_basic_lock(&ta->lock);
if(ta->numDS != 0 || ta->numDNSKEY != 0) {
/* not an insecurepoint */
lock_basic_unlock(&anchors->lock);
return ta;
}
lock_basic_unlock(&ta->lock);
ta = next;
}
lock_basic_unlock(&anchors->lock);
return NULL;
}

View File

@ -240,4 +240,12 @@ size_t anchor_list_keytags(struct trust_anchor* ta, uint16_t* list, size_t num);
int anchor_has_keytag(struct val_anchors* anchors, uint8_t* name, int namelabs, int anchor_has_keytag(struct val_anchors* anchors, uint8_t* name, int namelabs,
size_t namelen, uint16_t dclass, uint16_t keytag); size_t namelen, uint16_t dclass, uint16_t keytag);
/**
* Find an anchor that is not an insecure point, if any, or there are no
* DNSSEC verification anchors if none.
* @param anchors: anchor storage
* @return trust anchor or NULL. It is locked.
*/
struct trust_anchor* anchors_find_any_noninsecure(struct val_anchors* anchors);
#endif /* VALIDATOR_VAL_ANCHOR_H */ #endif /* VALIDATOR_VAL_ANCHOR_H */

View File

@ -748,7 +748,6 @@ dnskey_verify_rrset(struct module_env* env, struct val_env* ve,
return sec_status_bogus; return sec_status_bogus;
} }
} }
verbose(VERB_ALGO, "rrset failed to verify: all signatures are bogus");
if(!numchecked) { if(!numchecked) {
*reason = "signature for expected key and algorithm missing"; *reason = "signature for expected key and algorithm missing";
if(reason_bogus) if(reason_bogus)
@ -761,6 +760,7 @@ dnskey_verify_rrset(struct module_env* env, struct val_env* ve,
*reason = "algorithm refused by cryptolib"; *reason = "algorithm refused by cryptolib";
return sec_status_indeterminate; return sec_status_indeterminate;
} }
verbose(VERB_ALGO, "rrset failed to verify: all signatures are bogus");
return sec_status_bogus; return sec_status_bogus;
} }

View File

@ -424,11 +424,13 @@ static enum sec_status
verify_dnskeys_with_ds_rr(struct module_env* env, struct val_env* ve, verify_dnskeys_with_ds_rr(struct module_env* env, struct val_env* ve,
struct ub_packed_rrset_key* dnskey_rrset, struct ub_packed_rrset_key* dnskey_rrset,
struct ub_packed_rrset_key* ds_rrset, size_t ds_idx, char** reason, struct ub_packed_rrset_key* ds_rrset, size_t ds_idx, char** reason,
sldns_ede_code *reason_bogus, struct module_qstate* qstate) sldns_ede_code *reason_bogus, struct module_qstate* qstate,
int *nonechecked)
{ {
enum sec_status sec = sec_status_bogus; enum sec_status sec = sec_status_bogus;
size_t i, num, numchecked = 0, numhashok = 0, numsizesupp = 0; size_t i, num, numchecked = 0, numhashok = 0, numsizesupp = 0;
num = rrset_get_count(dnskey_rrset); num = rrset_get_count(dnskey_rrset);
*nonechecked = 0;
for(i=0; i<num; i++) { for(i=0; i<num; i++) {
/* Skip DNSKEYs that don't match the basic criteria. */ /* Skip DNSKEYs that don't match the basic criteria. */
if(ds_get_key_algo(ds_rrset, ds_idx) if(ds_get_key_algo(ds_rrset, ds_idx)
@ -476,13 +478,15 @@ verify_dnskeys_with_ds_rr(struct module_env* env, struct val_env* ve,
/* there is a working DS, but that DNSKEY is not supported */ /* there is a working DS, but that DNSKEY is not supported */
return sec_status_insecure; return sec_status_insecure;
} }
if(numchecked == 0) if(numchecked == 0) {
algo_needs_reason(env, ds_get_key_algo(ds_rrset, ds_idx), algo_needs_reason(env, ds_get_key_algo(ds_rrset, ds_idx),
reason, "no keys have a DS"); reason, "no keys have a DS");
else if(numhashok == 0) *nonechecked = 1;
} else if(numhashok == 0) {
*reason = "DS hash mismatches key"; *reason = "DS hash mismatches key";
else if(!*reason) } else if(!*reason) {
*reason = "keyset not secured by DNSKEY that matches DS"; *reason = "keyset not secured by DNSKEY that matches DS";
}
return sec_status_bogus; return sec_status_bogus;
} }
@ -511,7 +515,8 @@ val_verify_DNSKEY_with_DS(struct module_env* env, struct val_env* ve,
{ {
/* as long as this is false, we can consider this DS rrset to be /* as long as this is false, we can consider this DS rrset to be
* equivalent to no DS rrset. */ * equivalent to no DS rrset. */
int has_useful_ds = 0, digest_algo, alg; int has_useful_ds = 0, digest_algo, alg, has_algo_refusal = 0,
nonechecked, has_checked_ds = 0;
struct algo_needs needs; struct algo_needs needs;
size_t i, num; size_t i, num;
enum sec_status sec; enum sec_status sec;
@ -544,9 +549,16 @@ val_verify_DNSKEY_with_DS(struct module_env* env, struct val_env* ve,
} }
sec = verify_dnskeys_with_ds_rr(env, ve, dnskey_rrset, sec = verify_dnskeys_with_ds_rr(env, ve, dnskey_rrset,
ds_rrset, i, reason, reason_bogus, qstate); ds_rrset, i, reason, reason_bogus, qstate,
if(sec == sec_status_insecure) &nonechecked);
if(sec == sec_status_insecure) {
/* DNSKEY too large unsupported or algo refused by
* crypto lib. */
has_algo_refusal = 1;
continue; continue;
}
if(!nonechecked)
has_checked_ds = 1;
/* Once we see a single DS with a known digestID and /* Once we see a single DS with a known digestID and
* algorithm, we cannot return INSECURE (with a * algorithm, we cannot return INSECURE (with a
@ -571,6 +583,15 @@ val_verify_DNSKEY_with_DS(struct module_env* env, struct val_env* ve,
/* None of the DS's worked out. */ /* None of the DS's worked out. */
/* If none of the DSes have been checked, eg. that means no matches
* for keytags, and the other dses are all algo_refusal, it is an
* insecure delegation point, since the only matched DS records
* have an algo refusal, or are unsupported. */
if(has_algo_refusal && !has_checked_ds) {
verbose(VERB_ALGO, "No supported DS records were found -- "
"treating as insecure.");
return sec_status_insecure;
}
/* If no DSs were understandable, then this is OK. */ /* If no DSs were understandable, then this is OK. */
if(!has_useful_ds) { if(!has_useful_ds) {
verbose(VERB_ALGO, "No usable DS records were found -- " verbose(VERB_ALGO, "No usable DS records were found -- "
@ -624,7 +645,8 @@ val_verify_DNSKEY_with_TA(struct module_env* env, struct val_env* ve,
{ {
/* as long as this is false, we can consider this anchor to be /* as long as this is false, we can consider this anchor to be
* equivalent to no anchor. */ * equivalent to no anchor. */
int has_useful_ta = 0, digest_algo = 0, alg; int has_useful_ta = 0, digest_algo = 0, alg, has_algo_refusal = 0,
nonechecked, has_checked_ds = 0;
struct algo_needs needs; struct algo_needs needs;
size_t i, num; size_t i, num;
enum sec_status sec; enum sec_status sec;
@ -670,9 +692,13 @@ val_verify_DNSKEY_with_TA(struct module_env* env, struct val_env* ve,
continue; continue;
sec = verify_dnskeys_with_ds_rr(env, ve, dnskey_rrset, sec = verify_dnskeys_with_ds_rr(env, ve, dnskey_rrset,
ta_ds, i, reason, reason_bogus, qstate); ta_ds, i, reason, reason_bogus, qstate, &nonechecked);
if(sec == sec_status_insecure) if(sec == sec_status_insecure) {
has_algo_refusal = 1;
continue; continue;
}
if(!nonechecked)
has_checked_ds = 1;
/* Once we see a single DS with a known digestID and /* Once we see a single DS with a known digestID and
* algorithm, we cannot return INSECURE (with a * algorithm, we cannot return INSECURE (with a
@ -728,6 +754,15 @@ val_verify_DNSKEY_with_TA(struct module_env* env, struct val_env* ve,
} }
} }
/* If none of the DSes have been checked, eg. that means no matches
* for keytags, and the other dses are all algo_refusal, it is an
* insecure delegation point, since the only matched DS records
* have an algo refusal, or are unsupported. */
if(has_algo_refusal && !has_checked_ds) {
verbose(VERB_ALGO, "No supported trust anchors were found -- "
"treating as insecure.");
return sec_status_insecure;
}
/* If no DSs were understandable, then this is OK. */ /* If no DSs were understandable, then this is OK. */
if(!has_useful_ta) { if(!has_useful_ta) {
verbose(VERB_ALGO, "No usable trust anchors were found -- " verbose(VERB_ALGO, "No usable trust anchors were found -- "

View File

@ -205,6 +205,17 @@ val_init(struct module_env* env, int id)
log_err("validator: could not apply configuration settings."); log_err("validator: could not apply configuration settings.");
return 0; return 0;
} }
if(env->cfg->disable_edns_do) {
struct trust_anchor* anchor = anchors_find_any_noninsecure(
env->anchors);
if(anchor) {
char b[LDNS_MAX_DOMAINLEN+2];
dname_str(anchor->name, b);
log_warn("validator: disable-edns-do is enabled, but there is a trust anchor for '%s'. Since DNSSEC could not work, the disable-edns-do setting is turned off. Continuing without it.", b);
lock_basic_unlock(&anchor->lock);
env->cfg->disable_edns_do = 0;
}
}
return 1; return 1;
} }
@ -2999,6 +3010,8 @@ return_bogus:
* @param msg: result message (if rcode is OK). * @param msg: result message (if rcode is OK).
* @param qinfo: from the sub query state, query info. * @param qinfo: from the sub query state, query info.
* @param origin: the origin of msg. * @param origin: the origin of msg.
* @param suspend: returned true if the task takes too long and needs to
* suspend to continue the effort later.
*/ */
static void static void
process_ds_response(struct module_qstate* qstate, struct val_qstate* vq, process_ds_response(struct module_qstate* qstate, struct val_qstate* vq,

View File

@ -1,4 +1,4 @@
/* $OpenBSD: vmm_machdep.c,v 1.23 2024/04/09 21:55:16 dv Exp $ */ /* $OpenBSD: vmm_machdep.c,v 1.24 2024/04/13 21:57:22 dv Exp $ */
/* /*
* Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org> * Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org>
* *
@ -941,6 +941,7 @@ vmx_pmap_find_pte_ept(pmap_t pmap, paddr_t addr)
int int
vmm_start(void) vmm_start(void)
{ {
int rv = 0;
struct cpu_info *self = curcpu(); struct cpu_info *self = curcpu();
#ifdef MULTIPROCESSOR #ifdef MULTIPROCESSOR
struct cpu_info *ci; struct cpu_info *ci;
@ -950,16 +951,19 @@ vmm_start(void)
#endif /* MP_LOCKDEBUG */ #endif /* MP_LOCKDEBUG */
#endif /* MULTIPROCESSOR */ #endif /* MULTIPROCESSOR */
rw_enter_write(&vmm_softc->sc_slock);
/* VMM is already running */ /* VMM is already running */
if (self->ci_flags & CPUF_VMM) if (self->ci_flags & CPUF_VMM)
return (0); goto unlock;
/* Start VMM on this CPU */ /* Start VMM on this CPU */
start_vmm_on_cpu(self); start_vmm_on_cpu(self);
if (!(self->ci_flags & CPUF_VMM)) { if (!(self->ci_flags & CPUF_VMM)) {
printf("%s: failed to enter VMM mode\n", printf("%s: failed to enter VMM mode\n",
self->ci_dev->dv_xname); self->ci_dev->dv_xname);
return (EIO); rv = EIO;
goto unlock;
} }
#ifdef MULTIPROCESSOR #ifdef MULTIPROCESSOR
@ -984,8 +988,9 @@ vmm_start(void)
} }
} }
#endif /* MULTIPROCESSOR */ #endif /* MULTIPROCESSOR */
unlock:
return (0); rw_exit_write(&vmm_softc->sc_slock);
return (rv);
} }
/* /*
@ -996,6 +1001,7 @@ vmm_start(void)
int int
vmm_stop(void) vmm_stop(void)
{ {
int rv = 0;
struct cpu_info *self = curcpu(); struct cpu_info *self = curcpu();
#ifdef MULTIPROCESSOR #ifdef MULTIPROCESSOR
struct cpu_info *ci; struct cpu_info *ci;
@ -1005,16 +1011,19 @@ vmm_stop(void)
#endif /* MP_LOCKDEBUG */ #endif /* MP_LOCKDEBUG */
#endif /* MULTIPROCESSOR */ #endif /* MULTIPROCESSOR */
rw_enter_write(&vmm_softc->sc_slock);
/* VMM is not running */ /* VMM is not running */
if (!(self->ci_flags & CPUF_VMM)) if (!(self->ci_flags & CPUF_VMM))
return (0); goto unlock;
/* Stop VMM on this CPU */ /* Stop VMM on this CPU */
stop_vmm_on_cpu(self); stop_vmm_on_cpu(self);
if (self->ci_flags & CPUF_VMM) { if (self->ci_flags & CPUF_VMM) {
printf("%s: failed to exit VMM mode\n", printf("%s: failed to exit VMM mode\n",
self->ci_dev->dv_xname); self->ci_dev->dv_xname);
return (EIO); rv = EIO;
goto unlock;
} }
#ifdef MULTIPROCESSOR #ifdef MULTIPROCESSOR
@ -1039,7 +1048,8 @@ vmm_stop(void)
} }
} }
#endif /* MULTIPROCESSOR */ #endif /* MULTIPROCESSOR */
unlock:
rw_exit_write(&vmm_softc->sc_slock);
return (0); return (0);
} }

View File

@ -1,4 +1,4 @@
/* $OpenBSD: cpu.c,v 1.113 2024/03/18 21:57:22 kettenis Exp $ */ /* $OpenBSD: cpu.c,v 1.114 2024/04/13 14:19:39 kettenis Exp $ */
/* /*
* Copyright (c) 2016 Dale Rahn <drahn@dalerahn.com> * Copyright (c) 2016 Dale Rahn <drahn@dalerahn.com>
@ -278,6 +278,138 @@ void cpu_kstat_attach(struct cpu_info *ci);
void cpu_opp_kstat_attach(struct cpu_info *ci); void cpu_opp_kstat_attach(struct cpu_info *ci);
#endif #endif
/*
* Enable mitigation for Spectre-V2 branch target injection
* vulnerabilities (CVE-2017-5715).
*/
void
cpu_mitigate_spectre_v2(struct cpu_info *ci)
{
uint64_t id;
/*
* By default we let the firmware decide what mitigation is
* necessary.
*/
ci->ci_flush_bp = cpu_flush_bp_psci;
/* Some specific CPUs are known not to be vulnerable. */
switch (CPU_IMPL(ci->ci_midr)) {
case CPU_IMPL_ARM:
switch (CPU_PART(ci->ci_midr)) {
case CPU_PART_CORTEX_A35:
case CPU_PART_CORTEX_A53:
case CPU_PART_CORTEX_A55:
/* Not vulnerable. */
ci->ci_flush_bp = cpu_flush_bp_noop;
break;
}
break;
case CPU_IMPL_QCOM:
switch (CPU_PART(ci->ci_midr)) {
case CPU_PART_KRYO400_SILVER:
/* Not vulnerable. */
ci->ci_flush_bp = cpu_flush_bp_noop;
break;
}
}
/*
* The architecture has been updated to explicitly tell us if
* we're not vulnerable to Spectre-V2.
*/
id = READ_SPECIALREG(id_aa64pfr0_el1);
if (ID_AA64PFR0_CSV2(id) >= ID_AA64PFR0_CSV2_IMPL)
ci->ci_flush_bp = cpu_flush_bp_noop;
}
/*
* Enable mitigation for Spectre-BHB branch history injection
* vulnerabilities (CVE-2022-23960).
*/
void
cpu_mitigate_spectre_bhb(struct cpu_info *ci)
{
uint64_t id;
/*
* If we know the CPU, we can add a branchy loop that cleans
* the BHB.
*/
switch (CPU_IMPL(ci->ci_midr)) {
case CPU_IMPL_ARM:
switch (CPU_PART(ci->ci_midr)) {
case CPU_PART_CORTEX_A57:
case CPU_PART_CORTEX_A72:
ci->ci_trampoline_vectors =
(vaddr_t)trampoline_vectors_loop_8;
break;
case CPU_PART_CORTEX_A76:
case CPU_PART_CORTEX_A76AE:
case CPU_PART_CORTEX_A77:
case CPU_PART_NEOVERSE_N1:
ci->ci_trampoline_vectors =
(vaddr_t)trampoline_vectors_loop_24;
break;
case CPU_PART_CORTEX_A78:
case CPU_PART_CORTEX_A78AE:
case CPU_PART_CORTEX_A78C:
case CPU_PART_CORTEX_X1:
case CPU_PART_CORTEX_X2:
case CPU_PART_CORTEX_A710:
case CPU_PART_NEOVERSE_N2:
case CPU_PART_NEOVERSE_V1:
ci->ci_trampoline_vectors =
(vaddr_t)trampoline_vectors_loop_32;
break;
}
break;
case CPU_IMPL_AMPERE:
switch (CPU_PART(ci->ci_midr)) {
case CPU_PART_AMPERE1:
ci->ci_trampoline_vectors =
(vaddr_t)trampoline_vectors_loop_11;
break;
}
break;
}
/*
* If we're not using a loop, let firmware decide. This also
* covers the original Spectre-V2 in addition to Spectre-BHB.
*/
#if NPSCI > 0
if (ci->ci_trampoline_vectors == (vaddr_t)trampoline_vectors_none &&
smccc_needs_arch_workaround_3()) {
ci->ci_flush_bp = cpu_flush_bp_noop;
if (psci_method() == PSCI_METHOD_HVC)
ci->ci_trampoline_vectors =
(vaddr_t)trampoline_vectors_psci_hvc;
if (psci_method() == PSCI_METHOD_SMC)
ci->ci_trampoline_vectors =
(vaddr_t)trampoline_vectors_psci_smc;
}
#endif
/* Prefer CLRBHB to mitigate Spectre-BHB. */
id = READ_SPECIALREG(id_aa64isar2_el1);
if (ID_AA64ISAR2_CLRBHB(id) >= ID_AA64ISAR2_CLRBHB_IMPL)
ci->ci_trampoline_vectors = (vaddr_t)trampoline_vectors_clrbhb;
/* ECBHB tells us Spectre-BHB is mitigated. */
id = READ_SPECIALREG(id_aa64mmfr1_el1);
if (ID_AA64MMFR1_ECBHB(id) >= ID_AA64MMFR1_ECBHB_IMPL)
ci->ci_trampoline_vectors = (vaddr_t)trampoline_vectors_none;
/*
* The architecture has been updated to explicitly tell us if
* we're not vulnerable to Spectre-BHB.
*/
id = READ_SPECIALREG(id_aa64pfr0_el1);
if (ID_AA64PFR0_CSV2(id) >= ID_AA64PFR0_CSV2_HCXT)
ci->ci_trampoline_vectors = (vaddr_t)trampoline_vectors_none;
}
/* /*
* Enable mitigation for Spectre-V4 speculative store bypass * Enable mitigation for Spectre-V4 speculative store bypass
* vulnerabilities (CVE-2018-3639). * vulnerabilities (CVE-2018-3639).
@ -459,123 +591,8 @@ cpu_identify(struct cpu_info *ci)
clidr >>= 3; clidr >>= 3;
} }
/* cpu_mitigate_spectre_v2(ci);
* Some ARM processors are vulnerable to branch target cpu_mitigate_spectre_bhb(ci);
* injection attacks (CVE-2017-5715).
*/
switch (impl) {
case CPU_IMPL_ARM:
switch (part) {
case CPU_PART_CORTEX_A35:
case CPU_PART_CORTEX_A53:
case CPU_PART_CORTEX_A55:
/* Not vulnerable. */
ci->ci_flush_bp = cpu_flush_bp_noop;
break;
default:
/*
* Potentially vulnerable; call into the
* firmware and hope we're running on top of
* Arm Trusted Firmware with a fix for
* Security Advisory TFV 6.
*/
ci->ci_flush_bp = cpu_flush_bp_psci;
break;
}
break;
default:
/* Not much we can do for an unknown processor. */
ci->ci_flush_bp = cpu_flush_bp_noop;
break;
}
/*
* The architecture has been updated to explicitly tell us if
* we're not vulnerable to regular Spectre.
*/
id = READ_SPECIALREG(id_aa64pfr0_el1);
if (ID_AA64PFR0_CSV2(id) >= ID_AA64PFR0_CSV2_IMPL)
ci->ci_flush_bp = cpu_flush_bp_noop;
/*
* But we might still be vulnerable to Spectre-BHB. If we know the
* CPU, we can add a branchy loop that cleans the BHB.
*/
switch (impl) {
case CPU_IMPL_ARM:
switch (part) {
case CPU_PART_CORTEX_A57:
case CPU_PART_CORTEX_A72:
ci->ci_trampoline_vectors =
(vaddr_t)trampoline_vectors_loop_8;
break;
case CPU_PART_CORTEX_A76:
case CPU_PART_CORTEX_A76AE:
case CPU_PART_CORTEX_A77:
case CPU_PART_NEOVERSE_N1:
ci->ci_trampoline_vectors =
(vaddr_t)trampoline_vectors_loop_24;
break;
case CPU_PART_CORTEX_A78:
case CPU_PART_CORTEX_A78AE:
case CPU_PART_CORTEX_A78C:
case CPU_PART_CORTEX_X1:
case CPU_PART_CORTEX_X2:
case CPU_PART_CORTEX_A710:
case CPU_PART_NEOVERSE_N2:
case CPU_PART_NEOVERSE_V1:
ci->ci_trampoline_vectors =
(vaddr_t)trampoline_vectors_loop_32;
break;
}
break;
case CPU_IMPL_AMPERE:
switch (part) {
case CPU_PART_AMPERE1:
ci->ci_trampoline_vectors =
(vaddr_t)trampoline_vectors_loop_11;
break;
}
break;
}
/*
* If we're not using a loop, try and call into PSCI. This also
* covers the original Spectre in addition to Spectre-BHB.
*/
#if NPSCI > 0
if (ci->ci_trampoline_vectors == (vaddr_t)trampoline_vectors_none &&
smccc_needs_arch_workaround_3()) {
ci->ci_flush_bp = cpu_flush_bp_noop;
if (psci_method() == PSCI_METHOD_HVC)
ci->ci_trampoline_vectors =
(vaddr_t)trampoline_vectors_psci_hvc;
if (psci_method() == PSCI_METHOD_SMC)
ci->ci_trampoline_vectors =
(vaddr_t)trampoline_vectors_psci_smc;
}
#endif
/* Prefer CLRBHB to mitigate Spectre-BHB. */
id = READ_SPECIALREG(id_aa64isar2_el1);
if (ID_AA64ISAR2_CLRBHB(id) >= ID_AA64ISAR2_CLRBHB_IMPL)
ci->ci_trampoline_vectors = (vaddr_t)trampoline_vectors_clrbhb;
/* ECBHB tells us Spectre-BHB is mitigated. */
id = READ_SPECIALREG(id_aa64mmfr1_el1);
if (ID_AA64MMFR1_ECBHB(id) >= ID_AA64MMFR1_ECBHB_IMPL)
ci->ci_trampoline_vectors = (vaddr_t)trampoline_vectors_none;
/*
* The architecture has been updated to explicitly tell us if
* we're not vulnerable.
*/
id = READ_SPECIALREG(id_aa64pfr0_el1);
if (ID_AA64PFR0_CSV2(id) >= ID_AA64PFR0_CSV2_HCXT) {
ci->ci_flush_bp = cpu_flush_bp_noop;
ci->ci_trampoline_vectors = (vaddr_t)trampoline_vectors_none;
}
cpu_mitigate_spectre_v4(ci); cpu_mitigate_spectre_v4(ci);
/* /*

View File

@ -1,4 +1,4 @@
/* $OpenBSD: acpitoshiba.c,v 1.16 2022/04/06 18:59:27 naddy Exp $ */ /* $OpenBSD: acpitoshiba.c,v 1.17 2024/04/13 23:44:11 jsg Exp $ */
/*- /*-
* Copyright (c) 2003 Hiroyuki Aizu <aizu@navi.org> * Copyright (c) 2003 Hiroyuki Aizu <aizu@navi.org>
* All rights reserved. * All rights reserved.
@ -202,19 +202,18 @@ toshiba_update_brightness(void *arg0, int arg1)
int int
toshiba_match(struct device *parent, void *match, void *aux) toshiba_match(struct device *parent, void *match, void *aux)
{ {
struct acpi_attach_args *aa = aux; struct acpi_attach_args *aa = aux;
struct cfdata *cf = match; struct cfdata *cf = match;
if (acpi_matchhids(aa, acpitoshiba_hids, cf->cf_driver->cd_name)) if (acpi_matchhids(aa, acpitoshiba_hids, cf->cf_driver->cd_name))
return (1); return (1);
if (aa->aaa_name == NULL || if (aa->aaa_name == NULL ||
strcmp(aa->aaa_name, cf->cf_driver->cd_name) != 0 || strcmp(aa->aaa_name, cf->cf_driver->cd_name) != 0 ||
aa->aaa_table != NULL) aa->aaa_table != NULL)
return (0); return (0);
return (1);
return (1);
} }
int int

View File

@ -1,4 +1,4 @@
/* $OpenBSD: acpivout.c,v 1.25 2022/04/06 18:59:27 naddy Exp $ */ /* $OpenBSD: acpivout.c,v 1.26 2024/04/13 23:44:11 jsg Exp $ */
/* /*
* Copyright (c) 2009 Paul Irofti <paul@irofti.net> * Copyright (c) 2009 Paul Irofti <paul@irofti.net>
* *
@ -259,7 +259,7 @@ acpivout_get_bcl(struct acpivout_softc *sc)
value = aml_val2int(res.v_package[i + 2]); value = aml_val2int(res.v_package[i + 2]);
for (j = i; j > 0 && sc->sc_bcl[j - 1] > value; j--) for (j = i; j > 0 && sc->sc_bcl[j - 1] > value; j--)
sc->sc_bcl[j] = sc->sc_bcl[j - 1]; sc->sc_bcl[j] = sc->sc_bcl[j - 1];
sc->sc_bcl[j] = value; sc->sc_bcl[j] = value;
} }
err: err:

View File

@ -1,4 +1,4 @@
/* $OpenBSD: dsdt.c,v 1.265 2024/01/08 19:52:29 kettenis Exp $ */ /* $OpenBSD: dsdt.c,v 1.266 2024/04/13 23:44:11 jsg Exp $ */
/* /*
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org> * Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
* *
@ -4249,7 +4249,7 @@ aml_parse(struct aml_scope *scope, int ret_type, const char *stype)
/* Name: Nt */ /* Name: Nt */
rv = opargs[0]; rv = opargs[0];
aml_freevalue(rv); aml_freevalue(rv);
aml_copyvalue(rv, opargs[1]); aml_copyvalue(rv, opargs[1]);
break; break;
case AMLOP_ALIAS: case AMLOP_ALIAS:
/* Alias: nN */ /* Alias: nN */

View File

@ -1,4 +1,4 @@
/* $OpenBSD: psci.c,v 1.15 2024/03/18 21:57:22 kettenis Exp $ */ /* $OpenBSD: psci.c,v 1.16 2024/04/13 14:20:48 kettenis Exp $ */
/* /*
* Copyright (c) 2016 Jonathan Gray <jsg@openbsd.org> * Copyright (c) 2016 Jonathan Gray <jsg@openbsd.org>
@ -212,14 +212,6 @@ psci_flush_bp_smccc_arch_workaround_1(void)
(*sc->sc_callfn)(SMCCC_ARCH_WORKAROUND_1, 0, 0, 0); (*sc->sc_callfn)(SMCCC_ARCH_WORKAROUND_1, 0, 0, 0);
} }
void
psci_flush_bp_smccc_arch_workaround_3(void)
{
struct psci_softc *sc = psci_sc;
(*sc->sc_callfn)(SMCCC_ARCH_WORKAROUND_3, 0, 0, 0);
}
void void
psci_flush_bp(void) psci_flush_bp(void)
{ {

View File

@ -17,7 +17,6 @@ int32_t psci_cpu_on(register_t, register_t, register_t);
int32_t psci_cpu_off(void); int32_t psci_cpu_off(void);
int32_t psci_cpu_suspend(register_t, register_t, register_t); int32_t psci_cpu_suspend(register_t, register_t, register_t);
void psci_flush_bp(void); void psci_flush_bp(void);
int psci_flush_bp_has_bhb(void);
int psci_method(void); int psci_method(void);
int32_t smccc(uint32_t, register_t, register_t, register_t); int32_t smccc(uint32_t, register_t, register_t, register_t);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: adw.c,v 1.69 2022/04/16 19:19:58 naddy Exp $ */ /* $OpenBSD: adw.c,v 1.70 2024/04/13 23:44:11 jsg Exp $ */
/* $NetBSD: adw.c,v 1.23 2000/05/27 18:24:50 dante Exp $ */ /* $NetBSD: adw.c,v 1.23 2000/05/27 18:24:50 dante Exp $ */
/* /*
@ -449,7 +449,7 @@ adw_attach(ADW_SOFTC *sc)
/* /*
* Zero's the freeze_device status * Zero's the freeze_device status
*/ */
bzero(sc->sc_freeze_dev, sizeof(sc->sc_freeze_dev)); bzero(sc->sc_freeze_dev, sizeof(sc->sc_freeze_dev));
/* /*
* Initialize the adapter * Initialize the adapter

View File

@ -1,4 +1,4 @@
/* $OpenBSD: adwlib.c,v 1.29 2022/08/29 06:08:03 jsg Exp $ */ /* $OpenBSD: adwlib.c,v 1.30 2024/04/13 23:44:11 jsg Exp $ */
/* $NetBSD: adwlib.c,v 1.20 2000/07/04 04:17:03 itojun Exp $ */ /* $NetBSD: adwlib.c,v 1.20 2000/07/04 04:17:03 itojun Exp $ */
/* /*
@ -315,9 +315,9 @@ AdwInitFromEEPROM(ADW_SOFTC *sc)
*/ */
lsw_msb |= (ADW_EEPROM_INTAB >> 8) lsw_msb |= (ADW_EEPROM_INTAB >> 8)
& 0xFF; & 0xFF;
} }
eep_config.cfg_lsw &= 0x00FF; eep_config.cfg_lsw &= 0x00FF;
eep_config.cfg_lsw |= lsw_msb << 8; eep_config.cfg_lsw |= lsw_msb << 8;
} }
break; break;
} }

View File

@ -1,4 +1,4 @@
/* $OpenBSD: an.c,v 1.79 2022/04/21 21:03:02 stsp Exp $ */ /* $OpenBSD: an.c,v 1.80 2024/04/13 23:44:11 jsg Exp $ */
/* $NetBSD: an.c,v 1.34 2005/06/20 02:49:18 atatat Exp $ */ /* $NetBSD: an.c,v 1.34 2005/06/20 02:49:18 atatat Exp $ */
/* /*
* Copyright (c) 1997, 1998, 1999 * Copyright (c) 1997, 1998, 1999
@ -905,7 +905,7 @@ an_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
if ((error = suser(curproc)) != 0) if ((error = suser(curproc)) != 0)
break; break;
error = an_set_nwkey(sc, (struct ieee80211_nwkey *)data); error = an_set_nwkey(sc, (struct ieee80211_nwkey *)data);
break; break;
case SIOCG80211NWKEY: case SIOCG80211NWKEY:
error = an_get_nwkey(sc, (struct ieee80211_nwkey *)data); error = an_get_nwkey(sc, (struct ieee80211_nwkey *)data);
break; break;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: bwi.c,v 1.134 2023/11/10 15:51:20 bluhm Exp $ */ /* $OpenBSD: bwi.c,v 1.135 2024/04/13 23:44:11 jsg Exp $ */
/* /*
* Copyright (c) 2007 The DragonFly Project. All rights reserved. * Copyright (c) 2007 The DragonFly Project. All rights reserved.
@ -6400,7 +6400,7 @@ bwi_led_attach(struct bwi_softc *sc)
if (led->l_act == BWI_LED_ACT_BLINK_SLOW || if (led->l_act == BWI_LED_ACT_BLINK_SLOW ||
led->l_act == BWI_LED_ACT_BLINK_POLL || led->l_act == BWI_LED_ACT_BLINK_POLL ||
led->l_act == BWI_LED_ACT_BLINK) { led->l_act == BWI_LED_ACT_BLINK) {
led->l_flags |= BWI_LED_F_BLINK; led->l_flags |= BWI_LED_F_BLINK;
if (led->l_act == BWI_LED_ACT_BLINK_POLL) if (led->l_act == BWI_LED_ACT_BLINK_POLL)
led->l_flags |= BWI_LED_F_POLLABLE; led->l_flags |= BWI_LED_F_POLLABLE;
else if (led->l_act == BWI_LED_ACT_BLINK_SLOW) else if (led->l_act == BWI_LED_ACT_BLINK_SLOW)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ncr53c9x.c,v 1.81 2024/04/03 18:41:38 miod Exp $ */ /* $OpenBSD: ncr53c9x.c,v 1.82 2024/04/13 23:44:11 jsg Exp $ */
/* $NetBSD: ncr53c9x.c,v 1.56 2000/11/30 14:41:46 thorpej Exp $ */ /* $NetBSD: ncr53c9x.c,v 1.56 2000/11/30 14:41:46 thorpej Exp $ */
/* /*
@ -2456,7 +2456,7 @@ printf("<<RESELECT CONT'd>>");
if (sc->sc_state == NCR_IDLE) { if (sc->sc_state == NCR_IDLE) {
printf("%s: stray interrupt\n", printf("%s: stray interrupt\n",
sc->sc_dev.dv_xname); sc->sc_dev.dv_xname);
return (0); return (0);
} }
break; break;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: siop.c,v 1.89 2022/04/16 19:19:59 naddy Exp $ */ /* $OpenBSD: siop.c,v 1.90 2024/04/13 23:44:11 jsg Exp $ */
/* $NetBSD: siop.c,v 1.79 2005/11/18 23:10:32 bouyer Exp $ */ /* $NetBSD: siop.c,v 1.79 2005/11/18 23:10:32 bouyer Exp $ */
/* /*
@ -579,7 +579,7 @@ siop_intr(void *v)
* unexpected disconnect. Usually the target signals * unexpected disconnect. Usually the target signals
* a fatal condition this way. Attempt to get sense. * a fatal condition this way. Attempt to get sense.
*/ */
if (siop_cmd) { if (siop_cmd) {
siop_cmd->cmd_tables->status = siop_cmd->cmd_tables->status =
siop_htoc32(&sc->sc_c, SCSI_CHECK); siop_htoc32(&sc->sc_c, SCSI_CHECK);
goto end; goto end;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: siop_common.c,v 1.44 2022/01/09 05:42:42 jsg Exp $ */ /* $OpenBSD: siop_common.c,v 1.45 2024/04/13 23:44:11 jsg Exp $ */
/* $NetBSD: siop_common.c,v 1.37 2005/02/27 00:27:02 perry Exp $ */ /* $NetBSD: siop_common.c,v 1.37 2005/02/27 00:27:02 perry Exp $ */
/* /*
@ -281,7 +281,7 @@ siop_setuptables(struct siop_common_cmd *siop_cmd)
if ((*targ_flags & TARF_DT) && if ((*targ_flags & TARF_DT) &&
(sc->mode == STEST4_MODE_LVD)) { (sc->mode == STEST4_MODE_LVD)) {
sc->targets[target]->status = TARST_PPR_NEG; sc->targets[target]->status = TARST_PPR_NEG;
siop_ppr_msg(siop_cmd, msgoffset, sc->dt_minsync, siop_ppr_msg(siop_cmd, msgoffset, sc->dt_minsync,
sc->maxoff); sc->maxoff);
} else if (*targ_flags & TARF_WIDE) { } else if (*targ_flags & TARF_WIDE) {
sc->targets[target]->status = TARST_WIDE_NEG; sc->targets[target]->status = TARST_WIDE_NEG;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ad1848.c,v 1.48 2022/10/28 14:55:46 kn Exp $ */ /* $OpenBSD: ad1848.c,v 1.49 2024/04/13 23:44:11 jsg Exp $ */
/* $NetBSD: ad1848.c,v 1.45 1998/01/30 02:02:38 augustss Exp $ */ /* $NetBSD: ad1848.c,v 1.45 1998/01/30 02:02:38 augustss Exp $ */
/* /*
@ -1244,19 +1244,20 @@ ad1848_set_speed(struct ad1848_softc *sc, u_long *argp)
if (arg > speed_table[n - 1].speed) if (arg > speed_table[n - 1].speed)
selected = n - 1; selected = n - 1;
for (i = 1 /*really*/ ; selected == -1 && i < n; i++) for (i = 1 /*really*/ ; selected == -1 && i < n; i++) {
if (speed_table[i].speed == arg) if (speed_table[i].speed == arg)
selected = i; selected = i;
else if (speed_table[i].speed > arg) { else if (speed_table[i].speed > arg) {
int diff1, diff2; int diff1, diff2;
diff1 = arg - speed_table[i - 1].speed; diff1 = arg - speed_table[i - 1].speed;
diff2 = speed_table[i].speed - arg; diff2 = speed_table[i].speed - arg;
if (diff1 < diff2) if (diff1 < diff2)
selected = i - 1; selected = i - 1;
else else
selected = i; selected = i;
}
} }
if (selected == -1) { if (selected == -1) {

View File

@ -1,4 +1,4 @@
/* $OpenBSD: brgphy.c,v 1.108 2022/04/06 18:59:29 naddy Exp $ */ /* $OpenBSD: brgphy.c,v 1.109 2024/04/13 23:44:11 jsg Exp $ */
/* /*
* Copyright (c) 2000 * Copyright (c) 2000
@ -836,7 +836,7 @@ brgphy_reset_bge(struct mii_softc *sc)
if (bge_sc->bge_phy_flags & BGE_PHY_BER_BUG) if (bge_sc->bge_phy_flags & BGE_PHY_BER_BUG)
brgphy_ber_bug(sc); brgphy_ber_bug(sc);
else if (bge_sc->bge_phy_flags & BGE_PHY_JITTER_BUG) { else if (bge_sc->bge_phy_flags & BGE_PHY_JITTER_BUG) {
PHY_WRITE(sc, BRGPHY_MII_AUXCTL, 0x0c00); PHY_WRITE(sc, BRGPHY_MII_AUXCTL, 0x0c00);
PHY_WRITE(sc, BRGPHY_MII_DSP_ADDR_REG, 0x000a); PHY_WRITE(sc, BRGPHY_MII_DSP_ADDR_REG, 0x000a);
if (bge_sc->bge_phy_flags & BGE_PHY_ADJUST_TRIM) { if (bge_sc->bge_phy_flags & BGE_PHY_ADJUST_TRIM) {
@ -925,7 +925,7 @@ brgphy_reset_bnx(struct mii_softc *sc)
PHY_WRITE(sc, BRGPHY_5708S_PG5_TXACTL3, PHY_WRITE(sc, BRGPHY_5708S_PG5_TXACTL3,
bnx_sc->bnx_port_hw_cfg & bnx_sc->bnx_port_hw_cfg &
BNX_PORT_HW_CFG_CFG_TXCTL3_MASK); BNX_PORT_HW_CFG_CFG_TXCTL3_MASK);
PHY_WRITE(sc, BRGPHY_5708S_BLOCK_ADDR, PHY_WRITE(sc, BRGPHY_5708S_BLOCK_ADDR,
BRGPHY_5708S_DIG_PG0); BRGPHY_5708S_DIG_PG0);
} }
} else if (BNX_CHIP_NUM(bnx_sc) == BNX_CHIP_NUM_5709 && } else if (BNX_CHIP_NUM(bnx_sc) == BNX_CHIP_NUM_5709 &&

View File

@ -1,4 +1,4 @@
/* $OpenBSD: arc.c,v 1.124 2022/09/06 15:22:11 kn Exp $ */ /* $OpenBSD: arc.c,v 1.125 2024/04/13 23:44:11 jsg Exp $ */
/* /*
* Copyright (c) 2006 David Gwynne <dlg@openbsd.org> * Copyright (c) 2006 David Gwynne <dlg@openbsd.org>
@ -1409,18 +1409,18 @@ arc_enable_all_intr(struct arc_softc *sc)
int_mask &= ~(ARC_RA_INTRMASK_POSTQUEUE | int_mask &= ~(ARC_RA_INTRMASK_POSTQUEUE |
ARC_RA_INTRMASK_DOORBELL | ARC_RA_INTRMASK_MSG0); ARC_RA_INTRMASK_DOORBELL | ARC_RA_INTRMASK_MSG0);
arc_write(sc, ARC_RA_INTRMASK, int_mask); arc_write(sc, ARC_RA_INTRMASK, int_mask);
break; break;
case ARC_HBA_TYPE_C: case ARC_HBA_TYPE_C:
int_mask = arc_read(sc, ARC_RC_INTR_MASK); int_mask = arc_read(sc, ARC_RC_INTR_MASK);
int_mask &= ~(ARC_RC_INTR_MASK_POSTQUEUE | int_mask &= ~(ARC_RC_INTR_MASK_POSTQUEUE |
ARC_RC_INTR_MASK_DOORBELL | ARC_RC_INTR_MASK_UTILITY_A); ARC_RC_INTR_MASK_DOORBELL | ARC_RC_INTR_MASK_UTILITY_A);
arc_write(sc, ARC_RC_INTR_MASK, int_mask); arc_write(sc, ARC_RC_INTR_MASK, int_mask);
break; break;
case ARC_HBA_TYPE_D: case ARC_HBA_TYPE_D:
int_mask = arc_read(sc, ARC_RD_INTR_ENABLE); int_mask = arc_read(sc, ARC_RD_INTR_ENABLE);
int_mask |= ARC_RD_INTR_ENABLE_ALL; int_mask |= ARC_RD_INTR_ENABLE_ALL;
arc_write(sc, ARC_RD_INTR_ENABLE, int_mask); arc_write(sc, ARC_RD_INTR_ENABLE, int_mask);
break; break;
} }
} }

View File

@ -1,4 +1,4 @@
/* $OpenBSD: auvia.c,v 1.66 2022/10/26 20:19:08 kn Exp $ */ /* $OpenBSD: auvia.c,v 1.67 2024/04/13 23:44:11 jsg Exp $ */
/* $NetBSD: auvia.c,v 1.28 2002/11/04 16:38:49 kent Exp $ */ /* $NetBSD: auvia.c,v 1.28 2002/11/04 16:38:49 kent Exp $ */
/*- /*-
@ -611,7 +611,7 @@ auvia_set_params(void *addr, int setmode, int usemode,
if (p->channels == 6 if (p->channels == 6
&& codec->vtbl->set_rate(codec, reg, && codec->vtbl->set_rate(codec, reg,
&p->sample_rate)) &p->sample_rate))
return (EINVAL); return (EINVAL);
} }
} }

View File

@ -31,7 +31,7 @@
*******************************************************************************/ *******************************************************************************/
/* $OpenBSD: if_em_hw.c,v 1.119 2023/12/03 00:19:25 jsg Exp $ */ /* $OpenBSD: if_em_hw.c,v 1.120 2024/04/13 23:44:11 jsg Exp $ */
/* /*
* if_em_hw.c Shared functions for accessing and configuring the MAC * if_em_hw.c Shared functions for accessing and configuring the MAC
*/ */
@ -6432,9 +6432,9 @@ em_init_eeprom_params(struct em_hw *hw)
case em_pch2lan: case em_pch2lan:
case em_pch_lpt: case em_pch_lpt:
{ {
int32_t i = 0; int32_t i = 0;
uint32_t flash_size = uint32_t flash_size =
E1000_READ_ICH_FLASH_REG(hw, ICH_FLASH_GFPREG); E1000_READ_ICH_FLASH_REG(hw, ICH_FLASH_GFPREG);
eeprom->type = em_eeprom_ich8; eeprom->type = em_eeprom_ich8;
eeprom->use_eerd = FALSE; eeprom->use_eerd = FALSE;
eeprom->use_eewr = FALSE; eeprom->use_eewr = FALSE;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: if_iwm.c,v 1.414 2024/02/16 11:44:52 stsp Exp $ */ /* $OpenBSD: if_iwm.c,v 1.415 2024/04/13 23:44:11 jsg Exp $ */
/* /*
* Copyright (c) 2014, 2016 genua gmbh <info@genua.de> * Copyright (c) 2014, 2016 genua gmbh <info@genua.de>
@ -8169,7 +8169,7 @@ iwm_rval2ridx(int rval)
break; break;
} }
return ridx; return ridx;
} }
void void

View File

@ -1,4 +1,4 @@
/* $OpenBSD: if_iwx.c,v 1.182 2024/02/26 18:00:09 stsp Exp $ */ /* $OpenBSD: if_iwx.c,v 1.183 2024/04/13 23:44:11 jsg Exp $ */
/* /*
* Copyright (c) 2014, 2016 genua gmbh <info@genua.de> * Copyright (c) 2014, 2016 genua gmbh <info@genua.de>
@ -786,7 +786,7 @@ iwx_alloc_fw_monitor(struct iwx_softc *sc, uint8_t max_power)
} }
if (max_power > 26) { if (max_power > 26) {
DPRINTF(("%s: External buffer size for monitor is too big %d, " DPRINTF(("%s: External buffer size for monitor is too big %d, "
"check the FW TLV\n", DEVNAME(sc), max_power)); "check the FW TLV\n", DEVNAME(sc), max_power));
return 0; return 0;
} }
@ -7211,7 +7211,7 @@ iwx_rval2ridx(int rval)
break; break;
} }
return ridx; return ridx;
} }
void void
@ -9831,7 +9831,7 @@ iwx_rx_pkt(struct iwx_softc *sc, struct iwx_rx_data *data, struct mbuf_list *ml)
* For v5 and above, we can check the version, for older * For v5 and above, we can check the version, for older
* versions we need to check the size. * versions we need to check the size.
*/ */
if (iwx_lookup_notif_ver(sc, IWX_LEGACY_GROUP, if (iwx_lookup_notif_ver(sc, IWX_LEGACY_GROUP,
IWX_ALIVE) == 6) { IWX_ALIVE) == 6) {
SYNC_RESP_STRUCT(resp6, pkt); SYNC_RESP_STRUCT(resp6, pkt);
if (iwx_rx_packet_payload_len(pkt) != if (iwx_rx_packet_payload_len(pkt) !=
@ -10880,7 +10880,7 @@ iwx_find_device_cfg(struct iwx_softc *sc)
cores = IWX_SUBDEVICE_CORES(sdev_id); cores = IWX_SUBDEVICE_CORES(sdev_id);
for (i = nitems(iwx_dev_info_table) - 1; i >= 0; i--) { for (i = nitems(iwx_dev_info_table) - 1; i >= 0; i--) {
const struct iwx_dev_info *dev_info = &iwx_dev_info_table[i]; const struct iwx_dev_info *dev_info = &iwx_dev_info_table[i];
if (dev_info->device != (uint16_t)IWX_CFG_ANY && if (dev_info->device != (uint16_t)IWX_CFG_ANY &&
dev_info->device != sc->sc_pid) dev_info->device != sc->sc_pid)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: if_ngbe.c,v 1.3 2024/04/12 19:27:43 jan Exp $ */ /* $OpenBSD: if_ngbe.c,v 1.4 2024/04/13 23:44:11 jsg Exp $ */
/* /*
* Copyright (c) 2015-2017 Beijing WangXun Technology Co., Ltd. * Copyright (c) 2015-2017 Beijing WangXun Technology Co., Ltd.
@ -2952,7 +2952,7 @@ ngbe_host_interface_command(struct ngbe_softc *sc, uint32_t *buffer,
if (length == 0 || length > NGBE_HI_MAX_BLOCK_BYTE_LENGTH) { if (length == 0 || length > NGBE_HI_MAX_BLOCK_BYTE_LENGTH) {
printf("%s: buffer length failure\n", DEVNAME(sc)); printf("%s: buffer length failure\n", DEVNAME(sc));
return EINVAL; return EINVAL;
} }
if (hw->mac.ops.acquire_swfw_sync(sc, NGBE_MNG_SWFW_SYNC_SW_MB)) if (hw->mac.ops.acquire_swfw_sync(sc, NGBE_MNG_SWFW_SYNC_SW_MB))
@ -3706,7 +3706,7 @@ ngbe_reset_hw(struct ngbe_softc *sc)
* mng is using it. If link is down or the flag to force full link * mng is using it. If link is down or the flag to force full link
* reset is set, then perform link reset. * reset is set, then perform link reset.
*/ */
if (hw->force_full_reset) { if (hw->force_full_reset) {
rst_delay = (NGBE_READ_REG(hw, NGBE_MIS_RST_ST) & rst_delay = (NGBE_READ_REG(hw, NGBE_MIS_RST_ST) &
NGBE_MIS_RST_ST_RST_INIT) >> NGBE_MIS_RST_ST_RST_INI_SHIFT; NGBE_MIS_RST_ST_RST_INIT) >> NGBE_MIS_RST_ST_RST_INI_SHIFT;
if (hw->reset_type == NGBE_SW_RESET) { if (hw->reset_type == NGBE_SW_RESET) {
@ -4528,9 +4528,9 @@ ngbe_update_mc_addr_list(struct ngbe_hw *hw, uint8_t *mc_addr_list,
if (clear) if (clear)
memset(&hw->mac.mta_shadow, 0, sizeof(hw->mac.mta_shadow)); memset(&hw->mac.mta_shadow, 0, sizeof(hw->mac.mta_shadow));
/* Update mta_shadow */ /* Update mta_shadow */
for (i = 0; i < mc_addr_count; i++) for (i = 0; i < mc_addr_count; i++)
ngbe_set_mta(hw, next(hw, &mc_addr_list, &vmdq)); ngbe_set_mta(hw, next(hw, &mc_addr_list, &vmdq));
/* Enable mta */ /* Enable mta */
for (i = 0; i < hw->mac.mcft_size; i++) for (i = 0; i < hw->mac.mcft_size; i++)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: if_qwx_pci.c,v 1.14 2024/02/22 09:15:34 stsp Exp $ */ /* $OpenBSD: if_qwx_pci.c,v 1.15 2024/04/13 23:44:11 jsg Exp $ */
/* /*
* Copyright 2023 Stefan Sperling <stsp@openbsd.org> * Copyright 2023 Stefan Sperling <stsp@openbsd.org>
@ -2901,7 +2901,7 @@ qwx_mhi_start(struct qwx_pci_softc *psc)
#endif #endif
/* Transition to primary runtime. */ /* Transition to primary runtime. */
if (MHI_IN_PBL(ee)) { if (MHI_IN_PBL(ee)) {
ret = qwx_mhi_fw_load_handler(psc); ret = qwx_mhi_fw_load_handler(psc);
if (ret) if (ret)
return ret; return ret;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: if_rge.c,v 1.23 2023/12/22 05:28:14 kevlo Exp $ */ /* $OpenBSD: if_rge.c,v 1.24 2024/04/13 23:44:11 jsg Exp $ */
/* /*
* Copyright (c) 2019, 2020, 2023 Kevin Lo <kevlo@openbsd.org> * Copyright (c) 2019, 2020, 2023 Kevin Lo <kevlo@openbsd.org>
@ -1250,7 +1250,7 @@ rge_rxeof(struct rge_queues *q)
* If this is part of a multi-fragment packet, * If this is part of a multi-fragment packet,
* discard all the pieces. * discard all the pieces.
*/ */
if (q->q_rx.rge_head != NULL) { if (q->q_rx.rge_head != NULL) {
m_freem(q->q_rx.rge_head); m_freem(q->q_rx.rge_head);
q->q_rx.rge_head = q->q_rx.rge_tail = NULL; q->q_rx.rge_head = q->q_rx.rge_tail = NULL;
} }

View File

@ -1,4 +1,4 @@
/* $OpenBSD: if_sis.c,v 1.143 2023/11/10 15:51:20 bluhm Exp $ */ /* $OpenBSD: if_sis.c,v 1.144 2024/04/13 23:44:11 jsg Exp $ */
/* /*
* Copyright (c) 1997, 1998, 1999 * Copyright (c) 1997, 1998, 1999
* Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
@ -1791,7 +1791,7 @@ sis_init(void *xsc)
* This resolves an issue with tons of errors in AcceptPerfectMatch * This resolves an issue with tons of errors in AcceptPerfectMatch
* (non-IFF_PROMISC) mode. * (non-IFF_PROMISC) mode.
*/ */
if (sc->sis_type == SIS_TYPE_83815 && sc->sis_srr <= NS_SRR_15D) { if (sc->sis_type == SIS_TYPE_83815 && sc->sis_srr <= NS_SRR_15D) {
CSR_WRITE_4(sc, NS_PHY_PAGE, 0x0001); CSR_WRITE_4(sc, NS_PHY_PAGE, 0x0001);
CSR_WRITE_4(sc, NS_PHY_CR, 0x189C); CSR_WRITE_4(sc, NS_PHY_CR, 0x189C);
/* set val for c2 */ /* set val for c2 */

View File

@ -31,7 +31,7 @@
*******************************************************************************/ *******************************************************************************/
/* $OpenBSD: ixgb_hw.c,v 1.9 2022/01/09 05:42:56 jsg Exp $ */ /* $OpenBSD: ixgb_hw.c,v 1.10 2024/04/13 23:44:11 jsg Exp $ */
/* ixgb_hw.c /* ixgb_hw.c
* Shared functions for accessing and configuring the adapter * Shared functions for accessing and configuring the adapter
@ -83,14 +83,14 @@ ixgb_mac_reset(struct ixgb_hw *hw)
{ {
uint32_t ctrl_reg; uint32_t ctrl_reg;
ctrl_reg = IXGB_CTRL0_RST | ctrl_reg = IXGB_CTRL0_RST |
IXGB_CTRL0_SDP3_DIR | /* All pins are Output=1 */ IXGB_CTRL0_SDP3_DIR | /* All pins are Output=1 */
IXGB_CTRL0_SDP2_DIR | IXGB_CTRL0_SDP2_DIR |
IXGB_CTRL0_SDP1_DIR | IXGB_CTRL0_SDP1_DIR |
IXGB_CTRL0_SDP0_DIR | IXGB_CTRL0_SDP0_DIR |
IXGB_CTRL0_SDP3 | /* Initial value 1101 */ IXGB_CTRL0_SDP3 | /* Initial value 1101 */
IXGB_CTRL0_SDP2 | IXGB_CTRL0_SDP2 |
IXGB_CTRL0_SDP0; IXGB_CTRL0_SDP0;
#ifdef HP_ZX1 #ifdef HP_ZX1
/* Workaround for 82597EX reset errata */ /* Workaround for 82597EX reset errata */

View File

@ -1,4 +1,4 @@
/* $OpenBSD: maestro.c,v 1.50 2022/10/28 15:09:46 kn Exp $ */ /* $OpenBSD: maestro.c,v 1.51 2024/04/13 23:44:11 jsg Exp $ */
/* $FreeBSD: /c/ncvs/src/sys/dev/sound/pci/maestro.c,v 1.3 2000/11/21 12:22:11 julian Exp $ */ /* $FreeBSD: /c/ncvs/src/sys/dev/sound/pci/maestro.c,v 1.3 2000/11/21 12:22:11 julian Exp $ */
/* /*
* FreeBSD's ESS Agogo/Maestro driver * FreeBSD's ESS Agogo/Maestro driver
@ -900,7 +900,7 @@ maestro_set_speed(struct maestro_channel *ch, u_long *prate)
} else { } else {
/* compute 16 bits fixed point value of speed/48000, /* compute 16 bits fixed point value of speed/48000,
* being careful not to overflow */ * being careful not to overflow */
ch->dv = (((ch->speed % 48000) << 16U) + 24000) / 48000 ch->dv = (((ch->speed % 48000) << 16U) + 24000) / 48000
+ ((ch->speed / 48000) << 16U); + ((ch->speed / 48000) << 16U);
/* And this is the real rate obtained */ /* And this is the real rate obtained */
ch->speed = (ch->dv >> 16U) * 48000 + ch->speed = (ch->dv >> 16U) * 48000 +

View File

@ -1,4 +1,4 @@
/* $OpenBSD: pciide.c,v 1.363 2022/03/11 18:00:51 mpi Exp $ */ /* $OpenBSD: pciide.c,v 1.364 2024/04/13 23:44:11 jsg Exp $ */
/* $NetBSD: pciide.c,v 1.127 2001/08/03 01:31:08 tsutsui Exp $ */ /* $NetBSD: pciide.c,v 1.127 2001/08/03 01:31:08 tsutsui Exp $ */
/* /*
@ -2939,8 +2939,8 @@ piix_setup_channel(struct channel_softc *chp)
(drvp[1].drive_flags & DRIVE_DMA)) { (drvp[1].drive_flags & DRIVE_DMA)) {
mode[0] = mode[1] = mode[0] = mode[1] =
min(drvp[0].DMA_mode, drvp[1].DMA_mode); min(drvp[0].DMA_mode, drvp[1].DMA_mode);
drvp[0].DMA_mode = mode[0]; drvp[0].DMA_mode = mode[0];
drvp[1].DMA_mode = mode[1]; drvp[1].DMA_mode = mode[1];
goto ok; goto ok;
} }
/* /*
@ -4127,7 +4127,7 @@ cmd680_channel_map(struct pci_attach_args *pa, struct pciide_softc *sc,
printf("%s %s: " printf("%s %s: "
"cannot allocate channel queue", "cannot allocate channel queue",
sc->sc_wdcdev.sc_dev.dv_xname, cp->name); sc->sc_wdcdev.sc_dev.dv_xname, cp->name);
return; return;
} }
/* XXX */ /* XXX */
@ -7972,9 +7972,9 @@ acard_setup_channel(struct channel_softc *chp)
acard_act_pio[drvp->PIO_mode], acard_act_pio[drvp->PIO_mode],
acard_rec_pio[drvp->PIO_mode]); acard_rec_pio[drvp->PIO_mode]);
} }
pci_conf_write(sc->sc_pc, sc->sc_tag, ATP8x0_CTRL, pci_conf_write(sc->sc_pc, sc->sc_tag, ATP8x0_CTRL,
pci_conf_read(sc->sc_pc, sc->sc_tag, ATP8x0_CTRL) pci_conf_read(sc->sc_pc, sc->sc_tag, ATP8x0_CTRL) |
| ATP8x0_CTRL_EN(channel)); ATP8x0_CTRL_EN(channel));
} }
} }

View File

@ -1,4 +1,4 @@
/* $OpenBSD: qle.c,v 1.63 2022/04/16 19:19:59 naddy Exp $ */ /* $OpenBSD: qle.c,v 1.64 2024/04/14 00:38:26 jsg Exp $ */
/* /*
* Copyright (c) 2013, 2014 Jonathan Matthew <jmatthew@openbsd.org> * Copyright (c) 2013, 2014 Jonathan Matthew <jmatthew@openbsd.org>
@ -359,7 +359,7 @@ qle_attach(struct device *parent, struct device *self, void *aux)
pcireg_t bars[] = { QLE_PCI_MEM_BAR, QLE_PCI_IO_BAR }; pcireg_t bars[] = { QLE_PCI_MEM_BAR, QLE_PCI_IO_BAR };
pcireg_t memtype; pcireg_t memtype;
int r, i, rv, loop_up; int r, i, rv, loop_up = 0;
sc->sc_pc = pa->pa_pc; sc->sc_pc = pa->pa_pc;
sc->sc_tag = pa->pa_tag; sc->sc_tag = pa->pa_tag;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: if_umb.c,v 1.56 2023/10/24 09:13:22 jmatthew Exp $ */ /* $OpenBSD: if_umb.c,v 1.57 2024/04/13 23:44:11 jsg Exp $ */
/* /*
* Copyright (c) 2016 genua mbH * Copyright (c) 2016 genua mbH
@ -3135,7 +3135,7 @@ umb_intr(struct usbd_xfer *xfer, void *priv, usbd_status status)
if (total_len < UCDC_NOTIFICATION_LENGTH) { if (total_len < UCDC_NOTIFICATION_LENGTH) {
DPRINTF("%s: short notification (%d<%d)\n", DEVNAM(sc), DPRINTF("%s: short notification (%d<%d)\n", DEVNAM(sc),
total_len, UCDC_NOTIFICATION_LENGTH); total_len, UCDC_NOTIFICATION_LENGTH);
return; return;
} }
if (sc->sc_intr_msg.bmRequestType != UCDC_NOTIFICATION) { if (sc->sc_intr_msg.bmRequestType != UCDC_NOTIFICATION) {
DPRINTF("%s: unexpected notification (type=0x%02x)\n", DPRINTF("%s: unexpected notification (type=0x%02x)\n",

View File

@ -1,4 +1,4 @@
/* $OpenBSD: if_ure.c,v 1.33 2023/09/09 14:23:37 kevlo Exp $ */ /* $OpenBSD: if_ure.c,v 1.34 2024/04/13 23:44:11 jsg Exp $ */
/*- /*-
* Copyright (c) 2015, 2016, 2019 Kevin Lo <kevlo@openbsd.org> * Copyright (c) 2015, 2016, 2019 Kevin Lo <kevlo@openbsd.org>
* Copyright (c) 2020 Jonathon Fletcher <jonathon.fletcher@gmail.com> * Copyright (c) 2020 Jonathon Fletcher <jonathon.fletcher@gmail.com>
@ -2078,7 +2078,7 @@ ure_rxeof(struct usbd_xfer *xfer, void *priv, usbd_status status)
if (rxvlan & URE_RXPKT_VLAN_TAG) { if (rxvlan & URE_RXPKT_VLAN_TAG) {
m->m_pkthdr.ether_vtag = m->m_pkthdr.ether_vtag =
swap16(rxvlan & URE_RXPKT_VLAN_DATA); swap16(rxvlan & URE_RXPKT_VLAN_DATA);
m->m_flags |= M_VLANTAG; m->m_flags |= M_VLANTAG;
} }
#endif #endif

View File

@ -1,4 +1,4 @@
/* $OpenBSD: wsdisplay_compat_usl.c,v 1.33 2020/09/03 15:30:17 kettenis Exp $ */ /* $OpenBSD: wsdisplay_compat_usl.c,v 1.34 2024/04/13 23:44:11 jsg Exp $ */
/* $NetBSD: wsdisplay_compat_usl.c,v 1.12 2000/03/23 07:01:47 thorpej Exp $ */ /* $NetBSD: wsdisplay_compat_usl.c,v 1.12 2000/03/23 07:01:47 thorpej Exp $ */
/* /*
@ -440,9 +440,8 @@ wsdisplay_usl_ioctl2(struct wsdisplay_softc *sc, struct wsscreen *scr,
#define PCVT_SYSBEEPF 1193182 #define PCVT_SYSBEEPF 1193182
if (d >> 16) { if (d >> 16) {
bd.which = WSKBD_BELL_DOPERIOD; bd.which = WSKBD_BELL_DOPERIOD;
bd.period = d >> 16; /* ms */ bd.period = d >> 16; /* ms */
} } else
else
bd.which = 0; bd.which = 0;
if (d & 0xffff) { if (d & 0xffff) {
bd.which |= WSKBD_BELL_DOPITCH; bd.which |= WSKBD_BELL_DOPITCH;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: udf_subr.c,v 1.26 2022/09/01 13:45:26 krw Exp $ */ /* $OpenBSD: udf_subr.c,v 1.27 2024/04/13 23:44:11 jsg Exp $ */
/* /*
* Copyright (c) 2006, Miodrag Vallat * Copyright (c) 2006, Miodrag Vallat
@ -201,7 +201,7 @@ udf_vat_get(struct umount *ump, uint32_t lb)
up->u_vatlen = (letoh64(up->u_fentry->inf_len) - 36) >> 2; up->u_vatlen = (letoh64(up->u_fentry->inf_len) - 36) >> 2;
ump->um_vat = malloc(sizeof(struct unode), M_UDFMOUNT, M_WAITOK); ump->um_vat = malloc(sizeof(struct unode), M_UDFMOUNT, M_WAITOK);
*ump->um_vat = *up; *ump->um_vat = *up;
ump->um_flags &= ~UDF_MNT_FIND_VAT; ump->um_flags &= ~UDF_MNT_FIND_VAT;
ump->um_flags |= UDF_MNT_USES_VAT; ump->um_flags |= UDF_MNT_USES_VAT;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: kern_acct.c,v 1.47 2022/08/14 01:58:27 jsg Exp $ */ /* $OpenBSD: kern_acct.c,v 1.48 2024/04/13 23:44:11 jsg Exp $ */
/* $NetBSD: kern_acct.c,v 1.42 1996/02/04 02:15:12 christos Exp $ */ /* $NetBSD: kern_acct.c,v 1.42 1996/02/04 02:15:12 christos Exp $ */
/*- /*-
@ -270,7 +270,7 @@ encode_comp_t(u_long s, u_long ns)
s += ns / (1000000000 / AHZ); /* Maximize precision. */ s += ns / (1000000000 / AHZ); /* Maximize precision. */
while (s > MAXFRACT) { while (s > MAXFRACT) {
rnd = s & (1 << (EXPSIZE - 1)); /* Round up? */ rnd = s & (1 << (EXPSIZE - 1)); /* Round up? */
s >>= EXPSIZE; /* Base 8 exponent == 3 bit shift. */ s >>= EXPSIZE; /* Base 8 exponent == 3 bit shift. */
exp++; exp++;
} }

View File

@ -1,4 +1,4 @@
/* $OpenBSD: pf_osfp.c,v 1.47 2023/10/10 11:25:31 bluhm Exp $ */ /* $OpenBSD: pf_osfp.c,v 1.48 2024/04/13 23:44:11 jsg Exp $ */
/* /*
* Copyright (c) 2003 Mike Frantzen <frantzen@w4g.org> * Copyright (c) 2003 Mike Frantzen <frantzen@w4g.org>
@ -382,7 +382,7 @@ pf_osfp_add(struct pf_osfp_ioctl *fpioc)
if ((fp = pf_osfp_find_exact(&fpadd))) { if ((fp = pf_osfp_find_exact(&fpadd))) {
struct pf_osfp_entry *tentry; struct pf_osfp_entry *tentry;
SLIST_FOREACH(tentry, &fp->fp_oses, fp_entry) { SLIST_FOREACH(tentry, &fp->fp_oses, fp_entry) {
if (PF_OSFP_ENTRY_EQ(tentry, &fpioc->fp_os)) { if (PF_OSFP_ENTRY_EQ(tentry, &fpioc->fp_os)) {
PF_UNLOCK(); PF_UNLOCK();
pool_put(&pf_osfp_entry_pl, entry); pool_put(&pf_osfp_entry_pl, entry);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ieee80211_input.c,v 1.251 2024/03/15 17:45:36 stsp Exp $ */ /* $OpenBSD: ieee80211_input.c,v 1.252 2024/04/13 23:44:11 jsg Exp $ */
/* $NetBSD: ieee80211_input.c,v 1.24 2004/05/31 11:12:24 dyoung Exp $ */ /* $NetBSD: ieee80211_input.c,v 1.24 2004/05/31 11:12:24 dyoung Exp $ */
/*- /*-
@ -1901,7 +1901,7 @@ ieee80211_recv_probe_resp(struct ieee80211com *ic, struct mbuf *m,
* This probe response indicates the AP is still serving us * This probe response indicates the AP is still serving us
* so don't allow ieee80211_watchdog() to move us into SCAN. * so don't allow ieee80211_watchdog() to move us into SCAN.
*/ */
if ((ic->ic_flags & IEEE80211_F_BGSCAN) == 0) if ((ic->ic_flags & IEEE80211_F_BGSCAN) == 0)
ic->ic_mgt_timer = 0; ic->ic_mgt_timer = 0;
} }
/* /*

View File

@ -1,4 +1,4 @@
/* $OpenBSD: tcp_input.c,v 1.403 2024/04/12 16:07:09 bluhm Exp $ */ /* $OpenBSD: tcp_input.c,v 1.404 2024/04/13 23:44:11 jsg Exp $ */
/* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */ /* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */
/* /*
@ -1078,12 +1078,13 @@ findpcb:
* Receive window is amount of space in rcv queue, * Receive window is amount of space in rcv queue,
* but not less than advertised window. * but not less than advertised window.
*/ */
{ int win; {
int win;
win = sbspace(so, &so->so_rcv); win = sbspace(so, &so->so_rcv);
if (win < 0) if (win < 0)
win = 0; win = 0;
tp->rcv_wnd = imax(win, (int)(tp->rcv_adv - tp->rcv_nxt)); tp->rcv_wnd = imax(win, (int)(tp->rcv_adv - tp->rcv_nxt));
} }
switch (tp->t_state) { switch (tp->t_state) {

View File

@ -1,4 +1,4 @@
/* $OpenBSD: nfs_vnops.c,v 1.194 2024/03/25 17:57:07 guenther Exp $ */ /* $OpenBSD: nfs_vnops.c,v 1.195 2024/04/13 23:44:11 jsg Exp $ */
/* $NetBSD: nfs_vnops.c,v 1.62.4.1 1996/07/08 20:26:52 jtc Exp $ */ /* $NetBSD: nfs_vnops.c,v 1.62.4.1 1996/07/08 20:26:52 jtc Exp $ */
/* /*
@ -336,9 +336,9 @@ nfs_access(void *v)
* Check access cache first. If a request has been made for this uid * Check access cache first. If a request has been made for this uid
* shortly before, use the cached result. * shortly before, use the cached result.
*/ */
cachevalid = (np->n_accstamp != -1 && cachevalid = (np->n_accstamp != -1 &&
(gettime() - np->n_accstamp) < nfs_attrtimeo(np) && (gettime() - np->n_accstamp) < nfs_attrtimeo(np) &&
np->n_accuid == ap->a_cred->cr_uid); np->n_accuid == ap->a_cred->cr_uid);
if (cachevalid) { if (cachevalid) {
if (!np->n_accerror) { if (!np->n_accerror) {
@ -408,7 +408,7 @@ nfs_access(void *v)
* If we got the same result as for a previous, different request, OR * If we got the same result as for a previous, different request, OR
* it in. Don't update the timestamp in that case. * it in. Don't update the timestamp in that case.
*/ */
if (!error || error == EACCES) { if (!error || error == EACCES) {
if (cachevalid && np->n_accstamp != -1 && if (cachevalid && np->n_accstamp != -1 &&
error == np->n_accerror) { error == np->n_accerror) {
if (!error) if (!error)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ext2fs_bmap.c,v 1.28 2021/12/12 09:14:59 visa Exp $ */ /* $OpenBSD: ext2fs_bmap.c,v 1.29 2024/04/13 23:44:11 jsg Exp $ */
/* $NetBSD: ext2fs_bmap.c,v 1.5 2000/03/30 12:41:11 augustss Exp $ */ /* $NetBSD: ext2fs_bmap.c,v 1.5 2000/03/30 12:41:11 augustss Exp $ */
/* /*
@ -192,7 +192,7 @@ ext2fs_bmaparray(struct vnode *vp, daddr_t bn, daddr_t *bnp,
devvp = VFSTOUFS(vp->v_mount)->um_devvp; devvp = VFSTOUFS(vp->v_mount)->um_devvp;
#ifdef DIAGNOSTIC #ifdef DIAGNOSTIC
if (num > NIADDR + 1 || num < 1) { if (num > NIADDR + 1 || num < 1) {
printf("ext2fs_bmaparray: num=%d\n", num); printf("ext2fs_bmaparray: num=%d\n", num);
panic("ext2fs_bmaparray: num"); panic("ext2fs_bmaparray: num");
} }

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ext2fs_vnops.c,v 1.92 2024/03/25 17:57:07 guenther Exp $ */ /* $OpenBSD: ext2fs_vnops.c,v 1.93 2024/04/13 23:44:11 jsg Exp $ */
/* $NetBSD: ext2fs_vnops.c,v 1.1 1997/06/11 09:34:09 bouyer Exp $ */ /* $NetBSD: ext2fs_vnops.c,v 1.1 1997/06/11 09:34:09 bouyer Exp $ */
/* /*
@ -819,7 +819,7 @@ abortit:
UIO_SYSSPACE, IO_NODELOCKED, UIO_SYSSPACE, IO_NODELOCKED,
tcnp->cn_cred, NULL, curproc); tcnp->cn_cred, NULL, curproc);
if (error == 0) { if (error == 0) {
namlen = dirbuf.dotdot_namlen; namlen = dirbuf.dotdot_namlen;
if (namlen != 2 || if (namlen != 2 ||
dirbuf.dotdot_name[0] != '.' || dirbuf.dotdot_name[0] != '.' ||
dirbuf.dotdot_name[1] != '.') { dirbuf.dotdot_name[1] != '.') {

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ffs_balloc.c,v 1.46 2024/02/03 18:51:58 beck Exp $ */ /* $OpenBSD: ffs_balloc.c,v 1.47 2024/04/13 23:44:11 jsg Exp $ */
/* $NetBSD: ffs_balloc.c,v 1.3 1996/02/09 22:22:21 christos Exp $ */ /* $NetBSD: ffs_balloc.c,v 1.3 1996/02/09 22:22:21 christos Exp $ */
/* /*
@ -750,7 +750,7 @@ fail:
* that we resolve the dependencies in one pass. * that we resolve the dependencies in one pass.
* Write the cylinder group buffers for these buffers too. * Write the cylinder group buffers for these buffers too.
*/ */
for (i = num; i >= unwindidx; i--) { for (i = num; i >= unwindidx; i--) {
if (i == 0) if (i == 0)
break; break;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ffs_extern.h,v 1.47 2024/04/11 16:31:30 otto Exp $ */ /* $OpenBSD: ffs_extern.h,v 1.49 2024/04/13 15:08:37 jca Exp $ */
/* $NetBSD: ffs_extern.h,v 1.4 1996/02/09 22:22:22 christos Exp $ */ /* $NetBSD: ffs_extern.h,v 1.4 1996/02/09 22:22:22 christos Exp $ */
/* /*
@ -36,6 +36,7 @@
#define FFS_CLUSTERWRITE 2 /* cluster writing enabled */ #define FFS_CLUSTERWRITE 2 /* cluster writing enabled */
#define FFS_REALLOCBLKS 3 /* block reallocation enabled */ #define FFS_REALLOCBLKS 3 /* block reallocation enabled */
#define FFS_ASYNCFREE 4 /* asynchronous block freeing enabled */ #define FFS_ASYNCFREE 4 /* asynchronous block freeing enabled */
#define FFS_MAX_SOFTDEPS 5 /* maximum structs before slowdown */
#define FFS_SD_TICKDELAY 6 /* ticks to pause during slowdown */ #define FFS_SD_TICKDELAY 6 /* ticks to pause during slowdown */
#define FFS_SD_WORKLIST_PUSH 7 /* # of worklist cleanups */ #define FFS_SD_WORKLIST_PUSH 7 /* # of worklist cleanups */
#define FFS_SD_BLK_LIMIT_PUSH 8 /* # of times block limit neared */ #define FFS_SD_BLK_LIMIT_PUSH 8 /* # of times block limit neared */
@ -59,17 +60,17 @@
{ 0, 0 }, \ { 0, 0 }, \
{ 0, 0 }, \ { 0, 0 }, \
{ 0, 0 }, \ { 0, 0 }, \
{ "sd_tickdelay", CTLTYPE_INT }, \ { 0, 0 }, \
{ "sd_worklist_push", CTLTYPE_INT }, \ { 0, 0 }, \
{ "sd_blk_limit_push", CTLTYPE_INT }, \ { 0, 0 }, \
{ "sd_ino_limit_push", CTLTYPE_INT }, \ { 0, 0 }, \
{ "sd_blk_limit_hit", CTLTYPE_INT }, \ { 0, 0 }, \
{ "sd_ino_limit_hit", CTLTYPE_INT }, \ { 0, 0 }, \
{ "sd_sync_limit_hit", CTLTYPE_INT }, \ { 0, 0 }, \
{ "sd_indir_blk_ptrs", CTLTYPE_INT }, \ { 0, 0 }, \
{ "sd_inode_bitmap", CTLTYPE_INT }, \ { 0, 0 }, \
{ "sd_direct_blk_ptrs", CTLTYPE_INT }, \ { 0, 0 }, \
{ "sd_dir_entry", CTLTYPE_INT }, \ { 0, 0 }, \
{ "dirhash_dirsize", CTLTYPE_INT }, \ { "dirhash_dirsize", CTLTYPE_INT }, \
{ "dirhash_maxmem", CTLTYPE_INT }, \ { "dirhash_maxmem", CTLTYPE_INT }, \
{ "dirhash_mem", CTLTYPE_INT }, \ { "dirhash_mem", CTLTYPE_INT }, \

View File

@ -1,4 +1,4 @@
/* $OpenBSD: uvm_addr.c,v 1.32 2022/11/04 09:36:44 mpi Exp $ */ /* $OpenBSD: uvm_addr.c,v 1.33 2024/04/13 23:44:11 jsg Exp $ */
/* /*
* Copyright (c) 2011 Ariane van der Steldt <ariane@stack.nl> * Copyright (c) 2011 Ariane van der Steldt <ariane@stack.nl>
@ -1406,7 +1406,7 @@ uaddr_stack_brk_select(struct vm_map *map, struct uvm_addr_state *uaddr,
if (uvm_addr_linsearch(map, uaddr, entry_out, addr_out, if (uvm_addr_linsearch(map, uaddr, entry_out, addr_out,
0, sz, align, offset, dir, start, end - sz, 0, sz, align, offset, dir, start, end - sz,
before_gap, after_gap) == 0) before_gap, after_gap) == 0)
return 0; return 0;
} }
return ENOMEM; return ENOMEM;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: uvm_aobj.c,v 1.109 2024/04/10 15:25:14 mpi Exp $ */ /* $OpenBSD: uvm_aobj.c,v 1.110 2024/04/13 23:44:11 jsg Exp $ */
/* $NetBSD: uvm_aobj.c,v 1.39 2001/02/18 21:19:08 chs Exp $ */ /* $NetBSD: uvm_aobj.c,v 1.39 2001/02/18 21:19:08 chs Exp $ */
/* /*
@ -298,7 +298,7 @@ uao_set_swslot(struct uvm_object *uobj, int pageidx, int slot)
/* but a set is not */ /* but a set is not */
printf("uao_set_swslot: uobj = %p\n", uobj); printf("uao_set_swslot: uobj = %p\n", uobj);
panic("uao_set_swslot: attempt to set a slot on a NOSWAP object"); panic("uao_set_swslot: attempt to set a slot on a NOSWAP object");
} }
/* /*

Some files were not shown because too many files have changed in this diff Show More