Hello,
Here is the second iteration of the patch. It fixes a crash and it is a
refactoring.
Denis
Index: area.c
===================================================================
RCS file: /cvs/src/usr.sbin/ospf6d/area.c,v
retrieving revision 1.4
diff -u -p -r1.4 area.c
--- area.c 28 Dec 2008 20:08:31 -0000 1.4
+++ area.c 20 Dec 2015 20:38:00 -0000
@@ -57,7 +57,6 @@ area_del(struct area *area)
/* clean lists */
while ((iface = LIST_FIRST(&area->iface_list)) != NULL) {
LIST_REMOVE(iface, entry);
- if_del(iface);
}
while ((n = LIST_FIRST(&area->nbr_list)) != NULL)
Index: interface.c
===================================================================
RCS file: /cvs/src/usr.sbin/ospf6d/interface.c,v
retrieving revision 1.22
diff -u -p -r1.22 interface.c
--- interface.c 27 Sep 2015 17:31:50 -0000 1.22
+++ interface.c 20 Dec 2015 20:38:00 -0000
@@ -170,8 +170,7 @@ int
if_init(void)
{
TAILQ_INIT(&iflist);
-
- return (fetchifs(0));
+ return (0);
}
/* XXX using a linked list should be OK for now */
Index: ospf6d.c
===================================================================
RCS file: /cvs/src/usr.sbin/ospf6d/ospf6d.c,v
retrieving revision 1.29
diff -u -p -r1.29 ospf6d.c
--- ospf6d.c 5 Dec 2015 13:12:41 -0000 1.29
+++ ospf6d.c 20 Dec 2015 20:38:01 -0000
@@ -597,6 +597,7 @@ ospf_reload(void)
{
struct area *area;
struct ospfd_conf *xconf;
+ struct iface *iface;
if ((xconf = parse_config(conffile, ospfd_conf->opts)) == NULL)
return (-1);
@@ -605,10 +606,16 @@ ospf_reload(void)
if (ospf_sendboth(IMSG_RECONF_CONF, xconf, sizeof(*xconf)) == -1)
return (-1);
- /* send areas, interfaces happen out of band */
+ /* send areas & interfaces */
LIST_FOREACH(area, &xconf->area_list, entry) {
if (ospf_sendboth(IMSG_RECONF_AREA, area, sizeof(*area)) == -1)
return (-1);
+
+ LIST_FOREACH(iface, &area->iface_list, entry) {
+ if (ospf_sendboth(IMSG_RECONF_IFACE, iface,
+ sizeof(*iface)) == -1)
+ return (-1);
+ }
}
if (ospf_sendboth(IMSG_RECONF_END, NULL, 0) == -1)
Index: ospf6d.h
===================================================================
RCS file: /cvs/src/usr.sbin/ospf6d/ospf6d.h,v
retrieving revision 1.29
diff -u -p -r1.29 ospf6d.h
--- ospf6d.h 27 Sep 2015 17:31:50 -0000 1.29
+++ ospf6d.h 20 Dec 2015 20:38:01 -0000
@@ -121,6 +121,7 @@ enum imsg_type {
IMSG_ABR_DOWN,
IMSG_RECONF_CONF,
IMSG_RECONF_AREA,
+ IMSG_RECONF_IFACE,
IMSG_RECONF_END,
IMSG_DEMOTE
};
Index: ospfe.c
===================================================================
RCS file: /cvs/src/usr.sbin/ospf6d/ospfe.c,v
retrieving revision 1.47
diff -u -p -r1.47 ospfe.c
--- ospfe.c 5 Dec 2015 13:12:41 -0000 1.47
+++ ospfe.c 20 Dec 2015 20:38:02 -0000
@@ -250,6 +250,7 @@ ospfe_dispatch_main(int fd, short event,
static struct area *narea;
struct area *area;
struct iface *iface, *ifp;
+ struct iface *niface;
struct ifaddrchange *ifc;
struct iface_addr *ia, *nia;
struct imsg imsg;
@@ -388,6 +389,19 @@ ospfe_dispatch_main(int fd, short event,
RB_INIT(&narea->lsa_tree);
LIST_INSERT_HEAD(&nconf->area_list, narea, entry);
+ break;
+ case IMSG_RECONF_IFACE:
+ if ((niface = malloc(sizeof(struct iface))) == NULL)
+ fatal(NULL);
+
+ memcpy(niface, imsg.data, sizeof(struct iface));
+
+ LIST_INIT(&niface->nbr_list);
+ TAILQ_INIT(&niface->ls_ack_list);
+ RB_INIT(&niface->lsa_tree);
+
+ narea = area_find(nconf, niface->area_id);
+ LIST_INSERT_HEAD(&narea->iface_list, niface, entry);
break;
case IMSG_RECONF_END:
if ((oeconf->flags & OSPFD_FLAG_STUB_ROUTER) !=
Index: parse.y
===================================================================
RCS file: /cvs/src/usr.sbin/ospf6d/parse.y,v
retrieving revision 1.27
diff -u -p -r1.27 parse.y
--- parse.y 20 Nov 2014 05:51:20 -0000 1.27
+++ parse.y 20 Dec 2015 20:38:02 -0000
@@ -924,6 +924,7 @@ parse_config(char *filename, int opts)
LIST_INIT(&conf->area_list);
LIST_INIT(&conf->cand_list);
SIMPLEQ_INIT(&conf->redist_list);
+ fetchifs(0);
yyparse();
errors = file->errors;
Index: rde.c
===================================================================
RCS file: /cvs/src/usr.sbin/ospf6d/rde.c,v
retrieving revision 1.65
diff -u -p -r1.65 rde.c
--- rde.c 5 Dec 2015 13:12:41 -0000 1.65
+++ rde.c 20 Dec 2015 20:38:03 -0000
@@ -620,6 +620,7 @@ rde_dispatch_parent(int fd, short event,
static struct area *narea;
struct area *area;
struct iface *iface, *ifp;
+ struct iface *niface;
struct ifaddrchange *ifc;
struct iface_addr *ia, *nia;
struct imsg imsg;
@@ -824,6 +825,18 @@ rde_dispatch_parent(int fd, short event,
RB_INIT(&narea->lsa_tree);
LIST_INSERT_HEAD(&nconf->area_list, narea, entry);
+ break;
+ case IMSG_RECONF_IFACE:
+ if ((niface = malloc(sizeof(struct iface))) == NULL)
+ fatal(NULL);
+ memcpy(niface, imsg.data, sizeof(struct iface));
+
+ LIST_INIT(&niface->nbr_list);
+ TAILQ_INIT(&niface->ls_ack_list);
+ RB_INIT(&niface->lsa_tree);
+
+ narea = area_find(nconf, niface->area_id);
+ LIST_INSERT_HEAD(&narea->iface_list, niface, entry);
break;
case IMSG_RECONF_END:
merge_config(rdeconf, nconf);