TSG-14938 TFE支持新控制报文格式; 调整代码结构
This commit is contained in:
8207
common/include/mpack.h
Normal file
8207
common/include/mpack.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -12,6 +12,8 @@ void tap_close(int sockfd);
|
||||
int tap_up_link(const char *eth);
|
||||
int tap_get_mtu(const char *eth);
|
||||
|
||||
int tap_set_rps(const char *eth, int thread_index, const char *rps_mask);
|
||||
|
||||
#ifdef __cpluscplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,147 +0,0 @@
|
||||
#ifndef _TFE_ACCEPTOR_KNI_H
|
||||
#define _TFE_ACCEPTOR_KNI_H
|
||||
|
||||
#ifdef __cpluscplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <sched.h>
|
||||
#include <pthread.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 is_e2i_dir;
|
||||
struct addr_tuple4 tuple4;
|
||||
|
||||
char *header_data;
|
||||
int header_len;
|
||||
};
|
||||
|
||||
struct session_ctx
|
||||
{
|
||||
int policy_ids;
|
||||
uint64_t session_id;
|
||||
char *session_addr;
|
||||
|
||||
char client_mac[6];
|
||||
char server_mac[6];
|
||||
|
||||
struct packet_info c2s_info;
|
||||
struct packet_info s2c_info;
|
||||
|
||||
struct metadata *raw_meta_i2e;
|
||||
struct metadata *raw_meta_e2i;
|
||||
struct metadata *ctrl_meta;
|
||||
|
||||
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 packet_io *io;
|
||||
struct global_metrics *metrics;
|
||||
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
|
||||
@@ -6,15 +6,104 @@ extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct packet_io *packet_io_create(const char *profile, int thread_num, cpu_set_t *coremask);
|
||||
void packet_io_destory(struct packet_io *handle);
|
||||
#include "tfe_addr_tuple4.h"
|
||||
|
||||
struct tap_ctx
|
||||
{
|
||||
int tap_s;
|
||||
int tap_c;
|
||||
int tap_fd;
|
||||
|
||||
int eventfd;
|
||||
int eventfd_c;
|
||||
int eventfd_s;
|
||||
|
||||
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 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 packet_io *ref_io;
|
||||
struct global_metrics *ref_metrics;
|
||||
struct policy_enforcer *ref_enforcer;
|
||||
struct tfe_proxy *ref_proxy;
|
||||
struct acceptor_kni_v4 *ref_acceptor_ctx;
|
||||
|
||||
int session_table_need_reset;
|
||||
};
|
||||
|
||||
struct packet_info
|
||||
{
|
||||
int is_e2i_dir;
|
||||
struct addr_tuple4 tuple4;
|
||||
|
||||
char *header_data;
|
||||
int header_len;
|
||||
};
|
||||
|
||||
struct session_ctx
|
||||
{
|
||||
int policy_ids;
|
||||
uint64_t session_id;
|
||||
char *session_addr;
|
||||
|
||||
char client_mac[6];
|
||||
char server_mac[6];
|
||||
|
||||
struct packet_info c2s_info;
|
||||
struct packet_info s2c_info;
|
||||
|
||||
struct metadata *raw_meta_i2e;
|
||||
struct metadata *raw_meta_e2i;
|
||||
struct metadata *ctrl_meta;
|
||||
|
||||
struct tfe_cmsg *cmsg;
|
||||
|
||||
struct acceptor_thread_ctx *ref_thread_ctx;
|
||||
};
|
||||
|
||||
struct acceptor_kni_v4
|
||||
{
|
||||
int firewall_sids;
|
||||
int proxy_sids;
|
||||
int sce_sids;
|
||||
int nr_worker_threads;
|
||||
|
||||
int cpu_affinity_mask[TFE_THREAD_MAX];
|
||||
|
||||
cpu_set_t coremask;
|
||||
struct packet_io *io;
|
||||
struct global_metrics *metrics;
|
||||
struct acceptor_thread_ctx work_threads[TFE_THREAD_MAX];
|
||||
|
||||
struct tfe_proxy *ref_proxy;
|
||||
};
|
||||
|
||||
int is_enable_iouring(struct packet_io *handle);
|
||||
|
||||
void tfe_tap_ctx_destory(struct tap_ctx *handler);
|
||||
struct tap_ctx *tfe_tap_ctx_create(void *ctx);
|
||||
|
||||
int packet_io_thread_init(struct packet_io *handle, struct acceptor_thread_ctx *thread_ctx);
|
||||
void packet_io_thread_wait(struct packet_io *handle, struct acceptor_thread_ctx *thread_ctx, int timeout_ms);
|
||||
void packet_io_destory(struct packet_io *handle);
|
||||
struct packet_io *packet_io_create(const char *profile, int thread_num, cpu_set_t *coremask);
|
||||
|
||||
int packet_io_polling_nf_interface(struct packet_io *handle, int thread_seq, void *ctx);
|
||||
void handle_raw_packet_from_tap(const char *data, int len, void *args);
|
||||
void handle_decryption_packet_from_tap(const char *data, int len, void *args);
|
||||
void handle_raw_packet_from_tap(const char *data, int len, void *args);
|
||||
|
||||
#ifdef __cpluscplus
|
||||
}
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
#ifndef _TFE_TAP_RSS_H_
|
||||
#define _TFE_TAP_RSS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#define TAP_RSS_LOG_TAG "TAP_RSS: "
|
||||
|
||||
struct bpf_ctx;
|
||||
|
||||
int tfe_tap_get_bpf_prog_fd(struct bpf_ctx *ctx);
|
||||
|
||||
struct bpf_ctx *tfe_tap_global_load_rss_bpf(const char *bpf_obj_file, uint32_t bpf_queue_num, uint32_t bpf_hash_mode, uint32_t bpf_debug_log, void *logger);
|
||||
void tfe_tap_global_unload_rss_bpf(struct bpf_ctx *ctx);
|
||||
|
||||
struct tap_ctx *tfe_tap_ctx_create(void *ctx);
|
||||
|
||||
struct tap_config *tfe_tap_config_create(const char *profile, int thread_num);
|
||||
void tfe_tap_destory(struct tap_config *tap);
|
||||
|
||||
int tfe_tap_set_rps(void *local_logger, const char *tap_name, int thread_num, const char *rps_mask);
|
||||
|
||||
int tfe_tap_open_per_thread(const char *tap_dev, int tap_flags, int bpf_prog_fd, void *logger);
|
||||
void tfe_tap_close_per_thread(int tap_fd);
|
||||
|
||||
int tfe_tap_read_per_thread(int tap_fd, char *buff, int buff_size, void *logger);
|
||||
int tfe_tap_write_per_thread(int tap_fd, const char *data, int data_len, void *logger);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,24 +0,0 @@
|
||||
#ifndef _TFE_TIMESTAMP_H
|
||||
#define _TFE_TIMESTAMP_H
|
||||
|
||||
#ifdef __cpluscplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
struct timestamp *timestamp_new(uint64_t update_interval_ms);
|
||||
void timestamp_free(struct timestamp *ts);
|
||||
|
||||
void timestamp_update(struct timestamp *ts);
|
||||
uint64_t timestamp_update_interval_ms(struct timestamp *ts);
|
||||
|
||||
uint64_t timestamp_get_sec(struct timestamp *ts);
|
||||
uint64_t timestamp_get_msec(struct timestamp *ts);
|
||||
|
||||
#ifdef __cpluscplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user