Refactor the interface handling in the netmgr

The isc_nmiface_t type was holding just a single isc_sockaddr_t,
so we got rid of the datatype and use plain isc_sockaddr_t in place
where isc_nmiface_t was used before.  This means less type-casting and
shorter path to access isc_sockaddr_t members.

At the same time, instead of keeping the reference to the isc_sockaddr_t
that was passed to us when we start listening, we will keep a local
copy. This prevents the data race on destruction of the ns_interface_t
objects where pending nmsockets could reference the sockaddr of already
destroyed ns_interface_t object.
This commit is contained in:
Ondřej Surý
2021-05-26 08:15:34 +02:00
parent bef3a9b01f
commit 50270de8a0
20 changed files with 350 additions and 419 deletions

View File

@@ -266,20 +266,20 @@ run(void) {
switch (protocol) {
case UDP:
result = isc_nm_listenudp(netmgr, (isc_nmiface_t *)&sockaddr,
read_cb, NULL, 0, &sock);
result = isc_nm_listenudp(netmgr, &sockaddr, read_cb, NULL, 0,
&sock);
break;
case TCP:
result = isc_nm_listentcpdns(netmgr, (isc_nmiface_t *)&sockaddr,
read_cb, NULL, accept_cb, NULL, 0,
0, NULL, &sock);
result = isc_nm_listentcpdns(netmgr, &sockaddr, read_cb, NULL,
accept_cb, NULL, 0, 0, NULL,
&sock);
break;
case DOT: {
isc_tlsctx_createserver(NULL, NULL, &tls_ctx);
result = isc_nm_listentlsdns(netmgr, (isc_nmiface_t *)&sockaddr,
read_cb, NULL, accept_cb, NULL, 0,
0, NULL, tls_ctx, &sock);
result = isc_nm_listentlsdns(netmgr, &sockaddr, read_cb, NULL,
accept_cb, NULL, 0, 0, NULL,
tls_ctx, &sock);
break;
}
case HTTPS:
@@ -288,8 +288,8 @@ run(void) {
if (is_https) {
isc_tlsctx_createserver(NULL, NULL, &tls_ctx);
}
result = isc_nm_listenhttp(netmgr, (isc_nmiface_t *)&sockaddr,
0, NULL, tls_ctx, &sock);
result = isc_nm_listenhttp(netmgr, &sockaddr, 0, NULL, tls_ctx,
&sock);
if (result == ISC_R_SUCCESS) {
result = isc_nm_http_endpoint(sock, DEFAULT_DOH_PATH,
read_cb, NULL, 0);