From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1XAnCd-0007Jt-24 for mharc-grub-devel@gnu.org; Fri, 25 Jul 2014 17:38:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41646) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XAnCY-0007Aq-5e for grub-devel@gnu.org; Fri, 25 Jul 2014 17:38:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XAnCX-0001ic-1z for grub-devel@gnu.org; Fri, 25 Jul 2014 17:38:54 -0400 Received: from mail-we0-x233.google.com ([2a00:1450:400c:c03::233]:49098) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XAnCW-0001iE-OU for grub-devel@gnu.org; Fri, 25 Jul 2014 17:38:52 -0400 Received: by mail-we0-f179.google.com with SMTP id u57so4859687wes.38 for ; Fri, 25 Jul 2014 14:38:51 -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=75I5tsA74G/RYFQ9KJ5xkchsuI7BV/TRXUULSlGkX/k=; b=xJO6hazNC0dTiil6jcFx+6p+mS5sI37kjGjdmzYcqwVXGFi68kEk+dHcSZs6PZMytW icrC6F7QNud53dII+MbyF5d9B5JvRZb5NujGPR/bADjPorIibfChTY7sUP0uFr4OoPWo WSov7S0cFjWh8Ay7Z3tHva/fooDv1WXYD07jSGWNLCauRjgpVabpcN+VqzGbwQOZGlMx Aoup36XFszRMPbgSNLA0bT1yOXAG67xBQGlLZ0XiKrm8nGMzTD4pmTFgR6LbDGDvM+ev cQVYUnXQki6pGfqB03YlB65RvjmitFvJcTIHOwyBK2NRAsNFZedJCWqZkNw/hX0YNIFR FJUA== X-Received: by 10.180.183.131 with SMTP id em3mr8786112wic.56.1406324331646; Fri, 25 Jul 2014 14:38:51 -0700 (PDT) Received: from ?IPv6:2a02:1205:501d:7d90:3e77:e6ff:feb1:aba3? ([2a02:1205:501d:7d90:3e77:e6ff:feb1:aba3]) by mx.google.com with ESMTPSA id h3sm28585847wjn.10.2014.07.25.14.38.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Jul 2014 14:38:50 -0700 (PDT) Message-ID: <53D2CE5A.2040102@gmail.com> Date: Fri, 25 Jul 2014 23:38:34 +0200 From: =?UTF-8?B?VmxhZGltaXIgJ8+GLWNvZGVyL3BoY29kZXInIFNlcmJpbmVua28=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.0 MIME-Version: 1.0 To: The development of GNU GRUB Subject: Re: [PATCH] fix PXE transmit failure if P_UNKNOWN is not supported References: <1406303622-31501-1-git-send-email-arvidjaar@gmail.com> In-Reply-To: <1406303622-31501-1-git-send-email-arvidjaar@gmail.com> Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="8mAQ79hnxGTwI04SHN5cQdi2OfWkO1XHF" X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c03::233 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: Fri, 25 Jul 2014 21:38:55 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --8mAQ79hnxGTwI04SHN5cQdi2OfWkO1XHF Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 25.07.2014 17:53, Andrey Borzenkov wrote: > Some PXE stacks do not support P_UNKNOWN in UNDI TRANSMIT; nothing is > sent at all. So strip Ethernet header for known frame types and let PXE= > stack add it. >=20 If I'm reading this patch correctly it discards several fields of the packet and i.a. kills vlan fields. Such low in the stack it should replace the header only in the case of perfect match. It will be perfect match in 99% of configs but we shouldn0t break configs on unaffected machines. > PXE implementation that fail is e.g. >=20 > 64bit_foxconn with PXE-2.0 (build 082) NIC: SIS900 PXE > BootROM v1.09 Hook Int19 >=20 > Reported-By: Beeblebrox > Tested-By: Beeblebrox >=20 > --- > grub-core/net/drivers/i386/pc/pxe.c | 46 +++++++++++++++++++++++++++++= +++++--- > 1 file changed, 43 insertions(+), 3 deletions(-) >=20 > diff --git a/grub-core/net/drivers/i386/pc/pxe.c b/grub-core/net/driver= s/i386/pc/pxe.c > index e8c0b22..3d78bdd 100644 > --- a/grub-core/net/drivers/i386/pc/pxe.c > +++ b/grub-core/net/drivers/i386/pc/pxe.c > @@ -25,6 +25,7 @@ > #include > #include > #include > +#include > =20 > #include > #include > @@ -38,6 +39,11 @@ GRUB_MOD_LICENSE ("GPLv3+"); > #define SEGOFS(x) ((SEGMENT(x) << 16) + OFFSET(x)) > #define LINEAR(x) (void *) ((((x) >> 16) << 4) + ((x) & 0xFFFF)) > =20 > +#define P_UNKNOWN 0 > +#define P_IP 1 > +#define P_ARP 2 > +#define P_RARP 3 > + > struct grub_pxe_undi_open > { > grub_uint16_t status; > @@ -256,22 +262,56 @@ grub_pxe_send (struct grub_net_card *dev __attrib= ute__ ((unused)), > struct grub_pxe_undi_transmit *trans; > struct grub_pxe_undi_tbd *tbd; > char *buf; > + grub_uint8_t *dst; > + grub_uint16_t type; > =20 > trans =3D (void *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR; > grub_memset (trans, 0, sizeof (*trans)); > + dst =3D (void *) (GRUB_MEMORY_MACHINE_SCRATCH_ADDR + 128 - 6); > + /* First 6 bytes are destination address */ > + grub_memcpy (dst, pack->data, 6); > + > + /* Some PXE stacks do not support P_UNKNOWN. So strip Ethernet > + header for known protocols and let PXE implementation add it */ > + grub_memcpy (&type, pack->data + 12, 2); > + switch (type) > + { > + case grub_cpu_to_be16_compile_time (GRUB_NET_ETHERTYPE_IP): > + trans->protocol =3D P_IP; > + break; > + case grub_cpu_to_be16_compile_time (GRUB_NET_ETHERTYPE_ARP): > + trans->protocol =3D P_ARP; > + break; > + /* grub does not use RARP */ > + default: > + trans->protocol =3D P_UNKNOWN; > + break; > + } > + if (trans->protocol) > + { > + grub_err_t err; > + > + err =3D grub_netbuff_pull (pack, 14); > + if (err) > + return err; > + if (dst[0] =3D=3D 0xff && dst[1] =3D=3D 0xff && dst[2] =3D=3D 0x= ff && > + dst[3] =3D=3D 0xff && dst[4] =3D=3D 0xff && dst[5] =3D=3D 0xff) > + trans->xmitflag =3D 1; > + else > + trans->dest =3D SEGOFS ((grub_addr_t) dst); > + } > + =20 > tbd =3D (void *) (GRUB_MEMORY_MACHINE_SCRATCH_ADDR + 128); > grub_memset (tbd, 0, sizeof (*tbd)); > buf =3D (void *) (GRUB_MEMORY_MACHINE_SCRATCH_ADDR + 256); > grub_memcpy (buf, pack->data, pack->tail - pack->data); > - > trans->tbd =3D SEGOFS ((grub_addr_t) tbd); > - trans->protocol =3D 0; > tbd->len =3D pack->tail - pack->data; > tbd->buf =3D SEGOFS ((grub_addr_t) buf); > =20 > grub_pxe_call (GRUB_PXENV_UNDI_TRANSMIT, trans, pxe_rm_entry); > if (trans->status) > - return grub_error (GRUB_ERR_IO, N_("couldn't send network packet")= ); > + return grub_error (GRUB_ERR_IO, N_("couldn't send network packet, = PXE status: 0x%04x"), trans->status); > return 0; > } > =20 >=20 --8mAQ79hnxGTwI04SHN5cQdi2OfWkO1XHF 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 iF4EAREKAAYFAlPSzmkACgkQmBXlbbo5nOuHzAD/eqLSwoaAq8YP+wWMta4EDvRu s8yTA2BIr6LHbGMQZdIBAIY0Iod0hBHdxzwZ7gTknky3qzeAtM31xW6iMZxXNaTh =Vbfn -----END PGP SIGNATURE----- --8mAQ79hnxGTwI04SHN5cQdi2OfWkO1XHF--