变更kni系列名称到scm
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
add_executable(tfe src/key_keeper.cpp src/kni_acceptor.cpp src/ssl_stream.cpp
|
add_executable(tfe src/acceptor_scm.cpp src/ssl_stream.cpp
|
||||||
src/ssl_sess_cache.cpp src/ssl_sess_ticket.cpp src/ssl_service_cache.cpp
|
src/ssl_sess_cache.cpp src/ssl_sess_ticket.cpp src/ssl_service_cache.cpp
|
||||||
src/ssl_trusted_cert_storage.cpp src/ev_root_ca_metadata.cpp src/ssl_utils.cpp
|
src/ssl_trusted_cert_storage.cpp src/ev_root_ca_metadata.cpp src/ssl_utils.cpp
|
||||||
src/tcp_stream.cpp src/main.cpp src/proxy.cpp)
|
src/tcp_stream.cpp src/main.cpp src/proxy.cpp)
|
||||||
|
|||||||
7
platform/include/internal/acceptor_scm.h
Normal file
7
platform/include/internal/acceptor_scm.h
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
struct tfe_proxy;
|
||||||
|
struct acceptor_scm;
|
||||||
|
|
||||||
|
struct acceptor_scm * acceptor_scm_create(struct tfe_proxy * proxy, const char * profile, void * logger);
|
||||||
|
void acceptor_scm_deinit(struct acceptor_scm * ctx);
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
struct tfe_proxy;
|
|
||||||
struct kni_acceptor;
|
|
||||||
|
|
||||||
struct kni_acceptor * kni_acceptor_init(struct tfe_proxy *proxy, const char *profile, void *logger);
|
|
||||||
void kni_acceptor_deinit(struct kni_acceptor *ctx);
|
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
struct ssl_mgr;
|
struct ssl_mgr;
|
||||||
struct key_keeper;
|
struct key_keeper;
|
||||||
struct kni_acceptor;
|
struct acceptor_scm;
|
||||||
|
|
||||||
enum TFE_STAT_FIELD
|
enum TFE_STAT_FIELD
|
||||||
{
|
{
|
||||||
@@ -93,7 +93,7 @@ struct tfe_proxy
|
|||||||
struct ssl_mgr * ssl_mgr_handler;
|
struct ssl_mgr * ssl_mgr_handler;
|
||||||
struct ssl_policy_enforcer* ssl_ply_enforcer;
|
struct ssl_policy_enforcer* ssl_ply_enforcer;
|
||||||
struct key_keeper * key_keeper_handler;
|
struct key_keeper * key_keeper_handler;
|
||||||
struct kni_acceptor * kni_acceptor_handler;
|
struct acceptor_scm * kni_acceptor_handler;
|
||||||
|
|
||||||
/* DEBUG OPTIONS */
|
/* DEBUG OPTIONS */
|
||||||
unsigned int tcp_all_passthrough;
|
unsigned int tcp_all_passthrough;
|
||||||
|
|||||||
@@ -13,12 +13,12 @@
|
|||||||
|
|
||||||
#include <MESA/MESA_prof_load.h>
|
#include <MESA/MESA_prof_load.h>
|
||||||
#include <tfe_stream.h>
|
#include <tfe_stream.h>
|
||||||
#include <kni_acceptor.h>
|
#include <acceptor_scm.h>
|
||||||
#include <proxy.h>
|
#include <proxy.h>
|
||||||
#include <platform.h>
|
#include <platform.h>
|
||||||
|
|
||||||
#ifndef TFE_CONFIG_KNI_SCM_SOCKET_FILE
|
#ifndef TFE_CONFIG_SCM_SOCKET_FILE
|
||||||
#define TFE_CONFIG_KNI_SCM_SOCKET_FILE "/var/run/.tfe_kmod_scm_socket"
|
#define TFE_CONFIG_SCM_SOCKET_FILE "/var/run/.tfe_kmod_scm_socket"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* The KNI and TFE communicate with each other by UNIX-based socket,
|
/* The KNI and TFE communicate with each other by UNIX-based socket,
|
||||||
@@ -48,7 +48,7 @@
|
|||||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct kni_acceptor
|
struct acceptor_scm
|
||||||
{
|
{
|
||||||
/* INPUT */
|
/* INPUT */
|
||||||
struct tfe_proxy * proxy;
|
struct tfe_proxy * proxy;
|
||||||
@@ -65,9 +65,9 @@ struct kni_acceptor
|
|||||||
pthread_t thread;
|
pthread_t thread;
|
||||||
};
|
};
|
||||||
|
|
||||||
void __kni_event_cb(evutil_socket_t fd, short what, void * user)
|
void acceptor_scm_event(evutil_socket_t fd, short what, void * user)
|
||||||
{
|
{
|
||||||
struct kni_acceptor * __ctx = (struct kni_acceptor *) user;
|
struct acceptor_scm * __ctx = (struct acceptor_scm *) user;
|
||||||
struct cmsghdr * __cmsghdr;
|
struct cmsghdr * __cmsghdr;
|
||||||
struct tfe_proxy_accept_para __accept_para{};
|
struct tfe_proxy_accept_para __accept_para{};
|
||||||
|
|
||||||
@@ -154,17 +154,17 @@ __drop_recieved_fds:
|
|||||||
if (__fds != NULL) evutil_closesocket(__fds[1]);
|
if (__fds != NULL) evutil_closesocket(__fds[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void * kni_acceptor_event_thread_entry(void * args)
|
void * acceptor_scm_event_thread_entry(void * args)
|
||||||
{
|
{
|
||||||
struct kni_acceptor * __ctx = (struct kni_acceptor *) args;
|
struct acceptor_scm * __ctx = (struct acceptor_scm *) args;
|
||||||
assert(__ctx != NULL && __ctx->thread == pthread_self());
|
assert(__ctx != NULL && __ctx->thread == pthread_self());
|
||||||
|
|
||||||
TFE_LOG_INFO(__ctx->logger, "kni acceptor thread is running.");
|
TFE_LOG_INFO(__ctx->logger, "scm acceptor thread is running.");
|
||||||
event_base_dispatch(__ctx->ev_base);
|
event_base_dispatch(__ctx->ev_base);
|
||||||
DIE("kni acceptor thread is exited, abort.");
|
DIE("scm acceptor thread is exited, abort.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void kni_acceptor_deinit(struct kni_acceptor * ctx)
|
void acceptor_scm_deinit(struct acceptor_scm * ctx)
|
||||||
{
|
{
|
||||||
if (ctx != NULL && ctx->ev_base != NULL)
|
if (ctx != NULL && ctx->ev_base != NULL)
|
||||||
{
|
{
|
||||||
@@ -184,9 +184,9 @@ void kni_acceptor_deinit(struct kni_acceptor * ctx)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct kni_acceptor * kni_acceptor_init(struct tfe_proxy * proxy, const char * profile, void * logger)
|
struct acceptor_scm * acceptor_scm_create(struct tfe_proxy * proxy, const char * profile, void * logger)
|
||||||
{
|
{
|
||||||
struct kni_acceptor * __ctx = ALLOC(struct kni_acceptor, 1);
|
struct acceptor_scm * __ctx = ALLOC(struct acceptor_scm, 1);
|
||||||
struct sockaddr_un __sockaddr_un{};
|
struct sockaddr_un __sockaddr_un{};
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
@@ -195,8 +195,8 @@ struct kni_acceptor * kni_acceptor_init(struct tfe_proxy * proxy, const char * p
|
|||||||
__ctx->logger = logger;
|
__ctx->logger = logger;
|
||||||
|
|
||||||
/* Read the unix domain socket file, this file is used to recieve fds from KNI */
|
/* Read the unix domain socket file, this file is used to recieve fds from KNI */
|
||||||
MESA_load_profile_string_def(profile, "kni", "scm_socket_file", __ctx->str_scm_socket_file,
|
MESA_load_profile_string_def(profile, "acceptor_scm", "scm_socket_file", __ctx->str_scm_socket_file,
|
||||||
sizeof(__ctx->str_scm_socket_file), TFE_CONFIG_KNI_SCM_SOCKET_FILE);
|
sizeof(__ctx->str_scm_socket_file), TFE_CONFIG_SCM_SOCKET_FILE);
|
||||||
|
|
||||||
__sockaddr_un.sun_family = AF_UNIX;
|
__sockaddr_un.sun_family = AF_UNIX;
|
||||||
strncpy(__sockaddr_un.sun_path, __ctx->str_scm_socket_file, sizeof(__sockaddr_un.sun_path));
|
strncpy(__sockaddr_un.sun_path, __ctx->str_scm_socket_file, sizeof(__sockaddr_un.sun_path));
|
||||||
@@ -223,7 +223,9 @@ struct kni_acceptor * kni_acceptor_init(struct tfe_proxy * proxy, const char * p
|
|||||||
goto __errout;
|
goto __errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
__ctx->ev_scm_socket = event_new(__ctx->ev_base, __ctx->fd_scm_socket, EV_READ | EV_PERSIST, __kni_event_cb, __ctx);
|
__ctx->ev_scm_socket = event_new(__ctx->ev_base, __ctx->fd_scm_socket,
|
||||||
|
EV_READ | EV_PERSIST, acceptor_scm_event, __ctx);
|
||||||
|
|
||||||
if (unlikely(__ctx->ev_scm_socket == NULL))
|
if (unlikely(__ctx->ev_scm_socket == NULL))
|
||||||
{
|
{
|
||||||
TFE_LOG_ERROR(__ctx->logger, "Failed at setup READ event for scm socket fd %d.", __ctx->fd_scm_socket);
|
TFE_LOG_ERROR(__ctx->logger, "Failed at setup READ event for scm socket fd %d.", __ctx->fd_scm_socket);
|
||||||
@@ -238,7 +240,7 @@ struct kni_acceptor * kni_acceptor_init(struct tfe_proxy * proxy, const char * p
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Create a thread to dispatch ctx->evbase */
|
/* Create a thread to dispatch ctx->evbase */
|
||||||
ret = pthread_create(&__ctx->thread, NULL, kni_acceptor_event_thread_entry, (void *) __ctx);
|
ret = pthread_create(&__ctx->thread, NULL, acceptor_scm_event_thread_entry, (void *) __ctx);
|
||||||
if (unlikely(ret < 0))
|
if (unlikely(ret < 0))
|
||||||
{
|
{
|
||||||
TFE_LOG_ERROR(__ctx->logger, "Failed at creating event thread: %s", strerror(errno));
|
TFE_LOG_ERROR(__ctx->logger, "Failed at creating event thread: %s", strerror(errno));
|
||||||
@@ -249,6 +251,6 @@ struct kni_acceptor * kni_acceptor_init(struct tfe_proxy * proxy, const char * p
|
|||||||
return __ctx;
|
return __ctx;
|
||||||
|
|
||||||
__errout:
|
__errout:
|
||||||
kni_acceptor_deinit(__ctx);
|
acceptor_scm_deinit(__ctx);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
#include <platform.h>
|
#include <platform.h>
|
||||||
#include <proxy.h>
|
#include <proxy.h>
|
||||||
#include <kni_acceptor.h>
|
#include <acceptor_scm.h>
|
||||||
#include <tcp_stream.h>
|
#include <tcp_stream.h>
|
||||||
#include <MESA/MESA_prof_load.h>
|
#include <MESA/MESA_prof_load.h>
|
||||||
#include <MESA/field_stat2.h>
|
#include <MESA/field_stat2.h>
|
||||||
@@ -404,7 +404,7 @@ int main(int argc, char * argv[])
|
|||||||
tfe_proxy_work_thread_create_ctx(g_default_proxy);
|
tfe_proxy_work_thread_create_ctx(g_default_proxy);
|
||||||
|
|
||||||
/* ACCEPTOR INIT */
|
/* ACCEPTOR INIT */
|
||||||
g_default_proxy->kni_acceptor_handler = kni_acceptor_init(g_default_proxy, main_profile, g_default_logger);
|
g_default_proxy->kni_acceptor_handler = acceptor_scm_create(g_default_proxy, main_profile, g_default_logger);
|
||||||
CHECK_OR_EXIT(g_default_proxy->kni_acceptor_handler, "Failed at init KNI acceptor. Exit. ");
|
CHECK_OR_EXIT(g_default_proxy->kni_acceptor_handler, "Failed at init KNI acceptor. Exit. ");
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user