Currently when running bgpd -dvv you will see that the SE and the RDE are crashing during shutdown. Fixing the order of closing the imsg pipes solves this.
-- :wq Claudio Index: rde.c =================================================================== RCS file: /cvs/src/usr.sbin/bgpd/rde.c,v retrieving revision 1.363 diff -u -p -r1.363 rde.c --- rde.c 27 May 2017 18:12:23 -0000 1.363 +++ rde.c 27 May 2017 19:51:48 -0000 @@ -312,6 +312,10 @@ rde_main(int debug, int verbose) rib_dump_runner(); } + /* do not clean up on shutdown on production, it takes ages. */ + if (debug) + rde_shutdown(); + /* close pipes */ if (ibuf_se) { msgbuf_clear(&ibuf_se->w); @@ -326,10 +330,6 @@ rde_main(int debug, int verbose) msgbuf_clear(&ibuf_main->w); close(ibuf_main->fd); free(ibuf_main); - - /* do not clean up on shutdown on production, it takes ages. */ - if (debug) - rde_shutdown(); while ((mctx = LIST_FIRST(&rde_mrts)) != NULL) { msgbuf_clear(&mctx->mrt.wbuf); Index: session.c =================================================================== RCS file: /cvs/src/usr.sbin/bgpd/session.c,v retrieving revision 1.361 diff -u -p -r1.361 session.c --- session.c 27 May 2017 10:33:15 -0000 1.361 +++ session.c 27 May 2017 19:51:48 -0000 @@ -555,23 +555,6 @@ session_main(int debug, int verbose) control_dispatch_msg(&pfd[j], &ctl_cnt); } - /* close pipes */ - if (ibuf_rde) { - msgbuf_write(&ibuf_rde->w); - msgbuf_clear(&ibuf_rde->w); - close(ibuf_rde->fd); - free(ibuf_rde); - } - if (ibuf_rde_ctl) { - msgbuf_clear(&ibuf_rde_ctl->w); - close(ibuf_rde_ctl->fd); - free(ibuf_rde_ctl); - } - msgbuf_write(&ibuf_main->w); - msgbuf_clear(&ibuf_main->w); - close(ibuf_main->fd); - free(ibuf_main); - while ((p = peers) != NULL) { peers = p->next; strlcpy(p->conf.shutcomm, @@ -597,6 +580,22 @@ session_main(int debug, int verbose) free(mrt_l); free(pfd); + /* close pipes */ + if (ibuf_rde) { + msgbuf_write(&ibuf_rde->w); + msgbuf_clear(&ibuf_rde->w); + close(ibuf_rde->fd); + free(ibuf_rde); + } + if (ibuf_rde_ctl) { + msgbuf_clear(&ibuf_rde_ctl->w); + close(ibuf_rde_ctl->fd); + free(ibuf_rde_ctl); + } + msgbuf_write(&ibuf_main->w); + msgbuf_clear(&ibuf_main->w); + close(ibuf_main->fd); + free(ibuf_main); control_shutdown(csock); control_shutdown(rcsock);