TSG-22348 feature: adapt maat support UUID

This commit is contained in:
luwenpeng
2024-09-23 16:50:09 +08:00
parent 7ef8e44bca
commit 5799de5299
60 changed files with 2504 additions and 1043 deletions

View File

@@ -46,7 +46,7 @@ struct session_iterm
struct health_check policy; // value1: deep copy
int is_active; // value2
int profile_id; // value3
uuid_t sf_uuid; // value3
int vsys_id; // value4
UT_hash_handle hh1; /* handle for first hash table */
@@ -457,7 +457,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, int vsys_id, const struct health_check *policy)
uint64_t health_check_session_add(uuid_t *sf_uuid, int vsys_id, const struct health_check *policy)
{
uint64_t session_id = 0;
uint8_t mac[ETH_ALEN] = {0};
@@ -481,7 +481,7 @@ uint64_t health_check_session_add(int profile_id, int vsys_id, const struct heal
tmp->vsys_id = vsys_id;
tmp->session_id = session_id;
tmp->profile_id = profile_id;
uuid_copy(tmp->sf_uuid, *sf_uuid);
memcpy(&tmp->policy, policy, sizeof(struct health_check));
HASH_ADD(hh1, g_handle.root_by_id, session_id, sizeof(tmp->session_id), tmp);
@@ -498,13 +498,15 @@ uint64_t health_check_session_add(int profile_id, int vsys_id, const struct heal
health_check_method_table_set_mac(&g_handle_none, tmp->policy.address, mac);
}
LOG_DEBUG("health check session table insert: profile id [%d] session id [%lu] address [%s] success", profile_id, session_id, policy->address);
char sf_uuid_str[UUID_STRING_SIZE] = {0};
uuid_unparse(*sf_uuid, sf_uuid_str);
LOG_DEBUG("health check session table insert: profile id [%s] session id [%lu] address [%s] success", sf_uuid_str, session_id, policy->address);
return session_id;
}
// return 0 : success
// return -1 : key not exist
int health_check_session_del(uint64_t session_id, int profile_id, int vsys_id)
int health_check_session_del(uint64_t session_id, uuid_t *sf_uuid, int vsys_id)
{
int ret = 0;
struct session_iterm *tmp = NULL;
@@ -536,13 +538,15 @@ end:
HASH_DELETE(hh1, g_handle.root_by_id, tmp);
struct sf_status_key key = {0};
key.vsys_id = vsys_id;
key.sf_profile_id = profile_id;
uuid_copy(key.sf_uuid, *sf_uuid);
sf_status_delete(g_sf_status, &key);
pthread_rwlock_unlock(&g_handle.rwlock);
free(tmp);
tmp = NULL;
LOG_DEBUG("health check session table delete: profile id [%d] session id [%lu] success", profile_id, session_id);
char sf_uuid_str[UUID_STRING_SIZE] = {0};
uuid_unparse(*sf_uuid, sf_uuid_str);
LOG_DEBUG("health check session table delete: profile id [%s] session id [%lu] success", sf_uuid_str, session_id);
return 0;
}
@@ -667,7 +671,7 @@ static void *_health_check_session_foreach(void *arg)
struct sf_status_key key = {0};
key.vsys_id = node->vsys_id;
key.sf_profile_id = node->profile_id;
uuid_copy(key.sf_uuid, node->sf_uuid);
sf_status_update(g_sf_status, &key, is_active, 0);
if (node->is_active != is_active) {
node->is_active = is_active;
@@ -743,6 +747,7 @@ int health_check_session_get_mac(uint64_t session_id, u_char mac_buff[])
struct session_iterm *tmp = NULL;
uint8_t mac[ETH_ALEN] = {0};
uint8_t init_mac[ETH_ALEN] = {0};
char sf_uuid_str[UUID_STRING_SIZE] = {0};
if (enable == 0)
{
@@ -757,9 +762,10 @@ int health_check_session_get_mac(uint64_t session_id, u_char mac_buff[])
return -1;
}
uuid_unparse(tmp->sf_uuid, sf_uuid_str);
str_method = health_check_method_str(tmp->policy.method);
if (tmp->policy.method == HEALTH_CHECK_METHOD_BFD && tmp->is_active == 0) {
LOG_DEBUG("health check session id [%lu] profile id [%d] health check method [%s] active is down", session_id, tmp->profile_id, str_method);
LOG_DEBUG("health check session id [%lu] profile id [%s] health check method [%s] active is down", session_id, sf_uuid_str, str_method);
pthread_rwlock_unlock(&g_handle.rwlock);
return -1;
}
@@ -773,20 +779,20 @@ int health_check_session_get_mac(uint64_t session_id, u_char mac_buff[])
if (memcmp(mac, init_mac, ETH_ALEN) == 0) {
if (strlen(gateway_address) == 0) {
LOG_DEBUG("health check session id [%lu] profile id [%d] health check method [%s] get mac [null]", session_id, tmp->profile_id, str_method);
LOG_DEBUG("health check session id [%lu] profile id [%s] health check method [%s] get mac [null]", session_id, sf_uuid_str, str_method);
pthread_rwlock_unlock(&g_handle.rwlock);
return -1;
}
health_check_method_table_get_mac(&g_handle_none, gateway_address, mac);
if (memcmp(mac, init_mac, ETH_ALEN) == 0) {
LOG_DEBUG("health check session id [%lu] profile id [%d] health check method [%s] get mac [null]", session_id, tmp->profile_id, str_method);
LOG_DEBUG("health check session id [%lu] profile id [%s] health check method [%s] get mac [null]", session_id, sf_uuid_str, str_method);
pthread_rwlock_unlock(&g_handle.rwlock);
return -1;
}
}
memcpy(mac_buff, mac, ETH_ALEN);
LOG_DEBUG("health check session id [%lu] profile id [%d] health check method [%s] get mac [%02x:%02x:%02x:%02x:%02x:%02x]", session_id, tmp->profile_id, str_method, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
LOG_DEBUG("health check session id [%lu] profile id [%s] health check method [%s] get mac [%02x:%02x:%02x:%02x:%02x:%02x]", session_id, sf_uuid_str, str_method, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
pthread_rwlock_unlock(&g_handle.rwlock);
return 0;
}