TSG-13878 tsg-service-chaining-engine支持fieldstat2

This commit is contained in:
luwenpeng
2023-02-21 09:58:31 +08:00
parent b1abe96b06
commit 823490bcd1
20 changed files with 555 additions and 204 deletions

View File

@@ -0,0 +1,54 @@
#ifndef _GLOBAL_METRICS_H
#define _GLOBAL_METRICS_H
#ifdef __cpluscplus
extern "C"
{
#endif
#include "utils.h"
#include <MESA/field_stat2.h>
struct global_metrics_config
{
char output_file[256];
char statsd_server[32];
int statsd_port;
int statsd_format;
int statsd_cycle;
int prometheus_listen_port;
char prometheus_listen_url[256];
};
struct global_metrics
{
struct throughput_metrics dev_endpoint_rx; // 累计值
struct throughput_metrics dev_endpoint_tx; // 累计值
struct throughput_metrics dev_endpoint_err_drop; // 累计值
struct throughput_metrics dev_nf_interface_rx; // 累计值
struct throughput_metrics dev_nf_interface_tx; // 累计值
struct throughput_metrics dev_nf_interface_err_bypass; // 累计值
struct throughput_metrics hit_block_policy; // 累计值
struct throughput_metrics hit_bypass_policy; // 累计值
struct throughput_metrics control_packet_rx; // 累计值
uint64_t session_nums; // 瞬时值
struct global_metrics_config config;
screen_stat_handle_t fs_handle;
int fs_id[32];
};
struct global_metrics *global_metrics_create(const char *profile);
void global_metrics_destory(struct global_metrics *metrics);
void global_metrics_dump(struct global_metrics *metrics);
#ifdef __cpluscplus
}
#endif
#endif

View File

@@ -28,10 +28,6 @@ int health_check_session_get_status(int session_id);
// return -1 : key not exist
int health_check_session_set_status(int session_id, int is_active);
// return 0 : success
// return -1 : key not exist
int health_check_session_get_ip(int session_id, char *ip_buff);
// return 0 : success
// return -1 : key not exist
int health_check_session_get_mac(int session_id, char *mac_buff);

View File

@@ -79,6 +79,7 @@ struct connectivity
int int_vlan_tag;
int ext_vlan_tag;
char dest_ip[64];
char dest_mac[32]; // CM does not send this field, but only reads it from json, which is used for debugging
};
struct selected_sf
@@ -124,6 +125,7 @@ void selected_chaining_destory(struct selected_chaining *chaining);
void selected_chaining_dump(struct selected_chaining *chaining);
void selected_chaining_bref(struct selected_chaining *chaining);
const char *session_action_reason_to_string(enum session_action_reason session_action_reason);
void policy_enforce_select_chaining(struct selected_chaining *chaining, struct policy_enforcer *enforcer, struct raw_pkt_parser *parser, int policy_id, int dir_is_internal);
#ifdef __cpluscplus

View File

@@ -6,42 +6,17 @@ extern "C"
{
#endif
#include "utils.h"
#include "policy.h"
#include "packet_io.h"
#include "session_table.h"
/******************************************************************************
* Struct For Global
******************************************************************************/
struct global_metrics
{
struct throughput_metrics dev_endpoint_rx; // 累计值
struct throughput_metrics dev_endpoint_tx; // 累计值
struct throughput_metrics dev_endpoint_err_drop; // 累计值
struct throughput_metrics dev_nf_interface_rx; // 累计值
struct throughput_metrics dev_nf_interface_tx; // 累计值
struct throughput_metrics dev_nf_interface_err_bypass; // 累计值
struct throughput_metrics hit_block_policy; // 累计值
struct throughput_metrics hit_bypass_policy; // 累计值
uint64_t session_nums; // 瞬时值
};
struct global_metrics *global_metrics_create();
void global_metrics_destory(struct global_metrics *metrics);
void global_metrics_dump(struct global_metrics *metrics);
/******************************************************************************
* Struct For Thread
******************************************************************************/
struct thread_ctx
{
pthread_t tid;
pthread_t tid;
int thread_index;
struct session_table *session_table;
@@ -77,7 +52,7 @@ struct session_ctx
struct sids raw_pkt_i2e_sids;
struct sids raw_pkt_e2i_sids;
// depending on first control packet
struct packet_info first_ctrl_pkt;
struct selected_chaining *chaining;