static struct hash *cluster_hash;
+struct attr_extra *bgp_attr_extra_alloc(void)
+{
+ return XCALLOC(MTYPE_ATTR_EXTRA, sizeof(struct attr_extra));
+}
+
+void bgp_attr_extra_free(struct attr *attr)
+{
+ XFREE(MTYPE_ATTR_EXTRA, attr->extra);
+}
+
static void *cluster_hash_alloc(void *p)
{
const struct cluster_list *val = (const struct cluster_list *)p;
*/
static void attr_vfree(void *attr)
{
+ bgp_attr_extra_free(attr);
XFREE(MTYPE_ATTR, attr);
}
if (attr->refcnt == 0) {
ret = hash_release(attrhash, attr);
assert(ret != NULL);
+ bgp_attr_extra_free(attr);
XFREE(MTYPE_ATTR, attr);
*pattr = NULL;
}
uint8_t transposition_offset;
};
+struct attr_extra {
+ /* Extended Communities attribute. */
+ struct ecommunity *ipv6_ecommunity;
+};
+
/* BGP core attribute structure. */
struct attr {
/* AS Path structure */
/* 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;
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)
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)
DEFINE_MTYPE(BGPD, BGP_UPD_SUBGRP, "BGP update subgroup");
DEFINE_MTYPE(BGPD, BGP_PACKET, "BGP packet");
DEFINE_MTYPE(BGPD, ATTR, "BGP attribute");
+DEFINE_MTYPE(BGPD, ATTR_EXTRA, "BGP extra attribute");
DEFINE_MTYPE(BGPD, AS_PATH, "BGP aspath");
DEFINE_MTYPE(BGPD, AS_SEG, "BGP aspath seg");
DEFINE_MTYPE(BGPD, AS_SEG_DATA, "BGP aspath segment data");