Hello,

I want to use ospf6d but it is a bit rough around the edge.
A simple "ospf6ctl reload" makes it crash ! Come on, this is far from the
expected OpenBSD quality :p

I made a patch that make it crash less often. I still stumble on some "lost
interface" or "unknown interface" from time to time, lsa addresses are
often duplicated but it is better (from my point of view).

Concerning the duplicated lsa, this is what I get before reload :
orig_link_lsa: interface rl0
orig_link_lsa: link local address fe80::20a:e4ff:fe03:87b4
orig_link_lsa: prefix 2001:7a8:b5ad:2030::
orig_link_lsa: prefix 2001:7a8:b5ad:2030::

And after reload :
orig_link_lsa: interface rl0
orig_link_lsa: link local address fe80::20a:e4ff:fe03:87b4
orig_link_lsa: prefix 2001:7a8:b5ad:2030::
orig_link_lsa: prefix 2001:7a8:b5ad:2030::
orig_link_lsa: link local address fe80::20a:e4ff:fe03:87b4
orig_link_lsa: interface rl0
orig_link_lsa: link local address fe80::20a:e4ff:fe03:87b4
orig_link_lsa: prefix 2001:7a8:b5ad:2030::
orig_link_lsa: prefix 2001:7a8:b5ad:2030::
orig_link_lsa: link local address fe80::20a:e4ff:fe03:87b4
orig_link_lsa: prefix 2001:7a8:b5ad:2030::
orig_link_lsa: interface rl0
orig_link_lsa: link local address fe80::20a:e4ff:fe03:87b4
orig_link_lsa: prefix 2001:7a8:b5ad:2030::
orig_link_lsa: prefix 2001:7a8:b5ad:2030::
orig_link_lsa: link local address fe80::20a:e4ff:fe03:87b4
orig_link_lsa: prefix 2001:7a8:b5ad:2030::
orig_link_lsa: prefix 2001:7a8:b5ad:2030::

The fix would be (I think, I am still investigating) to check for existing LSA
before adding a new one in ospfe_dispatch_main() (ospfe.c) when handling
IMSG_IFADDRNEW. Perhaps use a tree instead of a list ?

Would someone help me to give some love to ospf6d to improve it and make it
usable ?

Denis

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 15 Dec 2015 16:40:33 -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    15 Dec 2015 16:40:34 -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    15 Dec 2015 16:40:34 -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     15 Dec 2015 16:40:34 -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     15 Dec 2015 16:40:35 -0000
@@ -451,6 +451,7 @@ areaoptsl   : interface
                ;
 
 interface      : INTERFACE STRING      {
+                       fetchifs(0);
                        if ((iface = if_findname($2)) == NULL) {
                                yyerror("unknown interface %s", $2);
                                free($2);
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       15 Dec 2015 16:40:35 -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);
Index: rde_spf.c
===================================================================
RCS file: /cvs/src/usr.sbin/ospf6d/rde_spf.c,v
retrieving revision 1.25
diff -u -p -r1.25 rde_spf.c
--- rde_spf.c   5 Dec 2015 06:45:19 -0000       1.25
+++ rde_spf.c   15 Dec 2015 16:40:36 -0000
@@ -184,9 +184,8 @@ spf_calc(struct area *area)
                TAILQ_FOREACH(vn, &v->nexthop, entry) {
                        strlcat(hops, log_in6addr(&vn->nexthop), sizeof(hops));
                        strlcat(hops, "%", sizeof(hops));
-                       if ((iface = if_find(vn->ifindex)) == NULL)
-                               fatalx("spf_calc: lost iface");
-                       strlcat(hops, iface->name, sizeof(hops));
+                       if ((iface = if_find(vn->ifindex)) != NULL)
+                               strlcat(hops, iface->name, sizeof(hops));
                        if (vn != TAILQ_LAST(&v->nexthop, v_nexthead))
                                strlcat(hops, ", ", sizeof(hops));
                }

Reply via email to