@@ -532,26 +532,23 @@ void bgp_delete_connected_nexthop(afi_t afi, struct peer *peer)
532
532
if (!peer )
533
533
return ;
534
534
535
- /*
536
- * In case the below check evaluates true and if
537
- * the bnc has not been freed at this point, then
538
- * we might have to do something similar to what's
539
- * done in bgp_unlink_nexthop_by_peer(). Since
540
- * bgp_unlink_nexthop_by_peer() loops through the
541
- * nodes of V6 nexthop cache to find the bnc, it is
542
- * currently not being called here.
543
- */
544
- if (!sockunion2hostprefix (& peer -> connection -> su , & p ))
545
- return ;
546
- /*
547
- * Gather the ifindex for if up/down events to be
548
- * tagged into this fun
549
- */
550
- if (afi == AFI_IP6 &&
551
- IN6_IS_ADDR_LINKLOCAL (& peer -> connection -> su .sin6 .sin6_addr ))
552
- ifindex = peer -> connection -> su .sin6 .sin6_scope_id ;
553
- bnc = bnc_find (& peer -> bgp -> nexthop_cache_table [family2afi (p .family )],
554
- & p , 0 , ifindex );
535
+ if (!sockunion2hostprefix (& peer -> connection -> su , & p )) {
536
+ /*
537
+ * If peer->connection->su is cleared before peer deletion,
538
+ * find the bnc whose nht_info matches the peer and free it.
539
+ */
540
+ bnc = bgp_find_ipv6_nexthop_matching_peer (peer );
541
+ } else {
542
+ /*
543
+ * Gather the ifindex for if up/down events to be
544
+ * tagged into this fun
545
+ */
546
+ if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (& peer -> connection -> su .sin6 .sin6_addr ))
547
+ ifindex = peer -> connection -> su .sin6 .sin6_scope_id ;
548
+ bnc = bnc_find (& peer -> bgp -> nexthop_cache_table [family2afi (p .family )], & p , 0 ,
549
+ ifindex );
550
+ }
551
+
555
552
if (!bnc ) {
556
553
if (BGP_DEBUG (nht , NHT ))
557
554
zlog_debug (
0 commit comments