diff options
author | liuze <liuze@asterfusion.com> | 2020-08-26 11:41:29 +0200 |
---|---|---|
committer | liuze <liuze@asterfusion.com> | 2020-08-26 11:41:29 +0200 |
commit | 9212d1e196bdc6bca247e6d05e5c19bbf9225f8c (patch) | |
tree | 41355d8c5892a425ad6cd5d0f87668e2ca5ab811 /zebra/zapi_msg.c | |
parent | Merge pull request #6967 from mjstapp/fix_sa_rib_dest (diff) | |
download | frr-9212d1e196bdc6bca247e6d05e5c19bbf9225f8c.tar.xz frr-9212d1e196bdc6bca247e6d05e5c19bbf9225f8c.zip |
zebra: Solve the problem of high CPU and memory usage when creating thousands of vrf
Signed-off-by: liuze <liuze@asterfusion.com>
Diffstat (limited to 'zebra/zapi_msg.c')
-rw-r--r-- | zebra/zapi_msg.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index 2bcb3502d..5d14e0e6d 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. */ |