From c8b9f5fb1271a5b02fd0abc9b3f55c6c5bf9e4de Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Thu, 14 Feb 2019 14:10:03 +0100 Subject: [PATCH 1/4] ospf6d: unitialised buffer zone used by socket a buffer zone is initialised, before being used by server socket. Signed-off-by: Philippe Guibert --- ospf6d/ospf6_network.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ospf6d/ospf6_network.c b/ospf6d/ospf6_network.c index 8df5f1cc47..136e931d3d 100644 --- a/ospf6d/ospf6_network.c +++ b/ospf6d/ospf6_network.c @@ -163,6 +163,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)); From d51884e6e1efb98e01fd8839be426c767f375092 Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Thu, 14 Feb 2019 14:06:41 +0100 Subject: [PATCH 2/4] ospf6d: closing server socket when leaving ospf6d this commit brings consistency as it closes the socket used to carry ospfv3 messages. Signed-off-by: Philippe Guibert --- ospf6d/ospf6_main.c | 2 ++ ospf6d/ospf6_network.c | 9 +++++++++ ospf6d/ospf6_network.h | 1 + 3 files changed, 12 insertions(+) diff --git a/ospf6d/ospf6_main.c b/ospf6d/ospf6_main.c index 046badc824..289c7dc18c 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" @@ -97,6 +98,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 136e931d3d..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) { 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 *, From 22b982dfe9eebe6c3ce0f39100d937650e24e082 Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Thu, 14 Feb 2019 14:04:45 +0100 Subject: [PATCH 3/4] ospf6d: upon interface deletion, the area if list may be updated there are some events where the list of interfaces per area should be reviewed due to an interface is being removed. This fix avoids having some memory leak. Signed-off-by: Philippe Guibert --- ospf6d/ospf6_area.c | 13 +++++++++++++ ospf6d/ospf6_area.h | 2 ++ ospf6d/ospf6_interface.c | 3 +++ 3 files changed, 18 insertions(+) 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); } From 18f286adfbaba52a7d6d4a3994e763109d088c74 Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Fri, 15 Feb 2019 17:42:13 +0100 Subject: [PATCH 4/4] ospf6d: reset the global ospf6 pointer reset the global ospf6 pointer. Signed-off-by: Philippe Guibert --- ospf6d/ospf6_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ospf6d/ospf6_main.c b/ospf6d/ospf6_main.c index 289c7dc18c..61094c7cdb 100644 --- a/ospf6d/ospf6_main.c +++ b/ospf6d/ospf6_main.c @@ -85,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();