diff --git a/ospf6d/ospf6_bfd.c b/ospf6d/ospf6_bfd.c index 5ef4ab4ca8..16dedb1031 100644 --- a/ospf6d/ospf6_bfd.c +++ b/ospf6d/ospf6_bfd.c @@ -71,7 +71,7 @@ ospf6_bfd_show_info(struct vty *vty, void *bfd_info, int param_only) * zebra for starting/stopping the monitoring of * the neighbor rechahability. */ -static void +void ospf6_bfd_reg_dereg_nbr (struct ospf6_neighbor *on, int command) { struct ospf6_interface *oi = on->ospf6_if; @@ -79,7 +79,7 @@ ospf6_bfd_reg_dereg_nbr (struct ospf6_neighbor *on, int command) struct bfd_info *bfd_info; char src[64]; - if (!oi->bfd_info) + if (!oi->bfd_info || !on->bfd_info) return; bfd_info = (struct bfd_info *)oi->bfd_info; @@ -93,6 +93,9 @@ ospf6_bfd_reg_dereg_nbr (struct ospf6_neighbor *on, int command) bfd_peer_sendmsg (zclient, bfd_info, AF_INET6, &on->linklocal_addr, on->ospf6_if->linklocal_addr, ifp->name, 0, 0, command, 0); + + if (command == ZEBRA_BFD_DEST_DEREGISTER) + bfd_info_free((struct bfd_info **)&on->bfd_info); } /* @@ -123,14 +126,16 @@ ospf6_bfd_reg_dereg_all_nbr (struct ospf6_interface *oi, int command) for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, node, on)) { - if (command != ZEBRA_BFD_DEST_DEREGISTER) + if (command == ZEBRA_BFD_DEST_REGISTER) ospf6_bfd_info_nbr_create(oi, on); - else - bfd_info_free((struct bfd_info **)&on->bfd_info); if (on->state < OSPF6_NEIGHBOR_TWOWAY) - continue; - + { + if (command == ZEBRA_BFD_DEST_DEREGISTER) + bfd_info_free((struct bfd_info **)&on->bfd_info); + continue; + } + ospf6_bfd_reg_dereg_nbr(on, command); } } diff --git a/ospf6d/ospf6_bfd.h b/ospf6d/ospf6_bfd.h index 11b13d66fb..9c3b57aa24 100644 --- a/ospf6d/ospf6_bfd.h +++ b/ospf6d/ospf6_bfd.h @@ -43,4 +43,6 @@ ospf6_bfd_info_free(void **bfd_info); extern void ospf6_bfd_show_info(struct vty *vty, void *bfd_info, int param_only); +extern void +ospf6_bfd_reg_dereg_nbr (struct ospf6_neighbor *on, int command); #endif /* OSPF6_BFD_H */ diff --git a/ospf6d/ospf6_neighbor.c b/ospf6d/ospf6_neighbor.c index 1636c26289..6f9c8bb4f8 100644 --- a/ospf6d/ospf6_neighbor.c +++ b/ospf6d/ospf6_neighbor.c @@ -141,7 +141,7 @@ ospf6_neighbor_delete (struct ospf6_neighbor *on) THREAD_OFF (on->thread_send_lsupdate); THREAD_OFF (on->thread_send_lsack); - ospf6_bfd_info_free(&on->bfd_info); + ospf6_bfd_reg_dereg_nbr(on, ZEBRA_BFD_DEST_DEREGISTER); XFREE (MTYPE_OSPF6_NEIGHBOR, on); }