Skip to contentSkip to conversation

net neighbour,decnet: Ensure to align device private data on preferred alignment.

PATCH Applied YOSHIFUJI Hideaki 2 participants 2 messages Feb 9, 2013 – Feb 11, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net neighbour,decnet: Ensure to align device private data on preferred alignment.

To allow both of protocol-specific data and device-specific data attached with neighbour entry, and to eliminate size calculation cost when allocating entry, sizeof protocol-speicic data must be multiple of NEIGH_PRIV_ALIGN. On 64bit archs, sizeof(struct dn_neigh) is multiple of NEIGH_PRIV_ALIGN, but on 32bit archs, it was not.

Introduce NEIGH_ENTRY_SPACE() macro to ensure that protocol-specific entry-size meets our requirement.

---
 include/net/neighbour.h |    1 +
 net/decnet/dn_neigh.c   |    2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
include/net/neighbour.h +1 -0
index 629ee57..7e748ad 100644
@@ -181,6 +181,7 @@ struct neigh_table {
 };
 
 #define NEIGH_PRIV_ALIGN	sizeof(long long)
+#define NEIGH_ENTRY_SIZE(size)	ALIGN((size), NEIGH_PRIV_ALIGN)
 
 static inline void *neighbour_priv(const struct neighbour *n)
 {
net/decnet/dn_neigh.c +1 -1
index 3aede1b..856636a 100644
@@ -95,7 +95,7 @@ static u32 dn_neigh_hash(const void *pkey,
 
 struct neigh_table dn_neigh_table = {
 	.family =			PF_DECnet,
-	.entry_size =			sizeof(struct dn_neigh),
+	.entry_size =			NEIGH_ENTRY_SIZE(sizeof(struct dn_neigh)),
 	.key_len =			sizeof(__le16),
 	.hash =				dn_neigh_hash,
 	.constructor =			dn_neigh_construct,
Signature · 1 line
1.7.9.5
maintainer Applied
#1 lore raw

From: YOSHIFUJI Hideaki <[email protected]>
Date: Sun, 10 Feb 2013 02:00:59 +0900

Quoted 7 lines

To allow both of protocol-specific data and device-specific data attached with neighbour entry, and to eliminate size calculation cost when allocating entry, sizeof protocol-speicic data must be multiple of NEIGH_PRIV_ALIGN. On 64bit archs, sizeof(struct dn_neigh) is multiple of NEIGH_PRIV_ALIGN, but on 32bit archs, it was not.

Quoted 5 lines

Introduce NEIGH_ENTRY_SPACE() macro to ensure that protocol-specific entry-size meets our requirement.

Applied.