diff --git a/src/control_server.c b/src/control_server.c index b27c9de..be5a084 100644 --- a/src/control_server.c +++ b/src/control_server.c @@ -10,6 +10,7 @@ #include "etcp_connections.h" #include "tun_if.h" #include "route_lib.h" +#include "route_bgp.h" #include "pkt_normalizer.h" #include "../lib/u_async.h" #include "../lib/debug_config.h" @@ -857,6 +858,15 @@ static void send_metrics(struct control_server* server, struct control_client* c rsp->tun.rt_local = 0; rsp->tun.rt_learned = 0; } + + /* BGP routing */ + if (instance->bgp) { + rsp->tun.rt_bgp_senders = (uint32_t)queue_entry_count(instance->bgp->senders_list); + rsp->tun.rt_bgp_nodes = (uint32_t)queue_entry_count(instance->bgp->nodes); + } else { + rsp->tun.rt_bgp_senders = 0; + rsp->tun.rt_bgp_nodes = 0; + } } else { memset(&rsp->tun, 0, sizeof(rsp->tun)); } diff --git a/tools/etcpmon/etcpmon_gui.c b/tools/etcpmon/etcpmon_gui.c index 4ff6f77..1f730c2 100644 --- a/tools/etcpmon/etcpmon_gui.c +++ b/tools/etcpmon/etcpmon_gui.c @@ -420,6 +420,18 @@ static void CreateControls(struct etcpmon_app* app) { WS_CHILD | WS_VISIBLE | ES_READONLY | ES_CENTER, mx + 260, my - 2, 50, 18, hWnd, (HMENU)IDC_EDIT_RT_LEARNED, hInst, NULL); + CreateWindowExA(0, "STATIC", "BGP S:", + WS_CHILD | WS_VISIBLE, mx + 320, my, 45, 18, hWnd, (HMENU)IDC_STATIC, hInst, NULL); + app->hEditRtBgpSenders = CreateWindowExA(WS_EX_CLIENTEDGE, "EDIT", "", + WS_CHILD | WS_VISIBLE | ES_READONLY | ES_CENTER, + mx + 370, my - 2, 45, 18, hWnd, (HMENU)IDC_EDIT_RT_BGP_SENDERS, hInst, NULL); + + CreateWindowExA(0, "STATIC", "Nodes:", + WS_CHILD | WS_VISIBLE, mx + 425, my, 45, 18, hWnd, (HMENU)IDC_STATIC, hInst, NULL); + app->hEditRtBgpNodes = CreateWindowExA(WS_EX_CLIENTEDGE, "EDIT", "", + WS_CHILD | WS_VISIBLE | ES_READONLY | ES_CENTER, + mx + 475, my - 2, 45, 18, hWnd, (HMENU)IDC_EDIT_RT_BGP_NODES, hInst, NULL); + /* Links list */ y = 725; CreateWindowExA(0, "STATIC", "Links:", @@ -958,6 +970,8 @@ void etcpmon_gui_update_metrics(struct etcpmon_app* app, UpdateEditIfChanged(hMain, IDC_EDIT_RT_COUNT, "%u", metrics->tun.rt_count); UpdateEditIfChanged(hMain, IDC_EDIT_RT_LOCAL, "%u", metrics->tun.rt_local); UpdateEditIfChanged(hMain, IDC_EDIT_RT_LEARNED, "%u", metrics->tun.rt_learned); + UpdateEditIfChanged(hMain, IDC_EDIT_RT_BGP_SENDERS, "%u", metrics->tun.rt_bgp_senders); + UpdateEditIfChanged(hMain, IDC_EDIT_RT_BGP_NODES, "%u", metrics->tun.rt_bgp_nodes); /* Queue Metrics */ UpdateEditIfChanged(hMain, IDC_EDIT_Q_IN_Q_BYTES, "%u", metrics->etcp.input_queue_bytes); @@ -1096,6 +1110,8 @@ void etcpmon_gui_clear_metrics(struct etcpmon_app* app) { SetDlgItemTextA(app->hWndMain, IDC_EDIT_RT_COUNT, ""); SetDlgItemTextA(app->hWndMain, IDC_EDIT_RT_LOCAL, ""); SetDlgItemTextA(app->hWndMain, IDC_EDIT_RT_LEARNED, ""); + SetDlgItemTextA(app->hWndMain, IDC_EDIT_RT_BGP_SENDERS, ""); + SetDlgItemTextA(app->hWndMain, IDC_EDIT_RT_BGP_NODES, ""); SetDlgItemTextA(app->hWndMain, IDC_EDIT_Q_IN_Q_BYTES, ""); SetDlgItemTextA(app->hWndMain, IDC_EDIT_Q_IN_Q_PKTS, ""); diff --git a/tools/etcpmon/etcpmon_gui.h b/tools/etcpmon/etcpmon_gui.h index 4a1d7d8..57079fd 100644 --- a/tools/etcpmon/etcpmon_gui.h +++ b/tools/etcpmon/etcpmon_gui.h @@ -69,6 +69,8 @@ extern "C" { #define IDC_EDIT_RT_COUNT 312 #define IDC_EDIT_RT_LOCAL 313 #define IDC_EDIT_RT_LEARNED 314 +#define IDC_EDIT_RT_BGP_SENDERS 315 +#define IDC_EDIT_RT_BGP_NODES 316 /* Link list control ID */ #define IDC_LIST_LINKS 400 @@ -215,6 +217,8 @@ struct etcpmon_app { HWND hEditRtCount; HWND hEditRtLocal; HWND hEditRtLearned; + HWND hEditRtBgpSenders; + HWND hEditRtBgpNodes; /* Links list */ HWND hListLinks; diff --git a/tools/etcpmon/etcpmon_protocol.h b/tools/etcpmon/etcpmon_protocol.h index c89a1e8..a924ddb 100644 --- a/tools/etcpmon/etcpmon_protocol.h +++ b/tools/etcpmon/etcpmon_protocol.h @@ -222,6 +222,8 @@ struct etcpmon_tun_metrics { uint32_t rt_count; /* Total routes in table */ uint32_t rt_local; /* Local routes */ uint32_t rt_learned; /* Learned routes (BGP) */ + uint32_t rt_bgp_senders; /* BGP senders_list count (ROUTE_BGP) */ + uint32_t rt_bgp_nodes; /* BGP nodes count (ROUTE_BGP) */ }; struct etcpmon_rsp_metrics {