From: "Vladimir 'φ-coder/phcoder' Serbinenko" <phcoder@gmail.com>
To: grub-devel@gnu.org
Subject: Re: Obtaining the MAC address of the boot NIC for a PXE boot
Date: Tue, 07 May 2013 12:03:51 +0200 [thread overview]
Message-ID: <5188D187.3040302@gmail.com> (raw)
In-Reply-To: <20130505091708.13b0a8c8@opensuse.site>
[-- Attachment #1: Type: text/plain, Size: 3884 bytes --]
On 05.05.2013 07:17, Andrey Borzenkov wrote:
> В Sat, 04 May 2013 23:19:50 +0200
> Vladimir 'φ-coder/phcoder' Serbinenko <phcoder@gmail.com> пишет:
>
>> Patch for net_default_*. Please test.
>>
>> === modified file 'grub-core/net/bootp.c'
>> --- grub-core/net/bootp.c 2013-01-20 13:24:47 +0000
>> +++ grub-core/net/bootp.c 2013-05-04 21:16:02 +0000
>> @@ -211,6 +211,9 @@
>> 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",
>>
>> === modified file 'grub-core/net/net.c'
>> --- grub-core/net/net.c 2013-01-21 01:33:46 +0000
>> +++ grub-core/net/net.c 2013-05-04 21:13:29 +0000
>> @@ -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,65 @@
>> return grub_net_default_server ? : "";
>> }
>>
>> +static const char *
>> +defip_get_env (struct grub_env_var *var __attribute__ ((unused)),
>> + const char *val)
>> +{
>> + const char *intf = grub_env_get ("net_default_interface");
>> + const char *ret = NULL;
>> + if (intf)
>> + {
>> + char *buf = grub_xasprintf ("net_%s_ip", intf);
>> + ret = grub_env_get (buf);
>
> This will crash if grub_xasprintf fails.
>
Right, thanks. This patch was actually meant to just show the principle.
Fixed this and another problem with it, tested and now comitting.
>> + 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);
>> + 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)
>> +{
>> + const char *intf = grub_env_get ("net_default_interface");
>> + const char *ret = NULL;
>> + if (intf)
>> + {
>> + char *buf = grub_xasprintf ("net_%s_mac", intf);
>> + 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);
>> + 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 +1619,10 @@
>> 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
>>
>>
>
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 294 bytes --]
next prev parent reply other threads:[~2013-05-07 10:04 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1367240132.58582.YahooMailNeo@web120204.mail.ne1.yahoo.com>
2013-05-01 14:59 ` Obtaining the MAC address of the boot NIC for a PXE boot Andrey Borzenkov
2013-05-04 21:08 ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-05-04 21:19 ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-05-05 5:17 ` Andrey Borzenkov
2013-05-07 10:03 ` Vladimir 'φ-coder/phcoder' Serbinenko [this message]
2013-05-07 17:50 ` Documentation for (Re: Obtaining the MAC address of the boot NIC for a PXE boot) Andrey Borzenkov
2013-05-07 19:45 ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-05-08 14:52 ` Andrey Borzenkov
2013-05-11 16:35 ` New command eval Andrey Borzenkov
2013-05-11 17:02 ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-05-11 17:30 ` Andrey Borzenkov
2013-05-14 6:26 ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-05-12 0:07 ` Seth Goldberg
2013-05-12 5:39 ` Andrey Borzenkov
2013-05-13 5:13 ` Seth Goldberg
2013-05-14 7:21 ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-05-08 17:27 ` Obtaining the MAC address of the boot NIC for a PXE boot Rigoberto Corujo
2013-05-08 19:25 ` Andrey Borzenkov
2013-05-10 16:12 ` Rigoberto Corujo
2013-05-11 4:47 ` Andrey Borzenkov
2013-05-15 17:09 ` Rigoberto Corujo
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=5188D187.3040302@gmail.com \
--to=phcoder@gmail.com \
--cc=grub-devel@gnu.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;
as well as URLs for NNTP newsgroup(s).