]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
ike-config: Also trigger handle-vips event if no virtual IPs requested
authorTobias Brunner <tobias@strongswan.org>
Fri, 16 Sep 2022 08:57:48 +0000 (10:57 +0200)
committerTobias Brunner <tobias@strongswan.org>
Fri, 16 Sep 2022 12:22:27 +0000 (14:22 +0200)
The ike-updown event is triggered by the ike-auth task, however, that
does so before the ike-config task runs and assigns/installs virtual IPs.
So listeners who require the IKE_SA to have virtual IPs assigned have to
use the assign/handle-vips events.  However, this doesn't work if the
handle-vips event is only triggered if there actually were any
configuration attributes requested.

src/libcharon/sa/ikev2/tasks/ike_config.c

index 221bc0d2082e79c08df552fed1139b162bb8fb59..6e976238d783595a5e5ee16b9316032b40b54694 100644 (file)
@@ -48,6 +48,11 @@ struct private_ike_config_t {
         */
        bool vip_requested;
 
+       /**
+        * Whether we requested any configuration attributes at all.
+        */
+       bool any_attributes_requested;
+
        /**
         * Received list of virtual IPs, host_t*
         */
@@ -322,10 +327,7 @@ METHOD(task_t, build_i, status_t,
                if (cp)
                {
                        message->add_payload(message, (payload_t*)cp);
-               }
-               else
-               {       /* we don't expect a CFG_REPLY */
-                       return SUCCESS;
+                       this->any_attributes_requested = TRUE;
                }
        }
        return NEED_MORE;
@@ -459,6 +461,12 @@ METHOD(task_t, process_i, status_t,
                enumerator_t *enumerator;
                host_t *host;
 
+               if (!this->any_attributes_requested)
+               {       /* just trigger the event even if no IPs were requested/assigned */
+                       charon->bus->handle_vips(charon->bus, this->ike_sa, TRUE);
+                       return SUCCESS;
+               }
+
                process_payloads(this, message);
 
                this->ike_sa->clear_virtual_ips(this->ike_sa, TRUE);
@@ -494,6 +502,8 @@ METHOD(task_t, migrate, void,
        this->requested->destroy_function(this->requested, free);
        this->requested = linked_list_create();
        this->public.task.build = _build_i;
+       this->vip_requested = FALSE;
+       this->any_attributes_requested = FALSE;
 }
 
 METHOD(task_t, destroy, void,