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 <donatas@opensourcerouting.org>
This commit is contained in:
Donatas Abraitis 2024-01-29 16:00:07 +02:00
parent 4821e7a0d8
commit 0804038916

View File

@ -369,6 +369,8 @@ struct bgp_static {
/* Import check status. */ /* Import check status. */
uint8_t valid; uint8_t valid;
uint16_t encap_tunneltype;
/* IGP metric. */ /* IGP metric. */
uint32_t igpmetric; uint32_t igpmetric;
@ -394,7 +396,6 @@ struct bgp_static {
/* EVPN */ /* EVPN */
esi_t *eth_s_id; esi_t *eth_s_id;
struct ethaddr *router_mac; struct ethaddr *router_mac;
uint16_t encap_tunneltype;
struct prefix gatewayIp; struct prefix gatewayIp;
}; };