diff --git a/conf/sce.conf b/conf/sce.conf index df26381..50ff4e7 100644 --- a/conf/sce.conf +++ b/conf/sce.conf @@ -75,6 +75,8 @@ telegraf_listen_port=8300 [bfdd] enable=1 +# use default_gw_mac when enable = 0 +default_gw_mac=aa:aa:aa:aa:aa:aa path=/run/run/frr/bfdd.vty device=eth0 local_address=127.0.0.1 diff --git a/platform/src/health_check.cpp b/platform/src/health_check.cpp index 474c311..f283e62 100644 --- a/platform/src/health_check.cpp +++ b/platform/src/health_check.cpp @@ -314,6 +314,7 @@ static int send_icmp_cycle() void health_check_session_init(const char *profile) { + char default_gw_mac_str[32] = { 0 }; memset(&g_handle, 0, sizeof(g_handle)); pthread_rwlock_init(&g_handle.rwlock, NULL); memset(&g_handle_bfd, 0, sizeof(g_handle_bfd)); @@ -326,9 +327,11 @@ void health_check_session_init(const char *profile) MESA_load_profile_string_def(profile, "bfdd", "device", hc_dev_name, sizeof(hc_dev_name), "eth0"); MESA_load_profile_string_def(profile, "bfdd", "local_address", local_address, sizeof(local_address), "127.0.0.1"); MESA_load_profile_string_def(profile, "bfdd", "gateway", gateway_address, sizeof(gateway_address), "127.0.0.1"); + MESA_load_profile_string_def(profile, "bfdd", "default_gw_mac", default_gw_mac_str, sizeof(default_gw_mac_str), "aa:aa:aa:aa:aa:aa"); if (enable == 0) { + str_to_mac(default_gw_mac_str, default_gw_mac); return; } @@ -721,6 +724,7 @@ int health_check_session_get_mac(uint64_t session_id, u_char mac_buff[]) if (enable == 0) { + memcpy(mac_buff, default_gw_mac, ETH_ALEN); return 0; } pthread_rwlock_rdlock(&g_handle.rwlock);