TSG-17728 tsg-service-chaining-engine增加日志字段
This commit is contained in:
@@ -509,7 +509,7 @@ void vlan_encapsulate(marsio_buff_t *mbuff, int vlan_id, int replace_orig_vlan_h
|
||||
|
||||
static int send_packet_to_sf(marsio_buff_t *mbuff, struct metadata *meta, struct selected_sf *sf, struct thread_ctx *thread_ctx)
|
||||
{
|
||||
thread_ctx->tx_packets_to_sf++;
|
||||
thread_ctx->tx_packets_ipid++;
|
||||
int nsend = 0;
|
||||
struct packet_io *packet_io = thread_ctx->ref_io;
|
||||
struct thread_metrics *thread_metrics = &thread_ctx->thread_metrics;
|
||||
@@ -519,7 +519,7 @@ static int send_packet_to_sf(marsio_buff_t *mbuff, struct metadata *meta, struct
|
||||
{
|
||||
case ENCAPSULATE_METHOD_VXLAN_G:
|
||||
vxlan_encapsulate(mbuff, packet_io->config.dev_endpoint_l3_mac, sf->sf_dst_mac,
|
||||
packet_io->config.dev_endpoint_l3_ip, sf->sf_dst_ip, thread_ctx->tx_packets_to_sf % 65535,
|
||||
packet_io->config.dev_endpoint_l3_ip, sf->sf_dst_ip, thread_ctx->tx_packets_ipid % 65535,
|
||||
meta->session_id % (65535 - 49152) + 49152, meta->raw_len, meta->is_e2i_dir, meta->is_decrypted, sf->sf_index);
|
||||
nsend = marsio_buff_datalen(mbuff);
|
||||
marsio_send_burst_with_options(packet_io->dev_endpoint_l3.mr_path, thread_ctx->thread_index, &mbuff, 1, MARSIO_SEND_OPT_REHASH);
|
||||
@@ -728,11 +728,16 @@ static void action_sf_chaining(struct thread_ctx *thread_ctx, struct session_ctx
|
||||
* handle session status
|
||||
******************************************************************************/
|
||||
|
||||
static int send_ctrl_packet(struct session_ctx *session_ctx, struct selected_chaining *chaining, struct thread_ctx *thread_ctx)
|
||||
static int send_ctrl_packet(struct session_ctx *session_ctx, struct selected_chainings *chainings, struct thread_ctx *thread_ctx)
|
||||
{
|
||||
struct sce_ctx *sce_ctx = thread_ctx->ref_sce_ctx;
|
||||
struct packet_io *packet_io = thread_ctx->ref_io;
|
||||
struct mutable_array *rule_ids = &session_ctx->rule_ids;
|
||||
struct selected_chaining *chaining_raw = chainings->chaining_raw;
|
||||
struct selected_chaining *chaining_decrypted = chainings->chaining_decrypted;
|
||||
int thread_index = thread_ctx->thread_index;
|
||||
int sc_rsp_raw_exist = 0;
|
||||
int sc_rsp_decrypted_exist = 0;
|
||||
|
||||
char *data;
|
||||
size_t size;
|
||||
@@ -768,17 +773,57 @@ static int send_ctrl_packet(struct session_ctx *session_ctx, struct selected_cha
|
||||
mpack_write_cstr(&writer, "sce");
|
||||
mpack_build_map(&writer); // sce value begin
|
||||
|
||||
mpack_write_cstr(&writer, "sf_profile_ids");
|
||||
mpack_build_array(&writer);
|
||||
for (int i = 0; i < chaining->chaining_used; i++)
|
||||
{
|
||||
struct selected_sf *sf = &(chaining->chaining[i]);
|
||||
if (sf->sf_action == SESSION_ACTION_FORWARD)
|
||||
mpack_write_cstr(&writer, "sc_rule_list");
|
||||
mpack_build_array(&writer); // sc_rule_list begin
|
||||
for (int i = 0; i < rule_ids->num; i++)
|
||||
{
|
||||
mpack_write_u32(&writer, sf->sf_profile_id);
|
||||
mpack_write_u64(&writer, mutable_array_index_elem(rule_ids, i));
|
||||
}
|
||||
mpack_complete_array(&writer); // sc_rule_list end
|
||||
}
|
||||
|
||||
{
|
||||
for (int i = 0; i < chaining_raw->chaining_used; i++)
|
||||
{
|
||||
struct selected_sf *sf = &(chaining_raw->chaining[i]);
|
||||
if (sf->sf_action == SESSION_ACTION_FORWARD)
|
||||
{
|
||||
if (sc_rsp_raw_exist == 0)
|
||||
{
|
||||
mpack_write_cstr(&writer, "sc_rsp_raw");
|
||||
mpack_build_array(&writer); // sc_rsp_raw begin
|
||||
sc_rsp_raw_exist = 1;
|
||||
}
|
||||
mpack_write_u64(&writer, sf->sf_profile_id);
|
||||
}
|
||||
}
|
||||
if (sc_rsp_raw_exist == 1)
|
||||
{
|
||||
mpack_complete_array(&writer); // sc_rsp_raw end
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
for (int i = 0; i < chaining_decrypted->chaining_used; i++)
|
||||
{
|
||||
struct selected_sf *sf = &(chaining_decrypted->chaining[i]);
|
||||
if (sf->sf_action == SESSION_ACTION_FORWARD)
|
||||
{
|
||||
if (sc_rsp_decrypted_exist == 0)
|
||||
{
|
||||
mpack_write_cstr(&writer, "sc_rsp_decrypted");
|
||||
mpack_build_array(&writer); // sc_rsp_decrypted begin
|
||||
sc_rsp_decrypted_exist = 1;
|
||||
}
|
||||
mpack_write_u64(&writer, sf->sf_profile_id);
|
||||
}
|
||||
}
|
||||
if (sc_rsp_decrypted_exist == 1)
|
||||
{
|
||||
mpack_complete_array(&writer); // sc_rsp_decrypted end
|
||||
}
|
||||
}
|
||||
mpack_complete_array(&writer);
|
||||
|
||||
mpack_complete_map(&writer); // sce value end
|
||||
}
|
||||
@@ -830,23 +875,10 @@ static void send_event_log(struct session_ctx *session_ctx, struct thread_ctx *t
|
||||
int nsend = 0;
|
||||
struct sce_ctx *sce_ctx = thread_ctx->ref_sce_ctx;
|
||||
struct thread_metrics *thread_metrics = &thread_ctx->thread_metrics;
|
||||
struct selected_chaining *chaining_raw = session_ctx->chainings.chaining_raw;
|
||||
struct selected_chaining *chaining_decrypted = session_ctx->chainings.chaining_decrypted;
|
||||
|
||||
if (chaining_raw->chaining_used && sce_ctx->enable_send_log)
|
||||
if (sce_ctx->enable_send_log)
|
||||
{
|
||||
nsend = send_ctrl_packet(session_ctx, chaining_raw, 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);
|
||||
}
|
||||
}
|
||||
|
||||
if (chaining_decrypted->chaining_used && sce_ctx->enable_send_log)
|
||||
{
|
||||
nsend = send_ctrl_packet(session_ctx, chaining_decrypted, thread_ctx);
|
||||
nsend = send_ctrl_packet(session_ctx, &session_ctx->chainings, thread_ctx);
|
||||
if (nsend > 0)
|
||||
{
|
||||
ATOMIC_INC(&(thread_metrics->sf_session.log));
|
||||
|
||||
Reference in New Issue
Block a user