From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752014AbcDWRGj (ORCPT ); Sat, 23 Apr 2016 13:06:39 -0400 Received: from metis.ext.4.pengutronix.de ([92.198.50.35]:45469 "EHLO metis.ext.4.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751927AbcDWRGi (ORCPT ); Sat, 23 Apr 2016 13:06:38 -0400 Subject: Re: [PATCH net-next 2/9] libnl: nla_put_le64(): align on a 64-bit area To: Eric Dumazet , Nicolas Dichtel References: <1461339084-3849-1-git-send-email-nicolas.dichtel@6wind.com> <1461339084-3849-3-git-send-email-nicolas.dichtel@6wind.com> <1461343880.7627.34.camel@edumazet-glaptop3.roam.corp.google.com> Cc: netdev@vger.kernel.org, davem@davemloft.net, linux-kernel@vger.kernel.org, linux-wpan@vger.kernel.org, pablo@netfilter.org, kaber@trash.net, kadlec@blackhole.kfki.hu, pshelar@nicira.com, kuznet@ms2.inr.ac.ru, jmorris@namei.org, yoshfuji@linux-ipv6.org, netfilter-devel@vger.kernel.org, dev@openvswitch.org, steffen.klassert@secunet.com, herbert@gondor.apana.org.au, bsingharora@gmail.com From: Alexander Aring Message-ID: <60b94d1a-23a2-ec18-7f2b-2ba21946af03@pengutronix.de> Date: Sat, 23 Apr 2016 19:05:41 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 In-Reply-To: <1461343880.7627.34.camel@edumazet-glaptop3.roam.corp.google.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 2001:67c:670:201:5054:ff:fe8d:eefb X-SA-Exim-Mail-From: aar@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 04/22/2016 06:51 PM, Eric Dumazet wrote: > On Fri, 2016-04-22 at 17:31 +0200, Nicolas Dichtel wrote: >> nla_data() is now aligned on a 64-bit area. >> >> Signed-off-by: Nicolas Dichtel >> --- >> include/net/netlink.h | 8 +++++--- >> include/net/nl802154.h | 6 ++++++ >> net/ieee802154/nl802154.c | 13 ++++++++----- >> 3 files changed, 19 insertions(+), 8 deletions(-) >> >> diff --git a/include/net/netlink.h b/include/net/netlink.h >> index 6f51a8a06498..7f6b99483ab7 100644 >> --- a/include/net/netlink.h >> +++ b/include/net/netlink.h >> @@ -878,14 +878,16 @@ static inline int nla_put_net64(struct sk_buff *skb, int attrtype, __be64 value) >> } >> >> /** >> - * nla_put_le64 - Add a __le64 netlink attribute to a socket buffer >> + * nla_put_le64 - Add a __le64 netlink attribute to a socket buffer and align it >> * @skb: socket buffer to add attribute to >> * @attrtype: attribute type >> * @value: numeric value >> + * @padattr: attribute type for the padding >> */ >> -static inline int nla_put_le64(struct sk_buff *skb, int attrtype, __le64 value) >> +static inline int nla_put_le64(struct sk_buff *skb, int attrtype, __le64 value, >> + int padattr) >> { >> - return nla_put(skb, attrtype, sizeof(__le64), &value); >> + return nla_put_64bit(skb, attrtype, sizeof(__le64), &value, padattr); >> } >> > > But _why_ is it needed ? > > nla_put() has no alignment assumptions, it simply copies 8 bytes. > > Seems this is going too far. > if this is really needed, then nla_put_u64/be64/etc need to be changed also, or? The function nla_put_u64 is the same like nla_put_le64 but with __le64 type, so sparse will not complain about that. - Alex