]> git.baikalelectronics.ru Git - kernel.git/commit
ipv4: nexthop: Reduce allocation size of 'struct nh_group'
authorIdo Schimmel <idosch@nvidia.com>
Wed, 26 Aug 2020 16:48:51 +0000 (19:48 +0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 26 Aug 2020 23:00:51 +0000 (16:00 -0700)
commit4a190c591e1b0dcbc5458c018799764832505c79
tree2958bcbc5c645f138d841e624b66122f056b6900
parentab080f6d0c434e3a59f641100e776009467e20be
ipv4: nexthop: Reduce allocation size of 'struct nh_group'

The struct looks as follows:

struct nh_group {
struct nh_group *spare; /* spare group for removals */
u16 num_nh;
bool mpath;
bool fdb_nh;
bool has_v4;
struct nh_grp_entry nh_entries[];
};

But its offset within 'struct nexthop' is also taken into account to
determine the allocation size.

Instead, use struct_size() to allocate only the required number of
bytes.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/nexthop.c