Skip to content

Commit

Permalink
net neighbour, decnet: Ensure to align device private data on preferr…
Browse files Browse the repository at this point in the history
…ed 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 <[email protected]>
Signed-off-by: YOSHIFUJI Hideaki <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
yoshfuji authored and davem330 committed Feb 11, 2013
1 parent ec16ef2 commit daaba4f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/net/neighbour.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion net/decnet/dn_neigh.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit daaba4f

Please sign in to comment.