From d6a27ec64ee6f77a00494cfa8a0001d190e537f6 Mon Sep 17 00:00:00 2001 From: Martin Willi Date: Tue, 23 Feb 2010 16:49:34 +0000 Subject: Do not kill daemon, just not use pluggable kernel interface if initialization failed --- .../plugins/kernel_netlink/kernel_netlink_shared.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/charon/plugins/kernel_netlink/kernel_netlink_shared.c') diff --git a/src/charon/plugins/kernel_netlink/kernel_netlink_shared.c b/src/charon/plugins/kernel_netlink/kernel_netlink_shared.c index b96186a3a..5ed568150 100644 --- a/src/charon/plugins/kernel_netlink/kernel_netlink_shared.c +++ b/src/charon/plugins/kernel_netlink/kernel_netlink_shared.c @@ -236,7 +236,10 @@ static status_t netlink_send_ack(private_netlink_socket_t *this, struct nlmsghdr */ static void destroy(private_netlink_socket_t *this) { - close(this->socket); + if (this->socket > 0) + { + close(this->socket); + } this->mutex->destroy(this->mutex); free(this); } @@ -244,7 +247,8 @@ static void destroy(private_netlink_socket_t *this) /** * Described in header. */ -netlink_socket_t *netlink_socket_create(int protocol) { +netlink_socket_t *netlink_socket_create(int protocol) +{ private_netlink_socket_t *this = malloc_thing(private_netlink_socket_t); struct sockaddr_nl addr; @@ -262,15 +266,19 @@ netlink_socket_t *netlink_socket_create(int protocol) { this->protocol = protocol; this->socket = socket(AF_NETLINK, SOCK_RAW, protocol); - if (this->socket <= 0) + if (this->socket < 0) { - charon->kill(charon, "unable to create netlink socket"); + DBG1(DBG_KNL, "unable to create netlink socket"); + destroy(this); + return NULL; } addr.nl_groups = 0; if (bind(this->socket, (struct sockaddr*)&addr, sizeof(addr))) { - charon->kill(charon, "unable to bind netlink socket"); + DBG1(DBG_KNL, "unable to bind netlink socket"); + destroy(this); + return NULL; } return &this->public; -- cgit v1.2.3