nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

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

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