TSG-14908 tsg-service-chaining-engine的service_chaining_rule_hits metrics适配vsys_id的变更
This commit is contained in:
@@ -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->raw_pkt.mirr_tx), 1, raw_len);
|
||||
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)
|
||||
@@ -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->raw_pkt.stee_tx), 1, raw_len);
|
||||
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)
|
||||
@@ -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]);
|
||||
throughput_metrics_inc(&sf->rx, 1, 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);
|
||||
|
||||
@@ -68,6 +68,7 @@ struct chaining_param
|
||||
{
|
||||
uint64_t rule_id;
|
||||
int ref_cnt;
|
||||
int vsys_id;
|
||||
|
||||
enum traffic_type traffic_type;
|
||||
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->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
|
||||
item = cJSON_GetObjectItem(json, "targeted_traffic");
|
||||
if (!item || !cJSON_IsString(item))
|
||||
@@ -1046,6 +1057,7 @@ static void selected_sf_init(struct selected_sf *item)
|
||||
if (item)
|
||||
{
|
||||
memset(item, 0, sizeof(struct selected_sf));
|
||||
item->rule_vsys_id = 0;
|
||||
item->rule_id = 0;
|
||||
item->traffic_type = TRAFFIC_TYPE_NONE;
|
||||
item->sff_profile_id = -1;
|
||||
@@ -1513,6 +1525,7 @@ void policy_enforce_select_chainings(struct policy_enforcer *enforcer, struct se
|
||||
selected_sf_init(item);
|
||||
|
||||
item->rule_id = rule_id;
|
||||
item->rule_vsys_id = chaining_param->vsys_id;
|
||||
item->traffic_type = chaining_param->traffic_type;
|
||||
item->sff_profile_id = chaining_param->sff_profile_ids[i];
|
||||
item->sf_index = chaining->chaining_used;
|
||||
|
||||
@@ -10,10 +10,11 @@
|
||||
#include "utils.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
|
||||
{
|
||||
int vsys_id;
|
||||
uint64_t rule_id;
|
||||
int sff_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)
|
||||
{
|
||||
@@ -146,6 +147,7 @@ void sf_metrics_inc(struct sf_metrics *handle, uint64_t rule_id, int sff_profile
|
||||
|
||||
struct key_tuple key;
|
||||
memset(&key, 0, sizeof(struct key_tuple));
|
||||
key.vsys_id = vsys_id;
|
||||
key.rule_id = rule_id;
|
||||
key.sff_profile_id = sff_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
|
||||
{
|
||||
temp = (struct node *)calloc(1, sizeof(struct node));
|
||||
temp->key.vsys_id = vsys_id;
|
||||
temp->key.rule_id = rule_id;
|
||||
temp->key.sff_profile_id = sff_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);
|
||||
nsend = snprintf(buff, size, SCE_SF_METRICS,
|
||||
node->key.vsys_id,
|
||||
node->key.rule_id,
|
||||
node->key.sff_profile_id,
|
||||
node->key.sf_profile_id,
|
||||
|
||||
Reference in New Issue
Block a user