grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] net/net: Delete Routes for Deleted Interfaces


From: Andrew Hamilton
Subject: Re: [PATCH] net/net: Delete Routes for Deleted Interfaces
Date: Fri, 30 Aug 2024 21:49:42 -0500

I see I messed up the description of the email... sorry about that.
Full description:
----------
Correct incorrect handling of routes being maintained when an
associated interface is deleted. Previously the route(s) for an interface
being removed were not deleted. This resulted in displaying corrupted
output to the console in the following sequence:
net_add_addr
if0 emu0 192.168.100.2
net_ls_routes if0:local 192.168.100.0/24 if0
net_del_addr if0
net_ls_routes if0:local 192.168.100.0/24 ???
...
net_ls_routes
if0:local 192.168.100.0/24 ?7?
The fields including the question marks above will contain pseudo-random
data from the heap which may change over time. In some cases this may
have resulted in crashes as well after a route was deleted and attempted
to be used in actual network routing operations.

With this update, routes mapped to a deleted interface will be deleted.

Signed-off-by: Andrew Hamilton <adhamilt@gmail.com>
-------------

On Fri, Aug 30, 2024 at 9:45 PM Andrew Hamilton <adhamilt@gmail.com> wrote:
>
> With this update, routes mapped to a deleted interface will be deleted.
>
> Signed-off-by: Andrew Hamilton <adhamilt@gmail.com>
> ---
>  grub-core/net/net.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
>
> diff --git a/grub-core/net/net.c b/grub-core/net/net.c
> index 8cad4fb6d..51e0dd312 100644
> --- a/grub-core/net/net.c
> +++ b/grub-core/net/net.c
> @@ -718,6 +718,23 @@ grub_cmd_deladdr (struct grub_command *cmd __attribute__ 
> ((unused)),
>      return grub_error (GRUB_ERR_IO,
>                        N_("you can't delete this address"));
>
> +  struct grub_net_route *route;
> +  struct grub_net_route **prev;
> +
> +  /* Remove any existing routes using this interface. */
> +  for (prev = &grub_net_routes, route = *prev; route;
> +       prev = &((*prev)->next), route = *prev)
> +    {
> +      if (grub_strcmp (route->interface->name, inter->name) == 0)
> +        {
> +          *prev = route->next;
> +          grub_free (route->name);
> +          grub_free (route);
> +          if (*prev == NULL)
> +            break;
> +        }
> +    }
> +
>    grub_net_network_level_interface_unregister (inter);
>    grub_free (inter->name);
>    grub_free (inter);
> --
> 2.39.2
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]