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

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