153 lines
3.7 KiB
C
153 lines
3.7 KiB
C
#ifndef _TFE_ACCEPTOR_KNI_H
|
|
#define _TFE_ACCEPTOR_KNI_H
|
|
|
|
#ifdef __cpluscplus
|
|
extern "C"
|
|
{
|
|
#endif
|
|
|
|
#include <sched.h>
|
|
|
|
// #include "proxy.h"
|
|
#include "tfe_utils.h"
|
|
#include "tfe_timestamp.h"
|
|
#include "tfe_packet_io.h"
|
|
#include "tfe_session_table.h"
|
|
|
|
/******************************************************************************
|
|
* Struct For tap
|
|
******************************************************************************/
|
|
|
|
struct tap_config
|
|
{
|
|
int enable_iouring;
|
|
int enable_debuglog;
|
|
|
|
int ring_size;
|
|
int buff_size;
|
|
|
|
int flags;
|
|
int sq_thread_idle;
|
|
|
|
char src_mac[6];
|
|
char tap_mac[6];
|
|
char tap_c_mac[6];
|
|
char tap_s_mac[6];
|
|
char tap_device[16];
|
|
char tap_c_device[16];
|
|
char tap_s_device[16];
|
|
int tap_rps_enable;
|
|
char tap_rps_mask[TFE_SYMBOL_MAX];
|
|
|
|
struct bpf_ctx *tap_bpf_ctx;
|
|
};
|
|
|
|
struct tap_ctx
|
|
{
|
|
int tap_s;
|
|
int tap_c;
|
|
int tap_fd;
|
|
|
|
struct io_uring_instance *io_uring_fd;
|
|
struct io_uring_instance *io_uring_c;
|
|
struct io_uring_instance *io_uring_s;
|
|
|
|
int buff_size;
|
|
char *buff;
|
|
};
|
|
|
|
/******************************************************************************
|
|
* Struct For Thread
|
|
******************************************************************************/
|
|
struct acceptor_thread_ctx
|
|
{
|
|
pthread_t tid;
|
|
int thread_index;
|
|
|
|
struct tap_ctx *tap_ctx;
|
|
struct session_table *session_table;
|
|
struct sf_metrics *sf_metrics;
|
|
|
|
struct tap_config *ref_tap_config;
|
|
struct packet_io *ref_io;
|
|
struct global_metrics *ref_metrics;
|
|
struct policy_enforcer *ref_enforcer;
|
|
struct acceptor_ctx *ref_acceptor_ctx;
|
|
struct tfe_proxy *ref_proxy;
|
|
|
|
int session_table_need_reset;
|
|
};
|
|
|
|
/******************************************************************************
|
|
* Struct For Session
|
|
******************************************************************************/
|
|
|
|
struct packet_info
|
|
{
|
|
int dir_is_e2i;
|
|
struct addr_tuple4 tuple4;
|
|
char *addr_string;
|
|
|
|
char *header_data;
|
|
int header_len;
|
|
|
|
struct sids sids;
|
|
struct route_ctx route_ctx;
|
|
};
|
|
|
|
struct session_ctx
|
|
{
|
|
int policy_ids;
|
|
uint64_t session_id;
|
|
|
|
uint16_t user_field;
|
|
|
|
struct route_ctx raw_pkt_i2e_route_ctx;
|
|
struct route_ctx raw_pkt_e2i_route_ctx;
|
|
|
|
struct sids raw_pkt_i2e_sids;
|
|
struct sids raw_pkt_e2i_sids;
|
|
|
|
// depending on first control packet
|
|
struct packet_info first_ctrl_pkt;
|
|
|
|
// 加锁
|
|
struct tfe_cmsg *cmsg;
|
|
struct acceptor_thread_ctx *ref_thread_ctx;
|
|
};
|
|
|
|
struct session_ctx *session_ctx_new();
|
|
void session_ctx_free(struct session_ctx *ctx);
|
|
|
|
/******************************************************************************
|
|
* Struct For KNI
|
|
******************************************************************************/
|
|
|
|
struct acceptor_ctx
|
|
{
|
|
int firewall_sids;
|
|
int sce_sids;
|
|
int nr_worker_threads;
|
|
|
|
int cpu_affinity_mask[TFE_THREAD_MAX];
|
|
|
|
cpu_set_t coremask;
|
|
struct tap_config *config;
|
|
struct timestamp *ts;
|
|
struct packet_io *io;
|
|
struct global_metrics *metrics;
|
|
struct policy_enforcer *enforcer;
|
|
struct acceptor_thread_ctx work_threads[TFE_THREAD_MAX];
|
|
|
|
struct tfe_proxy *ref_proxy;
|
|
};
|
|
|
|
struct acceptor_ctx *acceptor_ctx_create(const char *profile);
|
|
void acceptor_ctx_destory(struct acceptor_ctx *ctx);
|
|
|
|
#ifdef __cpluscplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|