TSG-13684 tsg-service-chaining-engine使用VLAN封装Packet并执行Traffic Mirroring

This commit is contained in:
luwenpeng
2023-10-18 10:08:10 +08:00
parent 18561bc4fe
commit 0753e8018c
57 changed files with 1784 additions and 1175 deletions

View File

@@ -26,13 +26,17 @@ struct device_metrics
struct throughput_metrics nf_rx; // 累计值
struct throughput_metrics nf_tx; // 累计值
struct throughput_metrics endpoint_rx; // 累计值
struct throughput_metrics endpoint_tx; // 累计值
struct throughput_metrics endpoint_drop; // 累计值
struct throughput_metrics endpoint_vxlan_rx; // 累计值
struct throughput_metrics endpoint_vxlan_tx; // 累计值
struct throughput_metrics endpoint_vxlan_drop; // 累计值
struct throughput_metrics endpoint_vlan_rx; // 累计值
struct throughput_metrics endpoint_vlan_tx; // 累计值
struct throughput_metrics endpoint_vlan_drop; // 累计值
};
// raw_pkt_metrics 不包含 g_vxlan 所占的字节
struct raw_pkt_metrics
// data_pkt_metrics 不包含 g_vxlan 所占的字节
struct data_pkt_metrics
{
struct throughput_metrics mirr_bypass; // 累计值
struct throughput_metrics mirr_block; // 累计值
@@ -85,7 +89,7 @@ struct sf_session_metrics
struct thread_metrics
{
struct device_metrics device;
struct raw_pkt_metrics raw_pkt;
struct data_pkt_metrics data_pkt;
struct ctrl_pkt_metrics ctrl_pkt;
struct keepalived_pkt_metrics kee_pkt;
@@ -96,7 +100,7 @@ struct thread_metrics
struct global_metrics
{
struct device_metrics device;
struct raw_pkt_metrics raw_pkt;
struct data_pkt_metrics data_pkt;
struct ctrl_pkt_metrics ctrl_pkt;
struct keepalived_pkt_metrics kee_pkt;

View File

@@ -8,19 +8,35 @@ extern "C"
#include <marsio.h>
// only for gtest
/******************************************************************************
* Packet IO API for gtest
******************************************************************************/
int mbuff_get_metadata(marsio_buff_t *rx_buff, struct metadata *meta);
int mbuff_set_metadata(marsio_buff_t *tx_buff, struct metadata *meta);
void vlan_encapsulate(marsio_buff_t *mbuff, int vlan_id, int replace_orig_vlan_header);
struct mr_instance *packet_io_get_mr_instance(struct packet_io *handle);
/******************************************************************************
* Packet IO API for global
******************************************************************************/
struct packet_io *packet_io_create(const char *profile, int thread_num, cpu_set_t *coremask);
void packet_io_destory(struct packet_io *handle);
/******************************************************************************
* Packet IO API for thread
******************************************************************************/
// return 0 for success
// return -1 for error
int packet_io_thread_init(struct packet_io *handle, struct thread_ctx *thread_ctx);
void packet_io_thread_wait(struct packet_io *handle, struct thread_ctx *thread_ctx, int timeout_ms);
// return n_packet_recved
int packet_io_thread_polling_nf(struct packet_io *handle, struct thread_ctx *thread_ctx);
int packet_io_thread_polling_endpoint(struct packet_io *handle, struct thread_ctx *thread_ctx);
int packet_io_thread_polling_endpoint_l3(struct packet_io *handle, struct thread_ctx *thread_ctx);
int packet_io_thread_polling_endpoint_l2(struct packet_io *handle, struct thread_ctx *thread_ctx);
#ifdef __cpluscplus
}

View File

@@ -7,7 +7,7 @@ extern "C"
#endif
#include "utils.h"
#include "raw_packet.h"
#include "data_packet.h"
#include <linux/if_ether.h>
enum traffic_type
@@ -45,12 +45,12 @@ enum action_reason
ACTION_FORWAED_DUE_SELECTED_SF = 0x20,
};
enum package_method
enum encapsulate_method
{
PACKAGE_METHOD_NONE = 0,
PACKAGE_METHOD_LAYER2_SWITCH = 1,
PACKAGE_METHOD_LAYER3_SWITCH = 2,
PACKAGE_METHOD_VXLAN_G = 3,
ENCAPSULATE_METHOD_NONE = 0,
ENCAPSULATE_METHOD_LAYER2_SWITCH = 1,
ENCAPSULATE_METHOD_LAYER3_SWITCH = 2,
ENCAPSULATE_METHOD_VXLAN_G = 3,
};
enum health_check_method
@@ -73,7 +73,7 @@ struct health_check
struct connectivity
{
enum package_method method;
enum encapsulate_method method;
int int_vlan_tag;
int ext_vlan_tag;
char dest_ip[64];
@@ -123,7 +123,7 @@ const char *traffic_type_to_string(enum traffic_type traffic_type);
const char *forward_type_to_string(enum forward_type forward_type);
const char *session_action_to_string(enum session_action session_action);
const char *action_reason_to_string(enum action_reason action_reason);
const char *package_method_to_string(enum package_method package_method);
const char *encapsulate_method_to_string(enum encapsulate_method encap_method);
struct selected_chaining *selected_chaining_create(int chaining_size, uint64_t session_id, char *session_addr);
void selected_chaining_destory(struct selected_chaining *chaining);
@@ -140,7 +140,7 @@ void policy_enforcer_destory(struct policy_enforcer *enforcer);
// return -1 : error
int policy_enforcer_register(struct policy_enforcer *enforcer);
int policy_enforce_chaining_size(struct policy_enforcer *enforcer);
void policy_enforce_select_chainings(struct policy_enforcer *enforcer, struct selected_chainings *chainings, struct session_ctx *s_ctx, struct raw_pkt_parser *parser, uint64_t rule_id, int dir_is_i2e);
void policy_enforce_select_chainings(struct policy_enforcer *enforcer, struct selected_chainings *chainings, struct session_ctx *s_ctx, struct data_packet *data_pkt, uint64_t rule_id, int dir_is_i2e);
#ifdef __cpluscplus
}

View File

@@ -76,7 +76,7 @@ struct session_ctx
char *session_addr;
struct addr_tuple4 inner_tuple4;
struct fixed_num_array rule_ids;
struct mutable_array rule_ids;
struct metadata *decrypted_meta_i2e;
struct metadata *decrypted_meta_e2i;