2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-22 01:59:26 +00:00

remove all references to isc_socket and related types

Removed socket.c, socket.h, and all references to isc_socket_t,
isc_socketmgr_t, isc_sockevent_t, etc.
This commit is contained in:
Evan Hunt 2021-10-03 00:27:52 -07:00
parent 68e8b19ddc
commit a55589f881
62 changed files with 114 additions and 7438 deletions

View File

@ -25,7 +25,6 @@
#include <isc/mem.h>
#include <isc/print.h>
#include <isc/result.h>
#include <isc/socket.h>
#include <isc/string.h>
#include <isc/task.h>
#include <isc/timer.h>

View File

@ -37,7 +37,6 @@
#include <isc/print.h>
#include <isc/result.h>
#include <isc/sockaddr.h>
#include <isc/socket.h>
#include <isc/string.h>
#include <isc/task.h>
#include <isc/timer.h>
@ -1742,7 +1741,7 @@ main(int argc, char *argv[]) {
CHECK(isc_appctx_create(mctx, &actx));
isc_managers_create(mctx, 1, 0, 0, &netmgr, &taskmgr, &timermgr, NULL);
isc_managers_create(mctx, 1, 0, &netmgr, &taskmgr, &timermgr);
parse_args(argc, argv);
@ -1844,7 +1843,7 @@ cleanup:
dns_client_detach(&client);
}
isc_managers_destroy(&netmgr, &taskmgr, &timermgr, NULL);
isc_managers_destroy(&netmgr, &taskmgr, &timermgr);
if (actx != NULL) {
isc_appctx_destroy(&actx);

View File

@ -26,6 +26,7 @@
#include <isc/result.h>
#include <isc/string.h>
#include <isc/task.h>
#include <isc/time.h>
#include <isc/util.h>
#include <dns/byaddr.h>

View File

@ -1356,7 +1356,7 @@ setup_libs(void) {
isc_log_setdebuglevel(lctx, 0);
isc_managers_create(mctx, 1, 0, 0, &netmgr, &taskmgr, NULL, NULL);
isc_managers_create(mctx, 1, 0, &netmgr, &taskmgr, NULL);
result = isc_task_create(taskmgr, 0, &global_task);
check_result(result, "isc_task_create");
@ -4248,7 +4248,7 @@ destroy_libs(void) {
isc_task_detach(&global_task);
}
isc_managers_destroy(&netmgr, &taskmgr, NULL, NULL);
isc_managers_destroy(&netmgr, &taskmgr, NULL);
LOCK_LOOKUP;
isc_refcount_destroy(&recvcount);

View File

@ -27,7 +27,7 @@
#include <isc/print.h>
#include <isc/refcount.h>
#include <isc/sockaddr.h>
#include <isc/socket.h>
#include <isc/time.h>
#include <dns/rdatalist.h>

View File

@ -3990,7 +3990,7 @@ main(int argc, char *argv[]) {
print_time(outfp);
print_version(outfp);
isc_managers_create(mctx, ntasks, 0, 0, &netmgr, &taskmgr, NULL, NULL);
isc_managers_create(mctx, ntasks, 0, &netmgr, &taskmgr, NULL);
main_task = NULL;
result = isc_task_create(taskmgr, 0, &main_task);
@ -4041,7 +4041,7 @@ main(int argc, char *argv[]) {
for (i = 0; i < (int)ntasks; i++) {
isc_task_detach(&tasks[i]);
}
isc_managers_destroy(&netmgr, &taskmgr, NULL, NULL);
isc_managers_destroy(&netmgr, &taskmgr, NULL);
isc_mem_put(mctx, tasks, ntasks * sizeof(isc_task_t *));
postsign();
TIME_NOW(&sign_finish);

View File

@ -11,7 +11,7 @@
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" version="1.0">
<xsl:output method="html" indent="yes" version="4.0"/>
<xsl:output method="html" indent="yes" version="5.0"/>
<xsl:template match="statistics[@version=&quot;3.11&quot;]">
<html>
<head>
@ -928,55 +928,6 @@
</xsl:for-each>
</xsl:for-each>
</xsl:if>
<xsl:if test="socketmgr/sockets/socket">
<h2>Network Status</h2>
<table class="netstat">
<tr>
<th>ID</th>
<th>Name</th>
<th>Type</th>
<th>References</th>
<th>LocalAddress</th>
<th>PeerAddress</th>
<th>State</th>
</tr>
<xsl:for-each select="socketmgr/sockets/socket">
<xsl:sort select="id"/>
<xsl:variable name="css-class12">
<xsl:choose>
<xsl:when test="position() mod 2 = 0">even</xsl:when>
<xsl:otherwise>odd</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<tr class="{$css-class12}">
<td>
<xsl:value-of select="id"/>
</td>
<td>
<xsl:value-of select="name"/>
</td>
<td>
<xsl:value-of select="type"/>
</td>
<td>
<xsl:value-of select="references"/>
</td>
<td>
<xsl:value-of select="local-address"/>
</td>
<td>
<xsl:value-of select="peer-address"/>
</td>
<td>
<xsl:for-each select="states">
<xsl:value-of select="."/>
</xsl:for-each>
</td>
</tr>
</xsl:for-each>
</table>
<br/>
</xsl:if>
<xsl:if test="taskmgr/thread-model/type">
<h2>Task Manager Configuration</h2>
<table class="counters">

View File

@ -59,22 +59,21 @@ EXTERN bool named_g_run_done INIT(false);
* for really short timers, another for client timers, and one
* for zone timers.
*/
EXTERN isc_timermgr_t *named_g_timermgr INIT(NULL);
EXTERN isc_socketmgr_t *named_g_socketmgr INIT(NULL);
EXTERN isc_nm_t *named_g_netmgr INIT(NULL);
EXTERN cfg_parser_t *named_g_parser INIT(NULL);
EXTERN cfg_parser_t *named_g_addparser INIT(NULL);
EXTERN const char *named_g_version INIT(PACKAGE_VERSION);
EXTERN const char *named_g_product INIT(PACKAGE_NAME);
EXTERN const char *named_g_description INIT(PACKAGE_DESCRIPTION);
EXTERN const char *named_g_srcid INIT(PACKAGE_SRCID);
EXTERN const char *named_g_configargs INIT(PACKAGE_CONFIGARGS);
EXTERN const char *named_g_builder INIT(PACKAGE_BUILDER);
EXTERN in_port_t named_g_port INIT(0);
EXTERN in_port_t named_g_tlsport INIT(0);
EXTERN in_port_t named_g_httpsport INIT(0);
EXTERN in_port_t named_g_httpport INIT(0);
EXTERN isc_dscp_t named_g_dscp INIT(-1);
EXTERN isc_timermgr_t *named_g_timermgr INIT(NULL);
EXTERN isc_nm_t *named_g_netmgr INIT(NULL);
EXTERN cfg_parser_t *named_g_parser INIT(NULL);
EXTERN cfg_parser_t *named_g_addparser INIT(NULL);
EXTERN const char *named_g_version INIT(PACKAGE_VERSION);
EXTERN const char *named_g_product INIT(PACKAGE_NAME);
EXTERN const char *named_g_description INIT(PACKAGE_DESCRIPTION);
EXTERN const char *named_g_srcid INIT(PACKAGE_SRCID);
EXTERN const char *named_g_configargs INIT(PACKAGE_CONFIGARGS);
EXTERN const char *named_g_builder INIT(PACKAGE_BUILDER);
EXTERN in_port_t named_g_port INIT(0);
EXTERN in_port_t named_g_tlsport INIT(0);
EXTERN in_port_t named_g_httpsport INIT(0);
EXTERN in_port_t named_g_httpport INIT(0);
EXTERN isc_dscp_t named_g_dscp INIT(-1);
EXTERN in_port_t named_g_http_listener_clients INIT(0);
EXTERN in_port_t named_g_http_streams_per_conn INIT(0);

View File

@ -120,7 +120,6 @@ static char absolute_conffile[PATH_MAX];
static char saved_command_line[4096] = { 0 };
static char ellipsis[5] = { 0 };
static char version[512];
static unsigned int maxsocks = 0;
static int maxudp = 0;
/*
@ -824,8 +823,7 @@ parse_command_line(int argc, char *argv[]) {
want_stats = true;
break;
case 'S':
maxsocks = parse_int(isc_commandline_argument,
"max number of sockets");
/* Formerly maxsocks */
break;
case 't':
/* XXXJAB should we make a copy? */
@ -897,7 +895,6 @@ parse_command_line(int argc, char *argv[]) {
static isc_result_t
create_managers(void) {
isc_result_t result;
unsigned int socks;
INSIST(named_g_cpus_detected > 0);
@ -921,30 +918,21 @@ create_managers(void) {
named_g_udpdisp == 1 ? "" : "s");
result = isc_managers_create(named_g_mctx, named_g_cpus,
0 /* quantum */, maxsocks, &named_g_netmgr,
&named_g_taskmgr, &named_g_timermgr,
&named_g_socketmgr);
0 /* quantum */, &named_g_netmgr,
&named_g_taskmgr, &named_g_timermgr);
if (result != ISC_R_SUCCESS) {
return (result);
}
isc_socketmgr_maxudp(named_g_socketmgr, maxudp);
isc_nm_maxudp(named_g_netmgr, maxudp);
result = isc_socketmgr_getmaxsockets(named_g_socketmgr, &socks);
if (result == ISC_R_SUCCESS) {
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
NAMED_LOGMODULE_SERVER, ISC_LOG_INFO,
"using up to %u sockets", socks);
}
return (ISC_R_SUCCESS);
}
static void
destroy_managers(void) {
isc_managers_destroy(&named_g_netmgr, &named_g_taskmgr,
&named_g_timermgr, &named_g_socketmgr);
&named_g_timermgr);
}
static void

View File

@ -391,7 +391,7 @@ OPTIONS
request-ixfr boolean;
request-nsid boolean;
require-server-cookie boolean;
reserved-sockets integer;
reserved-sockets integer;// deprecated
resolver-nonbackoff-tries integer;
resolver-query-timeout integer;
resolver-retry-interval integer;

View File

@ -29,7 +29,7 @@ named - Internet domain name server
Synopsis
~~~~~~~~
:program:`named` [ [**-4**] | [**-6**] ] [**-c** config-file] [**-d** debug-level] [**-D** string] [**-E** engine-name] [**-f**] [**-g**] [**-L** logfile] [**-M** option] [**-m** flag] [**-n** #cpus] [**-p** port] [**-s**] [**-S** #max-socks] [**-t** directory] [**-U** #listeners] [**-u** user] [**-v**] [**-V**] [**-X** lock-file]
:program:`named` [ [**-4**] | [**-6**] ] [**-c** config-file] [**-d** debug-level] [**-D** string] [**-E** engine-name] [**-f**] [**-g**] [**-L** logfile] [**-M** option] [**-m** flag] [**-n** #cpus] [**-p** port] [**-s**] [**-t** directory] [**-U** #listeners] [**-u** user] [**-v**] [**-V**] [**-X** lock-file]
Description
~~~~~~~~~~~
@ -126,9 +126,7 @@ Options
removed or changed in a future release.
``-S #max-socks``
This option allows ``named`` to use up to ``#max-socks`` sockets. The default value is
21000 on systems built with default configuration options, and 4096
on systems built with ``configure --with-tuning=small``.
This option is deprecated and no longer has any function.
.. warning::

View File

@ -45,7 +45,6 @@
#include <isc/resource.h>
#include <isc/result.h>
#include <isc/siphash.h>
#include <isc/socket.h>
#include <isc/stat.h>
#include <isc/stats.h>
#include <isc/stdio.h>
@ -8348,11 +8347,9 @@ load_configuration(const char *filename, named_server_t *server,
isc_logconfig_t *logc = NULL;
isc_portset_t *v4portset = NULL;
isc_portset_t *v6portset = NULL;
isc_resourcevalue_t nfiles;
isc_result_t result, tresult;
uint32_t heartbeat_interval;
uint32_t interface_interval;
uint32_t reserved;
uint32_t udpsize;
uint32_t transfer_message_size;
uint32_t recv_tcp_buffer_size;
@ -8363,7 +8360,6 @@ load_configuration(const char *filename, named_server_t *server,
named_cachelist_t cachelist, tmpcachelist;
ns_altsecret_t *altsecret;
ns_altsecretlist_t altsecrets, tmpaltsecrets;
unsigned int maxsocks;
uint32_t softquota = 0;
uint32_t max;
uint64_t initial, idle, keepalive, advertised;
@ -8516,52 +8512,6 @@ load_configuration(const char *filename, named_server_t *server,
*/
CHECK(check_lockfile(server, config, first_time));
/*
* Check if max number of open sockets that the system allows is
* sufficiently large. Failing this condition is not necessarily fatal,
* but may cause subsequent runtime failures for a busy recursive
* server.
*/
result = isc_socketmgr_getmaxsockets(named_g_socketmgr, &maxsocks);
if (result != ISC_R_SUCCESS) {
maxsocks = 0;
}
result = isc_resource_getcurlimit(isc_resource_openfiles, &nfiles);
if (result == ISC_R_SUCCESS && (isc_resourcevalue_t)maxsocks > nfiles) {
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
NAMED_LOGMODULE_SERVER, ISC_LOG_WARNING,
"max open files (%" PRIu64 ")"
" is smaller than max sockets (%u)",
nfiles, maxsocks);
}
/*
* Set the number of socket reserved for TCP, stdio etc.
*/
obj = NULL;
result = named_config_get(maps, "reserved-sockets", &obj);
INSIST(result == ISC_R_SUCCESS);
reserved = cfg_obj_asuint32(obj);
if (maxsocks != 0) {
if (maxsocks < 128U) { /* Prevent underflow. */
reserved = 0;
} else if (reserved > maxsocks - 128U) { /* Minimum UDP space.
*/
reserved = maxsocks - 128;
}
}
/* Minimum TCP/stdio space. */
if (reserved < 128U) {
reserved = 128;
}
if (reserved + 128U > maxsocks && maxsocks != 0) {
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
NAMED_LOGMODULE_SERVER, ISC_LOG_WARNING,
"less than 128 UDP sockets available after "
"applying 'reserved-sockets' and 'maxsockets'");
}
isc_socketmgr_setreserved(named_g_socketmgr, reserved);
#if defined(HAVE_GEOIP2)
/*
* Release any previously opened GeoIP2 databases.
@ -9871,11 +9821,11 @@ run_server(isc_task_t *task, isc_event_t *event) {
geoip = NULL;
#endif /* if defined(HAVE_GEOIP2) */
CHECKFATAL(ns_interfacemgr_create(
named_g_mctx, server->sctx, named_g_taskmgr,
named_g_timermgr, named_g_socketmgr, named_g_netmgr,
named_g_dispatchmgr, server->task, geoip,
named_g_cpus, &server->interfacemgr),
CHECKFATAL(ns_interfacemgr_create(named_g_mctx, server->sctx,
named_g_taskmgr, named_g_timermgr,
named_g_netmgr, named_g_dispatchmgr,
server->task, geoip, named_g_cpus,
&server->interfacemgr),
"creating interface manager");
CHECKFATAL(isc_timer_create(named_g_timermgr, isc_timertype_inactive,
@ -10182,7 +10132,6 @@ named_server_create(isc_mem_t *mctx, named_server_t **serverp) {
CHECKFATAL(isc_stats_create(server->mctx, &server->sockstats,
isc_sockstatscounter_max),
"isc_stats_create");
isc_socketmgr_setstats(named_g_socketmgr, server->sockstats);
isc_nm_setstats(named_g_netmgr, server->sockstats);
CHECKFATAL(isc_stats_create(named_g_mctx, &server->zonestats,

View File

@ -19,7 +19,6 @@
#include <isc/mem.h>
#include <isc/once.h>
#include <isc/print.h>
#include <isc/socket.h>
#include <isc/stats.h>
#include <isc/string.h>
#include <isc/util.h>
@ -2313,13 +2312,6 @@ generatexml(named_server_t *server, uint32_t flags, int *buflen,
}
TRY0(xmlTextWriterEndElement(writer)); /* /views */
if ((flags & STATS_XML_NET) != 0) {
TRY0(xmlTextWriterStartElement(writer,
ISC_XMLCHAR "socketmgr"));
TRY0(isc_socketmgr_renderxml(named_g_socketmgr, writer));
TRY0(xmlTextWriterEndElement(writer)); /* /socketmgr */
}
if ((flags & STATS_XML_TASKS) != 0) {
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "taskmgr"));
TRY0(isc_taskmgr_renderxml(named_g_taskmgr, writer));
@ -3103,7 +3095,6 @@ generatejson(named_server_t *server, size_t *msglen, const char **msg,
if ((flags & STATS_JSON_NET) != 0) {
/* socket stat counters */
json_object *sockets;
counters = json_object_new_object();
dumparg.result = ISC_R_SUCCESS;
@ -3124,17 +3115,6 @@ generatejson(named_server_t *server, size_t *msglen, const char **msg,
} else {
json_object_put(counters);
}
sockets = json_object_new_object();
CHECKMEM(sockets);
result = isc_socketmgr_renderjson(named_g_socketmgr, sockets);
if (result != ISC_R_SUCCESS) {
json_object_put(sockets);
goto cleanup;
}
json_object_object_add(bindstats, "socketmgr", sockets);
}
if ((flags & STATS_JSON_TASKS) != 0) {

View File

@ -913,8 +913,7 @@ setup_system(void) {
irs_resconf_destroy(&resconf);
result = isc_managers_create(gmctx, 1, 0, 0, &netmgr, &taskmgr, NULL,
NULL);
result = isc_managers_create(gmctx, 1, 0, &netmgr, &taskmgr, NULL);
check_result(result, "isc_managers_create");
result = dns_dispatchmgr_create(gmctx, netmgr, &dispatchmgr);
@ -3320,7 +3319,7 @@ cleanup(void) {
}
ddebug("Shutting down managers");
isc_managers_destroy(&netmgr, &taskmgr, NULL, NULL);
isc_managers_destroy(&netmgr, &taskmgr, NULL);
ddebug("Destroying event");
isc_event_free(&global_event);

View File

@ -30,7 +30,6 @@
#include <isc/random.h>
#include <isc/refcount.h>
#include <isc/result.h>
#include <isc/socket.h>
#include <isc/stdtime.h>
#include <isc/string.h>
#include <isc/task.h>
@ -1029,7 +1028,7 @@ main(int argc, char **argv) {
serial = isc_random32();
isc_mem_create(&rndc_mctx);
isc_managers_create(rndc_mctx, 1, 0, 0, &netmgr, &taskmgr, NULL, NULL);
isc_managers_create(rndc_mctx, 1, 0, &netmgr, &taskmgr, NULL);
DO("create task", isc_task_create(taskmgr, 0, &rndc_task));
isc_log_create(rndc_mctx, &log, &logconfig);
isc_log_setcontext(log);
@ -1084,7 +1083,7 @@ main(int argc, char **argv) {
}
isc_task_detach(&rndc_task);
isc_managers_destroy(&netmgr, &taskmgr, NULL, NULL);
isc_managers_destroy(&netmgr, &taskmgr, NULL);
/*
* Note: when TCP connections are shut down, there will be a final

View File

@ -262,7 +262,7 @@ main(int argc, char *argv[]) {
RUNCHECK(dst_lib_init(mctx, NULL));
isc_managers_create(mctx, 1, 0, 0, &netmgr, &taskmgr, NULL, NULL);
isc_managers_create(mctx, 1, 0, &netmgr, &taskmgr, NULL);
RUNCHECK(isc_task_create(taskmgr, 0, &task));
RUNCHECK(dns_dispatchmgr_create(mctx, netmgr, &dispatchmgr));
@ -287,7 +287,7 @@ main(int argc, char *argv[]) {
isc_task_shutdown(task);
isc_task_detach(&task);
isc_managers_destroy(&netmgr, &taskmgr, NULL, NULL);
isc_managers_destroy(&netmgr, &taskmgr, NULL);
dst_lib_destroy();

View File

@ -61,7 +61,7 @@ isc_timermgr_t *ctxs_timermgr = NULL;
static void
ctxs_destroy(void) {
isc_managers_destroy(&ctxs_netmgr, &ctxs_taskmgr, &ctxs_timermgr, NULL);
isc_managers_destroy(&ctxs_netmgr, &ctxs_taskmgr, &ctxs_timermgr);
if (ctxs_actx != NULL) {
isc_appctx_destroy(&ctxs_actx);
@ -83,8 +83,8 @@ ctxs_init(void) {
goto fail;
}
isc_managers_create(ctxs_mctx, 1, 0, 0, &ctxs_netmgr, &ctxs_taskmgr,
&ctxs_timermgr, NULL);
isc_managers_create(ctxs_mctx, 1, 0, &ctxs_netmgr, &ctxs_taskmgr,
&ctxs_timermgr);
result = isc_app_ctxstart(ctxs_actx);
if (result != ISC_R_SUCCESS) {

View File

@ -201,7 +201,6 @@ if $FEATURETEST --have-libxml2 && [ -x "${CURL}" ] && [ -x "${XSLTPROC}" ] ; th
# grep "<h2>Glue cache statistics</h2>" xsltproc.out.${n} >/dev/null || ret=1
grep "<h3>View _default" xsltproc.out.${n} >/dev/null || ret=1
grep "<h4>Zone example" xsltproc.out.${n} >/dev/null || ret=1
grep "<h2>Network Status</h2>" xsltproc.out.${n} >/dev/null || ret=1
grep "<h2>Task Manager Configuration</h2>" xsltproc.out.${n} >/dev/null || ret=1
grep "<h2>Tasks</h2>" xsltproc.out.${n} >/dev/null || ret=1
grep "<h2>Memory Usage Summary</h2>" xsltproc.out.${n} >/dev/null || ret=1

View File

@ -219,7 +219,7 @@ main(int argc, char *argv[]) {
RUNCHECK(dst_lib_init(mctx, NULL));
isc_managers_create(mctx, 1, 0, 0, &netmgr, &taskmgr, NULL, NULL);
isc_managers_create(mctx, 1, 0, &netmgr, &taskmgr, NULL);
RUNCHECK(isc_task_create(taskmgr, 0, &task));
RUNCHECK(dns_dispatchmgr_create(mctx, netmgr, &dispatchmgr));
@ -254,7 +254,7 @@ main(int argc, char *argv[]) {
dns_dispatchmgr_detach(&dispatchmgr);
isc_task_shutdown(task);
isc_task_detach(&task);
isc_managers_destroy(&netmgr, &taskmgr, NULL, NULL);
isc_managers_destroy(&netmgr, &taskmgr, NULL);
dst_key_free(&ourkey);
dns_tsigkey_detach(&initialkey);

View File

@ -163,7 +163,7 @@ main(int argc, char **argv) {
RUNCHECK(dst_lib_init(mctx, NULL));
isc_managers_create(mctx, 1, 0, 0, &netmgr, &taskmgr, NULL, NULL);
isc_managers_create(mctx, 1, 0, &netmgr, &taskmgr, NULL);
RUNCHECK(isc_task_create(taskmgr, 0, &task));
RUNCHECK(dns_dispatchmgr_create(mctx, netmgr, &dispatchmgr));
@ -197,7 +197,7 @@ main(int argc, char **argv) {
dns_dispatchmgr_detach(&dispatchmgr);
isc_task_shutdown(task);
isc_task_detach(&task);
isc_managers_destroy(&netmgr, &taskmgr, NULL, NULL);
isc_managers_destroy(&netmgr, &taskmgr, NULL);
dns_tsigkeyring_detach(&ring);

View File

@ -306,7 +306,7 @@ setup(void) {
isc_mem_create(&mctx);
isc_managers_create(mctx, workers, 0, 0, &netmgr, NULL, NULL, NULL);
isc_managers_create(mctx, workers, 0, &netmgr, NULL, NULL);
}
static void
@ -315,7 +315,7 @@ teardown(void) {
close(out);
}
isc_managers_destroy(&netmgr, NULL, NULL, NULL);
isc_managers_destroy(&netmgr, NULL, NULL);
isc_mem_destroy(&mctx);
if (tls_ctx) {
isc_tlsctx_free(&tls_ctx);

View File

@ -187,12 +187,12 @@ setup(void) {
isc_mem_create(&mctx);
isc_managers_create(mctx, workers, 0, 0, &netmgr, NULL, NULL, NULL);
isc_managers_create(mctx, workers, 0, &netmgr, NULL, NULL);
}
static void
teardown(void) {
isc_managers_destroy(&netmgr, NULL, NULL, NULL);
isc_managers_destroy(&netmgr, NULL, NULL);
isc_mem_destroy(&mctx);
if (tls_ctx) {
isc_tlsctx_free(&tls_ctx);

View File

@ -2115,7 +2115,7 @@ main(int argc, char *argv[]) {
fatal("can't choose between IPv4 and IPv6");
}
isc_managers_create(mctx, 1, 0, 0, &netmgr, &taskmgr, NULL, NULL);
isc_managers_create(mctx, 1, 0, &netmgr, &taskmgr, NULL);
RUNCHECK(isc_task_create(taskmgr, 0, &task));
RUNCHECK(dns_dispatchmgr_create(mctx, netmgr, &dispatchmgr));
@ -2175,7 +2175,7 @@ main(int argc, char *argv[]) {
isc_task_shutdown(task);
isc_task_detach(&task);
isc_managers_destroy(&netmgr, &taskmgr, NULL, NULL);
isc_managers_destroy(&netmgr, &taskmgr, NULL);
dst_lib_destroy();

View File

@ -3046,13 +3046,7 @@ system.
most two places after the decimal point are significant.
``reserved-sockets``
This sets the number of file descriptors reserved for TCP, stdio, etc. This
needs to be big enough to cover the number of interfaces ``named``
listens on plus ``tcp-clients``, as well as to provide room for
outgoing TCP queries and incoming zone transfers. The default is
``512``. The minimum value is ``128`` and the maximum value is
``128`` fewer than maxsockets (-S). This option may be removed in the
future.
This option is deprecated and no longer has any effect.
``max-cache-size``
This sets the maximum amount of memory to use for an individual cache

View File

@ -1370,32 +1370,6 @@ queue, the specified function will be called.
Examples:
`isc_socket_recv()` calls the `recv()` system call asynchronously: rather
than waiting for data, it returns immediately, but it sets up an event to
be triggered when the `recv()` call completes; BIND can now do other work
instead of waiting for I/O. Once the `recv()` is finished, the
associated event is triggered.
/*
* Function to handle a completed recv()
*/
static void
recvdone(isc_task_t *task, isc_event_t *event) {
/* Arguments are in event->ev_arg. */
}
...
/*
* Call recv() on socket 'sock', put results into 'region',
* minimum read size 1, and call recvdone() with NULL as
* argument. (Note: 'sock' is already associated with a
* particular task, so that doesn't need to be specified
* here.)
*/
isc_socket_recv(sock, &region, 1, recvdone, NULL);
A timer is set for a specified time in the future, and the event will
be triggered at that time.

View File

@ -32,7 +32,7 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
named \- Internet domain name server
.SH SYNOPSIS
.sp
\fBnamed\fP [ [\fB\-4\fP] | [\fB\-6\fP] ] [\fB\-c\fP config\-file] [\fB\-d\fP debug\-level] [\fB\-D\fP string] [\fB\-E\fP engine\-name] [\fB\-f\fP] [\fB\-g\fP] [\fB\-L\fP logfile] [\fB\-M\fP option] [\fB\-m\fP flag] [\fB\-n\fP #cpus] [\fB\-p\fP port] [\fB\-s\fP] [\fB\-S\fP #max\-socks] [\fB\-t\fP directory] [\fB\-U\fP #listeners] [\fB\-u\fP user] [\fB\-v\fP] [\fB\-V\fP] [\fB\-X\fP lock\-file]
\fBnamed\fP [ [\fB\-4\fP] | [\fB\-6\fP] ] [\fB\-c\fP config\-file] [\fB\-d\fP debug\-level] [\fB\-D\fP string] [\fB\-E\fP engine\-name] [\fB\-f\fP] [\fB\-g\fP] [\fB\-L\fP logfile] [\fB\-M\fP option] [\fB\-m\fP flag] [\fB\-n\fP #cpus] [\fB\-p\fP port] [\fB\-s\fP] [\fB\-t\fP directory] [\fB\-U\fP #listeners] [\fB\-u\fP user] [\fB\-v\fP] [\fB\-V\fP] [\fB\-X\fP lock\-file]
.SH DESCRIPTION
.sp
\fBnamed\fP is a Domain Name System (DNS) server, part of the BIND 9
@ -131,9 +131,7 @@ removed or changed in a future release.
.INDENT 0.0
.TP
.B \fB\-S #max\-socks\fP
This option allows \fBnamed\fP to use up to \fB#max\-socks\fP sockets. The default value is
21000 on systems built with default configuration options, and 4096
on systems built with \fBconfigure \-\-with\-tuning=small\fP\&.
This option is deprecated and no longer has any function.
.UNINDENT
.sp
\fBWARNING:\fP

View File

@ -458,7 +458,7 @@ options {
request\-ixfr boolean;
request\-nsid boolean;
require\-server\-cookie boolean;
reserved\-sockets integer;
reserved\-sockets integer;// deprecated
resolver\-nonbackoff\-tries integer;
resolver\-query\-timeout integer;
resolver\-retry\-interval integer;

View File

@ -316,7 +316,7 @@ options {
request-ixfr <boolean>;
request-nsid <boolean>;
require-server-cookie <boolean>;
reserved-sockets <integer>;
reserved-sockets <integer>; // deprecated
resolver-nonbackoff-tries <integer>;
resolver-query-timeout <integer>;
resolver-retry-interval <integer>;

View File

@ -314,7 +314,7 @@ options {
request-ixfr <boolean>;
request-nsid <boolean>;
require-server-cookie <boolean>;
reserved-sockets <integer>;
reserved-sockets <integer>; // deprecated
resolver-nonbackoff-tries <integer>;
resolver-query-timeout <integer>;
resolver-retry-interval <integer>;

View File

@ -234,7 +234,7 @@
request-ixfr <boolean>;
request-nsid <boolean>;
require-server-cookie <boolean>;
reserved-sockets <integer>;
reserved-sockets <integer>; // deprecated
resolver-nonbackoff-tries <integer>;
resolver-query-timeout <integer>;
resolver-retry-interval <integer>;

View File

@ -22,7 +22,6 @@
#include <isc/result.h>
#include <isc/safe.h>
#include <isc/sockaddr.h>
#include <isc/socket.h>
#include <isc/task.h>
#include <isc/timer.h>
#include <isc/util.h>

View File

@ -33,8 +33,7 @@
*
* Security:
*
*\li Depends on the isc_socket_t and dns_message_t for prevention of
* buffer overruns.
*\li Depends on dns_message_t for prevention of buffer overruns.
*
* Standards:
*
@ -52,7 +51,6 @@
#include <isc/lang.h>
#include <isc/mutex.h>
#include <isc/netmgr.h>
#include <isc/socket.h>
#include <isc/types.h>
#include <dns/types.h>
@ -187,7 +185,7 @@ dns_dispatch_createtcp(dns_dispatchmgr_t *mgr, const isc_sockaddr_t *localaddr,
const isc_sockaddr_t *destaddr, isc_dscp_t dscp,
dns_dispatch_t **dispp);
/*%<
* Create a new dns_dispatch and attach it to the provided isc_socket_t.
* Create a new TCP dns_dispatch.
*
* Requires:
*

View File

@ -46,8 +46,8 @@
#include <inttypes.h>
#include <stdbool.h>
#include <isc/event.h>
#include <isc/lang.h>
#include <isc/socket.h>
#include <isc/stats.h>
#include <dns/fixedname.h>

View File

@ -22,7 +22,6 @@
#include <isc/once.h>
#include <isc/print.h>
#include <isc/refcount.h>
#include <isc/socket.h>
#include <isc/stdio.h>
#include <isc/string.h>
#include <isc/util.h>

View File

@ -34,7 +34,6 @@
#include <isc/result.h>
#include <isc/rwlock.h>
#include <isc/serial.h>
#include <isc/socket.h>
#include <isc/stdio.h>
#include <isc/string.h>
#include <isc/task.h>

View File

@ -77,7 +77,6 @@ struct dns_request {
dns_requestmgr_t *requestmgr;
isc_buffer_t *tsig;
dns_tsigkey_t *tsigkey;
isc_socketevent_t sendevent;
isc_sockaddr_t destaddr;
unsigned int timeout;
unsigned int udpcount;

View File

@ -237,11 +237,10 @@ typedef struct query {
isc_buffer_t buffer;
isc_buffer_t *tsig;
dns_tsigkey_t *tsigkey;
isc_socketevent_t sendevent;
isc_dscp_t dscp;
int ednsversion;
unsigned int options;
isc_sockeventattr_t attributes;
unsigned int attributes;
unsigned int udpsize;
unsigned char data[512];
} resquery_t;

View File

@ -28,7 +28,6 @@
#include <isc/buffer.h>
#include <isc/managers.h>
#include <isc/refcount.h>
#include <isc/socket.h>
#include <isc/task.h>
#include <isc/util.h>
@ -143,8 +142,7 @@ _setup(void **state) {
close(sock);
/* Create a secondary network manager */
isc_managers_create(dt_mctx, ncpus, 0, 0, &connect_nm, NULL, NULL,
NULL);
isc_managers_create(dt_mctx, ncpus, 0, &connect_nm, NULL, NULL);
isc_nm_settimeouts(netmgr, T_SERVER_INIT, T_SERVER_IDLE,
T_SERVER_KEEPALIVE, T_SERVER_ADVERTISED);
@ -170,7 +168,7 @@ _teardown(void **state) {
uv_sem_destroy(&sem);
isc_managers_destroy(&connect_nm, NULL, NULL, NULL);
isc_managers_destroy(&connect_nm, NULL, NULL);
assert_null(connect_nm);
dns_test_end();

View File

@ -38,7 +38,6 @@
#include <isc/os.h>
#include <isc/print.h>
#include <isc/result.h>
#include <isc/socket.h>
#include <isc/stdio.h>
#include <isc/string.h>
#include <isc/task.h>
@ -99,7 +98,7 @@ cleanup_managers(void) {
isc_managers_destroy(netmgr == NULL ? NULL : &netmgr,
taskmgr == NULL ? NULL : &taskmgr,
timermgr == NULL ? NULL : &timermgr, NULL);
timermgr == NULL ? NULL : &timermgr);
if (app_running) {
isc_app_finish();
@ -111,8 +110,7 @@ create_managers(void) {
isc_result_t result;
ncpus = isc_os_ncpus();
isc_managers_create(dt_mctx, ncpus, 0, 0, &netmgr, &taskmgr, &timermgr,
NULL);
isc_managers_create(dt_mctx, ncpus, 0, &netmgr, &taskmgr, &timermgr);
CHECK(isc_task_create(taskmgr, 0, &maintask));
return (ISC_R_SUCCESS);

View File

@ -36,7 +36,6 @@
#include <isc/print.h>
#include <isc/random.h>
#include <isc/result.h>
#include <isc/socket.h>
#include <isc/stdio.h>
#include <isc/string.h>
#include <isc/task.h>

View File

@ -23,8 +23,8 @@
#include <isc/app.h>
#include <isc/buffer.h>
#include <isc/net.h>
#include <isc/print.h>
#include <isc/socket.h>
#include <isc/task.h>
#include <isc/timer.h>
#include <isc/util.h>

View File

@ -82,7 +82,6 @@ libisc_la_HEADERS = \
include/isc/serial.h \
include/isc/siphash.h \
include/isc/sockaddr.h \
include/isc/socket.h \
include/isc/stat.h \
include/isc/stats.h \
include/isc/stdatomic.h \
@ -186,8 +185,6 @@ libisc_la_SOURCES = \
serial.c \
siphash.c \
sockaddr.c \
socket.c \
socket_p.h \
stats.c \
stdio.c \
stdtime.c \

View File

@ -21,7 +21,7 @@
#include <isc/netmgr.h>
#include <isc/print.h>
#include <isc/refcount.h>
#include <isc/socket.h>
#include <isc/sockaddr.h>
#include <isc/string.h>
#include <isc/time.h>
#include <isc/util.h>

View File

@ -13,7 +13,6 @@
#include <isc/netmgr.h>
#include <isc/result.h>
#include <isc/socket.h>
#include <isc/task.h>
#include <isc/timer.h>
@ -21,10 +20,9 @@ typedef struct isc_managers isc_managers_t;
isc_result_t
isc_managers_create(isc_mem_t *mctx, size_t workers, size_t quantum,
size_t sockets, isc_nm_t **netmgrp,
isc_taskmgr_t **taskmgrp, isc_timermgr_t **timermgrp,
isc_socketmgr_t **socketmgrp);
isc_nm_t **netmgrp, isc_taskmgr_t **taskmgrp,
isc_timermgr_t **timermgrp);
void
isc_managers_destroy(isc_nm_t **netmgrp, isc_taskmgr_t **taskmgrp,
isc_timermgr_t **timermgrp, isc_socketmgr_t **socketmgrp);
isc_timermgr_t **timermgrp);

View File

@ -1,842 +0,0 @@
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
#pragma once
/*****
***** Module Info
*****/
/*! \file isc/socket.h
* \brief Provides TCP and UDP sockets for network I/O. The sockets are event
* sources in the task system.
*
* When I/O completes, a completion event for the socket is posted to the
* event queue of the task which requested the I/O.
*
* \li MP:
* The module ensures appropriate synchronization of data structures it
* creates and manipulates.
* Clients of this module must not be holding a socket's task's lock when
* making a call that affects that socket. Failure to follow this rule
* can result in deadlock.
* The caller must ensure that isc_socketmgr_destroy() is called only
* once for a given manager.
*
* \li Reliability:
* No anticipated impact.
*
* \li Resources:
* TBS
*
* \li Security:
* No anticipated impact.
*
* \li Standards:
* None.
*/
/***
*** Imports
***/
#include <inttypes.h>
#include <stdbool.h>
#include <isc/event.h>
#include <isc/eventclass.h>
#include <isc/lang.h>
#include <isc/region.h>
#include <isc/sockaddr.h>
#include <isc/time.h>
#include <isc/types.h>
ISC_LANG_BEGINDECLS
/***
*** Constants
***/
/*%
* Maximum number of buffers in a scatter/gather read/write. The operating
* system in use must support at least this number (plus one on some.)
*/
#define ISC_SOCKET_MAXSCATTERGATHER 8
/*@{*/
/*!
* Socket options:
*
* _REUSEADDRESS: Set SO_REUSEADDR prior to calling bind(),
* if a non-zero port is specified (applies to
* AF_INET and AF_INET6).
*/
typedef enum {
ISC_SOCKET_REUSEADDRESS = 0x01U,
} isc_socket_options_t;
/*@}*/
/*@{*/
/*!
* _ATTACHED: Internal use only.
* _TRUNC: Packet was truncated on receive.
* _CTRUNC: Packet control information was truncated. This can
* indicate that the packet is not complete, even though
* all the data is valid.
* _TIMESTAMP: The timestamp member is valid.
* _PKTINFO: The pktinfo member is valid.
* _MULTICAST: The UDP packet was received via a multicast transmission.
* _DSCP: The UDP DSCP value is valid.
* _USEMINMTU: Set the per packet IPV6_USE_MIN_MTU flag.
*/
typedef enum {
ISC_SOCKEVENTATTR_ATTACHED = 0x10000000U, /* internal */
ISC_SOCKEVENTATTR_TRUNC = 0x00800000U, /* public */
ISC_SOCKEVENTATTR_CTRUNC = 0x00400000U, /* public */
ISC_SOCKEVENTATTR_TIMESTAMP = 0x00200000U, /* public */
ISC_SOCKEVENTATTR_PKTINFO = 0x00100000U, /* public */
ISC_SOCKEVENTATTR_MULTICAST = 0x00080000U, /* public */
ISC_SOCKEVENTATTR_DSCP = 0x00040000U, /* public */
ISC_SOCKEVENTATTR_USEMINMTU = 0x00020000U /* public */
} isc_sockeventattr_t;
/*@}*/
/***
*** Types
***/
struct isc_socketevent {
ISC_EVENT_COMMON(isc_socketevent_t);
isc_result_t result; /*%< OK, EOF, whatever else */
unsigned int minimum; /*%< minimum i/o for event */
unsigned int n; /*%< bytes read or written */
unsigned int offset; /*%< offset into buffer list */
isc_region_t region; /*%< for single-buffer i/o */
isc_sockaddr_t address; /*%< source address */
isc_time_t timestamp; /*%< timestamp of packet recv */
struct in6_pktinfo pktinfo; /*%< ipv6 pktinfo */
isc_sockeventattr_t attributes; /*%< see isc_sockeventattr_t
* enum */
isc_eventdestructor_t destroy; /*%< original destructor */
unsigned int dscp; /*%< UDP dscp value */
};
typedef struct isc_socket_newconnev isc_socket_newconnev_t;
struct isc_socket_newconnev {
ISC_EVENT_COMMON(isc_socket_newconnev_t);
isc_socket_t *newsocket;
isc_result_t result; /*%< OK, EOF, whatever else */
isc_sockaddr_t address; /*%< source address */
};
typedef struct isc_socket_connev isc_socket_connev_t;
struct isc_socket_connev {
ISC_EVENT_COMMON(isc_socket_connev_t);
isc_result_t result; /*%< OK, EOF, whatever else */
};
#define ISC_SOCKEVENT_ANYEVENT (0)
#define ISC_SOCKEVENT_RECVDONE (ISC_EVENTCLASS_SOCKET + 1)
#define ISC_SOCKEVENT_SENDDONE (ISC_EVENTCLASS_SOCKET + 2)
#define ISC_SOCKEVENT_NEWCONN (ISC_EVENTCLASS_SOCKET + 3)
#define ISC_SOCKEVENT_CONNECT (ISC_EVENTCLASS_SOCKET + 4)
/*
* Internal events.
*/
#define ISC_SOCKEVENT_INTR (ISC_EVENTCLASS_SOCKET + 256)
#define ISC_SOCKEVENT_INTW (ISC_EVENTCLASS_SOCKET + 257)
typedef enum {
isc_sockettype_udp = 1,
isc_sockettype_tcp = 2,
isc_sockettype_unix = 3,
isc_sockettype_raw = 4
} isc_sockettype_t;
/*@{*/
/*!
* How a socket should be shutdown in isc_socket_shutdown() calls.
*/
#define ISC_SOCKSHUT_RECV 0x00000001 /*%< close read side */
#define ISC_SOCKSHUT_SEND 0x00000002 /*%< close write side */
#define ISC_SOCKSHUT_ALL 0x00000003 /*%< close them all */
/*@}*/
/*@{*/
/*!
* What I/O events to cancel in isc_socket_cancel() calls.
*/
#define ISC_SOCKCANCEL_RECV 0x00000001 /*%< cancel recv */
#define ISC_SOCKCANCEL_SEND 0x00000002 /*%< cancel send */
#define ISC_SOCKCANCEL_ACCEPT 0x00000004 /*%< cancel accept */
#define ISC_SOCKCANCEL_CONNECT 0x00000008 /*%< cancel connect */
#define ISC_SOCKCANCEL_ALL 0x0000000f /*%< cancel everything */
/*@}*/
/*@{*/
/*!
* Flags for isc_socket_send() and isc_socket_recv() calls.
*/
#define ISC_SOCKFLAG_IMMEDIATE 0x00000001 /*%< send event only if needed */
#define ISC_SOCKFLAG_NORETRY 0x00000002 /*%< drop failed UDP sends */
/*@}*/
/***
*** Socket and Socket Manager Functions
***
*** Note: all Ensures conditions apply only if the result is success for
*** those functions which return an isc_result.
***/
isc_result_t
isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
isc_socket_t **socketp);
/*%<
* Create a new 'type' socket managed by 'manager'.
*
* Note:
*
*\li 'pf' is the desired protocol family, e.g. PF_INET or PF_INET6.
*
* Requires:
*
*\li 'manager' is a valid manager
*
*\li 'socketp' is a valid pointer, and *socketp == NULL
*
* Ensures:
*
* '*socketp' is attached to the newly created socket
*
* Returns:
*
*\li #ISC_R_SUCCESS
*\li #ISC_R_NOMEMORY
*\li #ISC_R_NORESOURCES
*\li #ISC_R_UNEXPECTED
*/
void
isc_socket_cancel(isc_socket_t *sock, isc_task_t *task, unsigned int how);
/*%<
* Cancel pending I/O of the type specified by "how".
*
* Note: if "task" is NULL, then the cancel applies to all tasks using the
* socket.
*
* Requires:
*
* \li "socket" is a valid socket
*
* \li "task" is NULL or a valid task
*
* "how" is a bitmask describing the type of cancellation to perform.
* The type ISC_SOCKCANCEL_ALL will cancel all pending I/O on this
* socket.
*
* \li ISC_SOCKCANCEL_RECV:
* Cancel pending isc_socket_recv() calls.
*
* \li ISC_SOCKCANCEL_SEND:
* Cancel pending isc_socket_send() and isc_socket_sendto() calls.
*
* \li ISC_SOCKCANCEL_ACCEPT:
* Cancel pending isc_socket_accept() calls.
*
* \li ISC_SOCKCANCEL_CONNECT:
* Cancel pending isc_socket_connect() call.
*/
void
isc_socket_shutdown(isc_socket_t *sock, unsigned int how);
/*%<
* Shutdown 'socket' according to 'how'.
*
* Requires:
*
* \li 'socket' is a valid socket.
*
* \li 'task' is NULL or is a valid task.
*
* \li If 'how' is 'ISC_SOCKSHUT_RECV' or 'ISC_SOCKSHUT_ALL' then
*
* The read queue must be empty.
*
* No further read requests may be made.
*
* \li If 'how' is 'ISC_SOCKSHUT_SEND' or 'ISC_SOCKSHUT_ALL' then
*
* The write queue must be empty.
*
* No further write requests may be made.
*/
void
isc_socket_attach(isc_socket_t *sock, isc_socket_t **socketp);
/*%<
* Attach *socketp to socket.
*
* Requires:
*
* \li 'socket' is a valid socket.
*
* \li 'socketp' points to a NULL socket.
*
* Ensures:
*
* \li *socketp is attached to socket.
*/
void
isc_socket_detach(isc_socket_t **socketp);
/*%<
* Detach *socketp from its socket.
*
* Requires:
*
* \li 'socketp' points to a valid socket.
*
* \li If '*socketp' is the last reference to the socket,
* then:
*
* There must be no pending I/O requests.
*
* Ensures:
*
* \li *socketp is NULL.
*
* \li If '*socketp' is the last reference to the socket,
* then:
*
* The socket will be shutdown (both reading and writing)
* for all tasks.
*
* All resources used by the socket have been freed
*/
isc_result_t
isc_socket_open(isc_socket_t *sock);
/*%<
* Open a new socket file descriptor of the given socket structure. It simply
* opens a new descriptor; all of the other parameters including the socket
* type are inherited from the existing socket. This function is provided to
* avoid overhead of destroying and creating sockets when many short-lived
* sockets are frequently opened and closed. When the efficiency is not an
* issue, it should be safer to detach the unused socket and re-create a new
* one. This optimization may not be available for some systems, in which
* case this function will return ISC_R_NOTIMPLEMENTED and must not be used.
*
* Requires:
*
* \li there must be no other reference to this socket.
*
* \li 'socket' is a valid and previously closed by isc_socket_close()
*
* Returns:
* Same as isc_socket_create().
* \li ISC_R_NOTIMPLEMENTED
*/
isc_result_t
isc_socket_close(isc_socket_t *sock);
/*%<
* Close a socket file descriptor of the given socket structure. This function
* is provided as an alternative to destroying an unused socket when overhead
* destroying/re-creating sockets can be significant, and is expected to be
* used with isc_socket_open(). This optimization may not be available for some
* systems, in which case this function will return ISC_R_NOTIMPLEMENTED and
* must not be used.
*
* Requires:
*
* \li The socket must have a valid descriptor.
*
* \li There must be no other reference to this socket.
*
* \li There must be no pending I/O requests.
*
* Returns:
* \li #ISC_R_NOTIMPLEMENTED
*/
isc_result_t
isc_socket_bind(isc_socket_t *sock, const isc_sockaddr_t *addressp,
isc_socket_options_t options);
/*%<
* Bind 'socket' to '*addressp'.
*
* Requires:
*
* \li 'socket' is a valid socket
*
* \li 'addressp' points to a valid isc_sockaddr.
*
* Returns:
*
* \li ISC_R_SUCCESS
* \li ISC_R_NOPERM
* \li ISC_R_ADDRNOTAVAIL
* \li ISC_R_ADDRINUSE
* \li ISC_R_BOUND
* \li ISC_R_UNEXPECTED
*/
isc_result_t
isc_socket_filter(isc_socket_t *sock, const char *filter);
/*%<
* Inform the kernel that it should perform accept filtering.
* If filter is NULL the current filter will be removed.
*/
isc_result_t
isc_socket_listen(isc_socket_t *sock, unsigned int backlog);
/*%<
* Set listen mode on the socket. After this call, the only function that
* can be used (other than attach and detach) is isc_socket_accept().
*
* Notes:
*
* \li 'backlog' is as in the UNIX system call listen() and may be
* ignored by non-UNIX implementations.
*
* \li If 'backlog' is zero, a reasonable system default is used, usually
* SOMAXCONN.
*
* Requires:
*
* \li 'socket' is a valid, bound TCP socket or a valid, bound UNIX socket.
*
* Returns:
*
* \li ISC_R_SUCCESS
* \li ISC_R_UNEXPECTED
*/
isc_result_t
isc_socket_accept(isc_socket_t *sock, isc_task_t *task, isc_taskaction_t action,
void *arg);
/*%<
* Queue accept event. When a new connection is received, the task will
* get an ISC_SOCKEVENT_NEWCONN event with the sender set to the listen
* socket. The new socket structure is sent inside the isc_socket_newconnev_t
* event type, and is attached to the task 'task'.
*
* REQUIRES:
* \li 'socket' is a valid TCP socket that isc_socket_listen() was called
* on.
*
* \li 'task' is a valid task
*
* \li 'action' is a valid action
*
* RETURNS:
* \li ISC_R_SUCCESS
* \li ISC_R_NOMEMORY
* \li ISC_R_UNEXPECTED
*/
isc_result_t
isc_socket_connect(isc_socket_t *sock, const isc_sockaddr_t *addressp,
isc_task_t *task, isc_taskaction_t action, void *arg);
/*%<
* Connect 'socket' to peer with address *saddr. When the connection
* succeeds, or when an error occurs, a CONNECT event with action 'action'
* and arg 'arg' will be posted to the event queue for 'task'.
*
* Requires:
*
* \li 'socket' is a valid TCP socket
*
* \li 'addressp' points to a valid isc_sockaddr
*
* \li 'task' is a valid task
*
* \li 'action' is a valid action
*
* Returns:
*
* \li ISC_R_SUCCESS
* \li ISC_R_NOMEMORY
* \li ISC_R_UNEXPECTED
*
* Posted event's result code:
*
* \li ISC_R_SUCCESS
* \li ISC_R_TIMEDOUT
* \li ISC_R_CONNREFUSED
* \li ISC_R_NETUNREACH
* \li ISC_R_UNEXPECTED
*/
isc_result_t
isc_socket_getpeername(isc_socket_t *sock, isc_sockaddr_t *addressp);
/*%<
* Get the name of the peer connected to 'socket'.
*
* Requires:
*
* \li 'socket' is a valid TCP socket.
*
* Returns:
*
* \li ISC_R_SUCCESS
* \li ISC_R_TOOSMALL
* \li ISC_R_UNEXPECTED
*/
isc_result_t
isc_socket_getsockname(isc_socket_t *sock, isc_sockaddr_t *addressp);
/*%<
* Get the name of 'socket'.
*
* Requires:
*
* \li 'socket' is a valid socket.
*
* Returns:
*
* \li ISC_R_SUCCESS
* \li ISC_R_TOOSMALL
* \li ISC_R_UNEXPECTED
*/
/*@{*/
isc_result_t
isc_socket_recv(isc_socket_t *sock, isc_region_t *region, unsigned int minimum,
isc_task_t *task, isc_taskaction_t action, void *arg);
isc_result_t
isc_socket_recv2(isc_socket_t *sock, isc_region_t *region, unsigned int minimum,
isc_task_t *task, isc_socketevent_t *event,
unsigned int flags);
/*!
* Receive from 'socket', storing the results in region.
*
* Notes:
*
*\li Let 'length' refer to the length of 'region' or to the sum of all
* available regions in the list of buffers '*buflist'.
*
*\li If 'minimum' is non-zero and at least that many bytes are read,
* the completion event will be posted to the task 'task.' If minimum
* is zero, the exact number of bytes requested in the region must
* be read for an event to be posted. This only makes sense for TCP
* connections, and is always set to 1 byte for UDP.
*
*\li The read will complete when the desired number of bytes have been
* read, if end-of-input occurs, or if an error occurs. A read done
* event with the given 'action' and 'arg' will be posted to the
* event queue of 'task'.
*
*\li The caller may not modify 'region', the buffers which are passed
* into this function, or any data they refer to until the completion
* event is received.
*
*\li For isc_socket_recv2():
* 'event' is not NULL, and the non-socket specific fields are
* expected to be initialized.
*
*\li For isc_socket_recv2():
* The only defined value for 'flags' is ISC_SOCKFLAG_IMMEDIATE. If
* set and the operation completes, the return value will be
* ISC_R_SUCCESS and the event will be filled in and not sent. If the
* operation does not complete, the return value will be
* ISC_R_INPROGRESS and the event will be sent when the operation
* completes.
*
* Requires:
*
*\li 'socket' is a valid, bound socket.
*
*\li For isc_socket_recv():
* 'region' is a valid region
*
*\li For isc_socket_recvv():
* 'buflist' is non-NULL, and '*buflist' contain at least one buffer.
*
*\li 'task' is a valid task
*
*\li For isc_socket_recv() and isc_socket_recvv():
* action != NULL and is a valid action
*
*\li For isc_socket_recv2():
* event != NULL
*
* Returns:
*
*\li #ISC_R_SUCCESS
*\li #ISC_R_INPROGRESS
*\li #ISC_R_NOMEMORY
*\li #ISC_R_UNEXPECTED
*
* Event results:
*
*\li #ISC_R_SUCCESS
*\li #ISC_R_UNEXPECTED
*\li XXX needs other net-type errors
*/
/*@}*/
/*@{*/
isc_result_t
isc_socket_send(isc_socket_t *sock, isc_region_t *region, isc_task_t *task,
isc_taskaction_t action, void *arg);
isc_result_t
isc_socket_sendto(isc_socket_t *sock, isc_region_t *region, isc_task_t *task,
isc_taskaction_t action, void *arg,
const isc_sockaddr_t *address, struct in6_pktinfo *pktinfo);
isc_result_t
isc_socket_sendto2(isc_socket_t *sock, isc_region_t *region, isc_task_t *task,
const isc_sockaddr_t *address, struct in6_pktinfo *pktinfo,
isc_socketevent_t *event, unsigned int flags);
/*!
* Send the contents of 'region' to the socket's peer.
*
* Notes:
*
*\li Shutting down the requestor's task *may* result in any
* still pending writes being dropped or completed, depending on the
* underlying OS implementation.
*
*\li If 'action' is NULL, then no completion event will be posted.
*
*\li The caller may not modify 'region', the buffers which are passed
* into this function, or any data they refer to until the completion
* event is received.
*
*\li For isc_socket_sendto2():
* 'event' is not NULL, and the non-socket specific fields are
* expected to be initialized.
*
*\li For isc_socket_sendto2():
* The only defined values for 'flags' are ISC_SOCKFLAG_IMMEDIATE
* and ISC_SOCKFLAG_NORETRY.
*
*\li If ISC_SOCKFLAG_IMMEDIATE is set and the operation completes, the
* return value will be ISC_R_SUCCESS and the event will be filled
* in and not sent. If the operation does not complete, the return
* value will be ISC_R_INPROGRESS and the event will be sent when
* the operation completes.
*
*\li ISC_SOCKFLAG_NORETRY can only be set for UDP sockets. If set
* and the send operation fails due to a transient error, the send
* will not be retried and the error will be indicated in the event.
* Using this option along with ISC_SOCKFLAG_IMMEDIATE allows the caller
* to specify a region that is allocated on the stack.
*
* Requires:
*
*\li 'socket' is a valid, bound socket.
*
*\li For isc_socket_send():
* 'region' is a valid region
*
*\li For isc_socket_sendv() and isc_socket_sendtov():
* 'buflist' is non-NULL, and '*buflist' contain at least one buffer.
*
*\li 'task' is a valid task
*
*\li For isc_socket_sendv(), isc_socket_sendtov(), isc_socket_send(), and
* isc_socket_sendto():
* action == NULL or is a valid action
*
*\li For isc_socket_sendto2():
* event != NULL
*
* Returns:
*
*\li #ISC_R_SUCCESS
*\li #ISC_R_INPROGRESS
*\li #ISC_R_NOMEMORY
*\li #ISC_R_UNEXPECTED
*
* Event results:
*
*\li #ISC_R_SUCCESS
*\li #ISC_R_UNEXPECTED
*\li XXX needs other net-type errors
*/
/*@}*/
isc_result_t
isc_socketmgr_getmaxsockets(isc_socketmgr_t *manager, unsigned int *nsockp);
/*%<
* Returns in "*nsockp" the maximum number of sockets this manager may open.
*
* Requires:
*
*\li '*manager' is a valid isc_socketmgr_t.
*\li 'nsockp' is not NULL.
*
* Returns:
*
*\li #ISC_R_SUCCESS
*\li #ISC_R_NOTIMPLEMENTED
*/
void
isc_socketmgr_setstats(isc_socketmgr_t *manager, isc_stats_t *stats);
/*%<
* Set a general socket statistics counter set 'stats' for 'manager'.
*
* Requires:
* \li 'manager' is valid, hasn't opened any socket, and doesn't have
* stats already set.
*
*\li stats is a valid statistics supporting socket statistics counters
* (see above).
*/
isc_sockettype_t
isc_socket_gettype(isc_socket_t *sock);
/*%<
* Returns the socket type for "sock."
*
* Requires:
*
*\li "sock" is a valid socket.
*/
/*@{*/
void
isc_socket_ipv6only(isc_socket_t *sock, bool yes);
/*%<
* If the socket is an IPv6 socket set/clear the IPV6_IPV6ONLY socket
* option if the host OS supports this option.
*
* Requires:
*\li 'sock' is a valid socket.
*/
/*@}*/
void
isc_socket_dscp(isc_socket_t *sock, isc_dscp_t dscp);
/*%<
* Sets the Differentiated Services Code Point (DSCP) field for packets
* transmitted on this socket. If 'dscp' is -1, return immediately.
*
* Requires:
*\li 'sock' is a valid socket.
*/
isc_socketevent_t *
isc_socket_socketevent(isc_mem_t *mctx, void *sender, isc_eventtype_t eventtype,
isc_taskaction_t action, void *arg);
/*%<
* Get a isc_socketevent_t to be used with isc_socket_sendto2(), etc.
*/
void
isc_socket_cleanunix(const isc_sockaddr_t *addr, bool active);
/*%<
* Cleanup UNIX domain sockets in the file-system. If 'active' is true
* then just unlink the socket. If 'active' is false try to determine
* if there is a listener of the socket or not. If no listener is found
* then unlink socket.
*
* Prior to unlinking the path is tested to see if it a socket.
*
* Note: there are a number of race conditions which cannot be avoided
* both in the filesystem and any application using UNIX domain
* sockets (e.g. socket is tested between bind() and listen(),
* the socket is deleted and replaced in the file-system between
* stat() and unlink()).
*/
isc_result_t
isc_socket_permunix(const isc_sockaddr_t *sockaddr, uint32_t perm,
uint32_t owner, uint32_t group);
/*%<
* Set ownership and file permissions on the UNIX domain socket.
*
* Note: On Solaris this secures the directory containing
* the socket as Solaris do not honour the filesystem
* permissions on the socket.
*
* Requires:
* \li 'sockaddr' to be a valid UNIX domain sockaddr.
*
* Returns:
* \li #ISC_R_SUCCESS
* \li #ISC_R_FAILURE
*/
void
isc_socket_setname(isc_socket_t *socket, const char *name, void *tag);
/*%<
* Set the name and optional tag for a socket. This allows tracking of the
* owner or purpose for this socket, and is useful for tracing and statistics
* reporting.
*/
const char *
isc_socket_getname(isc_socket_t *socket);
/*%<
* Get the name associated with a socket, if any.
*/
void *
isc_socket_gettag(isc_socket_t *socket);
/*%<
* Get the tag associated with a socket, if any.
*/
int
isc_socket_getfd(isc_socket_t *socket);
/*%<
* Get the file descriptor associated with a socket
*/
void
isc_socketmgr_setreserved(isc_socketmgr_t *mgr, uint32_t);
/*%<
* Temporary. For use by named only.
*/
void
isc_socketmgr_maxudp(isc_socketmgr_t *mgr, unsigned int maxudp);
/*%<
* Test interface. Drop UDP packet > 'maxudp'.
*/
bool
isc_socket_hasreuseport(void);
/*%<
* Return true if there is SO_REUSEPORT support
*/
#ifdef HAVE_LIBXML2
int
isc_socketmgr_renderxml(isc_socketmgr_t *mgr, void *writer0);
/*%<
* Render internal statistics and other state into the XML document.
*/
#endif /* HAVE_LIBXML2 */
#ifdef HAVE_JSON_C
isc_result_t
isc_socketmgr_renderjson(isc_socketmgr_t *mgr, void *stats0);
/*%<
* Render internal statistics and other state into JSON format.
*/
#endif /* HAVE_JSON_C */
/*%<
* See isc_socketmgr_create() above.
*/
typedef isc_result_t (*isc_socketmgrcreatefunc_t)(isc_mem_t *mctx,
isc_socketmgr_t **managerp);
ISC_LANG_ENDDECLS

View File

@ -77,13 +77,10 @@ typedef struct isc_rwlock isc_rwlock_t; /*%< Read Write Lock */
typedef struct isc_sockaddr isc_sockaddr_t; /*%< Socket Address */
typedef ISC_LIST(isc_sockaddr_t) isc_sockaddrlist_t; /*%< Socket Address List
* */
typedef struct isc_socket isc_socket_t; /*%< Socket */
typedef struct isc_socketevent isc_socketevent_t; /*%< Socket Event */
typedef struct isc_socketmgr isc_socketmgr_t; /*%< Socket Manager */
typedef struct isc_stats isc_stats_t; /*%< Statistics */
typedef int_fast64_t isc_statscounter_t;
typedef struct isc_symtab isc_symtab_t; /*%< Symbol Table */
typedef struct isc_task isc_task_t; /*%< Task */
typedef struct isc_stats isc_stats_t; /*%< Statistics */
typedef int_fast64_t isc_statscounter_t;
typedef struct isc_symtab isc_symtab_t; /*%< Symbol Table */
typedef struct isc_task isc_task_t; /*%< Task */
typedef ISC_LIST(isc_task_t) isc_tasklist_t; /*%< Task List */
typedef struct isc_taskmgr isc_taskmgr_t; /*%< Task Manager */
typedef struct isc_textregion isc_textregion_t; /*%< Text Region */

View File

@ -14,18 +14,15 @@
#include <isc/util.h>
#include "netmgr_p.h"
#include "socket_p.h"
#include "task_p.h"
#include "timer_p.h"
isc_result_t
isc_managers_create(isc_mem_t *mctx, size_t workers, size_t quantum,
size_t sockets, isc_nm_t **netmgrp,
isc_taskmgr_t **taskmgrp, isc_timermgr_t **timermgrp,
isc_socketmgr_t **socketmgrp) {
isc_nm_t **netmgrp, isc_taskmgr_t **taskmgrp,
isc_timermgr_t **timermgrp) {
isc_result_t result;
isc_nm_t *netmgr = NULL;
isc_socketmgr_t *socketmgr = NULL;
isc_taskmgr_t *taskmgr = NULL;
isc_timermgr_t *timermgr = NULL;
@ -65,29 +62,16 @@ isc_managers_create(isc_mem_t *mctx, size_t workers, size_t quantum,
*timermgrp = timermgr;
}
REQUIRE(socketmgrp == NULL || *socketmgrp == NULL);
if (socketmgrp != NULL) {
result = isc__socketmgr_create(mctx, &socketmgr, sockets,
workers);
if (result != ISC_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"isc_socketmgr_create() failed: %s",
isc_result_totext(result));
goto fail;
}
*socketmgrp = socketmgr;
}
return (ISC_R_SUCCESS);
fail:
isc_managers_destroy(netmgrp, taskmgrp, timermgrp, socketmgrp);
isc_managers_destroy(netmgrp, taskmgrp, timermgrp);
return (result);
}
void
isc_managers_destroy(isc_nm_t **netmgrp, isc_taskmgr_t **taskmgrp,
isc_timermgr_t **timermgrp, isc_socketmgr_t **socketmgrp) {
isc_timermgr_t **timermgrp) {
/*
* If we have a taskmgr to clean up, then we must also have a netmgr.
*/
@ -137,8 +121,4 @@ isc_managers_destroy(isc_nm_t **netmgrp, isc_taskmgr_t **taskmgrp,
INSIST(*timermgrp != NULL);
isc__timermgr_destroy(timermgrp);
}
if (socketmgrp != NULL) {
INSIST(*socketmgrp != NULL);
isc__socketmgr_destroy(socketmgrp);
}
}

View File

@ -19,6 +19,7 @@
#include <isc/base64.h>
#include <isc/netmgr.h>
#include <isc/print.h>
#include <isc/sockaddr.h>
#include <isc/tls.h>
#include <isc/url.h>
#include <isc/util.h>

View File

@ -128,6 +128,13 @@ static const isc_statscounter_t unixstatsindex[] = {
static thread_local int isc__nm_tid_v = ISC_NETMGR_TID_UNKNOWN;
/*
* Set by the -T dscp option on the command line. If set to a value
* other than -1, we check to make sure DSCP values match it, and
* assert if not. (Not currently in use.)
*/
int isc_dscp_check_value = -1;
static void
nmsocket_maybe_destroy(isc_nmsocket_t *sock FLARG);
static void

File diff suppressed because it is too large Load Diff

View File

@ -1,79 +0,0 @@
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
#pragma once
#include <isc/mem.h>
#include <isc/result.h>
#include <isc/socket.h>
isc_result_t
isc__socketmgr_create(isc_mem_t *mctx, isc_socketmgr_t **managerp,
unsigned int maxsocks, int nthreads);
/*%<
* Create a socket manager. If "maxsocks" is non-zero, it specifies the
* maximum number of sockets that the created manager should handle.
*
* Notes:
*
*\li All memory will be allocated in memory context 'mctx'.
*
* Requires:
*
*\li 'mctx' is a valid memory context.
*
*\li 'managerp' points to a NULL isc_socketmgr_t.
*
* Ensures:
*
*\li '*managerp' is a valid isc_socketmgr_t.
*
* Returns:
*
*\li #ISC_R_SUCCESS
*\li #ISC_R_NOMEMORY
*\li #ISC_R_UNEXPECTED
*\li #ISC_R_NOTIMPLEMENTED
*/
void
isc__socketmgr_destroy(isc_socketmgr_t **managerp);
/*%<
* Destroy a socket manager.
*
* Notes:
*
*\li This routine blocks until there are no sockets left in the manager,
* so if the caller holds any socket references using the manager, it
* must detach them before calling isc_socketmgr_destroy() or it will
* block forever.
*
* Requires:
*
*\li '*managerp' is a valid isc_socketmgr_t.
*
*\li All sockets managed by this manager are fully detached.
*
* Ensures:
*
*\li *managerp == NULL
*
*\li All resources used by the manager have been freed.
*/
#include <sys/time.h>
typedef struct isc_socketwait isc_socketwait_t;
int
isc__socketmgr_waitevents(isc_socketmgr_t *, struct timeval *,
isc_socketwait_t **);
isc_result_t
isc__socketmgr_dispatch(isc_socketmgr_t *, isc_socketwait_t *);

View File

@ -9,7 +9,6 @@ LDADD += \
check_LTLIBRARIES = libisctest.la
libisctest_la_SOURCES = \
../socket_p.h \
isctest.c \
isctest.h \
uv_wrap.h
@ -40,7 +39,6 @@ check_PROGRAMS = \
safe_test \
siphash_test \
sockaddr_test \
socket_test \
stats_test \
symtab_test \
task_test \

View File

@ -23,7 +23,6 @@
#include <isc/managers.h>
#include <isc/mem.h>
#include <isc/os.h>
#include <isc/socket.h>
#include <isc/string.h>
#include <isc/task.h>
#include <isc/timer.h>
@ -33,7 +32,6 @@ isc_mem_t *test_mctx = NULL;
isc_log_t *test_lctx = NULL;
isc_taskmgr_t *taskmgr = NULL;
isc_timermgr_t *timermgr = NULL;
isc_socketmgr_t *socketmgr = NULL;
isc_nm_t *netmgr = NULL;
isc_task_t *maintask = NULL;
int ncpus;
@ -61,8 +59,7 @@ cleanup_managers(void) {
}
isc_managers_destroy(netmgr == NULL ? NULL : &netmgr,
taskmgr == NULL ? NULL : &taskmgr,
timermgr == NULL ? NULL : &timermgr,
socketmgr == NULL ? NULL : &socketmgr);
timermgr == NULL ? NULL : &timermgr);
}
static isc_result_t
@ -80,8 +77,8 @@ create_managers(unsigned int workers) {
INSIST(workers != 0);
isc_hp_init(6 * workers);
isc_managers_create(test_mctx, workers, 0, 0, &netmgr, &taskmgr,
&timermgr, &socketmgr);
isc_managers_create(test_mctx, workers, 0, &netmgr, &taskmgr,
&timermgr);
CHECK(isc_task_create_bound(taskmgr, 0, &maintask, 0));
isc_taskmgr_setexcltask(taskmgr, maintask);

View File

@ -39,7 +39,6 @@ extern isc_mem_t *test_mctx;
extern isc_log_t *test_lctx;
extern isc_taskmgr_t *taskmgr;
extern isc_timermgr_t *timermgr;
extern isc_socketmgr_t *socketmgr;
extern isc_nm_t *netmgr;
extern int ncpus;

View File

@ -1,734 +0,0 @@
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
/*! \file */
#if HAVE_CMOCKA
#include <inttypes.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#define UNIT_TESTING
#include <cmocka.h>
#include <isc/atomic.h>
#include <isc/print.h>
#include <isc/socket.h>
#include <isc/task.h>
#include "../socket_p.h"
#include "isctest.h"
static bool recv_dscp;
static unsigned int recv_dscp_value;
static bool recv_trunc;
isc_socket_t *s1 = NULL, *s2 = NULL, *s3 = NULL;
isc_task_t *test_task = NULL;
/*
* Helper functions
*/
static int
_setup(void **state) {
isc_result_t result;
UNUSED(state);
result = isc_test_begin(NULL, true, 0);
assert_int_equal(result, ISC_R_SUCCESS);
return (0);
}
static int
_teardown(void **state) {
UNUSED(state);
if (s1 != NULL) {
isc_socket_detach(&s1);
}
if (s2 != NULL) {
isc_socket_detach(&s2);
}
if (s3 != NULL) {
isc_socket_detach(&s3);
}
if (test_task != NULL) {
isc_task_detach(&test_task);
}
isc_test_end();
return (0);
}
typedef struct {
atomic_bool done;
atomic_uintptr_t socket;
isc_result_t result;
} completion_t;
static void
completion_init(completion_t *completion) {
atomic_init(&completion->done, false);
atomic_init(&completion->socket, (uintptr_t)NULL);
}
static void
accept_done(isc_task_t *task, isc_event_t *event) {
isc_socket_newconnev_t *nevent = (isc_socket_newconnev_t *)event;
completion_t *completion = event->ev_arg;
UNUSED(task);
completion->result = nevent->result;
atomic_store(&completion->done, true);
if (completion->result == ISC_R_SUCCESS) {
atomic_store(&completion->socket, (uintptr_t)nevent->newsocket);
}
isc_event_free(&event);
}
static void
event_done(isc_task_t *task, isc_event_t *event) {
isc_socketevent_t *sev = NULL;
isc_socket_connev_t *connev = NULL;
completion_t *completion = event->ev_arg;
UNUSED(task);
switch (event->ev_type) {
case ISC_SOCKEVENT_RECVDONE:
case ISC_SOCKEVENT_SENDDONE:
sev = (isc_socketevent_t *)event;
completion->result = sev->result;
if ((sev->attributes & ISC_SOCKEVENTATTR_DSCP) != 0) {
recv_dscp = true;
recv_dscp_value = sev->dscp;
} else {
recv_dscp = false;
}
recv_trunc = ((sev->attributes & ISC_SOCKEVENTATTR_TRUNC) != 0);
break;
case ISC_SOCKEVENT_CONNECT:
connev = (isc_socket_connev_t *)event;
completion->result = connev->result;
break;
default:
assert_false(true);
}
atomic_store(&completion->done, true);
isc_event_free(&event);
}
static void
waitfor(completion_t *completion) {
int i = 0;
while (!atomic_load(&completion->done) && i++ < 5000) {
isc_test_nap(10000);
}
assert_true(atomic_load(&completion->done));
}
static void
waitfor2(completion_t *c1, completion_t *c2) {
int i = 0;
while (!(atomic_load(&c1->done) && atomic_load(&c2->done)) &&
i++ < 5000) {
isc_test_nap(10000);
}
assert_true(atomic_load(&c1->done) && atomic_load(&c2->done));
}
/*
* Individual unit tests
*/
/* Test UDP sendto/recv (IPv4) */
static void
udp_sendto_test(void **state) {
isc_result_t result;
isc_sockaddr_t addr1, addr2;
struct in_addr in;
char sendbuf[BUFSIZ], recvbuf[BUFSIZ];
completion_t completion;
isc_region_t r;
UNUSED(state);
in.s_addr = inet_addr("127.0.0.1");
isc_sockaddr_fromin(&addr1, &in, 0);
isc_sockaddr_fromin(&addr2, &in, 0);
result = isc_socket_create(socketmgr, PF_INET, isc_sockettype_udp, &s1);
assert_int_equal(result, ISC_R_SUCCESS);
result = isc_socket_bind(s1, &addr1, 0);
assert_int_equal(result, ISC_R_SUCCESS);
result = isc_socket_getsockname(s1, &addr1);
assert_int_equal(result, ISC_R_SUCCESS);
assert_true(isc_sockaddr_getport(&addr1) != 0);
result = isc_socket_create(socketmgr, PF_INET, isc_sockettype_udp, &s2);
assert_int_equal(result, ISC_R_SUCCESS);
result = isc_socket_bind(s2, &addr2, 0);
assert_int_equal(result, ISC_R_SUCCESS);
result = isc_socket_getsockname(s2, &addr2);
assert_int_equal(result, ISC_R_SUCCESS);
assert_true(isc_sockaddr_getport(&addr2) != 0);
result = isc_task_create(taskmgr, 0, &test_task);
assert_int_equal(result, ISC_R_SUCCESS);
snprintf(sendbuf, sizeof(sendbuf), "Hello");
r.base = (void *)sendbuf;
r.length = strlen(sendbuf) + 1;
completion_init(&completion);
result = isc_socket_sendto(s1, &r, test_task, event_done, &completion,
&addr2, NULL);
assert_int_equal(result, ISC_R_SUCCESS);
waitfor(&completion);
assert_true(atomic_load(&completion.done));
assert_int_equal(completion.result, ISC_R_SUCCESS);
r.base = (void *)recvbuf;
r.length = BUFSIZ;
completion_init(&completion);
result = isc_socket_recv(s2, &r, 1, test_task, event_done, &completion);
assert_int_equal(result, ISC_R_SUCCESS);
waitfor(&completion);
assert_true(atomic_load(&completion.done));
assert_int_equal(completion.result, ISC_R_SUCCESS);
assert_string_equal(recvbuf, "Hello");
}
/* Test UDP sendto/recv (IPv4) */
static void
udp_dscp_v4_test(void **state) {
isc_result_t result;
isc_sockaddr_t addr1, addr2;
struct in_addr in;
char sendbuf[BUFSIZ], recvbuf[BUFSIZ];
completion_t completion;
isc_region_t r;
isc_socketevent_t *socketevent;
UNUSED(state);
in.s_addr = inet_addr("127.0.0.1");
isc_sockaddr_fromin(&addr1, &in, 0);
isc_sockaddr_fromin(&addr2, &in, 0);
result = isc_socket_create(socketmgr, PF_INET, isc_sockettype_udp, &s1);
assert_int_equal(result, ISC_R_SUCCESS);
result = isc_socket_bind(s1, &addr1, ISC_SOCKET_REUSEADDRESS);
assert_int_equal(result, ISC_R_SUCCESS);
result = isc_socket_getsockname(s1, &addr1);
assert_int_equal(result, ISC_R_SUCCESS);
assert_true(isc_sockaddr_getport(&addr1) != 0);
result = isc_socket_create(socketmgr, PF_INET, isc_sockettype_udp, &s2);
assert_int_equal(result, ISC_R_SUCCESS);
result = isc_socket_bind(s2, &addr2, ISC_SOCKET_REUSEADDRESS);
assert_int_equal(result, ISC_R_SUCCESS);
result = isc_socket_getsockname(s2, &addr2);
assert_int_equal(result, ISC_R_SUCCESS);
assert_true(isc_sockaddr_getport(&addr2) != 0);
result = isc_task_create(taskmgr, 0, &test_task);
assert_int_equal(result, ISC_R_SUCCESS);
snprintf(sendbuf, sizeof(sendbuf), "Hello");
r.base = (void *)sendbuf;
r.length = strlen(sendbuf) + 1;
completion_init(&completion);
socketevent = isc_socket_socketevent(
test_mctx, s1, ISC_SOCKEVENT_SENDDONE, event_done, &completion);
assert_non_null(socketevent);
if ((isc_net_probedscp() & ISC_NET_DSCPPKTV4) != 0) {
socketevent->dscp = 056; /* EF */
socketevent->attributes |= ISC_SOCKEVENTATTR_DSCP;
} else if ((isc_net_probedscp() & ISC_NET_DSCPSETV4) != 0) {
isc_socket_dscp(s1, 056); /* EF */
socketevent->dscp = 0;
socketevent->attributes &= ~ISC_SOCKEVENTATTR_DSCP;
}
recv_dscp = false;
recv_dscp_value = 0;
result = isc_socket_sendto2(s1, &r, test_task, &addr2, NULL,
socketevent, 0);
assert_int_equal(result, ISC_R_SUCCESS);
waitfor(&completion);
assert_true(atomic_load(&completion.done));
assert_int_equal(completion.result, ISC_R_SUCCESS);
r.base = (void *)recvbuf;
r.length = BUFSIZ;
completion_init(&completion);
result = isc_socket_recv(s2, &r, 1, test_task, event_done, &completion);
assert_int_equal(result, ISC_R_SUCCESS);
waitfor(&completion);
assert_true(atomic_load(&completion.done));
assert_int_equal(completion.result, ISC_R_SUCCESS);
assert_string_equal(recvbuf, "Hello");
if ((isc_net_probedscp() & ISC_NET_DSCPRECVV4) != 0) {
assert_true(recv_dscp);
assert_int_equal(recv_dscp_value, 056);
} else {
assert_false(recv_dscp);
}
}
/* Test UDP sendto/recv (IPv6) */
static void
udp_dscp_v6_test(void **state) {
isc_result_t result;
isc_sockaddr_t addr1, addr2;
struct in6_addr in6;
char sendbuf[BUFSIZ], recvbuf[BUFSIZ];
completion_t completion;
isc_region_t r;
isc_socketevent_t *socketevent;
int n;
UNUSED(state);
n = inet_pton(AF_INET6, "::1", &in6.s6_addr);
assert_true(n == 1);
isc_sockaddr_fromin6(&addr1, &in6, 0);
isc_sockaddr_fromin6(&addr2, &in6, 0);
result = isc_socket_create(socketmgr, PF_INET6, isc_sockettype_udp,
&s1);
assert_int_equal(result, ISC_R_SUCCESS);
result = isc_socket_bind(s1, &addr1, 0);
assert_int_equal(result, ISC_R_SUCCESS);
result = isc_socket_getsockname(s1, &addr1);
assert_int_equal(result, ISC_R_SUCCESS);
assert_true(isc_sockaddr_getport(&addr1) != 0);
result = isc_socket_create(socketmgr, PF_INET6, isc_sockettype_udp,
&s2);
assert_int_equal(result, ISC_R_SUCCESS);
result = isc_socket_bind(s2, &addr2, 0);
assert_int_equal(result, ISC_R_SUCCESS);
result = isc_socket_getsockname(s2, &addr2);
assert_int_equal(result, ISC_R_SUCCESS);
assert_true(isc_sockaddr_getport(&addr2) != 0);
result = isc_task_create(taskmgr, 0, &test_task);
assert_int_equal(result, ISC_R_SUCCESS);
snprintf(sendbuf, sizeof(sendbuf), "Hello");
r.base = (void *)sendbuf;
r.length = strlen(sendbuf) + 1;
completion_init(&completion);
socketevent = isc_socket_socketevent(
test_mctx, s1, ISC_SOCKEVENT_SENDDONE, event_done, &completion);
assert_non_null(socketevent);
if ((isc_net_probedscp() & ISC_NET_DSCPPKTV6) != 0) {
socketevent->dscp = 056; /* EF */
socketevent->attributes = ISC_SOCKEVENTATTR_DSCP;
} else if ((isc_net_probedscp() & ISC_NET_DSCPSETV6) != 0) {
isc_socket_dscp(s1, 056); /* EF */
}
recv_dscp = false;
recv_dscp_value = 0;
result = isc_socket_sendto2(s1, &r, test_task, &addr2, NULL,
socketevent, 0);
assert_int_equal(result, ISC_R_SUCCESS);
waitfor(&completion);
assert_true(atomic_load(&completion.done));
assert_int_equal(completion.result, ISC_R_SUCCESS);
r.base = (void *)recvbuf;
r.length = BUFSIZ;
completion_init(&completion);
result = isc_socket_recv(s2, &r, 1, test_task, event_done, &completion);
assert_int_equal(result, ISC_R_SUCCESS);
waitfor(&completion);
assert_true(atomic_load(&completion.done));
assert_int_equal(completion.result, ISC_R_SUCCESS);
assert_string_equal(recvbuf, "Hello");
if ((isc_net_probedscp() & ISC_NET_DSCPRECVV6) != 0) {
assert_true(recv_dscp);
assert_int_equal(recv_dscp_value, 056);
} else {
assert_false(recv_dscp);
}
}
/* Test TCP sendto/recv (IPv4) */
static void
tcp_dscp_v4_test(void **state) {
isc_result_t result;
isc_sockaddr_t addr1;
struct in_addr in;
char sendbuf[BUFSIZ], recvbuf[BUFSIZ];
completion_t completion, completion2;
isc_region_t r;
UNUSED(state);
in.s_addr = inet_addr("127.0.0.1");
isc_sockaddr_fromin(&addr1, &in, 0);
result = isc_socket_create(socketmgr, PF_INET, isc_sockettype_tcp, &s1);
assert_int_equal(result, ISC_R_SUCCESS);
result = isc_socket_bind(s1, &addr1, 0);
assert_int_equal(result, ISC_R_SUCCESS);
result = isc_socket_getsockname(s1, &addr1);
assert_int_equal(result, ISC_R_SUCCESS);
assert_true(isc_sockaddr_getport(&addr1) != 0);
result = isc_socket_listen(s1, 3);
assert_int_equal(result, ISC_R_SUCCESS);
result = isc_socket_create(socketmgr, PF_INET, isc_sockettype_tcp, &s2);
assert_int_equal(result, ISC_R_SUCCESS);
result = isc_task_create(taskmgr, 0, &test_task);
assert_int_equal(result, ISC_R_SUCCESS);
completion_init(&completion2);
result = isc_socket_accept(s1, test_task, accept_done, &completion2);
assert_int_equal(result, ISC_R_SUCCESS);
completion_init(&completion);
result = isc_socket_connect(s2, &addr1, test_task, event_done,
&completion);
assert_int_equal(result, ISC_R_SUCCESS);
waitfor2(&completion, &completion2);
assert_true(atomic_load(&completion.done));
assert_int_equal(completion.result, ISC_R_SUCCESS);
assert_true(atomic_load(&completion2.done));
assert_int_equal(completion2.result, ISC_R_SUCCESS);
s3 = (isc_socket_t *)atomic_load(&completion2.socket);
isc_socket_dscp(s2, 056); /* EF */
snprintf(sendbuf, sizeof(sendbuf), "Hello");
r.base = (void *)sendbuf;
r.length = strlen(sendbuf) + 1;
recv_dscp = false;
recv_dscp_value = 0;
completion_init(&completion);
result = isc_socket_sendto(s2, &r, test_task, event_done, &completion,
NULL, NULL);
assert_int_equal(result, ISC_R_SUCCESS);
waitfor(&completion);
assert_true(atomic_load(&completion.done));
assert_int_equal(completion.result, ISC_R_SUCCESS);
r.base = (void *)recvbuf;
r.length = BUFSIZ;
completion_init(&completion);
result = isc_socket_recv(s3, &r, 1, test_task, event_done, &completion);
assert_int_equal(result, ISC_R_SUCCESS);
waitfor(&completion);
assert_true(atomic_load(&completion.done));
assert_int_equal(completion.result, ISC_R_SUCCESS);
assert_string_equal(recvbuf, "Hello");
if ((isc_net_probedscp() & ISC_NET_DSCPRECVV4) != 0) {
if (recv_dscp) {
assert_int_equal(recv_dscp_value, 056);
}
} else {
assert_false(recv_dscp);
}
}
/* Test TCP sendto/recv (IPv6) */
static void
tcp_dscp_v6_test(void **state) {
isc_result_t result;
isc_sockaddr_t addr1;
struct in6_addr in6;
char sendbuf[BUFSIZ], recvbuf[BUFSIZ];
completion_t completion, completion2;
isc_region_t r;
int n;
UNUSED(state);
n = inet_pton(AF_INET6, "::1", &in6.s6_addr);
assert_true(n == 1);
isc_sockaddr_fromin6(&addr1, &in6, 0);
result = isc_socket_create(socketmgr, PF_INET6, isc_sockettype_tcp,
&s1);
assert_int_equal(result, ISC_R_SUCCESS);
result = isc_socket_bind(s1, &addr1, 0);
assert_int_equal(result, ISC_R_SUCCESS);
result = isc_socket_getsockname(s1, &addr1);
assert_int_equal(result, ISC_R_SUCCESS);
assert_true(isc_sockaddr_getport(&addr1) != 0);
result = isc_socket_listen(s1, 3);
assert_int_equal(result, ISC_R_SUCCESS);
result = isc_socket_create(socketmgr, PF_INET6, isc_sockettype_tcp,
&s2);
assert_int_equal(result, ISC_R_SUCCESS);
result = isc_task_create(taskmgr, 0, &test_task);
assert_int_equal(result, ISC_R_SUCCESS);
completion_init(&completion2);
result = isc_socket_accept(s1, test_task, accept_done, &completion2);
assert_int_equal(result, ISC_R_SUCCESS);
completion_init(&completion);
result = isc_socket_connect(s2, &addr1, test_task, event_done,
&completion);
assert_int_equal(result, ISC_R_SUCCESS);
waitfor2(&completion, &completion2);
assert_true(atomic_load(&completion.done));
assert_int_equal(completion.result, ISC_R_SUCCESS);
assert_true(atomic_load(&completion2.done));
assert_int_equal(completion2.result, ISC_R_SUCCESS);
s3 = (isc_socket_t *)atomic_load(&completion2.socket);
isc_socket_dscp(s2, 056); /* EF */
snprintf(sendbuf, sizeof(sendbuf), "Hello");
r.base = (void *)sendbuf;
r.length = strlen(sendbuf) + 1;
recv_dscp = false;
recv_dscp_value = 0;
completion_init(&completion);
result = isc_socket_sendto(s2, &r, test_task, event_done, &completion,
NULL, NULL);
assert_int_equal(result, ISC_R_SUCCESS);
waitfor(&completion);
assert_true(atomic_load(&completion.done));
assert_int_equal(completion.result, ISC_R_SUCCESS);
r.base = (void *)recvbuf;
r.length = BUFSIZ;
completion_init(&completion);
result = isc_socket_recv(s3, &r, 1, test_task, event_done, &completion);
assert_int_equal(result, ISC_R_SUCCESS);
waitfor(&completion);
assert_true(atomic_load(&completion.done));
assert_int_equal(completion.result, ISC_R_SUCCESS);
assert_string_equal(recvbuf, "Hello");
if ((isc_net_probedscp() & ISC_NET_DSCPRECVV6) != 0) {
/*
* IPV6_RECVTCLASS is undefined for TCP however
* if we do get it it should be the value we set.
*/
if (recv_dscp) {
assert_int_equal(recv_dscp_value, 056);
}
} else {
assert_false(recv_dscp);
}
}
/* probe dscp capabilities */
static void
net_probedscp_test(void **state) {
unsigned int n;
UNUSED(state);
n = isc_net_probedscp();
assert_true((n & ~ISC_NET_DSCPALL) == 0);
/* ISC_NET_DSCPSETV4 MUST be set if any is set. */
if (n & (ISC_NET_DSCPPKTV4 | ISC_NET_DSCPRECVV4)) {
assert_true((n & ISC_NET_DSCPSETV4) != 0);
}
/* ISC_NET_DSCPSETV6 MUST be set if any is set. */
if (n & (ISC_NET_DSCPPKTV6 | ISC_NET_DSCPRECVV6)) {
assert_true((n & ISC_NET_DSCPSETV6) != 0);
}
#if 0
fprintf(stdout,"IPv4:%s%s%s\n",
(n & ISC_NET_DSCPSETV4) ? " set" : "none",
(n & ISC_NET_DSCPPKTV4) ? " packet" : "",
(n & ISC_NET_DSCPRECVV4) ? " receive" : "");
fprintf(stdout,"IPv6:%s%s%s\n",
(n & ISC_NET_DSCPSETV6) ? " set" : "none",
(n & ISC_NET_DSCPPKTV6) ? " packet" : "",
(n & ISC_NET_DSCPRECVV6) ? " receive" : "");
#endif /* if 0 */
}
/* Test UDP truncation detection */
static void
udp_trunc_test(void **state) {
isc_result_t result;
isc_sockaddr_t addr1, addr2;
struct in_addr in;
char sendbuf[BUFSIZ * 2], recvbuf[BUFSIZ];
completion_t completion;
isc_region_t r;
isc_socketevent_t *socketevent;
UNUSED(state);
in.s_addr = inet_addr("127.0.0.1");
isc_sockaddr_fromin(&addr1, &in, 0);
isc_sockaddr_fromin(&addr2, &in, 0);
result = isc_socket_create(socketmgr, PF_INET, isc_sockettype_udp, &s1);
assert_int_equal(result, ISC_R_SUCCESS);
result = isc_socket_bind(s1, &addr1, ISC_SOCKET_REUSEADDRESS);
assert_int_equal(result, ISC_R_SUCCESS);
result = isc_socket_getsockname(s1, &addr1);
assert_int_equal(result, ISC_R_SUCCESS);
assert_true(isc_sockaddr_getport(&addr1) != 0);
result = isc_socket_create(socketmgr, PF_INET, isc_sockettype_udp, &s2);
assert_int_equal(result, ISC_R_SUCCESS);
result = isc_socket_bind(s2, &addr2, ISC_SOCKET_REUSEADDRESS);
assert_int_equal(result, ISC_R_SUCCESS);
result = isc_socket_getsockname(s2, &addr2);
assert_int_equal(result, ISC_R_SUCCESS);
assert_true(isc_sockaddr_getport(&addr2) != 0);
result = isc_task_create(taskmgr, 0, &test_task);
assert_int_equal(result, ISC_R_SUCCESS);
/*
* Send a message that will not be truncated.
*/
memset(sendbuf, 0xff, sizeof(sendbuf));
snprintf(sendbuf, sizeof(sendbuf), "Hello");
r.base = (void *)sendbuf;
r.length = strlen(sendbuf) + 1;
completion_init(&completion);
socketevent = isc_socket_socketevent(
test_mctx, s1, ISC_SOCKEVENT_SENDDONE, event_done, &completion);
assert_non_null(socketevent);
result = isc_socket_sendto2(s1, &r, test_task, &addr2, NULL,
socketevent, 0);
assert_int_equal(result, ISC_R_SUCCESS);
waitfor(&completion);
assert_true(atomic_load(&completion.done));
assert_int_equal(completion.result, ISC_R_SUCCESS);
r.base = (void *)recvbuf;
r.length = BUFSIZ;
completion_init(&completion);
recv_trunc = false;
result = isc_socket_recv(s2, &r, 1, test_task, event_done, &completion);
assert_int_equal(result, ISC_R_SUCCESS);
waitfor(&completion);
assert_true(atomic_load(&completion.done));
assert_int_equal(completion.result, ISC_R_SUCCESS);
assert_string_equal(recvbuf, "Hello");
assert_false(recv_trunc);
/*
* Send a message that will be truncated.
*/
memset(sendbuf, 0xff, sizeof(sendbuf));
snprintf(sendbuf, sizeof(sendbuf), "Hello");
r.base = (void *)sendbuf;
r.length = sizeof(sendbuf);
completion_init(&completion);
socketevent = isc_socket_socketevent(
test_mctx, s1, ISC_SOCKEVENT_SENDDONE, event_done, &completion);
assert_non_null(socketevent);
result = isc_socket_sendto2(s1, &r, test_task, &addr2, NULL,
socketevent, 0);
assert_int_equal(result, ISC_R_SUCCESS);
waitfor(&completion);
assert_true(atomic_load(&completion.done));
assert_int_equal(completion.result, ISC_R_SUCCESS);
r.base = (void *)recvbuf;
r.length = BUFSIZ;
completion_init(&completion);
recv_trunc = false;
result = isc_socket_recv(s2, &r, 1, test_task, event_done, &completion);
assert_int_equal(result, ISC_R_SUCCESS);
waitfor(&completion);
assert_true(atomic_load(&completion.done));
assert_int_equal(completion.result, ISC_R_SUCCESS);
assert_string_equal(recvbuf, "Hello");
assert_true(recv_trunc);
}
/*
* Main
*/
int
main(void) {
const struct CMUnitTest tests[] = {
cmocka_unit_test_setup_teardown(udp_sendto_test, _setup,
_teardown),
cmocka_unit_test_setup_teardown(tcp_dscp_v4_test, _setup,
_teardown),
cmocka_unit_test_setup_teardown(tcp_dscp_v6_test, _setup,
_teardown),
cmocka_unit_test_setup_teardown(udp_dscp_v4_test, _setup,
_teardown),
cmocka_unit_test_setup_teardown(udp_dscp_v6_test, _setup,
_teardown),
cmocka_unit_test_setup_teardown(net_probedscp_test, _setup,
_teardown),
cmocka_unit_test_setup_teardown(udp_trunc_test, _setup,
_teardown),
};
return (cmocka_run_group_tests(tests, NULL, NULL));
}
#else /* HAVE_CMOCKA */
#include <stdio.h>
int
main(void) {
printf("1..0 # Skipped: cmocka not available\n");
return (SKIPPED_TEST_EXIT_CODE);
}
#endif /* if HAVE_CMOCKA */

View File

@ -721,7 +721,7 @@ manytasks(void **state) {
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
isc_mem_create(&mctx);
isc_managers_create(mctx, 4, 0, 0, &netmgr, &taskmgr, NULL, NULL);
isc_managers_create(mctx, 4, 0, &netmgr, &taskmgr, NULL);
atomic_init(&done, false);
@ -736,7 +736,7 @@ manytasks(void **state) {
}
UNLOCK(&lock);
isc_managers_destroy(&netmgr, &taskmgr, NULL, NULL);
isc_managers_destroy(&netmgr, &taskmgr, NULL);
isc_mem_destroy(&mctx);
isc_condition_destroy(&cv);

View File

@ -1271,7 +1271,7 @@ static cfg_clausedef_t options_clauses[] = {
{ "random-device", &cfg_type_qstringornone, 0 },
{ "recursing-file", &cfg_type_qstring, 0 },
{ "recursive-clients", &cfg_type_uint32, 0 },
{ "reserved-sockets", &cfg_type_uint32, 0 },
{ "reserved-sockets", &cfg_type_uint32, CFG_CLAUSEFLAG_DEPRECATED },
{ "secroots-file", &cfg_type_qstring, 0 },
{ "serial-queries", NULL, CFG_CLAUSEFLAG_ANCIENT },
{ "serial-query-rate", &cfg_type_uint32, 0 },

View File

@ -97,10 +97,9 @@ struct ns_interface {
isc_result_t
ns_interfacemgr_create(isc_mem_t *mctx, ns_server_t *sctx,
isc_taskmgr_t *taskmgr, isc_timermgr_t *timermgr,
isc_socketmgr_t *socketmgr, isc_nm_t *nm,
dns_dispatchmgr_t *dispatchmgr, isc_task_t *task,
dns_geoip_databases_t *geoip, int ncpus,
ns_interfacemgr_t **mgrp);
isc_nm_t *nm, dns_dispatchmgr_t *dispatchmgr,
isc_task_t *task, dns_geoip_databases_t *geoip,
int ncpus, ns_interfacemgr_t **mgrp);
/*%<
* Create a new interface manager.
*

View File

@ -66,14 +66,13 @@ struct ns_interfacemgr {
unsigned int magic; /*%< Magic number */
isc_refcount_t references;
isc_mutex_t lock;
isc_mem_t *mctx; /*%< Memory context */
ns_server_t *sctx; /*%< Server context */
isc_taskmgr_t *taskmgr; /*%< Task manager */
isc_task_t *excl; /*%< Exclusive task */
isc_timermgr_t *timermgr; /*%< Timer manager */
isc_socketmgr_t *socketmgr; /*%< Socket manager */
isc_nm_t *nm; /*%< Net manager */
int ncpus; /*%< Number of workers */
isc_mem_t *mctx; /*%< Memory context */
ns_server_t *sctx; /*%< Server context */
isc_taskmgr_t *taskmgr; /*%< Task manager */
isc_task_t *excl; /*%< Exclusive task */
isc_timermgr_t *timermgr; /*%< Timer manager */
isc_nm_t *nm; /*%< Net manager */
int ncpus; /*%< Number of workers */
dns_dispatchmgr_t *dispatchmgr;
unsigned int generation; /*%< Current generation no */
ns_listenlist_t *listenon4;
@ -189,10 +188,9 @@ route_connected(isc_nmhandle_t *handle, isc_result_t eresult, void *arg) {
isc_result_t
ns_interfacemgr_create(isc_mem_t *mctx, ns_server_t *sctx,
isc_taskmgr_t *taskmgr, isc_timermgr_t *timermgr,
isc_socketmgr_t *socketmgr, isc_nm_t *nm,
dns_dispatchmgr_t *dispatchmgr, isc_task_t *task,
dns_geoip_databases_t *geoip, int ncpus,
ns_interfacemgr_t **mgrp) {
isc_nm_t *nm, dns_dispatchmgr_t *dispatchmgr,
isc_task_t *task, dns_geoip_databases_t *geoip,
int ncpus, ns_interfacemgr_t **mgrp) {
isc_result_t result;
ns_interfacemgr_t *mgr = NULL;
@ -205,7 +203,6 @@ ns_interfacemgr_create(isc_mem_t *mctx, ns_server_t *sctx,
mgr = isc_mem_get(mctx, sizeof(*mgr));
*mgr = (ns_interfacemgr_t){ .taskmgr = taskmgr,
.timermgr = timermgr,
.socketmgr = socketmgr,
.nm = nm,
.dispatchmgr = dispatchmgr,
.generation = 1,

View File

@ -30,7 +30,6 @@
#include <isc/random.h>
#include <isc/resource.h>
#include <isc/result.h>
#include <isc/socket.h>
#include <isc/stdio.h>
#include <isc/string.h>
#include <isc/task.h>
@ -57,7 +56,6 @@ isc_nm_t *netmgr = NULL;
isc_taskmgr_t *taskmgr = NULL;
isc_task_t *maintask = NULL;
isc_timermgr_t *timermgr = NULL;
isc_socketmgr_t *socketmgr = NULL;
dns_zonemgr_t *zonemgr = NULL;
dns_dispatchmgr_t *dispatchmgr = NULL;
ns_clientmgr_t *clientmgr = NULL;
@ -202,8 +200,7 @@ cleanup_managers(void) {
isc_managers_destroy(netmgr == NULL ? NULL : &netmgr,
taskmgr == NULL ? NULL : &taskmgr,
timermgr == NULL ? NULL : &timermgr,
socketmgr == NULL ? NULL : &socketmgr);
timermgr == NULL ? NULL : &timermgr);
if (app_running) {
isc_app_finish();
@ -226,8 +223,7 @@ create_managers(void) {
isc_event_t *event = NULL;
ncpus = isc_os_ncpus();
isc_managers_create(mctx, ncpus, 0, 0, &netmgr, &taskmgr, &timermgr,
&socketmgr);
isc_managers_create(mctx, ncpus, 0, &netmgr, &taskmgr, &timermgr);
CHECK(isc_task_create_bound(taskmgr, 0, &maintask, 0));
isc_taskmgr_setexcltask(taskmgr, maintask);
CHECK(isc_task_onshutdown(maintask, shutdown_managers, NULL));
@ -236,8 +232,8 @@ create_managers(void) {
CHECK(dns_dispatchmgr_create(mctx, netmgr, &dispatchmgr));
CHECK(ns_interfacemgr_create(mctx, sctx, taskmgr, timermgr, socketmgr,
netmgr, dispatchmgr, maintask, NULL, ncpus,
CHECK(ns_interfacemgr_create(mctx, sctx, taskmgr, timermgr, netmgr,
dispatchmgr, maintask, NULL, ncpus,
&interfacemgr));
CHECK(ns_listenlist_default(mctx, port, -1, true, &listenon));

View File

@ -54,7 +54,6 @@ extern isc_log_t *lctx;
extern isc_taskmgr_t *taskmgr;
extern isc_task_t *maintask;
extern isc_timermgr_t *timermgr;
extern isc_socketmgr_t *socketmgr;
extern dns_zonemgr_t *zonemgr;
extern dns_dispatchmgr_t *dispatchmgr;
extern ns_clientmgr_t *clientmgr;

View File

@ -1691,7 +1691,6 @@
./lib/isc/include/isc/serial.h C 1999,2000,2001,2004,2005,2006,2007,2009,2016,2018,2019,2020,2021
./lib/isc/include/isc/siphash.h C 2019,2020,2021
./lib/isc/include/isc/sockaddr.h C 1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2009,2012,2015,2016,2018,2019,2020,2021
./lib/isc/include/isc/socket.h C 1998,1999,2000,2001,2002,2004,2005,2006,2007,2008,2009,2011,2012,2013,2014,2016,2018,2019,2020,2021
./lib/isc/include/isc/stat.h C 2004,2007,2014,2016,2018,2019,2020,2021
./lib/isc/include/isc/stats.h C 2009,2012,2016,2018,2019,2020,2021
./lib/isc/include/isc/stdatomic.h C 2019,2020,2021
@ -1761,8 +1760,6 @@
./lib/isc/serial.c C 1999,2000,2001,2004,2005,2007,2016,2018,2019,2020,2021
./lib/isc/siphash.c C 2019,2020,2021
./lib/isc/sockaddr.c C 1999,2000,2001,2002,2003,2004,2005,2006,2007,2010,2011,2012,2014,2015,2016,2017,2018,2019,2020,2021
./lib/isc/socket.c C 1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021
./lib/isc/socket_p.h C 2021
./lib/isc/stats.c C 2009,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021
./lib/isc/stdio.c C 2000,2001,2004,2007,2011,2012,2013,2014,2016,2018,2019,2020,2021
./lib/isc/stdtime.c C 1999,2000,2001,2004,2005,2007,2016,2018,2019,2020,2021
@ -1800,7 +1797,6 @@
./lib/isc/tests/safe_test.c C 2013,2015,2016,2017,2018,2019,2020,2021
./lib/isc/tests/siphash_test.c C 2019,2020,2021
./lib/isc/tests/sockaddr_test.c C 2012,2015,2016,2017,2018,2019,2020,2021
./lib/isc/tests/socket_test.c C 2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021
./lib/isc/tests/stats_test.c C 2021
./lib/isc/tests/symtab_test.c C 2011,2012,2013,2016,2018,2019,2020,2021
./lib/isc/tests/task_test.c C 2011,2012,2016,2017,2018,2019,2020,2021