if (LIST_EMPTY(&(bnc->paths)) && !bnc->nht_info) {
if (BGP_DEBUG(nht, NHT)) {
char buf[PREFIX2STR_BUFFER];
- zlog_debug("%s: freeing bnc %s(%u)(%s)", __func__,
+ zlog_debug("%s: freeing bnc %s(%d)(%u)(%s)", __func__,
bnc_str(bnc, buf, PREFIX2STR_BUFFER),
- bnc->srte_color, bnc->bgp->name_pretty);
+ bnc->ifindex, bnc->srte_color,
+ bnc->bgp->name_pretty);
}
/* only unregister if this is the last nh for this prefix*/
if (!bnc_existing_for_prefix(bnc))
struct prefix pt;
struct bgp_nexthop_cache *bncp, *bnct;
afi_t afi;
+ ifindex_t ifindex = 0;
if (!sockunion2hostprefix(&from->su, &pp))
return;
+ /*
+ * Gather the ifindex for if up/down events to be
+ * tagged into this fun
+ */
+ if (from->conf_if && IN6_IS_ADDR_LINKLOCAL(&from->su.sin6.sin6_addr))
+ ifindex = from->su.sin6.sin6_scope_id;
+
afi = family2afi(pp.family);
- bncp = bnc_find(&from->bgp->nexthop_cache_table[afi], &pp, 0);
+ bncp = bnc_find(&from->bgp->nexthop_cache_table[afi], &pp, 0, ifindex);
if (!sockunion2hostprefix(&to->su, &pt))
return;
- bnct = bnc_find(&to->bgp->nexthop_cache_table[afi], &pt, 0);
+ /*
+ * Gather the ifindex for if up/down events to be
+ * tagged into this fun
+ */
+ ifindex = 0;
+ if (to->conf_if && IN6_IS_ADDR_LINKLOCAL(&to->su.sin6.sin6_addr))
+ ifindex = to->su.sin6.sin6_scope_id;
+ bnct = bnc_find(&to->bgp->nexthop_cache_table[afi], &pt, 0, ifindex);
if (bnct != bncp)
return;
struct prefix p;
struct bgp_nexthop_cache *bnc;
afi_t afi = family2afi(peer->su.sa.sa_family);
+ ifindex_t ifindex = 0;
if (!sockunion2hostprefix(&peer->su, &p))
return;
-
- bnc = bnc_find(&peer->bgp->nexthop_cache_table[afi], &p, 0);
+ /*
+ * Gather the ifindex for if up/down events to be
+ * tagged into this fun
+ */
+ if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&peer->su.sin6.sin6_addr))
+ ifindex = peer->su.sin6.sin6_scope_id;
+ bnc = bnc_find(&peer->bgp->nexthop_cache_table[afi], &p, 0, ifindex);
if (!bnc)
return;
* Gather the ifindex for if up/down events to be
* tagged into this fun
*/
- if (afi == AFI_IP6
- && IN6_IS_ADDR_LINKLOCAL(&peer->su.sin6.sin6_addr))
+ if (afi == AFI_IP6 &&
+ IN6_IS_ADDR_LINKLOCAL(&peer->su.sin6.sin6_addr)) {
ifindex = peer->su.sin6.sin6_scope_id;
+ if (ifindex == 0) {
+ if (BGP_DEBUG(nht, NHT)) {
+ zlog_debug(
+ "%s: Unable to locate ifindex, waiting till we have one",
+ peer->conf_if);
+ }
+ return 0;
+ }
+ }
if (!sockunion2hostprefix(&peer->su, &p)) {
if (BGP_DEBUG(nht, NHT)) {
else
tree = &bgp_nexthop->nexthop_cache_table[afi];
- bnc = bnc_find(tree, &p, srte_color);
+ bnc = bnc_find(tree, &p, srte_color, ifindex);
if (!bnc) {
- bnc = bnc_new(tree, &p, srte_color);
+ bnc = bnc_new(tree, &p, srte_color, ifindex);
bnc->bgp = bgp_nexthop;
- bnc->ifindex = ifindex;
if (BGP_DEBUG(nht, NHT)) {
char buf[PREFIX2STR_BUFFER];
- zlog_debug("Allocated bnc %s(%u)(%s) peer %p",
+ zlog_debug("Allocated bnc %s(%d)(%u)(%s) peer %p",
bnc_str(bnc, buf, PREFIX2STR_BUFFER),
- bnc->srte_color, bnc->bgp->name_pretty,
- peer);
+ bnc->ifindex, bnc->srte_color,
+ bnc->bgp->name_pretty, peer);
}
} else {
if (BGP_DEBUG(nht, NHT)) {
char buf[PREFIX2STR_BUFFER];
zlog_debug(
- "Found existing bnc %s(%s) flags 0x%x ifindex %d #paths %d peer %p",
+ "Found existing bnc %s(%d)(%s) flags 0x%x ifindex %d #paths %d peer %p",
bnc_str(bnc, buf, PREFIX2STR_BUFFER),
- bnc->bgp->name_pretty, bnc->flags, bnc->ifindex,
- bnc->path_count, bnc->nht_info);
+ bnc->ifindex, bnc->bgp->name_pretty, bnc->flags,
+ bnc->ifindex, bnc->path_count, bnc->nht_info);
}
}
{
struct bgp_nexthop_cache *bnc;
struct prefix p;
+ ifindex_t ifindex = 0;
if (!peer)
return;
if (!sockunion2hostprefix(&peer->su, &p))
return;
-
+ /*
+ * Gather the ifindex for if up/down events to be
+ * tagged into this fun
+ */
+ if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&peer->su.sin6.sin6_addr))
+ ifindex = peer->su.sin6.sin6_scope_id;
bnc = bnc_find(&peer->bgp->nexthop_cache_table[family2afi(p.family)],
- &p, 0);
+ &p, 0, ifindex);
if (!bnc) {
if (BGP_DEBUG(nht, NHT))
zlog_debug(
char bnc_buf[BNC_FLAG_DUMP_SIZE];
zlog_debug(
- "%s(%u): Rcvd NH update %pFX(%u) - metric %d/%d #nhops %d/%d flags %s",
+ "%s(%u): Rcvd NH update %pFX(%u)%u) - metric %d/%d #nhops %d/%d flags %s",
bnc->bgp->name_pretty, bnc->bgp->vrf_id, &nhr->prefix,
- bnc->srte_color, nhr->metric, bnc->metric,
+ bnc->ifindex, bnc->srte_color, nhr->metric, bnc->metric,
nhr->nexthop_num, bnc->nexthop_num,
bgp_nexthop_dump_bnc_flags(bnc, bnc_buf,
sizeof(bnc_buf)));
struct bgp_nexthop_cache_head *table;
struct bgp_nexthop_cache *bnc;
struct prefix p;
+ ifindex_t ifindex = 0;
if (!IN6_IS_ADDR_LINKLOCAL(&peer->su.sin6.sin6_addr))
return;
if (!sockunion2hostprefix(&peer->su, &p))
return;
+ /*
+ * Gather the ifindex for if up/down events to be
+ * tagged into this fun
+ */
+ if (peer->conf_if && IN6_IS_ADDR_LINKLOCAL(&peer->su.sin6.sin6_addr))
+ ifindex = peer->su.sin6.sin6_scope_id;
table = &bgp->nexthop_cache_table[AFI_IP6];
- bnc = bnc_find(table, &p, 0);
+ bnc = bnc_find(table, &p, 0, ifindex);
if (!bnc)
return;
afi = family2afi(match.family);
tree = &bgp->nexthop_cache_table[afi];
- bnc_nhc = bnc_find(tree, &match, nhr.srte_color);
+ bnc_nhc = bnc_find(tree, &match, nhr.srte_color, 0);
if (!bnc_nhc) {
if (BGP_DEBUG(nht, NHT))
zlog_debug(
tree = &bgp->import_check_table[afi];
- bnc_import = bnc_find(tree, &match, nhr.srte_color);
+ bnc_import = bnc_find(tree, &match, nhr.srte_color, 0);
if (!bnc_import) {
if (BGP_DEBUG(nht, NHT))
zlog_debug(
bnc_str(bnc, buf, PREFIX2STR_BUFFER);
zlog_debug(
- "NH update for %s(%u)(%s) - flags %s chgflags %s- evaluate paths",
- buf, bnc->srte_color, bnc->bgp->name_pretty,
+ "NH update for %s(%d)(%u)(%s) - flags %s chgflags %s- evaluate paths",
+ buf, bnc->ifindex, bnc->srte_color,
+ bnc->bgp->name_pretty,
bgp_nexthop_dump_bnc_flags(bnc, bnc_buf,
sizeof(bnc_buf)),
bgp_nexthop_dump_bnc_change_flags(bnc, chg_buf,
struct nexthop *nhop;
struct interface *ifp;
struct prefix p;
+ ifindex_t ifindex = 0;
if (peer->ifp)
return;
if (p.family != AF_INET6)
return;
+ /*
+ * Gather the ifindex for if up/down events to be
+ * tagged into this fun
+ */
+ if (peer->conf_if && IN6_IS_ADDR_LINKLOCAL(&peer->su.sin6.sin6_addr))
+ ifindex = peer->su.sin6.sin6_scope_id;
- bnc = bnc_find(&bgp->nexthop_cache_table[AFI_IP6], &p, 0);
+ bnc = bnc_find(&bgp->nexthop_cache_table[AFI_IP6], &p, 0, ifindex);
if (!bnc)
return;
struct nexthop *nhop;
struct interface *ifp;
struct prefix p;
+ ifindex_t ifindex = 0;
if (peer->ifp)
return;
if (p.family != AF_INET6)
return;
+ /*
+ * Gather the ifindex for if up/down events to be
+ * tagged into this fun
+ */
+ if (peer->conf_if && IN6_IS_ADDR_LINKLOCAL(&peer->su.sin6.sin6_addr))
+ ifindex = peer->su.sin6.sin6_scope_id;
- bnc = bnc_find(&bgp->nexthop_cache_table[AFI_IP6], &p, 0);
+ bnc = bnc_find(&bgp->nexthop_cache_table[AFI_IP6], &p, 0, ifindex);
if (!bnc)
return;