From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=47349 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OvxpB-0000iJ-9P for qemu-devel@nongnu.org; Wed, 15 Sep 2010 15:39:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Ovxp6-00072Y-35 for qemu-devel@nongnu.org; Wed, 15 Sep 2010 15:39:21 -0400 Received: from smtp5-g21.free.fr ([212.27.42.5]:53904) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ovxp5-00071L-Gj for qemu-devel@nongnu.org; Wed, 15 Sep 2010 15:39:16 -0400 Message-ID: <4C9120D6.9010207@reactos.org> Date: Wed, 15 Sep 2010 21:39:02 +0200 From: =?ISO-8859-1?Q?Herv=E9_Poussineau?= MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] [slirp] Make ARP replies at least 64 bytes long References: <1284411762-3687-1-git-send-email-hpoussin@reactos.org> <20100914222257.GB16690@laped.lan> In-Reply-To: <20100914222257.GB16690@laped.lan> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Edgar E. Iglesias" Cc: =?ISO-8859-1?Q?Herv=E9_Poussineau?= , qemu-devel@nongnu.org Edgar E. Iglesias a =E9crit : > On Mon, Sep 13, 2010 at 11:02:42PM +0200, Herv=E9 Poussineau wrote: > =20 >> IEEE 802.3 standard requires Ethernet frames to be at least 64 bytes l= ong. >> If it is not the case, they will be considered as runt frames, and may= be ignored by netcard and/or OS >> >> Signed-off-by: Herv=E9 Poussineau >> --- >> slirp/slirp.c | 12 ++++++++---- >> 1 files changed, 8 insertions(+), 4 deletions(-) >> >> diff --git a/slirp/slirp.c b/slirp/slirp.c >> index 82fd9b4..2e8c017 100644 >> --- a/slirp/slirp.c >> +++ b/slirp/slirp.c >> @@ -599,9 +599,12 @@ static void arp_input(Slirp *slirp, const uint8_t= *pkt, int pkt_len) >> { >> struct ethhdr *eh =3D (struct ethhdr *)pkt; >> struct arphdr *ah =3D (struct arphdr *)(pkt + ETH_HLEN); >> - uint8_t arp_reply[ETH_HLEN + sizeof(struct arphdr)]; >> - struct ethhdr *reh =3D (struct ethhdr *)arp_reply; >> - struct arphdr *rah =3D (struct arphdr *)(arp_reply + ETH_HLEN); >> + union { >> + uint8_t data[ETH_HLEN + sizeof(struct arphdr)]; >> + uint8_t payload[64]; /* Minimum Ethernet frame size */ >> + } arp_reply; >> + struct ethhdr *reh =3D (struct ethhdr *)arp_reply.data; >> + struct arphdr *rah =3D (struct arphdr *)(arp_reply.data + ETH_HLE= N); >> =20 > > > Hi, > > Would you mind explaning the point of the union here? Why not just > do something like: > > - uint8_t arp_reply[ETH_HLEN + sizeof(struct arphdr)]; > + uint8_t arp_reply[MAX(ETH_HLEN + sizeof(struct arphdr), 64)]; > > =20 Good idea. I'll send an updated patch soon. Herv=E9