nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

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

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