Hi, On Sat, Jun 10, 2017 at 06:16:13PM +0200, Jeremie Courreges-Anglas wrote: > Loaded symbols for /usr/libexec/ld.so > #0 write_tun_header (tt=0x1ddd4e1900, buf=0x1d336921c5 "E", len=84) at > tun.c:1661 > 1661 if (iph->ip_v == 6) > (gdb) > > buf points to an odd address.
That's a single-byte access...? Nothing to be aligned here. On FreeBSD, ip_v is defined as such: * Structure of an internet header, naked of options. */ struct ip { #if BYTE_ORDER == LITTLE_ENDIAN u_char ip_hl:4, /* header length */ ip_v:4; /* version */ #endif #if BYTE_ORDER == BIG_ENDIAN u_char ip_v:4, /* version */ ip_hl:4; /* header length */ #endif ... ... so whatever it is, it's part of a single uchar at the very beginning of that header... strange. OTOH, the compiler might assume 16bit-alignment here and use a 16bit- access to get the first word, then bit-shift (someone who understands sparc64 assembly around to check?) - in this case, the following change should help: old: if (iph->ip_v == 6) new: if (OPENVPN_IPH_GET_VER(*buf) == 6) this is an existing macro which takes an int argument, shifting and masking the right bits, and since *buf is "uint8_t *buf", this should both be correct and alignment-ignorant. It might be less efficient than accessing the bit field - but then, it's the same work to do, so hopefully the compiler is smart enough to compile it to the same instructions. gert -- USENET is *not* the non-clickable part of WWW! //www.muc.de/~gert/ Gert Doering - Munich, Germany g...@greenie.muc.de fax: +49-89-35655025 g...@net.informatik.tu-muenchen.de
signature.asc
Description: PGP signature
------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel