[PATCH] Free interfaces in shutdown state
Maria Matejka
maria.matejka at nic.cz
Wed Jul 13 09:47:25 CEST 2022
Hello!
I tried to implement this myself several times, yet this simple approach
doesn't work. The configuration system also creates "pending" interfaces
if something depends on a certain interface name. This patch would
delete these "pending" interfaces, rendering some pointers invalid.
The right way to do this is to introduce some kind of reference counting
to interface objects, as e.g. the cached route attribute objects do.
Something like this is probably going to land in some future version of
BIRD 3, anyway if you decided to implement this for version 2 as well, I
won't complain.
Thank you for your contribution!
Maria
On 7/12/22 7:54 PM, Lorenz Brun wrote:
> When interfaces are created and destroyed by automated systems,
> a potentially unbounded amount of interfaces exist.
> This results in bird consuming ever-increasing amounts of memory and
> CPU time for the list of known interfaces.
>
> This change frees the interface after it is in shutdown state and all
> notifications for it have been processed.
> ---
> nest/iface.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/nest/iface.c b/nest/iface.c
> index 682340c5..b4c65512 100644
> --- a/nest/iface.c
> +++ b/nest/iface.c
> @@ -324,7 +324,7 @@ if_update(struct iface *new)
> if_copy(i, new);
> if (c)
> if_notify_change(c, i);
> -
> +
> i->flags |= IF_UPDATED;
> return i;
> }
> @@ -365,10 +365,10 @@ if_end_partial_update(struct iface *i)
> void
> if_end_update(void)
> {
> - struct iface *i;
> + struct iface *i, *x;
> struct ifa *a, *b;
>
> - WALK_LIST(i, iface_list)
> + WALK_LIST_DELSAFE(i, x, iface_list)
> {
> if (!(i->flags & IF_UPDATED))
> if_change_flags(i, (i->flags & ~IF_ADMIN_UP) | IF_SHUTDOWN);
> @@ -379,6 +379,11 @@ if_end_update(void)
> ifa_delete(a);
> if_end_partial_update(i);
> }
> + if ((i->flags & IF_SHUTDOWN)) {
> + WALK_LIST_DELSAFE(a, b, i->addrs)
> + ifa_delete(a);
> + rem_node(&i->n);
> + }
> }
> }
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2839 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://trubka.network.cz/pipermail/bird-users/attachments/20220713/f1a426c5/attachment.p7s>
More information about the Bird-users
mailing list