a load testing plugin, to:

find multi-threading issues
	do performance profiling
This commit is contained in:
Martin Willi
2008-10-21 13:00:38 +00:00
parent 6df2837a8c
commit 0fd6e95562
11 changed files with 846 additions and 0 deletions
+10
View File
@@ -385,6 +385,14 @@ AC_ARG_ENABLE(
fi]
)
AC_ARG_ENABLE(
[load-tests],
AS_HELP_STRING([--enable-load-tests],[enable load testing plugin for IKEv2 daemon (default is NO).]),
[if test x$enableval = xyes; then
loadtest=true
fi]
)
AC_ARG_ENABLE(
[eap-sim],
AS_HELP_STRING([--enable-eap-sim],[build SIM authenication module for EAP (default is NO).]),
@@ -876,6 +884,7 @@ AM_CONDITIONAL(USE_SMP, test x$smp = xtrue)
AM_CONDITIONAL(USE_SQL, test x$sql = xtrue)
AM_CONDITIONAL(USE_UPDOWN, test x$updown = xtrue)
AM_CONDITIONAL(USE_UNIT_TESTS, test x$unittest = xtrue)
AM_CONDITIONAL(USE_LOAD_TESTS, test x$loadtest = xtrue)
AM_CONDITIONAL(USE_EAP_SIM, test x$eap_sim = xtrue)
AM_CONDITIONAL(USE_EAP_SIM_FILE, test x$eap_sim_file = xtrue)
AM_CONDITIONAL(USE_EAP_IDENTITY, test x$eap_identity = xtrue)
@@ -968,6 +977,7 @@ AC_OUTPUT(
src/charon/plugins/stroke/Makefile
src/charon/plugins/updown/Makefile
src/charon/plugins/unit_tester/Makefile
src/charon/plugins/load_tester/Makefile
src/stroke/Makefile
src/ipsec/Makefile
src/starter/Makefile
+5
View File
@@ -144,6 +144,11 @@ endif
SUBDIRS = .
PLUGINS = ${libstrongswan_plugins}
if USE_LOAD_TESTS
SUBDIRS += plugins/load_tester
PLUGINS += load-tester
endif
if USE_KERNEL_PFKEY
SUBDIRS += plugins/kernel_pfkey
PLUGINS += kernel-pfkey
@@ -0,0 +1,15 @@
INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon
AM_CFLAGS = -rdynamic
plugin_LTLIBRARIES = libstrongswan-load-tester.la
libstrongswan_load_tester_la_SOURCES = \
load_tester_plugin.c load_tester_plugin.h \
load_tester_config.c load_tester_config.h \
load_tester_creds.c load_tester_creds.h \
load_tester_ipsec.c load_tester_ipsec.h
libstrongswan_load_tester_la_LDFLAGS = -module
@@ -0,0 +1,127 @@
/*
* Copyright (C) 2008 Martin Willi
* Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* $Id$
*/
#include "load_tester_config.h"
#include <daemon.h>
typedef struct private_load_tester_config_t private_load_tester_config_t;
/**
* Private data of an load_tester_config_t object
*/
struct private_load_tester_config_t {
/**
* Public part
*/
load_tester_config_t public;
/**
* peer config
*/
peer_cfg_t *peer_cfg;
};
/**
* Implementation of backend_t.create_peer_cfg_enumerator.
*/
static enumerator_t* create_peer_cfg_enumerator(private_load_tester_config_t *this,
identification_t *me,
identification_t *other)
{
return enumerator_create_single(this->peer_cfg, NULL);
}
/**
* Implementation of backend_t.create_ike_cfg_enumerator.
*/
static enumerator_t* create_ike_cfg_enumerator(private_load_tester_config_t *this,
host_t *me, host_t *other)
{
ike_cfg_t *ike_cfg;
ike_cfg = this->peer_cfg->get_ike_cfg(this->peer_cfg);
return enumerator_create_single(ike_cfg, NULL);
}
/**
* implements backend_t.get_peer_cfg_by_name.
*/
static peer_cfg_t *get_peer_cfg_by_name(private_load_tester_config_t *this, char *name)
{
return this->peer_cfg->get_ref(this->peer_cfg);;
}
/**
* Implementation of load_tester_config_t.destroy.
*/
static void destroy(private_load_tester_config_t *this)
{
this->peer_cfg->destroy(this->peer_cfg);
free(this);
}
/**
* Described in header.
*/
load_tester_config_t *load_tester_config_create()
{
private_load_tester_config_t *this = malloc_thing(private_load_tester_config_t);
ike_cfg_t *ike_cfg;
child_cfg_t *child_cfg;
proposal_t *proposal;
traffic_selector_t *ts;
auth_info_t *auth;
auth_class_t class;
this->public.backend.create_peer_cfg_enumerator = (enumerator_t*(*)(backend_t*, identification_t *me, identification_t *other))create_peer_cfg_enumerator;
this->public.backend.create_ike_cfg_enumerator = (enumerator_t*(*)(backend_t*, host_t *me, host_t *other))create_ike_cfg_enumerator;
this->public.backend.get_peer_cfg_by_name = (peer_cfg_t* (*)(backend_t*,char*))get_peer_cfg_by_name;
this->public.destroy = (void(*)(load_tester_config_t*))destroy;
ike_cfg = ike_cfg_create(TRUE, FALSE, "0.0.0.0", "127.0.0.1");
proposal = proposal_create_from_string(PROTO_IKE,
lib->settings->get_str(lib->settings,
"charon.plugins.load_tester.proposal", "aes128-sha1-modp768"));
if (!proposal)
{ /* fallback */
proposal = proposal_create_from_string(PROTO_IKE, "aes128-sha1-modp768");
}
ike_cfg->add_proposal(ike_cfg, proposal);
this->peer_cfg = peer_cfg_create("load-test", 2, ike_cfg,
identification_create_from_string("[email protected]"),
identification_create_from_string("[email protected]"),
CERT_SEND_IF_ASKED, UNIQUE_NO, 1, 0, 0, /* keytries, rekey, reauth */
0, 0, TRUE, 60, /* jitter, overtime, mobike, dpddelay */
NULL, NULL, FALSE, NULL, NULL); /* vip, pool, mediation */
auth = this->peer_cfg->get_auth(this->peer_cfg);
class = AUTH_CLASS_PUBKEY;
auth->add_item(auth, AUTHN_AUTH_CLASS, &class);
child_cfg = child_cfg_create("load-test", 0, 0, 300, NULL, TRUE,
MODE_TUNNEL, ACTION_NONE, ACTION_NONE, FALSE);
proposal = proposal_create_from_string(PROTO_ESP, "aes128-sha1");
child_cfg->add_proposal(child_cfg, proposal);
ts = traffic_selector_create_dynamic(0, 0, 65535);
child_cfg->add_traffic_selector(child_cfg, TRUE, ts);
ts = traffic_selector_create_dynamic(0, 0, 65535);
child_cfg->add_traffic_selector(child_cfg, FALSE, ts);
this->peer_cfg->add_child_cfg(this->peer_cfg, child_cfg);
return &this->public;
}
@@ -0,0 +1,53 @@
/*
* Copyright (C) 2008 Martin Willi
* Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* $Id$
*/
/**
* @defgroup load_tester_config_t load_tester_config
* @{ @ingroup load_tester
*/
#ifndef LOAD_TESTER_CONFIG_H_
#define LOAD_TESTER_CONFIG_H_
#include <config/backend.h>
typedef struct load_tester_config_t load_tester_config_t;
/**
* Provide configurations for load testing.
*/
struct load_tester_config_t {
/**
* Implements backend_t interface
*/
backend_t backend;
/**
* Destroy the backend.
*/
void (*destroy)(load_tester_config_t *this);
};
/**
* Create a configuration backend for load testing.
*
* @return configuration backend
*/
load_tester_config_t *load_tester_config_create();
#endif /* LOAD_TESTER_CONFIG_H_ @}*/
@@ -0,0 +1,201 @@
/*
* Copyright (C) 2008 Martin Willi
* Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* $Id$
*/
#include "load_tester_creds.h"
#include <daemon.h>
#include <credentials/keys/shared_key.h>
#include <utils/identification.h>
typedef struct private_load_tester_creds_t private_load_tester_creds_t;
/**
* Private data of an load_tester_creds_t object
*/
struct private_load_tester_creds_t {
/**
* Public part
*/
load_tester_creds_t public;
/**
* Private key to create signatures
*/
private_key_t *private;
/**
* Trusted certificate to verify signatures
*/
certificate_t *cert;
};
/**
* 1024-bit RSA key
*/
static char private[] = {
0x30,0x82,0x02,0x5d,0x02,0x01,0x00,0x02,0x81,0x81,0x00,0xd0,0x5e,0xbe,0xe9,0xa0,
0x03,0xd8,0x64,0xbc,0x66,0x4c,0x2a,0x91,0xe7,0x54,0x93,0x19,0x1b,0xa4,0xf4,0x77,
0x39,0x49,0x6b,0x53,0x72,0xce,0x9b,0xd9,0x1c,0xe9,0x9c,0xff,0x04,0x55,0x12,0xf1,
0x24,0x45,0x71,0x38,0xa1,0x3d,0x33,0x0e,0xa7,0xee,0x60,0xf5,0xa4,0xda,0xee,0xa4,
0x2a,0x67,0xa4,0x64,0x5d,0x2c,0x05,0x79,0x57,0x39,0xd3,0x3e,0x14,0x90,0xea,0x4e,
0xe9,0xa4,0x92,0x6b,0xc6,0x8b,0x11,0x62,0x0d,0x29,0x1d,0x36,0x6a,0x05,0x41,0x02,
0xee,0x74,0x05,0xc0,0x07,0xb5,0xd2,0x0f,0x2a,0xd1,0x49,0xcc,0xd7,0x06,0xb8,0x94,
0x9c,0xc6,0xc4,0x31,0xfb,0xf1,0xdd,0xb5,0x71,0x5c,0x1e,0x26,0x06,0xe4,0xc4,0x07,
0xb2,0xae,0x24,0xb4,0x8e,0x13,0x6c,0xee,0x03,0xb9,0x9d,0x02,0x03,0x01,0x00,0x01,
0x02,0x81,0x80,0x09,0x50,0x02,0xb6,0x4c,0x49,0x7f,0xb5,0x58,0xda,0x35,0x93,0x3d,
0x7c,0x1a,0x42,0x8c,0xbf,0xb8,0x8a,0x98,0x7d,0x7d,0xf3,0x87,0x02,0x3d,0x8b,0xa7,
0x93,0x6c,0x39,0x71,0x08,0x4f,0x89,0x0e,0x2f,0xf1,0xce,0x92,0x9a,0x5a,0x32,0xda,
0xf7,0xd4,0x66,0x8e,0xf3,0xf4,0x38,0xf0,0x2b,0x59,0x00,0x76,0xdf,0xd7,0x24,0xd3,
0x7c,0x7b,0x80,0x09,0xb6,0xa1,0xbb,0xad,0xa2,0xc1,0x9b,0xa9,0xb2,0xb3,0x25,0x94,
0xb9,0x73,0x22,0x1a,0xcb,0x3c,0x96,0xf5,0xd8,0xd9,0x0c,0x70,0x5d,0xb7,0xd1,0xe8,
0xaa,0xe2,0x81,0xdf,0xd6,0xac,0xa5,0x68,0xad,0xdf,0x13,0xf3,0x92,0xba,0xfe,0x41,
0xe2,0x24,0x8a,0x08,0x2d,0x98,0x12,0x80,0x2d,0x30,0x71,0x4f,0x0c,0x40,0x53,0xe3,
0xfa,0x7a,0xe1,0x02,0x41,0x00,0xf8,0x20,0xf7,0x6b,0xcc,0xa6,0xc2,0xac,0xee,0xfd,
0x2c,0xab,0xe8,0x3e,0xb4,0x10,0xb5,0x38,0xcb,0xea,0x88,0x1a,0x83,0xda,0xc8,0xf6,
0x7d,0x99,0xba,0x82,0xb7,0xfd,0x75,0x72,0x6e,0x1d,0x9b,0xc8,0xe5,0xd3,0xf2,0xd0,
0x39,0x1b,0x98,0xd2,0xcf,0xd0,0x1c,0xf1,0x77,0x95,0x3a,0xc9,0xc7,0xf6,0x04,0xf9,
0xdd,0x65,0xde,0x68,0xb3,0x85,0x02,0x41,0x00,0xd6,0xfa,0xe6,0xfe,0x15,0x52,0x11,
0xab,0x29,0xe5,0xe0,0x13,0x81,0x0e,0xe2,0x83,0xd0,0x85,0xf8,0x61,0x8a,0xaa,0x14,
0xf0,0x5e,0x9f,0xee,0x39,0x29,0x7f,0x87,0x72,0x11,0x99,0x2b,0x6e,0xe4,0x9d,0x02,
0xf4,0x09,0x18,0xcb,0x1d,0x1b,0x9f,0x78,0xf9,0x47,0xc8,0x94,0x11,0x7f,0xc2,0xd3,
0x42,0x92,0x13,0x59,0x10,0x36,0x1e,0x0d,0x39,0x02,0x40,0x54,0xeb,0x0b,0x62,0x54,
0x46,0xda,0x27,0x4f,0x1f,0x4c,0x53,0x85,0x07,0x38,0x9e,0xe3,0x36,0x8d,0xeb,0x35,
0x2b,0x45,0xe6,0xf1,0x92,0x12,0x48,0x33,0x61,0x9b,0x50,0x5e,0x0a,0x8c,0x8f,0x0b,
0x8a,0xc4,0xc5,0x35,0xbb,0x77,0x5f,0xef,0x7c,0x6e,0x6c,0xbe,0x0b,0x11,0xae,0xfb,
0xd0,0xa4,0xe3,0x98,0xae,0x5e,0xcc,0x07,0x42,0xf3,0xf5,0x02,0x41,0x00,0xb8,0x60,
0x01,0x62,0x62,0xc8,0xbb,0x2c,0x90,0x47,0x7d,0xd1,0x5c,0x7b,0x76,0x9b,0xd4,0x68,
0x41,0xe8,0xee,0x33,0x06,0xb8,0x4c,0x7f,0x5f,0xa1,0x98,0xcc,0xae,0x4e,0x8f,0x77,
0x4d,0x3f,0xd3,0x44,0x31,0xf7,0x38,0x22,0x12,0x79,0x49,0x6a,0x91,0x27,0x42,0x80,
0x6d,0x35,0x40,0xdc,0xc7,0xb1,0x2d,0x74,0xf8,0x8a,0xa5,0xcf,0x4a,0x49,0x02,0x41,
0x00,0xd2,0x8c,0xb8,0x41,0xc2,0xf1,0x27,0x4a,0xe5,0xb8,0x12,0x52,0x0c,0xcc,0x1c,
0x0b,0x6e,0xee,0xf9,0xef,0x7c,0xf6,0x83,0x35,0x3c,0xd8,0xc8,0xfa,0xb6,0xba,0xf0,
0x3a,0xca,0x28,0xc7,0xfb,0xe6,0x71,0xea,0x53,0xd5,0x68,0xf2,0xe0,0x0b,0xcf,0x64,
0x78,0x31,0xa7,0xbb,0xc4,0x5c,0xd4,0x9e,0x4b,0xe3,0x39,0x2f,0x6f,0x50,0x35,0x3a,
0x7c,
};
/**
* And an associated self-signed certificate
*/
static char cert[] = {
0x30,0x82,0x01,0xdb,0x30,0x82,0x01,0x44,0xa0,0x03,0x02,0x01,0x02,0x02,0x11,0x00,
0xa9,0x92,0x2d,0x07,0x3e,0xdd,0x05,0x78,0x5a,0xcc,0x15,0x92,0x9c,0x6a,0x63,0x99,
0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x05,0x05,0x00,0x30,
0x17,0x31,0x15,0x30,0x13,0x06,0x03,0x55,0x04,0x03,0x13,0x0c,0x6c,0x6f,0x61,0x64,
0x2d,0x74,0x65,0x73,0x74,0x69,0x6e,0x67,0x30,0x1e,0x17,0x0d,0x30,0x38,0x31,0x30,
0x32,0x31,0x31,0x32,0x34,0x39,0x34,0x30,0x5a,0x17,0x0d,0x31,0x33,0x31,0x30,0x32,
0x30,0x31,0x32,0x34,0x39,0x34,0x30,0x5a,0x30,0x17,0x31,0x15,0x30,0x13,0x06,0x03,
0x55,0x04,0x03,0x13,0x0c,0x6c,0x6f,0x61,0x64,0x2d,0x74,0x65,0x73,0x74,0x69,0x6e,
0x67,0x30,0x81,0x9f,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,
0x01,0x05,0x00,0x03,0x81,0x8d,0x00,0x30,0x81,0x89,0x02,0x81,0x81,0x00,0xd0,0x5e,
0xbe,0xe9,0xa0,0x03,0xd8,0x64,0xbc,0x66,0x4c,0x2a,0x91,0xe7,0x54,0x93,0x19,0x1b,
0xa4,0xf4,0x77,0x39,0x49,0x6b,0x53,0x72,0xce,0x9b,0xd9,0x1c,0xe9,0x9c,0xff,0x04,
0x55,0x12,0xf1,0x24,0x45,0x71,0x38,0xa1,0x3d,0x33,0x0e,0xa7,0xee,0x60,0xf5,0xa4,
0xda,0xee,0xa4,0x2a,0x67,0xa4,0x64,0x5d,0x2c,0x05,0x79,0x57,0x39,0xd3,0x3e,0x14,
0x90,0xea,0x4e,0xe9,0xa4,0x92,0x6b,0xc6,0x8b,0x11,0x62,0x0d,0x29,0x1d,0x36,0x6a,
0x05,0x41,0x02,0xee,0x74,0x05,0xc0,0x07,0xb5,0xd2,0x0f,0x2a,0xd1,0x49,0xcc,0xd7,
0x06,0xb8,0x94,0x9c,0xc6,0xc4,0x31,0xfb,0xf1,0xdd,0xb5,0x71,0x5c,0x1e,0x26,0x06,
0xe4,0xc4,0x07,0xb2,0xae,0x24,0xb4,0x8e,0x13,0x6c,0xee,0x03,0xb9,0x9d,0x02,0x03,
0x01,0x00,0x01,0xa3,0x27,0x30,0x25,0x30,0x23,0x06,0x03,0x55,0x1d,0x11,0x04,0x1c,
0x30,0x1a,0x81,0x18,0x6c,0x6f,0x61,0x64,0x2d,0x74,0x65,0x73,0x74,0x40,0x73,0x74,
0x72,0x6f,0x6e,0x67,0x73,0x77,0x61,0x6e,0x2e,0x6f,0x72,0x67,0x30,0x0d,0x06,0x09,
0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x05,0x05,0x00,0x03,0x81,0x81,0x00,0x4f,
0x24,0x37,0x28,0xb5,0x54,0xd7,0x74,0x37,0x53,0x7b,0x99,0x66,0xd4,0x0b,0xe7,0xaa,
0xe6,0xeb,0xcd,0x30,0x30,0xbb,0xb4,0xfb,0x6c,0xf5,0xeb,0x83,0xe7,0xc5,0xc4,0xee,
0x0e,0x89,0xe9,0xd7,0xd0,0x30,0x3d,0xfb,0xe5,0xe3,0x2d,0x24,0x8c,0x27,0x50,0x62,
0xa5,0x00,0xe8,0xd5,0xdc,0xce,0xe6,0xf8,0xd1,0x9a,0xc2,0x31,0xf9,0x99,0x11,0xb5,
0x5a,0xad,0x6f,0x68,0x03,0x2b,0x3d,0x95,0x67,0x9f,0xf2,0xca,0x9f,0x5b,0x4a,0x6f,
0x6a,0xc3,0x56,0xb1,0x33,0x8e,0xc2,0x08,0x38,0x81,0xc0,0x12,0x87,0x55,0x42,0x62,
0xc3,0x17,0xef,0x70,0xbc,0x47,0x5a,0x5e,0x81,0x63,0x3f,0x6e,0xdc,0x97,0xd9,0x21,
0x1a,0xef,0xe4,0x75,0xac,0x11,0x19,0xc0,0x75,0x6d,0x23,0x18,0x05,0x72,0x73,
};
/**
* Implements credential_set_t.create_private_enumerator
*/
static enumerator_t* create_private_enumerator(private_load_tester_creds_t *this,
key_type_t type, identification_t *id)
{
if (type != KEY_ANY && type != KEY_RSA)
{
return NULL;
}
if (id)
{
identification_t *keyid;
keyid = this->private->get_id(this->private, id->get_type(id));
if (!keyid || !keyid->equals(keyid, id))
{
return NULL;
}
}
return enumerator_create_single(this->private, NULL);
}
/**
* Implements credential_set_t.create_cert_enumerator
*/
static enumerator_t* create_cert_enumerator(private_load_tester_creds_t *this,
certificate_type_t cert, key_type_t key,
identification_t *id, bool trusted)
{
if (cert != CERT_ANY && cert != CERT_X509)
{
return NULL;
}
if (key != KEY_ANY && key != KEY_RSA)
{
return NULL;
}
if (id && !this->cert->has_subject(this->cert, id))
{
return NULL;
}
return enumerator_create_single(this->cert, NULL);
}
/**
* Implementation of load_tester_creds_t.destroy
*/
static void destroy(private_load_tester_creds_t *this)
{
this->private->destroy(this->private);
this->cert->destroy(this->cert);
free(this);
}
load_tester_creds_t *load_tester_creds_create()
{
private_load_tester_creds_t *this = malloc_thing(private_load_tester_creds_t);
this->public.credential_set.create_shared_enumerator = (enumerator_t*(*)(credential_set_t*, shared_key_type_t, identification_t*, identification_t*))return_null;
this->public.credential_set.create_private_enumerator = (enumerator_t*(*) (credential_set_t*, key_type_t, identification_t*))create_private_enumerator;
this->public.credential_set.create_cert_enumerator = (enumerator_t*(*) (credential_set_t*, certificate_type_t, key_type_t,identification_t *, bool))create_cert_enumerator;
this->public.credential_set.create_cdp_enumerator = (enumerator_t*(*) (credential_set_t *,certificate_type_t, identification_t *))return_null;
this->public.credential_set.cache_cert = (void (*)(credential_set_t *, certificate_t *))nop;
this->public.destroy = (void(*) (load_tester_creds_t*))destroy;
this->private = lib->creds->create(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
BUILD_BLOB_ASN1_DER, chunk_create(private, sizeof(private)), BUILD_END);
this->cert = lib->creds->create(lib->creds, CRED_CERTIFICATE, CERT_X509,
BUILD_BLOB_ASN1_DER, chunk_create(cert, sizeof(cert)), BUILD_END);
return &this->public;
}
@@ -0,0 +1,53 @@
/*
* Copyright (C) 2008 Martin Willi
* Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* $Id$
*/
/**
* @defgroup load_tester_creds_t load_tester_creds
* @{ @ingroup load_tester
*/
#ifndef LOAD_TESTER_CREDS_H_
#define LOAD_TESTER_CREDS_H_
#include <credentials/credential_set.h>
typedef struct load_tester_creds_t load_tester_creds_t;
/**
* Provide hard-coded credentials for load testing.
*/
struct load_tester_creds_t {
/**
* Implements credential set interface.
*/
credential_set_t credential_set;
/**
* Destroy the backend.
*/
void (*destroy)(load_tester_creds_t *this);
};
/**
* Create a credential set for load testing.
*
* @return credential set
*/
load_tester_creds_t *load_tester_creds_create();
#endif /* LOAD_TESTER_CREDS_H_ @}*/
@@ -0,0 +1,161 @@
/*
* Copyright (C) 2008 Martin Willi
* Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* $Id$
*/
#include "load_tester_ipsec.h"
typedef struct private_load_tester_ipsec_t private_load_tester_ipsec_t;
/**
* Private variables and functions of kernel_pfkey class.
*/
struct private_load_tester_ipsec_t {
/**
* Public interface.
*/
load_tester_ipsec_t public;
/**
* faked SPI counter
*/
u_int32_t spi;
};
/**
* Implementation of kernel_interface_t.get_spi.
*/
static status_t get_spi(private_load_tester_ipsec_t *this,
host_t *src, host_t *dst,
protocol_id_t protocol, u_int32_t reqid,
u_int32_t *spi)
{
*spi = ++this->spi;
return SUCCESS;
}
/**
* Implementation of kernel_interface_t.get_cpi.
*/
static status_t get_cpi(private_load_tester_ipsec_t *this,
host_t *src, host_t *dst,
u_int32_t reqid, u_int16_t *cpi)
{
return FAILED;
}
/**
* Implementation of kernel_interface_t.add_sa.
*/
static status_t add_sa(private_load_tester_ipsec_t *this,
host_t *src, host_t *dst, u_int32_t spi,
protocol_id_t protocol, u_int32_t reqid,
u_int64_t expire_soft, u_int64_t expire_hard,
u_int16_t enc_alg, chunk_t enc_key,
u_int16_t int_alg, chunk_t int_key,
ipsec_mode_t mode, u_int16_t ipcomp, bool encap,
bool replace)
{
return SUCCESS;
}
/**
* Implementation of kernel_interface_t.update_sa.
*/
static status_t update_sa(private_load_tester_ipsec_t *this,
u_int32_t spi, protocol_id_t protocol,
host_t *src, host_t *dst,
host_t *new_src, host_t *new_dst, bool encap)
{
return SUCCESS;
}
/**
* Implementation of kernel_interface_t.del_sa.
*/
static status_t del_sa(private_load_tester_ipsec_t *this, host_t *dst,
u_int32_t spi, protocol_id_t protocol)
{
return SUCCESS;
}
/**
* Implementation of kernel_interface_t.add_policy.
*/
static status_t add_policy(private_load_tester_ipsec_t *this,
host_t *src, host_t *dst,
traffic_selector_t *src_ts,
traffic_selector_t *dst_ts,
policy_dir_t direction, protocol_id_t protocol,
u_int32_t reqid, bool high_prio, ipsec_mode_t mode,
u_int16_t ipcomp)
{
return SUCCESS;
}
/**
* Implementation of kernel_interface_t.query_policy.
*/
static status_t query_policy(private_load_tester_ipsec_t *this,
traffic_selector_t *src_ts,
traffic_selector_t *dst_ts,
policy_dir_t direction, u_int32_t *use_time)
{
*use_time = time(NULL);
return SUCCESS;
}
/**
* Implementation of kernel_interface_t.del_policy.
*/
static status_t del_policy(private_load_tester_ipsec_t *this,
traffic_selector_t *src_ts,
traffic_selector_t *dst_ts,
policy_dir_t direction)
{
return SUCCESS;
}
/**
* Implementation of kernel_interface_t.destroy.
*/
static void destroy(private_load_tester_ipsec_t *this)
{
free(this);
}
/*
* Described in header.
*/
load_tester_ipsec_t *load_tester_ipsec_create()
{
private_load_tester_ipsec_t *this = malloc_thing(private_load_tester_ipsec_t);
/* public functions */
this->public.interface.get_spi = (status_t(*)(kernel_ipsec_t*,host_t*,host_t*,protocol_id_t,u_int32_t,u_int32_t*))get_spi;
this->public.interface.get_cpi = (status_t(*)(kernel_ipsec_t*,host_t*,host_t*,u_int32_t,u_int16_t*))get_cpi;
this->public.interface.add_sa = (status_t(*)(kernel_ipsec_t *,host_t*,host_t*,u_int32_t,protocol_id_t,u_int32_t,u_int64_t,u_int64_t,u_int16_t,chunk_t,u_int16_t,chunk_t,ipsec_mode_t,u_int16_t,bool,bool))add_sa;
this->public.interface.update_sa = (status_t(*)(kernel_ipsec_t*,u_int32_t,protocol_id_t,host_t*,host_t*,host_t*,host_t*,bool))update_sa;
this->public.interface.del_sa = (status_t(*)(kernel_ipsec_t*,host_t*,u_int32_t,protocol_id_t))del_sa;
this->public.interface.add_policy = (status_t(*)(kernel_ipsec_t*,host_t*,host_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t,protocol_id_t,u_int32_t,bool,ipsec_mode_t,u_int16_t))add_policy;
this->public.interface.query_policy = (status_t(*)(kernel_ipsec_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t,u_int32_t*))query_policy;
this->public.interface.del_policy = (status_t(*)(kernel_ipsec_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t))del_policy;
this->public.interface.destroy = (void(*)(kernel_ipsec_t*)) destroy;
this->spi = 0;
return &this->public;
}
@@ -0,0 +1,48 @@
/*
* Copyright (C) 2008 Martin Willi
* Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* $Id$
*/
/**
* @defgroup load_tester_ipsec_i load_tester_ipsec
* @{ @ingroup load_tester
*/
#ifndef LOAD_TESTER_IPSEC_H_
#define LOAD_TESTER_IPSEC_H_
#include <kernel/kernel_ipsec.h>
typedef struct load_tester_ipsec_t load_tester_ipsec_t;
/**
* Implementation of a fake kernel ipsec interface for load testing.
*/
struct load_tester_ipsec_t {
/**
* Implements kernel_ipsec_t interface
*/
kernel_ipsec_t interface;
};
/**
* Create a faked kernel ipsec interface instance.
*
* @return kernel_load_tester_ipsec_t instance
*/
load_tester_ipsec_t *load_tester_ipsec_create();
#endif /* LOAD_TESTER_IPSEC_H_ @} */
@@ -0,0 +1,122 @@
/*
* Copyright (C) 2008 Martin Willi
* Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* $Id$
*/
#include "load_tester_plugin.h"
#include "load_tester_config.h"
#include "load_tester_creds.h"
#include "load_tester_ipsec.h"
#include <daemon.h>
#include <processing/jobs/callback_job.h>
typedef struct private_load_tester_plugin_t private_load_tester_plugin_t;
/**
* private data of load_tester plugin
*/
struct private_load_tester_plugin_t {
/**
* implements plugin interface
*/
load_tester_plugin_t public;
/**
* load_tester configuration backend
*/
load_tester_config_t *config;
/**
* load_tester credential set implementation
*/
load_tester_creds_t *creds;
};
/**
* Begin the load test
*/
static job_requeue_t do_load_test(private_load_tester_plugin_t *this)
{
peer_cfg_t *peer_cfg;
child_cfg_t *child_cfg = NULL;;
enumerator_t *enumerator;
int iterations, i;
iterations = lib->settings->get_int(lib->settings,
"charon.plugins.load_tester.iterations", 0);
peer_cfg = charon->backends->get_peer_cfg_by_name(charon->backends,
"load-test");
if (peer_cfg)
{
enumerator = peer_cfg->create_child_cfg_enumerator(peer_cfg);
if (enumerator->enumerate(enumerator, &child_cfg))
{
child_cfg->get_ref(child_cfg);
}
enumerator->destroy(enumerator);
if (child_cfg)
{
for (i = 0; i < iterations; i++)
{
charon->controller->initiate(charon->controller,
peer_cfg->get_ref(peer_cfg), child_cfg->get_ref(child_cfg),
NULL, NULL);
}
child_cfg->destroy(child_cfg);
}
peer_cfg->destroy(peer_cfg);
}
return JOB_REQUEUE_NONE;
}
/**
* Implementation of plugin_t.destroy
*/
static void destroy(private_load_tester_plugin_t *this)
{
charon->kernel_interface->remove_ipsec_interface(charon->kernel_interface,
(kernel_ipsec_constructor_t)load_tester_ipsec_create);
charon->backends->remove_backend(charon->backends, &this->config->backend);
charon->credentials->remove_set(charon->credentials, &this->creds->credential_set);
this->config->destroy(this->config);
this->creds->destroy(this->creds);
free(this);
}
/*
* see header file
*/
plugin_t *plugin_create()
{
private_load_tester_plugin_t *this = malloc_thing(private_load_tester_plugin_t);
this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
this->config = load_tester_config_create();
this->creds = load_tester_creds_create();
charon->backends->add_backend(charon->backends, &this->config->backend);
charon->credentials->add_set(charon->credentials, &this->creds->credential_set);
charon->kernel_interface->add_ipsec_interface(charon->kernel_interface,
(kernel_ipsec_constructor_t)load_tester_ipsec_create);
charon->processor->queue_job(charon->processor, (job_t*)callback_job_create(
(callback_job_cb_t)do_load_test, this, NULL, NULL));
return &this->public.plugin;
}
@@ -0,0 +1,51 @@
/*
* Copyright (C) 2008 Martin Willi
* Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* $Id$
*/
/**
* @defgroup load_tester load_tester
* @ingroup cplugins
*
* @defgroup load_tester_plugin load_tester_plugin
* @{ @ingroup load_tester
*/
#ifndef LOAD_TESTER_PLUGIN_H_
#define LOAD_TESTER_PLUGIN_H_
#include <plugins/plugin.h>
typedef struct load_tester_plugin_t load_tester_plugin_t;
/**
* Load tester plugin to inspect system core under high load.
*
* This plugin
*/
struct load_tester_plugin_t {
/**
* implements plugin interface
*/
plugin_t plugin;
};
/**
* Create a load_tester_plugin instance.
*/
plugin_t *plugin_create();
#endif /* LOAD_TESTER_PLUGIN_H_ @}*/