Received: from list by lists.gnu.org with archive (Exim 4.71) id 1UaB92-0000Go-Lu for mharc-grub-devel@gnu.org; Wed, 08 May 2013 16:39:24 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57172) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ua89h-0002xK-PS for grub-devel@gnu.org; Wed, 08 May 2013 13:27:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ua89d-0000Xr-On for grub-devel@gnu.org; Wed, 08 May 2013 13:27:53 -0400 Received: from nm33-vm4.bullet.mail.ne1.yahoo.com ([98.138.229.68]:38856) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ua89d-0000Wt-7v for grub-devel@gnu.org; Wed, 08 May 2013 13:27:49 -0400 Received: from [98.138.90.52] by nm33.bullet.mail.ne1.yahoo.com with NNFMP; 08 May 2013 17:27:47 -0000 Received: from [98.138.88.234] by tm5.bullet.mail.ne1.yahoo.com with NNFMP; 08 May 2013 17:27:47 -0000 Received: from [127.0.0.1] by omp1034.mail.ne1.yahoo.com with NNFMP; 08 May 2013 17:27:47 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 360373.81800.bm@omp1034.mail.ne1.yahoo.com Received: (qmail 48390 invoked by uid 60001); 8 May 2013 17:27:47 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1368034067; bh=X9BN8hxpoxzptCTATsm95rp24IPF7TAQO80haue6uf0=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=CquX9iScSSEtm13fxcdEIYlQlf5rgZVNNB0QIIkw96IcdgQehGOjwVEMggbtf1KhB46xWG4/dOk9+JXwnpoeKm5a3Dz0KROs6wPAGKX9f7DORsdsT/Zc3pVcmQTEaz9L4RUzO9pZaCX+juNELICexULlR1/6ob+s3gbnzdAD/D4= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=L3bRM4YBJtJ9uqHU3VYOI4FZNM33TJslbu65tC/9uVCPmxWtfM0DFmbN3Fo+3nvmvYygnIl3w5wtSrj+xHCED4QphRIk+GK157XFeTEFsV1ns6zh9ao8ZW725UdYPf/0ZvxzXMbzAqux65+qb3zVuR/qXuom/A7OuNdpLn/Ped0=; X-YMail-OSG: sTSvTiIVM1mX_jHUMP32SNBxwwyFDnrenXOsBLMbUA4dabQ aOL4qsg4xEfQgPJAN.mIv3imM_lIjJApWoQJIX561OjXo1nYu2oHl.GYfTzS sRwmOLXAIlx5Lh2kOCbKNbwq25cAJp_zcM6koqbymVHslPSi1qJYi0JRqR.L 8V2Dh1yalxgvKULirGH9Ohkds9Ad3kfUMPR33AcEWcuyOTfJDnAwRai5kAjb E34OK5NCaa7KhXgBSRGIm3nQO6ftsoW1QIlxbJcqboOLHm3ggi1rif1QjSlc nb0YeNdBy2554xYrsTPBvTacbFAHByVj3pbjr3yPYSxlg9cZM0V.0GGtG3ik pdP4u3Peu61n_O8khR8sT5o8Hhy2bVEISgjedERszG23DN4GRJIRpmF3RMaR MrjRtHar4m4RM6BqaYK0A2YgRHfvtzMmGUtuYzz2gKTpyOZq15147FSpITOK bmPH88CZPxj3bQIvn3gyR03m22bs4b3ocVt6wai5v7l38B21VzYcJj7q7qG2 GhihBjvhGqz_tSBhgoZipFcFseb_pnHiwgF8Sj2zL6jRXCTpimuAcXkKjcbz tIQGP4cegUXTZMk6hM12BtMKsXmUZXqH1xE8xjVCueLcXM_NMellXIVQlBKW zQjeB.3lqIOxIHmf.H.qeu7wJ_91nEaNx6vJpoqeBApE90SB7viRmKm34 Received: from [15.203.233.79] by web120203.mail.ne1.yahoo.com via HTTP; Wed, 08 May 2013 10:27:47 PDT X-Rocket-MIMEInfo: 002.001, LS0tLS0gT3JpZ2luYWwgTWVzc2FnZSAtLS0tLQoKPiBGcm9tOiBBbmRyZXkgQm9yemVua292IDxhcnZpZGphYXJAZ21haWwuY29tPgo.IFRvOiBSaWdvYmVydG8gQ29ydWpvIDxyY29ydWpvQHlhaG9vLmNvbT4KPiBDYzogImhlbHAtZ3J1YkBnbnUub3JnIiA8aGVscC1ncnViQGdudS5vcmc.OyBncnViLWRldmVsQGdudS5vcmcKPiBTZW50OiBXZWRuZXNkYXksIE1heSAxLCAyMDEzIDEwOjU5IEFNCj4gU3ViamVjdDogUmU6IE9idGFpbmluZyB0aGUgTUFDIGFkZHJlc3Mgb2YgdGhlIGJvb3QgTklDIGZvciBhIFABMAEBAQE- X-Mailer: YahooMailWebService/0.8.141.536 References: <1367240132.58582.YahooMailNeo@web120204.mail.ne1.yahoo.com> <20130501185934.3f2b9c28@opensuse.site> Message-ID: <1368034067.35751.YahooMailNeo@web120203.mail.ne1.yahoo.com> Date: Wed, 8 May 2013 10:27:47 -0700 (PDT) From: Rigoberto Corujo Subject: Re: Obtaining the MAC address of the boot NIC for a PXE boot To: Andrey Borzenkov In-Reply-To: <20130501185934.3f2b9c28@opensuse.site> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: FreeBSD 8.x X-Received-From: 98.138.229.68 X-Mailman-Approved-At: Wed, 08 May 2013 16:39:22 -0400 Cc: "help-grub@gnu.org" , "grub-devel@gnu.org" X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 May 2013 17:27:57 -0000 ----- Original Message -----=0A=0A> From: Andrey Borzenkov =0A> To: Rigoberto Corujo =0A> Cc: "help-grub@gnu.o= rg" ; grub-devel@gnu.org=0A> Sent: Wednesday, May 1, 201= 3 10:59 AM=0A> Subject: Re: Obtaining the MAC address of the boot NIC for a= PXE boot=0A> =0A> =D0=92 Mon, 29 Apr 2013 05:55:32 -0700 (PDT)=0A> Rigober= to Corujo =D0=BF=D0=B8=D1=88=D0=B5=D1=82:=0A> =0A>> He= llo everyone,=0A>> =0A>> With pxelinux, you can specify "IPAPPEND 2" in yo= ur boot loader =0A> configuration file and the MAC address of the boot NIC = automatically gets =0A> appended to your kernel parameters as "BOOTIF=3DXX:= XX:XX:XX:XX:XX".=C2=A0=0A>> =0A>> I am now trying to become familiar with = Grub 2, because if its EFI support. =0A> =C2=A0 I noticed that with Grub 2,= some of the documentation, which may be outdated, =0A> says that there is = a "net_pxe_mac" variable which, as I understand it, =0A> should contain the= MAC address of the boot NIC. =C2=A0However, I've built the =0A> latest Gru= b 2 sources and, when I PXE boot and drop into a grub shell prompt, if =0A>= type "set", I don't see "net_pxe_mac" listed as one of =0A> the variables.= =C2=A0I know there is a "net_ls_addr" command which prints =0A> out someth= ing like "efinet8 3c:4a:92:b2:6a:e8 10.1.1.114", but I =0A> don't know how = to use Grub scripting to parse out the MAC address. =C2=A0I also =0A> don't= know if there will ever be a case where "net_ls_addr" will =0A> print out = multiple entries on a PXE boot, making it difficult to determine which =0A>= one corresponds to the boot NIC.=0A>> =0A>> =0A>> Basically, I'm using th= e "ksdevice=3Dbootif" kernel parameter =0A> when PXE booting my Red Hat ker= nel. =C2=A0With PXE Linux, "bootif" provides =0A> the MAC address of the bo= ot NIC. =C2=A0I was hoping to do something like =0A> "ksdevice=3D${net_pxe_= mac}", but since "net_pxe_mac" does not =0A> appear to be getting set, I ne= ed to find some other method.=0A>> =0A> =0A> =0A> As it stands currently, n= et_pxe_* variables are defined on PC BIOS=0A> platform only. For UEFI (whic= h you apparently have) GRUB2 defines=0A> net_efinetNN_* variables where efi= netNN is symbolic name for interface=0A> that was used to boot GRUB2.=0A> = =0A> May be GRUB2 should also define net_pxe_* namespace for the case of=0A= > UEFI. There is no real way to find out which interface was used for=0A> b= ooting and even if there were, grub does not support nested=0A> variables s= ubstitution or eval'ing (like ${net_${boot_if}_mac).=0A> =0A> Probably, add= ing "eval" support is really the most simple. Could you=0A> test the patch = below. What it does, is=0A> =0A> - it adds "eval" command (same as known fr= om UNIX shells) which=0A> =C2=A0 executes its argument=0A> =0A> - it export= s boot interface as "efi_boot_interface" variable=0A> =0A> This should allo= w you to do=0A> =0A> if $grub_platform =3D efi ; then=0A> =C2=A0 eval "set = net_pxe_mac=3D\$net_${efi_boot_interface}_mac" =0A> fi=0A> =0A> and then us= e $net_pxe_mac on both platforms.=0A> =0A> If it works for you, I will clea= n it up; for consistency this is=0A> probably needed for ieee1275 as well.= =0A> =0A> ---=0A> grub-core/Makefile.core.def=C2=A0 =C2=A0 =C2=A0 =C2=A0 |= =C2=A0 5 ++++=0A> grub-core/commands/eval.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 | 51 ++++++++++++++++++++++++++++++++++++++=0A> grub-core/net/drivers/e= fi/efinet.c |=C2=A0 2 ++=0A> 3 files changed, 58 insertions(+)=0A> =0A> dif= f --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def=0A> ind= ex 7e19acb..8844f2f 100644=0A> --- a/grub-core/Makefile.core.def=0A> +++ b/= grub-core/Makefile.core.def=0A> @@ -699,6 +699,11 @@ module =3D {=0A> };=0A= > =0A> module =3D {=0A> +=C2=A0 name =3D eval;=0A> +=C2=A0 common =3D comma= nds/eval.c;=0A> +};=0A> +=0A> +module =3D {=0A> =C2=A0 name =3D extcmd;=0A= > =C2=A0 common =3D commands/extcmd.c;=0A> =C2=A0 common =3D lib/arg.c;= =0A> diff --git a/grub-core/commands/eval.c b/grub-core/commands/eval.c=0A>= new file mode 100644=0A> index 0000000..a21ff89=0A> --- /dev/null=0A> +++ = b/grub-core/commands/eval.c=0A> @@ -0,0 +1,51 @@=0A> +/*=0A> + *=C2=A0 GRUB= =C2=A0 --=C2=A0 GRand Unified Bootloader=0A> + *=C2=A0 Copyright (C) 2009= =C2=A0 Free Software Foundation, Inc.=0A> + *=0A> + *=C2=A0 GRUB is free so= ftware: you can redistribute it and/or modify=0A> + *=C2=A0 it under the te= rms of the GNU General Public License as published by=0A> + *=C2=A0 the Fre= e Software Foundation, either version 3 of the License, or=0A> + *=C2=A0 (a= t your option) any later version.=0A> + *=0A> + *=C2=A0 GRUB is distributed= in the hope that it will be useful,=0A> + *=C2=A0 but WITHOUT ANY WARRANTY= ; without even the implied warranty of=0A> + *=C2=A0 MERCHANTABILITY or FIT= NESS FOR A PARTICULAR PURPOSE.=C2=A0 See the=0A> + *=C2=A0 GNU General Publ= ic License for more details.=0A> + *=0A> + *=C2=A0 You should have received= a copy of the GNU General Public License=0A> + *=C2=A0 along with GRUB.=C2= =A0 If not, see .=0A> + */=0A> +=0A> +#includ= e =0A> +#include =0A> +#include =0A>= +#include =0A> +#include =0A> +=0A> +GRUB_MOD_LI= CENSE ("GPLv3+");=0A> +=0A> +static grub_err_t=0A> +grub_cmd_eval (grub_ext= cmd_context_t ctxt __attribute__((__unused__)),=0A> +=C2=A0=C2=A0=C2=A0 =C2= =A0 =C2=A0 =C2=A0 int argc, char *argv[])=0A> +{=0A> +=C2=A0 char *dummy[1= ] =3D { NULL };=0A> +=0A> +=C2=A0 if (argc !=3D 1)=0A> +=C2=A0 =C2=A0 retur= n=C2=A0 grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument =0A> expected")= );=0A> +=C2=A0 return grub_script_execute_sourcecode (argv[0], 0, dummy);= =0A> +}=0A> +=0A> +static grub_extcmd_t cmd;=0A> +=0A> +GRUB_MOD_INIT(eval)= =0A> +{=0A> +=C2=A0 cmd =3D grub_register_extcmd ("eval", grub_cmd_eval, 0,= =0A> +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 =C2= =A0 =C2=A0 N_("[STRING]"), N_("Evaluate commands"),=0A> +=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 NULL);=0A> +}=0A> +=0A> +GRUB_MOD_FINI(eval)=0A> +{=0A> +=C2= =A0 grub_unregister_extcmd (cmd);=0A> +}=0A> +=0A> diff --git a/grub-core/n= et/drivers/efi/efinet.c =0A> b/grub-core/net/drivers/efi/efinet.c=0A> index= 2b344d6..f7d8fd5 100644=0A> --- a/grub-core/net/drivers/efi/efinet.c=0A> += ++ b/grub-core/net/drivers/efi/efinet.c=0A> @@ -23,6 +23,7 @@=0A> #include = =0A> #include =0A> #include = =0A> +#include =0A> =0A> GRUB_MOD_LICENSE ("GPLv3+");=0A> =0A> = @@ -250,6 +251,7 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char = =0A> **device,=0A> =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 =C2=A0 =C2=A0 &pxe_mode->dhcp_ack,=0A> =C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 =C2=A0 = sizeof (pxe_mode->dhcp_ack),=0A> =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 =C2=A0 1, device, path);=0A> +=C2= =A0 =C2=A0 grub_env_set ("efi_boot_interface", card->name);=0A> =C2=A0 =C2= =A0 return;=0A> =C2=A0 }=0A> }=0A> -- =0A> tg: (93daf86..) e/uefi_pxe_var= s (depends on: master)=0A> =0A> =0A> ______________________________________= _________=0A> Help-grub mailing list=0A> Help-grub@gnu.org=0A> https://list= s.gnu.org/mailman/listinfo/help-grub=0A> =0A=0AThank you very much, Andrey.= =C2=A0This worked. =C2=A0I did have to add the following lines to "grub-co= re/Makefile.core.am" to get a "eval.mod" generated, but I'm sure that it's = probably because I missed an important step that would have automatically g= enerated it.=0A=0A=0Aif COND_x86_64_efi=0Aplatform_PROGRAMS +=3D eval.modul= e=0AMODULE_FILES +=3D eval.module$(EXEEXT)=0Aeval_module_SOURCES =C2=A0=3D = commands/eval.c =C2=A0## platform sources=0Anodist_eval_module_SOURCES =C2= =A0=3D =C2=A0## platform nodist sources=0Aeval_module_LDADD =C2=A0=3D=0Aeva= l_module_CFLAGS =C2=A0=3D $(AM_CFLAGS) $(CFLAGS_MODULE)=0Aeval_module_LDFLA= GS =C2=A0=3D $(AM_LDFLAGS) $(LDFLAGS_MODULE)=0Aeval_module_CPPFLAGS =C2=A0= =3D $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)=0Aeval_module_CCASFLAGS =C2=A0=3D $(A= M_CCASFLAGS) $(CCASFLAGS_MODULE)=0AEXTRA_DIST +=3D=0ABUILT_SOURCES +=3D $(n= odist_eval_module_SOURCES)=0ACLEANFILES +=3D $(nodist_eval_module_SOURCES)= =0AMOD_FILES +=3D eval.mod=0AMARKER_FILES +=3D eval.marker=0ACLEANFILES += =3D eval.marker=0A=0Aeval.marker: $(eval_module_SOURCES) $(nodist_eval_modu= le_SOURCES)=0A=C2=A0 =C2=A0 =C2=A0 =C2=A0 $(TARGET_CPP) -DGRUB_LST_GENERATO= R $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(eval_module_= CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)=0A=C2=A0 =C2=A0 =C2= =A0 =C2=A0 grep 'MARKER' $@.new > $@; rm -f $@.new=0Aendif=0A=0AAnyway, tha= nk you once again.=0A=0ARigoberto=0A