bugfix: TSG-14257 mirror block时客户端无法上网

This commit is contained in:
luwenpeng
2023-03-15 16:03:13 +08:00
parent 56de9db921
commit a1b1824de7

View File

@@ -145,7 +145,7 @@ static int forward_packet_to_sf(struct packet_io *handle, marsio_buff_t *rx_buff
// return + : send n bytes
// return -1 : error
static int mirror_packet_to_sf(struct packet_io *handle, marsio_buff_t *rx_buff, struct metadata *meta, struct selected_sf *sf, int thread_seq, void *ctx);
// rx_buff : include g_vxlan header
// rx_buff : not include g_vxlan header
// return + : send n bytes
// return -1 : error
static int forward_packet_to_nf(struct packet_io *handle, marsio_buff_t *rx_buff, struct metadata *meta, int thread_seq, void *ct);
@@ -796,8 +796,15 @@ static enum raw_pkt_action handle_raw_packet(struct packet_io *handle, marsio_bu
last_sf_is_action_bypass = 1;
continue;
case SESSION_ACTION_BLOCK:
// BLOCK ALL SF
marsio_buff_free(handle->instance, &rx_buff, 1, 0, thread_seq);
if (node->sff_forward_type == FORWARD_TYPE_STEERING)
{
marsio_buff_free(handle->instance, &rx_buff, 1, 0, thread_seq);
}
else
{
marsio_send_burst(handle->dev_nf_interface.mr_path, thread_seq, &rx_buff, 1);
throughput_metrics_inc(&g_metrics->raw_pkt_tx, 1, raw_len);
}
*action_bytes = raw_len;
return RAW_PKT_HIT_BLOCK;
case SESSION_ACTION_FORWARD:
@@ -882,7 +889,6 @@ static enum raw_pkt_action handle_raw_packet(struct packet_io *handle, marsio_bu
static enum inject_pkt_action handle_inject_packet(struct packet_io *handle, marsio_buff_t *rx_buff, int thread_seq, void *ctx, int *action_bytes)
{
int nsend = 0;
int mbuff_is_adj = 0;
struct thread_ctx *thread = (struct thread_ctx *)ctx;
struct global_metrics *g_metrics = thread->ref_metrics;
@@ -962,6 +968,7 @@ static enum inject_pkt_action handle_inject_packet(struct packet_io *handle, mar
sf_metrics_inc(thread->sf_metrics, chaining->chaining[sf_index].policy_id, chaining->chaining[sf_index].sff_profile_id, chaining->chaining[sf_index].sf_profile_id, 1, raw_len, 0, 0);
throughput_metrics_inc(&chaining->chaining[sf_index].rx, 1, raw_len);
marsio_buff_adj(rx_buff, raw_len - meta.raw_len);
int next_sf_index;
for (next_sf_index = sf_index + 1; next_sf_index < chaining->chaining_used; next_sf_index++)
{
@@ -980,10 +987,32 @@ static enum inject_pkt_action handle_inject_packet(struct packet_io *handle, mar
// BYPASS CURRENT SF
continue;
case SESSION_ACTION_BLOCK:
// BLOCK ALL SF
marsio_buff_free(handle->instance, &rx_buff, 1, 0, thread_seq);
*action_bytes = raw_len;
return INJT_PKT_HIT_BLOCK;
if (node->sff_forward_type == FORWARD_TYPE_STEERING)
{
marsio_buff_free(handle->instance, &rx_buff, 1, 0, thread_seq);
*action_bytes = raw_len;
return INJT_PKT_HIT_BLOCK;
}
else
{
// rx_buff : not include g_vxlan header
// return + : send n bytes
// return -1 : error
int nsend = forward_packet_to_nf(handle, rx_buff, &meta, thread_seq, ctx);
if (nsend > 0)
{
*action_bytes = raw_len;
throughput_metrics_inc(&g_metrics->raw_pkt_tx, 1, nsend);
return INJT_PKT_HIT_BLOCK;
}
else
{
LOG_ERROR("%s: processing inject packet, session %lu %s forwarding packet to network function failed, drop !!!", LOG_TAG_PKTIO, s_ctx->session_id, s_ctx->first_ctrl_pkt.addr_string);
marsio_buff_free(handle->instance, &rx_buff, 1, 0, thread_seq);
*action_bytes = raw_len;
return INJT_PKT_ERR_DROP;
}
}
case SESSION_ACTION_FORWARD:
if (node->sf_connectivity.method != PACKAGE_METHOD_VXLAN_G)
{
@@ -993,12 +1022,6 @@ static enum inject_pkt_action handle_inject_packet(struct packet_io *handle, mar
return INJT_PKT_ERR_DROP;
}
if (mbuff_is_adj == 0)
{
marsio_buff_adj(rx_buff, raw_len - meta.raw_len);
mbuff_is_adj = 1;
}
if (node->sff_forward_type == FORWARD_TYPE_STEERING)
{
// rx_buff : not include g_vxlan header
@@ -1059,7 +1082,7 @@ static enum inject_pkt_action handle_inject_packet(struct packet_io *handle, mar
}
else
{
// rx_buff : include g_vxlan header
// rx_buff : not include g_vxlan header
// return + : send n bytes
// return -1 : error
int nsend = forward_packet_to_nf(handle, rx_buff, &meta, thread_seq, ctx);
@@ -1137,13 +1160,11 @@ static int mirror_packet_to_sf(struct packet_io *handle, marsio_buff_t *rx_buff,
return nsend;
}
// rx_buff : include g_vxlan header
// rx_buff : not include g_vxlan header
// return + : send n bytes
// return -1 : error
static int forward_packet_to_nf(struct packet_io *handle, marsio_buff_t *rx_buff, struct metadata *meta, int thread_seq, void *ct)
{
marsio_buff_adj(rx_buff, marsio_buff_datalen(rx_buff) - meta->raw_len);
marsio_buff_ctrlzone_reset(rx_buff);
if (packet_io_set_metadata(rx_buff, meta) != 0)
{