Skip to content

Commit cca1d81

Browse files
edumazetdavem330
authored andcommitted
net: fix HAVE_EFFICIENT_UNALIGNED_ACCESS typos
HAVE_EFFICIENT_UNALIGNED_ACCESS needs CONFIG_ prefix. Also add a comment in nla_align_64bit() explaining we have to add a padding if current skb->data is aligned, as it certainly can be confusing. Fixes: 35c5845 ("net: Add helpers for 64-bit aligning netlink attributes.") Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent b84e930 commit cca1d81

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

include/net/netlink.h

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,18 +1238,21 @@ static inline int nla_validate_nested(const struct nlattr *start, int maxtype,
12381238
* Conditionally emit a padding netlink attribute in order to make
12391239
* the next attribute we emit have a 64-bit aligned nla_data() area.
12401240
* This will only be done in architectures which do not have
1241-
* HAVE_EFFICIENT_UNALIGNED_ACCESS defined.
1241+
* CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS defined.
12421242
*
12431243
* Returns zero on success or a negative error code.
12441244
*/
12451245
static inline int nla_align_64bit(struct sk_buff *skb, int padattr)
12461246
{
1247-
#ifndef HAVE_EFFICIENT_UNALIGNED_ACCESS
1248-
if (IS_ALIGNED((unsigned long)skb->data, 8)) {
1249-
struct nlattr *attr = nla_reserve(skb, padattr, 0);
1250-
if (!attr)
1251-
return -EMSGSIZE;
1252-
}
1247+
#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
1248+
/* The nlattr header is 4 bytes in size, that's why we test
1249+
* if the skb->data _is_ aligned. This NOP attribute, plus
1250+
* nlattr header for next attribute, will make nla_data()
1251+
* 8-byte aligned.
1252+
*/
1253+
if (IS_ALIGNED((unsigned long)skb->data, 8) &&
1254+
!nla_reserve(skb, padattr, 0))
1255+
return -EMSGSIZE;
12531256
#endif
12541257
return 0;
12551258
}
@@ -1261,7 +1264,7 @@ static inline int nla_align_64bit(struct sk_buff *skb, int padattr)
12611264
static inline int nla_total_size_64bit(int payload)
12621265
{
12631266
return NLA_ALIGN(nla_attr_size(payload))
1264-
#ifndef HAVE_EFFICIENT_UNALIGNED_ACCESS
1267+
#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
12651268
+ NLA_ALIGN(nla_attr_size(0))
12661269
#endif
12671270
;

0 commit comments

Comments
 (0)