Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Nov 2013 08:34:40 +0200
From:      Boris Astardzhiev <boris.astardzhiev@gmail.com>
To:        attilio@freebsd.org, freebsd-net@freebsd.org, freebsd-arm@freebsd.org
Subject:   NETDUMP ARM alignment fault fix
Message-ID:  <CAP=KkTwCcK9_QrCKw2Hog7WvL2J6LJvZFj=eNtESOvVPPwGKcw@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
--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

ZGlmZiAtLWdpdCBhL3N5cy9uZXRpbmV0L25ldGR1bX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