From: Lutz Jaenicke Date: Thu, 30 Aug 2012 05:01:34 +0000 (+0000) Subject: rtnl_wilddump_request: fix alignment issue for embedded platforms X-Git-Tag: v3.8.0~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=257422f77fc2a11429a3f86dea0a740752d15d19;p=thirdparty%2Fiproute2.git rtnl_wilddump_request: fix alignment issue for embedded platforms Platforms have different alignment requirements which need to be fulfilled by the compiler. If the structure elements are already 4 byte (NLMGS_ALIGNTO) aligned by the compiler adding an explicit padding element (align_rta) is not allowed. Use __attribute__ ((aligned (NLMSG_ALIGNTO))) in order to achieve the required alignment. Experienced on ARM (xscale) with symptom netlink: 12 bytes leftover after parsing attributes Tested on: ARM (32bit Big Endian) PowerPC (32bit Big Endian) x86_64 (64bit Little Endian) Each with different aligment requirments. Signed-off-by: Lutz Jaenicke --- diff --git a/lib/libnetlink.c b/lib/libnetlink.c index 8e8c8b9e5..09b427784 100644 --- a/lib/libnetlink.c +++ b/lib/libnetlink.c @@ -94,8 +94,8 @@ int rtnl_wilddump_request(struct rtnl_handle *rth, int family, int type) struct { struct nlmsghdr nlh; struct rtgenmsg g; - __u16 align_rta; /* attribute has to be 32bit aligned */ - struct rtattr ext_req; + /* attribute has to be NLMSG aligned */ + struct rtattr ext_req __attribute__ ((aligned(NLMSG_ALIGNTO))); __u32 ext_filter_mask; } req;