策略方式选择BFD时,才添加bfdd控制命;获取mac接口如果为空,返回-1
This commit is contained in:
@@ -102,15 +102,17 @@ int health_check_session_add(int session_id, const struct health_check *policy)
|
||||
tmp = (struct session_iterm *)calloc(1, sizeof(struct session_iterm));
|
||||
assert(tmp);
|
||||
|
||||
health_check_session_init_bfd_client(&client);
|
||||
bfd_vtysh_connect(&client);
|
||||
ret = bfd_vtysh_add_dev(&client, policy->address, policy->retires, policy->interval_ms);
|
||||
if (ret != 0) {
|
||||
LOG_DEBUG("bfd vtysh add dev address [%s] failed!", policy->address);
|
||||
if (policy->method == HEALTH_CHECK_METHOD_BFD) {
|
||||
health_check_session_init_bfd_client(&client);
|
||||
bfd_vtysh_connect(&client);
|
||||
ret = bfd_vtysh_add_dev(&client, policy->address, policy->retires, policy->interval_ms);
|
||||
if (ret != 0) {
|
||||
LOG_DEBUG("bfd vtysh add dev address [%s] failed!", policy->address);
|
||||
bfd_vtysh_close(&client);
|
||||
return -1;
|
||||
}
|
||||
bfd_vtysh_close(&client);
|
||||
return -1;
|
||||
}
|
||||
bfd_vtysh_close(&client);
|
||||
|
||||
memset(tmp, 0, sizeof(*tmp));
|
||||
tmp->session_id = session_id;
|
||||
@@ -138,15 +140,17 @@ int health_check_session_del(int session_id)
|
||||
return -1;
|
||||
}
|
||||
|
||||
health_check_session_init_bfd_client(&client);
|
||||
bfd_vtysh_connect(&client);
|
||||
ret = bfd_vtysh_del_dev(&client, tmp->policy.address);
|
||||
if (ret != 0) {
|
||||
LOG_DEBUG("bfd vtysh delete dev address [%s] failed!", tmp->policy.address);
|
||||
if (tmp->policy.method == HEALTH_CHECK_METHOD_BFD) {
|
||||
health_check_session_init_bfd_client(&client);
|
||||
bfd_vtysh_connect(&client);
|
||||
ret = bfd_vtysh_del_dev(&client, tmp->policy.address);
|
||||
if (ret != 0) {
|
||||
LOG_DEBUG("bfd vtysh delete dev address [%s] failed!", tmp->policy.address);
|
||||
bfd_vtysh_close(&client);
|
||||
return -1;
|
||||
}
|
||||
bfd_vtysh_close(&client);
|
||||
return -1;
|
||||
}
|
||||
bfd_vtysh_close(&client);
|
||||
|
||||
pthread_rwlock_wrlock(&g_handle.rwlock);
|
||||
HASH_DELETE(hh1, g_handle.root_by_id, tmp);
|
||||
@@ -284,6 +288,7 @@ int health_check_session_get_mac(int session_id, char *mac_buff)
|
||||
{
|
||||
uint8_t *p = NULL;
|
||||
struct session_iterm *tmp = NULL;
|
||||
uint8_t init_mac[HC_MAC_LEN] = {0};
|
||||
|
||||
pthread_rwlock_rdlock(&g_handle.rwlock);
|
||||
HASH_FIND(hh1, g_handle.root_by_id, &session_id, sizeof(session_id), tmp);
|
||||
@@ -294,8 +299,13 @@ int health_check_session_get_mac(int session_id, char *mac_buff)
|
||||
}
|
||||
|
||||
p = (uint8_t *)tmp->mac;
|
||||
if (memcmp(p, init_mac, HC_MAC_LEN) == 0) {
|
||||
pthread_rwlock_unlock(&g_handle.rwlock);
|
||||
return -1;
|
||||
}
|
||||
snprintf(mac_buff, 18, "%02x:%02x:%02x:%02x:%02x:%02x", p[0], p[1], p[2], p[3], p[4], p[5]);
|
||||
pthread_rwlock_unlock(&g_handle.rwlock);
|
||||
LOG_DEBUG("health check session get mac: %s", mac_buff);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user