aboutsummaryrefslogtreecommitdiffstats
path: root/src/charon/plugins/kernel_netlink/kernel_netlink_shared.c
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2010-02-23 16:49:34 +0000
committerMartin Willi <martin@revosec.ch>2010-02-26 11:44:33 +0100
commitd6a27ec64ee6f77a00494cfa8a0001d190e537f6 (patch)
treeaf68d1c6e4ab4f1916e16f080a51118c5fadd534 /src/charon/plugins/kernel_netlink/kernel_netlink_shared.c
parent54f818590e1482eb271b01e9f462c58ec1299242 (diff)
downloadstrongswan-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_netlink/kernel_netlink_shared.c')
-rw-r--r--src/charon/plugins/kernel_netlink/kernel_netlink_shared.c18
1 files changed, 13 insertions, 5 deletions
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;