diff options
| author | Donatas Abraitis <donatas.abraitis@gmail.com> | 2022-01-26 21:40:29 +0200 | 
|---|---|---|
| committer | Donatas Abraitis <donatas.abraitis@gmail.com> | 2022-01-26 21:52:40 +0200 | 
| commit | 2703b7db19cebad82772d5210132dab412b855c3 (patch) | |
| tree | 77735d8cdaa6ba148eaac599d7d4e4bc0a18e909 /bgpd/bgp_attr.h | |
| parent | 457fb2c846a30cac6e4c79dcc53796b5bf101991 (diff) | |
bgpd: Move out ipv6_ecommunity struct from attr to attr_extra
This is the initial work to move all non IPv4/IPv6 AFI related
attributes/structs to attr->extra to avoid unnecesarry allocations.
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
Diffstat (limited to 'bgpd/bgp_attr.h')
| -rw-r--r-- | bgpd/bgp_attr.h | 25 | 
1 files changed, 21 insertions, 4 deletions
diff --git a/bgpd/bgp_attr.h b/bgpd/bgp_attr.h index 3573c2ae03..5bef6860ef 100644 --- a/bgpd/bgp_attr.h +++ b/bgpd/bgp_attr.h @@ -159,6 +159,11 @@ struct bgp_attr_srv6_l3vpn {  	uint8_t transposition_offset;  }; +struct attr_extra { +	/* Extended Communities attribute. */ +	struct ecommunity *ipv6_ecommunity; +}; +  /* BGP core attribute structure. */  struct attr {  	/* AS Path structure */ @@ -199,8 +204,8 @@ struct attr {  	/* Extended Communities attribute. */  	struct ecommunity *ecommunity; -	/* Extended Communities attribute. */ -	struct ecommunity *ipv6_ecommunity; +	/* Extra attributes, non IPv4/IPv6 AFI related */ +	struct attr_extra *extra;  	/* Large Communities attribute. */  	struct lcommunity *lcommunity; @@ -472,6 +477,8 @@ extern void bgp_packet_mpunreach_end(struct stream *s, size_t attrlen_pnt);  extern bgp_attr_parse_ret_t bgp_attr_nexthop_valid(struct peer *peer,  						   struct attr *attr); +extern struct attr_extra *bgp_attr_extra_alloc(void); +extern void bgp_attr_extra_free(struct attr *attr);  static inline int bgp_rmap_nhop_changed(uint32_t out_rmap_flags,  					uint32_t in_rmap_flags) @@ -508,13 +515,23 @@ static inline void bgp_attr_set_pmsi_tnl_type(struct attr *attr,  static inline struct ecommunity *  bgp_attr_get_ipv6_ecommunity(const struct attr *attr)  { -	return attr->ipv6_ecommunity; +	if (attr->extra) +		return attr->extra->ipv6_ecommunity; + +	return NULL;  }  static inline void bgp_attr_set_ipv6_ecommunity(struct attr *attr,  						struct ecommunity *ipv6_ecomm)  { -	attr->ipv6_ecommunity = ipv6_ecomm; +	if (!attr->extra) { +		if (!ipv6_ecomm) +			return; + +		attr->extra = bgp_attr_extra_alloc(); +	} + +	attr->extra->ipv6_ecommunity = ipv6_ecomm;  }  static inline struct transit *bgp_attr_get_transit(const struct attr *attr)  | 
