All of lore.kernel.org
 help / color / mirror / Atom feed
* Patch for export IP addresses from PXE into grub2 enviroment variables
@ 2009-10-15  6:52 Aleš Kapica
  2009-10-15  6:53 ` Seth Goldberg
  0 siblings, 1 reply; 8+ messages in thread
From: Aleš Kapica @ 2009-10-15  6:52 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 470 bytes --]

Could I ask you for apply patch from attachment on pxecmd.c in grub2, please? It's adding an option -s to the command pxe, which do make possible set IP addresses of the server and the client machine, got from PXE, among grub2 enviroment variables.
DHCP gives IP according to MAC address, and we use it to identify the client station by IP address.

Thanks a lot, with regards Aleš Kapica

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

[-- Attachment #2: set_pxeinfo_into_enviroment_variables.diff --]
[-- Type: application/octet-stream, Size: 1657 bytes --]

diff --git a/grub2/commands/i386/pc/pxecmd.c b/grub2/commands/i386/pc/pxecmd.c
index df53870..066d9a0 100644
--- a/grub2/commands/i386/pc/pxecmd.c
+++ b/grub2/commands/i386/pc/pxecmd.c
@@ -22,12 +22,14 @@
 #include <grub/misc.h>
 #include <grub/machine/pxe.h>
 #include <grub/extcmd.h>
+#include <grub/env.h>
 
 static const struct grub_arg_option options[] =
 {
     {"info", 'i', 0, "show PXE information.", 0, 0},
     {"bsize", 'b', 0, "set PXE block size", 0, ARG_TYPE_INT},
     {"unload", 'u', 0, "unload PXE stack.", 0, 0},
+    {"set", 's', 0, "set network variables PXE_IP etc.", 0, 0},
     {0, 0, 0, 0, 0, 0}
   };
 
@@ -43,6 +45,15 @@ print_ip (grub_uint32_t ip)
     }
   grub_printf ("%d", ip);
 }
+static void
+set_ip2env_var(char *var_name, grub_uint32_t ip)
+{
+	char s[20];
+	grub_sprintf (s,"%d.%d.%d.%d", (ip>>0)&0xFF,
+		(ip>>8)&0xFF, (ip>>16)&0xFF, (ip>>24)&0xFF);
+	grub_env_set (var_name, s);
+}
+
 
 static grub_err_t
 grub_cmd_pxe (grub_extcmd_t cmd, int argc __attribute__ ((unused)),
@@ -78,6 +89,13 @@ grub_cmd_pxe (grub_extcmd_t cmd, int argc __attribute__ ((unused)),
       grub_printf ("\n");
     }
 
+  if (state[3].set)
+    {
+		set_ip2env_var ("pxe_your_ip", grub_pxe_your_ip);
+		set_ip2env_var ("pxe_server_ip", grub_pxe_server_ip);
+		set_ip2env_var ("pxe_gateway_ip", grub_pxe_gateway_ip);
+	}
+
   if (state[2].set)
     grub_pxe_unload ();
 
@@ -89,7 +107,7 @@ static grub_extcmd_t cmd;
 GRUB_MOD_INIT(pxecmd)
 {
   cmd = grub_register_extcmd ("pxe", grub_cmd_pxe, GRUB_COMMAND_FLAG_BOTH,
-			      "pxe [-i|-b|-u]",
+			      "pxe [-i|-b|-u|-s']",
 			      "Command to control the PXE device.", options);
 }
 

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: Patch for export IP addresses from PXE into grub2 enviroment variables
  2009-10-15  6:52 Patch for export IP addresses from PXE into grub2 enviroment variables Aleš Kapica
@ 2009-10-15  6:53 ` Seth Goldberg
  2009-10-15  7:38   ` Felix Zielcke
  0 siblings, 1 reply; 8+ messages in thread
From: Seth Goldberg @ 2009-10-15  6:53 UTC (permalink / raw)
  To: The development of GRUB 2

[-- Attachment #1: Type: TEXT/PLAIN, Size: 948 bytes --]

Hi,

   That's actually not sufficient -- we need the entire DHCPACK to be passed 
(somehow) to the loading kernel.  I've discussed this a bit with phcoder, and 
he suggested adding another member to the multiboot structure off of which we 
can hang the DHCPACK packet.  The environment variables may also have value, 
for other OSes that don't use multiboot.

  --S

Quoting Aleš Kapica, who wrote the following on Thu, 15 Oct 2009:

> Could I ask you for apply patch from attachment on pxecmd.c in grub2, please? 
> It's adding an option -s to the command pxe, which do make possible set IP 
> addresses of the server and the client machine, got from PXE, among grub2 
> enviroment variables.
> DHCP gives IP according to MAC address, and we use it to identify the client 
> station by IP address.
>
> Thanks a lot, with regards Aleš Kapica
>
> -- 
> Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Patch for export IP addresses from PXE into grub2 enviroment variables
  2009-10-15  6:53 ` Seth Goldberg
@ 2009-10-15  7:38   ` Felix Zielcke
  2009-10-15  7:51     ` Seth Goldberg
  0 siblings, 1 reply; 8+ messages in thread
From: Felix Zielcke @ 2009-10-15  7:38 UTC (permalink / raw)
  To: The development of GRUB 2

Am Mittwoch, den 14.10.2009, 23:53 -0700 schrieb Seth Goldberg:
> Hi,
> 
>    That's actually not sufficient -- we need the entire DHCPACK to be passed 
> (somehow) to the loading kernel.  I've discussed this a bit with phcoder, and 
> he suggested adding another member to the multiboot structure off of which we 
> can hang the DHCPACK packet.  The environment variables may also have value, 
> for other OSes that don't use multiboot.
> 
>   --S
> 
> Quoting Aleš Kapica, who wrote the following on Thu, 15 Oct 2009:
> 
> > Could I ask you for apply patch from attachment on pxecmd.c in grub2, please? 
> > It's adding an option -s to the command pxe, which do make possible set IP 
> > addresses of the server and the client machine, got from PXE, among grub2 
> > enviroment variables.
> > DHCP gives IP according to MAC address, and we use it to identify the client 
> > station by IP address.
> >
> > Thanks a lot, with regards Aleš Kapica
> >

Having the Client IP avaible inside grub.cfg might be useful for some.
Then you could have one grub.cfg for all your machines and if one or a
small number of it needs some special stuff, you could just check for
the IP inside the grub.cfg. Then you don't need to use a seperate one
for them.

But maybe this isn't that useful if option-150 gets implemented which
Yoann requested.

-- 
Felix Zielcke
Proud Debian Maintainer and GNU GRUB developer




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Patch for export IP addresses from PXE into grub2 enviroment variables
  2009-10-15  7:38   ` Felix Zielcke
@ 2009-10-15  7:51     ` Seth Goldberg
  2009-10-15  8:00       ` Vladimir 'phcoder' Serbinenko
  2009-10-15  8:05       ` Felix Zielcke
  0 siblings, 2 replies; 8+ messages in thread
From: Seth Goldberg @ 2009-10-15  7:51 UTC (permalink / raw)
  To: The development of GRUB 2

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1571 bytes --]



Quoting Felix Zielcke, who wrote the following on Thu, 15 Oct 2009:

> Am Mittwoch, den 14.10.2009, 23:53 -0700 schrieb Seth Goldberg:
>> Hi,
>>
>>    That's actually not sufficient -- we need the entire DHCPACK to be passed
>> (somehow) to the loading kernel.  I've discussed this a bit with phcoder, and
>> he suggested adding another member to the multiboot structure off of which we
>> can hang the DHCPACK packet.  The environment variables may also have value,
>> for other OSes that don't use multiboot.
>>
>>   --S
>>
>> Quoting Aleš Kapica, who wrote the following on Thu, 15 Oct 2009:
>>
>>> Could I ask you for apply patch from attachment on pxecmd.c in grub2, please?
>>> It's adding an option -s to the command pxe, which do make possible set IP
>>> addresses of the server and the client machine, got from PXE, among grub2
>>> enviroment variables.
>>> DHCP gives IP according to MAC address, and we use it to identify the client
>>> station by IP address.
>>>
>>> Thanks a lot, with regards Aleš Kapica
>>>
>
> Having the Client IP avaible inside grub.cfg might be useful for some.
> Then you could have one grub.cfg for all your machines and if one or a
> small number of it needs some special stuff, you could just check for
> the IP inside the grub.cfg. Then you don't need to use a seperate one
> for them.

  Please, no.  That's terribly non-scalable for a large number of clients 
(enterprise deployments).  We definitely need a solution that includes the 
configuration file to use as a DHCP option.

  --S

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Patch for export IP addresses from PXE into grub2 enviroment variables
  2009-10-15  7:51     ` Seth Goldberg
@ 2009-10-15  8:00       ` Vladimir 'phcoder' Serbinenko
  2009-10-15  8:04         ` Seth Goldberg
  2009-10-15  8:07         ` Yoann Moulin
  2009-10-15  8:05       ` Felix Zielcke
  1 sibling, 2 replies; 8+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2009-10-15  8:00 UTC (permalink / raw)
  To: The development of GRUB 2

Seth Goldberg wrote:
>
>
> Quoting Felix Zielcke, who wrote the following on Thu, 15 Oct 2009:
>
>> Am Mittwoch, den 14.10.2009, 23:53 -0700 schrieb Seth Goldberg:
>>> Hi,
>>>
>>>    That's actually not sufficient -- we need the entire DHCPACK to
>>> be passed
>>> (somehow) to the loading kernel.  I've discussed this a bit with
>>> phcoder, and
>>> he suggested adding another member to the multiboot structure off of
>>> which we
>>> can hang the DHCPACK packet.  The environment variables may also
>>> have value,
>>> for other OSes that don't use multiboot.
>>>
>>>   --S
>>>
>>> Quoting Aleš Kapica, who wrote the following on Thu, 15 Oct 2009:
>>>
>>>> Could I ask you for apply patch from attachment on pxecmd.c in
>>>> grub2, please?
>>>> It's adding an option -s to the command pxe, which do make possible
>>>> set IP
>>>> addresses of the server and the client machine, got from PXE, among
>>>> grub2
>>>> enviroment variables.
>>>> DHCP gives IP according to MAC address, and we use it to identify
>>>> the client
>>>> station by IP address.
>>>>
>>>> Thanks a lot, with regards Aleš Kapica
>>>>
>>
>> Having the Client IP avaible inside grub.cfg might be useful for some.
>> Then you could have one grub.cfg for all your machines and if one or a
>> small number of it needs some special stuff, you could just check for
>> the IP inside the grub.cfg. Then you don't need to use a seperate one
>> for them.
>
>  Please, no.  That's terribly non-scalable for a large number of
> clients (enterprise deployments).  We definitely need a solution that
> includes the configuration file to use as a DHCP option.
>
One doesn't prevent another. And then it will be up to administrator to
choose the way they want their system to work
>  --S
> ------------------------------------------------------------------------
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel
>   


-- 
Regards
Vladimir 'phcoder' Serbinenko
Personal git repository: http://repo.or.cz/w/grub2/phcoder.git 




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Patch for export IP addresses from PXE into grub2 enviroment variables
  2009-10-15  8:00       ` Vladimir 'phcoder' Serbinenko
@ 2009-10-15  8:04         ` Seth Goldberg
  2009-10-15  8:07         ` Yoann Moulin
  1 sibling, 0 replies; 8+ messages in thread
From: Seth Goldberg @ 2009-10-15  8:04 UTC (permalink / raw)
  To: The development of GRUB 2


>>>
>>> Having the Client IP avaible inside grub.cfg might be useful for some.
>>> Then you could have one grub.cfg for all your machines and if one or a
>>> small number of it needs some special stuff, you could just check for
>>> the IP inside the grub.cfg. Then you don't need to use a seperate one
>>> for them.
>>
>>  Please, no.  That's terribly non-scalable for a large number of
>> clients (enterprise deployments).  We definitely need a solution that
>> includes the configuration file to use as a DHCP option.
>>
> One doesn't prevent another. And then it will be up to administrator to
> choose the way they want their system to work

   As long as we have the choice, that's fine with me.

  --S



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Patch for export IP addresses from PXE into grub2 enviroment variables
  2009-10-15  7:51     ` Seth Goldberg
  2009-10-15  8:00       ` Vladimir 'phcoder' Serbinenko
@ 2009-10-15  8:05       ` Felix Zielcke
  1 sibling, 0 replies; 8+ messages in thread
From: Felix Zielcke @ 2009-10-15  8:05 UTC (permalink / raw)
  To: The development of GRUB 2

Am Donnerstag, den 15.10.2009, 00:51 -0700 schrieb Seth Goldberg:
> 
> Quoting Felix Zielcke, who wrote the following on Thu, 15 Oct 2009:
> 
> > Am Mittwoch, den 14.10.2009, 23:53 -0700 schrieb Seth Goldberg:
> >> Hi,
> >>
> >>    That's actually not sufficient -- we need the entire DHCPACK to be passed
> >> (somehow) to the loading kernel.  I've discussed this a bit with phcoder, and
> >> he suggested adding another member to the multiboot structure off of which we
> >> can hang the DHCPACK packet.  The environment variables may also have value,
> >> for other OSes that don't use multiboot.
> >>
> >>   --S
> >>
> >> Quoting Aleš Kapica, who wrote the following on Thu, 15 Oct 2009:
> >>
> >>> Could I ask you for apply patch from attachment on pxecmd.c in grub2, please?
> >>> It's adding an option -s to the command pxe, which do make possible set IP
> >>> addresses of the server and the client machine, got from PXE, among grub2
> >>> enviroment variables.
> >>> DHCP gives IP according to MAC address, and we use it to identify the client
> >>> station by IP address.
> >>>
> >>> Thanks a lot, with regards Aleš Kapica
> >>>
> >
> > Having the Client IP avaible inside grub.cfg might be useful for some.
> > Then you could have one grub.cfg for all your machines and if one or a
> > small number of it needs some special stuff, you could just check for
> > the IP inside the grub.cfg. Then you don't need to use a seperate one
> > for them.
> 
>   Please, no.  That's terribly non-scalable for a large number of clients 
> (enterprise deployments).  We definitely need a solution that includes the 
> configuration file to use as a DHCP option.

Both methods should coexist fine.
I didn't meant to implement only this and not the option-150.
I just thought that this method might have an advantage for some people
over the other.

As I said as last sentence
>But maybe this isn't that useful if option-150 gets implemented which
>Yoann requested.


-- 
Felix Zielcke
Proud Debian Maintainer and GNU GRUB developer




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Patch for export IP addresses from PXE into grub2 enviroment variables
  2009-10-15  8:00       ` Vladimir 'phcoder' Serbinenko
  2009-10-15  8:04         ` Seth Goldberg
@ 2009-10-15  8:07         ` Yoann Moulin
  1 sibling, 0 replies; 8+ messages in thread
From: Yoann Moulin @ 2009-10-15  8:07 UTC (permalink / raw)
  To: The development of GRUB 2

>>> Having the Client IP avaible inside grub.cfg might be useful for some.
>>> Then you could have one grub.cfg for all your machines and if one or a
>>> small number of it needs some special stuff, you could just check for
>>> the IP inside the grub.cfg. Then you don't need to use a seperate one
>>> for them.
>>
>>  Please, no.  That's terribly non-scalable for a large number of
>> clients (enterprise deployments).  We definitely need a solution that
>> includes the configuration file to use as a DHCP option.
>>
> One doesn't prevent another. And then it will be up to administrator to
> choose the way they want their system to work
>>  --S

might be good to get option-150 first for compatibility with old grub
than developed new feature ? I mean, this feature can be useful for some
people but option-150 must be need by more people ?

Yoann



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-10-15  8:08 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-15  6:52 Patch for export IP addresses from PXE into grub2 enviroment variables Aleš Kapica
2009-10-15  6:53 ` Seth Goldberg
2009-10-15  7:38   ` Felix Zielcke
2009-10-15  7:51     ` Seth Goldberg
2009-10-15  8:00       ` Vladimir 'phcoder' Serbinenko
2009-10-15  8:04         ` Seth Goldberg
2009-10-15  8:07         ` Yoann Moulin
2009-10-15  8:05       ` Felix Zielcke

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.