diff options
author | Robert Shearman <rshearma@brocade.com> | 2015-10-27 00:37:36 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-10-27 19:52:59 -0700 |
commit | cf4b24f0024fc2e3fbc653a659356d224b5b9172 (patch) | |
tree | 131a351e670f5d86c725c9e140acee1c93b11ce9 /fs/btrfs | |
parent | b4e04fc7357b6cef0856cb14b42306af1af990e5 (diff) |
mpls: reduce memory usage of routes
Nexthops for MPLS routes have a via address field sized for the
largest via address that is expected, which is 32 bytes. This means
that in the most common case of having ipv4 via addresses, 28 bytes of
memory more than required are used per nexthop. In the other common
case of an ipv6 nexthop then 16 bytes more than required are
used. With large numbers of MPLS routes this extra memory usage could
start to become significant.
To avoid allocating memory for a maximum length via address when not
all of it is required and to allow for ease of iterating over
nexthops, then the via addresses are changed to be stored in the same
memory block as the route and nexthops, but in an array after the end
of the array of nexthops. New accessors are provided to retrieve a
pointer to the via address.
To allow for O(1) access without having to store a pointer or offset
per nh, the via address for each nexthop is sized according to the
maximum via address for any nexthop in the route, which is stored in a
new route field, rt_max_alen, but this is in an existing hole in
struct mpls_route so it doesn't increase the size of the
structure. Each via address is ensured to be aligned to VIA_ALEN_ALIGN
to account for architectures that don't allow unaligned accesses.
Signed-off-by: Robert Shearman <rshearma@brocade.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'fs/btrfs')
0 files changed, 0 insertions, 0 deletions