On Thu, Dec 04, 2025 at 04:51:55PM +0300, Alexander Mukhin wrote:
> >Synopsis:    ospfd and ripd dump core on exit
> >Category:    user
> >Environment:
>       System      : OpenBSD 7.8
>       Details     : OpenBSD 7.8 (GENERIC) #54: Sun Oct 12 12:45:58 MDT 2025
>                        
> [email protected]:/usr/src/sys/arch/amd64/compile/GENERIC
> 
>       Architecture: OpenBSD.amd64
>       Machine     : amd64
> >Description:
>       ospfd and ripd dump core on exit when static redistribution is enabled
> >How-To-Repeat:
>       # cat ospfd.conf
>       redistribute static
>       area 0.0.0.0 {
>               interface vio1
>       }
>       # route add ...
>       # ospfd -d -v -f ospfd.conf
>       ...
>       ^C
>       ...
>       Segmentation fault (core dumped)
> 
>       # cat ripd.conf
>       redistribute static
>       interface vio1
>       # route add ...
>       # ripd -d -v -f ripd.conf
>       ...
>       ^C
>       ...
>       Segmentation fault (core dumped)
> 
> >Fix:
>       The reason is the same in both cases - sending imsgs through
>       closed pipes. Calling kr_shutdown() before closing pipes helps.
>       The proper fix is probably something like Claudio Jeker did
>       for ldpd.

Patches:

--- ospfd.c
+++ ospfd.c
@@ -313,6 +313,8 @@
        int                      status;
        struct redistribute     *r;
 
+       kr_shutdown();
+
        /* close pipes */
        imsgbuf_clear(&iev_ospfe->ibuf);
        close(iev_ospfe->ibuf.fd);
@@ -324,7 +326,6 @@
                SIMPLEQ_REMOVE_HEAD(&ospfd_conf->redist_list, entry);
                free(r);
        }
-       kr_shutdown();
        carp_demote_shutdown();
 
        log_debug("waiting for children to terminate");


--- ripd.c
+++ ripd.c
@@ -271,6 +271,8 @@
        pid_t            pid;
        int              status;
 
+       kr_shutdown();
+
        /* close pipes */
        imsgbuf_clear(&iev_ripe->ibuf);
        close(iev_ripe->ibuf.fd);
@@ -281,8 +283,6 @@
                LIST_REMOVE(i, entry);
                if_del(i);
        }
-
-       kr_shutdown();
 
        log_debug("waiting for children to terminate");
        do {

-- 
Alexander.

Reply via email to