TSG-14909 tsg-service-chaining-engine的service_function_status metrics适配vsys_id的变更
This commit is contained in:
@@ -39,6 +39,7 @@ struct session_iterm
|
||||
int is_active; // value2
|
||||
int profile_id; // value3
|
||||
uint8_t mac[HC_MAC_LEN]; // value4
|
||||
int vsys_id; // value5
|
||||
|
||||
UT_hash_handle hh1; /* handle for first hash table */
|
||||
};
|
||||
@@ -203,7 +204,7 @@ static uint64_t health_check_get_session_id()
|
||||
// return >0 : session id
|
||||
// return 0 : fail
|
||||
// struct health_check *policy : need deep copy
|
||||
uint64_t health_check_session_add(int profile_id, const struct health_check *policy)
|
||||
uint64_t health_check_session_add(int profile_id, int vsys_id, const struct health_check *policy)
|
||||
{
|
||||
int ret = 0;
|
||||
uint64_t session_id = 0;
|
||||
@@ -224,6 +225,7 @@ uint64_t health_check_session_add(int profile_id, const struct health_check *pol
|
||||
tmp = (struct session_iterm *)calloc(1, sizeof(struct session_iterm));
|
||||
assert(tmp);
|
||||
|
||||
tmp->vsys_id = vsys_id;
|
||||
tmp->session_id = session_id;
|
||||
tmp->profile_id = profile_id;
|
||||
memcpy(&tmp->policy, policy, sizeof(struct health_check));
|
||||
@@ -352,7 +354,7 @@ int health_check_session_set_status(uint64_t session_id, int is_active)
|
||||
|
||||
static int get_mac_by_addr(char *addr, uint8_t *buf)
|
||||
{
|
||||
int sfd, saved_errno, ret;
|
||||
int sfd, ret;
|
||||
struct arpreq arp_req;
|
||||
struct sockaddr_in *sin;
|
||||
|
||||
@@ -418,7 +420,7 @@ static void *_health_check_session_foreach(void *arg)
|
||||
is_active = 0;
|
||||
}
|
||||
|
||||
sf_status_update(g_sf_status, node->profile_id, is_active, 0);
|
||||
sf_status_update(g_sf_status, node->profile_id, node->vsys_id, is_active, 0);
|
||||
if (node->is_active != is_active) {
|
||||
node->is_active = is_active;
|
||||
if (node->is_active == 1) {
|
||||
|
||||
@@ -136,6 +136,7 @@ enum admin_status
|
||||
|
||||
struct sf_param
|
||||
{
|
||||
int sf_vsys_id;
|
||||
int sf_profile_id;
|
||||
int sf_ref_cnt;
|
||||
|
||||
@@ -681,16 +682,18 @@ static void sf_param_new_cb(const char *table_name, int table_id, const char *ke
|
||||
int admin_status = 0;
|
||||
char connectivity[128] = {0};
|
||||
char health_check[128] = {0};
|
||||
int vsys_id = 0;
|
||||
int is_valid = 0;
|
||||
|
||||
if (sscanf(table_line, "%d\t%s\t%d\t%s\t%s\t%d",
|
||||
&profile_id, device_group, &admin_status, connectivity, health_check, &is_valid) != 6)
|
||||
if (sscanf(table_line, "%d\t%s\t%d\t%s\t%s\t%d\t%d",
|
||||
&profile_id, device_group, &admin_status, connectivity, health_check, &vsys_id, &is_valid) != 7)
|
||||
{
|
||||
LOG_ERROR("%s: unexpected sf profile: %s", LOG_TAG_POLICY, table_line);
|
||||
return;
|
||||
}
|
||||
|
||||
param = (struct sf_param *)calloc(1, sizeof(struct sf_param));
|
||||
param->sf_vsys_id = vsys_id;
|
||||
param->sf_profile_id = atoi(key);
|
||||
param->sf_ref_cnt = 1;
|
||||
memcpy(param->sf_device_group, device_group, strlen(device_group));
|
||||
@@ -849,7 +852,7 @@ static void sf_param_new_cb(const char *table_name, int table_id, const char *ke
|
||||
param->sf_health_check.retires = item->valueint;
|
||||
LOG_DEBUG("%s: parse sf profile: %d, health_check->retires: %d", LOG_TAG_POLICY, param->sf_profile_id, item->valueint);
|
||||
}
|
||||
param->health_check_session_id = health_check_session_add(param->sf_profile_id, ¶m->sf_health_check);
|
||||
param->health_check_session_id = health_check_session_add(param->sf_profile_id, param->sf_vsys_id, ¶m->sf_health_check);
|
||||
|
||||
*ad = param;
|
||||
LOG_INFO("%s: Add sf profile: %d", LOG_TAG_POLICY, param->sf_profile_id);
|
||||
@@ -1600,6 +1603,7 @@ void policy_enforce_select_chainings(struct policy_enforcer *enforcer, struct se
|
||||
continue;
|
||||
}
|
||||
|
||||
item->sf_vsys_id = sf_param->sf_vsys_id;
|
||||
connectivity_copy(&item->sf_connectivity, &sf_param->sf_connectivity);
|
||||
memcpy(item->sf_dst_ip, sf_param->sf_connectivity.dest_ip, strlen(sf_param->sf_connectivity.dest_ip));
|
||||
chaining->chaining_used++;
|
||||
|
||||
@@ -9,10 +9,11 @@
|
||||
#include "utils.h"
|
||||
#include "sf_status.h"
|
||||
|
||||
#define SCE_SF_STATUS "service_function_status,sf_profile_id=%d sf_status=%d,sf_latency_us=%d"
|
||||
#define SCE_SF_STATUS "service_function_status,vsys_id=%d,sf_profile_id=%d sf_status=%d,sf_latency_us=%d"
|
||||
|
||||
struct node
|
||||
{
|
||||
int sf_vsys_id;
|
||||
int sf_profile_id;
|
||||
int sf_status;
|
||||
int sf_latency;
|
||||
@@ -144,7 +145,7 @@ void sf_status_delete(struct sf_status *handle, int sf_profile_id)
|
||||
}
|
||||
}
|
||||
|
||||
void sf_status_update(struct sf_status *handle, int sf_profile_id, int sf_status, int sf_latency)
|
||||
void sf_status_update(struct sf_status *handle, int sf_vsys_id, int sf_profile_id, int sf_status, int sf_latency)
|
||||
{
|
||||
if (handle == NULL || handle->config.enable == 0)
|
||||
{
|
||||
@@ -159,6 +160,7 @@ void sf_status_update(struct sf_status *handle, int sf_profile_id, int sf_status
|
||||
{
|
||||
LOG_DEBUG("%s: update: sf_profile %d status %d success, elem_num %lu", LOG_TAG_SF_STATUS, sf_profile_id, sf_status, handle->htable_elem_count);
|
||||
}
|
||||
temp->sf_vsys_id = sf_vsys_id;
|
||||
temp->sf_profile_id = sf_profile_id;
|
||||
temp->sf_status = sf_status;
|
||||
temp->sf_latency = sf_latency;
|
||||
@@ -168,6 +170,7 @@ void sf_status_update(struct sf_status *handle, int sf_profile_id, int sf_status
|
||||
handle->htable_elem_count++;
|
||||
LOG_DEBUG("%s: insert: sf_profile %d status %d success, elem_num %lu", LOG_TAG_SF_STATUS, sf_profile_id, sf_status, handle->htable_elem_count);
|
||||
temp = (struct node *)calloc(1, sizeof(struct node));
|
||||
temp->sf_vsys_id = sf_vsys_id;
|
||||
temp->sf_profile_id = sf_profile_id;
|
||||
temp->sf_status = sf_status;
|
||||
temp->sf_latency = sf_latency;
|
||||
@@ -194,6 +197,7 @@ void sf_status_send(struct sf_status *handle)
|
||||
{
|
||||
memset(buff, 0, size);
|
||||
nsend = snprintf(buff, size, SCE_SF_STATUS,
|
||||
node->sf_vsys_id,
|
||||
node->sf_profile_id,
|
||||
node->sf_status,
|
||||
node->sf_latency);
|
||||
|
||||
Reference in New Issue
Block a user