]> git.puffer.fish Git - mirror/frr.git/commit
staticd: fix nht memory leak
authorIgor Ryzhov <iryzhov@nfware.com>
Sat, 3 Feb 2024 19:41:37 +0000 (21:41 +0200)
committerIgor Ryzhov <iryzhov@nfware.com>
Sun, 4 Feb 2024 20:28:10 +0000 (22:28 +0200)
commit3c05d53bf8defc36acdfe6e78064e068d60c649f
treec074aa6eaf19c7132618b6ea00a89cb14df70575
parent6090b2b939cd01f1c9d44c14ebfa257795f06a1b
staticd: fix nht memory leak

When a static route with a gateway nexthop is created, the nexthop is
sent to zebra for NHT, and added to a local hash. When the nexthop's VRF
is deleted from kernel, nexthop still stays in the hash. This is a
memory leak, because it is never deleted from there. Even if the VRF is
recreated in kernel, it is assigned with a new `vrf_id` so the old hash
entry is not reused, and a new one is created. To fix the issue, remove
all nexthops from the hash when the corresponding VRF is deleted, do not
add nexthops to the hash if their corresponding VRF doesn't exist in
kernel and don't add the same nexthop to the hash multiple times.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
staticd/static_routes.c