diff --git a/bin/tests/system/dlzexternal/driver/driver.c b/bin/tests/system/dlzexternal/driver/driver.c index 28b9639598..a113208858 100644 --- a/bin/tests/system/dlzexternal/driver/driver.c +++ b/bin/tests/system/dlzexternal/driver/driver.c @@ -480,8 +480,7 @@ dlz_lookup(const char *zone, const char *name, void *dbdata, * If the DLZ only operates on 'live' data, then version * wouldn't necessarily be needed. */ - if (clientinfo != NULL && clientinfo->version >= DNS_CLIENTINFO_VERSION) - { + if (clientinfo != NULL && clientinfo->version >= 2) { dbversion = clientinfo->dbversion; if (dbversion != NULL && *(bool *)dbversion) { loginfo("dlz_example: lookup against live transaction"); diff --git a/contrib/dlz/example/dlz_example.c b/contrib/dlz/example/dlz_example.c index 969334fd83..daf9a40457 100644 --- a/contrib/dlz/example/dlz_example.c +++ b/contrib/dlz/example/dlz_example.c @@ -428,8 +428,7 @@ dlz_lookup(const char *zone, const char *name, void *dbdata, * If the DLZ only operates on 'live' data, then version * wouldn't necessarily be needed. */ - if (clientinfo != NULL && clientinfo->version >= DNS_CLIENTINFO_VERSION) - { + if (clientinfo != NULL && clientinfo->version >= 2) { dbversion = clientinfo->dbversion; if (dbversion != NULL && *(bool *)dbversion) { state->log(ISC_LOG_INFO, "dlz_example: lookup against " @@ -439,6 +438,7 @@ dlz_lookup(const char *zone, const char *name, void *dbdata, } if (strcmp(name, "source-addr") == 0) { + char ecsbuf[100] = "not supported"; strcpy(buf, "unknown"); if (methods != NULL && methods->sourceip != NULL && (methods->version - methods->age <= @@ -448,12 +448,25 @@ dlz_lookup(const char *zone, const char *name, void *dbdata, methods->sourceip(clientinfo, &src); fmt_address(src, buf, sizeof(buf)); } + if (clientinfo != NULL && clientinfo->version >= 3) { + if (clientinfo->ecs.addr.family != AF_UNSPEC) { + dns_ecs_format(&clientinfo->ecs, ecsbuf, + sizeof(ecsbuf)); + } else { + strcpy(ecsbuf, "not present"); + } + } + i = strlen(buf); + snprintf(buf + i, sizeof(buf) - i - 1, " ECS %s", ecsbuf); state->log(ISC_LOG_INFO, "dlz_example: lookup connection from: %s", buf); found = true; result = state->putrr(lookup, "TXT", 0, buf); + /* We could also generate a CNAME RR: + snprintf(buf, sizeof(buf), "%s.redirect.example.", ecsbuf); + result = state->putrr(lookup, "CNAME", 0, buf); */ if (result != ISC_R_SUCCESS) { return (result); } diff --git a/contrib/dlz/modules/include/dlz_minimal.h b/contrib/dlz/modules/include/dlz_minimal.h index 24447844ef..a820527cd4 100644 --- a/contrib/dlz/modules/include/dlz_minimal.h +++ b/contrib/dlz/modules/include/dlz_minimal.h @@ -28,6 +28,8 @@ #include #include +#include + #include #include #include @@ -35,8 +37,7 @@ #include #include -typedef unsigned int isc_result_t; -typedef uint32_t dns_ttl_t; +typedef uint32_t dns_ttl_t; /* * Define DLZ_DLOPEN_VERSION to different values to use older versions @@ -88,8 +89,6 @@ typedef uint32_t dns_ttl_t; /* opaque structures */ typedef void *dns_sdlzlookup_t; typedef void *dns_sdlzallnodes_t; -typedef void *dns_view_t; -typedef void *dns_dlzdb_t; #if DLZ_DLOPEN_VERSION > 1 /* @@ -107,11 +106,12 @@ typedef struct isc_sockaddr { void *link; } isc_sockaddr_t; -#define DNS_CLIENTINFO_VERSION 2 +#define DNS_CLIENTINFO_VERSION 3 typedef struct dns_clientinfo { - uint16_t version; - void *data; - void *dbversion; + uint16_t version; + void *data; + void *dbversion; + dns_ecs_t ecs; } dns_clientinfo_t; typedef isc_result_t (*dns_clientinfo_sourceip_t)(dns_clientinfo_t *client, diff --git a/contrib/dlz/modules/mysqldyn/dlz_mysqldyn_mod.c b/contrib/dlz/modules/mysqldyn/dlz_mysqldyn_mod.c index 97ff486e5d..d0204c6b99 100644 --- a/contrib/dlz/modules/mysqldyn/dlz_mysqldyn_mod.c +++ b/contrib/dlz/modules/mysqldyn/dlz_mysqldyn_mod.c @@ -1128,8 +1128,7 @@ dlz_lookup(const char *zone, const char *name, void *dbdata, } /* Are we okay to try to find the txn version? */ - if (clientinfo != NULL && clientinfo->version >= DNS_CLIENTINFO_VERSION) - { + if (clientinfo != NULL && clientinfo->version >= 2) { txn = (mysql_transaction_t *)clientinfo->dbversion; if (txn != NULL && validate_txn(state, txn) == ISC_R_SUCCESS) { dbi = txn->dbi;