策略方式选择BFD时,才添加bfdd控制命;获取mac接口如果为空,返回-1
This commit is contained in:
@@ -102,6 +102,7 @@ int health_check_session_add(int session_id, const struct health_check *policy)
|
|||||||
tmp = (struct session_iterm *)calloc(1, sizeof(struct session_iterm));
|
tmp = (struct session_iterm *)calloc(1, sizeof(struct session_iterm));
|
||||||
assert(tmp);
|
assert(tmp);
|
||||||
|
|
||||||
|
if (policy->method == HEALTH_CHECK_METHOD_BFD) {
|
||||||
health_check_session_init_bfd_client(&client);
|
health_check_session_init_bfd_client(&client);
|
||||||
bfd_vtysh_connect(&client);
|
bfd_vtysh_connect(&client);
|
||||||
ret = bfd_vtysh_add_dev(&client, policy->address, policy->retires, policy->interval_ms);
|
ret = bfd_vtysh_add_dev(&client, policy->address, policy->retires, policy->interval_ms);
|
||||||
@@ -111,6 +112,7 @@ int health_check_session_add(int session_id, const struct health_check *policy)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
bfd_vtysh_close(&client);
|
bfd_vtysh_close(&client);
|
||||||
|
}
|
||||||
|
|
||||||
memset(tmp, 0, sizeof(*tmp));
|
memset(tmp, 0, sizeof(*tmp));
|
||||||
tmp->session_id = session_id;
|
tmp->session_id = session_id;
|
||||||
@@ -138,6 +140,7 @@ int health_check_session_del(int session_id)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tmp->policy.method == HEALTH_CHECK_METHOD_BFD) {
|
||||||
health_check_session_init_bfd_client(&client);
|
health_check_session_init_bfd_client(&client);
|
||||||
bfd_vtysh_connect(&client);
|
bfd_vtysh_connect(&client);
|
||||||
ret = bfd_vtysh_del_dev(&client, tmp->policy.address);
|
ret = bfd_vtysh_del_dev(&client, tmp->policy.address);
|
||||||
@@ -147,6 +150,7 @@ int health_check_session_del(int session_id)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
bfd_vtysh_close(&client);
|
bfd_vtysh_close(&client);
|
||||||
|
}
|
||||||
|
|
||||||
pthread_rwlock_wrlock(&g_handle.rwlock);
|
pthread_rwlock_wrlock(&g_handle.rwlock);
|
||||||
HASH_DELETE(hh1, g_handle.root_by_id, tmp);
|
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;
|
uint8_t *p = NULL;
|
||||||
struct session_iterm *tmp = NULL;
|
struct session_iterm *tmp = NULL;
|
||||||
|
uint8_t init_mac[HC_MAC_LEN] = {0};
|
||||||
|
|
||||||
pthread_rwlock_rdlock(&g_handle.rwlock);
|
pthread_rwlock_rdlock(&g_handle.rwlock);
|
||||||
HASH_FIND(hh1, g_handle.root_by_id, &session_id, sizeof(session_id), tmp);
|
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;
|
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]);
|
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);
|
pthread_rwlock_unlock(&g_handle.rwlock);
|
||||||
LOG_DEBUG("health check session get mac: %s", mac_buff);
|
LOG_DEBUG("health check session get mac: %s", mac_buff);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user