From 0804038916212cf8902595aeab016877e3b08bb2 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Mon, 29 Jan 2024 16:00:07 +0200 Subject: [PATCH] bgpd: Optimize memory usage for bgp_static struct ``` struct bgp_static { int backdoor; /* 0 4 */ uint32_t label_index; /* 4 4 */ uint8_t valid; /* 8 1 */ /* XXX 1 byte hole, try to pack */ uint16_t encap_tunneltype; /* 10 2 */ uint32_t igpmetric; /* 12 4 */ struct in_addr igpnexthop; /* 16 4 */ uint32_t atomic; /* 20 4 */ struct { char * name; /* 24 8 */ struct route_map * map; /* 32 8 */ } rmap; /* 24 16 */ struct prefix_rd prd __attribute__((__aligned__(8))); /* 40 16 */ char * prd_pretty; /* 56 8 */ /* --- cacheline 1 boundary (64 bytes) --- */ mpls_label_t label; /* 64 4 */ /* XXX 4 bytes hole, try to pack */ esi_t * eth_s_id; /* 72 8 */ struct ethaddr * router_mac; /* 80 8 */ struct prefix gatewayIp __attribute__((__aligned__(8))); /* 88 56 */ /* size: 144, cachelines: 3, members: 14 */ /* sum members: 139, holes: 2, sum holes: 5 */ /* forced alignments: 2 */ /* last cacheline: 16 bytes */ } __attribute__((__aligned__(8))); /* saved 8 bytes! */ ``` Signed-off-by: Donatas Abraitis --- bgpd/bgp_route.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h index 0599e8dce1..a3f7ba2d76 100644 --- a/bgpd/bgp_route.h +++ b/bgpd/bgp_route.h @@ -369,6 +369,8 @@ struct bgp_static { /* Import check status. */ uint8_t valid; + uint16_t encap_tunneltype; + /* IGP metric. */ uint32_t igpmetric; @@ -394,7 +396,6 @@ struct bgp_static { /* EVPN */ esi_t *eth_s_id; struct ethaddr *router_mac; - uint16_t encap_tunneltype; struct prefix gatewayIp; }; -- 2.39.5