From 9212d1e196bdc6bca247e6d05e5c19bbf9225f8c Mon Sep 17 00:00:00 2001 From: liuze Date: Wed, 26 Aug 2020 17:41:29 +0800 Subject: [PATCH] zebra: Solve the problem of high CPU and memory usage when creating thousands of vrf Signed-off-by: liuze --- zebra/zapi_msg.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index 2bcb3502d5..5d14e0e6d6 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -1349,6 +1349,20 @@ static void zread_interface_add(ZAPI_HANDLER_ARGS) struct vrf *vrf; struct interface *ifp; + vrf_id_t vrf_id = zvrf_id(zvrf); + if (vrf_id != VRF_DEFAULT && vrf_id != VRF_UNKNOWN) { + FOR_ALL_INTERFACES (zvrf->vrf, ifp) { + /* Skip pseudo interface. */ + if (!CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_ACTIVE)) + continue; + + zsend_interface_add(client, ifp); + zsend_interface_link_params(client, ifp); + zsend_interface_addresses(client, ifp); + } + return; + } + RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id) { FOR_ALL_INTERFACES (vrf, ifp) { /* Skip pseudo interface. */ -- 2.39.5