libnl: nla_put_msecs(): align on a 64-bit area
authorNicolas Dichtel <nicolas.dichtel@6wind.com>
Fri, 22 Apr 2016 15:31:21 +0000 (17:31 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sun, 24 Apr 2016 00:13:24 +0000 (20:13 -0400)
nla_data() is now aligned on a 64-bit area.

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/netlink.h
include/uapi/linux/l2tp.h
include/uapi/linux/neighbour.h
include/uapi/linux/tcp_metrics.h
net/core/neighbour.c
net/ipv4/tcp_metrics.c
net/l2tp/l2tp_netlink.c

index 074215a59d194971e132ac978d454b18c0de84c9..113b483b6ee83c897436318e7354c7a301c1a62d 100644 (file)
  *               padattr)              add s64 attribute to skb
  *   nla_put_string(skb, type, str)    add string attribute to skb
  *   nla_put_flag(skb, type)           add flag attribute to skb
- *   nla_put_msecs(skb, type, jiffies) add msecs attribute to skb
+ *   nla_put_msecs(skb, type, jiffies,
+ *                 padattr)            add msecs attribute to skb
  *   nla_put_in_addr(skb, type, addr)  add IPv4 address attribute to skb
  *   nla_put_in6_addr(skb, type, addr) add IPv6 address attribute to skb
  *
@@ -965,16 +966,18 @@ static inline int nla_put_flag(struct sk_buff *skb, int attrtype)
 }
 
 /**
- * nla_put_msecs - Add a msecs netlink attribute to a socket buffer
+ * nla_put_msecs - Add a msecs netlink attribute to a skb and align it
  * @skb: socket buffer to add attribute to
  * @attrtype: attribute type
  * @njiffies: number of jiffies to convert to msecs
+ * @padattr: attribute type for the padding
  */
 static inline int nla_put_msecs(struct sk_buff *skb, int attrtype,
-                               unsigned long njiffies)
+                               unsigned long njiffies, int padattr)
 {
        u64 tmp = jiffies_to_msecs(njiffies);
-       return nla_put(skb, attrtype, sizeof(u64), &tmp);
+
+       return nla_put_64bit(skb, attrtype, sizeof(u64), &tmp, padattr);
 }
 
 /**
index 347ef22a964ee4d112fa31e1974609eb6fb525df..3386a99e03972e50ecc77704504374e272ccd404 100644 (file)
@@ -126,6 +126,7 @@ enum {
        L2TP_ATTR_IP6_DADDR,            /* struct in6_addr */
        L2TP_ATTR_UDP_ZERO_CSUM6_TX,    /* u8 */
        L2TP_ATTR_UDP_ZERO_CSUM6_RX,    /* u8 */
+       L2TP_ATTR_PAD,
        __L2TP_ATTR_MAX,
 };
 
index 788655bfa0f3001d549e90c8fe5dd811600e3a98..bd99a8d80f36e527094f05ceabb55c21ea004ae7 100644 (file)
@@ -128,6 +128,7 @@ enum {
        NDTPA_LOCKTIME,                 /* u64, msecs */
        NDTPA_QUEUE_LENBYTES,           /* u32 */
        NDTPA_MCAST_REPROBES,           /* u32 */
+       NDTPA_PAD,
        __NDTPA_MAX
 };
 #define NDTPA_MAX (__NDTPA_MAX - 1)
@@ -160,6 +161,7 @@ enum {
        NDTA_PARMS,                     /* nested TLV NDTPA_* */
        NDTA_STATS,                     /* struct ndt_stats, read-only */
        NDTA_GC_INTERVAL,               /* u64, msecs */
+       NDTA_PAD,
        __NDTA_MAX
 };
 #define NDTA_MAX (__NDTA_MAX - 1)
index 93533926035ca8d18e08f04eac3adacfcb266d8d..80ad90d0cfc23b0a67b4c6639eaf6df1d2abca25 100644 (file)
@@ -40,6 +40,7 @@ enum {
        TCP_METRICS_ATTR_FOPEN_COOKIE,          /* binary */
        TCP_METRICS_ATTR_SADDR_IPV4,            /* u32 */
        TCP_METRICS_ATTR_SADDR_IPV6,            /* binary */
+       TCP_METRICS_ATTR_PAD,
 
        __TCP_METRICS_ATTR_MAX,
 };
index f18ae91b652e971ccba5c03177301f1a46a8da57..6a395d4402288be0bed26f2a5407db57204997e2 100644 (file)
@@ -1763,21 +1763,22 @@ static int neightbl_fill_parms(struct sk_buff *skb, struct neigh_parms *parms)
                        NEIGH_VAR(parms, MCAST_PROBES)) ||
            nla_put_u32(skb, NDTPA_MCAST_REPROBES,
                        NEIGH_VAR(parms, MCAST_REPROBES)) ||
-           nla_put_msecs(skb, NDTPA_REACHABLE_TIME, parms->reachable_time) ||
+           nla_put_msecs(skb, NDTPA_REACHABLE_TIME, parms->reachable_time,
+                         NDTPA_PAD) ||
            nla_put_msecs(skb, NDTPA_BASE_REACHABLE_TIME,
-                         NEIGH_VAR(parms, BASE_REACHABLE_TIME)) ||
+                         NEIGH_VAR(parms, BASE_REACHABLE_TIME), NDTPA_PAD) ||
            nla_put_msecs(skb, NDTPA_GC_STALETIME,
-                         NEIGH_VAR(parms, GC_STALETIME)) ||
+                         NEIGH_VAR(parms, GC_STALETIME), NDTPA_PAD) ||
            nla_put_msecs(skb, NDTPA_DELAY_PROBE_TIME,
-                         NEIGH_VAR(parms, DELAY_PROBE_TIME)) ||
+                         NEIGH_VAR(parms, DELAY_PROBE_TIME), NDTPA_PAD) ||
            nla_put_msecs(skb, NDTPA_RETRANS_TIME,
-                         NEIGH_VAR(parms, RETRANS_TIME)) ||
+                         NEIGH_VAR(parms, RETRANS_TIME), NDTPA_PAD) ||
            nla_put_msecs(skb, NDTPA_ANYCAST_DELAY,
-                         NEIGH_VAR(parms, ANYCAST_DELAY)) ||
+                         NEIGH_VAR(parms, ANYCAST_DELAY), NDTPA_PAD) ||
            nla_put_msecs(skb, NDTPA_PROXY_DELAY,
-                         NEIGH_VAR(parms, PROXY_DELAY)) ||
+                         NEIGH_VAR(parms, PROXY_DELAY), NDTPA_PAD) ||
            nla_put_msecs(skb, NDTPA_LOCKTIME,
-                         NEIGH_VAR(parms, LOCKTIME)))
+                         NEIGH_VAR(parms, LOCKTIME), NDTPA_PAD))
                goto nla_put_failure;
        return nla_nest_end(skb, nest);
 
@@ -1804,7 +1805,7 @@ static int neightbl_fill_info(struct sk_buff *skb, struct neigh_table *tbl,
        ndtmsg->ndtm_pad2   = 0;
 
        if (nla_put_string(skb, NDTA_NAME, tbl->id) ||
-           nla_put_msecs(skb, NDTA_GC_INTERVAL, tbl->gc_interval) ||
+           nla_put_msecs(skb, NDTA_GC_INTERVAL, tbl->gc_interval, NDTA_PAD) ||
            nla_put_u32(skb, NDTA_THRESH1, tbl->gc_thresh1) ||
            nla_put_u32(skb, NDTA_THRESH2, tbl->gc_thresh2) ||
            nla_put_u32(skb, NDTA_THRESH3, tbl->gc_thresh3))
index 7b7eec4399069249ef949ef4b287e8cd0ef4df91..b617826e24770a09ba07202b3d546ae248b68a50 100644 (file)
@@ -800,7 +800,8 @@ static int tcp_metrics_fill_info(struct sk_buff *msg,
        }
 
        if (nla_put_msecs(msg, TCP_METRICS_ATTR_AGE,
-                         jiffies - tm->tcpm_stamp) < 0)
+                         jiffies - tm->tcpm_stamp,
+                         TCP_METRICS_ATTR_PAD) < 0)
                goto nla_put_failure;
        if (tm->tcpm_ts_stamp) {
                if (nla_put_s32(msg, TCP_METRICS_ATTR_TW_TS_STAMP,
@@ -864,7 +865,8 @@ static int tcp_metrics_fill_info(struct sk_buff *msg,
                    (nla_put_u16(msg, TCP_METRICS_ATTR_FOPEN_SYN_DROPS,
                                tfom->syn_loss) < 0 ||
                     nla_put_msecs(msg, TCP_METRICS_ATTR_FOPEN_SYN_DROP_TS,
-                               jiffies - tfom->last_syn_loss) < 0))
+                               jiffies - tfom->last_syn_loss,
+                               TCP_METRICS_ATTR_PAD) < 0))
                        goto nla_put_failure;
                if (tfom->cookie.len > 0 &&
                    nla_put(msg, TCP_METRICS_ATTR_FOPEN_COOKIE,
index 2caaa84ce92dac811c7813ebbb233c9596d03ca0..24ed2e875c45af8e8a52ddf7d47972607992a1ba 100644 (file)
@@ -746,7 +746,8 @@ static int l2tp_nl_session_send(struct sk_buff *skb, u32 portid, u32 seq, int fl
             nla_put_u8(skb, L2TP_ATTR_USING_IPSEC, 1)) ||
 #endif
            (session->reorder_timeout &&
-            nla_put_msecs(skb, L2TP_ATTR_RECV_TIMEOUT, session->reorder_timeout)))
+            nla_put_msecs(skb, L2TP_ATTR_RECV_TIMEOUT,
+                          session->reorder_timeout, L2TP_ATTR_PAD)))
                goto nla_put_failure;
 
        nest = nla_nest_start(skb, L2TP_ATTR_STATS);