perf: 优化session_ctx减少内存占用; 优化global metrics的结构
This commit is contained in:
@@ -67,6 +67,30 @@ struct packet_io
|
||||
* metadata
|
||||
******************************************************************************/
|
||||
|
||||
static inline void sids_copy(struct sids *dst, struct sids *src)
|
||||
{
|
||||
if (dst && src)
|
||||
{
|
||||
dst->num = src->num;
|
||||
memcpy(dst->elems, src->elems, sizeof(dst->elems[0]) * dst->num);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void route_ctx_copy(struct route_ctx *dst, struct route_ctx *src)
|
||||
{
|
||||
memcpy(dst->data, src->data, src->len);
|
||||
dst->len = src->len;
|
||||
}
|
||||
|
||||
static inline void route_ctx_copy_once(struct route_ctx *dst, struct route_ctx *src)
|
||||
{
|
||||
if (dst->len == 0)
|
||||
{
|
||||
memcpy(dst->data, src->data, src->len);
|
||||
dst->len = src->len;
|
||||
}
|
||||
}
|
||||
|
||||
void sce_packet_get_innermost_tuple(const struct packet *handler, struct four_tuple *tuple)
|
||||
{
|
||||
memset(tuple, 0, sizeof(struct four_tuple));
|
||||
@@ -205,47 +229,39 @@ int mbuff_set_metadata(marsio_buff_t *tx_buff, struct metadata *meta)
|
||||
|
||||
static void update_session_by_metadata(struct session_ctx *ctx, struct metadata *meta)
|
||||
{
|
||||
struct metadata *dst_meta_i2e = NULL;
|
||||
struct metadata *dst_meta_e2i = NULL;
|
||||
struct sids *e2i_sids = NULL;
|
||||
struct sids *i2e_sids = NULL;
|
||||
struct route_ctx *e2i_route_ctx = NULL;
|
||||
struct route_ctx *i2e_route_ctx = NULL;
|
||||
|
||||
if (meta->is_decrypted)
|
||||
{
|
||||
dst_meta_i2e = &ctx->decrypted_meta_i2e;
|
||||
dst_meta_e2i = &ctx->decrypted_meta_e2i;
|
||||
e2i_sids = &ctx->decrypted_e2i_sids;
|
||||
i2e_sids = &ctx->decrypted_i2e_sids;
|
||||
|
||||
e2i_route_ctx = &ctx->decrypted_e2i_route_ctx;
|
||||
i2e_route_ctx = &ctx->decrypted_i2e_route_ctx;
|
||||
}
|
||||
else
|
||||
{
|
||||
dst_meta_i2e = &ctx->raw_meta_i2e;
|
||||
dst_meta_e2i = &ctx->raw_meta_e2i;
|
||||
e2i_sids = &ctx->raw_e2i_sids;
|
||||
i2e_sids = &ctx->raw_i2e_sids;
|
||||
|
||||
e2i_route_ctx = &ctx->raw_e2i_route_ctx;
|
||||
i2e_route_ctx = &ctx->raw_i2e_route_ctx;
|
||||
}
|
||||
|
||||
// 1: E2I
|
||||
// 0: I2E
|
||||
if (meta->direction)
|
||||
{
|
||||
// first packet update metadata
|
||||
if (metadata_isempty(dst_meta_e2i))
|
||||
{
|
||||
metadata_copy(dst_meta_e2i, meta);
|
||||
}
|
||||
else
|
||||
{
|
||||
// next packet only update sids
|
||||
sids_copy(&dst_meta_e2i->sids, &meta->sids);
|
||||
}
|
||||
route_ctx_copy_once(e2i_route_ctx, &meta->route_ctx);
|
||||
sids_copy(e2i_sids, &meta->sids);
|
||||
}
|
||||
else
|
||||
{
|
||||
// first packet update metadata
|
||||
if (metadata_isempty(dst_meta_i2e))
|
||||
{
|
||||
metadata_copy(dst_meta_i2e, meta);
|
||||
}
|
||||
else
|
||||
{
|
||||
// next packet only update sids
|
||||
sids_copy(&dst_meta_i2e->sids, &meta->sids);
|
||||
}
|
||||
route_ctx_copy_once(i2e_route_ctx, &meta->route_ctx);
|
||||
sids_copy(i2e_sids, &meta->sids);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,26 +278,26 @@ static void update_metadata_by_session(struct session_ctx *ctx, struct metadata
|
||||
{
|
||||
if (meta->is_decrypted)
|
||||
{
|
||||
sids = &(ctx->decrypted_meta_e2i.sids);
|
||||
route_ctx = &(ctx->decrypted_meta_e2i.route_ctx);
|
||||
sids = &(ctx->decrypted_e2i_sids);
|
||||
route_ctx = &(ctx->decrypted_e2i_route_ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
sids = &(ctx->raw_meta_e2i.sids);
|
||||
route_ctx = &(ctx->raw_meta_e2i.route_ctx);
|
||||
sids = &(ctx->raw_e2i_sids);
|
||||
route_ctx = &(ctx->raw_e2i_route_ctx);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (meta->is_decrypted)
|
||||
{
|
||||
sids = &(ctx->decrypted_meta_i2e.sids);
|
||||
route_ctx = &(ctx->decrypted_meta_i2e.route_ctx);
|
||||
sids = &(ctx->decrypted_i2e_sids);
|
||||
route_ctx = &(ctx->decrypted_i2e_route_ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
sids = &(ctx->raw_meta_i2e.sids);
|
||||
route_ctx = &(ctx->raw_meta_i2e.route_ctx);
|
||||
sids = &(ctx->raw_i2e_sids);
|
||||
route_ctx = &(ctx->raw_i2e_route_ctx);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,7 +311,7 @@ static void update_metadata_by_session(struct session_ctx *ctx, struct metadata
|
||||
|
||||
// return 0 : not keepalive packet
|
||||
// return 1 : is keepalive packet
|
||||
static int is_downlink_keepalive_packet(marsio_buff_t *rx_buff, int raw_len)
|
||||
static inline int is_downlink_keepalive_packet(marsio_buff_t *rx_buff, int raw_len)
|
||||
{
|
||||
char *raw_data = marsio_buff_mtod(rx_buff);
|
||||
if (raw_data == NULL || raw_len < (int)(sizeof(struct ethhdr)))
|
||||
@@ -316,7 +332,7 @@ static int is_downlink_keepalive_packet(marsio_buff_t *rx_buff, int raw_len)
|
||||
|
||||
// return 0 : not keepalive packet
|
||||
// return 1 : is keepalive packet
|
||||
static int is_uplink_keepalive_packet(marsio_buff_t *rx_buff, int raw_len)
|
||||
static inline int is_uplink_keepalive_packet(marsio_buff_t *rx_buff, int raw_len)
|
||||
{
|
||||
char *raw_data = marsio_buff_mtod(rx_buff);
|
||||
if (raw_data == NULL || raw_len < (int)(sizeof(struct ethhdr) + sizeof(struct ip) + sizeof(struct udphdr)))
|
||||
@@ -495,7 +511,7 @@ static inline int send_packet_to_sf(struct session_ctx *session_ctx, marsio_buff
|
||||
char *buffer = NULL;
|
||||
struct packet_io *packet_io = thread_ctx->ref_io;
|
||||
struct thread_metrics *thread_metrics = &thread_ctx->thread_metrics;
|
||||
uint32_t rehash_index = session_ctx->ctrl_meta.rehash_index;
|
||||
uint32_t rehash_index = session_ctx->rehash_index;
|
||||
|
||||
marsio_buff_ctrlzone_reset(mbuff);
|
||||
switch (sf->sf_connectivity.method)
|
||||
@@ -511,7 +527,7 @@ static inline int send_packet_to_sf(struct session_ctx *session_ctx, marsio_buff
|
||||
nsend = marsio_buff_datalen(mbuff);
|
||||
marsio_buff_set_metadata(mbuff, MR_BUFF_REHASH_INDEX, &rehash_index, sizeof(rehash_index));
|
||||
marsio_send_burst(packet_io->dev_endpoint_l3.mr_path, thread_ctx->thread_index, &mbuff, 1);
|
||||
throughput_metrics_inc(&(thread_metrics->device.endpoint_vxlan_tx), 1, nsend);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->endpoint_vxlan_tx), 1, nsend);
|
||||
break;
|
||||
case ENCAPSULATE_METHOD_LAYER2_SWITCH:
|
||||
vlan_encapsulate(mbuff,
|
||||
@@ -520,7 +536,7 @@ static inline int send_packet_to_sf(struct session_ctx *session_ctx, marsio_buff
|
||||
nsend = marsio_buff_datalen(mbuff);
|
||||
marsio_buff_set_metadata(mbuff, MR_BUFF_REHASH_INDEX, &rehash_index, sizeof(rehash_index));
|
||||
marsio_send_burst(packet_io->dev_endpoint_l2.mr_path, thread_ctx->thread_index, &mbuff, 1);
|
||||
throughput_metrics_inc(&(thread_metrics->device.endpoint_vlan_tx), 1, nsend);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->endpoint_vlan_tx), 1, nsend);
|
||||
break;
|
||||
case ENCAPSULATE_METHOD_LAYER3_SWITCH:
|
||||
// TODO
|
||||
@@ -541,7 +557,7 @@ static inline void action_err_bypass(marsio_buff_t *rx_buff, struct metadata *me
|
||||
int nsend = action_nf_inject(rx_buff, meta, sf, thread_ctx);
|
||||
if (nsend > 0)
|
||||
{
|
||||
throughput_metrics_inc(&(thread_metrics->data_pkt.error_bypass), 1, nsend);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->error_bypass), 1, nsend);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -551,7 +567,7 @@ static inline void action_err_block(marsio_buff_t *rx_buff, struct metadata *met
|
||||
struct packet_io *packet_io = thread_ctx->ref_io;
|
||||
int thread_index = thread_ctx->thread_index;
|
||||
|
||||
throughput_metrics_inc(&(thread_metrics->data_pkt.error_block), 1, meta->raw_len);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->error_block), 1, meta->raw_len);
|
||||
marsio_buff_free(packet_io->instance, &rx_buff, 1, 0, thread_index);
|
||||
}
|
||||
|
||||
@@ -570,7 +586,7 @@ static inline int action_nf_inject(marsio_buff_t *rx_buff, struct metadata *meta
|
||||
}
|
||||
|
||||
marsio_send_burst(packet_io->dev_nf.mr_path, thread_index, &rx_buff, 1);
|
||||
throughput_metrics_inc(&(thread_metrics->device.nf_tx), 1, meta->raw_len);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->nf_tx), 1, meta->raw_len);
|
||||
return meta->raw_len;
|
||||
}
|
||||
|
||||
@@ -578,14 +594,14 @@ static inline void action_mirr_bypass(marsio_buff_t *rx_buff, struct metadata *m
|
||||
{
|
||||
struct thread_metrics *thread_metrics = &thread_ctx->thread_metrics;
|
||||
|
||||
throughput_metrics_inc(&(thread_metrics->data_pkt.mirr_bypass), 1, meta->raw_len);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->mirr_bypass), 1, meta->raw_len);
|
||||
}
|
||||
|
||||
static inline void action_mirr_block(marsio_buff_t *rx_buff, struct metadata *meta, struct selected_sf *sf, struct thread_ctx *thread_ctx)
|
||||
{
|
||||
struct thread_metrics *thread_metrics = &thread_ctx->thread_metrics;
|
||||
|
||||
throughput_metrics_inc(&(thread_metrics->data_pkt.mirr_block), 1, meta->raw_len);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->mirr_block), 1, meta->raw_len);
|
||||
}
|
||||
|
||||
static inline void action_mirr_forward(struct session_ctx *session_ctx, marsio_buff_t *rx_buff, struct metadata *meta, struct selected_sf *sf, struct thread_ctx *thread_ctx)
|
||||
@@ -607,8 +623,8 @@ static inline void action_mirr_forward(struct session_ctx *session_ctx, marsio_b
|
||||
memcpy(copy_ptr, raw_data, meta->raw_len);
|
||||
|
||||
int nsend = send_packet_to_sf(session_ctx, new_buff, meta, sf, thread_ctx);
|
||||
throughput_metrics_inc(&(thread_metrics->data_pkt.mirr_tx), 1, meta->raw_len);
|
||||
throughput_metrics_inc(&sf->tx, 1, nsend);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->mirr_tx), 1, meta->raw_len);
|
||||
THROUGHPUT_METRICS_INC(&sf->tx, 1, nsend);
|
||||
struct sf_metrics_key key = {0};
|
||||
key.rule_id = sf->rule_id;
|
||||
key.sff_profile_id = sf->sff_profile_id;
|
||||
@@ -621,7 +637,7 @@ static inline void action_stee_bypass(marsio_buff_t *rx_buff, struct metadata *m
|
||||
{
|
||||
struct thread_metrics *thread_metrics = &thread_ctx->thread_metrics;
|
||||
|
||||
throughput_metrics_inc(&(thread_metrics->data_pkt.stee_bypass), 1, meta->raw_len);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->stee_bypass), 1, meta->raw_len);
|
||||
}
|
||||
|
||||
static inline void action_stee_block(marsio_buff_t *rx_buff, struct metadata *meta, struct selected_sf *sf, struct thread_ctx *thread_ctx)
|
||||
@@ -630,7 +646,7 @@ static inline void action_stee_block(marsio_buff_t *rx_buff, struct metadata *me
|
||||
struct packet_io *packet_io = thread_ctx->ref_io;
|
||||
int thread_index = thread_ctx->thread_index;
|
||||
|
||||
throughput_metrics_inc(&(thread_metrics->data_pkt.stee_block), 1, meta->raw_len);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->stee_block), 1, meta->raw_len);
|
||||
marsio_buff_free(packet_io->instance, &rx_buff, 1, 0, thread_index);
|
||||
}
|
||||
|
||||
@@ -639,8 +655,8 @@ static inline void action_stee_forward(struct session_ctx *session_ctx, marsio_b
|
||||
struct thread_metrics *thread_metrics = &thread_ctx->thread_metrics;
|
||||
|
||||
int nsend = send_packet_to_sf(session_ctx, rx_buff, meta, sf, thread_ctx);
|
||||
throughput_metrics_inc(&(thread_metrics->data_pkt.stee_tx), 1, meta->raw_len);
|
||||
throughput_metrics_inc(&sf->tx, 1, nsend);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->stee_tx), 1, meta->raw_len);
|
||||
THROUGHPUT_METRICS_INC(&sf->tx, 1, nsend);
|
||||
struct sf_metrics_key key = {0};
|
||||
key.rule_id = sf->rule_id;
|
||||
key.sff_profile_id = sf->sff_profile_id;
|
||||
@@ -839,8 +855,8 @@ static int send_ctrl_packet(struct session_ctx *session_ctx, struct thread_ctx *
|
||||
LOG_INFO("%s: session %lu %s send event log %ld bytes", LOG_TAG_SFMETRICS, session_ctx->session_id, session_ctx->session_addr, size);
|
||||
|
||||
marsio_buff_t *tx_buffs[1];
|
||||
const char *packet_header_data = session_ctx->ctrl_packet_header_data;
|
||||
int packet_header_len = session_ctx->ctrl_packet_header_len;
|
||||
const char *packet_header_data = session_ctx->ctrl_pkt_hdr_ptr;
|
||||
int packet_header_len = session_ctx->ctrl_pkt_hdr_len;
|
||||
marsio_buff_malloc_global(packet_io->instance, tx_buffs, 1, 0, thread_index);
|
||||
char *dst = marsio_buff_append(tx_buffs[0], packet_header_len + size);
|
||||
memcpy(dst, packet_header_data, packet_header_len);
|
||||
@@ -852,7 +868,7 @@ static int send_ctrl_packet(struct session_ctx *session_ctx, struct thread_ctx *
|
||||
meta.is_ctrl_pkt = 1;
|
||||
meta.sids.num = 1;
|
||||
meta.sids.elems[0] = sce_ctx->firewall_sids;
|
||||
route_ctx_copy(&meta.route_ctx, &(session_ctx->ctrl_meta.route_ctx));
|
||||
route_ctx_copy(&meta.route_ctx, &(session_ctx->ctrl_route_ctx));
|
||||
mbuff_set_metadata(tx_buffs[0], &meta);
|
||||
int nsend = marsio_buff_datalen(tx_buffs[0]);
|
||||
marsio_send_burst(packet_io->dev_nf.mr_path, thread_index, tx_buffs, 1);
|
||||
@@ -872,9 +888,9 @@ static void send_event_log(struct session_ctx *session_ctx, struct thread_ctx *t
|
||||
nsend = send_ctrl_packet(session_ctx, thread_ctx);
|
||||
if (nsend > 0)
|
||||
{
|
||||
ATOMIC_INC(&(thread_metrics->sf_session.log));
|
||||
throughput_metrics_inc(&(thread_metrics->ctrl_pkt.tx), 1, nsend);
|
||||
throughput_metrics_inc(&(thread_metrics->device.nf_tx), 1, nsend);
|
||||
ATOMIC_INC(&(thread_metrics->session_log));
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->ctrl_tx), 1, nsend);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->nf_tx), 1, nsend);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -945,7 +961,7 @@ static void handle_session_closing(struct metadata *meta, struct control_packet
|
||||
dump_sf_metrics(s_ctx, s_ctx->chaining_decrypted);
|
||||
|
||||
session_table_delete_by_id(session_table, meta->session_id);
|
||||
ATOMIC_DEC(&(thread_metrics->sf_session.num));
|
||||
ATOMIC_DEC(&(thread_metrics->session_num));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -991,11 +1007,12 @@ static void handle_session_active(struct metadata *meta, struct control_packet *
|
||||
struct session_ctx *session_ctx = session_ctx_new();
|
||||
session_ctx->session_id = meta->session_id;
|
||||
session_ctx->session_addr = sce_ctx->enable_debug ? four_tuple_tostring(&inner_tuple4) : NULL;
|
||||
session_ctx->rehash_index = meta->rehash_index;
|
||||
session_ctx->vxlan_src_port = calculate_vxlan_source_port(&inner_tuple4);
|
||||
four_tuple_copy(&session_ctx->inner_tuple4, &inner_tuple4);
|
||||
metadata_copy(&session_ctx->ctrl_meta, meta);
|
||||
session_ctx->ctrl_packet_header_data = memdup(meta->raw_data, meta->raw_len);
|
||||
session_ctx->ctrl_packet_header_len = meta->raw_len;
|
||||
route_ctx_copy(&session_ctx->ctrl_route_ctx, &meta->route_ctx);
|
||||
session_ctx->ctrl_pkt_hdr_ptr = memdup(meta->raw_data, meta->raw_len);
|
||||
session_ctx->ctrl_pkt_hdr_len = meta->raw_len;
|
||||
session_ctx->chaining_raw = selected_chaining_create(chaining_size, session_ctx->session_id, session_ctx->session_addr);
|
||||
session_ctx->chaining_decrypted = selected_chaining_create(chaining_size, session_ctx->session_id, session_ctx->session_addr);
|
||||
session_ctx->ref_thread_ctx = thread_ctx;
|
||||
@@ -1005,7 +1022,7 @@ static void handle_session_active(struct metadata *meta, struct control_packet *
|
||||
send_event_log(session_ctx, thread_ctx);
|
||||
|
||||
session_table_insert(session_table, session_ctx->session_id, &session_ctx->inner_tuple4, session_ctx, session_value_free_cb);
|
||||
ATOMIC_INC(&(thread_metrics->sf_session.num));
|
||||
ATOMIC_INC(&(thread_metrics->session_num));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1015,7 +1032,7 @@ static void handle_session_resetall(struct metadata *meta, struct control_packet
|
||||
struct sce_ctx *sce_ctx = thread_ctx->ref_sce_ctx;
|
||||
|
||||
LOG_ERROR("%s: session %lu resetall: notification clears all session tables !!!", LOG_TAG_PKTIO, meta->session_id);
|
||||
ATOMIC_ZERO(&(global_metrics->sf_session.num));
|
||||
ATOMIC_ZERO(&(global_metrics->sum.session_num));
|
||||
for (int i = 0; i < sce_ctx->nr_worker_threads; i++)
|
||||
{
|
||||
struct thread_ctx *temp_ctx = &sce_ctx->work_threads[i];
|
||||
@@ -1058,20 +1075,20 @@ static void handle_control_packet(marsio_buff_t *rx_buff, struct thread_ctx *thr
|
||||
switch (ctrl_pkt.state)
|
||||
{
|
||||
case SESSION_STATE_OPENING:
|
||||
ATOMIC_INC(&(thread_metrics->ctrl_pkt.opening));
|
||||
ATOMIC_INC(&(thread_metrics->ctrl_opening));
|
||||
// when session opening, firewall not send policy id
|
||||
// return handle_session_opening(&meta, &ctrl_pkt, ctx);
|
||||
break;
|
||||
case SESSION_STATE_CLOSING:
|
||||
ATOMIC_INC(&(thread_metrics->ctrl_pkt.closing));
|
||||
ATOMIC_INC(&(thread_metrics->ctrl_closing));
|
||||
handle_session_closing(&meta, &ctrl_pkt, thread_ctx);
|
||||
break;
|
||||
case SESSION_STATE_ACTIVE:
|
||||
ATOMIC_INC(&(thread_metrics->ctrl_pkt.active));
|
||||
ATOMIC_INC(&(thread_metrics->ctrl_active));
|
||||
handle_session_active(&meta, &ctrl_pkt, thread_ctx);
|
||||
break;
|
||||
case SESSION_STATE_RESETALL:
|
||||
ATOMIC_INC(&(thread_metrics->ctrl_pkt.resetall));
|
||||
ATOMIC_INC(&(thread_metrics->ctrl_resetall));
|
||||
handle_session_resetall(&meta, &ctrl_pkt, thread_ctx);
|
||||
break;
|
||||
default:
|
||||
@@ -1080,7 +1097,7 @@ static void handle_control_packet(marsio_buff_t *rx_buff, struct thread_ctx *thr
|
||||
return;
|
||||
|
||||
error_ctrl_pkt:
|
||||
ATOMIC_INC(&(thread_metrics->ctrl_pkt.error));
|
||||
ATOMIC_INC(&(thread_metrics->ctrl_error));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1122,7 +1139,7 @@ static void handle_data_packet(marsio_buff_t *rx_buff, struct thread_ctx *thread
|
||||
session_ctx = data_packet_search_session(session_table, meta.raw_data, meta.raw_len, meta.session_id);
|
||||
if (session_ctx == NULL)
|
||||
{
|
||||
throughput_metrics_inc(&(thread_metrics->data_pkt.miss_sess), 1, meta.raw_len);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->miss_sess), 1, meta.raw_len);
|
||||
goto error_bypass;
|
||||
}
|
||||
|
||||
@@ -1164,7 +1181,7 @@ static void handle_inject_vxlan_packet(marsio_buff_t *rx_buff, struct thread_ctx
|
||||
char *raw_data = marsio_buff_mtod(rx_buff);
|
||||
if (vxlan_frame_decode(&vxlan_hdr, raw_data, raw_len) == -1)
|
||||
{
|
||||
throughput_metrics_inc(&(thread_metrics->device.endpoint_vxlan_drop), 1, raw_len);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->endpoint_vxlan_drop), 1, raw_len);
|
||||
meta.raw_len = raw_len;
|
||||
action_err_block(rx_buff, &meta, NULL, thread_ctx);
|
||||
return;
|
||||
@@ -1206,14 +1223,14 @@ static void handle_inject_vxlan_packet(marsio_buff_t *rx_buff, struct thread_ctx
|
||||
{
|
||||
LOG_DEBUG("%s: unexpected inject packet, session %lu %s with sf_profile_id %d executes mirror and does not require reflow, drop !!!",
|
||||
LOG_TAG_PKTIO, session_ctx->session_id, session_ctx->session_addr, chaining->chaining[sf_index].sf_profile_id);
|
||||
throughput_metrics_inc(&(thread_metrics->data_pkt.mirr_rx_drop), 1, meta.raw_len);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->mirr_rx_drop), 1, meta.raw_len);
|
||||
goto error_block;
|
||||
}
|
||||
else
|
||||
{
|
||||
struct selected_sf *sf = &(chaining->chaining[sf_index]);
|
||||
throughput_metrics_inc(&sf->rx, 1, raw_len);
|
||||
throughput_metrics_inc(&(thread_metrics->data_pkt.stee_rx), 1, meta.raw_len);
|
||||
THROUGHPUT_METRICS_INC(&sf->rx, 1, raw_len);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->stee_rx), 1, meta.raw_len);
|
||||
struct sf_metrics_key key = {0};
|
||||
key.rule_id = sf->rule_id;
|
||||
key.sff_profile_id = sf->sff_profile_id;
|
||||
@@ -1227,7 +1244,7 @@ static void handle_inject_vxlan_packet(marsio_buff_t *rx_buff, struct thread_ctx
|
||||
return;
|
||||
|
||||
error_block:
|
||||
throughput_metrics_inc(&(thread_metrics->device.endpoint_vxlan_drop), 1, raw_len);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->endpoint_vxlan_drop), 1, raw_len);
|
||||
marsio_buff_adj(rx_buff, raw_len - meta.raw_len);
|
||||
action_err_block(rx_buff, &meta, NULL, thread_ctx);
|
||||
}
|
||||
@@ -1496,8 +1513,8 @@ int packet_io_thread_polling_nf(struct packet_io *handle, struct thread_ctx *thr
|
||||
{
|
||||
int raw_len = marsio_buff_datalen(rx_buffs[j]);
|
||||
|
||||
throughput_metrics_inc(&(thread_metrics->device.nf_rx), 1, raw_len);
|
||||
throughput_metrics_inc(&(thread_metrics->device.nf_tx), 1, raw_len);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->nf_rx), 1, raw_len);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->nf_tx), 1, raw_len);
|
||||
}
|
||||
|
||||
marsio_send_burst(handle->dev_nf.mr_path, thread_index, rx_buffs, nr_recv);
|
||||
@@ -1511,28 +1528,28 @@ int packet_io_thread_polling_nf(struct packet_io *handle, struct thread_ctx *thr
|
||||
|
||||
if (is_downlink_keepalive_packet(rx_buff, raw_len))
|
||||
{
|
||||
throughput_metrics_inc(&(thread_metrics->device.nf_rx), 1, raw_len);
|
||||
throughput_metrics_inc(&(thread_metrics->device.nf_tx), 1, raw_len);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->nf_rx), 1, raw_len);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->nf_tx), 1, raw_len);
|
||||
|
||||
throughput_metrics_inc(&(thread_metrics->kee_pkt.downlink_rx), 1, raw_len);
|
||||
throughput_metrics_inc(&(thread_metrics->kee_pkt.downlink_tx), 1, raw_len);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->downlink_rx), 1, raw_len);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->downlink_tx), 1, raw_len);
|
||||
|
||||
marsio_send_burst(handle->dev_nf.mr_path, thread_index, &rx_buff, 1);
|
||||
}
|
||||
else if (marsio_buff_is_ctrlbuf(rx_buff))
|
||||
{
|
||||
throughput_metrics_inc(&(thread_metrics->device.nf_rx), 1, raw_len);
|
||||
throughput_metrics_inc(&(thread_metrics->device.nf_tx), 1, raw_len);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->nf_rx), 1, raw_len);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->nf_tx), 1, raw_len);
|
||||
|
||||
throughput_metrics_inc(&(thread_metrics->ctrl_pkt.rx), 1, raw_len);
|
||||
throughput_metrics_inc(&(thread_metrics->ctrl_pkt.tx), 1, raw_len);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->ctrl_rx), 1, raw_len);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->ctrl_tx), 1, raw_len);
|
||||
|
||||
handle_control_packet(rx_buff, thread_ctx, raw_len);
|
||||
marsio_send_burst(handle->dev_nf.mr_path, thread_index, &rx_buff, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
throughput_metrics_inc(&(thread_metrics->device.nf_rx), 1, raw_len);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->nf_rx), 1, raw_len);
|
||||
|
||||
handle_data_packet(rx_buff, thread_ctx, raw_len);
|
||||
}
|
||||
@@ -1559,8 +1576,8 @@ int packet_io_thread_polling_endpoint_l3(struct packet_io *handle, struct thread
|
||||
{
|
||||
int raw_len = marsio_buff_datalen(rx_buffs[j]);
|
||||
|
||||
throughput_metrics_inc(&(thread_metrics->device.endpoint_vxlan_rx), 1, raw_len);
|
||||
throughput_metrics_inc(&(thread_metrics->device.endpoint_vxlan_tx), 1, raw_len);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->endpoint_vxlan_rx), 1, raw_len);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->endpoint_vxlan_tx), 1, raw_len);
|
||||
}
|
||||
|
||||
marsio_send_burst(handle->dev_endpoint_l3.mr_path, thread_index, rx_buffs, nr_recv);
|
||||
@@ -1574,15 +1591,15 @@ int packet_io_thread_polling_endpoint_l3(struct packet_io *handle, struct thread
|
||||
|
||||
if (is_uplink_keepalive_packet(rx_buff, raw_len))
|
||||
{
|
||||
throughput_metrics_inc(&(thread_metrics->device.endpoint_vxlan_rx), 1, raw_len);
|
||||
throughput_metrics_inc(&(thread_metrics->kee_pkt.uplink_rx), 1, raw_len);
|
||||
throughput_metrics_inc(&(thread_metrics->kee_pkt.uplink_tx_drop), 1, raw_len);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->endpoint_vxlan_rx), 1, raw_len);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->uplink_rx), 1, raw_len);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->uplink_tx_drop), 1, raw_len);
|
||||
|
||||
marsio_buff_free(handle->instance, &rx_buff, 1, 0, thread_index);
|
||||
}
|
||||
else
|
||||
{
|
||||
throughput_metrics_inc(&(thread_metrics->device.endpoint_vxlan_rx), 1, raw_len);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->endpoint_vxlan_rx), 1, raw_len);
|
||||
|
||||
handle_inject_vxlan_packet(rx_buff, thread_ctx, raw_len);
|
||||
}
|
||||
@@ -1609,8 +1626,8 @@ int packet_io_thread_polling_endpoint_l2(struct packet_io *handle, struct thread
|
||||
{
|
||||
int raw_len = marsio_buff_datalen(rx_buffs[j]);
|
||||
|
||||
throughput_metrics_inc(&(thread_metrics->device.endpoint_vlan_rx), 1, raw_len);
|
||||
throughput_metrics_inc(&(thread_metrics->device.endpoint_vlan_tx), 1, raw_len);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->endpoint_vlan_rx), 1, raw_len);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->endpoint_vlan_tx), 1, raw_len);
|
||||
}
|
||||
|
||||
marsio_send_burst(handle->dev_endpoint_l2.mr_path, thread_index, rx_buffs, nr_recv);
|
||||
@@ -1622,8 +1639,8 @@ int packet_io_thread_polling_endpoint_l2(struct packet_io *handle, struct thread
|
||||
marsio_buff_t *rx_buff = rx_buffs[j];
|
||||
int raw_len = marsio_buff_datalen(rx_buffs[j]);
|
||||
|
||||
throughput_metrics_inc(&(thread_metrics->device.endpoint_vlan_rx), 1, raw_len);
|
||||
throughput_metrics_inc(&(thread_metrics->device.endpoint_vlan_drop), 1, raw_len);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->endpoint_vlan_rx), 1, raw_len);
|
||||
THROUGHPUT_METRICS_INC(&(thread_metrics->endpoint_vlan_drop), 1, raw_len);
|
||||
|
||||
marsio_buff_free(handle->instance, &rx_buff, 1, 0, thread_index);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user