load-tester: Register kernel-ipsec implementation as plugin feature
[strongswan.git] / src / libcharon / plugins / load_tester / load_tester_plugin.c
index e684f22..a0c467e 100644 (file)
@@ -152,7 +152,7 @@ static job_requeue_t do_load_test(private_load_tester_plugin_t *this)
 
                charon->controller->initiate(charon->controller,
                                        peer_cfg, child_cfg->get_ref(child_cfg),
-                                       NULL, NULL, 0);
+                                       NULL, NULL, 0, FALSE);
                if (s)
                {
                        sleep(s);
@@ -240,16 +240,24 @@ METHOD(plugin_t, get_features, int,
                                PLUGIN_SDEPEND(PRIVKEY, KEY_RSA),
                                PLUGIN_SDEPEND(CERT_DECODE, CERT_ANY),
                                PLUGIN_SDEPEND(CERT_DECODE, CERT_X509),
+               PLUGIN_CALLBACK(kernel_ipsec_register, load_tester_ipsec_create),
+                       PLUGIN_PROVIDE(CUSTOM, "kernel-ipsec"),
        };
+       int count = countof(f);
+
        *features = f;
-       return countof(f);
+
+       if (!lib->settings->get_bool(lib->settings,
+                       "%s.plugins.load-tester.fake_kernel", FALSE, lib->ns))
+       {
+               count -= 2;
+       }
+       return count;
 }
 
 METHOD(plugin_t, destroy, void,
        private_load_tester_plugin_t *this)
 {
-       hydra->kernel_interface->remove_ipsec_interface(hydra->kernel_interface,
-                                               (kernel_ipsec_constructor_t)load_tester_ipsec_create);
        this->mutex->destroy(this->mutex);
        this->condvar->destroy(this->condvar);
        free(this);
@@ -289,12 +297,5 @@ plugin_t *load_tester_plugin_create()
                .mutex = mutex_create(MUTEX_TYPE_DEFAULT),
                .condvar = condvar_create(CONDVAR_TYPE_DEFAULT),
        );
-
-       if (lib->settings->get_bool(lib->settings,
-                       "%s.plugins.load-tester.fake_kernel", FALSE, lib->ns))
-       {
-               hydra->kernel_interface->add_ipsec_interface(hydra->kernel_interface,
-                                               (kernel_ipsec_constructor_t)load_tester_ipsec_create);
-       }
        return &this->public.plugin;
 }