From owner-freebsd-arm@FreeBSD.ORG Thu Nov 14 06:34:43 2013 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9936DD8C; Thu, 14 Nov 2013 06:34:43 +0000 (UTC) Received: from mail-wi0-x22b.google.com (mail-wi0-x22b.google.com [IPv6:2a00:1450:400c:c05::22b]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id E11982095; Thu, 14 Nov 2013 06:34:42 +0000 (UTC) Received: by mail-wi0-f171.google.com with SMTP id hn6so3475370wib.10 for ; Wed, 13 Nov 2013 22:34:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=if1v7LuDWKV9fenvzbAvYSgZZ3Z5gol3/6CBj+nQSCI=; b=lijTwXC1/S17HNTTQhBdwSTTVIukzEa2ErowBrtid8PK9bllMygEPSMNSNpe6E9PB1 ckDQaKbPLNjZ+mIAeo2r8CcO/TB++ZkFYMYXO3jUz13ykGdcTSNA1vm/jhcTJpGuxCqA JbUt9oXnHy7DJZfhZBuSxD4awxOJvVjBNYJnboT/TNKF7CUK5CliODdB5zKKKbREbyVU osqxUs814qy5sXToo1mXv9ijW5iv45gpX6C8ZuoepM9iOxceR2Wh6aJwpnCKwPmXmm8z WFsFfP2zRXH3t/9EMHn1TGGQl/gVFjSbYeO/RqPaEbPjOMDmwjE48/m9Qd2olnFnTbyK CRng== MIME-Version: 1.0 X-Received: by 10.194.78.99 with SMTP id a3mr545919wjx.93.1384410880750; Wed, 13 Nov 2013 22:34:40 -0800 (PST) Received: by 10.216.66.131 with HTTP; Wed, 13 Nov 2013 22:34:40 -0800 (PST) Date: Thu, 14 Nov 2013 08:34:40 +0200 Message-ID: Subject: NETDUMP ARM alignment fault fix From: Boris Astardzhiev To: attilio@freebsd.org, freebsd-net@freebsd.org, freebsd-arm@freebsd.org Content-Type: multipart/mixed; boundary=047d7bf0c48cc552cd04eb1d4631 X-Content-Filtered-By: Mailman/MimeDel 2.1.16 X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Nov 2013 06:34:43 -0000 --047d7bf0c48cc552cd04eb1d4631 Content-Type: text/plain; charset=ISO-8859-1 Hi, I've experienced some alignment faults using NETDUMP on the Sheevaplug ARM board. The function in question is netdump_send_arp(). I've attached a simple fix to it and I'm posting it as it might be of use to someone. diff --git a/sys/netinet/netdump_client.c b/sys/netinet/netdump_client.c index f6e5170..0379c61 100644 --- a/sys/netinet/netdump_client.c +++ b/sys/netinet/netdump_client.c @@ -510,9 +510,11 @@ netdump_send_arp() ah->ar_pln = sizeof(struct in_addr); ah->ar_op = htons(ARPOP_REQUEST); memcpy(ar_sha(ah), IF_LLADDR(nd_nic), ETHER_ADDR_LEN); - ((struct in_addr *)ar_spa(ah))->s_addr = nd_client.s_addr; + memcpy(&(((struct in_addr *)ar_spa(ah))->s_addr), + &nd_client.s_addr, sizeof(nd_client.s_addr)); bzero(ar_tha(ah), ETHER_ADDR_LEN); - ((struct in_addr *)ar_tpa(ah))->s_addr = nd_gw.s_addr; + memcpy(&(((struct in_addr *)ar_tpa(ah))->s_addr), &nd_gw.s_addr, + sizeof(nd_gw.s_addr)); return netdump_ether_output(m, nd_nic, bcast, ETHERTYPE_ARP); } Greetings, Boris --047d7bf0c48cc552cd04eb1d4631 Content-Type: text/plain; charset=US-ASCII; name="armnetdumpalign.diff" Content-Disposition: attachment; filename="armnetdumpalign.diff" Content-Transfer-Encoding: base64 X-Attachment-Id: f_hnzmeefw0 ZGl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