mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 14:07:59 +00:00
Convert setting of the TLS contexts to to isc_async callback
Simplify the setting of the TLS contexts by using the isc_async API from the loopmgr instead of using the asychronous netievent mechanism in the netmgr.
This commit is contained in:
@@ -250,7 +250,6 @@ struct isc_nmhandle {
|
|||||||
};
|
};
|
||||||
|
|
||||||
typedef enum isc__netievent_type {
|
typedef enum isc__netievent_type {
|
||||||
netievent_settlsctx,
|
|
||||||
netievent_sockstop, /* for multilayer sockets */
|
netievent_sockstop, /* for multilayer sockets */
|
||||||
} isc__netievent_type;
|
} isc__netievent_type;
|
||||||
|
|
||||||
@@ -1509,9 +1508,6 @@ void
|
|||||||
isc__nm_streamdns_failed_read_cb(isc_nmsocket_t *sock, isc_result_t result,
|
isc__nm_streamdns_failed_read_cb(isc_nmsocket_t *sock, isc_result_t result,
|
||||||
bool async);
|
bool async);
|
||||||
|
|
||||||
void
|
|
||||||
isc__nm_async_settlsctx(isc__networker_t *worker, isc__netievent_t *ev0);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
isc__nm_async_sockstop(isc__networker_t *worker, isc__netievent_t *ev0);
|
isc__nm_async_sockstop(isc__networker_t *worker, isc__netievent_t *ev0);
|
||||||
|
|
||||||
@@ -1629,14 +1625,12 @@ isc__nmsocket_stop(isc_nmsocket_t *listener);
|
|||||||
|
|
||||||
NETIEVENT_SOCKET_REQ_RESULT_TYPE(sendcb);
|
NETIEVENT_SOCKET_REQ_RESULT_TYPE(sendcb);
|
||||||
|
|
||||||
NETIEVENT_SOCKET_TLSCTX_TYPE(settlsctx);
|
|
||||||
NETIEVENT_SOCKET_TYPE(sockstop);
|
NETIEVENT_SOCKET_TYPE(sockstop);
|
||||||
|
|
||||||
/* Now declared the helper functions */
|
/* Now declared the helper functions */
|
||||||
|
|
||||||
NETIEVENT_SOCKET_REQ_RESULT_DECL(sendcb);
|
NETIEVENT_SOCKET_REQ_RESULT_DECL(sendcb);
|
||||||
|
|
||||||
NETIEVENT_SOCKET_TLSCTX_DECL(settlsctx);
|
|
||||||
NETIEVENT_SOCKET_DECL(sockstop);
|
NETIEVENT_SOCKET_DECL(sockstop);
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@@ -439,7 +439,6 @@ process_netievent(void *arg) {
|
|||||||
isc__networker_t *worker = ievent->worker;
|
isc__networker_t *worker = ievent->worker;
|
||||||
|
|
||||||
switch (ievent->type) {
|
switch (ievent->type) {
|
||||||
NETIEVENT_CASE(settlsctx);
|
|
||||||
NETIEVENT_CASE(sockstop);
|
NETIEVENT_CASE(sockstop);
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
@@ -465,7 +464,6 @@ isc__nm_put_netievent(isc__networker_t *worker, void *ievent) {
|
|||||||
isc__networker_unref(worker);
|
isc__networker_unref(worker);
|
||||||
}
|
}
|
||||||
|
|
||||||
NETIEVENT_SOCKET_TLSCTX_DEF(settlsctx);
|
|
||||||
NETIEVENT_SOCKET_DEF(sockstop);
|
NETIEVENT_SOCKET_DEF(sockstop);
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -2380,23 +2378,27 @@ isc_nm_verify_tls_peer_result_string(const isc_nmhandle_t *handle) {
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
typedef struct settlsctx_data {
|
||||||
isc__nm_async_settlsctx(isc__networker_t *worker, isc__netievent_t *ev0) {
|
isc_nmsocket_t *listener;
|
||||||
isc__netievent__tlsctx_t *ev_tlsctx = (isc__netievent__tlsctx_t *)ev0;
|
isc_tlsctx_t *tlsctx;
|
||||||
const int tid = isc_tid();
|
} settlsctx_data_t;
|
||||||
isc_nmsocket_t *listener = ev_tlsctx->sock;
|
|
||||||
isc_tlsctx_t *tlsctx = ev_tlsctx->tlsctx;
|
|
||||||
|
|
||||||
UNUSED(worker);
|
static void
|
||||||
|
settlsctx_cb(void *arg) {
|
||||||
|
settlsctx_data_t *data = arg;
|
||||||
|
const uint32_t tid = isc_tid();
|
||||||
|
isc_nmsocket_t *listener = data->listener;
|
||||||
|
isc_tlsctx_t *tlsctx = data->tlsctx;
|
||||||
|
isc__networker_t *worker = &listener->worker->netmgr->workers[tid];
|
||||||
|
|
||||||
|
isc_mem_put(worker->loop->mctx, data, sizeof(*data));
|
||||||
|
|
||||||
|
REQUIRE(listener->type == isc_nm_tlslistener);
|
||||||
|
|
||||||
switch (listener->type) {
|
|
||||||
case isc_nm_tlslistener:
|
|
||||||
isc__nm_async_tls_set_tlsctx(listener, tlsctx, tid);
|
isc__nm_async_tls_set_tlsctx(listener, tlsctx, tid);
|
||||||
break;
|
|
||||||
default:
|
isc__nmsocket_detach(&listener);
|
||||||
UNREACHABLE();
|
isc_tlsctx_free(&tlsctx);
|
||||||
break;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -2407,10 +2409,13 @@ set_tlsctx_workers(isc_nmsocket_t *listener, isc_tlsctx_t *tlsctx) {
|
|||||||
for (size_t i = 0; i < nworkers; i++) {
|
for (size_t i = 0; i < nworkers; i++) {
|
||||||
isc__networker_t *worker =
|
isc__networker_t *worker =
|
||||||
&listener->worker->netmgr->workers[i];
|
&listener->worker->netmgr->workers[i];
|
||||||
isc__netievent__tlsctx_t *ievent =
|
settlsctx_data_t *data = isc_mem_getx(
|
||||||
isc__nm_get_netievent_settlsctx(worker, listener,
|
worker->loop->mctx, sizeof(*data), ISC_MEM_ZERO);
|
||||||
tlsctx);
|
|
||||||
isc__nm_enqueue_ievent(worker, (isc__netievent_t *)ievent);
|
isc__nmsocket_attach(listener, &data->listener);
|
||||||
|
isc_tlsctx_attach(tlsctx, &data->tlsctx);
|
||||||
|
|
||||||
|
isc_async_run(worker->loop, settlsctx_cb, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user