diff options
author | Donald Sharp <sharpd@nvidia.com> | 2023-04-19 14:13:18 +0200 |
---|---|---|
committer | Donald Sharp <sharpd@nvidia.com> | 2023-06-26 20:59:21 +0200 |
commit | 161972c9fe108ffe3de851a537d9b34efeb09e31 (patch) | |
tree | 6de17e2202d18969ee4aae4c85ecaccdc89c4f89 /ospf6d | |
parent | Merge pull request #13804 from LabNConsulting/aceelindem/ospf6d-config-callbacks (diff) | |
download | frr-161972c9fe108ffe3de851a537d9b34efeb09e31.tar.xz frr-161972c9fe108ffe3de851a537d9b34efeb09e31.zip |
*: Rearrange vrf_bitmap_X api to reduce memory footprint
When running all daemons with config for most of them, FRR has
sharpd@janelle:~/frr$ vtysh -c "show debug hashtable" | grep "VRF BIT HASH" | wc -l
3570
3570 hashes for bitmaps associated with the vrf. This is a very
large number of hashes. Let's do two things:
a) Reduce the created size of the actually created hashes to 2
instead of 32.
b) Delay generation of the hash *until* a set operation happens.
As that no hash directly implies a unset value if/when checked.
This reduces the number of hashes to 61 in my setup for normal
operation.
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'ospf6d')
-rw-r--r-- | ospf6d/ospf6_top.c | 8 | ||||
-rw-r--r-- | ospf6d/ospf6_zebra.c | 16 | ||||
-rw-r--r-- | ospf6d/ospf6_zebra.h | 2 |
3 files changed, 13 insertions, 13 deletions
diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c index 01c962194..4c4029879 100644 --- a/ospf6d/ospf6_top.c +++ b/ospf6d/ospf6_top.c @@ -140,20 +140,20 @@ static void ospf6_set_redist_vrf_bitmaps(struct ospf6 *ospf6, bool set) "%s: setting redist vrf %d bitmap for type %d", __func__, ospf6->vrf_id, type); if (set) - vrf_bitmap_set(zclient->redist[AFI_IP6][type], + vrf_bitmap_set(&zclient->redist[AFI_IP6][type], ospf6->vrf_id); else - vrf_bitmap_unset(zclient->redist[AFI_IP6][type], + vrf_bitmap_unset(&zclient->redist[AFI_IP6][type], ospf6->vrf_id); } red_list = ospf6->redist[DEFAULT_ROUTE]; if (red_list) { if (set) - vrf_bitmap_set(zclient->default_information[AFI_IP6], + vrf_bitmap_set(&zclient->default_information[AFI_IP6], ospf6->vrf_id); else - vrf_bitmap_unset(zclient->default_information[AFI_IP6], + vrf_bitmap_unset(&zclient->default_information[AFI_IP6], ospf6->vrf_id); } } diff --git a/ospf6d/ospf6_zebra.c b/ospf6d/ospf6_zebra.c index 0f631c4d0..8bd0d8f0b 100644 --- a/ospf6d/ospf6_zebra.c +++ b/ospf6d/ospf6_zebra.c @@ -97,9 +97,9 @@ static int ospf6_router_id_update_zebra(ZAPI_CALLBACK_ARGS) /* redistribute function */ void ospf6_zebra_redistribute(int type, vrf_id_t vrf_id) { - if (vrf_bitmap_check(zclient->redist[AFI_IP6][type], vrf_id)) + if (vrf_bitmap_check(&zclient->redist[AFI_IP6][type], vrf_id)) return; - vrf_bitmap_set(zclient->redist[AFI_IP6][type], vrf_id); + vrf_bitmap_set(&zclient->redist[AFI_IP6][type], vrf_id); if (zclient->sock > 0) zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, zclient, @@ -108,9 +108,9 @@ void ospf6_zebra_redistribute(int type, vrf_id_t vrf_id) void ospf6_zebra_no_redistribute(int type, vrf_id_t vrf_id) { - if (!vrf_bitmap_check(zclient->redist[AFI_IP6][type], vrf_id)) + if (!vrf_bitmap_check(&zclient->redist[AFI_IP6][type], vrf_id)) return; - vrf_bitmap_unset(zclient->redist[AFI_IP6][type], vrf_id); + vrf_bitmap_unset(&zclient->redist[AFI_IP6][type], vrf_id); if (zclient->sock > 0) zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE, zclient, AFI_IP6, type, 0, vrf_id); @@ -333,10 +333,10 @@ DEFUN(show_zebra, json_object_int_add(json_zebra, "fail", zclient->fail); json_object_int_add( json_zebra, "redistributeDefault", - vrf_bitmap_check(zclient->default_information[AFI_IP6], + vrf_bitmap_check(&zclient->default_information[AFI_IP6], VRF_DEFAULT)); for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { - if (vrf_bitmap_check(zclient->redist[AFI_IP6][i], + if (vrf_bitmap_check(&zclient->redist[AFI_IP6][i], VRF_DEFAULT)) json_object_array_add( json_array, @@ -351,11 +351,11 @@ DEFUN(show_zebra, vty_out(vty, "Zebra Information\n"); vty_out(vty, " fail: %d\n", zclient->fail); vty_out(vty, " redistribute default: %d\n", - vrf_bitmap_check(zclient->default_information[AFI_IP6], + vrf_bitmap_check(&zclient->default_information[AFI_IP6], VRF_DEFAULT)); vty_out(vty, " redistribute:"); for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { - if (vrf_bitmap_check(zclient->redist[AFI_IP6][i], + if (vrf_bitmap_check(&zclient->redist[AFI_IP6][i], VRF_DEFAULT)) vty_out(vty, " %s", zebra_route_string(i)); } diff --git a/ospf6d/ospf6_zebra.h b/ospf6d/ospf6_zebra.h index 9f41dfca9..7669b5e2c 100644 --- a/ospf6d/ospf6_zebra.h +++ b/ospf6d/ospf6_zebra.h @@ -38,7 +38,7 @@ extern void ospf6_zebra_route_update_remove(struct ospf6_route *request, extern void ospf6_zebra_redistribute(int, vrf_id_t vrf_id); extern void ospf6_zebra_no_redistribute(int, vrf_id_t vrf_id); #define ospf6_zebra_is_redistribute(type, vrf_id) \ - vrf_bitmap_check(zclient->redist[AFI_IP6][type], vrf_id) + vrf_bitmap_check(&zclient->redist[AFI_IP6][type], vrf_id) extern void ospf6_zebra_init(struct event_loop *tm); extern void ospf6_zebra_import_default_route(struct ospf6 *ospf6, bool unreg); extern void ospf6_zebra_add_discard(struct ospf6_route *request, |