mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-02 07:35:26 +00:00
extend DLZ interface and example with ECS support
Apparently we forgot about DLZ when updating DNS_CLIENTINFO_VERSION constant for ECS, which is at value "3" since ECS was introduced. The code in example drivers and tests now hardcodes version numbers 2 (without ECS) and 3 (with ECS) depending on what a given code path requires.
This commit is contained in:
@@ -480,8 +480,7 @@ dlz_lookup(const char *zone, const char *name, void *dbdata,
|
|||||||
* If the DLZ only operates on 'live' data, then version
|
* If the DLZ only operates on 'live' data, then version
|
||||||
* wouldn't necessarily be needed.
|
* wouldn't necessarily be needed.
|
||||||
*/
|
*/
|
||||||
if (clientinfo != NULL && clientinfo->version >= DNS_CLIENTINFO_VERSION)
|
if (clientinfo != NULL && clientinfo->version >= 2) {
|
||||||
{
|
|
||||||
dbversion = clientinfo->dbversion;
|
dbversion = clientinfo->dbversion;
|
||||||
if (dbversion != NULL && *(bool *)dbversion) {
|
if (dbversion != NULL && *(bool *)dbversion) {
|
||||||
loginfo("dlz_example: lookup against live transaction");
|
loginfo("dlz_example: lookup against live transaction");
|
||||||
|
@@ -428,8 +428,7 @@ dlz_lookup(const char *zone, const char *name, void *dbdata,
|
|||||||
* If the DLZ only operates on 'live' data, then version
|
* If the DLZ only operates on 'live' data, then version
|
||||||
* wouldn't necessarily be needed.
|
* wouldn't necessarily be needed.
|
||||||
*/
|
*/
|
||||||
if (clientinfo != NULL && clientinfo->version >= DNS_CLIENTINFO_VERSION)
|
if (clientinfo != NULL && clientinfo->version >= 2) {
|
||||||
{
|
|
||||||
dbversion = clientinfo->dbversion;
|
dbversion = clientinfo->dbversion;
|
||||||
if (dbversion != NULL && *(bool *)dbversion) {
|
if (dbversion != NULL && *(bool *)dbversion) {
|
||||||
state->log(ISC_LOG_INFO, "dlz_example: lookup against "
|
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) {
|
if (strcmp(name, "source-addr") == 0) {
|
||||||
|
char ecsbuf[100] = "not supported";
|
||||||
strcpy(buf, "unknown");
|
strcpy(buf, "unknown");
|
||||||
if (methods != NULL && methods->sourceip != NULL &&
|
if (methods != NULL && methods->sourceip != NULL &&
|
||||||
(methods->version - methods->age <=
|
(methods->version - methods->age <=
|
||||||
@@ -448,12 +448,25 @@ dlz_lookup(const char *zone, const char *name, void *dbdata,
|
|||||||
methods->sourceip(clientinfo, &src);
|
methods->sourceip(clientinfo, &src);
|
||||||
fmt_address(src, buf, sizeof(buf));
|
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,
|
state->log(ISC_LOG_INFO,
|
||||||
"dlz_example: lookup connection from: %s", buf);
|
"dlz_example: lookup connection from: %s", buf);
|
||||||
|
|
||||||
found = true;
|
found = true;
|
||||||
result = state->putrr(lookup, "TXT", 0, buf);
|
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) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
@@ -28,6 +28,8 @@
|
|||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include <dns/ecs.h>
|
||||||
|
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
@@ -35,7 +37,6 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
|
|
||||||
typedef unsigned int isc_result_t;
|
|
||||||
typedef uint32_t dns_ttl_t;
|
typedef uint32_t dns_ttl_t;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -88,8 +89,6 @@ typedef uint32_t dns_ttl_t;
|
|||||||
/* opaque structures */
|
/* opaque structures */
|
||||||
typedef void *dns_sdlzlookup_t;
|
typedef void *dns_sdlzlookup_t;
|
||||||
typedef void *dns_sdlzallnodes_t;
|
typedef void *dns_sdlzallnodes_t;
|
||||||
typedef void *dns_view_t;
|
|
||||||
typedef void *dns_dlzdb_t;
|
|
||||||
|
|
||||||
#if DLZ_DLOPEN_VERSION > 1
|
#if DLZ_DLOPEN_VERSION > 1
|
||||||
/*
|
/*
|
||||||
@@ -107,11 +106,12 @@ typedef struct isc_sockaddr {
|
|||||||
void *link;
|
void *link;
|
||||||
} isc_sockaddr_t;
|
} isc_sockaddr_t;
|
||||||
|
|
||||||
#define DNS_CLIENTINFO_VERSION 2
|
#define DNS_CLIENTINFO_VERSION 3
|
||||||
typedef struct dns_clientinfo {
|
typedef struct dns_clientinfo {
|
||||||
uint16_t version;
|
uint16_t version;
|
||||||
void *data;
|
void *data;
|
||||||
void *dbversion;
|
void *dbversion;
|
||||||
|
dns_ecs_t ecs;
|
||||||
} dns_clientinfo_t;
|
} dns_clientinfo_t;
|
||||||
|
|
||||||
typedef isc_result_t (*dns_clientinfo_sourceip_t)(dns_clientinfo_t *client,
|
typedef isc_result_t (*dns_clientinfo_sourceip_t)(dns_clientinfo_t *client,
|
||||||
|
@@ -1128,8 +1128,7 @@ dlz_lookup(const char *zone, const char *name, void *dbdata,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Are we okay to try to find the txn version? */
|
/* 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;
|
txn = (mysql_transaction_t *)clientinfo->dbversion;
|
||||||
if (txn != NULL && validate_txn(state, txn) == ISC_R_SUCCESS) {
|
if (txn != NULL && validate_txn(state, txn) == ISC_R_SUCCESS) {
|
||||||
dbi = txn->dbi;
|
dbi = txn->dbi;
|
||||||
|
Reference in New Issue
Block a user