mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 22:15:20 +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
|
||||
* 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");
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -28,6 +28,8 @@
|
||||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <dns/ecs.h>
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <net/if.h>
|
||||
#include <netinet/in.h>
|
||||
@@ -35,8 +37,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
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,
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user