diff --git a/ospf6d/ospf6_area.c b/ospf6d/ospf6_area.c index 30f0e9e774..76722aad10 100644 --- a/ospf6d/ospf6_area.c +++ b/ospf6d/ospf6_area.c @@ -1022,3 +1022,16 @@ void ospf6_area_init(void) install_element(OSPF6_NODE, &area_filter_list_cmd); install_element(OSPF6_NODE, &no_area_filter_list_cmd); } + +void ospf6_area_interface_delete(struct ospf6_interface *oi) +{ + struct ospf6_area *oa; + struct listnode *node, *nnode; + + if (!ospf6) + return; + for (ALL_LIST_ELEMENTS(ospf6->area_list, node, nnode, oa)) + if(listnode_lookup(oa->if_list, oi)) + listnode_delete(oa->if_list, oi); + +} diff --git a/ospf6d/ospf6_area.h b/ospf6d/ospf6_area.h index ba497a168e..5648b1dfec 100644 --- a/ospf6d/ospf6_area.h +++ b/ospf6d/ospf6_area.h @@ -132,5 +132,7 @@ extern void ospf6_area_show(struct vty *, struct ospf6_area *); extern void ospf6_area_plist_update(struct prefix_list *plist, int add); extern void ospf6_area_config_write(struct vty *vty); extern void ospf6_area_init(void); +struct ospf6_interface; +extern void ospf6_area_interface_delete(struct ospf6_interface *oi); #endif /* OSPF_AREA_H */ diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c index dd08144daa..83b9001fea 100644 --- a/ospf6d/ospf6_interface.c +++ b/ospf6d/ospf6_interface.c @@ -269,6 +269,9 @@ void ospf6_interface_delete(struct ospf6_interface *oi) ospf6_bfd_info_free(&(oi->bfd_info)); + /* disable from area list if possible */ + ospf6_area_interface_delete(oi); + XFREE(MTYPE_OSPF6_IF, oi); } diff --git a/ospf6d/ospf6_main.c b/ospf6d/ospf6_main.c index 046badc824..61094c7cdb 100644 --- a/ospf6d/ospf6_main.c +++ b/ospf6d/ospf6_main.c @@ -43,6 +43,7 @@ #include "ospf6d.h" #include "ospf6_top.h" #include "ospf6_message.h" +#include "ospf6_network.h" #include "ospf6_asbr.h" #include "ospf6_lsa.h" #include "ospf6_interface.h" @@ -84,8 +85,10 @@ static void __attribute__((noreturn)) ospf6_exit(int status) frr_early_fini(); - if (ospf6) + if (ospf6) { ospf6_delete(ospf6); + ospf6 = NULL; + } bfd_gbl_exit(); @@ -97,6 +100,7 @@ static void __attribute__((noreturn)) ospf6_exit(int status) ospf6_asbr_terminate(); ospf6_lsa_terminate(); + ospf6_serv_close(); /* reverse access_list_init */ access_list_reset(); diff --git a/ospf6d/ospf6_network.c b/ospf6d/ospf6_network.c index 8df5f1cc47..625ad884f2 100644 --- a/ospf6d/ospf6_network.c +++ b/ospf6d/ospf6_network.c @@ -73,6 +73,15 @@ static void ospf6_set_checksum(void) #endif /* DISABLE_IPV6_CHECKSUM */ } +void ospf6_serv_close(void) +{ + if (ospf6_sock > 0) { + close(ospf6_sock); + ospf6_sock = -1; + return; + } +} + /* Make ospf6d's server socket. */ int ospf6_serv_sock(void) { @@ -163,6 +172,7 @@ int ospf6_sendmsg(struct in6_addr *src, struct in6_addr *dst, assert(dst); assert(*ifindex); + memset(&cmsgbuf, 0, sizeof(cmsgbuf)); scmsgp = (struct cmsghdr *)&cmsgbuf; pktinfo = (struct in6_pktinfo *)(CMSG_DATA(scmsgp)); memset(&dst_sin6, 0, sizeof(struct sockaddr_in6)); diff --git a/ospf6d/ospf6_network.h b/ospf6d/ospf6_network.h index 7c7c155fbf..7fe6e33ff2 100644 --- a/ospf6d/ospf6_network.h +++ b/ospf6d/ospf6_network.h @@ -26,6 +26,7 @@ extern struct in6_addr allspfrouters6; extern struct in6_addr alldrouters6; extern int ospf6_serv_sock(void); +extern void ospf6_serv_close(void); extern int ospf6_sso(ifindex_t ifindex, struct in6_addr *group, int option); extern int ospf6_sendmsg(struct in6_addr *, struct in6_addr *, ifindex_t *,