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

@@ -38,6 +38,7 @@ yum install -y mrzcpd
yum install -y libmaatframe-devel yum install -y libmaatframe-devel
yum install -y libMESA_handle_logger-devel yum install -y libMESA_handle_logger-devel
yum install -y libMESA_prof_load-devel yum install -y libMESA_prof_load-devel
yum install -y libMESA_field_stat2-devel
yum install -y librulescan-devel yum install -y librulescan-devel
yum install -y sapp-devel # Maat_rule require MESA/stream.h yum install -y sapp-devel # Maat_rule require MESA/stream.h
yum install -y libasan yum install -y libasan

View File

@@ -19,7 +19,7 @@ struct g_vxlan
unsigned int dir_is_e2i : 1; unsigned int dir_is_e2i : 1;
unsigned int traffic_is_decrypted : 1; unsigned int traffic_is_decrypted : 1;
unsigned int next_sf_index : 5; // max value 32 unsigned int sf_index : 5; // max value 32
unsigned int online_test : 1; unsigned int online_test : 1;
// Reserved 1 Bytes // Reserved 1 Bytes
@@ -34,11 +34,11 @@ struct g_vxlan
} __attribute__((__packed__)); } __attribute__((__packed__));
void g_vxlan_set_packet_dir(struct g_vxlan *hdr, int dir_is_e2i); void g_vxlan_set_packet_dir(struct g_vxlan *hdr, int dir_is_e2i);
void g_vxlan_set_next_sf_index(struct g_vxlan *hdr, int next_sf_index); void g_vxlan_set_sf_index(struct g_vxlan *hdr, int sf_index);
void g_vxlan_set_traffic_type(struct g_vxlan *hdr, int traffic_is_decrypted); void g_vxlan_set_traffic_type(struct g_vxlan *hdr, int traffic_is_decrypted);
int g_vxlan_get_packet_dir(struct g_vxlan *hdr); int g_vxlan_get_packet_dir(struct g_vxlan *hdr);
int g_vxlan_get_next_sf_index(struct g_vxlan *hdr); int g_vxlan_get_sf_index(struct g_vxlan *hdr);
int g_vxlan_get_traffic_type(struct g_vxlan *hdr); int g_vxlan_get_traffic_type(struct g_vxlan *hdr);
// return 0 : success // return 0 : success

View File

@@ -7,6 +7,7 @@ extern "C"
#endif #endif
#include <stdio.h> #include <stdio.h>
#include <pthread.h>
#include <MESA/MESA_handle_logger.h> #include <MESA/MESA_handle_logger.h>
extern void *g_default_logger; extern void *g_default_logger;
@@ -15,31 +16,50 @@ int LOG_INIT(const char *profile);
void LOG_CLOSE(void); void LOG_CLOSE(void);
void LOG_RELOAD(void); void LOG_RELOAD(void);
#define LOG_DEBUG(format, ...) \ // __FUNCTION__
do \ #define LOG_DEBUG(format, ...) \
{ \ do \
if (g_default_logger) \ { \
MESA_handle_runtime_log(g_default_logger, RLOG_LV_DEBUG, __FUNCTION__, format, ##__VA_ARGS__); \ if (g_default_logger) \
else \ { \
fprintf(stdout, "DEBUG " format "\n", ##__VA_ARGS__); \ char __tid_buff[16] = {0}; \
snprintf(__tid_buff, 16, "tid:%ld", pthread_self()); \
MESA_handle_runtime_log(g_default_logger, RLOG_LV_DEBUG, __tid_buff, format, ##__VA_ARGS__); \
} \
else \
{ \
fprintf(stdout, "DEBUG " format "\n", ##__VA_ARGS__); \
} \
} while (0) } while (0)
#define LOG_INFO(format, ...) \ #define LOG_INFO(format, ...) \
do \ do \
{ \ { \
if (g_default_logger) \ if (g_default_logger) \
MESA_handle_runtime_log(g_default_logger, RLOG_LV_INFO, __FUNCTION__, format, ##__VA_ARGS__); \ { \
else \ char __tid_buff[16] = {0}; \
fprintf(stdout, "INFO " format "\n", ##__VA_ARGS__); \ snprintf(__tid_buff, 16, "tid:%ld", pthread_self()); \
MESA_handle_runtime_log(g_default_logger, RLOG_LV_INFO, __tid_buff, format, ##__VA_ARGS__); \
} \
else \
{ \
fprintf(stdout, "INFOR " format "\n", ##__VA_ARGS__); \
} \
} while (0) } while (0)
#define LOG_ERROR(format, ...) \ #define LOG_ERROR(format, ...) \
do \ do \
{ \ { \
if (g_default_logger) \ if (g_default_logger) \
MESA_handle_runtime_log(g_default_logger, RLOG_LV_FATAL, __FUNCTION__, format, ##__VA_ARGS__); \ { \
else \ char __tid_buff[16] = {0}; \
fprintf(stderr, "ERROR " format "\n", ##__VA_ARGS__); \ snprintf(__tid_buff, 16, "tid:%ld", pthread_self()); \
MESA_handle_runtime_log(g_default_logger, RLOG_LV_FATAL, __tid_buff, format, ##__VA_ARGS__); \
} \
else \
{ \
fprintf(stderr, "ERROR " format "\n", ##__VA_ARGS__); \
} \
} while (0) } while (0)
#ifdef __cpluscplus #ifdef __cpluscplus

View File

@@ -1,4 +1,5 @@
#include <string.h> #include <string.h>
#include <stdlib.h>
#include <cjson/cJSON.h> #include <cjson/cJSON.h>
#include "log.h" #include "log.h"
@@ -54,12 +55,12 @@ int ctrl_packet_parser_parse(struct ctrl_pkt_parser *handler, const char *data,
// session_id // session_id
item = cJSON_GetObjectItem(json, "session_id"); item = cJSON_GetObjectItem(json, "session_id");
if (!item || !cJSON_IsNumber(item)) if (!item || !cJSON_IsString(item))
{ {
LOG_ERROR("%s: unexpected control packet: (invalid session_id format) %s", LOG_TAG_CTRLPKT, data); LOG_ERROR("%s: unexpected control packet: (invalid session_id format) %s", LOG_TAG_CTRLPKT, data);
goto error_out; goto error_out;
} }
handler->session_id = item->valueint; handler->session_id = atoll(item->valuestring);
// state // state
item = cJSON_GetObjectItem(json, "state"); item = cJSON_GetObjectItem(json, "state");

View File

@@ -9,9 +9,9 @@ void g_vxlan_set_packet_dir(struct g_vxlan *hdr, int dir_is_e2i)
hdr->dir_is_e2i = (!!dir_is_e2i); hdr->dir_is_e2i = (!!dir_is_e2i);
} }
void g_vxlan_set_next_sf_index(struct g_vxlan *hdr, int next_sf_index) void g_vxlan_set_sf_index(struct g_vxlan *hdr, int sf_index)
{ {
hdr->next_sf_index = (0x1f & next_sf_index); hdr->sf_index = (0x1f & sf_index);
} }
void g_vxlan_set_traffic_type(struct g_vxlan *hdr, int traffic_is_decrypted) void g_vxlan_set_traffic_type(struct g_vxlan *hdr, int traffic_is_decrypted)
@@ -24,9 +24,9 @@ int g_vxlan_get_packet_dir(struct g_vxlan *hdr)
return (!!hdr->dir_is_e2i); return (!!hdr->dir_is_e2i);
} }
int g_vxlan_get_next_sf_index(struct g_vxlan *hdr) int g_vxlan_get_sf_index(struct g_vxlan *hdr)
{ {
return hdr->next_sf_index; return hdr->sf_index;
} }
int g_vxlan_get_traffic_type(struct g_vxlan *hdr) int g_vxlan_get_traffic_type(struct g_vxlan *hdr)

View File

@@ -392,7 +392,7 @@ uint64_t raw_packet_parser_get_hash_value(struct raw_pkt_parser *handler, enum l
char *inner_addr_str = addr_tuple4_to_str(&inner_addr); char *inner_addr_str = addr_tuple4_to_str(&inner_addr);
char *outer_addr_str = addr_tuple4_to_str(&outer_addr); char *outer_addr_str = addr_tuple4_to_str(&outer_addr);
LOG_ERROR("%s: pkt_trace_id: %lu, outer_addr: %s, inner_addr: %s, is_internal: %d, hash_method: %s, hash_value: %lu", LOG_DEBUG("%s: pkt_trace_id: %lu, outer_addr: %s, inner_addr: %s, is_internal: %d, hash_method: %s, hash_value: %lu",
LOG_TAG_RAWPKT, handler->pkt_trace_id, outer_addr_str, inner_addr_str, dir_is_internal, ldbc_method_to_string(method), hash_value); LOG_TAG_RAWPKT, handler->pkt_trace_id, outer_addr_str, inner_addr_str, dir_is_internal, ldbc_method_to_string(method), hash_value);
free(inner_addr_str); free(inner_addr_str);
free(outer_addr_str); free(outer_addr_str);

View File

@@ -10,7 +10,7 @@ perf_switch=1
scan_detail=0 scan_detail=0
deferred_load=0 deferred_load=0
effect_interval_ms=1000 effect_interval_ms=1000
stat_file=log/sce.fs2 stat_file=log/maat.fs2
table_info=resource/table_info.conf table_info=resource/table_info.conf
accept_path=/opt/tsg/etc/tsg_device_tag.json accept_path=/opt/tsg/etc/tsg_device_tag.json
inc_cfg_dir=resource/inc/ inc_cfg_dir=resource/inc/
@@ -30,6 +30,18 @@ app_symbol=sce
dev_endpoint=eth_sf_endpoint dev_endpoint=eth_sf_endpoint
dev_nf_interface=eth_nf_interface dev_nf_interface=eth_nf_interface
default_src_ip=192.168.100.1 default_src_ip=192.168.100.1
default_dst_ip=192.168.100.2
default_src_mac=aa:aa:aa:aa:aa:aa default_src_mac=aa:aa:aa:aa:aa:aa
# only used for bypass_all_traffic=2
default_dst_ip=192.168.100.2
default_dst_mac=bb:bb:bb:bb:bb:bb default_dst_mac=bb:bb:bb:bb:bb:bb
[stat]
output_file=log/sce.fs2
statsd_server=127.0.0.1
statsd_port=8100
# 1 : FS_OUTPUT_STATSD
# 2 : FS_OUTPUT_INFLUX_LINE
statsd_format=1
statsd_cycle=2
prometheus_listen_port=9001
prometheus_listen_url=/sce_prometheus

View File

@@ -1,7 +1,8 @@
add_library(platform src/policy.cpp src/health_check.cpp src/sce.cpp src/packet_io.cpp) add_library(platform src/policy.cpp src/health_check.cpp src/sce.cpp src/packet_io.cpp src/global_metrics.cpp)
target_link_libraries(platform PUBLIC common) target_link_libraries(platform PUBLIC common)
target_link_libraries(platform PUBLIC pthread) target_link_libraries(platform PUBLIC pthread)
target_link_libraries(platform PUBLIC MESA_prof_load) target_link_libraries(platform PUBLIC MESA_prof_load)
target_link_libraries(platform PUBLIC MESA_field_stat)
target_link_libraries(platform PUBLIC maatframe) target_link_libraries(platform PUBLIC maatframe)
target_link_libraries(platform PUBLIC mrzcpd) target_link_libraries(platform PUBLIC mrzcpd)
target_link_libraries(platform PUBLIC cjson) target_link_libraries(platform PUBLIC cjson)

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 // return -1 : key not exist
int health_check_session_set_status(int session_id, int is_active); 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 0 : success
// return -1 : key not exist // return -1 : key not exist
int health_check_session_get_mac(int session_id, char *mac_buff); 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 int_vlan_tag;
int ext_vlan_tag; int ext_vlan_tag;
char dest_ip[64]; 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 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_dump(struct selected_chaining *chaining);
void selected_chaining_bref(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); 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 #ifdef __cpluscplus

View File

@@ -6,42 +6,17 @@ extern "C"
{ {
#endif #endif
#include "utils.h"
#include "policy.h" #include "policy.h"
#include "packet_io.h" #include "packet_io.h"
#include "session_table.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 For Thread
******************************************************************************/ ******************************************************************************/
struct thread_ctx struct thread_ctx
{ {
pthread_t tid; pthread_t tid;
int thread_index; int thread_index;
struct session_table *session_table; struct session_table *session_table;

View File

@@ -0,0 +1,219 @@
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <MESA/MESA_prof_load.h>
#include "log.h"
#include "global_metrics.h"
enum SCE_STAT_FIELD
{
// dev endpoint
STAT_ENDPOINT_RX_PKT,
STAT_ENDPOINT_RX_B,
STAT_ENDPOINT_TX_PKT,
STAT_ENDPOINT_TX_B,
STAT_ENDPOINT_ERR_DROP_PKT,
STAT_ENDPOINT_ERR_DROP_B,
// hit block policy
STAT_HIT_BLOCK_POLICY_PKT,
STAT_HIT_BLOCK_POLICY_B,
// dev nf interface
STAT_NF_INTERFACE_RX_PKT,
STAT_NF_INTERFACE_RX_B,
STAT_NF_INTERFACE_TX_PKT,
STAT_NF_INTERFACE_TX_B,
STAT_NF_INTERFACE_ERR_BYPASS_PKT,
STAT_NF_INTERFACE_ERR_BYPASS_B,
// hit bypass policy
STAT_HIT_BYPASS_POLICY_PKT,
STAT_HIT_BYPASS_POLICY_B,
// control packet
STAT_CONTROL_RX_PKT,
STAT_CONTROL_RX_B,
// current session number
STAT_CURRENT_SESSION_NUMS,
// max
STAT_MAX,
};
static const char *stat_map[] =
{
// dev endpoint
[STAT_ENDPOINT_RX_PKT] = "endp_rx_pkt",
[STAT_ENDPOINT_RX_B] = "endp_rx_B",
[STAT_ENDPOINT_TX_PKT] = "endp_tx_pkt",
[STAT_ENDPOINT_TX_B] = "endp_tx_B",
[STAT_ENDPOINT_ERR_DROP_PKT] = "endp_e_drop_pkt",
[STAT_ENDPOINT_ERR_DROP_B] = "endp_e_drop_B",
// hit block policy
[STAT_HIT_BLOCK_POLICY_PKT] = "hit_block_pkt",
[STAT_HIT_BLOCK_POLICY_B] = "hit_block_B",
// dev nf interface
[STAT_NF_INTERFACE_RX_PKT] = "nf_rx_pkt",
[STAT_NF_INTERFACE_RX_B] = "nf_rx_B",
[STAT_NF_INTERFACE_TX_PKT] = "nf_tx_pkt",
[STAT_NF_INTERFACE_TX_B] = "nf_tx_B",
[STAT_NF_INTERFACE_ERR_BYPASS_PKT] = "nf_e_bypass_pkt",
[STAT_NF_INTERFACE_ERR_BYPASS_B] = "nf_e_bypass_B",
// hit bypass policy
[STAT_HIT_BYPASS_POLICY_PKT] = "hit_bypass_pkt",
[STAT_HIT_BYPASS_POLICY_B] = "hit_bypass_B",
// control packet
[STAT_CONTROL_RX_PKT] = "ctrl_rx_pkt",
[STAT_CONTROL_RX_B] = "ctrl_rx_B",
// current session number
[STAT_CURRENT_SESSION_NUMS] = "curr_sess_num",
[STAT_MAX] = NULL};
static void global_metrics_parse_config(const char *profile, struct global_metrics_config *config)
{
MESA_load_profile_string_def(profile, "STAT", "output_file", config->output_file, sizeof(config->output_file), "log/sce.fs2");
MESA_load_profile_string_def(profile, "STAT", "statsd_server", config->statsd_server, sizeof(config->statsd_server), "127.0.0.1");
MESA_load_profile_int_def(profile, "STAT", "statsd_port", &(config->statsd_port), 8100);
MESA_load_profile_int_def(profile, "STAT", "statsd_format", &(config->statsd_format), 1); // FS_OUTPUT_STATSD=1, FS_OUTPUT_INFLUX_LINE=2
MESA_load_profile_int_def(profile, "STAT", "statsd_cycle", &(config->statsd_cycle), 1);
MESA_load_profile_int_def(profile, "STAT", "prometheus_listen_port", &(config->prometheus_listen_port), 9001);
MESA_load_profile_string_def(profile, "STAT", "prometheus_listen_url", config->prometheus_listen_url, sizeof(config->prometheus_listen_url), "/sce_prometheus");
if (config->statsd_format != 1 && config->statsd_format != 2)
{
config->statsd_format = 1;
}
LOG_DEBUG("%s: STAT->output_file : %s", LOG_TAG_METRICS, config->output_file);
LOG_DEBUG("%s: STAT->statsd_server : %s", LOG_TAG_METRICS, config->statsd_server);
LOG_DEBUG("%s: STAT->statsd_port : %d", LOG_TAG_METRICS, config->statsd_port);
LOG_DEBUG("%s: STAT->statsd_format : %d", LOG_TAG_METRICS, config->statsd_format);
LOG_DEBUG("%s: STAT->statsd_cycle : %d", LOG_TAG_METRICS, config->statsd_cycle);
LOG_DEBUG("%s: STAT->prometheus_listen_port : %d", LOG_TAG_METRICS, config->prometheus_listen_port);
LOG_DEBUG("%s: STAT->prometheus_listen_url : %s", LOG_TAG_METRICS, config->prometheus_listen_url);
}
struct global_metrics *global_metrics_create(const char *profile)
{
struct global_metrics *metrics = (struct global_metrics *)calloc(1, sizeof(struct global_metrics));
assert(metrics != NULL);
global_metrics_parse_config(profile, &metrics->config);
FS_library_set_prometheus_port(metrics->config.prometheus_listen_port);
FS_library_set_prometheus_url_path(metrics->config.prometheus_listen_url);
FS_library_init();
int value = 0;
metrics->fs_handle = FS_create_handle(); // TODO memleak no free() API
FS_set_para(metrics->fs_handle, APP_NAME, "SCE", 3);
FS_set_para(metrics->fs_handle, OUTPUT_DEVICE, metrics->config.output_file, strlen(metrics->config.output_file));
value = 1;
FS_set_para(metrics->fs_handle, OUTPUT_PROMETHEUS, &value, sizeof(value));
value = 1;
FS_set_para(metrics->fs_handle, PRINT_MODE, &value, sizeof(value));
value = 0;
FS_set_para(metrics->fs_handle, CREATE_THREAD, &value, sizeof(value));
if (strlen(metrics->config.statsd_server) > 0 && metrics->config.statsd_port != 0)
{
FS_set_para(metrics->fs_handle, STATS_SERVER_IP, metrics->config.statsd_server, strlen(metrics->config.statsd_server));
FS_set_para(metrics->fs_handle, STATS_SERVER_PORT, &(metrics->config.statsd_port), sizeof(metrics->config.statsd_port));
FS_set_para(metrics->fs_handle, STATS_FORMAT, &metrics->config.statsd_format, sizeof(metrics->config.statsd_format));
}
for (int i = 0; i < STAT_MAX; i++)
{
metrics->fs_id[i] = FS_register(metrics->fs_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, stat_map[i]);
}
FS_start(metrics->fs_handle);
return metrics;
}
void global_metrics_destory(struct global_metrics *metrics)
{
if (metrics)
{
FS_library_destroy();
free(metrics);
metrics = NULL;
}
}
void global_metrics_dump(struct global_metrics *metrics)
{
if (strlen(metrics->config.statsd_server) == 0)
{
LOG_INFO("%s: dev_endpoint_rx : n_pkts : %6lu, n_bytes: %6lu", LOG_TAG_METRICS, metrics->dev_endpoint_rx.n_pkts, metrics->dev_endpoint_rx.n_bytes);
LOG_INFO("%s: dev_endpoint_tx : n_pkts : %6lu, n_bytes: %6lu", LOG_TAG_METRICS, metrics->dev_endpoint_tx.n_pkts, metrics->dev_endpoint_tx.n_bytes);
LOG_INFO("%s: dev_endpoint_err_drop : n_pkts : %6lu, n_bytes: %6lu", LOG_TAG_METRICS, metrics->dev_endpoint_err_drop.n_pkts, metrics->dev_endpoint_err_drop.n_bytes);
LOG_INFO("%s: dev_nf_interface_rx : n_pkts : %6lu, n_bytes: %6lu", LOG_TAG_METRICS, metrics->dev_nf_interface_rx.n_pkts, metrics->dev_nf_interface_rx.n_bytes);
LOG_INFO("%s: dev_nf_interface_tx : n_pkts : %6lu, n_bytes: %6lu", LOG_TAG_METRICS, metrics->dev_nf_interface_tx.n_pkts, metrics->dev_nf_interface_tx.n_bytes);
LOG_INFO("%s: dev_nf_interface_err_bypass : n_pkts : %6lu, n_bytes: %6lu", LOG_TAG_METRICS, metrics->dev_nf_interface_err_bypass.n_pkts, metrics->dev_nf_interface_err_bypass.n_bytes);
LOG_INFO("%s: hit_block_policy : n_pkts : %6lu, n_bytes: %6lu", LOG_TAG_METRICS, metrics->hit_block_policy.n_pkts, metrics->hit_block_policy.n_bytes);
LOG_INFO("%s: hit_bypass_policy : n_pkts : %6lu, n_bytes: %6lu", LOG_TAG_METRICS, metrics->hit_bypass_policy.n_pkts, metrics->hit_bypass_policy.n_bytes);
LOG_INFO("%s: control_packet : n_pkts : %6lu, n_bytes: %6lu", LOG_TAG_METRICS, metrics->control_packet_rx.n_pkts, metrics->control_packet_rx.n_bytes);
LOG_INFO("%s: current_session_num : %6lu", LOG_TAG_METRICS, metrics->session_nums);
}
// dev endpoint
FS_operate(metrics->fs_handle, metrics->fs_id[STAT_ENDPOINT_RX_PKT], 0, FS_OP_SET, __atomic_fetch_add(&(metrics->dev_endpoint_rx.n_pkts), 0, __ATOMIC_RELAXED));
FS_operate(metrics->fs_handle, metrics->fs_id[STAT_ENDPOINT_RX_B], 0, FS_OP_SET, __atomic_fetch_add(&(metrics->dev_endpoint_rx.n_bytes), 0, __ATOMIC_RELAXED));
FS_operate(metrics->fs_handle, metrics->fs_id[STAT_ENDPOINT_TX_PKT], 0, FS_OP_SET, __atomic_fetch_add(&(metrics->dev_endpoint_tx.n_pkts), 0, __ATOMIC_RELAXED));
FS_operate(metrics->fs_handle, metrics->fs_id[STAT_ENDPOINT_TX_B], 0, FS_OP_SET, __atomic_fetch_add(&(metrics->dev_endpoint_tx.n_bytes), 0, __ATOMIC_RELAXED));
FS_operate(metrics->fs_handle, metrics->fs_id[STAT_ENDPOINT_ERR_DROP_PKT], 0, FS_OP_SET, __atomic_fetch_add(&(metrics->dev_endpoint_err_drop.n_pkts), 0, __ATOMIC_RELAXED));
FS_operate(metrics->fs_handle, metrics->fs_id[STAT_ENDPOINT_ERR_DROP_B], 0, FS_OP_SET, __atomic_fetch_add(&(metrics->dev_endpoint_err_drop.n_bytes), 0, __ATOMIC_RELAXED));
// hit policy
FS_operate(metrics->fs_handle, metrics->fs_id[STAT_HIT_BLOCK_POLICY_PKT], 0, FS_OP_SET, __atomic_fetch_add(&(metrics->hit_block_policy.n_pkts), 0, __ATOMIC_RELAXED));
FS_operate(metrics->fs_handle, metrics->fs_id[STAT_HIT_BLOCK_POLICY_B], 0, FS_OP_SET, __atomic_fetch_add(&(metrics->hit_block_policy.n_bytes), 0, __ATOMIC_RELAXED));
// dev nf interface
FS_operate(metrics->fs_handle, metrics->fs_id[STAT_NF_INTERFACE_RX_PKT], 0, FS_OP_SET, __atomic_fetch_add(&(metrics->dev_nf_interface_rx.n_pkts), 0, __ATOMIC_RELAXED));
FS_operate(metrics->fs_handle, metrics->fs_id[STAT_NF_INTERFACE_RX_B], 0, FS_OP_SET, __atomic_fetch_add(&(metrics->dev_nf_interface_rx.n_bytes), 0, __ATOMIC_RELAXED));
FS_operate(metrics->fs_handle, metrics->fs_id[STAT_NF_INTERFACE_TX_PKT], 0, FS_OP_SET, __atomic_fetch_add(&(metrics->dev_nf_interface_tx.n_pkts), 0, __ATOMIC_RELAXED));
FS_operate(metrics->fs_handle, metrics->fs_id[STAT_NF_INTERFACE_TX_B], 0, FS_OP_SET, __atomic_fetch_add(&(metrics->dev_nf_interface_tx.n_bytes), 0, __ATOMIC_RELAXED));
FS_operate(metrics->fs_handle, metrics->fs_id[STAT_NF_INTERFACE_ERR_BYPASS_PKT], 0, FS_OP_SET, __atomic_fetch_add(&(metrics->dev_nf_interface_err_bypass.n_pkts), 0, __ATOMIC_RELAXED));
FS_operate(metrics->fs_handle, metrics->fs_id[STAT_NF_INTERFACE_ERR_BYPASS_B], 0, FS_OP_SET, __atomic_fetch_add(&(metrics->dev_nf_interface_err_bypass.n_bytes), 0, __ATOMIC_RELAXED));
// hit bypass policy
FS_operate(metrics->fs_handle, metrics->fs_id[STAT_HIT_BYPASS_POLICY_PKT], 0, FS_OP_SET, __atomic_fetch_add(&(metrics->hit_bypass_policy.n_pkts), 0, __ATOMIC_RELAXED));
FS_operate(metrics->fs_handle, metrics->fs_id[STAT_HIT_BYPASS_POLICY_B], 0, FS_OP_SET, __atomic_fetch_add(&(metrics->hit_bypass_policy.n_bytes), 0, __ATOMIC_RELAXED));
// control packet
FS_operate(metrics->fs_handle, metrics->fs_id[STAT_CONTROL_RX_PKT], 0, FS_OP_SET, __atomic_fetch_add(&(metrics->control_packet_rx.n_pkts), 0, __ATOMIC_RELAXED));
FS_operate(metrics->fs_handle, metrics->fs_id[STAT_CONTROL_RX_B], 0, FS_OP_SET, __atomic_fetch_add(&(metrics->control_packet_rx.n_bytes), 0, __ATOMIC_RELAXED));
// current session number
FS_operate(metrics->fs_handle, metrics->fs_id[STAT_CURRENT_SESSION_NUMS], 0, FS_OP_SET, __atomic_fetch_add(&(metrics->session_nums), 0, __ATOMIC_RELAXED));
FS_passive_output(metrics->fs_handle);
}

View File

@@ -61,18 +61,11 @@ int health_check_session_set_status(int session_id, int is_active)
return 0; return 0;
} }
// return 0 : success
// return -1 : key not exist
int health_check_session_get_ip(int session_id, char *ip_buff)
{
// TODO
return 0;
}
// return 0 : success // return 0 : success
// return -1 : key not exist // return -1 : key not exist
int health_check_session_get_mac(int session_id, char *mac_buff) int health_check_session_get_mac(int session_id, char *mac_buff)
{ {
strcpy(mac_buff, "66:AA:AA:AA:AA:AA");
// TODO // TODO
return 0; return 0;
} }

View File

@@ -6,6 +6,7 @@
#include "sce.h" #include "sce.h"
#include "log.h" #include "log.h"
#include "utils.h" #include "utils.h"
#include "global_metrics.h"
static void sig_handler(int signo) static void sig_handler(int signo)
{ {
@@ -96,8 +97,8 @@ int main(int argc, char **argv)
while (1) while (1)
{ {
sleep(20);
global_metrics_dump(ctx->metrics); global_metrics_dump(ctx->metrics);
sleep(ctx->metrics->config.statsd_cycle);
} }
error_out: error_out:

View File

@@ -11,10 +11,11 @@
#include "utils.h" #include "utils.h"
#include "g_vxlan.h" #include "g_vxlan.h"
#include "ctrl_packet.h" #include "ctrl_packet.h"
#include "global_metrics.h"
/* /*
* add: vxlan_hdr * add: vxlan_hdr
* del: marsio_buff_reset() * del: marsio_buff_ctrlzone_reset()
* +----+ NF2SF +----+ * +----+ NF2SF +----+
* | |--------------------------->| | * | |--------------------------->| |
* | | | | * | | | |
@@ -89,7 +90,7 @@ struct metadata
int dir_is_e2i; int dir_is_e2i;
int is_ctrl_pkt; int is_ctrl_pkt;
int l7_offset; // only control packet set l7_offset uint16_t l7_offset; // only control packet set l7_offset
int traffic_is_decrypted; // only raw packet set traffic_is_decrypted int traffic_is_decrypted; // only raw packet set traffic_is_decrypted
struct sids sids; struct sids sids;
@@ -106,6 +107,8 @@ void packet_io_destory(struct packet_io *handle);
int packet_io_polling_nf_interface(struct packet_io *handle, int thread_seq, void *ctx); int packet_io_polling_nf_interface(struct packet_io *handle, int thread_seq, void *ctx);
int packet_io_polling_endpoint(struct packet_io *handle, int thread_seq, void *ctx); int packet_io_polling_endpoint(struct packet_io *handle, int thread_seq, void *ctx);
// return 0 : success
// return -1 : error
static int packet_io_config(const char *profile, struct config *config); static int packet_io_config(const char *profile, struct config *config);
// return 0 : success // return 0 : success
@@ -114,6 +117,7 @@ static int packet_io_get_metadata(marsio_buff_t *tx_buff, struct metadata *meta)
// return 0 : success // return 0 : success
// return -1 : error // return -1 : error
static int packet_io_set_metadata(marsio_buff_t *tx_buff, struct metadata *meta); static int packet_io_set_metadata(marsio_buff_t *tx_buff, struct metadata *meta);
static void packet_io_dump_metadata(marsio_buff_t *tx_buff, struct metadata *meta);
// return 0 : success // return 0 : success
// return -1 : error // return -1 : error
@@ -122,21 +126,25 @@ static int handle_control_packet(struct packet_io *handle, marsio_buff_t *rx_buf
// return : RAW_PKT_HIT_BYPASS // return : RAW_PKT_HIT_BYPASS
// return : RAW_PKT_HIT_BLOCK // return : RAW_PKT_HIT_BLOCK
// reutrn : RAW_PKT_HIT_FORWARD // reutrn : RAW_PKT_HIT_FORWARD
static enum raw_pkt_action handle_raw_packet(struct packet_io *handle, marsio_buff_t *rx_buff, int thread_seq, void *ctx); static enum raw_pkt_action handle_raw_packet(struct packet_io *handle, marsio_buff_t *rx_buff, int thread_seq, void *ctx, int *action_bytes);
// return : INJT_PKT_ERR_DROP // return : INJT_PKT_ERR_DROP
// return : INJT_PKT_HIT_BLOCK // return : INJT_PKT_HIT_BLOCK
// return : INJT_PKT_HIT_FWD2SF // return : INJT_PKT_HIT_FWD2SF
// return : INJT_PKT_HIT_FWD2NF // return : INJT_PKT_HIT_FWD2NF
static enum inject_pkt_action handle_inject_packet(struct packet_io *handle, marsio_buff_t *rx_buff, int thread_seq, void *ctx); 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);
// return 0 : success // return + : send n bytes
// return -1 : error // return -1 : error
static int forward_packet_to_sf(struct packet_io *handle, marsio_buff_t *rx_buff, struct metadata *meta, struct selected_sf *sf, int thread_seq, void *ctx); static int forward_packet_to_sf(struct packet_io *handle, marsio_buff_t *rx_buff, struct metadata *meta, struct selected_sf *sf, int thread_seq, void *ctx);
// return 0 : success // return + : send n bytes
// return -1 : error // 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); static int forward_packet_to_nf(struct packet_io *handle, marsio_buff_t *rx_buff, struct metadata *meta, int thread_seq, void *ct);
static void forward_all_nf_packet_to_sf(struct packet_io *handle, marsio_buff_t *rx_buff, struct selected_sf *sf, int thread_seq, void *ctx); // return + : send n bytes
static void forward_all_sf_packet_to_nf(struct packet_io *handle, marsio_buff_t *rx_buff, int thread_seq, void *ctx); // return -1 : error bypass
static int forward_all_nf_packet_to_sf(struct packet_io *handle, marsio_buff_t *rx_buff, struct selected_sf *sf, int thread_seq, void *ctx);
// return + : send n bytes
// return -1 : error drop
static int forward_all_sf_packet_to_nf(struct packet_io *handle, marsio_buff_t *rx_buff, int thread_seq, void *ctx);
// return 0 : success // return 0 : success
// return -1 : error // return -1 : error
@@ -282,7 +290,7 @@ int packet_io_polling_nf_interface(struct packet_io *handle, int thread_seq, voi
{ {
for (int j = 0; j < nr_recv; j++) for (int j = 0; j < nr_recv; j++)
{ {
if (marsio_buff_is_ctrlbuf(rx_buffs[j])) if (!marsio_buff_is_ctrlbuf(rx_buffs[j]))
{ {
int raw_len = marsio_buff_datalen(rx_buffs[j]); int raw_len = marsio_buff_datalen(rx_buffs[j]);
throughput_metrics_inc(&g_metrics->dev_nf_interface_rx, 1, raw_len); throughput_metrics_inc(&g_metrics->dev_nf_interface_rx, 1, raw_len);
@@ -304,8 +312,18 @@ int packet_io_polling_nf_interface(struct packet_io *handle, int thread_seq, voi
marsio_buff_t *rx_buff = rx_buffs[j]; marsio_buff_t *rx_buff = rx_buffs[j];
int raw_len = marsio_buff_datalen(rx_buff); int raw_len = marsio_buff_datalen(rx_buff);
throughput_metrics_inc(&g_metrics->dev_nf_interface_rx, 1, raw_len); throughput_metrics_inc(&g_metrics->dev_nf_interface_rx, 1, raw_len);
throughput_metrics_inc(&g_metrics->dev_endpoint_tx, 1, raw_len); // return + : send n bytes
forward_all_nf_packet_to_sf(handle, rx_buff, &sf, thread_seq, ctx); // return -1 : error bypass
int nsend = forward_all_nf_packet_to_sf(handle, rx_buff, &sf, thread_seq, ctx);
if (nsend > 0)
{
throughput_metrics_inc(&g_metrics->dev_endpoint_tx, 1, nsend);
}
else
{
throughput_metrics_inc(&g_metrics->dev_nf_interface_err_bypass, 1, raw_len);
marsio_send_burst(handle->dev_nf_interface.mr_path, thread_seq, &rx_buff, 1);
}
} }
return nr_recv; return nr_recv;
} }
@@ -313,29 +331,33 @@ int packet_io_polling_nf_interface(struct packet_io *handle, int thread_seq, voi
for (int j = 0; j < nr_recv; j++) for (int j = 0; j < nr_recv; j++)
{ {
marsio_buff_t *rx_buff = rx_buffs[j]; marsio_buff_t *rx_buff = rx_buffs[j];
int raw_len = marsio_buff_datalen(rx_buff);
if (marsio_buff_is_ctrlbuf(rx_buff)) if (marsio_buff_is_ctrlbuf(rx_buff))
{ {
handle_control_packet(handle, rx_buff, thread_seq, ctx); handle_control_packet(handle, rx_buff, thread_seq, ctx);
throughput_metrics_inc(&g_metrics->control_packet_rx, 1, raw_len);
// all control packet need bypass // all control packet need bypass
marsio_send_burst(handle->dev_nf_interface.mr_path, thread_seq, &rx_buff, 1); marsio_send_burst(handle->dev_nf_interface.mr_path, thread_seq, &rx_buff, 1);
} }
else else
{ {
int raw_len = marsio_buff_datalen(rx_buff);
throughput_metrics_inc(&g_metrics->dev_nf_interface_rx, 1, raw_len); throughput_metrics_inc(&g_metrics->dev_nf_interface_rx, 1, raw_len);
enum raw_pkt_action action = handle_raw_packet(handle, rx_buff, thread_seq, ctx); int action_bytes = 0;
enum raw_pkt_action action = handle_raw_packet(handle, rx_buff, thread_seq, ctx, &action_bytes);
assert(action_bytes > 0);
switch (action) switch (action)
{ {
case RAW_PKT_ERR_BYPASS: case RAW_PKT_ERR_BYPASS:
throughput_metrics_inc(&g_metrics->dev_nf_interface_err_bypass, 1, raw_len); throughput_metrics_inc(&g_metrics->dev_nf_interface_err_bypass, 1, action_bytes);
break; break;
case RAW_PKT_HIT_BYPASS: case RAW_PKT_HIT_BYPASS:
throughput_metrics_inc(&g_metrics->hit_bypass_policy, 1, raw_len); throughput_metrics_inc(&g_metrics->hit_bypass_policy, 1, action_bytes);
break; break;
case RAW_PKT_HIT_BLOCK: case RAW_PKT_HIT_BLOCK:
throughput_metrics_inc(&g_metrics->hit_block_policy, 1, raw_len); throughput_metrics_inc(&g_metrics->hit_block_policy, 1, action_bytes);
break; break;
case RAW_PKT_HIT_FORWARD: case RAW_PKT_HIT_FORWARD:
throughput_metrics_inc(&g_metrics->dev_endpoint_tx, 1, action_bytes);
break; break;
} }
} }
@@ -377,8 +399,17 @@ int packet_io_polling_endpoint(struct packet_io *handle, int thread_seq, void *c
marsio_buff_t *rx_buff = rx_buffs[j]; marsio_buff_t *rx_buff = rx_buffs[j];
int raw_len = marsio_buff_datalen(rx_buff); int raw_len = marsio_buff_datalen(rx_buff);
throughput_metrics_inc(&g_metrics->dev_endpoint_rx, 1, raw_len); throughput_metrics_inc(&g_metrics->dev_endpoint_rx, 1, raw_len);
throughput_metrics_inc(&g_metrics->dev_nf_interface_tx, 1, raw_len); // return + : send n bytes
forward_all_sf_packet_to_nf(handle, rx_buff, thread_seq, ctx); // return -1 : error drop
int nsend = forward_all_sf_packet_to_nf(handle, rx_buff, thread_seq, ctx);
if (nsend > 0)
{
throughput_metrics_inc(&g_metrics->dev_nf_interface_tx, 1, nsend);
}
else
{
throughput_metrics_inc(&g_metrics->dev_endpoint_err_drop, 1, raw_len);
}
} }
return nr_recv; return nr_recv;
} }
@@ -389,20 +420,22 @@ int packet_io_polling_endpoint(struct packet_io *handle, int thread_seq, void *c
int data_len = marsio_buff_datalen(rx_buff); int data_len = marsio_buff_datalen(rx_buff);
throughput_metrics_inc(&g_metrics->dev_endpoint_rx, 1, data_len); throughput_metrics_inc(&g_metrics->dev_endpoint_rx, 1, data_len);
enum inject_pkt_action action = handle_inject_packet(handle, rx_buff, thread_seq, ctx); int action_bytes = 0;
enum inject_pkt_action action = handle_inject_packet(handle, rx_buff, thread_seq, ctx, &action_bytes);
assert(action_bytes > 0);
switch (action) switch (action)
{ {
case INJT_PKT_ERR_DROP: case INJT_PKT_ERR_DROP:
throughput_metrics_inc(&g_metrics->dev_endpoint_err_drop, 1, data_len); throughput_metrics_inc(&g_metrics->dev_endpoint_err_drop, 1, action_bytes);
break; break;
case INJT_PKT_HIT_BLOCK: case INJT_PKT_HIT_BLOCK:
throughput_metrics_inc(&g_metrics->hit_block_policy, 1, data_len); throughput_metrics_inc(&g_metrics->hit_block_policy, 1, action_bytes);
break; break;
case INJT_PKT_HIT_FWD2SF: // forward to next service function case INJT_PKT_HIT_FWD2SF: // forward to next service function
throughput_metrics_inc(&g_metrics->dev_endpoint_tx, 1, data_len); throughput_metrics_inc(&g_metrics->dev_endpoint_tx, 1, action_bytes);
break; break;
case INJT_PKT_HIT_FWD2NF: // forward to network function case INJT_PKT_HIT_FWD2NF: // forward to network function
throughput_metrics_inc(&g_metrics->dev_nf_interface_tx, 1, data_len); throughput_metrics_inc(&g_metrics->dev_nf_interface_tx, 1, action_bytes);
break; break;
} }
} }
@@ -410,8 +443,8 @@ int packet_io_polling_endpoint(struct packet_io *handle, int thread_seq, void *c
return nr_recv; return nr_recv;
} }
// return -1 : error
// return 0 : success // return 0 : success
// return -1 : error
static int packet_io_config(const char *profile, struct config *config) static int packet_io_config(const char *profile, struct config *config)
{ {
MESA_load_profile_int_def(profile, "PACKET_IO", "bypass_all_traffic", (int *)&(config->bypass_all_traffic), 0); MESA_load_profile_int_def(profile, "PACKET_IO", "bypass_all_traffic", (int *)&(config->bypass_all_traffic), 0);
@@ -468,7 +501,7 @@ static int packet_io_get_metadata(marsio_buff_t *rx_buff, struct metadata *meta)
{ {
memset(meta, 0, sizeof(struct metadata)); memset(meta, 0, sizeof(struct metadata));
if (marsio_buff_get_metadata(rx_buff, MR_BUFF_SESSION_ID, &(meta->session_id), sizeof(meta->session_id)) != 0) if (marsio_buff_get_metadata(rx_buff, MR_BUFF_SESSION_ID, &(meta->session_id), sizeof(meta->session_id)) <= 0)
{ {
LOG_ERROR("%s: unable to get session_id from metadata", LOG_TAG_PKTIO); LOG_ERROR("%s: unable to get session_id from metadata", LOG_TAG_PKTIO);
return -1; return -1;
@@ -484,7 +517,7 @@ static int packet_io_get_metadata(marsio_buff_t *rx_buff, struct metadata *meta)
// 1: E2I // 1: E2I
// 0: I2E // 0: I2E
if (marsio_buff_get_metadata(rx_buff, MR_BUFF_DIR, &(meta->dir_is_e2i), sizeof(meta->dir_is_e2i)) != 0) if (marsio_buff_get_metadata(rx_buff, MR_BUFF_DIR, &(meta->dir_is_e2i), sizeof(meta->dir_is_e2i)) <= 0)
{ {
LOG_ERROR("%s: unable to get buff_dir from metadata", LOG_TAG_PKTIO); LOG_ERROR("%s: unable to get buff_dir from metadata", LOG_TAG_PKTIO);
return -1; return -1;
@@ -493,15 +526,12 @@ static int packet_io_get_metadata(marsio_buff_t *rx_buff, struct metadata *meta)
if (marsio_buff_is_ctrlbuf(rx_buff)) if (marsio_buff_is_ctrlbuf(rx_buff))
{ {
meta->is_ctrl_pkt = 1; meta->is_ctrl_pkt = 1;
// only control packet set MR_L7_OFFSET // only control packet set MR_BUFF_PAYLOAD_OFFSET
// TODO if (marsio_buff_get_metadata(rx_buff, MR_BUFF_PAYLOAD_OFFSET, &(meta->l7_offset), sizeof(meta->l7_offset)) <= 0)
#if 0
if (marsio_buff_get_metadata(rx_buff, MR_L7_OFFSET, &(meta->l7_offset), sizeof(meta->l7_offset)) != 0)
{ {
LOG_ERROR("%s: unable to get l7_offset from metadata", LOG_TAG_PKTIO); LOG_ERROR("%s: unable to get l7_offset from metadata", LOG_TAG_PKTIO);
return -1; return -1;
} }
#endif
} }
else else
{ {
@@ -509,7 +539,7 @@ static int packet_io_get_metadata(marsio_buff_t *rx_buff, struct metadata *meta)
// only raw packet set MR_IS_DECRYPTED // only raw packet set MR_IS_DECRYPTED
// TODO // TODO
#if 0 #if 0
if (marsio_buff_get_metadata(rx_buff, MR_IS_DECRYPTED, &(meta->traffic_is_decrypted), sizeof(meta->traffic_is_decrypted)) != 0) if (marsio_buff_get_metadata(rx_buff, MR_IS_DECRYPTED, &(meta->traffic_is_decrypted), sizeof(meta->traffic_is_decrypted)) <= 0)
{ {
LOG_ERROR("%s: unable to get traffic_is_decrypted from metadata", LOG_TAG_PKTIO); LOG_ERROR("%s: unable to get traffic_is_decrypted from metadata", LOG_TAG_PKTIO);
return -1; return -1;
@@ -517,7 +547,7 @@ static int packet_io_get_metadata(marsio_buff_t *rx_buff, struct metadata *meta)
#endif #endif
} }
if (marsio_buff_get_metadata(rx_buff, MR_BUFF_ROUTE_CTX, meta->route_ctx, sizeof(meta->route_ctx)) != 0) if (marsio_buff_get_metadata(rx_buff, MR_BUFF_ROUTE_CTX, meta->route_ctx, sizeof(meta->route_ctx)) <= 0)
{ {
LOG_ERROR("%s: unable to get route_ctx from metadata", LOG_TAG_PKTIO); LOG_ERROR("%s: unable to get route_ctx from metadata", LOG_TAG_PKTIO);
return -1; return -1;
@@ -548,22 +578,22 @@ static int packet_io_set_metadata(marsio_buff_t *tx_buff, struct metadata *meta)
// 1: E2I // 1: E2I
// 0: I2E // 0: I2E
#if 0
// use MR_BUFF_ROUTE_CTX instead
if (marsio_buff_set_metadata(tx_buff, MR_BUFF_DIR, &(meta->dir_is_e2i), sizeof(meta->dir_is_e2i)) != 0) if (marsio_buff_set_metadata(tx_buff, MR_BUFF_DIR, &(meta->dir_is_e2i), sizeof(meta->dir_is_e2i)) != 0)
{ {
LOG_ERROR("%s: unable to set buff_dir for metadata", LOG_TAG_PKTIO); LOG_ERROR("%s: unable to set buff_dir for metadata", LOG_TAG_PKTIO);
return -1; return -1;
} }
#endif
if (meta->is_ctrl_pkt) if (meta->is_ctrl_pkt)
{ {
// TODO if (marsio_buff_set_metadata(tx_buff, MR_BUFF_PAYLOAD_OFFSET, &(meta->l7_offset), sizeof(meta->l7_offset)) != 0)
#if 0
if (marsio_buff_set_metadata(tx_buff, MR_L7_OFFSET, &(meta->l7_offset), sizeof(meta->l7_offset)) != 0)
{ {
LOG_ERROR("%s: unable to set l7_offset for metadata", LOG_TAG_PKTIO); LOG_ERROR("%s: unable to set l7_offset for metadata", LOG_TAG_PKTIO);
return -1; return -1;
} }
#endif
} }
else else
{ {
@@ -598,6 +628,11 @@ static int packet_io_set_metadata(marsio_buff_t *tx_buff, struct metadata *meta)
return 0; return 0;
} }
static void packet_io_dump_metadata(marsio_buff_t *tx_buff, struct metadata *meta)
{
LOG_DEBUG("%s: META={session_id: %lu, raw_len: %d, dir_is_e2i: %d, is_ctrl_pkt: %d, l7_offset: %d, traffic_is_decrypted: %d, sids_num: %d}", LOG_TAG_PKTIO, meta->session_id, meta->raw_len, meta->dir_is_e2i, meta->is_ctrl_pkt, meta->l7_offset, meta->traffic_is_decrypted, meta->sids.num);
}
// return 0 : success // return 0 : success
// return -1 : error // return -1 : error
static int handle_control_packet(struct packet_io *handle, marsio_buff_t *rx_buff, int thread_seq, void *ctx) static int handle_control_packet(struct packet_io *handle, marsio_buff_t *rx_buff, int thread_seq, void *ctx)
@@ -606,6 +641,7 @@ static int handle_control_packet(struct packet_io *handle, marsio_buff_t *rx_buf
if (packet_io_get_metadata(rx_buff, &meta) == -1) if (packet_io_get_metadata(rx_buff, &meta) == -1)
{ {
LOG_ERROR("%s: unexpected control packet, unable to get metadata", LOG_TAG_PKTIO); LOG_ERROR("%s: unexpected control packet, unable to get metadata", LOG_TAG_PKTIO);
packet_io_dump_metadata(rx_buff, &meta);
return -1; return -1;
} }
@@ -644,15 +680,20 @@ static int handle_control_packet(struct packet_io *handle, marsio_buff_t *rx_buf
// return : RAW_PKT_HIT_BYPASS // return : RAW_PKT_HIT_BYPASS
// return : RAW_PKT_HIT_BLOCK // return : RAW_PKT_HIT_BLOCK
// reutrn : RAW_PKT_HIT_FORWARD // reutrn : RAW_PKT_HIT_FORWARD
static enum raw_pkt_action handle_raw_packet(struct packet_io *handle, marsio_buff_t *rx_buff, int thread_seq, void *ctx) static enum raw_pkt_action handle_raw_packet(struct packet_io *handle, marsio_buff_t *rx_buff, int thread_seq, void *ctx, int *action_bytes)
{ {
int nsend = 0;
struct thread_ctx *thread = (struct thread_ctx *)ctx; struct thread_ctx *thread = (struct thread_ctx *)ctx;
int raw_len = marsio_buff_datalen(rx_buff);
*action_bytes = 0;
struct metadata meta; struct metadata meta;
if (packet_io_get_metadata(rx_buff, &meta) == -1) if (packet_io_get_metadata(rx_buff, &meta) == -1)
{ {
LOG_ERROR("%s: unexpected raw packet, unable to get metadata, bypass !!!", LOG_TAG_PKTIO); LOG_ERROR("%s: unexpected raw packet, unable to get metadata, bypass !!!", LOG_TAG_PKTIO);
packet_io_dump_metadata(rx_buff, &meta);
marsio_send_burst(handle->dev_nf_interface.mr_path, thread_seq, &rx_buff, 1); marsio_send_burst(handle->dev_nf_interface.mr_path, thread_seq, &rx_buff, 1);
*action_bytes = raw_len;
return RAW_PKT_ERR_BYPASS; return RAW_PKT_ERR_BYPASS;
} }
@@ -661,6 +702,7 @@ static enum raw_pkt_action handle_raw_packet(struct packet_io *handle, marsio_bu
{ {
LOG_ERROR("%s: unexpected raw packet, unable to find session %lu from session table, bypass !!!", LOG_TAG_PKTIO, meta.session_id); LOG_ERROR("%s: unexpected raw packet, unable to find session %lu from session table, bypass !!!", LOG_TAG_PKTIO, meta.session_id);
marsio_send_burst(handle->dev_nf_interface.mr_path, thread_seq, &rx_buff, 1); marsio_send_burst(handle->dev_nf_interface.mr_path, thread_seq, &rx_buff, 1);
*action_bytes = raw_len;
return RAW_PKT_ERR_BYPASS; return RAW_PKT_ERR_BYPASS;
} }
@@ -689,14 +731,15 @@ static enum raw_pkt_action handle_raw_packet(struct packet_io *handle, marsio_bu
{ {
LOG_ERROR("%s: unexpected raw packet, session %lu %s misses policy, bypass !!!", LOG_TAG_PKTIO, s_ctx->session_id, s_ctx->first_ctrl_pkt.addr_string); LOG_ERROR("%s: unexpected raw packet, session %lu %s misses policy, bypass !!!", LOG_TAG_PKTIO, s_ctx->session_id, s_ctx->first_ctrl_pkt.addr_string);
marsio_send_burst(handle->dev_nf_interface.mr_path, thread_seq, &rx_buff, 1); marsio_send_burst(handle->dev_nf_interface.mr_path, thread_seq, &rx_buff, 1);
*action_bytes = raw_len;
return RAW_PKT_ERR_BYPASS; return RAW_PKT_ERR_BYPASS;
} }
for (int i = 0; i < chaining->chaining_used; i++) for (int i = 0; i < chaining->chaining_used; i++)
{ {
struct selected_sf *node = &(chaining->chaining[i]); struct selected_sf *node = &(chaining->chaining[i]);
LOG_INFO("%s: session %lu %s execute policy: %d -> sff_profile_id %d -> sf_profile_id %d -> sf_need_skip %d sf_action_reason : %d", LOG_INFO("%s: session %lu %s execute policy: %d -> sff_profile_id %d -> sf_profile_id %d -> sf_need_skip %d sf_action_reason : %s",
LOG_TAG_PKTIO, s_ctx->session_id, s_ctx->first_ctrl_pkt.addr_string, node->policy_id, node->sff_profile_id, node->sf_profile_id, node->sf_need_skip, node->sf_action_reason); LOG_TAG_PKTIO, s_ctx->session_id, s_ctx->first_ctrl_pkt.addr_string, node->policy_id, node->sff_profile_id, node->sf_profile_id, node->sf_need_skip, session_action_reason_to_string(node->sf_action_reason));
if (node->sf_need_skip) if (node->sf_need_skip)
{ {
@@ -711,25 +754,29 @@ static enum raw_pkt_action handle_raw_packet(struct packet_io *handle, marsio_bu
case SESSION_ACTION_BLOCK: case SESSION_ACTION_BLOCK:
// BLOCK ALL SF // BLOCK ALL SF
marsio_buff_free(handle->instance, &rx_buff, 1, 0, thread_seq); marsio_buff_free(handle->instance, &rx_buff, 1, 0, thread_seq);
*action_bytes = raw_len;
return RAW_PKT_HIT_BLOCK; return RAW_PKT_HIT_BLOCK;
case SESSION_ACTION_FORWARD: case SESSION_ACTION_FORWARD:
if (node->sf_connectivity.method != PACKAGE_METHOD_VXLAN_G) if (node->sf_connectivity.method != PACKAGE_METHOD_VXLAN_G)
{ {
LOG_ERROR("%s: processing raw packets, session %lu %s requires encapsulation format not supported, bypass !!!", LOG_TAG_PKTIO, s_ctx->session_id, s_ctx->first_ctrl_pkt.addr_string); LOG_ERROR("%s: processing raw packets, session %lu %s requires encapsulation format not supported, bypass !!!", LOG_TAG_PKTIO, s_ctx->session_id, s_ctx->first_ctrl_pkt.addr_string);
marsio_send_burst(handle->dev_nf_interface.mr_path, thread_seq, &rx_buff, 1); marsio_send_burst(handle->dev_nf_interface.mr_path, thread_seq, &rx_buff, 1);
*action_bytes = raw_len;
return RAW_PKT_ERR_BYPASS; return RAW_PKT_ERR_BYPASS;
} }
if (forward_packet_to_sf(handle, rx_buff, &meta, node, thread_seq, ctx) == 0) nsend = forward_packet_to_sf(handle, rx_buff, &meta, node, thread_seq, ctx);
if (nsend > 0)
{ {
throughput_metrics_inc(&node->tx, 1, meta.raw_len); throughput_metrics_inc(&node->tx, 1, nsend);
*action_bytes = nsend;
return RAW_PKT_HIT_FORWARD; return RAW_PKT_HIT_FORWARD;
} }
else else
{ {
LOG_ERROR("%s: processing raw packet, session %lu %s forwarding packet to service function failed, bypass !!!", LOG_TAG_PKTIO, s_ctx->session_id, s_ctx->first_ctrl_pkt.addr_string); LOG_ERROR("%s: processing raw packet, session %lu %s forwarding packet to service function failed, bypass !!!", LOG_TAG_PKTIO, s_ctx->session_id, s_ctx->first_ctrl_pkt.addr_string);
// TODO
marsio_send_burst(handle->dev_nf_interface.mr_path, thread_seq, &rx_buff, 1); marsio_send_burst(handle->dev_nf_interface.mr_path, thread_seq, &rx_buff, 1);
*action_bytes = raw_len;
return RAW_PKT_ERR_BYPASS; return RAW_PKT_ERR_BYPASS;
} }
default: default:
@@ -740,6 +787,7 @@ static enum raw_pkt_action handle_raw_packet(struct packet_io *handle, marsio_bu
// BYPASS ALL SF // BYPASS ALL SF
LOG_INFO("%s: session %lu %s bypass all service function", LOG_TAG_PKTIO, s_ctx->session_id, s_ctx->first_ctrl_pkt.addr_string); LOG_INFO("%s: session %lu %s bypass all service function", LOG_TAG_PKTIO, s_ctx->session_id, s_ctx->first_ctrl_pkt.addr_string);
marsio_send_burst(handle->dev_nf_interface.mr_path, thread_seq, &rx_buff, 1); marsio_send_burst(handle->dev_nf_interface.mr_path, thread_seq, &rx_buff, 1);
*action_bytes = raw_len;
return RAW_PKT_HIT_BYPASS; return RAW_PKT_HIT_BYPASS;
} }
@@ -747,17 +795,20 @@ static enum raw_pkt_action handle_raw_packet(struct packet_io *handle, marsio_bu
// return : INJT_PKT_HIT_BLOCK // return : INJT_PKT_HIT_BLOCK
// return : INJT_PKT_HIT_FWD2SF // return : INJT_PKT_HIT_FWD2SF
// return : INJT_PKT_HIT_FWD2NF // return : INJT_PKT_HIT_FWD2NF
static enum inject_pkt_action handle_inject_packet(struct packet_io *handle, marsio_buff_t *rx_buff, int thread_seq, void *ctx) 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;
struct thread_ctx *thread = (struct thread_ctx *)ctx; struct thread_ctx *thread = (struct thread_ctx *)ctx;
struct g_vxlan *g_vxlan_hdr = NULL; struct g_vxlan *g_vxlan_hdr = NULL;
int raw_len = marsio_buff_datalen(rx_buff); int raw_len = marsio_buff_datalen(rx_buff);
char *raw_data = marsio_buff_mtod(rx_buff); char *raw_data = marsio_buff_mtod(rx_buff);
*action_bytes = 0;
if (g_vxlan_decode(&g_vxlan_hdr, raw_data, raw_len) == -1) if (g_vxlan_decode(&g_vxlan_hdr, raw_data, raw_len) == -1)
{ {
LOG_ERROR("%s: unexpected inject packet, not a vxlan-encapsulated packet, drop !!!", LOG_TAG_PKTIO); LOG_ERROR("%s: unexpected inject packet, not a vxlan-encapsulated packet, drop !!!", LOG_TAG_PKTIO);
marsio_buff_free(handle->instance, &rx_buff, 1, 0, thread_seq); marsio_buff_free(handle->instance, &rx_buff, 1, 0, thread_seq);
*action_bytes = raw_len;
return INJT_PKT_ERR_DROP; return INJT_PKT_ERR_DROP;
} }
@@ -771,7 +822,7 @@ static enum inject_pkt_action handle_inject_packet(struct packet_io *handle, mar
meta.l7_offset = 0; meta.l7_offset = 0;
// meta.session_id set later // meta.session_id set later
// meta.sids set later // meta.sids set later
int next_sf_index = g_vxlan_get_next_sf_index(g_vxlan_hdr); int sf_index = g_vxlan_get_sf_index(g_vxlan_hdr);
struct addr_tuple4 inner_addr; struct addr_tuple4 inner_addr;
struct raw_pkt_parser raw_parser; struct raw_pkt_parser raw_parser;
@@ -787,6 +838,7 @@ static enum inject_pkt_action handle_inject_packet(struct packet_io *handle, mar
LOG_ERROR("%s: unexpected inject packet, unable to find session %s from session table, drop !!!", LOG_TAG_PKTIO, addr_string); LOG_ERROR("%s: unexpected inject packet, unable to find session %s from session table, drop !!!", LOG_TAG_PKTIO, addr_string);
free(addr_string); free(addr_string);
marsio_buff_free(handle->instance, &rx_buff, 1, 0, thread_seq); marsio_buff_free(handle->instance, &rx_buff, 1, 0, thread_seq);
*action_bytes = raw_len;
return INJT_PKT_ERR_DROP; return INJT_PKT_ERR_DROP;
} }
@@ -802,22 +854,25 @@ static enum inject_pkt_action handle_inject_packet(struct packet_io *handle, mar
sids_copy(&meta.sids, &s_ctx->raw_pkt_i2e_sids); sids_copy(&meta.sids, &s_ctx->raw_pkt_i2e_sids);
memcpy(meta.route_ctx, s_ctx->raw_pkt_i2e_route_ctx, sizeof(s_ctx->raw_pkt_i2e_route_ctx)); memcpy(meta.route_ctx, s_ctx->raw_pkt_i2e_route_ctx, sizeof(s_ctx->raw_pkt_i2e_route_ctx));
} }
LOG_DEBUG("%s: session %lu get metadata from inject packet, META={raw_len: %d, dir_is_e2i: %d, traffic_is_decrypted: %d, sf_index: %d}", LOG_TAG_PKTIO, meta.session_id, meta.raw_len, meta.dir_is_e2i, meta.traffic_is_decrypted, sf_index);
struct selected_chaining *chaining = s_ctx->chaining; struct selected_chaining *chaining = s_ctx->chaining;
if (chaining == NULL || next_sf_index < 1 || next_sf_index > chaining->chaining_used) if (chaining == NULL || sf_index < 0 || sf_index >= chaining->chaining_used)
{ {
LOG_ERROR("%s: unexpected inject packet, session %lu %s misses chaining index, drop !!!", LOG_TAG_PKTIO, s_ctx->session_id, s_ctx->first_ctrl_pkt.addr_string); LOG_ERROR("%s: unexpected inject packet, session %lu %s misses chaining index, 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); marsio_buff_free(handle->instance, &rx_buff, 1, 0, thread_seq);
*action_bytes = raw_len;
return INJT_PKT_ERR_DROP; return INJT_PKT_ERR_DROP;
} }
throughput_metrics_inc(&chaining->chaining[next_sf_index - 1].rx, 1, meta.raw_len); throughput_metrics_inc(&chaining->chaining[sf_index].rx, 1, meta.raw_len);
for (int i = next_sf_index; i < chaining->chaining_used; i++) int next_sf_index;
for (next_sf_index = sf_index + 1; next_sf_index < chaining->chaining_used; next_sf_index++)
{ {
struct selected_sf *node = &(chaining->chaining[i]); struct selected_sf *node = &(chaining->chaining[next_sf_index]);
LOG_INFO("%s: session %lu %s execute policy: %d -> sff_profile_id %d -> sf_profile_id %d -> sf_need_skip %d sf_action_reason : %d", LOG_INFO("%s: session %lu %s execute policy: %d -> sff_profile_id %d -> sf_profile_id %d -> sf_need_skip %d sf_action_reason : %s",
LOG_TAG_PKTIO, s_ctx->session_id, s_ctx->first_ctrl_pkt.addr_string, node->policy_id, node->sff_profile_id, node->sf_profile_id, node->sf_need_skip, node->sf_action_reason); LOG_TAG_PKTIO, s_ctx->session_id, s_ctx->first_ctrl_pkt.addr_string, node->policy_id, node->sff_profile_id, node->sf_profile_id, node->sf_need_skip, session_action_reason_to_string(node->sf_action_reason));
if (node->sf_need_skip) if (node->sf_need_skip)
{ {
@@ -832,77 +887,93 @@ static enum inject_pkt_action handle_inject_packet(struct packet_io *handle, mar
case SESSION_ACTION_BLOCK: case SESSION_ACTION_BLOCK:
// BLOCK ALL SF // BLOCK ALL SF
marsio_buff_free(handle->instance, &rx_buff, 1, 0, thread_seq); marsio_buff_free(handle->instance, &rx_buff, 1, 0, thread_seq);
*action_bytes = raw_len;
return INJT_PKT_HIT_BLOCK; return INJT_PKT_HIT_BLOCK;
case SESSION_ACTION_FORWARD: case SESSION_ACTION_FORWARD:
if (node->sf_connectivity.method != PACKAGE_METHOD_VXLAN_G) if (node->sf_connectivity.method != PACKAGE_METHOD_VXLAN_G)
{ {
LOG_ERROR("%s: processing inject packets, session %lu %s requires encapsulation format not supported, drop !!!", LOG_TAG_PKTIO, s_ctx->session_id, s_ctx->first_ctrl_pkt.addr_string); LOG_ERROR("%s: processing inject packets, session %lu %s requires encapsulation format not supported, 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); marsio_buff_free(handle->instance, &rx_buff, 1, 0, thread_seq);
*action_bytes = raw_len;
return INJT_PKT_ERR_DROP; return INJT_PKT_ERR_DROP;
} }
if (forward_packet_to_sf(handle, rx_buff, &meta, node, thread_seq, ctx) == 0) nsend = forward_packet_to_sf(handle, rx_buff, &meta, node, thread_seq, ctx);
if (nsend > 0)
{ {
throughput_metrics_inc(&node->tx, 1, meta.raw_len); throughput_metrics_inc(&node->tx, 1, nsend);
*action_bytes = nsend;
return INJT_PKT_HIT_FWD2SF; return INJT_PKT_HIT_FWD2SF;
} }
else else
{ {
LOG_ERROR("%s: processing inject packet, session %lu %s forwarding packet to service function failed, drop !!!", LOG_TAG_PKTIO, s_ctx->session_id, s_ctx->first_ctrl_pkt.addr_string); LOG_ERROR("%s: processing inject packet, session %lu %s forwarding packet to service 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); marsio_buff_free(handle->instance, &rx_buff, 1, 0, thread_seq);
*action_bytes = raw_len;
return INJT_PKT_ERR_DROP; return INJT_PKT_ERR_DROP;
} }
default: default:
assert(0);
continue; continue;
} }
} }
// the last sf need bypass or need skip
if (next_sf_index != chaining->chaining_used) if (next_sf_index != chaining->chaining_used)
{ {
LOG_ERROR("%s: unexpected inject packet, session %lu %s using invalid chaining index, drop !!!", LOG_TAG_PKTIO, s_ctx->session_id, s_ctx->first_ctrl_pkt.addr_string); LOG_ERROR("%s: unexpected inject packet, session %lu %s using invalid chaining index, 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); marsio_buff_free(handle->instance, &rx_buff, 1, 0, thread_seq);
return INJT_PKT_ERR_DROP; *action_bytes = raw_len;
}
if (forward_packet_to_nf(handle, rx_buff, &meta, thread_seq, ctx) == -1)
{
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);
return INJT_PKT_ERR_DROP; return INJT_PKT_ERR_DROP;
} }
else else
{ {
return INJT_PKT_HIT_FWD2NF; int nsend = forward_packet_to_nf(handle, rx_buff, &meta, thread_seq, ctx);
if (nsend > 0)
{
*action_bytes = nsend;
return INJT_PKT_HIT_FWD2NF;
}
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;
}
} }
} }
// return 0 : success // return + : send n bytes
// return -1 : error // return -1 : error
static int forward_packet_to_sf(struct packet_io *handle, marsio_buff_t *rx_buff, struct metadata *meta, struct selected_sf *sf, int thread_seq, void *ctx) static int forward_packet_to_sf(struct packet_io *handle, marsio_buff_t *rx_buff, struct metadata *meta, struct selected_sf *sf, int thread_seq, void *ctx)
{ {
marsio_buff_reset(rx_buff); marsio_buff_ctrlzone_reset(rx_buff);
struct ethhdr *eth_hdr = (struct ethhdr *)marsio_buff_prepend(rx_buff, sizeof(struct ethhdr) + sizeof(struct ip) + sizeof(struct udp_hdr) + sizeof(struct g_vxlan)); struct ethhdr *eth_hdr = (struct ethhdr *)marsio_buff_prepend(rx_buff, sizeof(struct ethhdr) + sizeof(struct ip) + sizeof(struct udp_hdr) + sizeof(struct g_vxlan));
struct ip *ip_hdr = (struct ip *)((char *)eth_hdr + sizeof(struct ethhdr)); struct ip *ip_hdr = (struct ip *)((char *)eth_hdr + sizeof(struct ethhdr));
struct udp_hdr *udp_hdr = (struct udp_hdr *)((char *)ip_hdr + sizeof(struct ip)); struct udp_hdr *udp_hdr = (struct udp_hdr *)((char *)ip_hdr + sizeof(struct ip));
struct g_vxlan *g_vxlan_hdr = (struct g_vxlan *)((char *)udp_hdr + sizeof(struct udp_hdr)); struct g_vxlan *g_vxlan_hdr = (struct g_vxlan *)((char *)udp_hdr + sizeof(struct udp_hdr));
LOG_DEBUG("%s: session %lu set metadata to inject packet, META={raw_len: %d, dir_is_e2i: %d, traffic_is_decrypted: %d, sf_index: %d}", LOG_TAG_PKTIO, meta->session_id, meta->raw_len, meta->dir_is_e2i, meta->traffic_is_decrypted, sf->sf_index);
memset(g_vxlan_hdr, 0, sizeof(struct g_vxlan)); memset(g_vxlan_hdr, 0, sizeof(struct g_vxlan));
g_vxlan_set_packet_dir(g_vxlan_hdr, meta->dir_is_e2i); g_vxlan_set_packet_dir(g_vxlan_hdr, meta->dir_is_e2i);
g_vxlan_set_next_sf_index(g_vxlan_hdr, sf->sf_index + 1); g_vxlan_set_sf_index(g_vxlan_hdr, sf->sf_index);
g_vxlan_set_traffic_type(g_vxlan_hdr, meta->traffic_is_decrypted); g_vxlan_set_traffic_type(g_vxlan_hdr, meta->traffic_is_decrypted);
build_ether_header(eth_hdr, ETH_P_IP, handle->config.default_src_mac, sf->sf_dst_mac); build_ether_header(eth_hdr, ETH_P_IP, handle->config.default_src_mac, sf->sf_dst_mac);
build_ip_header(ip_hdr, IPPROTO_UDP, handle->config.default_src_ip, sf->sf_dst_ip, sizeof(struct udp_hdr) + sizeof(struct g_vxlan) + meta->raw_len); build_ip_header(ip_hdr, IPPROTO_UDP, handle->config.default_src_ip, sf->sf_dst_ip, sizeof(struct udp_hdr) + sizeof(struct g_vxlan) + meta->raw_len);
build_udp_header((const char *)&ip_hdr->ip_src, 8, udp_hdr, meta->session_id % (65535 - 49152) + 49152, 4789, sizeof(struct g_vxlan) + meta->raw_len); build_udp_header((const char *)&ip_hdr->ip_src, 8, udp_hdr, meta->session_id % (65535 - 49152) + 49152, 4789, sizeof(struct g_vxlan) + meta->raw_len);
int raw_len = marsio_buff_datalen(rx_buff);
if (marsio_send_burst(handle->dev_endpoint.mr_path, thread_seq, &rx_buff, 1) != 0) if (marsio_send_burst(handle->dev_endpoint.mr_path, thread_seq, &rx_buff, 1) != 0)
{ {
LOG_ERROR("%s: unable to send burst on device %s, thread_seq: %d", LOG_TAG_PKTIO, handle->config.dev_endpoint, thread_seq); LOG_ERROR("%s: unable to send burst on device %s, thread_seq: %d", LOG_TAG_PKTIO, handle->config.dev_endpoint, thread_seq);
return -1; return -1;
} }
return 0; return raw_len;
} }
// return 0 : success // return 0 : success
@@ -911,22 +982,25 @@ static int forward_packet_to_nf(struct packet_io *handle, marsio_buff_t *rx_buff
{ {
marsio_buff_adj(rx_buff, marsio_buff_datalen(rx_buff) - meta->raw_len); marsio_buff_adj(rx_buff, marsio_buff_datalen(rx_buff) - meta->raw_len);
marsio_buff_reset(rx_buff); marsio_buff_ctrlzone_reset(rx_buff);
if (packet_io_set_metadata(rx_buff, meta) != 0) if (packet_io_set_metadata(rx_buff, meta) != 0)
{ {
return -1; return -1;
} }
int raw_len = marsio_buff_datalen(rx_buff);
if (marsio_send_burst(handle->dev_nf_interface.mr_path, thread_seq, &rx_buff, 1) != 0) if (marsio_send_burst(handle->dev_nf_interface.mr_path, thread_seq, &rx_buff, 1) != 0)
{ {
LOG_ERROR("%s: unable to send burst on device %s, thread_seq: %d", LOG_TAG_PKTIO, handle->config.dev_nf_interface, thread_seq); LOG_ERROR("%s: unable to send burst on device %s, thread_seq: %d", LOG_TAG_PKTIO, handle->config.dev_nf_interface, thread_seq);
return -1; return -1;
} }
return 0; return raw_len;
} }
static void forward_all_nf_packet_to_sf(struct packet_io *handle, marsio_buff_t *rx_buff, struct selected_sf *sf, int thread_seq, void *ctx) // return + : send n bytes
// return -1 : error drop
static int forward_all_nf_packet_to_sf(struct packet_io *handle, marsio_buff_t *rx_buff, struct selected_sf *sf, int thread_seq, void *ctx)
{ {
struct thread_ctx *thread = (struct thread_ctx *)ctx; struct thread_ctx *thread = (struct thread_ctx *)ctx;
struct global_metrics *g_metrics = thread->ref_metrics; struct global_metrics *g_metrics = thread->ref_metrics;
@@ -941,9 +1015,9 @@ static void forward_all_nf_packet_to_sf(struct packet_io *handle, marsio_buff_t
// get metadata // get metadata
if (packet_io_get_metadata(rx_buff, &meta) == -1) if (packet_io_get_metadata(rx_buff, &meta) == -1)
{ {
LOG_ERROR("%s: unexpected raw packet, unable to get metadata, drop !!!", LOG_TAG_PKTIO); LOG_ERROR("%s: unexpected raw packet, unable to get metadata, bypass !!!", LOG_TAG_PKTIO);
marsio_buff_free(handle->instance, &rx_buff, 1, 0, thread_seq); packet_io_dump_metadata(rx_buff, &meta);
return; return -1;
} }
// search session id // search session id
@@ -992,15 +1066,21 @@ static void forward_all_nf_packet_to_sf(struct packet_io *handle, marsio_buff_t
// forward data // forward data
forward: forward:
if (forward_packet_to_sf(handle, rx_buff, &meta, sf, thread_seq, ctx) == 0) int nsend = forward_packet_to_sf(handle, rx_buff, &meta, sf, thread_seq, ctx);
if (nsend > 0)
{ {
LOG_ERROR("%s: processing raw packet, session %lu %s forwarding packet to service function failed, drop !!!", LOG_TAG_PKTIO, s_ctx->session_id, s_ctx->first_ctrl_pkt.addr_string); return nsend;
marsio_buff_free(handle->instance, &rx_buff, 1, 0, thread_seq); }
return; else
{
LOG_ERROR("%s: processing raw packet, session %lu %s forwarding packet to service function failed, bypass !!!", LOG_TAG_PKTIO, s_ctx->session_id, s_ctx->first_ctrl_pkt.addr_string);
return -1;
} }
} }
static void forward_all_sf_packet_to_nf(struct packet_io *handle, marsio_buff_t *rx_buff, int thread_seq, void *ctx) // return + : send n bytes
// return -1 : error drop
static int forward_all_sf_packet_to_nf(struct packet_io *handle, marsio_buff_t *rx_buff, int thread_seq, void *ctx)
{ {
struct thread_ctx *thread = (struct thread_ctx *)ctx; struct thread_ctx *thread = (struct thread_ctx *)ctx;
// struct global_metrics *g_metrics = thread->ref_metrics; // struct global_metrics *g_metrics = thread->ref_metrics;
@@ -1013,7 +1093,7 @@ static void forward_all_sf_packet_to_nf(struct packet_io *handle, marsio_buff_t
{ {
LOG_ERROR("%s: unexpected inject packet, not a vxlan-encapsulated packet, drop !!!", LOG_TAG_PKTIO); LOG_ERROR("%s: unexpected inject packet, not a vxlan-encapsulated packet, drop !!!", LOG_TAG_PKTIO);
marsio_buff_free(handle->instance, &rx_buff, 1, 0, thread_seq); marsio_buff_free(handle->instance, &rx_buff, 1, 0, thread_seq);
return; return -1;
} }
struct metadata meta; struct metadata meta;
@@ -1041,7 +1121,7 @@ static void forward_all_sf_packet_to_nf(struct packet_io *handle, marsio_buff_t
LOG_ERROR("%s: unexpected inject packet, unable to find session %s from session table, drop !!!", LOG_TAG_PKTIO, addr_string); LOG_ERROR("%s: unexpected inject packet, unable to find session %s from session table, drop !!!", LOG_TAG_PKTIO, addr_string);
free(addr_string); free(addr_string);
marsio_buff_free(handle->instance, &rx_buff, 1, 0, thread_seq); marsio_buff_free(handle->instance, &rx_buff, 1, 0, thread_seq);
return; return -1;
} }
// add meta data // add meta data
@@ -1059,11 +1139,16 @@ static void forward_all_sf_packet_to_nf(struct packet_io *handle, marsio_buff_t
} }
// sendto nf // sendto nf
if (forward_packet_to_nf(handle, rx_buff, &meta, thread_seq, ctx) == -1) int nsend = forward_packet_to_nf(handle, rx_buff, &meta, thread_seq, ctx);
if (nsend > 0)
{
return nsend;
}
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); 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); marsio_buff_free(handle->instance, &rx_buff, 1, 0, thread_seq);
return; return -1;
} }
} }
@@ -1097,6 +1182,8 @@ static int handle_session_opening(struct metadata *meta, struct ctrl_pkt_parser
s_ctx->first_ctrl_pkt.header_len = meta->l7_offset; s_ctx->first_ctrl_pkt.header_len = meta->l7_offset;
s_ctx->chaining = selected_chaining_create(128); s_ctx->chaining = selected_chaining_create(128);
LOG_INFO("%s: session %lu %s opening", LOG_TAG_PKTIO, s_ctx->session_id, s_ctx->first_ctrl_pkt.addr_string);
for (int i = 0; i < parser->policy_id_num; i++) for (int i = 0; i < parser->policy_id_num; i++)
{ {
int new_policy_id = parser->policy_ids[i]; int new_policy_id = parser->policy_ids[i];
@@ -1107,12 +1194,11 @@ static int handle_session_opening(struct metadata *meta, struct ctrl_pkt_parser
else else
{ {
policy_enforce_select_chaining(s_ctx->chaining, thread->ref_enforcer, &raw_parser, new_policy_id, meta->dir_is_e2i); policy_enforce_select_chaining(s_ctx->chaining, thread->ref_enforcer, &raw_parser, new_policy_id, meta->dir_is_e2i);
selected_chaining_bref(s_ctx->chaining);
fixed_num_array_add_elem(&s_ctx->policy_ids, new_policy_id); fixed_num_array_add_elem(&s_ctx->policy_ids, new_policy_id);
} }
} }
LOG_INFO("%s: session %lu %s opening", LOG_TAG_PKTIO, s_ctx->session_id, s_ctx->first_ctrl_pkt.addr_string);
__atomic_fetch_add(&g_metrics->session_nums, 1, __ATOMIC_RELAXED); __atomic_fetch_add(&g_metrics->session_nums, 1, __ATOMIC_RELAXED);
session_table_insert(thread->session_table, s_ctx->session_id, &(s_ctx->first_ctrl_pkt.tuple4), s_ctx, session_value_free_cb); session_table_insert(thread->session_table, s_ctx->session_id, &(s_ctx->first_ctrl_pkt.tuple4), s_ctx, session_value_free_cb);
@@ -1161,6 +1247,8 @@ static int handle_session_active(struct metadata *meta, struct ctrl_pkt_parser *
} }
struct session_ctx *s_ctx = (struct session_ctx *)node->val_data; struct session_ctx *s_ctx = (struct session_ctx *)node->val_data;
LOG_INFO("%s: session %lu %s update", LOG_TAG_PKTIO, s_ctx->session_id, s_ctx->first_ctrl_pkt.addr_string);
for (int i = 0; i < parser->policy_id_num; i++) for (int i = 0; i < parser->policy_id_num; i++)
{ {
int new_policy_id = parser->policy_ids[i]; int new_policy_id = parser->policy_ids[i];
@@ -1171,6 +1259,7 @@ static int handle_session_active(struct metadata *meta, struct ctrl_pkt_parser *
else else
{ {
policy_enforce_select_chaining(s_ctx->chaining, thread->ref_enforcer, &raw_parser, new_policy_id, meta->dir_is_e2i); policy_enforce_select_chaining(s_ctx->chaining, thread->ref_enforcer, &raw_parser, new_policy_id, meta->dir_is_e2i);
selected_chaining_bref(s_ctx->chaining);
fixed_num_array_add_elem(&s_ctx->policy_ids, new_policy_id); fixed_num_array_add_elem(&s_ctx->policy_ids, new_policy_id);
} }
} }

View File

@@ -190,7 +190,7 @@ static const char *session_action_to_string(enum session_action session_action)
} }
} }
static const char *session_action_reason_to_string(enum session_action_reason session_action_reason) const char *session_action_reason_to_string(enum session_action_reason session_action_reason)
{ {
switch (session_action_reason) switch (session_action_reason)
{ {
@@ -830,6 +830,14 @@ static void sf_param_new_cb(int table_id, const char *key, const char *table_lin
} }
memcpy(param->sf_connectivity.dest_ip, item->valuestring, strlen(item->valuestring)); memcpy(param->sf_connectivity.dest_ip, item->valuestring, strlen(item->valuestring));
LOG_DEBUG("%s: parse sf profile: %d, connectivity->dest_ip: %s", LOG_TAG_POLICY, param->sf_profile_id, item->valuestring); LOG_DEBUG("%s: parse sf profile: %d, connectivity->dest_ip: %s", LOG_TAG_POLICY, param->sf_profile_id, item->valuestring);
// CM does not send this field, but only reads it from json, which is used for debugging
item = cJSON_GetObjectItem(root1, "dest_mac");
if (item && cJSON_IsString(item))
{
memcpy(param->sf_connectivity.dest_mac, item->valuestring, strlen(item->valuestring));
LOG_DEBUG("%s: parse sf profile: %d, connectivity->dst_mac: %s", LOG_TAG_POLICY, param->sf_profile_id, item->valuestring);
}
} }
// health_check // health_check
@@ -1107,6 +1115,7 @@ static void selected_sf_init(struct selected_sf *item)
{ {
if (item) if (item)
{ {
memset(item, 0, sizeof(struct selected_sf));
item->policy_id = -1; item->policy_id = -1;
item->traffic_type = TRAFFIC_TYPE_NONE; item->traffic_type = TRAFFIC_TYPE_NONE;
item->sff_profile_id = -1; item->sff_profile_id = -1;
@@ -1115,7 +1124,6 @@ static void selected_sf_init(struct selected_sf *item)
item->sf_profile_id = -1; item->sf_profile_id = -1;
item->sf_action = SESSION_ACTION_BYPASS; item->sf_action = SESSION_ACTION_BYPASS;
item->sf_action_reason = ACTION_BYPASS_DUE_DEFAULT; item->sf_action_reason = ACTION_BYPASS_DUE_DEFAULT;
memset(&item->sf_connectivity, 0, sizeof(struct connectivity));
} }
} }
@@ -1475,8 +1483,17 @@ void policy_enforce_select_chaining(struct selected_chaining *chaining, struct p
item->sf_connectivity.int_vlan_tag = sf_param->sf_connectivity.int_vlan_tag; item->sf_connectivity.int_vlan_tag = sf_param->sf_connectivity.int_vlan_tag;
item->sf_connectivity.ext_vlan_tag = sf_param->sf_connectivity.ext_vlan_tag; item->sf_connectivity.ext_vlan_tag = sf_param->sf_connectivity.ext_vlan_tag;
memcpy(item->sf_connectivity.dest_ip, sf_param->sf_connectivity.dest_ip, strlen(sf_param->sf_connectivity.dest_ip)); memcpy(item->sf_connectivity.dest_ip, sf_param->sf_connectivity.dest_ip, strlen(sf_param->sf_connectivity.dest_ip));
health_check_session_get_ip(item->sf_profile_id, item->sf_dst_ip);
health_check_session_get_mac(item->sf_profile_id, item->sf_dst_mac); memcpy(item->sf_dst_ip, sf_param->sf_connectivity.dest_ip, strlen(sf_param->sf_connectivity.dest_ip));
if (strlen(sf_param->sf_connectivity.dest_mac))
{
// CM does not send this field, but only reads it from json, which is used for debugging
memcpy(item->sf_dst_mac, sf_param->sf_connectivity.dest_ip, strlen(sf_param->sf_connectivity.dest_ip));
}
else
{
health_check_session_get_mac(item->sf_profile_id, item->sf_dst_mac);
}
chaining->chaining_used++; chaining->chaining_used++;
sf_param_free(sf_param); sf_param_free(sf_param);

View File

@@ -3,46 +3,7 @@
#include "sce.h" #include "sce.h"
#include "log.h" #include "log.h"
#include "global_metrics.h"
/******************************************************************************
* global_metrics
******************************************************************************/
struct global_metrics *global_metrics_create()
{
struct global_metrics *metrics = (struct global_metrics *)calloc(1, sizeof(struct global_metrics));
assert(metrics == NULL);
return metrics;
}
void global_metrics_destory(struct global_metrics *metrics)
{
if (metrics)
{
free(metrics);
metrics = NULL;
}
}
void global_metrics_dump(struct global_metrics *metrics)
{
if (metrics)
{
LOG_INFO("%s: dev_endpoint_rx : n_pkts : %6lu, n_bytes: %6lu", LOG_TAG_METRICS, metrics->dev_endpoint_rx.n_pkts, metrics->dev_endpoint_rx.n_bytes);
LOG_INFO("%s: dev_endpoint_tx : n_pkts : %6lu, n_bytes: %6lu", LOG_TAG_METRICS, metrics->dev_endpoint_tx.n_pkts, metrics->dev_endpoint_tx.n_bytes);
LOG_INFO("%s: dev_endpoint_err_drop : n_pkts : %6lu, n_bytes: %6lu", LOG_TAG_METRICS, metrics->dev_endpoint_err_drop.n_pkts, metrics->dev_endpoint_err_drop.n_bytes);
LOG_INFO("%s: dev_nf_interface_rx : n_pkts : %6lu, n_bytes: %6lu", LOG_TAG_METRICS, metrics->dev_nf_interface_rx.n_pkts, metrics->dev_nf_interface_rx.n_bytes);
LOG_INFO("%s: dev_nf_interface_tx : n_pkts : %6lu, n_bytes: %6lu", LOG_TAG_METRICS, metrics->dev_nf_interface_tx.n_pkts, metrics->dev_nf_interface_tx.n_bytes);
LOG_INFO("%s: dev_nf_interface_err_bypass : n_pkts : %6lu, n_bytes: %6lu", LOG_TAG_METRICS, metrics->dev_nf_interface_err_bypass.n_pkts, metrics->dev_nf_interface_err_bypass.n_bytes);
LOG_INFO("%s: hit_block_policy : n_pkts : %6lu, n_bytes: %6lu", LOG_TAG_METRICS, metrics->hit_block_policy.n_pkts, metrics->hit_block_policy.n_bytes);
LOG_INFO("%s: hit_bypass_policy : n_pkts : %6lu, n_bytes: %6lu", LOG_TAG_METRICS, metrics->hit_bypass_policy.n_pkts, metrics->hit_bypass_policy.n_bytes);
LOG_INFO("%s: current_session_num : %6lu", LOG_TAG_METRICS, metrics->session_nums);
}
}
/****************************************************************************** /******************************************************************************
* session_ctx * session_ctx
@@ -100,7 +61,7 @@ struct sce_ctx *sce_ctx_create(const char *profile)
goto error_out; goto error_out;
} }
ctx->metrics = global_metrics_create(); ctx->metrics = global_metrics_create(profile);
if (ctx->metrics == NULL) if (ctx->metrics == NULL)
{ {
goto error_out; goto error_out;
@@ -112,6 +73,11 @@ struct sce_ctx *sce_ctx_create(const char *profile)
goto error_out; goto error_out;
} }
if (policy_enforcer_register(ctx->enforcer) == -1)
{
goto error_out;
}
return ctx; return ctx;
error_out: error_out:

View File

@@ -3,8 +3,8 @@
{ {
"table_name": "SERVICE_FUNCTION_PROFILE", "table_name": "SERVICE_FUNCTION_PROFILE",
"table_content": [ "table_content": [
"1\tdevice_group_a\t1\t{\"method\":\"vxlan_g\",\"dest_ip\":\"1.1.1.1\"}\t{\"method\":\"none\"}\t1", "1\tdevice_group_a\t1\t{\"method\":\"vxlan_g\",\"dest_ip\":\"1.1.1.1\",\"dest_mac\":\"AA:AA:AA:AA:AA:AA\"}\t{\"method\":\"none\"}\t1",
"2\tdevice_group_a\t1\t{\"method\":\"vxlan_g\",\"dest_ip\":\"1.1.1.1\"}\t{\"method\":\"bfd\",\"address\":\"1.2.3.4\",\"port\":\"10000\",\"interval_ms\":100,\"retires\":5}\t1", "2\tdevice_group_a\t1\t{\"method\":\"vxlan_g\",\"dest_ip\":\"2.2.2.2\",\"dest_mac\":\"BB:BB:BB:BB:BB:BB\"}\t{\"method\":\"bfd\",\"address\":\"1.2.3.4\",\"port\":\"10000\",\"interval_ms\":100,\"retires\":5}\t1",
"3\tdevice_group_a\t1\t{\"method\":\"vxlan_g\",\"dest_ip\":\"1.1.1.1\"}\t{\"method\":\"in_band_bfd\",\"address\":\"1.2.3.4\",\"port\":\"10000\",\"interval_ms\":100,\"retires\":5}\t1", "3\tdevice_group_a\t1\t{\"method\":\"vxlan_g\",\"dest_ip\":\"1.1.1.1\"}\t{\"method\":\"in_band_bfd\",\"address\":\"1.2.3.4\",\"port\":\"10000\",\"interval_ms\":100,\"retires\":5}\t1",
"4\tdevice_group_a\t1\t{\"method\":\"vxlan_g\",\"dest_ip\":\"1.1.1.1\"}\t{\"method\":\"http\",\"url\":\"http://192.168.100.1:8080/health_check.index\",\"interval_ms\":100,\"retires\":5}\t1", "4\tdevice_group_a\t1\t{\"method\":\"vxlan_g\",\"dest_ip\":\"1.1.1.1\"}\t{\"method\":\"http\",\"url\":\"http://192.168.100.1:8080/health_check.index\",\"interval_ms\":100,\"retires\":5}\t1",
"5\tdevice_group_a\t1\t{\"method\":\"layer2_switch\",\"int_vlan_tag\":10,\"ext_vlan_tag\":5}\t{\"method\":\"none\"}\t1", "5\tdevice_group_a\t1\t{\"method\":\"layer2_switch\",\"int_vlan_tag\":10,\"ext_vlan_tag\":5}\t{\"method\":\"none\"}\t1",

View File

@@ -48,6 +48,10 @@ add_library(MESA_prof_load SHARED IMPORTED GLOBAL)
set_property(TARGET MESA_prof_load PROPERTY IMPORTED_LOCATION ${MESA_FRAMEWORK_LIB_DIR}/libMESA_prof_load.so) set_property(TARGET MESA_prof_load PROPERTY IMPORTED_LOCATION ${MESA_FRAMEWORK_LIB_DIR}/libMESA_prof_load.so)
set_property(TARGET MESA_prof_load PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${MESA_FRAMEWORK_INCLUDE_DIR}) set_property(TARGET MESA_prof_load PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${MESA_FRAMEWORK_INCLUDE_DIR})
add_library(MESA_field_stat SHARED IMPORTED GLOBAL)
set_property(TARGET MESA_field_stat PROPERTY IMPORTED_LOCATION ${MESA_FRAMEWORK_LIB_DIR}/libMESA_field_stat2.so)
set_property(TARGET MESA_field_stat PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${MESA_FRAMEWORK_INCLUDE_DIR})
add_library(maatframe SHARED IMPORTED GLOBAL) add_library(maatframe SHARED IMPORTED GLOBAL)
set_property(TARGET maatframe PROPERTY IMPORTED_LOCATION ${MESA_FRAMEWORK_LIB_DIR}/libmaatframe.so) set_property(TARGET maatframe PROPERTY IMPORTED_LOCATION ${MESA_FRAMEWORK_LIB_DIR}/libmaatframe.so)
set_property(TARGET maatframe PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${MESA_FRAMEWORK_INCLUDE_DIR}) set_property(TARGET maatframe PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${MESA_FRAMEWORK_INCLUDE_DIR})