Skip to content

Commit

Permalink
netlink: use 48 byte ctx instead of 6 signed longs for callback
Browse files Browse the repository at this point in the history
People are inclined to stuff random things into cb->args[n] because it
looks like an array of integers. Sometimes people even put u64s in there
with comments noting that a certain member takes up two slots. The
horror! Really this should mirror the usage of skb->cb, which are just
48 opaque bytes suitable for casting a struct. Then people can create
their usual casting macros for accessing strongly typed members of a
struct.

As a plus, this also gives us the same amount of space on 32bit and 64bit.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jason A. Donenfeld authored and David S. Miller committed Jul 2, 2019
1 parent 53962bc commit 362b87f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion include/linux/netlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,14 @@ struct netlink_callback {
bool strict_check;
u16 answer_flags;
unsigned int prev_seq, seq;
long args[6];
union {
u8 ctx[48];

/* args is deprecated. Cast a struct over ctx instead
* for proper type safety.
*/
long args[6];
};
};

struct netlink_notify {
Expand Down

0 comments on commit 362b87f

Please sign in to comment.