Commit 67adc03e authored by Evan Hunt's avatar Evan Hunt

[master] add DSCP support

3535.	[func]		Add support for setting Differentiated Services Code
			Point (DSCP) values in named.  Most configuration
			options which take a "port" option (e.g.,
			listen-on, forwarders, also-notify, masters,
			notify-source, etc) can now also take a "dscp"
			option specifying a code point for use with
			outgoing traffic, if supported by the underlying
			OS. [RT #27596]
parent bbb3705e
3536. [func] Add support for setting Differentiated Services Code
Point (DSCP) values in named. Most configuration
options which take a "port" option (e.g.,
listen-on, forwarders, also-notify, masters,
notify-source, etc) can now also take a "dscp"
option specifying a code point for use with
outgoing traffic, if supported by the underlying
OS. [RT #27596]
3535. [bug] Minor win32 cleanups. [RT #32962] 3535. [bug] Minor win32 cleanups. [RT #32962]
3534. [bug] Extra text after an embedded NULL was ignored when 3534. [bug] Extra text after an embedded NULL was ignored when
......
...@@ -827,6 +827,7 @@ client_sendpkg(ns_client_t *client, isc_buffer_t *buffer) { ...@@ -827,6 +827,7 @@ client_sendpkg(ns_client_t *client, isc_buffer_t *buffer) {
isc_netaddr_t netaddr; isc_netaddr_t netaddr;
int match; int match;
unsigned int sockflags = ISC_SOCKFLAG_IMMEDIATE; unsigned int sockflags = ISC_SOCKFLAG_IMMEDIATE;
isc_dscp_t dispdscp = -1;
if (TCP_CLIENT(client)) { if (TCP_CLIENT(client)) {
socket = client->tcpsocket; socket = client->tcpsocket;
...@@ -852,6 +853,20 @@ client_sendpkg(ns_client_t *client, isc_buffer_t *buffer) { ...@@ -852,6 +853,20 @@ client_sendpkg(ns_client_t *client, isc_buffer_t *buffer) {
else else
pktinfo = NULL; pktinfo = NULL;
if (client->dispatch != NULL) {
dispdscp = dns_dispatch_getdscp(client->dispatch);
if (dispdscp != -1)
client->dscp = dispdscp;
}
if (client->dscp == -1) {
client->sendevent->attributes &= ~ISC_SOCKEVENTATTR_DSCP;
client->sendevent->dscp = 0;
} else {
client->sendevent->attributes |= ISC_SOCKEVENTATTR_DSCP;
client->sendevent->dscp = client->dscp;
}
isc_buffer_usedregion(buffer, &r); isc_buffer_usedregion(buffer, &r);
CTRACE("sendto"); CTRACE("sendto");
...@@ -1533,6 +1548,13 @@ client_request(isc_task_t *task, isc_event_t *event) { ...@@ -1533,6 +1548,13 @@ client_request(isc_task_t *task, isc_event_t *event) {
client->peeraddr = sevent->address; client->peeraddr = sevent->address;
client->peeraddr_valid = ISC_TRUE; client->peeraddr_valid = ISC_TRUE;
} }
if ((sevent->attributes & ISC_SOCKEVENTATTR_DSCP) != 0) {
ns_client_log(client, NS_LOGCATEGORY_CLIENT,
NS_LOGMODULE_CLIENT, ISC_LOG_DEBUG(90),
"received DSCP %d", sevent->dscp);
if (client->dscp == -1)
client->dscp = sevent->dscp;
}
if ((sevent->attributes & ISC_SOCKEVENTATTR_PKTINFO) != 0) { if ((sevent->attributes & ISC_SOCKEVENTATTR_PKTINFO) != 0) {
client->attributes |= NS_CLIENTATTR_PKTINFO; client->attributes |= NS_CLIENTATTR_PKTINFO;
client->pktinfo = sevent->pktinfo; client->pktinfo = sevent->pktinfo;
...@@ -2196,11 +2218,9 @@ client_create(ns_clientmgr_t *manager, ns_client_t **clientp) { ...@@ -2196,11 +2218,9 @@ client_create(ns_clientmgr_t *manager, ns_client_t **clientp) {
/* XXXRTH Hardwired constants */ /* XXXRTH Hardwired constants */
client->sendevent = (isc_socketevent_t *) client->sendevent = isc_socket_socketevent(client->mctx, client,
isc_event_allocate(client->mctx, client, ISC_SOCKEVENT_SENDDONE,
ISC_SOCKEVENT_SENDDONE, client_senddone, client);
client_senddone, client,
sizeof(isc_socketevent_t));
if (client->sendevent == NULL) { if (client->sendevent == NULL) {
result = ISC_R_NOMEMORY; result = ISC_R_NOMEMORY;
goto cleanup_message; goto cleanup_message;
...@@ -2212,11 +2232,9 @@ client_create(ns_clientmgr_t *manager, ns_client_t **clientp) { ...@@ -2212,11 +2232,9 @@ client_create(ns_clientmgr_t *manager, ns_client_t **clientp) {
goto cleanup_sendevent; goto cleanup_sendevent;
} }
client->recvevent = (isc_socketevent_t *) client->recvevent = isc_socket_socketevent(client->mctx, client,
isc_event_allocate(client->mctx, client, ISC_SOCKEVENT_RECVDONE,
ISC_SOCKEVENT_RECVDONE, client_request, client);
client_request, client,
sizeof(isc_socketevent_t));
if (client->recvevent == NULL) { if (client->recvevent == NULL) {
result = ISC_R_NOMEMORY; result = ISC_R_NOMEMORY;
goto cleanup_recvbuf; goto cleanup_recvbuf;
...@@ -2243,6 +2261,7 @@ client_create(ns_clientmgr_t *manager, ns_client_t **clientp) { ...@@ -2243,6 +2261,7 @@ client_create(ns_clientmgr_t *manager, ns_client_t **clientp) {
client->tcpbuf = NULL; client->tcpbuf = NULL;
client->opt = NULL; client->opt = NULL;
client->udpsize = 512; client->udpsize = 512;
client->dscp = -1;
client->extflags = 0; client->extflags = 0;
client->ednsversion = -1; client->ednsversion = -1;
client->next = NULL; client->next = NULL;
...@@ -2737,6 +2756,8 @@ get_client(ns_clientmgr_t *manager, ns_interface_t *ifp, ...@@ -2737,6 +2756,8 @@ get_client(ns_clientmgr_t *manager, ns_interface_t *ifp,
client->state = NS_CLIENTSTATE_READY; client->state = NS_CLIENTSTATE_READY;
INSIST(client->recursionquota == NULL); INSIST(client->recursionquota == NULL);
client->dscp = ifp->dscp;
if (tcp) { if (tcp) {
client->attributes |= NS_CLIENTATTR_TCP; client->attributes |= NS_CLIENTATTR_TCP;
isc_socket_attach(ifp->tcpsocket, isc_socket_attach(ifp->tcpsocket,
......
...@@ -64,6 +64,7 @@ options {\n\ ...@@ -64,6 +64,7 @@ options {\n\
session-keyalg hmac-sha256;\n\ session-keyalg hmac-sha256;\n\
deallocate-on-exit true;\n\ deallocate-on-exit true;\n\
# directory <none>\n\ # directory <none>\n\
dscp 0;\n\
dump-file \"named_dump.db\";\n\ dump-file \"named_dump.db\";\n\
fake-iquery no;\n\ fake-iquery no;\n\
has-old-clients false;\n\ has-old-clients false;\n\
...@@ -279,7 +280,9 @@ ns_config_parsedefaults(cfg_parser_t *parser, cfg_obj_t **conf) { ...@@ -279,7 +280,9 @@ ns_config_parsedefaults(cfg_parser_t *parser, cfg_obj_t **conf) {
} }
isc_result_t isc_result_t
ns_config_get(const cfg_obj_t **maps, const char *name, const cfg_obj_t **obj) { ns_config_get(cfg_obj_t const * const *maps, const char *name,
const cfg_obj_t **obj)
{
int i; int i;
for (i = 0;; i++) { for (i = 0;; i++) {
...@@ -402,17 +405,20 @@ ns_config_getzonetype(const cfg_obj_t *zonetypeobj) { ...@@ -402,17 +405,20 @@ ns_config_getzonetype(const cfg_obj_t *zonetypeobj) {
isc_result_t isc_result_t
ns_config_getiplist(const cfg_obj_t *config, const cfg_obj_t *list, ns_config_getiplist(const cfg_obj_t *config, const cfg_obj_t *list,
in_port_t defport, isc_mem_t *mctx, in_port_t defport, isc_mem_t *mctx,
isc_sockaddr_t **addrsp, isc_uint32_t *countp) isc_sockaddr_t **addrsp, isc_dscp_t **dscpsp,
isc_uint32_t *countp)
{ {
int count, i = 0; int count, i = 0;
const cfg_obj_t *addrlist; const cfg_obj_t *addrlist;
const cfg_obj_t *portobj; const cfg_obj_t *portobj, *dscpobj;
const cfg_listelt_t *element; const cfg_listelt_t *element;
isc_sockaddr_t *addrs; isc_sockaddr_t *addrs;
in_port_t port; in_port_t port;
isc_dscp_t dscp = -1, *dscps;
isc_result_t result; isc_result_t result;
INSIST(addrsp != NULL && *addrsp == NULL); INSIST(addrsp != NULL && *addrsp == NULL);
INSIST(dscpsp == NULL || *dscpsp == NULL);
INSIST(countp != NULL); INSIST(countp != NULL);
addrlist = cfg_tuple_get(list, "addresses"); addrlist = cfg_tuple_get(list, "addresses");
...@@ -435,6 +441,23 @@ ns_config_getiplist(const cfg_obj_t *config, const cfg_obj_t *list, ...@@ -435,6 +441,23 @@ ns_config_getiplist(const cfg_obj_t *config, const cfg_obj_t *list,
return (result); return (result);
} }
if (dscpsp != NULL) {
dscps = isc_mem_get(mctx, count * sizeof(isc_dscp_t));
if (dscps == NULL)
return (ISC_R_NOMEMORY);
dscpobj = cfg_tuple_get(list, "dscp");
if (dscpobj != NULL && cfg_obj_isuint32(dscpobj)) {
if (cfg_obj_asuint32(dscpobj) > 63) {
cfg_obj_log(dscpobj, ns_g_lctx, ISC_LOG_ERROR,
"dscp value '%u' is out of range",
cfg_obj_asuint32(dscpobj));
return (ISC_R_RANGE);
}
dscp = (isc_dscp_t)cfg_obj_asuint32(dscpobj);
}
}
addrs = isc_mem_get(mctx, count * sizeof(isc_sockaddr_t)); addrs = isc_mem_get(mctx, count * sizeof(isc_sockaddr_t));
if (addrs == NULL) if (addrs == NULL)
return (ISC_R_NOMEMORY); return (ISC_R_NOMEMORY);
...@@ -443,8 +466,17 @@ ns_config_getiplist(const cfg_obj_t *config, const cfg_obj_t *list, ...@@ -443,8 +466,17 @@ ns_config_getiplist(const cfg_obj_t *config, const cfg_obj_t *list,
element != NULL; element != NULL;
element = cfg_list_next(element), i++) element = cfg_list_next(element), i++)
{ {
const cfg_obj_t *addr;
INSIST(i < count); INSIST(i < count);
addrs[i] = *cfg_obj_assockaddr(cfg_listelt_value(element)); addr = cfg_listelt_value(element);
addrs[i] = *cfg_obj_assockaddr(addr);
if (dscpsp != NULL) {
isc_dscp_t innerdscp;
innerdscp = cfg_obj_getdscp(addr);
if (innerdscp == -1)
innerdscp = dscp;
dscps[i] = innerdscp;
}
if (isc_sockaddr_getport(&addrs[i]) == 0) if (isc_sockaddr_getport(&addrs[i]) == 0)
isc_sockaddr_setport(&addrs[i], port); isc_sockaddr_setport(&addrs[i], port);
} }
...@@ -453,17 +485,26 @@ ns_config_getiplist(const cfg_obj_t *config, const cfg_obj_t *list, ...@@ -453,17 +485,26 @@ ns_config_getiplist(const cfg_obj_t *config, const cfg_obj_t *list,
*addrsp = addrs; *addrsp = addrs;
*countp = count; *countp = count;
if (dscpsp != NULL)
*dscpsp = dscps;
return (ISC_R_SUCCESS); return (ISC_R_SUCCESS);
} }
void void
ns_config_putiplist(isc_mem_t *mctx, isc_sockaddr_t **addrsp, ns_config_putiplist(isc_mem_t *mctx, isc_sockaddr_t **addrsp,
isc_uint32_t count) isc_dscp_t **dscpsp, isc_uint32_t count)
{ {
INSIST(addrsp != NULL && *addrsp != NULL); INSIST(addrsp != NULL && *addrsp != NULL);
INSIST(dscpsp == NULL || *dscpsp != NULL);
isc_mem_put(mctx, *addrsp, count * sizeof(isc_sockaddr_t)); isc_mem_put(mctx, *addrsp, count * sizeof(isc_sockaddr_t));
*addrsp = NULL; *addrsp = NULL;
if (dscpsp != NULL) {
isc_mem_put(mctx, *dscpsp, count * sizeof(isc_dscp_t));
*dscpsp = NULL;
}
} }
static isc_result_t static isc_result_t
...@@ -497,32 +538,40 @@ get_masters_def(const cfg_obj_t *cctx, const char *name, ...@@ -497,32 +538,40 @@ get_masters_def(const cfg_obj_t *cctx, const char *name,
isc_result_t isc_result_t
ns_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list, ns_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list,
isc_mem_t *mctx, isc_sockaddr_t **addrsp, isc_mem_t *mctx, isc_sockaddr_t **addrsp,
dns_name_t ***keysp, isc_uint32_t *countp) isc_dscp_t **dscpsp, dns_name_t ***keysp,
isc_uint32_t *countp)
{ {
isc_uint32_t addrcount = 0, keycount = 0, i = 0; isc_uint32_t addrcount = 0, dscpcount = 0, keycount = 0, i = 0;
isc_uint32_t listcount = 0, l = 0, j; isc_uint32_t listcount = 0, l = 0, j;
isc_uint32_t stackcount = 0, pushed = 0; isc_uint32_t stackcount = 0, pushed = 0;
isc_result_t result; isc_result_t result;
const cfg_listelt_t *element; const cfg_listelt_t *element;
const cfg_obj_t *addrlist; const cfg_obj_t *addrlist;
const cfg_obj_t *portobj; const cfg_obj_t *portobj;
const cfg_obj_t *dscpobj;
in_port_t port; in_port_t port;
isc_dscp_t dscp;
dns_fixedname_t fname; dns_fixedname_t fname;
isc_sockaddr_t *addrs = NULL; isc_sockaddr_t *addrs = NULL;
isc_dscp_t *dscps = NULL;
dns_name_t **keys = NULL; dns_name_t **keys = NULL;
struct { const char *name; } *lists = NULL; struct { const char *name; } *lists = NULL;
struct { struct {
const cfg_listelt_t *element; const cfg_listelt_t *element;
in_port_t port; in_port_t port;
isc_dscp_t dscp;
} *stack = NULL; } *stack = NULL;
REQUIRE(addrsp != NULL && *addrsp == NULL); REQUIRE(addrsp != NULL && *addrsp == NULL);
REQUIRE(dscpsp != NULL && *dscpsp == NULL);
REQUIRE(keysp != NULL && *keysp == NULL); REQUIRE(keysp != NULL && *keysp == NULL);
REQUIRE(countp != NULL); REQUIRE(countp != NULL);
newlist: newlist:
addrlist = cfg_tuple_get(list, "addresses"); addrlist = cfg_tuple_get(list, "addresses");
portobj = cfg_tuple_get(list, "port"); portobj = cfg_tuple_get(list, "port");
dscpobj = cfg_tuple_get(list, "dscp");
if (cfg_obj_isuint32(portobj)) { if (cfg_obj_isuint32(portobj)) {
isc_uint32_t val = cfg_obj_asuint32(portobj); isc_uint32_t val = cfg_obj_asuint32(portobj);
if (val > ISC_UINT16_MAX) { if (val > ISC_UINT16_MAX) {
...@@ -538,6 +587,20 @@ ns_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list, ...@@ -538,6 +587,20 @@ ns_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list,
goto cleanup; goto cleanup;
} }
if (dscpobj != NULL && cfg_obj_isuint32(dscpobj)) {
if (cfg_obj_asuint32(dscpobj) > 63) {
cfg_obj_log(dscpobj, ns_g_lctx, ISC_LOG_ERROR,
"dscp value '%u' is out of range",
cfg_obj_asuint32(dscpobj));
return (ISC_R_RANGE);
}
dscp = (isc_dscp_t)cfg_obj_asuint32(dscpobj);
} else {
result = ns_config_getdscp(config, &dscp);
if (result != ISC_R_SUCCESS)
goto cleanup;
}
result = ISC_R_NOMEMORY; result = ISC_R_NOMEMORY;
element = cfg_list_first(addrlist); element = cfg_list_first(addrlist);
...@@ -618,6 +681,7 @@ ns_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list, ...@@ -618,6 +681,7 @@ ns_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list,
*/ */
stack[pushed].element = cfg_list_next(element); stack[pushed].element = cfg_list_next(element);
stack[pushed].port = port; stack[pushed].port = port;
stack[pushed].dscp = dscp;
pushed++; pushed++;
goto newlist; goto newlist;
} }
...@@ -639,6 +703,18 @@ ns_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list, ...@@ -639,6 +703,18 @@ ns_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list,
addrs = new; addrs = new;
addrcount = newlen; addrcount = newlen;
newsize = newlen * sizeof(isc_dscp_t);
oldsize = dscpcount * sizeof(isc_dscp_t);
new = isc_mem_get(mctx, newsize);
if (new == NULL)
goto cleanup;
if (dscpcount != 0) {
memcpy(new, dscps, oldsize);
isc_mem_put(mctx, dscps, oldsize);
}
dscps = new;
dscpcount = newlen;
newsize = newlen * sizeof(dns_name_t *); newsize = newlen * sizeof(dns_name_t *);
oldsize = keycount * sizeof(dns_name_t *); oldsize = keycount * sizeof(dns_name_t *);
new = isc_mem_get(mctx, newsize); new = isc_mem_get(mctx, newsize);
...@@ -655,6 +731,9 @@ ns_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list, ...@@ -655,6 +731,9 @@ ns_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list,
addrs[i] = *cfg_obj_assockaddr(addr); addrs[i] = *cfg_obj_assockaddr(addr);
if (isc_sockaddr_getport(&addrs[i]) == 0) if (isc_sockaddr_getport(&addrs[i]) == 0)
isc_sockaddr_setport(&addrs[i], port); isc_sockaddr_setport(&addrs[i], port);
dscps[i] = cfg_obj_getdscp(addr);
if (dscps[i] == -1)
dscps[i] = dscp;
keys[i] = NULL; keys[i] = NULL;
i++; /* Increment here so that cleanup on error works. */ i++; /* Increment here so that cleanup on error works. */
if (!cfg_obj_isstring(key)) if (!cfg_obj_isstring(key))
...@@ -681,6 +760,7 @@ ns_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list, ...@@ -681,6 +760,7 @@ ns_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list,
pushed--; pushed--;
element = stack[pushed].element; element = stack[pushed].element;
port = stack[pushed].port; port = stack[pushed].port;
dscp = stack[pushed].dscp;
goto resume; goto resume;
} }
if (i < addrcount) { if (i < addrcount) {
...@@ -700,6 +780,19 @@ ns_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list, ...@@ -700,6 +780,19 @@ ns_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list,
addrs = new; addrs = new;
addrcount = i; addrcount = i;
newsize = i * sizeof(isc_dscp_t);
oldsize = dscpcount * sizeof(isc_dscp_t);
if (i != 0) {
new = isc_mem_get(mctx, newsize);
if (new == NULL)
goto cleanup;
memcpy(new, dscps, newsize);
} else
new = NULL;
isc_mem_put(mctx, dscps, oldsize);
dscps = new;
dscpcount = i;
newsize = i * sizeof(dns_name_t *); newsize = i * sizeof(dns_name_t *);
oldsize = keycount * sizeof(dns_name_t *); oldsize = keycount * sizeof(dns_name_t *);
if (i != 0) { if (i != 0) {
...@@ -722,6 +815,7 @@ ns_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list, ...@@ -722,6 +815,7 @@ ns_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list,
INSIST(keycount == addrcount); INSIST(keycount == addrcount);
*addrsp = addrs; *addrsp = addrs;
*dscpsp = dscps;
*keysp = keys; *keysp = keys;
*countp = addrcount; *countp = addrcount;
...@@ -730,6 +824,8 @@ ns_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list, ...@@ -730,6 +824,8 @@ ns_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list,
cleanup: cleanup:
if (addrs != NULL) if (addrs != NULL)
isc_mem_put(mctx, addrs, addrcount * sizeof(isc_sockaddr_t)); isc_mem_put(mctx, addrs, addrcount * sizeof(isc_sockaddr_t));
if (dscps != NULL)
isc_mem_put(mctx, dscps, dscpcount * sizeof(isc_dscp_t));
if (keys != NULL) { if (keys != NULL) {
for (j = 0; j < i; j++) { for (j = 0; j < i; j++) {
if (keys[j] == NULL) if (keys[j] == NULL)
...@@ -749,14 +845,21 @@ ns_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list, ...@@ -749,14 +845,21 @@ ns_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list,
void void
ns_config_putipandkeylist(isc_mem_t *mctx, isc_sockaddr_t **addrsp, ns_config_putipandkeylist(isc_mem_t *mctx, isc_sockaddr_t **addrsp,
dns_name_t ***keysp, isc_uint32_t count) isc_dscp_t **dscpsp, dns_name_t ***keysp,
isc_uint32_t count)
{ {
unsigned int i; unsigned int i;
dns_name_t **keys = *keysp; dns_name_t **keys;
INSIST(addrsp != NULL && *addrsp != NULL); REQUIRE(addrsp != NULL && *addrsp != NULL);
REQUIRE(dscpsp == NULL || *dscpsp != NULL);
REQUIRE(keysp != NULL && *keysp != NULL);
keys = *keysp;
isc_mem_put(mctx, *addrsp, count * sizeof(isc_sockaddr_t)); isc_mem_put(mctx, *addrsp, count * sizeof(isc_sockaddr_t));
if (dscpsp != NULL)
isc_mem_put(mctx, *dscpsp, count * sizeof(isc_dscp_t));
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
if (keys[i] == NULL) if (keys[i] == NULL)
continue; continue;
...@@ -766,6 +869,8 @@ ns_config_putipandkeylist(isc_mem_t *mctx, isc_sockaddr_t **addrsp, ...@@ -766,6 +869,8 @@ ns_config_putipandkeylist(isc_mem_t *mctx, isc_sockaddr_t **addrsp,
} }
isc_mem_put(mctx, *keysp, count * sizeof(dns_name_t *)); isc_mem_put(mctx, *keysp, count * sizeof(dns_name_t *));
*addrsp = NULL; *addrsp = NULL;
if (dscpsp != NULL)
*dscpsp = NULL;
*keysp = NULL; *keysp = NULL;
} }
...@@ -796,6 +901,35 @@ ns_config_getport(const cfg_obj_t *config, in_port_t *portp) { ...@@ -796,6 +901,35 @@ ns_config_getport(const cfg_obj_t *config, in_port_t *portp) {
return (ISC_R_SUCCESS); return (ISC_R_SUCCESS);
} }
isc_result_t
ns_config_getdscp(const cfg_obj_t *config, isc_dscp_t *dscpp) {
const cfg_obj_t *maps[2];
const cfg_obj_t *options = NULL;
const cfg_obj_t *dscpobj = NULL;
isc_result_t result;
int i;
(void)cfg_map_get(config, "options", &options);
i = 0;
if (options != NULL)
maps[i++] = options;
maps[i] = NULL;
result = ns_config_get(maps, "dscp", &dscpobj);
if (dscpobj == NULL) {
*dscpp = -1;
return (ISC_R_SUCCESS);
}
if (cfg_obj_asuint32(dscpobj) >= 64) {
cfg_obj_log(dscpobj, ns_g_lctx, ISC_LOG_ERROR,
"dscp '%u' out of range",
cfg_obj_asuint32(dscpobj));
return (ISC_R_RANGE);
}
*dscpp = (isc_dscp_t)cfg_obj_asuint32(dscpobj);
return (ISC_R_SUCCESS);
}
struct keyalgorithms { struct keyalgorithms {
const char *str; const char *str;
enum { hmacnone, hmacmd5, hmacsha1, hmacsha224, enum { hmacnone, hmacmd5, hmacsha1, hmacsha224,
......
...@@ -141,6 +141,7 @@ struct ns_client { ...@@ -141,6 +141,7 @@ struct ns_client {
isc_boolean_t peeraddr_valid; isc_boolean_t peeraddr_valid;
isc_netaddr_t destaddr; isc_netaddr_t destaddr;
struct in6_pktinfo pktinfo; struct in6_pktinfo pktinfo;
isc_dscp_t dscp;
isc_event_t ctlevent; isc_event_t ctlevent;
#ifdef ALLOW_FILTER_AAAA #ifdef ALLOW_FILTER_AAAA
dns_aaaa_t filter_aaaa; dns_aaaa_t filter_aaaa;
......
...@@ -31,7 +31,8 @@ isc_result_t ...@@ -31,7 +31,8 @@ isc_result_t
ns_config_parsedefaults(cfg_parser_t *parser, cfg_obj_t **conf); ns_config_parsedefaults(cfg_parser_t *parser, cfg_obj_t **conf);
isc_result_t isc_result_t
ns_config_get(const cfg_obj_t **maps, const char* name, const cfg_obj_t **obj); ns_config_get(cfg_obj_t const * const *maps, const char* name,
const cfg_obj_t **obj);