perf: 性能优化
* io_uring使用buffer pool避免内存分配与释放
* packet io thread与worker thread无锁访问cmsg
* 为解密流量的fd设置默认的TTL
This commit is contained in:
@@ -27,15 +27,15 @@ struct io_uring_instance;
|
||||
struct io_uring_instance *io_uring_instance_create(int sockfd, int eventfd, int ring_size, int buff_size, int flags, int sq_thread_idle, int enable_debug);
|
||||
void io_uring_instance_destory(struct io_uring_instance *instance);
|
||||
|
||||
typedef void read_callback(const char *data, int len, void *args);
|
||||
typedef void io_uring_read_cb(const char *data, int len, void *args);
|
||||
// return 0 : success
|
||||
// reutrn -1 : error
|
||||
int io_uring_register_read_callback(struct io_uring_instance *instance, read_callback *read_cb, void *cb_arg);
|
||||
int io_uring_set_read_cb(struct io_uring_instance *instance, io_uring_read_cb *read_cb, void *cb_arg);
|
||||
// return 0 : success
|
||||
// reutrn -1 : error
|
||||
int io_uring_submit_write_entry(struct io_uring_instance *instance, const char *data, int len);
|
||||
int io_uring_write(struct io_uring_instance *instance, const char *data, int len);
|
||||
// returns the number of processed entrys
|
||||
int io_uring_peek_ready_entrys(struct io_uring_instance *instance);
|
||||
int io_uring_polling(struct io_uring_instance *instance);
|
||||
|
||||
#ifdef __cpluscplus
|
||||
}
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
#ifndef _RAW_SOCKET_H
|
||||
#define _RAW_SOCKET_H
|
||||
|
||||
#ifdef __cpluscplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <linux/if_packet.h>
|
||||
#include <net/ethernet.h>
|
||||
|
||||
struct raw_socket
|
||||
{
|
||||
int sockfd;
|
||||
char interface[16];
|
||||
struct ether_addr mac_addr;
|
||||
struct sockaddr_ll sockaddr;
|
||||
};
|
||||
|
||||
struct raw_socket *raw_socket_create(const char *interface, int fd_so_mask);
|
||||
void raw_socket_destory(struct raw_socket *raw);
|
||||
int raw_socket_send(struct raw_socket *raw, const char *data, int data_len);
|
||||
int raw_socket_recv(struct raw_socket *raw, char *buff, int buff_size);
|
||||
|
||||
#ifdef __cpluscplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -22,9 +22,6 @@ struct tap_ctx
|
||||
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 packet_io_thread_ctx
|
||||
|
||||
@@ -40,6 +40,10 @@ struct tcp_restore_info
|
||||
void tfe_tcp_restore_info_dump(const struct tcp_restore_info *info);
|
||||
int tfe_tcp_restore_fd_create(const struct tcp_restore_endpoint *endpoint, const struct tcp_restore_endpoint *peer, const char *devname, unsigned int fd_so_mask);
|
||||
|
||||
int tfe_tcp_restore_syn_packet(struct tcp_restore_info *info, struct ether_addr *client_mac, struct ether_addr *server_mac, char *buffer, int size);
|
||||
int tfe_tcp_restore_synack_packet(struct tcp_restore_info *info, struct ether_addr *client_mac, struct ether_addr *server_mac, char *buffer, int size);
|
||||
int tfe_tcp_restore_ack_packet(struct tcp_restore_info *info, struct ether_addr *client_mac, struct ether_addr *server_mac, char *buffer, int size);
|
||||
|
||||
#ifdef __cpluscplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
#define TFE_PATH_MAX 256
|
||||
#define TFE_SYMBOL_MAX 64
|
||||
#define TFE_THREAD_MAX 128
|
||||
#define TFE_FAKE_C_DEFAULT_TTL 60
|
||||
#define TFE_FAKE_S_DEFAULT_TTL 65
|
||||
|
||||
#ifndef TFE_CONFIG_BACKLOG_DEFAULT
|
||||
#define TFE_CONFIG_BACKLOG_DEFAULT 20
|
||||
|
||||
Reference in New Issue
Block a user