Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8d9ea160 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'nla_align-more'



Nicolas Dichtel says:

====================
netlink: align attributes when needed (patchset #1)

This is the continuation of the work done to align netlink attributes
when these attributes contain some 64-bit fields.

David, if the third patch is too big (or maybe the series), I can split it.
Just tell me what you prefer.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 1602f49b 80df5542
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -351,7 +351,8 @@ ip_set_put_skbinfo(struct sk_buff *skb, struct ip_set_skbinfo *skbinfo)
	return ((skbinfo->skbmark || skbinfo->skbmarkmask) &&
		nla_put_net64(skb, IPSET_ATTR_SKBMARK,
			      cpu_to_be64((u64)skbinfo->skbmark << 32 |
					  skbinfo->skbmarkmask))) ||
					  skbinfo->skbmarkmask),
			      IPSET_ATTR_PAD)) ||
	       (skbinfo->skbprio &&
		nla_put_net32(skb, IPSET_ATTR_SKBPRIO,
			      cpu_to_be32(skbinfo->skbprio))) ||
@@ -374,9 +375,11 @@ static inline bool
ip_set_put_counter(struct sk_buff *skb, struct ip_set_counter *counter)
{
	return nla_put_net64(skb, IPSET_ATTR_BYTES,
			     cpu_to_be64(ip_set_get_bytes(counter))) ||
			     cpu_to_be64(ip_set_get_bytes(counter)),
			     IPSET_ATTR_PAD) ||
	       nla_put_net64(skb, IPSET_ATTR_PACKETS,
			     cpu_to_be64(ip_set_get_packets(counter)));
			     cpu_to_be64(ip_set_get_packets(counter)),
			     IPSET_ATTR_PAD);
}

static inline void
+43 −17
Original line number Diff line number Diff line
@@ -102,10 +102,12 @@
 *   nla_put_s8(skb, type, value)	add s8 attribute to skb
 *   nla_put_s16(skb, type, value)	add s16 attribute to skb
 *   nla_put_s32(skb, type, value)	add s32 attribute to skb
 *   nla_put_s64(skb, type, value)	add s64 attribute to skb
 *   nla_put_s64(skb, type, value,
 *               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
 *
@@ -856,36 +858,56 @@ static inline int nla_put_u64(struct sk_buff *skb, int attrtype, u64 value)
}

/**
 * nla_put_be64 - Add a __be64 netlink attribute to a socket buffer
 * nla_put_u64_64bit - Add a u64 netlink attribute to a skb 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_be64(struct sk_buff *skb, int attrtype, __be64 value)
static inline int nla_put_u64_64bit(struct sk_buff *skb, int attrtype,
				    u64 value, int padattr)
{
	return nla_put(skb, attrtype, sizeof(__be64), &value);
	return nla_put_64bit(skb, attrtype, sizeof(u64), &value, padattr);
}

/**
 * nla_put_net64 - Add 64-bit network byte order netlink attribute to a socket buffer
 * nla_put_be64 - Add a __be64 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_net64(struct sk_buff *skb, int attrtype, __be64 value)
static inline int nla_put_be64(struct sk_buff *skb, int attrtype, __be64 value,
			       int padattr)
{
	return nla_put_be64(skb, attrtype | NLA_F_NET_BYTEORDER, value);
	return nla_put_64bit(skb, attrtype, sizeof(__be64), &value, padattr);
}

/**
 * nla_put_le64 - Add a __le64 netlink attribute to a socket buffer
 * nla_put_net64 - Add 64-bit network byte order nlattr to a skb 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_net64(struct sk_buff *skb, int attrtype, __be64 value,
				int padattr)
{
	return nla_put(skb, attrtype, sizeof(__le64), &value);
	return nla_put_be64(skb, attrtype | NLA_F_NET_BYTEORDER, value,
			    padattr);
}

/**
 * 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,
			       int padattr)
{
	return nla_put_64bit(skb, attrtype, sizeof(__le64), &value, padattr);
}

/**
@@ -922,14 +944,16 @@ static inline int nla_put_s32(struct sk_buff *skb, int attrtype, s32 value)
}

/**
 * nla_put_s64 - Add a s64 netlink attribute to a socket buffer
 * nla_put_s64 - Add a s64 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_s64(struct sk_buff *skb, int attrtype, s64 value)
static inline int nla_put_s64(struct sk_buff *skb, int attrtype, s64 value,
			      int padattr)
{
	return nla_put(skb, attrtype, sizeof(s64), &value);
	return nla_put_64bit(skb, attrtype, sizeof(s64), &value, padattr);
}

/**
@@ -955,16 +979,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);
}

/**
+6 −0
Original line number Diff line number Diff line
@@ -138,6 +138,8 @@ enum nl802154_attrs {
	NL802154_ATTR_SEC_KEY,
#endif /* CONFIG_IEEE802154_NL802154_EXPERIMENTAL */

	NL802154_ATTR_PAD,

	__NL802154_ATTR_AFTER_LAST,
	NL802154_ATTR_MAX = __NL802154_ATTR_AFTER_LAST - 1
};
@@ -295,6 +297,7 @@ enum nl802154_dev_addr_attrs {
	NL802154_DEV_ADDR_ATTR_MODE,
	NL802154_DEV_ADDR_ATTR_SHORT,
	NL802154_DEV_ADDR_ATTR_EXTENDED,
	NL802154_DEV_ADDR_ATTR_PAD,

	/* keep last */
	__NL802154_DEV_ADDR_ATTR_AFTER_LAST,
@@ -320,6 +323,7 @@ enum nl802154_key_id_attrs {
	NL802154_KEY_ID_ATTR_IMPLICIT,
	NL802154_KEY_ID_ATTR_SOURCE_SHORT,
	NL802154_KEY_ID_ATTR_SOURCE_EXTENDED,
	NL802154_KEY_ID_ATTR_PAD,

	/* keep last */
	__NL802154_KEY_ID_ATTR_AFTER_LAST,
@@ -402,6 +406,7 @@ enum nl802154_dev {
	NL802154_DEV_ATTR_EXTENDED_ADDR,
	NL802154_DEV_ATTR_SECLEVEL_EXEMPT,
	NL802154_DEV_ATTR_KEY_MODE,
	NL802154_DEV_ATTR_PAD,

	/* keep last */
	__NL802154_DEV_ATTR_AFTER_LAST,
@@ -414,6 +419,7 @@ enum nl802154_devkey {
	NL802154_DEVKEY_ATTR_FRAME_COUNTER,
	NL802154_DEVKEY_ATTR_EXTENDED_ADDR,
	NL802154_DEVKEY_ATTR_ID,
	NL802154_DEVKEY_ATTR_PAD,

	/* keep last */
	__NL802154_DEVKEY_ATTR_AFTER_LAST,
+1 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ enum {
	FRA_TABLE,	/* Extended table id */
	FRA_FWMASK,	/* mask for netfilter mark */
	FRA_OIFNAME,
	FRA_PAD,
	__FRA_MAX
};

+1 −0
Original line number Diff line number Diff line
@@ -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,
};

Loading