diff options
author | Eric Dumazet <edumazet@google.com> | 2016-04-20 10:31:31 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-04-20 10:53:22 -0400 |
commit | cca1d81574d266d4a3aa33f3947297564525e127 (patch) | |
tree | b90c1cc043aca75be750e0a6dd2b95bdb3046835 | |
parent | b84e93077fe926bc65e23d887b54fc46be60b76e (diff) |
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: 35c5845957c7 ("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>
-rw-r--r-- | include/net/netlink.h | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/include/net/netlink.h b/include/net/netlink.h index e644b3489acf..cf95df1fa14b 100644 --- a/include/net/netlink.h +++ b/include/net/netlink.h | |||
@@ -1238,18 +1238,21 @@ static inline int nla_validate_nested(const struct nlattr *start, int maxtype, | |||
1238 | * Conditionally emit a padding netlink attribute in order to make | 1238 | * Conditionally emit a padding netlink attribute in order to make |
1239 | * the next attribute we emit have a 64-bit aligned nla_data() area. | 1239 | * the next attribute we emit have a 64-bit aligned nla_data() area. |
1240 | * This will only be done in architectures which do not have | 1240 | * This will only be done in architectures which do not have |
1241 | * HAVE_EFFICIENT_UNALIGNED_ACCESS defined. | 1241 | * CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS defined. |
1242 | * | 1242 | * |
1243 | * Returns zero on success or a negative error code. | 1243 | * Returns zero on success or a negative error code. |
1244 | */ | 1244 | */ |
1245 | static inline int nla_align_64bit(struct sk_buff *skb, int padattr) | 1245 | static inline int nla_align_64bit(struct sk_buff *skb, int padattr) |
1246 | { | 1246 | { |
1247 | #ifndef HAVE_EFFICIENT_UNALIGNED_ACCESS | 1247 | #ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS |
1248 | if (IS_ALIGNED((unsigned long)skb->data, 8)) { | 1248 | /* The nlattr header is 4 bytes in size, that's why we test |
1249 | struct nlattr *attr = nla_reserve(skb, padattr, 0); | 1249 | * if the skb->data _is_ aligned. This NOP attribute, plus |
1250 | if (!attr) | 1250 | * nlattr header for next attribute, will make nla_data() |
1251 | return -EMSGSIZE; | 1251 | * 8-byte aligned. |
1252 | } | 1252 | */ |
1253 | if (IS_ALIGNED((unsigned long)skb->data, 8) && | ||
1254 | !nla_reserve(skb, padattr, 0)) | ||
1255 | return -EMSGSIZE; | ||
1253 | #endif | 1256 | #endif |
1254 | return 0; | 1257 | return 0; |
1255 | } | 1258 | } |
@@ -1261,7 +1264,7 @@ static inline int nla_align_64bit(struct sk_buff *skb, int padattr) | |||
1261 | static inline int nla_total_size_64bit(int payload) | 1264 | static inline int nla_total_size_64bit(int payload) |
1262 | { | 1265 | { |
1263 | return NLA_ALIGN(nla_attr_size(payload)) | 1266 | return NLA_ALIGN(nla_attr_size(payload)) |
1264 | #ifndef HAVE_EFFICIENT_UNALIGNED_ACCESS | 1267 | #ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS |
1265 | + NLA_ALIGN(nla_attr_size(0)) | 1268 | + NLA_ALIGN(nla_attr_size(0)) |
1266 | #endif | 1269 | #endif |
1267 | ; | 1270 | ; |