TFE适配MRZCPD的分流算法的变更;并增加分流的调试日志
This commit is contained in:
@@ -328,11 +328,11 @@ static inline void select_rss_queue(struct packet *packet, struct bpf_config *co
|
||||
{
|
||||
packet->src_addr_hash = crc32_hash(&packet->in4_src, 4, 0);
|
||||
packet->dst_addr_hash = crc32_hash(&packet->in4_dst, 4, 0);
|
||||
packet->last_hash = packet->src_addr_hash ^ packet->dst_addr_hash;
|
||||
packet->last_hash = packet->src_addr_hash + packet->dst_addr_hash;
|
||||
|
||||
packet->src_port_hash = crc32_hash(&packet->src_port, 2, packet->last_hash);
|
||||
packet->dst_port_hash = crc32_hash(&packet->dst_port, 2, packet->last_hash);
|
||||
packet->last_hash = packet->src_port_hash ^ packet->dst_port_hash;
|
||||
packet->last_hash = packet->src_port_hash + packet->dst_port_hash;
|
||||
|
||||
packet->select_queue = packet->last_hash % bpf_config_get_queue_num(config);
|
||||
}
|
||||
@@ -340,7 +340,7 @@ static inline void select_rss_queue(struct packet *packet, struct bpf_config *co
|
||||
{
|
||||
packet->src_addr_hash = crc32_hash(&packet->in4_src, 4, 0);
|
||||
packet->dst_addr_hash = crc32_hash(&packet->in4_dst, 4, 0);
|
||||
packet->last_hash = packet->src_addr_hash ^ packet->dst_addr_hash;
|
||||
packet->last_hash = packet->src_addr_hash + packet->dst_addr_hash;
|
||||
|
||||
packet->select_queue = packet->last_hash % bpf_config_get_queue_num(config);
|
||||
}
|
||||
@@ -352,11 +352,11 @@ static inline void select_rss_queue(struct packet *packet, struct bpf_config *co
|
||||
{
|
||||
packet->src_addr_hash = crc32_hash(&packet->in6_src, 16, 0);
|
||||
packet->dst_addr_hash = crc32_hash(&packet->in6_dst, 16, 0);
|
||||
packet->last_hash = packet->src_addr_hash ^ packet->dst_addr_hash;
|
||||
packet->last_hash = packet->src_addr_hash + packet->dst_addr_hash;
|
||||
|
||||
packet->src_port_hash = crc32_hash(&packet->src_port, 2, packet->last_hash);
|
||||
packet->dst_port_hash = crc32_hash(&packet->dst_port, 2, packet->last_hash);
|
||||
packet->last_hash = packet->src_port_hash ^ packet->dst_port_hash;
|
||||
packet->last_hash = packet->src_port_hash + packet->dst_port_hash;
|
||||
|
||||
packet->select_queue = packet->last_hash % bpf_config_get_queue_num(config);
|
||||
}
|
||||
@@ -364,7 +364,7 @@ static inline void select_rss_queue(struct packet *packet, struct bpf_config *co
|
||||
{
|
||||
packet->src_addr_hash = crc32_hash(&packet->in6_src, 16, 0);
|
||||
packet->dst_addr_hash = crc32_hash(&packet->in6_dst, 16, 0);
|
||||
packet->last_hash = packet->src_addr_hash ^ packet->dst_addr_hash;
|
||||
packet->last_hash = packet->src_addr_hash + packet->dst_addr_hash;
|
||||
|
||||
packet->select_queue = packet->last_hash % bpf_config_get_queue_num(config);
|
||||
}
|
||||
|
||||
@@ -80,6 +80,7 @@ struct session_ctx
|
||||
|
||||
struct acceptor_kni_v4
|
||||
{
|
||||
int debug;
|
||||
int firewall_sids;
|
||||
int proxy_sids;
|
||||
int sce_sids;
|
||||
|
||||
@@ -90,8 +90,10 @@ int raw_packet_parser_get_most_outer_tuple4(struct raw_pkt_parser *handler, stru
|
||||
int raw_packet_parser_get_most_inner_address(struct raw_pkt_parser *handler, struct addr_tuple4 *addr, void *logger);
|
||||
int raw_packet_parser_get_most_outer_address(struct raw_pkt_parser *handler, struct addr_tuple4 *addr, void *logger);
|
||||
|
||||
uint64_t raw_packet_parser_get_hash_value(struct raw_pkt_parser *handler, enum ldbc_method method, int dir_is_internal, void *logger);
|
||||
uint16_t raw_packet_parser_get_most_inner_ipid(struct raw_pkt_parser *handler);
|
||||
uint16_t raw_packet_parser_get_most_outer_ipid(struct raw_pkt_parser *handler);
|
||||
|
||||
uint64_t raw_packet_parser_get_hash_value(struct raw_pkt_parser *handler, enum ldbc_method method, int dir_is_internal, void *logger);
|
||||
|
||||
int raw_traffic_decapsulate(struct raw_pkt_parser *handler, char *raw_data, int raw_len, char **output, int *out_len, int *is_ipv4);
|
||||
|
||||
|
||||
@@ -1536,6 +1536,22 @@ static int handle_raw_packet_from_nf(struct packet_io *handle, marsio_buff_t *rx
|
||||
if (node == NULL) {
|
||||
throughput_metrics_inc(&packet_io_fs->raw_pkt_rx, 1, raw_len);
|
||||
throughput_metrics_inc(&packet_io_fs->raw_bypass, 1, raw_len);
|
||||
|
||||
if (thread->ref_acceptor_ctx->debug)
|
||||
{
|
||||
struct addr_tuple4 inner_addr;
|
||||
struct raw_pkt_parser raw_parser;
|
||||
memset(&inner_addr, 0, sizeof(struct addr_tuple4));
|
||||
raw_packet_parser_init(&raw_parser, 0, LAYER_TYPE_ALL, 8);
|
||||
raw_packet_parser_parse(&raw_parser, (const void *)raw_data, raw_len, logger);
|
||||
raw_packet_parser_get_most_inner_tuple4(&raw_parser, &inner_addr, logger);
|
||||
uint16_t ipid = raw_packet_parser_get_most_inner_ipid(&raw_parser);
|
||||
|
||||
char *str = addr_tuple4_to_str(&inner_addr);
|
||||
TFE_LOG_ERROR(logger, "packet from nf %lu: %s (ipid: %u) miss session table", meta.session_id, str, ipid);
|
||||
free(str);
|
||||
}
|
||||
|
||||
marsio_send_burst(handle->dev_nf_interface.mr_path, thread_seq, &rx_buff, 1);
|
||||
return -1;
|
||||
}
|
||||
@@ -1913,6 +1929,7 @@ int packet_io_polling_nf_interface(struct packet_io *handle, int thread_seq, voi
|
||||
{
|
||||
marsio_buff_t *rx_buff = rx_buffs[j];
|
||||
int raw_len = marsio_buff_datalen(rx_buff);
|
||||
char *raw_data = marsio_buff_mtod(rx_buff);
|
||||
|
||||
if (is_downstream_keepalive_packet(rx_buff))
|
||||
{
|
||||
@@ -1926,6 +1943,21 @@ int packet_io_polling_nf_interface(struct packet_io *handle, int thread_seq, voi
|
||||
continue;
|
||||
}
|
||||
|
||||
if (thread->ref_acceptor_ctx->debug)
|
||||
{
|
||||
struct addr_tuple4 inner_addr;
|
||||
struct raw_pkt_parser raw_parser;
|
||||
memset(&inner_addr, 0, sizeof(struct addr_tuple4));
|
||||
raw_packet_parser_init(&raw_parser, 0, LAYER_TYPE_ALL, 8);
|
||||
raw_packet_parser_parse(&raw_parser, (const void *)raw_data, raw_len, thread->logger);
|
||||
raw_packet_parser_get_most_inner_tuple4(&raw_parser, &inner_addr, thread->logger);
|
||||
uint16_t ipid = raw_packet_parser_get_most_inner_ipid(&raw_parser);
|
||||
|
||||
char *str = addr_tuple4_to_str(&inner_addr);
|
||||
TFE_LOG_DEBUG(thread->logger, "recv packet %s (ipid: %u)", str, ipid);
|
||||
free(str);
|
||||
}
|
||||
|
||||
if (marsio_buff_is_ctrlbuf(rx_buff))
|
||||
{
|
||||
throughput_metrics_inc(&packet_io_fs->raw_pkt_rx, 1, raw_len);
|
||||
@@ -2041,6 +2073,15 @@ void handle_raw_packet_from_tap(const char *data, int len, void *args)
|
||||
struct session_node *node = session_table_search_by_addr(thread->session_table, &inner_addr);
|
||||
if (node == NULL) {
|
||||
throughput_metrics_inc(&packet_io_fs->tap_pkt_rxdrop, 1, len);
|
||||
|
||||
if (thread->ref_acceptor_ctx->debug)
|
||||
{
|
||||
char *str = addr_tuple4_to_str(&inner_addr);
|
||||
uint16_t ipid = raw_packet_parser_get_most_inner_ipid(&raw_parser);
|
||||
TFE_LOG_ERROR(logger, "packet from tap %s (ipid: %u) miss session table", str, ipid);
|
||||
free(str);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -271,6 +271,64 @@ int raw_packet_parser_get_most_outer_address(struct raw_pkt_parser *handler, str
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint16_t raw_packet_parser_get_most_inner_ipid(struct raw_pkt_parser *handler)
|
||||
{
|
||||
const char *l3_layer_data = NULL;
|
||||
struct layer_results *results = &handler->results;
|
||||
|
||||
// search L3 layer in reverse order
|
||||
for (int8_t i = results->layers_used - 1; i >= 0; i--)
|
||||
{
|
||||
const struct layer_result *layer = &results->layers[i];
|
||||
enum layer_type type = layer->type;
|
||||
|
||||
if (type & LAYER_TYPE_L3)
|
||||
{
|
||||
l3_layer_data = (const char *)handler->ptr_pkt_start + layer->offset;
|
||||
if (type == LAYER_TYPE_IPV4)
|
||||
{
|
||||
const struct ip *ipv4_hdr = (const struct ip *)l3_layer_data;
|
||||
return ntohs(ipv4_hdr->ip_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint16_t raw_packet_parser_get_most_outer_ipid(struct raw_pkt_parser *handler)
|
||||
{
|
||||
const char *l3_layer_data = NULL;
|
||||
struct layer_results *results = &handler->results;
|
||||
|
||||
// search L3 layer in order
|
||||
for (int8_t i = 0; i <= results->layers_used - 1; i++)
|
||||
{
|
||||
const struct layer_result *layer = &results->layers[i];
|
||||
enum layer_type type = layer->type;
|
||||
|
||||
if (type & LAYER_TYPE_L3)
|
||||
{
|
||||
l3_layer_data = (const char *)handler->ptr_pkt_start + layer->offset;
|
||||
if (type == LAYER_TYPE_IPV4)
|
||||
{
|
||||
const struct ip *ipv4_hdr = (const struct ip *)l3_layer_data;
|
||||
return ntohs(ipv4_hdr->ip_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint64_t raw_packet_parser_get_hash_value(struct raw_pkt_parser *handler, enum ldbc_method method, int dir_is_internal, void *logger)
|
||||
{
|
||||
uint64_t temp = 0;
|
||||
|
||||
@@ -228,6 +228,7 @@ app_name="proxy_rule_hits"
|
||||
|
||||
# for enable kni v4
|
||||
[packet_io]
|
||||
packet_io_debug=0
|
||||
packet_io_threads=8
|
||||
packet_io_cpu_affinity_mask=1-9
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
[global]
|
||||
|
||||
default format = "%d(%c), %V, %F, %U, %m%n"
|
||||
default format = "%d(%c), %t, %V, %F, %U, %m%n"
|
||||
|
||||
[levels]
|
||||
|
||||
|
||||
@@ -85,6 +85,7 @@ struct acceptor_kni_v4 *acceptor_ctx_create(const char *profile, void *logger)
|
||||
MESA_load_profile_int_def(profile, "PACKET_IO", "firewall_sids", (int *)&(ctx->firewall_sids), 1000);
|
||||
MESA_load_profile_int_def(profile, "PACKET_IO", "proxy_sids", (int *)&(ctx->proxy_sids), 1001);
|
||||
MESA_load_profile_int_def(profile, "PACKET_IO", "service_chaining_sids", (int *)&(ctx->sce_sids), 1002);
|
||||
MESA_load_profile_int_def(profile, "PACKET_IO", "packet_io_debug", (int *)&(ctx->debug), 0);
|
||||
MESA_load_profile_int_def(profile, "PACKET_IO", "packet_io_threads", (int *)&(ctx->nr_worker_threads), 8);
|
||||
MESA_load_profile_uint_range(profile, "PACKET_IO", "packet_io_cpu_affinity_mask", TFE_THREAD_MAX, (unsigned int *)ctx->cpu_affinity_mask);
|
||||
ctx->nr_worker_threads = MIN(ctx->nr_worker_threads, TFE_THREAD_MAX);
|
||||
|
||||
Reference in New Issue
Block a user