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

Signed-off-by: Andrew Hamilton <adham...@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


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to