From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1WbsNf-0007zO-9M for mharc-grub-devel@gnu.org; Sun, 20 Apr 2014 10:06:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55826) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WbsNY-0007me-Lp for grub-devel@gnu.org; Sun, 20 Apr 2014 10:06:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WbsNT-00052a-3n for grub-devel@gnu.org; Sun, 20 Apr 2014 10:05:56 -0400 Received: from mail-ee0-x22e.google.com ([2a00:1450:4013:c00::22e]:50028) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WbsNS-00050v-OG for grub-devel@gnu.org; Sun, 20 Apr 2014 10:05:51 -0400 Received: by mail-ee0-f46.google.com with SMTP id t10so2960125eei.5 for ; Sun, 20 Apr 2014 07:05:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type; bh=jjhdFsEw69UZaJmkzGRqq3cO7e4j5myzOdZesUZpqmM=; b=JAjW2d5aPBqhpQjDSrq7vJTweTg642EaNEbWWdzzAmHLPLXoJTvYTjFFC664FxBp8V UbfNFKqfJ2R6E5ac83cUKFXP0lr0fybBgO6Lufq4cwH4mzCZzRyseQfGXZAvLuo2a5bM 1CYzNkYjDqbZuo2xjlmr8YiY85AtIIkCcWP+8SDLJy2ShGJjTeYR0zlMj1N5pYtdzIOS fBpEhJXVu4TCDylZz2ZWWcvnzksuXyFs8eYXhda+pd0SNrhISoKSE58ct0A7D+/ZnMAr j7YLZygYE++EJcJXTItFkTM8cszrXnCrRzffXA3hIB8XHUrOTGkxIyDFVutkiVvsSp3k lcIg== X-Received: by 10.15.82.132 with SMTP id a4mr38748394eez.47.1398002749876; Sun, 20 Apr 2014 07:05:49 -0700 (PDT) Received: from [192.168.42.163] (1-228.197-178.cust.bluewin.ch. [178.197.228.1]) by mx.google.com with ESMTPSA id cb5sm94882953eeb.18.2014.04.20.07.05.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 20 Apr 2014 07:05:49 -0700 (PDT) Message-ID: <5353D436.60007@gmail.com> Date: Sun, 20 Apr 2014 16:05:42 +0200 From: =?UTF-8?B?VmxhZGltaXIgJ8+GLWNvZGVyL3BoY29kZXInIFNlcmJpbmVua28=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.4.0 MIME-Version: 1.0 To: The development of GNU GRUB Subject: Re: RFC Patch [0/2] PXE Add support for proxy DHCP References: <6D165E863E048E4D86C25F15CEA5329797665DF1@ORSMSX109.amr.corp.intel.com> In-Reply-To: <6D165E863E048E4D86C25F15CEA5329797665DF1@ORSMSX109.amr.corp.intel.com> X-Enigmail-Version: 1.6 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="eusubdsfTgTA83dcoq0Vmdmn0IRmRKLDg" X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4013:c00::22e 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: Sun, 20 Apr 2014 14:06:02 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --eusubdsfTgTA83dcoq0Vmdmn0IRmRKLDg Content-Type: multipart/mixed; boundary="------------080904020607050909010705" This is a multi-part message in MIME format. --------------080904020607050909010705 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 19.04.2014 02:26, Mroczek, Joseph T wrote: > Hello: >=20 > Currently, grub does not support getting boot server information from a= proxy DHCP server. This patch set adds this support for EFI. If the appr= oach is good, I will go back and create a i386-pc patch as well. >=20 > It works by combining the contents from the two DHCP packets into a sin= gle source. This seems simpler and cleaner than updating all the DHCP cod= e to work with multiple packets and juggling precedence across all the op= tions. >=20 > Any help in getting this support into grub would be greatly appreciated= =2E >=20 We have patch for similar problem for i386-pc port (attached). The main problem with it is that it wasn't tested. If you can confirm that it works for EFI as well (after adaptations from your patch), we could commit pxe2.diff and necessarry adaptations on top of it. > ~joe >=20 >=20 >=20 > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/grub-devel >=20 --------------080904020607050909010705 Content-Type: text/x-diff; name="pxe2.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="pxe2.diff" diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c index 19dc988..a1dcde6 100644 --- a/grub-core/kern/main.c +++ b/grub-core/kern/main.c @@ -142,8 +142,9 @@ grub_set_prefix_and_root (void) if (pptr[0]) path =3D grub_strdup (pptr); } - if ((!device || device[0] =3D=3D ',' || !device[0]) || !path) - grub_machine_get_bootlocation (&fwdevice, &fwpath); + + /* Call unconditionally as it also configures the network. */ + grub_machine_get_bootlocation (&fwdevice, &fwpath); =20 if (!device && fwdevice) device =3D fwdevice; diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c index ed15941..38b0836 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c @@ -161,33 +161,14 @@ parse_dhcp_vendor (const char *name, const void *ve= nd, int limit, int *mask) =20 #define OFFSET_OF(x, y) ((grub_size_t)((grub_uint8_t *)((y)->x) - (grub_= uint8_t *)(y))) =20 -struct grub_net_network_level_interface * -grub_net_configure_by_dhcp_ack (const char *name, - struct grub_net_card *card, - grub_net_interface_flags_t flags, - const struct grub_net_bootp_packet *bp, - grub_size_t size, - int is_def, char **device, char **path) +void +grub_net_process_dhcp_ack (struct grub_net_network_level_interface *inte= r, + const struct grub_net_bootp_packet *bp, + grub_size_t size, + int is_def, char **device, char **path) { - grub_net_network_level_address_t addr; - grub_net_link_level_address_t hwaddr; - struct grub_net_network_level_interface *inter; int mask =3D -1; =20 - addr.type =3D GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; - addr.ipv4 =3D bp->your_ip; - - if (device) - *device =3D 0; - if (path) - *path =3D 0; - - grub_memcpy (hwaddr.mac, bp->mac_addr, - bp->hw_len < sizeof (hwaddr.mac) ? bp->hw_len - : sizeof (hwaddr.mac)); - hwaddr.type =3D GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET; - - inter =3D grub_net_add_addr (name, card, &addr, &hwaddr, flags); if (bp->gateway_ip) { grub_net_network_level_netaddress_t target; @@ -199,7 +180,7 @@ grub_net_configure_by_dhcp_ack (const char *name, target.ipv4.masksize =3D 32; gw.type =3D GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; gw.ipv4 =3D bp->gateway_ip; - rname =3D grub_xasprintf ("%s:gw", name); + rname =3D grub_xasprintf ("%s:gw", inter->name); if (rname) grub_net_add_route_gw (rname, target, gw); grub_free (rname); @@ -207,14 +188,12 @@ grub_net_configure_by_dhcp_ack (const char *name, target.type =3D GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; target.ipv4.base =3D bp->gateway_ip; target.ipv4.masksize =3D 32; - grub_net_add_route (name, target, inter); + grub_net_add_route (inter->name, target, inter); } =20 if (size > OFFSET_OF (boot_file, bp)) - set_env_limn_ro (name, "boot_file", (char *) bp->boot_file, + set_env_limn_ro (inter->name, "boot_file", (char *) bp->boot_file, sizeof (bp->boot_file)); - if (is_def) - grub_net_default_server =3D 0; if (is_def && !grub_net_default_server && bp->server_ip) { grub_net_default_server =3D grub_xasprintf ("%d.%d.%d.%d", @@ -225,12 +204,6 @@ grub_net_configure_by_dhcp_ack (const char *name, grub_print_error (); } =20 - if (is_def) - { - grub_env_set ("net_default_interface", name); - grub_env_export ("net_default_interface"); - } - if (device && !*device && bp->server_ip) { *device =3D grub_xasprintf ("tftp,%d.%d.%d.%d", @@ -243,7 +216,7 @@ grub_net_configure_by_dhcp_ack (const char *name, if (size > OFFSET_OF (server_name, bp) && bp->server_name[0]) { - set_env_limn_ro (name, "dhcp_server_name", (char *) bp->server_nam= e, + set_env_limn_ro (inter->name, "dhcp_server_name", (char *) bp->ser= ver_name, sizeof (bp->server_name)); if (is_def && !grub_net_default_server) { @@ -257,7 +230,8 @@ grub_net_configure_by_dhcp_ack (const char *name, } } =20 - if (size > OFFSET_OF (boot_file, bp) && path) + if (size > OFFSET_OF (boot_file, bp) && path && !*path + && bp->boot_file[0]) { *path =3D grub_strndup (bp->boot_file, sizeof (bp->boot_file)); grub_print_error (); @@ -272,9 +246,47 @@ grub_net_configure_by_dhcp_ack (const char *name, } } if (size > OFFSET_OF (vendor, bp)) - parse_dhcp_vendor (name, &bp->vendor, size - OFFSET_OF (vendor, bp),= &mask); + parse_dhcp_vendor (inter->name, &bp->vendor, size - OFFSET_OF (vendo= r, bp), &mask); grub_net_add_ipv4_local (inter, mask); - =20 +} + + +struct grub_net_network_level_interface * +grub_net_configure_by_dhcp_ack (const char *name, + struct grub_net_card *card, + grub_net_interface_flags_t flags, + const struct grub_net_bootp_packet *bp, + grub_size_t size, + int is_def, char **device, char **path) +{ + grub_net_network_level_address_t addr; + grub_net_link_level_address_t hwaddr; + struct grub_net_network_level_interface *inter; + + addr.type =3D GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; + addr.ipv4 =3D bp->your_ip; + + if (device) + *device =3D 0; + if (path) + *path =3D 0; + + grub_memcpy (hwaddr.mac, bp->mac_addr, + bp->hw_len < sizeof (hwaddr.mac) ? bp->hw_len + : sizeof (hwaddr.mac)); + hwaddr.type =3D GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET; + + inter =3D grub_net_add_addr (name, card, &addr, &hwaddr, flags); + + if (is_def) + { + grub_env_set ("net_default_interface", name); + grub_env_export ("net_default_interface"); + grub_net_default_server =3D 0; + } + + grub_net_process_dhcp_ack (inter, bp, size, is_def, device, path); + inter->dhcp_ack =3D grub_malloc (size); if (inter->dhcp_ack) { diff --git a/grub-core/net/drivers/i386/pc/pxe.c b/grub-core/net/drivers/= i386/pc/pxe.c index 3e75b2e..0a2ed82 100644 --- a/grub-core/net/drivers/i386/pc/pxe.c +++ b/grub-core/net/drivers/i386/pc/pxe.c @@ -360,15 +360,24 @@ static void grub_pc_net_config_real (char **device, char **path) { struct grub_net_bootp_packet *bp; + struct grub_net_network_level_interface *inter; =20 bp =3D grub_pxe_get_cached (GRUB_PXENV_PACKET_TYPE_DHCP_ACK); =20 if (!bp) return; - grub_net_configure_by_dhcp_ack ("pxe", &grub_pxe_card, 0, - bp, GRUB_PXE_BOOTP_SIZE, - 1, device, path); + inter =3D grub_net_configure_by_dhcp_ack ("pxe", &grub_pxe_card, 0, + bp, GRUB_PXE_BOOTP_SIZE, + 1, device, path); =20 + + /* Boot server PXE options add and override boot file/server */ + bp =3D grub_pxe_get_cached (GRUB_PXENV_PACKET_TYPE_CACHED_REPLY); + + + if (bp) + grub_net_process_dhcp_ack (inter, bp, GRUB_PXE_BOOTP_SIZE, + 1, device, path); } =20 static struct grub_preboot *fini_hnd; diff --git a/include/grub/net.h b/include/grub/net.h index 788516a..507f985 100644 --- a/include/grub/net.h +++ b/include/grub/net.h @@ -444,6 +444,12 @@ grub_net_configure_by_dhcp_ack (const char *name, grub_size_t size, int is_def, char **device, char **path); =20 +void +grub_net_process_dhcp_ack (struct grub_net_network_level_interface *inte= r, + const struct grub_net_bootp_packet *bp, + grub_size_t size, + int is_def, char **device, char **path); + grub_err_t grub_net_add_ipv4_local (struct grub_net_network_level_interface *inf, int mask); --------------080904020607050909010705-- --eusubdsfTgTA83dcoq0Vmdmn0IRmRKLDg Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Using GnuPG with Icedove - http://www.enigmail.net/ iF4EAREKAAYFAlNT1DYACgkQmBXlbbo5nOvUKAD/cByW2tNNx9sA6aFiV1Dn2rR7 TSmLV3EYUup2P4uFQgwA/iTQpYF0ARXvZ4wJVLO19PcRzOQbJzHVEw/gfJv9ShUR =gRfs -----END PGP SIGNATURE----- --eusubdsfTgTA83dcoq0Vmdmn0IRmRKLDg--