diff options
| author | Donatas Abraitis <donatas@opensourcerouting.org> | 2024-01-29 15:56:07 +0200 |
|---|---|---|
| committer | Donatas Abraitis <donatas@opensourcerouting.org> | 2024-01-30 08:12:58 +0200 |
| commit | 4821e7a0d88ce1a70c1a27398b040817e5941238 (patch) | |
| tree | 33b41c92f17ea466ddae65ad9093b0f3b3715ea2 /bgpd/bgp_attr.h | |
| parent | 89e124f042f514b5ce0e3dc39796613152e225b8 (diff) | |
bgpd: Optimize memory usage for attr struct
```
struct attr {
struct aspath * aspath; /* 0 8 */
struct community * community; /* 8 8 */
long unsigned int refcnt; /* 16 8 */
_uint64_t flag; /* 24 8 */
struct in_addr nexthop; /* 32 4 */
uint32_t med; /* 36 4 */
uint32_t local_pref; /* 40 4 */
ifindex_t nh_ifindex; /* 44 4 */
uint8_t origin; /* 48 1 */
uint8_t es_flags; /* 49 1 */
uint8_t router_flag; /* 50 1 */
uint8_t default_gw; /* 51 1 */
enum pta_type pmsi_tnl_type; /* 52 4 */
uint32_t rmap_change_flags; /* 56 4 */
struct in6_addr mp_nexthop_global; /* 60 16 */
/* --- cacheline 1 boundary (64 bytes) was 12 bytes ago --- */
struct in6_addr mp_nexthop_local; /* 76 16 */
ifindex_t nh_lla_ifindex; /* 92 4 */
struct ecommunity * ecommunity; /* 96 8 */
struct ecommunity * ipv6_ecommunity; /* 104 8 */
struct lcommunity * lcommunity; /* 112 8 */
struct cluster_list * cluster1; /* 120 8 */
/* --- cacheline 2 boundary (128 bytes) --- */
struct transit * transit; /* 128 8 */
struct in_addr mp_nexthop_global_in; /* 136 4 */
struct in_addr aggregator_addr; /* 140 4 */
struct in_addr originator_id; /* 144 4 */
uint32_t weight; /* 148 4 */
as_t aggregator_as; /* 152 4 */
uint8_t mp_nexthop_len; /* 156 1 */
uint8_t mp_nexthop_prefer_global; /* 157 1 */
uint8_t sticky; /* 158 1 */
uint8_t distance; /* 159 1 */
uint16_t encap_tunneltype; /* 160 2 */
uint8_t df_alg; /* 162 1 */
/* XXX 1 byte hole, try to pack */
route_tag_t tag; /* 164 4 */
uint32_t label_index; /* 168 4 */
mpls_label_t label; /* 172 4 */
struct bgp_attr_srv6_vpn * srv6_vpn; /* 176 8 */
struct bgp_attr_srv6_l3vpn * srv6_l3vpn; /* 184 8 */
/* --- cacheline 3 boundary (192 bytes) --- */
struct bgp_attr_encap_subtlv * encap_subtlvs; /* 192 8 */
struct bgp_attr_encap_subtlv * vnc_subtlvs; /* 200 8 */
struct bgp_route_evpn evpn_overlay; /* 208 36 */
uint32_t mm_seqnum; /* 244 4 */
uint32_t mm_sync_seqnum; /* 248 4 */
struct ethaddr rmac; /* 252 6 */
/* --- cacheline 4 boundary (256 bytes) was 2 bytes ago --- */
uint16_t df_pref; /* 258 2 */
uint32_t rmap_table_id; /* 260 4 */
uint32_t link_bw; /* 264 4 */
esi_t esi; /* 268 10 */
/* XXX 2 bytes hole, try to pack */
uint32_t srte_color; /* 280 4 */
uint32_t otc; /* 284 4 */
enum nexthop_types_t nh_type; /* 288 4 */
enum blackhole_type bh_type; /* 292 4 */
_uint64_t aigp_metric; /* 296 8 */
/* size: 304, cachelines: 5, members: 53 */
/* sum members: 301, holes: 2, sum holes: 3 */
/* last cacheline: 48 bytes */
}; /* saved 16 bytes! */
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
Diffstat (limited to 'bgpd/bgp_attr.h')
| -rw-r--r-- | bgpd/bgp_attr.h | 87 |
1 files changed, 44 insertions, 43 deletions
diff --git a/bgpd/bgp_attr.h b/bgpd/bgp_attr.h index d30155e6db..9ac0c9854d 100644 --- a/bgpd/bgp_attr.h +++ b/bgpd/bgp_attr.h @@ -159,6 +159,45 @@ struct attr { /* Path origin attribute */ uint8_t origin; + /* ES info */ + uint8_t es_flags; + /* Path is not "locally-active" on the advertising VTEP. This is + * translated into an ARP-ND ECOM. + */ +#define ATTR_ES_PROXY_ADVERT (1 << 0) + /* Destination ES is present locally. This flag is set on local + * paths and sync paths + */ +#define ATTR_ES_IS_LOCAL (1 << 1) + /* There are one or more non-best paths from ES peers. Note that + * this flag is only set on the local MAC-IP paths in the VNI + * route table (not set in the global routing table). And only + * non-proxy advertisements from an ES peer can result in this + * flag being set. + */ +#define ATTR_ES_PEER_ACTIVE (1 << 2) + /* There are one or more non-best proxy paths from ES peers */ +#define ATTR_ES_PEER_PROXY (1 << 3) + /* An ES peer has router bit set - only applicable if + * ATTR_ES_PEER_ACTIVE is set + */ +#define ATTR_ES_PEER_ROUTER (1 << 4) + + /* These two flags are only set on L3 routes installed in a + * VRF as a result of EVPN MAC-IP route + * XXX - while splitting up per-family attrs these need to be + * classified as non-EVPN + */ +#define ATTR_ES_L3_NHG_USE (1 << 5) +#define ATTR_ES_L3_NHG_ACTIVE (1 << 6) +#define ATTR_ES_L3_NHG (ATTR_ES_L3_NHG_USE | ATTR_ES_L3_NHG_ACTIVE) + + /* NA router flag (R-bit) support in EVPN */ + uint8_t router_flag; + + /* Distance as applied by Route map */ + uint8_t distance; + /* PMSI tunnel type (RFC 6514). */ enum pta_type pmsi_tnl_type; @@ -214,42 +253,6 @@ struct attr { /* Flag for default gateway extended community in EVPN */ uint8_t default_gw; - /* NA router flag (R-bit) support in EVPN */ - uint8_t router_flag; - - /* ES info */ - uint8_t es_flags; - /* Path is not "locally-active" on the advertising VTEP. This is - * translated into an ARP-ND ECOM. - */ -#define ATTR_ES_PROXY_ADVERT (1 << 0) - /* Destination ES is present locally. This flag is set on local - * paths and sync paths - */ -#define ATTR_ES_IS_LOCAL (1 << 1) - /* There are one or more non-best paths from ES peers. Note that - * this flag is only set on the local MAC-IP paths in the VNI - * route table (not set in the global routing table). And only - * non-proxy advertisements from an ES peer can result in this - * flag being set. - */ -#define ATTR_ES_PEER_ACTIVE (1 << 2) - /* There are one or more non-best proxy paths from ES peers */ -#define ATTR_ES_PEER_PROXY (1 << 3) - /* An ES peer has router bit set - only applicable if - * ATTR_ES_PEER_ACTIVE is set - */ -#define ATTR_ES_PEER_ROUTER (1 << 4) - - /* These two flags are only set on L3 routes installed in a - * VRF as a result of EVPN MAC-IP route - * XXX - while splitting up per-family attrs these need to be - * classified as non-EVPN - */ -#define ATTR_ES_L3_NHG_USE (1 << 5) -#define ATTR_ES_L3_NHG_ACTIVE (1 << 6) -#define ATTR_ES_L3_NHG (ATTR_ES_L3_NHG_USE | ATTR_ES_L3_NHG_ACTIVE) - /* route tag */ route_tag_t tag; @@ -259,13 +262,16 @@ struct attr { /* MPLS label */ mpls_label_t label; + /* EVPN DF preference for DF election on local ESs */ + uint16_t df_pref; + uint8_t df_alg; + /* SRv6 VPN SID */ struct bgp_attr_srv6_vpn *srv6_vpn; /* SRv6 L3VPN SID */ struct bgp_attr_srv6_l3vpn *srv6_l3vpn; - uint16_t encap_tunneltype; /* grr */ struct bgp_attr_encap_subtlv *encap_subtlvs; /* rfc5512 */ #ifdef ENABLE_BGP_VNC @@ -287,8 +293,7 @@ struct attr { /* EVPN local router-mac */ struct ethaddr rmac; - /* Distance as applied by Route map */ - uint8_t distance; + uint16_t encap_tunneltype; /* rmap set table */ uint32_t rmap_table_id; @@ -302,10 +307,6 @@ struct attr { /* SR-TE Color */ uint32_t srte_color; - /* EVPN DF preference and algorithm for DF election on local ESs */ - uint16_t df_pref; - uint8_t df_alg; - /* Nexthop type */ enum nexthop_types_t nh_type; |
