From patchwork Mon Sep 13 21:02:42 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Herv=C3=A9_Poussineau?= X-Patchwork-Id: 64656 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5892DB70CB for ; Tue, 14 Sep 2010 07:06:45 +1000 (EST) Received: from localhost ([127.0.0.1]:34349 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OvGEc-0004j4-OJ for incoming@patchwork.ozlabs.org; Mon, 13 Sep 2010 17:06:42 -0400 Received: from [140.186.70.92] (port=42141 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OvGCY-0003ZH-EC for qemu-devel@nongnu.org; Mon, 13 Sep 2010 17:04:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OvGCV-0004st-Hn for qemu-devel@nongnu.org; Mon, 13 Sep 2010 17:04:34 -0400 Received: from smtp5-g21.free.fr ([212.27.42.5]:41267) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OvGCU-0004sB-Vk for qemu-devel@nongnu.org; Mon, 13 Sep 2010 17:04:31 -0400 Received: from localhost.localdomain (unknown [88.171.126.33]) by smtp5-g21.free.fr (Postfix) with ESMTP id 215DAD48121; Mon, 13 Sep 2010 23:04:25 +0200 (CEST) From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= To: qemu-devel@nongnu.org Date: Mon, 13 Sep 2010 23:02:42 +0200 Message-Id: <1284411762-3687-1-git-send-email-hpoussin@reactos.org> X-Mailer: git-send-email 1.7.1.GIT MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Subject: [Qemu-devel] [PATCH] [slirp] Make ARP replies at least 64 bytes long X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org IEEE 802.3 standard requires Ethernet frames to be at least 64 bytes long. 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é 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 = (struct ethhdr *)pkt; struct arphdr *ah = (struct arphdr *)(pkt + ETH_HLEN); - uint8_t arp_reply[ETH_HLEN + sizeof(struct arphdr)]; - struct ethhdr *reh = (struct ethhdr *)arp_reply; - struct arphdr *rah = (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 = (struct ethhdr *)arp_reply.data; + struct arphdr *rah = (struct arphdr *)(arp_reply.data + ETH_HLEN); int ar_op; struct ex_list *ex_ptr; @@ -619,6 +622,7 @@ static void arp_input(Slirp *slirp, const uint8_t *pkt, int pkt_len) } return; arp_ok: + memset(&arp_reply, 0, sizeof(arp_reply)); /* XXX: make an ARP request to have the client address */ memcpy(slirp->client_ethaddr, eh->h_source, ETH_ALEN); @@ -637,7 +641,7 @@ static void arp_input(Slirp *slirp, const uint8_t *pkt, int pkt_len) rah->ar_sip = ah->ar_tip; memcpy(rah->ar_tha, ah->ar_sha, ETH_ALEN); rah->ar_tip = ah->ar_sip; - slirp_output(slirp->opaque, arp_reply, sizeof(arp_reply)); + slirp_output(slirp->opaque, (const uint8_t *)&arp_reply, sizeof(arp_reply)); } break; case ARPOP_REPLY: