Openembedded Core Discussions
 help / color / mirror / Atom feed
From: wenzong fan <wenzong.fan@windriver.com>
To: <openembedded-core@lists.openembedded.org>
Subject: Re: [PATCH] grub: Add support for net_default_mac and net_default_ip variables
Date: Fri, 24 Jul 2015 16:10:30 +0800	[thread overview]
Message-ID: <55B1F2F6.5030401@windriver.com> (raw)
In-Reply-To: <1436256840-1930-1-git-send-email-wenzong.fan@windriver.com>

Ping ...

On 07/07/2015 04:14 PM, wenzong.fan@windriver.com wrote:
> From: Lijun Guo <Lijun.Guo@windriver.com>
>
> Using "-c" parameter, grub-mkimage can embed a configuration file into
> the grub image. However grub 2.0 doesn't support net_default_mac and
> net_default_ip variables in the configuration file.
>
> Backport upstream commit to fix the issue:
> * commit id: 2aa072d76a9c7df837a6a81bf80958094a522740
>
> Signed-off-by: Lijun Guo <Lijun.Guo@windriver.com>
> ---
>   ...-to-determine-MAC-IP-of-default-interface.patch | 127 +++++++++++++++++++++
>   meta/recipes-bsp/grub/grub2.inc                    |   1 +
>   2 files changed, 128 insertions(+)
>   create mode 100644 meta/recipes-bsp/grub/files/New-variables-to-determine-MAC-IP-of-default-interface.patch
>
> diff --git a/meta/recipes-bsp/grub/files/New-variables-to-determine-MAC-IP-of-default-interface.patch b/meta/recipes-bsp/grub/files/New-variables-to-determine-MAC-IP-of-default-interface.patch
> new file mode 100644
> index 0000000..b1b028e
> --- /dev/null
> +++ b/meta/recipes-bsp/grub/files/New-variables-to-determine-MAC-IP-of-default-interface.patch
> @@ -0,0 +1,127 @@
> +From 2aa072d76a9c7df837a6a81bf80958094a522740 Mon Sep 17 00:00:00 2001
> +From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
> +Date: Tue, 7 May 2013 12:05:36 +0200
> +Subject: [PATCH] New variables 'net_default_*' to determine MAC/IP of
> + default interface.
> +
> +commit 2aa072d76a9c7df837a6a81bf80958094a522740 upstream
> +
> +Upstream-Status: Backport
> +
> +Signed-off-by: Lijun Guo <lijun.guo@windriver.com>
> +
> +---
> + grub-core/net/bootp.c |  3 +++
> + grub-core/net/net.c   | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++-
> + 2 files changed, 71 insertions(+), 1 deletion(-)
> +
> +diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c
> +index 33f860a..c8ef4d6 100644
> +--- a/grub-core/net/bootp.c
> ++++ b/grub-core/net/bootp.c
> +@@ -211,6 +211,9 @@ grub_net_configure_by_dhcp_ack (const char *name,
> +       grub_print_error ();
> +     }
> +
> ++  if (is_def)
> ++    grub_env_set ("net_default_interface", name);
> ++
> +   if (device && !*device && bp->server_ip)
> +     {
> +       *device = grub_xasprintf ("tftp,%d.%d.%d.%d",
> +diff --git a/grub-core/net/net.c b/grub-core/net/net.c
> +index aebbe4b..8ea6906 100644
> +--- a/grub-core/net/net.c
> ++++ b/grub-core/net/net.c
> +@@ -1,6 +1,6 @@
> + /*
> +  *  GRUB  --  GRand Unified Bootloader
> +- *  Copyright (C) 2010,2011  Free Software Foundation, Inc.
> ++ *  Copyright (C) 2010,2011,2012,2013  Free Software Foundation, Inc.
> +  *
> +  *  GRUB is free software: you can redistribute it and/or modify
> +  *  it under the terms of the GNU General Public License as published by
> +@@ -813,6 +813,69 @@ defserver_get_env (struct grub_env_var *var __attribute__ ((unused)),
> +   return grub_net_default_server ? : "";
> + }
> +
> ++static const char *
> ++defip_get_env (struct grub_env_var *var __attribute__ ((unused)),
> ++	       const char *val __attribute__ ((unused)))
> ++{
> ++  const char *intf = grub_env_get ("net_default_interface");
> ++  const char *ret = NULL;
> ++  if (intf)
> ++    {
> ++      char *buf = grub_xasprintf ("net_%s_ip", intf);
> ++      if (buf)
> ++	ret = grub_env_get (buf);
> ++      grub_free (buf);
> ++    }
> ++  return ret;
> ++}
> ++
> ++static char *
> ++defip_set_env (struct grub_env_var *var __attribute__ ((unused)),
> ++	       const char *val)
> ++{
> ++  const char *intf = grub_env_get ("net_default_interface");
> ++  if (intf)
> ++    {
> ++      char *buf = grub_xasprintf ("net_%s_ip", intf);
> ++      if (buf)
> ++	grub_env_set (buf, val);
> ++      grub_free (buf);
> ++    }
> ++  return NULL;
> ++}
> ++
> ++
> ++static const char *
> ++defmac_get_env (struct grub_env_var *var __attribute__ ((unused)),
> ++	       const char *val __attribute__ ((unused)))
> ++{
> ++  const char *intf = grub_env_get ("net_default_interface");
> ++  const char *ret = NULL;
> ++  if (intf)
> ++    {
> ++      char *buf = grub_xasprintf ("net_%s_mac", intf);
> ++      if (buf)
> ++	ret = grub_env_get (buf);
> ++      grub_free (buf);
> ++    }
> ++  return ret;
> ++}
> ++
> ++static char *
> ++defmac_set_env (struct grub_env_var *var __attribute__ ((unused)),
> ++	       const char *val)
> ++{
> ++  const char *intf = grub_env_get ("net_default_interface");
> ++  if (intf)
> ++    {
> ++      char *buf = grub_xasprintf ("net_%s_mac", intf);
> ++      if (buf)
> ++	grub_env_set (buf, val);
> ++      grub_free (buf);
> ++    }
> ++  return NULL;
> ++}
> ++
> +
> + static void
> + grub_net_network_level_interface_register (struct grub_net_network_level_interface *inter)
> +@@ -1560,6 +1623,10 @@ GRUB_MOD_INIT(net)
> + 			       defserver_set_env);
> +   grub_register_variable_hook ("pxe_default_server", defserver_get_env,
> + 			       defserver_set_env);
> ++  grub_register_variable_hook ("net_default_ip", defip_get_env,
> ++			       defip_set_env);
> ++  grub_register_variable_hook ("net_default_mac", defmac_get_env,
> ++			       defmac_set_env);
> +
> +   cmd_addaddr = grub_register_command ("net_add_addr", grub_cmd_addaddr,
> + 					/* TRANSLATORS: HWADDRESS stands for
> +--
> +1.8.5.2.233.g932f7e4
> +
> diff --git a/meta/recipes-bsp/grub/grub2.inc b/meta/recipes-bsp/grub/grub2.inc
> index 312771b..07be851 100644
> --- a/meta/recipes-bsp/grub/grub2.inc
> +++ b/meta/recipes-bsp/grub/grub2.inc
> @@ -27,6 +27,7 @@ SRC_URI = "ftp://ftp.gnu.org/gnu/grub/grub-${PV}.tar.gz \
>              file://0001-Unset-need_charset_alias-when-building-for-musl.patch \
>              file://0001-parse_dhcp_vendor-Add-missing-const-qualifiers.patch \
>              file://grub2-fix-initrd-size-bug.patch \
> +           file://New-variables-to-determine-MAC-IP-of-default-interface.patch \
>               "
>
>   DEPENDS = "flex-native bison-native xz"
>


      reply	other threads:[~2015-07-24  8:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-07  8:14 [PATCH] grub: Add support for net_default_mac and net_default_ip variables wenzong.fan
2015-07-24  8:10 ` wenzong fan [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55B1F2F6.5030401@windriver.com \
    --to=wenzong.fan@windriver.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox