Christian Weisgerber <na...@mips.inka.de> wrote:

> As a separate issue, tcpdump wants packets to be aligned to
> sizeof(long) bytes.  I guess what it gets from pcap is 4-byte
> aligned, so on LP64 archs all packets are treated as misaligned.
> I strongly suspect it should just check for 4-byte alignment, but
> haven't looked closely yet.

If anybody wants to try it, here's the switch to requiring only
four-byte alignment.  It survived a first test on my sparc64, but
that was only Ethernet and very few protocols.

I grepped over the source for long, long long, and int64_t, and
apart from one iffy access in print-gtp.c I didn't spot anything
that looked problematic.

Index: print-atalk.c
===================================================================
RCS file: /cvs/src/usr.sbin/tcpdump/print-atalk.c,v
retrieving revision 1.26
diff -u -p -r1.26 print-atalk.c
--- print-atalk.c       27 Oct 2009 23:59:55 -0000      1.26
+++ print-atalk.c       17 Sep 2011 16:05:55 -0000
@@ -219,7 +219,7 @@ ddp_print(register const u_char *bp, reg
          register u_short snet, register u_char snode, u_char skt)
 {
 
-       if ((intptr_t)bp & (sizeof(long)-1)) {
+       if ((intptr_t)bp & (sizeof(int32_t)-1)) {
                static u_char *abuf = NULL;
                int clen = snapend - bp;
                if (clen > snaplen)
Index: print-ip.c
===================================================================
RCS file: /cvs/src/usr.sbin/tcpdump/print-ip.c,v
retrieving revision 1.36
diff -u -p -r1.36 print-ip.c
--- print-ip.c  12 Jan 2010 06:10:33 -0000      1.36
+++ print-ip.c  17 Sep 2011 16:05:13 -0000
@@ -365,7 +365,7 @@ ip_print(register const u_char *bp, regi
         * This will never happen with BPF.  It does happen with raw packet
         * dumps from -r.
         */
-       if ((intptr_t)ip & (sizeof(long)-1)) {
+       if ((intptr_t)ip & (sizeof(int32_t)-1)) {
                static u_char *abuf = NULL;
                static int didwarn = 0;
                int clen = snapend - bp;
Index: print-ip6.c
===================================================================
RCS file: /cvs/src/usr.sbin/tcpdump/print-ip6.c,v
retrieving revision 1.14
diff -u -p -r1.14 print-ip6.c
--- print-ip6.c 27 Jun 2011 16:54:14 -0000      1.14
+++ print-ip6.c 17 Sep 2011 16:05:43 -0000
@@ -67,7 +67,7 @@ ip6_print(register const u_char *bp, reg
         * This will never happen with BPF.  It does happen with
         * raw packet dumps from -r.
         */
-       if ((intptr_t)ip6 & (sizeof(long)-1)) {
+       if ((intptr_t)ip6 & (sizeof(int32_t)-1)) {
                static u_char *abuf = NULL;
                static int didwarn = 0;
                int clen = snapend - bp;
-- 
Christian "naddy" Weisgerber                          na...@mips.inka.de

Reply via email to