dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

Blame SOURCES/0305-efi-net-Print-a-debug-message-if-parsing-the-address.patch

5d780f
From b1c58d0b9fb6641f2e9fc34f4075e1a929bdaf5c Mon Sep 17 00:00:00 2001
5d780f
From: Javier Martinez Canillas <javierm@redhat.com>
5d780f
Date: Tue, 10 Mar 2020 11:23:49 +0100
5d780f
Subject: [PATCH] efi/net: Print a debug message if parsing the address fails
5d780f
5d780f
Currently if parsing the address fails an error message is printed. But in
5d780f
most cases this isn't a fatal error since the grub_efi_net_parse_address()
5d780f
function is only used to match an address with a network interface to use.
5d780f
5d780f
And if this fails, the default interface is used which is good enough for
5d780f
most cases. So instead of printing an error that would pollute the console
5d780f
just print a debug message if the address is not parsed correctly.
5d780f
5d780f
A user can enable debug messages for the efinet driver to have information
5d780f
about the failure and the fact that the default interface is being used.
5d780f
5d780f
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
5d780f
---
5d780f
 grub-core/net/efi/net.c | 18 +++++++++++-------
5d780f
 1 file changed, 11 insertions(+), 7 deletions(-)
5d780f
5d780f
diff --git a/grub-core/net/efi/net.c b/grub-core/net/efi/net.c
5d780f
index 71a59fe723d..78e5442fc52 100644
5d780f
--- a/grub-core/net/efi/net.c
5d780f
+++ b/grub-core/net/efi/net.c
5d780f
@@ -778,9 +778,9 @@ grub_efi_net_parse_address (const char *address,
5d780f
 	}
5d780f
     }
5d780f
 
5d780f
-  return grub_error (GRUB_ERR_NET_BAD_ADDRESS,
5d780f
-		   N_("unrecognised network address `%s'"),
5d780f
-		   address);
5d780f
+  grub_dprintf ("efinet", "unrecognised network address '%s'\n", address);
5d780f
+
5d780f
+  return GRUB_ERR_NET_BAD_ADDRESS;
5d780f
 }
5d780f
 
5d780f
 static grub_efi_net_interface_t *
5d780f
@@ -795,10 +795,7 @@ match_route (const char *server)
5d780f
   err = grub_efi_net_parse_address (server, &ip4, &ip6, &is_ip6, 0);
5d780f
 
5d780f
   if (err)
5d780f
-    {
5d780f
-      grub_print_error ();
5d780f
       return NULL;
5d780f
-    }
5d780f
 
5d780f
   if (is_ip6)
5d780f
     {
5d780f
@@ -1233,8 +1230,15 @@ grub_net_open_real (const char *name __attribute__ ((unused)))
5d780f
   /*FIXME: Use DNS translate name to address */
5d780f
   net_interface = match_route (server);
5d780f
 
5d780f
+  if (!net_interface && net_default_interface)
5d780f
+    {
5d780f
+      net_interface = net_default_interface;
5d780f
+      grub_dprintf ("efinet", "interface lookup failed, using default '%s'\n",
5d780f
+                    net_interface->name);
5d780f
+    }
5d780f
+
5d780f
   /*XXX: should we check device with default gateway ? */
5d780f
-  if (!net_interface && !(net_interface = net_default_interface))
5d780f
+  if (!net_interface)
5d780f
     {
5d780f
       grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("disk `%s' no route found"),
5d780f
 		  name);
5d780f
-- 
5d780f
2.24.1
5d780f