diff options
| author | Mark Stapp <mjs.ietf@gmail.com> | 2025-03-03 11:09:47 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-03 11:09:47 -0500 |
| commit | b66145b8ca1ee8c222ceb79afa89bced21273537 (patch) | |
| tree | a435e58b5ec050d6074b86ddc5c9e05eb81ece0d /lib/zclient.c | |
| parent | 21a8f5277b51ec90fff2cfcdee2a60c28e9037f6 (diff) | |
| parent | 8c9b007a0c7efb2e9afc2eac936ba9dd971c6707 (diff) | |
Merge pull request #18030 from fdumontet6WIND/mem_alloc_stream
zebra: reduce memory usage by streams when redistributing routes
Diffstat (limited to 'lib/zclient.c')
| -rw-r--r-- | lib/zclient.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/zclient.c b/lib/zclient.c index 532771cb93..f0476867be 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -1326,6 +1326,24 @@ enum zclient_send_status zclient_nhg_send(struct zclient *zclient, int cmd, return zclient_send_message(zclient); } +/* size needed by a stream for redistributing a route */ +int zapi_redistribute_stream_size(struct zapi_route *api) +{ + size_t msg_size = 0; + size_t nh_size = sizeof(struct zapi_nexthop); + + msg_size = sizeof(struct zapi_route); + /* remove unused nexthop structures */ + msg_size -= (MULTIPATH_NUM - api->nexthop_num) * nh_size; + /* remove unused backup nexthop structures */ + msg_size -= (MULTIPATH_NUM - api->backup_nexthop_num) * nh_size; + /* remove unused opaque values */ + msg_size -= ZAPI_MESSAGE_OPAQUE_LENGTH - api->opaque.length; + + return msg_size; +} + + int zapi_route_encode(uint8_t cmd, struct stream *s, struct zapi_route *api) { struct zapi_nexthop *api_nh; |
