All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, linux-kernel@vger.kernel.org,
	linux-wpan@vger.kernel.org, aar@pengutronix.de,
	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,
	Nicolas Dichtel <nicolas.dichtel@6wind.com>
Subject: [PATCH net-next 8/9] xfrm: align nlattr properly when needed
Date: Fri, 22 Apr 2016 17:31:23 +0200	[thread overview]
Message-ID: <1461339084-3849-9-git-send-email-nicolas.dichtel@6wind.com> (raw)
In-Reply-To: <1461339084-3849-1-git-send-email-nicolas.dichtel@6wind.com>

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 include/uapi/linux/xfrm.h |  1 +
 net/xfrm/xfrm_user.c      | 10 ++++++----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/include/uapi/linux/xfrm.h b/include/uapi/linux/xfrm.h
index 2cd9e608d0d1..143338978b48 100644
--- a/include/uapi/linux/xfrm.h
+++ b/include/uapi/linux/xfrm.h
@@ -302,6 +302,7 @@ enum xfrm_attr_type_t {
 	XFRMA_SA_EXTRA_FLAGS,	/* __u32 */
 	XFRMA_PROTO,		/* __u8 */
 	XFRMA_ADDRESS_FILTER,	/* struct xfrm_address_filter */
+	XFRMA_PAD,
 	__XFRMA_MAX
 
 #define XFRMA_MAX (__XFRMA_MAX - 1)
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 2cc7af858c6f..d516845e16e3 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -809,7 +809,8 @@ static int copy_to_user_state_extra(struct xfrm_state *x,
 			goto out;
 	}
 	if (x->lastused) {
-		ret = nla_put_u64(skb, XFRMA_LASTUSED, x->lastused);
+		ret = nla_put_u64_64bit(skb, XFRMA_LASTUSED, x->lastused,
+					XFRMA_PAD);
 		if (ret)
 			goto out;
 	}
@@ -1813,7 +1814,7 @@ static inline size_t xfrm_aevent_msgsize(struct xfrm_state *x)
 
 	return NLMSG_ALIGN(sizeof(struct xfrm_aevent_id))
 	       + nla_total_size(replay_size)
-	       + nla_total_size(sizeof(struct xfrm_lifetime_cur))
+	       + nla_total_size_64bit(sizeof(struct xfrm_lifetime_cur))
 	       + nla_total_size(sizeof(struct xfrm_mark))
 	       + nla_total_size(4) /* XFRM_AE_RTHR */
 	       + nla_total_size(4); /* XFRM_AE_ETHR */
@@ -1848,7 +1849,8 @@ static int build_aevent(struct sk_buff *skb, struct xfrm_state *x, const struct
 	}
 	if (err)
 		goto out_cancel;
-	err = nla_put(skb, XFRMA_LTIME_VAL, sizeof(x->curlft), &x->curlft);
+	err = nla_put_64bit(skb, XFRMA_LTIME_VAL, sizeof(x->curlft), &x->curlft,
+			    XFRMA_PAD);
 	if (err)
 		goto out_cancel;
 
@@ -2617,7 +2619,7 @@ static inline size_t xfrm_sa_len(struct xfrm_state *x)
 		l += nla_total_size(sizeof(x->props.extra_flags));
 
 	/* Must count x->lastused as it may become non-zero behind our back. */
-	l += nla_total_size(sizeof(u64));
+	l += nla_total_size_64bit(sizeof(u64));
 
 	return l;
 }
-- 
2.8.1

  parent reply	other threads:[~2016-04-22 15:43 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-22 15:31 [PATCH net-next 0/9] netlink: align attributes when needed (patchset #1) Nicolas Dichtel
2016-04-22 15:31 ` [PATCH net-next 1/9] libnl: fix help of _64bit functions Nicolas Dichtel
2016-04-22 15:31 ` [PATCH net-next 2/9] libnl: nla_put_le64(): align on a 64-bit area Nicolas Dichtel
2016-04-22 16:51   ` Eric Dumazet
2016-04-22 16:51     ` Eric Dumazet
2016-04-23 17:05     ` Alexander Aring
2016-04-23 17:28       ` Alexander Aring
2016-04-25  7:41         ` Nicolas Dichtel
2016-04-25  7:41           ` Nicolas Dichtel
2016-04-22 15:31 ` [PATCH net-next 3/9] libnl: nla_put_be64(): " Nicolas Dichtel
2016-04-22 15:31 ` [PATCH net-next 4/9] libnl: nla_put_net64(): " Nicolas Dichtel
2016-04-22 15:31 ` [PATCH net-next 5/9] libnl: nla_put_s64(): " Nicolas Dichtel
2016-04-22 15:31   ` Nicolas Dichtel
2016-04-22 15:31 ` [PATCH net-next 6/9] libnl: nla_put_msecs(): " Nicolas Dichtel
2016-04-22 15:31   ` Nicolas Dichtel
2016-04-22 15:31 ` [PATCH net-next 7/9] libnl: add nla_put_u64_64bit() helper Nicolas Dichtel
2016-04-22 15:31 ` Nicolas Dichtel [this message]
2016-04-22 15:31 ` [PATCH net-next 9/9] taskstats: use the libnl API to align nlattr on 64-bit Nicolas Dichtel
2016-04-27  1:14   ` Balbir Singh
2016-04-27  1:14     ` Balbir Singh
2016-04-27  7:29     ` Nicolas Dichtel
2016-04-27  7:29       ` Nicolas Dichtel
2016-04-27 12:29       ` Balbir Singh
2016-04-27 12:29         ` Balbir Singh
2016-04-27 15:46         ` Nicolas Dichtel
2016-04-27 15:46           ` Nicolas Dichtel
2016-04-27 15:47           ` [PATCH net-next] taskstats: fix nl parsing in accounting/getdelays.c Nicolas Dichtel
2016-04-27 15:49             ` Nicolas Dichtel
2016-04-27 15:49               ` Nicolas Dichtel
2016-04-27 15:53               ` [PATCH net-next v2] " Nicolas Dichtel
2016-04-27 15:53                 ` Nicolas Dichtel
2016-04-27 16:56                 ` David Miller
2016-04-27 16:56                   ` David Miller
2016-04-27 16:41         ` [PATCH net-next 9/9] taskstats: use the libnl API to align nlattr on 64-bit David Miller
2016-04-24  0:13 ` [PATCH net-next 0/9] netlink: align attributes when needed (patchset #1) David Miller
2016-04-24  0:13   ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1461339084-3849-9-git-send-email-nicolas.dichtel@6wind.com \
    --to=nicolas.dichtel@6wind.com \
    --cc=aar@pengutronix.de \
    --cc=bsingharora@gmail.com \
    --cc=davem@davemloft.net \
    --cc=dev@openvswitch.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=jmorris@namei.org \
    --cc=kaber@trash.net \
    --cc=kadlec@blackhole.kfki.hu \
    --cc=kuznet@ms2.inr.ac.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wpan@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    --cc=pshelar@nicira.com \
    --cc=steffen.klassert@secunet.com \
    --cc=yoshfuji@linux-ipv6.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.