[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Obtaining the MAC address of the boot NIC for a PXE boot

From: Vladimir 'φ-coder/phcoder' Serbinenko
Subject: Re: Obtaining the MAC address of the boot NIC for a PXE boot
Date: Sat, 04 May 2013 23:08:03 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130116 Icedove/10.0.12

> As it stands currently, net_pxe_* variables are defined on PC BIOS
> platform only. For UEFI (which you apparently have) GRUB2 defines
> net_efinetNN_* variables where efinetNN is symbolic name for interface
> that was used to boot GRUB2.
> May be GRUB2 should also define net_pxe_* namespace for the case of

"pxe" is the name of drivers used for BIOS. But it's ok to define
net_boot_* on all platforms and make it alias to the boot interface.

        > There is no real way to find out which interface was used for
> booting and even if there were, grub does not support nested
> variables substitution or eval'ing (like ${net_${boot_if}_mac).

Bash doesn't support such construction either. We generally prefer to
stay reasonably close to bash to allow for easy reference and testing.

> Probably, adding "eval" support is really the most simple. Could you
> test the patch below. What it does, is
> - it adds "eval" command (same as known from UNIX shells) which
>   executes its argument

eval is generally good

> - it exports boot interface as "efi_boot_interface" variable

This is needlessly EFI-specific. Similar variable would be useful on
many platforms. But a possible problem is that it's not known when using
native drivers (and on some platforms you have to). Perhaps making
something similar to "root" partition would be useful:
echo $net_default_mac
With net_default_interface defined to boot one on boot.
This would parallel net_default_server.

> This should allow you to do
> if $grub_platform = efi ; then
>   eval "set net_pxe_mac=\$net_${efi_boot_interface}_mac" 
> fi

Defining system variables manually looks dirty.

> +static grub_err_t
> +grub_cmd_eval (grub_extcmd_context_t ctxt __attribute__((__unused__)),
> +            int argc, char *argv[])
> +{

You don't use any argument parsing. It's better to use command and not
extcmd in this case. Also "eval" in bash concatenates its arguments.

> +  cmd = grub_register_extcmd ("eval", grub_cmd_eval, 0,
> +                           N_("[STRING]"), N_("Evaluate commands"),

This description seems a bit vague for either human-reading or translation.

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]