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

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