]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
Made inactivity_timeout a per CHILD_SA config option
authorMartin Willi <martin@strongswan.org>
Wed, 27 Jan 2010 14:47:08 +0000 (15:47 +0100)
committerMartin Willi <martin@strongswan.org>
Wed, 27 Jan 2010 14:47:08 +0000 (15:47 +0100)
src/charon/config/child_cfg.c
src/charon/config/child_cfg.h
src/charon/plugins/load_tester/load_tester_config.c
src/charon/plugins/medcli/medcli_config.c
src/charon/plugins/nm/nm_service.c
src/charon/plugins/sql/sql_config.c
src/charon/plugins/stroke/stroke_config.c
src/charon/plugins/uci/uci_config.c
src/charon/sa/tasks/child_create.c

index 350a5a99e90c0d9ad5d85c62e77ab339a0f8382c..8410b3fe57ee3421fbc054489e1068d9da6f58f8 100644 (file)
@@ -106,6 +106,11 @@ struct private_child_cfg_t {
         */
        bool use_ipcomp;
 
+       /**
+        * Inactivity timeout
+        */
+       u_int32_t inactivity;
+
        /**
         * set up IPsec transport SA in MIPv6 proxy mode
         */
@@ -432,6 +437,14 @@ static bool use_ipcomp(private_child_cfg_t *this)
        return this->use_ipcomp;
 }
 
+/**
+ * Implementation of child_cfg_t.get_inactivity.
+ */
+static u_int32_t get_inactivity(private_child_cfg_t *this)
+{
+       return this->inactivity;
+}
+
 /**
  * Implementation of child_cfg_t.set_mipv6_options.
  */
@@ -492,7 +505,8 @@ static void destroy(private_child_cfg_t *this)
 child_cfg_t *child_cfg_create(char *name, lifetime_cfg_t *lifetime,
                                                          char *updown, bool hostaccess,
                                                          ipsec_mode_t mode, action_t dpd_action,
-                                                         action_t close_action, bool ipcomp)
+                                                         action_t close_action, bool ipcomp,
+                                                         u_int32_t inactivity)
 {
        private_child_cfg_t *this = malloc_thing(private_child_cfg_t);
 
@@ -511,6 +525,7 @@ child_cfg_t *child_cfg_create(char *name, lifetime_cfg_t *lifetime,
        this->public.get_dh_group = (diffie_hellman_group_t(*)(child_cfg_t*)) get_dh_group;
        this->public.set_mipv6_options = (void (*) (child_cfg_t*,bool,bool))set_mipv6_options;
        this->public.use_ipcomp = (bool (*) (child_cfg_t *))use_ipcomp;
+       this->public.get_inactivity = (u_int32_t (*) (child_cfg_t *))get_inactivity;
        this->public.use_proxy_mode = (bool (*) (child_cfg_t *))use_proxy_mode;
        this->public.install_policy = (bool (*) (child_cfg_t *))install_policy;
        this->public.get_ref = (child_cfg_t* (*) (child_cfg_t*))get_ref;
@@ -523,6 +538,7 @@ child_cfg_t *child_cfg_create(char *name, lifetime_cfg_t *lifetime,
        this->dpd_action = dpd_action;
        this->close_action = close_action;
        this->use_ipcomp = ipcomp;
+       this->inactivity = inactivity;
        this->proxy_mode = FALSE;
        this->install_policy = TRUE;
        this->refcount = 1;
index f98170d69309a58387efa31dfc881110bdee4bca..c6186ea366bd7c112bc34f6359093bd5e6914838 100644 (file)
@@ -231,6 +231,13 @@ struct child_cfg_t {
         */
        bool (*use_ipcomp)(child_cfg_t *this);
 
+       /**
+        * Get the inactivity timeout value.
+        *
+        * @return                              inactivity timeout in s
+        */
+       u_int32_t (*get_inactivity)(child_cfg_t *this);
+
        /**
         * Sets two options needed for Mobile IPv6 interoperability
         *
@@ -291,11 +298,13 @@ struct child_cfg_t {
  * @param dpd_action           DPD action
  * @param close_action         close action
  * @param ipcomp                       use IPComp, if peer supports it
+ * @param inactivity           inactivity timeout in s before closing a CHILD_SA
  * @return                                     child_cfg_t object
  */
 child_cfg_t *child_cfg_create(char *name, lifetime_cfg_t *lifetime,
                                                          char *updown, bool hostaccess,
                                                          ipsec_mode_t mode, action_t dpd_action,
-                                                         action_t close_action, bool ipcomp);
+                                                         action_t close_action, bool ipcomp,
+                                                         u_int32_t inactivity);
 
 #endif /** CHILD_CFG_H_ @}*/
index ae3fa8ffa2c87dce7b728b0c546bca3b53ac7094..82f408d4554605d0a4070d4554840d29115c870a 100644 (file)
@@ -210,7 +210,7 @@ static peer_cfg_t* generate_config(private_load_tester_config_t *this, uint num)
        }
 
        child_cfg = child_cfg_create("load-test", &lifetime, NULL, TRUE,
-                                                                MODE_TUNNEL, ACTION_NONE, ACTION_NONE, FALSE);
+                                                                MODE_TUNNEL, ACTION_NONE, ACTION_NONE, FALSE, 0);
        proposal = proposal_create_from_string(PROTO_ESP, "aes128-sha1");
        child_cfg->add_proposal(child_cfg, proposal);
        ts = traffic_selector_create_dynamic(0, 0, 65535);
index 6f2cd094e524f21b068fb445c5f4b8e236ce8d7b..2e49ebbf7d212c7c3118938b691558d171557141 100644 (file)
@@ -181,7 +181,7 @@ static peer_cfg_t *get_peer_cfg_by_name(private_medcli_config_t *this, char *nam
        peer_cfg->add_auth_cfg(peer_cfg, auth, FALSE);
 
        child_cfg = child_cfg_create(name, &lifetime, NULL, TRUE,
-                                                         MODE_TUNNEL, ACTION_NONE, ACTION_NONE, FALSE);
+                                                         MODE_TUNNEL, ACTION_NONE, ACTION_NONE, FALSE, 0);
        child_cfg->add_proposal(child_cfg, proposal_create_default(PROTO_ESP));
        child_cfg->add_traffic_selector(child_cfg, TRUE, ts_from_string(local_net));
        child_cfg->add_traffic_selector(child_cfg, FALSE, ts_from_string(remote_net));
@@ -259,7 +259,7 @@ static bool peer_enumerator_enumerate(peer_enumerator_t *this, peer_cfg_t **cfg)
        this->current->add_auth_cfg(this->current, auth, FALSE);
 
        child_cfg = child_cfg_create(name, &lifetime, NULL, TRUE, MODE_TUNNEL,
-                                                                ACTION_NONE, ACTION_NONE, FALSE);
+                                                                ACTION_NONE, ACTION_NONE, FALSE, 0);
        child_cfg->add_proposal(child_cfg, proposal_create_default(PROTO_ESP));
        child_cfg->add_traffic_selector(child_cfg, TRUE, ts_from_string(local_net));
        child_cfg->add_traffic_selector(child_cfg, FALSE, ts_from_string(remote_net));
index 04c7b2b12906a4eb5040ca3ad341dcd36a2fe880..3cc086764241f830d2e8cbc0843e0956b266ac70 100644 (file)
@@ -443,7 +443,7 @@ static gboolean connect_(NMVPNPlugin *plugin, NMConnection *connection,
 
        child_cfg = child_cfg_create(priv->name, &lifetime,
                                                                 NULL, TRUE, MODE_TUNNEL, /* updown, hostaccess */
-                                                                ACTION_NONE, ACTION_NONE, ipcomp);
+                                                                ACTION_NONE, ACTION_NONE, ipcomp, 0);
        child_cfg->add_proposal(child_cfg, proposal_create_default(PROTO_ESP));
        ts = traffic_selector_create_dynamic(0, 0, 65535);
        child_cfg->add_traffic_selector(child_cfg, TRUE, ts);
index 7c76c572d59f86ea5f0b2532d95ce943d3fe193d..afee0896cd5a5b0a162c403984c35a88b2477bae 100644 (file)
@@ -134,7 +134,7 @@ static child_cfg_t *build_child_cfg(private_sql_config_t *this, enumerator_t *e)
                        .time = { .life = lifetime, .rekey = rekeytime, .jitter = jitter }
                };
                child_cfg = child_cfg_create(name, &lft, updown, hostaccess, mode,
-                                                                        dpd, close, ipcomp);
+                                                                        dpd, close, ipcomp, 0);
                /* TODO: read proposal from db */
                child_cfg->add_proposal(child_cfg, proposal_create_default(PROTO_ESP));
                add_traffic_selectors(this, child_cfg, id);
index 1f585f72b6af9d7caa3cc68e1eadc8aaf27f7215..dcfae0bdb219b72b5cf753a7fa479e327fcdd21b 100644 (file)
@@ -786,7 +786,7 @@ static child_cfg_t *build_child_cfg(private_stroke_config_t *this,
        child_cfg = child_cfg_create(
                                msg->add_conn.name, &lifetime,
                                msg->add_conn.me.updown, msg->add_conn.me.hostaccess,
-                               msg->add_conn.mode, dpd, dpd, msg->add_conn.ipcomp);
+                               msg->add_conn.mode, dpd, dpd, msg->add_conn.ipcomp, 0);
        child_cfg->set_mipv6_options(child_cfg, msg->add_conn.proxy_mode,
                                                                                        msg->add_conn.install_policy);
        add_ts(this, &msg->add_conn.me, child_cfg, TRUE);
index d53d057503be408b2aa1de3050be6b4659d8edb7..a6ee970ad9cec14a86bbda3fb0fabd122b2fe7b8 100644 (file)
@@ -195,7 +195,7 @@ static bool peer_enumerator_enumerate(peer_enumerator_t *this, peer_cfg_t **cfg)
                this->peer_cfg->add_auth_cfg(this->peer_cfg, auth, FALSE);
 
                child_cfg = child_cfg_create(name, &lifetime, NULL, TRUE, MODE_TUNNEL,
-                                                                        ACTION_NONE, ACTION_NONE, FALSE);
+                                                                        ACTION_NONE, ACTION_NONE, FALSE, 0);
                child_cfg->add_proposal(child_cfg, create_proposal(esp_proposal, PROTO_ESP));
                child_cfg->add_traffic_selector(child_cfg, TRUE, create_ts(local_net));
                child_cfg->add_traffic_selector(child_cfg, FALSE, create_ts(remote_net));
index 04f8cc89ab26f8cd342af4305fdff0ed02bc496a..3f002f2633776d35c6153738b0dc8015ebcdfaf4 100644 (file)
@@ -251,19 +251,19 @@ static bool allocate_spi(private_child_create_t *this)
 /**
  * Schedule inactivity timeout for CHILD_SA with reqid, if enabled
  */
-static void schedule_inactivity_timeout(u_int32_t reqid)
+static void schedule_inactivity_timeout(private_child_create_t *this)
 {
-       time_t timeout;
+       u_int32_t timeout;
        bool close_ike;
 
-       timeout = lib->settings->get_time(lib->settings,
-                                                                         "charon.inactivity_timeout", 0);
+       timeout = this->config->get_inactivity(this->config);
        if (timeout)
        {
                close_ike = lib->settings->get_bool(lib->settings,
                                                                                "charon.inactivity_close_ike", FALSE);
-               charon->scheduler->schedule_job(charon->scheduler,
-                       (job_t*)inactivity_job_create(reqid, timeout, close_ike), timeout);
+               charon->scheduler->schedule_job(charon->scheduler, (job_t*)
+                               inactivity_job_create(this->child_sa->get_reqid(this->child_sa),
+                                                                         timeout, close_ike), timeout);
        }
 }
 
@@ -539,7 +539,7 @@ static status_t select_and_install(private_child_create_t *this, bool no_dh)
 
        if (!this->rekey)
        {       /* a rekeyed SA uses the same reqid, no need for a new job */
-               schedule_inactivity_timeout(this->child_sa->get_reqid(this->child_sa));
+               schedule_inactivity_timeout(this);
        }
        return SUCCESS;
 }