diff options
Diffstat (limited to 'bgpd/bgp_zebra.c')
| -rw-r--r-- | bgpd/bgp_zebra.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 63214c5676..3af874fb82 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -33,6 +33,7 @@ #include "memory.h" #include "lib/json.h" #include "lib/bfd.h" +#include "lib/route_opaque.h" #include "filter.h" #include "mpls.h" #include "vxlan.h" @@ -1400,11 +1401,24 @@ void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p, is_add = (valid_nh_count || nhg_id) ? true : false; if (is_add && CHECK_FLAG(bm->flags, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA)) { - struct aspath *aspath = info->attr->aspath; + struct bgp_zebra_opaque bzo = {}; + + strlcpy(bzo.aspath, info->attr->aspath->str, + sizeof(bzo.aspath)); + + if (info->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES)) + strlcpy(bzo.community, info->attr->community->str, + sizeof(bzo.community)); + + if (info->attr->flag + & ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES)) + strlcpy(bzo.lcommunity, info->attr->lcommunity->str, + sizeof(bzo.lcommunity)); SET_FLAG(api.message, ZAPI_MESSAGE_OPAQUE); - api.opaque.length = strlen(aspath->str) + 1; - memcpy(api.opaque.data, aspath->str, api.opaque.length); + api.opaque.length = MIN(sizeof(struct bgp_zebra_opaque), + ZAPI_MESSAGE_OPAQUE_LENGTH); + memcpy(api.opaque.data, &bzo, api.opaque.length); } if (allow_recursion) |
