diff options
author | Martin Willi <martin@revosec.ch> | 2010-02-23 16:49:34 +0000 |
---|---|---|
committer | Martin Willi <martin@revosec.ch> | 2010-02-26 11:44:33 +0100 |
commit | d6a27ec64ee6f77a00494cfa8a0001d190e537f6 (patch) | |
tree | af68d1c6e4ab4f1916e16f080a51118c5fadd534 /src/charon/plugins/kernel_pfroute | |
parent | 54f818590e1482eb271b01e9f462c58ec1299242 (diff) | |
download | strongswan-d6a27ec64ee6f77a00494cfa8a0001d190e537f6.tar.bz2 strongswan-d6a27ec64ee6f77a00494cfa8a0001d190e537f6.tar.xz |
Do not kill daemon, just not use pluggable kernel interface if initialization failed
Diffstat (limited to 'src/charon/plugins/kernel_pfroute')
-rw-r--r-- | src/charon/plugins/kernel_pfroute/kernel_pfroute_net.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/src/charon/plugins/kernel_pfroute/kernel_pfroute_net.c b/src/charon/plugins/kernel_pfroute/kernel_pfroute_net.c index 9f1baf5b5..97c019b58 100644 --- a/src/charon/plugins/kernel_pfroute/kernel_pfroute_net.c +++ b/src/charon/plugins/kernel_pfroute/kernel_pfroute_net.c @@ -650,9 +650,18 @@ static status_t init_address_list(private_kernel_pfroute_net_t *this) */ static void destroy(private_kernel_pfroute_net_t *this) { - this->job->cancel(this->job); - close(this->socket); - close(this->socket_events); + if (this->job) + { + this->job->cancel(this->job); + } + if (this->socket > 0) + { + close(this->socket); + } + if (this->socket_events) + { + close(this->socket_events); + } this->ifaces->destroy_function(this->ifaces, (void*)iface_entry_destroy); this->mutex->destroy(this->mutex); this->mutex_pfroute->destroy(this->mutex_pfroute); @@ -684,19 +693,25 @@ kernel_pfroute_net_t *kernel_pfroute_net_create() this->mutex_pfroute = mutex_create(MUTEX_TYPE_DEFAULT); this->seq = 0; + this->socket_events = 0; + this->job = NULL; /* create a PF_ROUTE socket to communicate with the kernel */ this->socket = socket(PF_ROUTE, SOCK_RAW, AF_UNSPEC); - if (this->socket <= 0) + if (this->socket < 0) { - charon->kill(charon, "unable to create PF_ROUTE socket"); + DBG1(DBG_KNL, "unable to create PF_ROUTE socket"); + destroy(this); + return NULL; } /* create a PF_ROUTE socket to receive events */ this->socket_events = socket(PF_ROUTE, SOCK_RAW, AF_UNSPEC); - if (this->socket_events <= 0) + if (this->socket_events < 0) { - charon->kill(charon, "unable to create PF_ROUTE event socket"); + DBG1(DBG_KNL, "unable to create PF_ROUTE event socket"); + destroy(this); + return NULL; } this->job = callback_job_create((callback_job_cb_t)receive_events, @@ -705,7 +720,9 @@ kernel_pfroute_net_t *kernel_pfroute_net_create() if (init_address_list(this) != SUCCESS) { - charon->kill(charon, "unable to get interface list"); + DBG1(DBG_KNL, "unable to get interface list"); + destroy(this); + return NULL; } return &this->public; |