Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

YOSHIFUJI Hideaki / 吉藤英明 and committed by
David S. Miller
daaba4fa ec16ef22

+2 -1
+1
include/net/neighbour.h
··· 181 181 }; 182 182 183 183 #define NEIGH_PRIV_ALIGN sizeof(long long) 184 + #define NEIGH_ENTRY_SIZE(size) ALIGN((size), NEIGH_PRIV_ALIGN) 184 185 185 186 static inline void *neighbour_priv(const struct neighbour *n) 186 187 {
+1 -1
net/decnet/dn_neigh.c
··· 95 95 96 96 struct neigh_table dn_neigh_table = { 97 97 .family = PF_DECnet, 98 - .entry_size = sizeof(struct dn_neigh), 98 + .entry_size = NEIGH_ENTRY_SIZE(sizeof(struct dn_neigh)), 99 99 .key_len = sizeof(__le16), 100 100 .hash = dn_neigh_hash, 101 101 .constructor = dn_neigh_construct,