[packages/grub2] - import patches from fedora, descriptions inside

baggins baggins at pld-linux.org
Mon Apr 15 00:37:34 CEST 2013


commit 50fb40250d7a1e5080971e05b7d638b535160865
Author: Jan Rękorajski <baggins at pld-linux.org>
Date:   Mon Apr 15 00:25:43 2013 +0200

    - import patches from fedora, descriptions inside

 Issue-separate-DNS-queries-for-ipv4-and-ipv6.patch | 230 +++++++++++++++++++++
 add-GRUB-DISABLE-SUBMENU-option.patch              | 114 ++++++++++
 add-X-option-to-printf-functions.patch             |  58 ++++++
 add-vlan-tag-support.patch                         | 185 +++++++++++++++++
 dhcp-client-id-and-uuid-options-added.patch        | 121 +++++++++++
 fix-http-crash.patch                               |  28 +++
 grub2.spec                                         |  16 ++
 just-say-linux.patch                               |  45 ++++
 search-for-specific-config-file-for-netboot.patch  | 205 ++++++++++++++++++
 9 files changed, 1002 insertions(+)
---
diff --git a/grub2.spec b/grub2.spec
index 419faa4..e533f9f 100644
--- a/grub2.spec
+++ b/grub2.spec
@@ -73,6 +73,14 @@ Patch8:		posix.patch
 Patch9:		%{name}-gets.patch
 Patch10:	%{name}-fonts_path.patch
 Patch11:	%{name}-tftp_fix.patch
+Patch12:	add-vlan-tag-support.patch
+Patch13:	just-say-linux.patch
+Patch14:	add-GRUB-DISABLE-SUBMENU-option.patch
+Patch15:	add-X-option-to-printf-functions.patch
+Patch16:	dhcp-client-id-and-uuid-options-added.patch
+Patch17:	fix-http-crash.patch
+Patch18:	Issue-separate-DNS-queries-for-ipv4-and-ipv6.patch
+Patch19:	search-for-specific-config-file-for-netboot.patch
 URL:		http://www.gnu.org/software/grub/
 BuildRequires:	autoconf >= 2.53
 BuildRequires:	automake >= 1:1.11.1-1
@@ -288,6 +296,14 @@ Motyw starfield dla GRUB-a.
 %patch9 -p1
 %patch10 -p1
 %patch11 -p1
+%patch12 -p1
+%patch13 -p1
+%patch14 -p1
+%patch15 -p1
+%patch16 -p1
+%patch17 -p1
+%patch18 -p1
+%patch19 -p1
 
 %if "%{cc_version}" < "3.4"
 grep -rl -- -Wno-missing-field-initializers . | xargs %{__sed} -i -e 's,-Wno-missing-field-initializers,,'
diff --git a/Issue-separate-DNS-queries-for-ipv4-and-ipv6.patch b/Issue-separate-DNS-queries-for-ipv4-and-ipv6.patch
new file mode 100644
index 0000000..953f2bd
--- /dev/null
+++ b/Issue-separate-DNS-queries-for-ipv4-and-ipv6.patch
@@ -0,0 +1,230 @@
+From 3e00d82827f80461f9fe6da37acd84235c08e5a5 Mon Sep 17 00:00:00 2001
+From: Gustavo Luiz Duarte <gustavold at linux.vnet.ibm.com>
+Date: Fri, 28 Sep 2012 19:42:07 -0400
+Subject: [PATCH] Issue separate DNS queries for ipv4 and ipv6
+
+Adding multiple questions on a single DNS query is not supportted by
+most DNS servers. This patch issues two separate DNS queries
+sequentially for ipv4 and then for ipv6.
+
+There are 4 possible config options:
+ DNS_OPTION_IPV4: issue only one ipv4 query
+ DNS_OPTION_IPV6: issue only one ipv6 query
+ DNS_OPTION_PREFER_IPV4: issue the ipv4 query first and fallback to ipv6
+ DNS_OPTION_PREFER_IPV6: issue the ipv6 query first and fallback to ipv4
+However, there is no code yet to set such config option. The default is
+DNS_OPTION_PREFER_IPV4.
+
+Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=860829
+---
+ grub-core/net/dns.c | 99 ++++++++++++++++++++++++++++++++++++-----------------
+ include/grub/net.h  |  9 +++++
+ 2 files changed, 76 insertions(+), 32 deletions(-)
+
+diff --git a/grub-core/net/dns.c b/grub-core/net/dns.c
+index 3381ea7..725725c 100644
+--- a/grub-core/net/dns.c
++++ b/grub-core/net/dns.c
+@@ -34,6 +34,14 @@ struct dns_cache_element
+ #define DNS_CACHE_SIZE 1021
+ #define DNS_HASH_BASE 423
+ 
++typedef enum grub_dns_qtype_id
++  {
++    GRUB_DNS_QTYPE_A = 1,
++    GRUB_DNS_QTYPE_AAAA = 28
++  } grub_dns_qtype_id_t;
++
++static grub_dns_option_t dns_type_option = DNS_OPTION_PREFER_IPV4;
++
+ static struct dns_cache_element dns_cache[DNS_CACHE_SIZE];
+ static struct grub_net_network_level_address *dns_servers;
+ static grub_size_t dns_nservers, dns_servers_alloc;
+@@ -410,13 +418,13 @@ recv_hook (grub_net_udp_socket_t sock __attribute__ ((unused)),
+   return GRUB_ERR_NONE;
+ }
+ 
+-grub_err_t
+-grub_net_dns_lookup (const char *name,
++static grub_err_t
++grub_net_dns_lookup_qtype (const char *name,
+ 		     const struct grub_net_network_level_address *servers,
+ 		     grub_size_t n_servers,
+ 		     grub_size_t *naddresses,
+ 		     struct grub_net_network_level_address **addresses,
+-		     int cache)
++		     int cache, grub_dns_qtype_id_t qtype)
+ {
+   grub_size_t send_servers = 0;
+   grub_size_t i, j;
+@@ -471,8 +479,7 @@ grub_net_dns_lookup (const char *name,
+ 			   + GRUB_NET_MAX_LINK_HEADER_SIZE
+ 			   + GRUB_NET_UDP_HEADER_SIZE
+ 			   + sizeof (struct dns_header)
+-			   + grub_strlen (name) + 2 + 4
+-			   + 2 + 4);
++			   + grub_strlen (name) + 2 + 4);
+   if (!nb)
+     {
+       grub_free (data.name);
+@@ -482,7 +489,7 @@ grub_net_dns_lookup (const char *name,
+ 			+ GRUB_NET_MAX_LINK_HEADER_SIZE
+ 			+ GRUB_NET_UDP_HEADER_SIZE);
+   grub_netbuff_put (nb, sizeof (struct dns_header)
+-		    + grub_strlen (name) + 2 + 4 + 2 + 4);
++		    + grub_strlen (name) + 2 + 4);
+   head = (struct dns_header *) nb->data;
+   optr = (grub_uint8_t *) (head + 1);
+   for (iptr = name; *iptr; )
+@@ -509,18 +516,7 @@ grub_net_dns_lookup (const char *name,
+ 
+   /* Type: A.  */
+   *optr++ = 0;
+-  *optr++ = 1;
+-
+-  /* Class.  */
+-  *optr++ = 0;
+-  *optr++ = 1;
+-
+-  /* Compressed name.  */
+-  *optr++ = 0xc0;
+-  *optr++ = 0x0c;
+-  /* Type: AAAA.  */
+-  *optr++ = 0;
+-  *optr++ = 28;
++  *optr++ = qtype;
+ 
+   /* Class.  */
+   *optr++ = 0;
+@@ -529,7 +525,7 @@ grub_net_dns_lookup (const char *name,
+   head->id = data.id;
+   head->flags = FLAGS_RD;
+   head->ra_z_r_code = 0;
+-  head->qdcount = grub_cpu_to_be16_compile_time (2);
++  head->qdcount = grub_cpu_to_be16_compile_time (1);
+   head->ancount = grub_cpu_to_be16_compile_time (0);
+   head->nscount = grub_cpu_to_be16_compile_time (0);
+   head->arcount = grub_cpu_to_be16_compile_time (0);
+@@ -587,16 +583,47 @@ grub_net_dns_lookup (const char *name,
+   if (*data.naddresses)
+     return GRUB_ERR_NONE;
+   if (data.dns_err)
+-    return grub_error (GRUB_ERR_NET_NO_DOMAIN,
+-		       N_("no DNS record found"));
+-    
++    {
++      grub_dprintf ("dns", "%s. QTYPE: %u QNAME: %s\n",
++                    N_("no DNS record found"), qtype, name);
++      return GRUB_ERR_NET_NO_DOMAIN;
++    }
+   if (err)
+     {
+       grub_errno = err;
+       return err;
+     }
+-  return grub_error (GRUB_ERR_TIMEOUT,
+-		     N_("no DNS reply received"));
++  grub_dprintf ("dns", "%s. QTYPE: %u QNAME: %s\n",
++                N_("no DNS reply received"), qtype, name);
++  return GRUB_ERR_TIMEOUT;
++}
++
++grub_err_t
++grub_net_dns_lookup (const char *name,
++		     const struct grub_net_network_level_address *servers,
++		     grub_size_t n_servers,
++		     grub_size_t *naddresses,
++		     struct grub_net_network_level_address **addresses,
++		     int cache)
++{
++  if (dns_type_option == DNS_OPTION_IPV6 || dns_type_option == DNS_OPTION_PREFER_IPV6)
++      grub_net_dns_lookup_qtype (name, servers, n_servers, naddresses,
++                                 addresses, cache, GRUB_DNS_QTYPE_AAAA);
++  else
++      grub_net_dns_lookup_qtype (name, servers, n_servers, naddresses,
++                                 addresses, cache, GRUB_DNS_QTYPE_A);
++  if (!*naddresses)
++    {
++      if (dns_type_option == DNS_OPTION_PREFER_IPV4)
++          grub_net_dns_lookup_qtype (name, servers, n_servers, naddresses,
++                                     addresses, cache, GRUB_DNS_QTYPE_AAAA);
++      else if (dns_type_option == DNS_OPTION_PREFER_IPV6)
++          grub_net_dns_lookup_qtype (name, servers, n_servers, naddresses,
++                                     addresses, cache, GRUB_DNS_QTYPE_A);
++    }
++  if (!*naddresses)
++      return GRUB_ERR_NET_NO_DOMAIN;
++  return GRUB_ERR_NONE;
+ }
+ 
+ static grub_err_t
+@@ -604,22 +631,28 @@ grub_cmd_nslookup (struct grub_command *cmd __attribute__ ((unused)),
+ 		   int argc, char **args)
+ {
+   grub_err_t err;
+-  grub_size_t naddresses, i;
++  struct grub_net_network_level_address cmd_server;
++  struct grub_net_network_level_address *servers;
++  grub_size_t nservers, i, naddresses = 0;
+   struct grub_net_network_level_address *addresses = 0;
+   if (argc != 2 && argc != 1)
+     return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("two arguments expected"));
+   if (argc == 2)
+     {
+-      struct grub_net_network_level_address server;
+-      err = grub_net_resolve_address (args[1], &server);
++      err = grub_net_resolve_address (args[1], &cmd_server);
+       if (err)
+ 	return err;
+-      err = grub_net_dns_lookup (args[0], &server, 1, &naddresses,
+-				 &addresses, 0);
++      servers = &cmd_server;
++      nservers = 1;
+     }
+   else
+-    err = grub_net_dns_lookup (args[0], dns_servers, dns_nservers, &naddresses,
+-			       &addresses, 0);
++    {
++      servers = dns_servers;
++      nservers = dns_nservers;
++    }
++
++  grub_net_dns_lookup (args[0], servers, nservers, &naddresses,
++                       &addresses, 0);
+ 
+   for (i = 0; i < naddresses; i++)
+     {
+@@ -628,7 +661,9 @@ grub_cmd_nslookup (struct grub_command *cmd __attribute__ ((unused)),
+       grub_printf ("%s\n", buf);
+     }
+   grub_free (addresses);
+-  return GRUB_ERR_NONE;
++  if (naddresses)
++    return GRUB_ERR_NONE;
++  return grub_error (GRUB_ERR_NET_NO_DOMAIN, N_("no DNS record found"));
+ }
+ 
+ static grub_err_t
+diff --git a/include/grub/net.h b/include/grub/net.h
+index 3877451..a7e5b2c 100644
+--- a/include/grub/net.h
++++ b/include/grub/net.h
+@@ -505,6 +505,15 @@ grub_err_t
+ grub_net_link_layer_resolve (struct grub_net_network_level_interface *inf,
+ 			     const grub_net_network_level_address_t *proto_addr,
+ 			     grub_net_link_level_address_t *hw_addr);
++
++typedef enum
++  {
++    DNS_OPTION_IPV4,
++    DNS_OPTION_IPV6,
++    DNS_OPTION_PREFER_IPV4,
++    DNS_OPTION_PREFER_IPV6
++  } grub_dns_option_t;
++
+ grub_err_t
+ grub_net_dns_lookup (const char *name,
+ 		     const struct grub_net_network_level_address *servers,
+-- 
+1.7.11.4
+
diff --git a/add-GRUB-DISABLE-SUBMENU-option.patch b/add-GRUB-DISABLE-SUBMENU-option.patch
new file mode 100644
index 0000000..c4ffb92
--- /dev/null
+++ b/add-GRUB-DISABLE-SUBMENU-option.patch
@@ -0,0 +1,114 @@
+From 81e46875469ae8b2a803e6457784801a0a7a7963 Mon Sep 17 00:00:00 2001
+From: Prarit Bhargava <prarit at redhat.com>
+Date: Thu, 7 Feb 2013 11:53:41 -0500
+Subject: [PATCH] add GRUB_DISABLE_SUBMENU option
+
+This patch adds the ability to disable the grub2 submenus from
+/etc/default/grub
+
+To disable the submenus
+
+echo 'GRUB_DISABLE_SUBMENU="true"' >> /etc/default/grub
+
+
+---
+ util/grub-mkconfig.in   |  3 ++-
+ util/grub.d/10_linux.in | 24 ++++++++++++++----------
+ 2 files changed, 16 insertions(+), 11 deletions(-)
+
+diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
+index 516be86..354eb43 100644
+--- a/util/grub-mkconfig.in
++++ b/util/grub-mkconfig.in
+@@ -216,7 +216,8 @@ export GRUB_DEFAULT \
+   GRUB_INIT_TUNE \
+   GRUB_SAVEDEFAULT \
+   GRUB_ENABLE_CRYPTODISK \
+-  GRUB_BADRAM
++  GRUB_BADRAM \
++  GRUB_DISABLE_SUBMENU
+ 
+ if test "x${grub_cfg}" != "x"; then
+   rm -f "${grub_cfg}.new"
+diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
+index e2b8ab3..9427a39 100644
+--- a/util/grub.d/10_linux.in
++++ b/util/grub.d/10_linux.in
+@@ -240,17 +240,19 @@ while [ "x$list" != "x" ] ; do
+     linux_root_device_thisversion=${GRUB_DEVICE}
+   fi
+ 
+-  if [ "x$is_first_entry" = xtrue ]; then
+-    linux_entry "${OS}" "${version}" simple \
+-    "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
++  if [ "x${GRUB_DISABLE_SUBMENU}" = x ]; then
++    if [ "x$is_first_entry" = xtrue ]; then
++      linux_entry "${OS}" "${version}" simple \
++      "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
+ 
+-    submenu_indentation="\t"
++      submenu_indentation="\t"
+     
+-    if [ -z "$boot_device_id" ]; then
+-	boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
++      if [ -z "$boot_device_id" ]; then
++	  boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
++      fi
++      # TRANSLATORS: %s is replaced with an OS name
++      echo "submenu '$(gettext_printf "Advanced options for %s" "${OS}" | grub_quote)' \$menuentry_id_option 'gnulinux-advanced-$boot_device_id' {"
+     fi
+-    # TRANSLATORS: %s is replaced with an OS name
+-    echo "submenu '$(gettext_printf "Advanced options for %s" "${OS}" | grub_quote)' \$menuentry_id_option 'gnulinux-advanced-$boot_device_id' {"
+   fi
+ 
+   linux_entry "${OS}" "${version}" advanced \
+@@ -266,8 +268,10 @@ done
+ 
+ # If at least one kernel was found, then we need to
+ # add a closing '}' for the submenu command.
+-if [ x"$is_first_entry" != xtrue ]; then
+-  echo '}'
++if [ "x${GRUB_DISABLE_SUBMENU}" = x ]; then
++  if [ x"$is_first_entry" != xtrue ]; then
++    echo '}'
++  fi
+ fi
+ 
+ echo "$title_correction_code"
+--- grub-2.00/util/grub.d/20_linux_xen.in~	2013-04-15 00:03:09.162253769 +0200
++++ grub-2.00/util/grub.d/20_linux_xen.in	2013-04-15 00:18:49.254774567 +0200
+@@ -232,7 +232,8 @@
+ 	    linux_root_device_thisversion=${GRUB_DEVICE}
+ 	fi
+ 
+-	if [ "x$is_first_entry" = xtrue ]; then
++        if [ "x${GRUB_DISABLE_SUBMENU}" = x ]; then
++	  if [ "x$is_first_entry" = xtrue ]; then
+ 	    linux_entry "${OS}" "${version}" "${xen_version}" simple \
+ 		"${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT}"
+ 
+@@ -243,9 +244,10 @@
+ 	    fi
+             # TRANSLATORS: %s is replaced with an OS name
+ 	    echo "submenu '$(gettext_printf "Advanced options for %s (with Xen hypervisor)" "${OS}" | grub_quote)' \$menuentry_id_option 'gnulinux-advanced-$boot_device_id' {"
+-	echo "	submenu '$(gettext_printf "Xen hypervisor, version %s" "${xen_version}" | grub_quote)' \$menuentry_id_option 'xen-hypervisor-$xen_version-$boot_device_id' {"
++	    echo "	submenu '$(gettext_printf "Xen hypervisor, version %s" "${xen_version}" | grub_quote)' \$menuentry_id_option 'xen-hypervisor-$xen_version-$boot_device_id' {"
++	  fi
++	  is_first_entry=false
+ 	fi
+-	is_first_entry=false
+ 
+ 	linux_entry "${OS}" "${version}" "${xen_version}" advanced \
+ 	    "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT}"
+@@ -256,8 +258,10 @@
+ 
+ 	list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
+     done
+-    if [ x"$is_first_entry" != xtrue ]; then
++    if [ "x${GRUB_DISABLE_SUBMENU}" = x ]; then
++      if [ x"$is_first_entry" != xtrue ]; then
+ 	echo '	}'
++      fi
+     fi
+     xen_list=`echo $xen_list | tr ' ' '\n' | grep -vx $current_xen | tr '\n' ' '`
+ done
diff --git a/add-X-option-to-printf-functions.patch b/add-X-option-to-printf-functions.patch
new file mode 100644
index 0000000..63d7b79
--- /dev/null
+++ b/add-X-option-to-printf-functions.patch
@@ -0,0 +1,58 @@
+From 80f81f233bf74aac740d7a299d075ea46c9c7bd4 Mon Sep 17 00:00:00 2001
+From: Paulo Flabiano Smorigo <pfsmorigo at br.ibm.com>
+Date: Tue, 27 Nov 2012 16:58:39 -0200
+Subject: [PATCH 1/3] Add %X option to printf functions.
+
+---
+ grub-core/kern/misc.c |    7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c
+index 95d4624..8ac087a 100644
+--- a/grub-core/kern/misc.c
++++ b/grub-core/kern/misc.c
+@@ -596,7 +596,7 @@ grub_divmod64 (grub_uint64_t n, grub_uint64_t d, grub_uint64_t *r)
+ static char *
+ grub_lltoa (char *str, int c, unsigned long long n)
+ {
+-  unsigned base = (c == 'x') ? 16 : 10;
++  unsigned base = ((c == 'x') || (c == 'X')) ? 16 : 10;
+   char *p;
+ 
+   if ((long long) n < 0 && c == 'd')
+@@ -611,7 +611,7 @@ grub_lltoa (char *str, int c, unsigned long long n)
+     do
+       {
+ 	unsigned d = (unsigned) (n & 0xf);
+-	*p++ = (d > 9) ? d + 'a' - 10 : d + '0';
++	*p++ = (d > 9) ? d + ((c == 'x') ? 'a' : 'A') - 10 : d + '0';
+       }
+     while (n >>= 4);
+   else
+@@ -702,6 +702,7 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0, va_list a
+ 	{
+ 	case 'p':
+ 	case 'x':
++	case 'X':
+ 	case 'u':
+ 	case 'd':
+ 	case 'c':
+@@ -777,6 +778,7 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0, va_list a
+       switch (c)
+ 	{
+ 	case 'x':
++	case 'X':
+ 	case 'u':
+ 	case 'd':
+ 	  if (longlongfmt)
+@@ -918,6 +920,7 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0, va_list a
+ 	  longlongfmt |= (sizeof (void *) == sizeof (long long));
+ 	  /* Fall through. */
+ 	case 'x':
++	case 'X':
+ 	case 'u':
+ 	  unsig = 1;
+ 	  /* Fall through. */
+-- 
+1.7.10.4
+
diff --git a/add-vlan-tag-support.patch b/add-vlan-tag-support.patch
new file mode 100644
index 0000000..be01c58
--- /dev/null
+++ b/add-vlan-tag-support.patch
@@ -0,0 +1,185 @@
+From 5573f16fd05c1f8f310f2ead176b52ed6d4a08ec Mon Sep 17 00:00:00 2001
+From: Paulo Flabiano Smorigo <pfsmorigo at br.ibm.com>
+Date: Tue, 30 Oct 2012 15:19:39 -0200
+Subject: [PATCH] Add vlan-tag support
+
+This patch adds support for virtual LAN (VLAN) tagging. VLAN tagging allows
+multiple VLANs in a bridged network to share the same physical network link but
+maintain isolation:
+
+http://en.wikipedia.org/wiki/IEEE_802.1Q
+
+This patch should fix this bugzilla:
+https://bugzilla.redhat.com/show_bug.cgi?id=871563
+---
+ grub-core/kern/ieee1275/init.c   |    1 +
+ grub-core/kern/ieee1275/openfw.c |   30 +++++++++++++++++++++++++++
+ grub-core/net/ethernet.c         |   42 +++++++++++++++++++++++++++++++++++---
+ include/grub/ieee1275/ieee1275.h |    1 +
+ include/grub/net.h               |    2 ++
+ 5 files changed, 73 insertions(+), 3 deletions(-)
+
+diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c
+index 5c45947..209cf8a 100644
+--- a/grub-core/kern/ieee1275/init.c
++++ b/grub-core/kern/ieee1275/init.c
+@@ -102,6 +102,7 @@ grub_machine_get_bootlocation (char **device, char **path)
+       char *dev, *canon;
+       char *ptr;
+       dev = grub_ieee1275_get_aliasdevname (bootpath);
++      grub_ieee1275_parse_net_options (bootpath);
+       canon = grub_ieee1275_canonicalise_devname (dev);
+       ptr = canon + grub_strlen (canon) - 1;
+       while (ptr > canon && (*ptr == ',' || *ptr == ':'))
+diff --git a/grub-core/kern/ieee1275/openfw.c b/grub-core/kern/ieee1275/openfw.c
+index c2b1bdf..9fdfafa 100644
+--- a/grub-core/kern/ieee1275/openfw.c
++++ b/grub-core/kern/ieee1275/openfw.c
+@@ -23,6 +23,7 @@
+ #include <grub/mm.h>
+ #include <grub/ieee1275/ieee1275.h>
+ #include <grub/net.h>
++#include <grub/env.h>
+ 
+ enum grub_ieee1275_parse_type
+ {
+@@ -413,6 +414,35 @@ fail:
+   return ret;
+ }
+ 
++int
++grub_ieee1275_parse_net_options (const char *path)
++{
++  char *comma;
++  char *args;
++  char *option = 0;
++
++  args = grub_ieee1275_get_devargs (path);
++  if (!args)
++    /* There is no option.  */
++    return -1;
++
++  do
++    {
++      comma = grub_strchr (args, ',');
++      if (! comma)
++        option = grub_strdup (args);
++      else
++        option = grub_strndup (args, (grub_size_t)(comma - args));
++      args = comma + 1;
++
++      if (! grub_strncmp(option, "vtag", 4))
++          grub_env_set ("vlan-tag", option + grub_strlen("vtag="));
++
++    } while (comma);
++
++  return 0;
++}
++
+ char *
+ grub_ieee1275_get_device_type (const char *path)
+ {
+diff --git a/grub-core/net/ethernet.c b/grub-core/net/ethernet.c
+index b38e2c8..5e45d46 100644
+--- a/grub-core/net/ethernet.c
++++ b/grub-core/net/ethernet.c
+@@ -23,6 +23,7 @@
+ #include <grub/net/arp.h>
+ #include <grub/net/netbuff.h>
+ #include <grub/net.h>
++#include <grub/env.h>
+ #include <grub/time.h>
+ #include <grub/net/arp.h>
+ 
+@@ -56,10 +57,19 @@ send_ethernet_packet (struct grub_net_network_level_interface *inf,
+ {
+   struct etherhdr *eth;
+   grub_err_t err;
++  grub_uint32_t vlantag = 0;
++  grub_uint8_t etherhdr_size;
+ 
+-  COMPILE_TIME_ASSERT (sizeof (*eth) < GRUB_NET_MAX_LINK_HEADER_SIZE);
++  etherhdr_size = sizeof (*eth);
++  COMPILE_TIME_ASSERT (sizeof (*eth) + 4 < GRUB_NET_MAX_LINK_HEADER_SIZE);
+ 
+-  err = grub_netbuff_push (nb, sizeof (*eth));
++  const char *vlantag_text = grub_env_get ("vlan-tag");
++  if (vlantag_text != 0) {
++      etherhdr_size += 4;
++      vlantag = grub_strtoul (vlantag_text, 0, 16);
++  }
++
++  err = grub_netbuff_push (nb, etherhdr_size);
+   if (err)
+     return err;
+   eth = (struct etherhdr *) nb->data;
+@@ -76,6 +86,19 @@ send_ethernet_packet (struct grub_net_network_level_interface *inf,
+ 	return err;
+       inf->card->opened = 1;
+     }
++
++  /* Check if a vlan-tag is needed. */
++  if (vlantag != 0)
++    {
++      /* Move eth type to the right */
++      grub_memcpy((char *) nb->data + etherhdr_size - 2,
++                  (char *) nb->data + etherhdr_size - 6, 2);
++
++      /* Add the tag in the middle */
++      grub_memcpy((char *) nb->data + etherhdr_size - 6,
++                  &vlantag, 4);
++    }
++
+   return inf->card->driver->send (inf->card, nb);
+ }
+ 
+@@ -90,10 +113,23 @@ grub_net_recv_ethernet_packet (struct grub_net_buff *nb,
+   grub_net_link_level_address_t hwaddress;
+   grub_net_link_level_address_t src_hwaddress;
+   grub_err_t err;
++  grub_uint8_t etherhdr_size = sizeof (*eth);
++
++  grub_uint16_t vlantag_identifier = 0;
++  grub_memcpy (&vlantag_identifier, nb->data + etherhdr_size - 2, 2);
++
++  /* Check if a vlan-tag is present. */
++  if (vlantag_identifier == VLANTAG_IDENTIFIER)
++    {
++      etherhdr_size += 4;
++      /* Move eth type to the original position */
++      grub_memcpy((char *) nb->data + etherhdr_size - 6,
++                  (char *) nb->data + etherhdr_size - 2, 2);
++    }
+ 
+   eth = (struct etherhdr *) nb->data;
+   type = grub_be_to_cpu16 (eth->type);
+-  err = grub_netbuff_pull (nb, sizeof (*eth));
++  err = grub_netbuff_pull (nb, etherhdr_size);
+   if (err)
+     return err;
+ 
+diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h
+index 416a544..a8cf093 100644
+--- a/include/grub/ieee1275/ieee1275.h
++++ b/include/grub/ieee1275/ieee1275.h
+@@ -210,5 +210,6 @@ char *EXPORT_FUNC(grub_ieee1275_canonicalise_devname) (const char *path);
+ char *EXPORT_FUNC(grub_ieee1275_get_aliasdevname) (const char *path);
+ char *EXPORT_FUNC(grub_ieee1275_canonicalise_devname) (const char *path);
+ char *EXPORT_FUNC(grub_ieee1275_get_device_type) (const char *path);
++int EXPORT_FUNC(grub_ieee1275_parse_net_options) (const char *path);
+ 
+ #endif /* ! GRUB_IEEE1275_HEADER */
+diff --git a/include/grub/net.h b/include/grub/net.h
+index a7e5b2c..f4fec17 100644
+--- a/include/grub/net.h
++++ b/include/grub/net.h
+@@ -532,4 +532,6 @@ extern char *grub_net_default_server;
+ #define GRUB_NET_TRIES 40
+ #define GRUB_NET_INTERVAL 400
+ 
++#define VLANTAG_IDENTIFIER 0x8100
++
+ #endif /* ! GRUB_NET_HEADER */
+-- 
+1.7.10.4
+
diff --git a/dhcp-client-id-and-uuid-options-added.patch b/dhcp-client-id-and-uuid-options-added.patch
new file mode 100644
index 0000000..c573936
--- /dev/null
+++ b/dhcp-client-id-and-uuid-options-added.patch
@@ -0,0 +1,121 @@
+From d63a0b7fd665fae1dd34d3e86127b93dd87b8114 Mon Sep 17 00:00:00 2001
+From: Paulo Flabiano Smorigo <pfsmorigo at br.ibm.com>
+Date: Tue, 27 Nov 2012 17:18:53 -0200
+Subject: [PATCH 2/3] DHCP client ID and UUID options added.
+
+---
+ grub-core/net/bootp.c |   56 +++++++++++++++++++++++++++++++++++++++++--------
+ include/grub/net.h    |    2 ++
+ 2 files changed, 49 insertions(+), 9 deletions(-)
+
+diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c
+index bc07d53..3b4130d 100644
+--- a/grub-core/net/bootp.c
++++ b/grub-core/net/bootp.c
+@@ -51,6 +51,14 @@ set_env_limn_ro (const char *intername, const char *suffix,
+   grub_register_variable_hook (varname, 0, grub_env_write_readonly);
+ }
+ 
++static char
++hexdigit (grub_uint8_t val)
++{
++  if (val < 10)
++    return val + '0';
++  return val + 'a' - 10;
++}
++
+ static void
+ parse_dhcp_vendor (const char *name, void *vend, int limit, int *mask)
+ {
+@@ -81,6 +89,9 @@ parse_dhcp_vendor (const char *name, void *vend, int limit, int *mask)
+ 
+       taglength = *ptr++;
+ 
++      grub_dprintf("net", "DHCP option %u (0x%02x) found with length %u.\n",
++                   tagtype, tagtype, taglength);
++
+       switch (tagtype)
+ 	{
+ 	case GRUB_NET_BOOTP_NETMASK:
+@@ -121,7 +132,9 @@ parse_dhcp_vendor (const char *name, void *vend, int limit, int *mask)
+ 		grub_net_add_dns_server (&s);
+ 		ptr += 4;
+ 	      }
+-	  }
++            /* Skip adittional increment */
++            continue;
++          }
+ 	  break;
+ 	case GRUB_NET_BOOTP_HOSTNAME:
+ 	  set_env_limn_ro (name, "hostname", (char *) ptr, taglength);
+@@ -139,6 +152,39 @@ parse_dhcp_vendor (const char *name, void *vend, int limit, int *mask)
+ 	  set_env_limn_ro (name, "extensionspath", (char *) ptr, taglength);
+ 	  break;
+ 
++        case GRUB_NET_BOOTP_CLIENT_ID:
++	  set_env_limn_ro (name, "clientid", (char *) ptr, taglength);
++          break;
++
++        case GRUB_NET_BOOTP_CLIENT_UUID:
++            {
++              if (taglength != 17)
++                break;
++
++              /* The format is 9cfe245e-d0c8-bd45-a79f-54ea5fbd3d97 */
++
++              ptr += 1;
++              taglength -= 1;
++
++              char *val = grub_malloc (2 * taglength + 4 + 1);
++              int i = 0;
++              int j = 0;
++              for (i = 0; i < taglength; i++)
++                {
++                  val[2 * i + j] = hexdigit (ptr[i] >> 4);
++                  val[2 * i + 1 + j] = hexdigit (ptr[i] & 0xf);
++
++                  if ((i == 3) || (i == 5) || (i == 7) || (i == 9))
++                    {
++                      j++;
++                      val[2 * i + 1+ j] = '-';
++                    }
++                }
++
++              set_env_limn_ro (name, "clientuuid", (char *) val, 2 * taglength + 4);
++            }
++          break;
++
+ 	  /* If you need any other options please contact GRUB
+ 	     developpement team.  */
+ 	}
+@@ -299,14 +345,6 @@ grub_net_process_dhcp (struct grub_net_buff *nb,
+     }
+ }
+ 
+-static char
+-hexdigit (grub_uint8_t val)
+-{
+-  if (val < 10)
+-    return val + '0';
+-  return val + 'a' - 10;
+-}
+-
+ static grub_err_t
+ grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)),
+ 		  int argc, char **args)
+diff --git a/include/grub/net.h b/include/grub/net.h
+index a7e5b2c..45348dd 100644
+--- a/include/grub/net.h
++++ b/include/grub/net.h
+@@ -423,6 +423,8 @@ enum
+     GRUB_NET_BOOTP_DOMAIN = 0x0f,
+     GRUB_NET_BOOTP_ROOT_PATH = 0x11,
+     GRUB_NET_BOOTP_EXTENSIONS_PATH = 0x12,
++    GRUB_NET_BOOTP_CLIENT_ID = 0x3d,
++    GRUB_NET_BOOTP_CLIENT_UUID = 0x61,
+     GRUB_NET_BOOTP_END = 0xff
+   };
+ 
+-- 
+1.7.10.4
+
diff --git a/fix-http-crash.patch b/fix-http-crash.patch
new file mode 100644
index 0000000..ac110c3
--- /dev/null
+++ b/fix-http-crash.patch
@@ -0,0 +1,28 @@
+From 4414df5e72937b0bb1c4a0bb66cd1132ec2a5720 Mon Sep 17 00:00:00 2001
+From: Gustavo Luiz Duarte <gustavold at linux.vnet.ibm.com>
+Date: Tue, 25 Sep 2012 18:40:55 -0400
+Subject: [PATCH] Fix crash on http
+
+Don't free file->data on receiving FIN flag since it is used all over without
+checking. http_close() will be called later to free that memory.
+https://bugzilla.redhat.com/show_bug.cgi?id=860834
+---
+ grub-core/net/http.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/grub-core/net/http.c b/grub-core/net/http.c
+index a7542d1..a5f6f31 100644
+--- a/grub-core/net/http.c
++++ b/grub-core/net/http.c
+@@ -386,7 +386,7 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial)
+ 
+   data->sock = grub_net_tcp_open (file->device->net->server,
+ 				  HTTP_PORT, http_receive,
+-				  http_err, http_err,
++				  http_err, NULL,
+ 				  file);
+   if (!data->sock)
+     {
+-- 
+1.7.11.4
+
diff --git a/just-say-linux.patch b/just-say-linux.patch
new file mode 100644
index 0000000..6cce32b
--- /dev/null
+++ b/just-say-linux.patch
@@ -0,0 +1,45 @@
+From d4bd41f972c6e22b86c773cbba2a1e14f400a8be Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones at redhat.com>
+Date: Mon, 14 Mar 2011 14:27:42 -0400
+Subject: [PATCH] Don't say "GNU/Linux" in generated menus.
+
+---
+ util/grub.d/10_linux.in     |    4 ++--
+ util/grub.d/20_linux_xen.in |    4 ++--
+ 2 files changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
+index a09c3e6..0b0df78 100644
+--- a/util/grub.d/10_linux.in
++++ b/util/grub.d/10_linux.in
+@@ -29,9 +29,9 @@ export TEXTDOMAINDIR=@localedir@
+ CLASS="--class gnu-linux --class gnu --class os"
+ 
+ if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
+-  OS=GNU/Linux
++  OS="$(. /etc/os-release ; echo "$NAME $VERSION")"
+ else
+-  OS="${GRUB_DISTRIBUTOR} GNU/Linux"
++  OS="${GRUB_DISTRIBUTOR}"
+   CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1) ${CLASS}"
+ fi
+ 
+diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in
+index ee49cd9..10422b0 100644
+--- a/util/grub.d/20_linux_xen.in
++++ b/util/grub.d/20_linux_xen.in
+@@ -29,9 +29,9 @@ export TEXTDOMAINDIR=@localedir@
+ CLASS="--class gnu-linux --class gnu --class os --class xen"
+ 
+ if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
+-  OS=GNU/Linux
++  OS="$(. /etc/os-release ; echo "$NAME $VERSION")"
+ else
+-  OS="${GRUB_DISTRIBUTOR} GNU/Linux"
++  OS="${GRUB_DISTRIBUTOR}"
+   CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1) ${CLASS}"
+ fi
+ 
+-- 
+1.7.4
+
diff --git a/search-for-specific-config-file-for-netboot.patch b/search-for-specific-config-file-for-netboot.patch
new file mode 100644
index 0000000..33e3793
--- /dev/null
+++ b/search-for-specific-config-file-for-netboot.patch
@@ -0,0 +1,205 @@
+From 38d458ddd69cb7dd6e7f58f9e9f3197c6b6184f3 Mon Sep 17 00:00:00 2001
+From: Paulo Flabiano Smorigo <pfsmorigo at br.ibm.com>
+Date: Tue, 27 Nov 2012 17:22:07 -0200
+Subject: [PATCH 3/3] Search for specific config file for netboot
+
+This patch implements a search for a specific configuration when the config
+file is on a remoteserver. It uses the following order:
+   1) DHCP client UUID option.
+   2) MAC address (in lower case hexadecimal with dash separators);
+   3) IP (in upper case hexadecimal) or IPv6;
+   4) The original grub.cfg file.
+
+This procedure is similar to what is used by pxelinux and yaboot:
+http://www.syslinux.org/wiki/index.php/PXELINUX#config
+
+This should close the bugzilla:
+https://bugzilla.redhat.com/show_bug.cgi?id=873406
+---
+ grub-core/net/net.c     |  118 +++++++++++++++++++++++++++++++++++++++++++++++
+ grub-core/normal/main.c |   18 ++++++--
+ include/grub/net.h      |    3 ++
+ 3 files changed, 135 insertions(+), 4 deletions(-)
+
+diff --git a/grub-core/net/net.c b/grub-core/net/net.c
+index 01c5d32..49c32c5 100644
+--- a/grub-core/net/net.c
++++ b/grub-core/net/net.c
+@@ -1548,6 +1548,124 @@ grub_net_restore_hw (void)
+   return GRUB_ERR_NONE;
+ }
+ 
++grub_err_t
++grub_net_search_configfile (char *config)
++{
++  grub_size_t config_len;
++  char *suffix;
++
++  auto int search_through (grub_size_t num_tries, grub_size_t slice_size);
++  int search_through (grub_size_t num_tries, grub_size_t slice_size)
++    {
++      while (num_tries-- > 0)
++        {
++	  grub_dprintf ("net", "probe %s\n", config);
++
++          grub_file_t file;
++          file = grub_file_open (config);
++
++          if (file)
++            {
++              grub_file_close (file);
++              grub_dprintf ("net", "found!\n");
++              return 0;
++            }
++          else
++            {
++              if (grub_errno == GRUB_ERR_IO)
++                grub_errno = GRUB_ERR_NONE;
++            }
++
++          if (grub_strlen (suffix) < slice_size)
++            break;
++
++          config[grub_strlen (config) - slice_size] = '\0';
++        }
++
++      return 1;
++    }
++
++  config_len = grub_strlen (config);
++  config[config_len] = '-';
++  suffix = config + config_len + 1;
++
++  struct grub_net_network_level_interface *inf;
++  FOR_NET_NETWORK_LEVEL_INTERFACES (inf)
++    {
++      /* By the Client UUID. */
++
++      char client_uuid_var[sizeof ("net_") + grub_strlen (inf->name) +
++                           sizeof ("_clientuuid") + 1];
++      grub_snprintf (client_uuid_var, sizeof (client_uuid_var),
++                     "net_%s_clientuuid", inf->name);
++
++      const char *client_uuid;
++      client_uuid = grub_env_get (client_uuid_var);
++
++      if (client_uuid)
++        {
++          grub_strcpy (suffix, client_uuid);
++          if (search_through (1, 0) == 0) return GRUB_ERR_NONE;
++        }
++
++      /* By the MAC address. */
++
++      /* Add ethernet type */
++      grub_strcpy (suffix, "01-");
++
++      grub_net_hwaddr_to_str (&inf->hwaddress, suffix + 3);
++
++      char *ptr;
++      for (ptr = suffix; *ptr; ptr++)
++        if (*ptr == ':')
++          *ptr = '-';
++
++      if (search_through (1, 0) == 0) return GRUB_ERR_NONE;
++
++      /* By IP address */
++
++      switch ((&inf->address)->type)
++        {
++        case GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4:
++            {
++              grub_uint32_t n = grub_be_to_cpu32 ((&inf->address)->ipv4);
++              grub_snprintf (suffix, GRUB_NET_MAX_STR_ADDR_LEN, "%02X%02X%02X%02X", \
++                             ((n >> 24) & 0xff), ((n >> 16) & 0xff), \
++                             ((n >> 8) & 0xff), ((n >> 0) & 0xff));
++
++              if (search_through (8, 1) == 0) return GRUB_ERR_NONE;
++              break;
++            }
++        case GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6:
++            {
++              char buf[GRUB_NET_MAX_STR_ADDR_LEN];
++              struct grub_net_network_level_address base;
++              base.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6;
++              grub_memcpy (&base.ipv6, ((&inf->address)->ipv6), 16);
++              grub_net_addr_to_str (&base, buf);
++
++              for (ptr = buf; *ptr; ptr++)
++                if (*ptr == ':')
++                  *ptr = '-';
++
++              grub_snprintf (suffix, GRUB_NET_MAX_STR_ADDR_LEN, "%s", buf);
++              if (search_through (1, 0) == 0) return GRUB_ERR_NONE;
++              break;
++            }
++        case GRUB_NET_NETWORK_LEVEL_PROTOCOL_DHCP_RECV:
++          return grub_error (GRUB_ERR_BUG, "shouldn't reach here");
++        default:
++          return grub_error (GRUB_ERR_BUG,
++                             "unsupported address type %d", (&inf->address)->type);
++        }
++    }
++
++  /* Remove the remaining minus sign at the end. */
++  config[config_len] = '\0';
++
++  return GRUB_ERR_NONE;
++}
++
+ static struct grub_preboot *fini_hnd;
+ 
+ static grub_command_t cmd_addaddr, cmd_deladdr, cmd_addroute, cmd_delroute;
+diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c
+index aa0b3e5..cc519a5 100644
+--- a/grub-core/normal/main.c
++++ b/grub-core/normal/main.c
+@@ -32,6 +32,7 @@
+ #include <grub/i18n.h>
+ #include <grub/charset.h>
+ #include <grub/script_sh.h>
++#include <grub/net.h>
+ 
+ GRUB_MOD_LICENSE ("GPLv3+");
+ 
+@@ -379,10 +380,19 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)),
+ 
+       prefix = grub_env_get ("prefix");
+       if (prefix)
+-	{
+-	  config = grub_xasprintf ("%s/grub.cfg", prefix);
+-	  if (! config)
+-	    goto quit;
++        {
++          grub_size_t config_len;
++          config_len = grub_strlen (prefix) +
++                      sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");
++          config = grub_malloc (config_len);
++
++          if (! config)
++            goto quit;
++
++          grub_snprintf (config, config_len, "%s/grub.cfg", prefix);
++
++          if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0)
++            grub_net_search_configfile (config);
+ 
+ 	  grub_enter_normal_mode (config);
+ 	  grub_free (config);
+diff --git a/include/grub/net.h b/include/grub/net.h
+index 45348dd..09b8d56 100644
+--- a/include/grub/net.h
++++ b/include/grub/net.h
+@@ -534,6 +534,9 @@ extern char *grub_net_default_server;
+ #define GRUB_NET_TRIES 40
+ #define GRUB_NET_INTERVAL 400
+
+ #define VLANTAG_IDENTIFIER 0x8100
+ 
++grub_err_t
++grub_net_search_configfile (char *config);
++
+ #endif /* ! GRUB_NET_HEADER */
+-- 
+1.7.10.4
+
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/grub2.git/commitdiff/1ef550022616a6abdf1f33f3a0213336b0c8ea36



More information about the pld-cvs-commit mailing list