diff options
author | Renato Westphal <renato@cvs.openbsd.org> | 2016-05-23 14:59:51 +0000 |
---|---|---|
committer | Renato Westphal <renato@cvs.openbsd.org> | 2016-05-23 14:59:51 +0000 |
commit | b29c91d520f9854061ca57a248145d6adebc4cc5 (patch) | |
tree | 26a9da3e6a2b01470dfb412dd2f9dcb60508fbc4 /usr.sbin | |
parent | e15c6239e2d7698242e666d27c5fbfa5b2694840 (diff) |
Explicitly close the pfkey socket on exit.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ldpd/ldpd.h | 3 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldpe.c | 13 |
2 files changed, 9 insertions, 7 deletions
diff --git a/usr.sbin/ldpd/ldpd.h b/usr.sbin/ldpd/ldpd.h index daed15d8c0f..0cf11845c2e 100644 --- a/usr.sbin/ldpd/ldpd.h +++ b/usr.sbin/ldpd/ldpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpd.h,v 1.56 2015/09/27 17:30:38 stsp Exp $ */ +/* $OpenBSD: ldpd.h,v 1.57 2016/05/23 14:59:50 renato Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -332,6 +332,7 @@ struct ldpd_conf { #define LDPD_OPT_VERBOSE2 0x00000002 #define LDPD_OPT_NOACTION 0x00000004 time_t uptime; + int pfkeysock; int ldp_discovery_socket; int ldp_ediscovery_socket; int ldp_session_socket; diff --git a/usr.sbin/ldpd/ldpe.c b/usr.sbin/ldpd/ldpe.c index b116f8f8940..d8becc2c963 100644 --- a/usr.sbin/ldpd/ldpe.c +++ b/usr.sbin/ldpd/ldpe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpe.c,v 1.42 2016/05/23 14:55:41 renato Exp $ */ +/* $OpenBSD: ldpe.c,v 1.43 2016/05/23 14:59:50 renato Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -82,7 +82,7 @@ ldpe(struct ldpd_conf *xconf, int pipe_parent2ldpe[2], int pipe_ldpe2lde[2], struct event ev_sigint, ev_sigterm; struct sockaddr_in disc_addr, sess_addr; pid_t pid; - int pfkeysock, opt; + int opt; switch (pid = fork()) { case -1: @@ -98,12 +98,12 @@ ldpe(struct ldpd_conf *xconf, int pipe_parent2ldpe[2], int pipe_ldpe2lde[2], setproctitle("ldp engine"); ldpd_process = PROC_LDP_ENGINE; - pfkeysock = pfkey_init(&sysdep); - /* create ldpd control socket outside chroot */ if (control_init() == -1) fatalx("control socket setup failed"); + leconf->pfkeysock = pfkey_init(&sysdep); + /* create the discovery UDP socket */ disc_addr.sin_family = AF_INET; disc_addr.sin_port = htons(LDP_PORT); @@ -243,7 +243,7 @@ ldpe(struct ldpd_conf *xconf, int pipe_parent2ldpe[2], int pipe_ldpe2lde[2], iev_main->handler, iev_main); event_add(&iev_main->ev, NULL); - event_set(&pfkey_ev, pfkeysock, EV_READ | EV_PERSIST, + event_set(&pfkey_ev, leconf->pfkeysock, EV_READ | EV_PERSIST, ldpe_dispatch_pfkey, NULL); event_add(&pfkey_ev, NULL); @@ -288,10 +288,11 @@ ldpe_shutdown(void) control_cleanup(); + event_del(&pfkey_ev); event_del(&disc_ev); event_del(&edisc_ev); accept_del(leconf->ldp_session_socket); - event_del(&pfkey_ev); + close(leconf->pfkeysock); close(leconf->ldp_discovery_socket); close(leconf->ldp_ediscovery_socket); close(leconf->ldp_session_socket); |