TSG-14908 tsg-service-chaining-engine的service_chaining_rule_hits metrics适配vsys_id的变更
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
# Telegraf Configuration
|
# Telegraf Configuration
|
||||||
[global_tags]
|
[global_tags]
|
||||||
device_id = "123456"
|
device_id = "123456"
|
||||||
vsys_id = "1"
|
|
||||||
device_group = "group-xxg-x-test"
|
device_group = "group-xxg-x-test"
|
||||||
data_center = "center-xxg-x-test"
|
data_center = "center-xxg-x-test"
|
||||||
|
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ struct connectivity
|
|||||||
struct selected_sf
|
struct selected_sf
|
||||||
{
|
{
|
||||||
uint64_t rule_id;
|
uint64_t rule_id;
|
||||||
|
int rule_vsys_id;
|
||||||
enum traffic_type traffic_type;
|
enum traffic_type traffic_type;
|
||||||
|
|
||||||
int sff_profile_id;
|
int sff_profile_id;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ struct sf_metrics *sf_metrics_create(const char *profile);
|
|||||||
void sf_metrics_destory(struct sf_metrics *handle);
|
void sf_metrics_destory(struct sf_metrics *handle);
|
||||||
void sf_metrics_reset(struct sf_metrics *handle);
|
void sf_metrics_reset(struct sf_metrics *handle);
|
||||||
|
|
||||||
void sf_metrics_inc(struct sf_metrics *handle, uint64_t rule_id, int sff_profile_id, int sf_profile_id, uint64_t rx_pkts, uint64_t rx_bytes, uint64_t tx_pkts, uint64_t tx_bytes);
|
void sf_metrics_inc(struct sf_metrics *handle, int vsys_id, uint64_t rule_id, int sff_profile_id, int sf_profile_id, uint64_t rx_pkts, uint64_t rx_bytes, uint64_t tx_pkts, uint64_t tx_bytes);
|
||||||
void sf_metrics_send(struct sf_metrics *handle);
|
void sf_metrics_send(struct sf_metrics *handle);
|
||||||
int sf_metrics_get_interval(struct sf_metrics *handle);
|
int sf_metrics_get_interval(struct sf_metrics *handle);
|
||||||
|
|
||||||
|
|||||||
@@ -447,7 +447,7 @@ static void action_mirr_forward(marsio_buff_t *rx_buff, struct metadata *meta, s
|
|||||||
throughput_metrics_inc(&(g_metrics->device.endpoint_tx), 1, nsend);
|
throughput_metrics_inc(&(g_metrics->device.endpoint_tx), 1, nsend);
|
||||||
throughput_metrics_inc(&(g_metrics->raw_pkt.mirr_tx), 1, raw_len);
|
throughput_metrics_inc(&(g_metrics->raw_pkt.mirr_tx), 1, raw_len);
|
||||||
throughput_metrics_inc(&sf->tx, 1, nsend);
|
throughput_metrics_inc(&sf->tx, 1, nsend);
|
||||||
sf_metrics_inc(thread_ctx->sf_metrics, sf->rule_id, sf->sff_profile_id, sf->sf_profile_id, 0, 0, 1, nsend);
|
sf_metrics_inc(thread_ctx->sf_metrics, sf->rule_vsys_id, sf->rule_id, sf->sff_profile_id, sf->sf_profile_id, 0, 0, 1, nsend);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void action_stee_bypass(marsio_buff_t *rx_buff, struct metadata *meta, struct selected_sf *sf, struct thread_ctx *thread_ctx)
|
static void action_stee_bypass(marsio_buff_t *rx_buff, struct metadata *meta, struct selected_sf *sf, struct thread_ctx *thread_ctx)
|
||||||
@@ -478,7 +478,7 @@ static void action_stee_forward(marsio_buff_t *rx_buff, struct metadata *meta, s
|
|||||||
throughput_metrics_inc(&(g_metrics->device.endpoint_tx), 1, nsend);
|
throughput_metrics_inc(&(g_metrics->device.endpoint_tx), 1, nsend);
|
||||||
throughput_metrics_inc(&(g_metrics->raw_pkt.stee_tx), 1, raw_len);
|
throughput_metrics_inc(&(g_metrics->raw_pkt.stee_tx), 1, raw_len);
|
||||||
throughput_metrics_inc(&sf->tx, 1, nsend);
|
throughput_metrics_inc(&sf->tx, 1, nsend);
|
||||||
sf_metrics_inc(thread_ctx->sf_metrics, sf->rule_id, sf->sff_profile_id, sf->sf_profile_id, 0, 0, 1, nsend);
|
sf_metrics_inc(thread_ctx->sf_metrics, sf->rule_vsys_id, sf->rule_id, sf->sff_profile_id, sf->sf_profile_id, 0, 0, 1, nsend);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void action_sf_chaining(struct thread_ctx *thread_ctx, struct session_ctx *session_ctx, struct selected_chaining *chaining, marsio_buff_t *rx_buff, struct metadata *meta, int next_sf_index)
|
static void action_sf_chaining(struct thread_ctx *thread_ctx, struct session_ctx *session_ctx, struct selected_chaining *chaining, marsio_buff_t *rx_buff, struct metadata *meta, int next_sf_index)
|
||||||
@@ -963,7 +963,7 @@ static void handle_inject_packet(marsio_buff_t *rx_buff, struct thread_ctx *thre
|
|||||||
struct selected_sf *sf = &(chaining->chaining[sf_index]);
|
struct selected_sf *sf = &(chaining->chaining[sf_index]);
|
||||||
throughput_metrics_inc(&sf->rx, 1, raw_len);
|
throughput_metrics_inc(&sf->rx, 1, raw_len);
|
||||||
throughput_metrics_inc(&(g_metrics->raw_pkt.stee_rx), 1, meta.raw_len);
|
throughput_metrics_inc(&(g_metrics->raw_pkt.stee_rx), 1, meta.raw_len);
|
||||||
sf_metrics_inc(thread_ctx->sf_metrics, sf->rule_id, sf->sff_profile_id, sf->sf_profile_id, 1, raw_len, 0, 0);
|
sf_metrics_inc(thread_ctx->sf_metrics, sf->rule_vsys_id, sf->rule_id, sf->sff_profile_id, sf->sf_profile_id, 1, raw_len, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
marsio_buff_adj(rx_buff, raw_len - meta.raw_len);
|
marsio_buff_adj(rx_buff, raw_len - meta.raw_len);
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ struct chaining_param
|
|||||||
{
|
{
|
||||||
uint64_t rule_id;
|
uint64_t rule_id;
|
||||||
int ref_cnt;
|
int ref_cnt;
|
||||||
|
int vsys_id;
|
||||||
|
|
||||||
enum traffic_type traffic_type;
|
enum traffic_type traffic_type;
|
||||||
int *sff_profile_ids;
|
int *sff_profile_ids;
|
||||||
@@ -301,6 +302,16 @@ static void chaining_param_new_cb(const char *table_name, int table_id, const ch
|
|||||||
param->rule_id = atoll(key);
|
param->rule_id = atoll(key);
|
||||||
param->ref_cnt = 1;
|
param->ref_cnt = 1;
|
||||||
|
|
||||||
|
// vsys_id
|
||||||
|
item = cJSON_GetObjectItem(json, "vsys_id");
|
||||||
|
if (!item || !cJSON_IsNumber(item))
|
||||||
|
{
|
||||||
|
LOG_ERROR("%s: unexpected chaining rule: (invalid vsys_id param) %s", LOG_TAG_POLICY, table_line);
|
||||||
|
goto error_out;
|
||||||
|
}
|
||||||
|
param->vsys_id = item->valueint;
|
||||||
|
LOG_DEBUG("%s: parse chaining rule: %lu, vsys_id: %d", LOG_TAG_POLICY, param->rule_id, param->vsys_id);
|
||||||
|
|
||||||
// targeted_traffic
|
// targeted_traffic
|
||||||
item = cJSON_GetObjectItem(json, "targeted_traffic");
|
item = cJSON_GetObjectItem(json, "targeted_traffic");
|
||||||
if (!item || !cJSON_IsString(item))
|
if (!item || !cJSON_IsString(item))
|
||||||
@@ -1046,6 +1057,7 @@ static void selected_sf_init(struct selected_sf *item)
|
|||||||
if (item)
|
if (item)
|
||||||
{
|
{
|
||||||
memset(item, 0, sizeof(struct selected_sf));
|
memset(item, 0, sizeof(struct selected_sf));
|
||||||
|
item->rule_vsys_id = 0;
|
||||||
item->rule_id = 0;
|
item->rule_id = 0;
|
||||||
item->traffic_type = TRAFFIC_TYPE_NONE;
|
item->traffic_type = TRAFFIC_TYPE_NONE;
|
||||||
item->sff_profile_id = -1;
|
item->sff_profile_id = -1;
|
||||||
@@ -1513,6 +1525,7 @@ void policy_enforce_select_chainings(struct policy_enforcer *enforcer, struct se
|
|||||||
selected_sf_init(item);
|
selected_sf_init(item);
|
||||||
|
|
||||||
item->rule_id = rule_id;
|
item->rule_id = rule_id;
|
||||||
|
item->rule_vsys_id = chaining_param->vsys_id;
|
||||||
item->traffic_type = chaining_param->traffic_type;
|
item->traffic_type = chaining_param->traffic_type;
|
||||||
item->sff_profile_id = chaining_param->sff_profile_ids[i];
|
item->sff_profile_id = chaining_param->sff_profile_ids[i];
|
||||||
item->sf_index = chaining->chaining_used;
|
item->sf_index = chaining->chaining_used;
|
||||||
|
|||||||
@@ -10,10 +10,11 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "sf_metrics.h"
|
#include "sf_metrics.h"
|
||||||
|
|
||||||
#define SCE_SF_METRICS "service_chaining_rule_hits,rule_id=%lu,sff_profile_id=%d,sf_profile_id=%d sent_pkts=%lu,sent_bytes=%lu,recv_pkts=%lu,recv_bytes=%lu"
|
#define SCE_SF_METRICS "service_chaining_rule_hits,vsys_id=%d,rule_id=%lu,sff_profile_id=%d,sf_profile_id=%d sent_pkts=%lu,sent_bytes=%lu,recv_pkts=%lu,recv_bytes=%lu"
|
||||||
|
|
||||||
struct key_tuple
|
struct key_tuple
|
||||||
{
|
{
|
||||||
|
int vsys_id;
|
||||||
uint64_t rule_id;
|
uint64_t rule_id;
|
||||||
int sff_profile_id;
|
int sff_profile_id;
|
||||||
int sf_profile_id;
|
int sf_profile_id;
|
||||||
@@ -137,7 +138,7 @@ void sf_metrics_reset(struct sf_metrics *handle)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sf_metrics_inc(struct sf_metrics *handle, uint64_t rule_id, int sff_profile_id, int sf_profile_id, uint64_t rx_pkts, uint64_t rx_bytes, uint64_t tx_pkts, uint64_t tx_bytes)
|
void sf_metrics_inc(struct sf_metrics *handle, int vsys_id, uint64_t rule_id, int sff_profile_id, int sf_profile_id, uint64_t rx_pkts, uint64_t rx_bytes, uint64_t tx_pkts, uint64_t tx_bytes)
|
||||||
{
|
{
|
||||||
if (handle->config.enable == 0)
|
if (handle->config.enable == 0)
|
||||||
{
|
{
|
||||||
@@ -146,6 +147,7 @@ void sf_metrics_inc(struct sf_metrics *handle, uint64_t rule_id, int sff_profile
|
|||||||
|
|
||||||
struct key_tuple key;
|
struct key_tuple key;
|
||||||
memset(&key, 0, sizeof(struct key_tuple));
|
memset(&key, 0, sizeof(struct key_tuple));
|
||||||
|
key.vsys_id = vsys_id;
|
||||||
key.rule_id = rule_id;
|
key.rule_id = rule_id;
|
||||||
key.sff_profile_id = sff_profile_id;
|
key.sff_profile_id = sff_profile_id;
|
||||||
key.sf_profile_id = sf_profile_id;
|
key.sf_profile_id = sf_profile_id;
|
||||||
@@ -162,6 +164,7 @@ void sf_metrics_inc(struct sf_metrics *handle, uint64_t rule_id, int sff_profile
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
temp = (struct node *)calloc(1, sizeof(struct node));
|
temp = (struct node *)calloc(1, sizeof(struct node));
|
||||||
|
temp->key.vsys_id = vsys_id;
|
||||||
temp->key.rule_id = rule_id;
|
temp->key.rule_id = rule_id;
|
||||||
temp->key.sff_profile_id = sff_profile_id;
|
temp->key.sff_profile_id = sff_profile_id;
|
||||||
temp->key.sf_profile_id = sf_profile_id;
|
temp->key.sf_profile_id = sf_profile_id;
|
||||||
@@ -197,6 +200,7 @@ void sf_metrics_send(struct sf_metrics *handle)
|
|||||||
|
|
||||||
memset(buff, 0, size);
|
memset(buff, 0, size);
|
||||||
nsend = snprintf(buff, size, SCE_SF_METRICS,
|
nsend = snprintf(buff, size, SCE_SF_METRICS,
|
||||||
|
node->key.vsys_id,
|
||||||
node->key.rule_id,
|
node->key.rule_id,
|
||||||
node->key.sff_profile_id,
|
node->key.sff_profile_id,
|
||||||
node->key.sf_profile_id,
|
node->key.sf_profile_id,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ TEST(SF_METRICS, TEST)
|
|||||||
{
|
{
|
||||||
struct sf_metrics *metrics = sf_metrics_create("./test_resource/sce.conf");
|
struct sf_metrics *metrics = sf_metrics_create("./test_resource/sce.conf");
|
||||||
EXPECT_TRUE(sf_metrics_get_interval(metrics) == 1);
|
EXPECT_TRUE(sf_metrics_get_interval(metrics) == 1);
|
||||||
sf_metrics_inc(metrics, 1, 2, 3, 4, 5, 6, 7);
|
sf_metrics_inc(metrics, 1, 1, 2, 3, 4, 5, 6, 7);
|
||||||
sf_metrics_send(metrics);
|
sf_metrics_send(metrics);
|
||||||
sf_metrics_destory(metrics);
|
sf_metrics_destory(metrics);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,10 +31,10 @@
|
|||||||
{
|
{
|
||||||
"table_name": "SERVICE_CHAINING_COMPILE",
|
"table_name": "SERVICE_CHAINING_COMPILE",
|
||||||
"table_content": [
|
"table_content": [
|
||||||
"1\t0\t2\t1\t1\t{}\t{\"targeted_traffic\":\"raw\",\"sff_profiles\":[1]}\t1\t2",
|
"1\t0\t2\t1\t1\t{}\t{\"vsys_id\":1,\"targeted_traffic\":\"raw\",\"sff_profiles\":[1]}\t1\t2",
|
||||||
"2\t0\t2\t1\t1\t{}\t{\"targeted_traffic\":\"raw\",\"sff_profiles\":[1,2,3,4,5,6,7,8,9,10]}\t1\t2",
|
"2\t0\t2\t1\t1\t{}\t{\"vsys_id\":1,\"targeted_traffic\":\"raw\",\"sff_profiles\":[1,2,3,4,5,6,7,8,9,10]}\t1\t2",
|
||||||
"11\t0\t2\t1\t1\t{}\t{\"targeted_traffic\":\"decrypted\",\"sff_profiles\":[1]}\t1\t2",
|
"11\t0\t2\t1\t1\t{}\t{\"vsys_id\":1,\"targeted_traffic\":\"decrypted\",\"sff_profiles\":[1]}\t1\t2",
|
||||||
"12\t0\t2\t1\t1\t{}\t{\"targeted_traffic\":\"decrypted\",\"sff_profiles\":[1,2,3,4,5,6,7,8,9,10]}\t1\t2"
|
"12\t0\t2\t1\t1\t{}\t{\"vsys_id\":1,\"targeted_traffic\":\"decrypted\",\"sff_profiles\":[1,2,3,4,5,6,7,8,9,10]}\t1\t2"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -31,10 +31,10 @@
|
|||||||
{
|
{
|
||||||
"table_name": "SERVICE_CHAINING_COMPILE",
|
"table_name": "SERVICE_CHAINING_COMPILE",
|
||||||
"table_content": [
|
"table_content": [
|
||||||
"1\t0\t2\t1\t1\t{}\t{\"targeted_traffic\":\"raw\",\"sff_profiles\":[1]}\t1\t2",
|
"1\t0\t2\t1\t1\t{}\t{\"vsys_id\":1,\"targeted_traffic\":\"raw\",\"sff_profiles\":[1]}\t1\t2",
|
||||||
"2\t0\t2\t1\t1\t{}\t{\"targeted_traffic\":\"raw\",\"sff_profiles\":[1,2,3,4,5,6,7,8,9,10]}\t1\t2",
|
"2\t0\t2\t1\t1\t{}\t{\"vsys_id\":1,\"targeted_traffic\":\"raw\",\"sff_profiles\":[1,2,3,4,5,6,7,8,9,10]}\t1\t2",
|
||||||
"11\t0\t2\t1\t1\t{}\t{\"targeted_traffic\":\"decrypted\",\"sff_profiles\":[1]}\t1\t2",
|
"11\t0\t2\t1\t1\t{}\t{\"vsys_id\":1,\"targeted_traffic\":\"decrypted\",\"sff_profiles\":[1]}\t1\t2",
|
||||||
"12\t0\t2\t1\t1\t{}\t{\"targeted_traffic\":\"decrypted\",\"sff_profiles\":[1,2,3,4,5,6,7,8,9,10]}\t1\t2"
|
"12\t0\t2\t1\t1\t{}\t{\"vsys_id\":1,\"targeted_traffic\":\"decrypted\",\"sff_profiles\":[1,2,3,4,5,6,7,8,9,10]}\t1\t2"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
{
|
{
|
||||||
"table_name": "SERVICE_CHAINING_COMPILE",
|
"table_name": "SERVICE_CHAINING_COMPILE",
|
||||||
"table_content": [
|
"table_content": [
|
||||||
"995199\t0\t2\t1\t1\t{}\t{\"targeted_traffic\":\"raw\",\"sff_profiles\":[1]}\t1\t2"
|
"995199\t0\t2\t1\t1\t{}\t{\"vsys_id\":1,\"targeted_traffic\":\"raw\",\"sff_profiles\":[1]}\t1\t2"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
{
|
{
|
||||||
"table_name": "SERVICE_CHAINING_COMPILE",
|
"table_name": "SERVICE_CHAINING_COMPILE",
|
||||||
"table_content": [
|
"table_content": [
|
||||||
"995199\t0\t2\t1\t1\t{}\t{\"targeted_traffic\":\"raw\",\"sff_profiles\":[1]}\t1\t2"
|
"995199\t0\t2\t1\t1\t{}\t{\"vsys_id\":1,\"targeted_traffic\":\"raw\",\"sff_profiles\":[1]}\t1\t2"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
{
|
{
|
||||||
"table_name": "SERVICE_CHAINING_COMPILE",
|
"table_name": "SERVICE_CHAINING_COMPILE",
|
||||||
"table_content": [
|
"table_content": [
|
||||||
"995199\t0\t2\t1\t1\t{}\t{\"targeted_traffic\":\"raw\",\"sff_profiles\":[1]}\t1\t2"
|
"995199\t0\t2\t1\t1\t{}\t{\"vsys_id\":1,\"targeted_traffic\":\"raw\",\"sff_profiles\":[1]}\t1\t2"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
{
|
{
|
||||||
"table_name": "SERVICE_CHAINING_COMPILE",
|
"table_name": "SERVICE_CHAINING_COMPILE",
|
||||||
"table_content": [
|
"table_content": [
|
||||||
"995199\t0\t2\t1\t1\t{}\t{\"targeted_traffic\":\"raw\",\"sff_profiles\":[1]}\t1\t2"
|
"995199\t0\t2\t1\t1\t{}\t{\"vsys_id\":1,\"targeted_traffic\":\"raw\",\"sff_profiles\":[1]}\t1\t2"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
{
|
{
|
||||||
"table_name": "SERVICE_CHAINING_COMPILE",
|
"table_name": "SERVICE_CHAINING_COMPILE",
|
||||||
"table_content": [
|
"table_content": [
|
||||||
"995199\t0\t2\t1\t1\t{}\t{\"targeted_traffic\":\"raw\",\"sff_profiles\":[1]}\t1\t2"
|
"995199\t0\t2\t1\t1\t{}\t{\"vsys_id\":1,\"targeted_traffic\":\"raw\",\"sff_profiles\":[1]}\t1\t2"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
{
|
{
|
||||||
"table_name": "SERVICE_CHAINING_COMPILE",
|
"table_name": "SERVICE_CHAINING_COMPILE",
|
||||||
"table_content": [
|
"table_content": [
|
||||||
"995199\t0\t2\t1\t1\t{}\t{\"targeted_traffic\":\"raw\",\"sff_profiles\":[1]}\t1\t2"
|
"995199\t0\t2\t1\t1\t{}\t{\"vsys_id\":1,\"targeted_traffic\":\"raw\",\"sff_profiles\":[1]}\t1\t2"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
{
|
{
|
||||||
"table_name": "SERVICE_CHAINING_COMPILE",
|
"table_name": "SERVICE_CHAINING_COMPILE",
|
||||||
"table_content": [
|
"table_content": [
|
||||||
"995199\t0\t2\t1\t1\t{}\t{\"targeted_traffic\":\"raw\",\"sff_profiles\":[1]}\t1\t2"
|
"995199\t0\t2\t1\t1\t{}\t{\"vsys_id\":1,\"targeted_traffic\":\"raw\",\"sff_profiles\":[1]}\t1\t2"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user