From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=33203 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PoAGJ-0005dy-3I for qemu-devel@nongnu.org; Sat, 12 Feb 2011 02:51:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PoAGH-0000OP-Kx for qemu-devel@nongnu.org; Sat, 12 Feb 2011 02:51:22 -0500 Received: from smtp5-g21.free.fr ([212.27.42.5]:39087) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PoAGH-0000NP-2f for qemu-devel@nongnu.org; Sat, 12 Feb 2011 02:51:21 -0500 Message-ID: <4D563BEC.4090505@reactos.org> Date: Sat, 12 Feb 2011 08:51:08 +0100 From: =?ISO-8859-1?Q?Herv=E9_Poussineau?= MIME-Version: 1.0 References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] Re: [PATCH] slirp: ensure minimum packet size List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: brogers@novell.com Hi, qemu-devel-request@nongnu.org a =E9crit : > Date: Thu, 10 Feb 2011 15:54:28 -0700 > From: "Bruce Rogers" > Subject: [Qemu-devel] [PATCH] slirp: ensure minimum packet size > To: > Message-ID: <4D540A3402000048000A9C8C@novprvoes0310.provo.novell.com> > Content-Type: text/plain; charset=3DUS-ASCII > > With recent gpxe eepro100 drivers, short packets are rejected, > so ensure the minimum ethernet packet size. > > Signed-off-by: Bruce Rogers > --- > slirp/slirp.c | 4 ++-- > 1 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/slirp/slirp.c b/slirp/slirp.c > index 332d83b..b611cf7 100644 > --- a/slirp/slirp.c > +++ b/slirp/slirp.c > @@ -697,7 +697,7 @@ void if_encap(Slirp *slirp, const uint8_t *ip_data,= int ip_data_len) > return; > =20 > if (!memcmp(slirp->client_ethaddr, zero_ethaddr, ETH_ALEN)) { > - uint8_t arp_req[ETH_HLEN + sizeof(struct arphdr)]; > + uint8_t arp_req[max(ETH_HLEN + sizeof(struct arphdr), 64)]; > struct ethhdr *reh =3D (struct ethhdr *)arp_req; > struct arphdr *rah =3D (struct arphdr *)(arp_req + ETH_HLEN); > const struct ip *iph =3D (const struct ip *)ip_data; > =20 Ack for this part. Slirp must not generate frames which are not 802.3 compliant, ie less=20 than 64 bytes. A similar fix has already been done at=20 http://git.qemu.org/qemu.git/commit/?id=3Ddbf3c4b4baceb91eb64d09f787cbe92= d65188813 On a side note, maybe you need to add a memset to clear the unused part=20 of the buffer? > @@ -734,7 +734,7 @@ void if_encap(Slirp *slirp, const uint8_t *ip_data,= int ip_data_len) > memcpy(&eh->h_source[2], &slirp->vhost_addr, 4); > eh->h_proto =3D htons(ETH_P_IP); > memcpy(buf + sizeof(struct ethhdr), ip_data, ip_data_len); > - slirp_output(slirp->opaque, buf, ip_data_len + ETH_HLEN); > + slirp_output(slirp->opaque, buf, max(ip_data_len + ETH_HLEN, 6= 4)); > } > } > =20 > =20 Nack for this part. Here, you're limiting the Ethernet frame to at most 64 bytes. You=20 probably meant min(ip_data_len + ETH_HLEN, 64). Even with min(), I'm not sure if it is slirp responsability to increase=20 buffer size to meet Ethernet standards. Herv=E9