fixed MOBIKE roaming if clients address changes
authorMartin Willi <martin@strongswan.org>
Thu, 9 Oct 2008 08:25:11 +0000 (08:25 -0000)
committerMartin Willi <martin@strongswan.org>
Thu, 9 Oct 2008 08:25:11 +0000 (08:25 -0000)
src/charon/sa/ike_sa.c
src/charon/sa/tasks/ike_mobike.c

index 12f4ebe..af2c7d0 100644 (file)
@@ -1451,7 +1451,7 @@ static status_t process_message(private_ike_sa_t *this, message_t *message)
                        charon->scheduler->schedule_job(charon->scheduler, job,
                                                                                        HALF_OPEN_IKE_SA_TIMEOUT);
                }
-               
+               this->time.inbound = time(NULL);
                /* check if message is trustworthy, and update host information */
                if (this->state == IKE_CREATED || this->state == IKE_CONNECTING ||
                        message->get_exchange_type(message) != IKE_SA_INIT)
@@ -1460,7 +1460,6 @@ static status_t process_message(private_ike_sa_t *this, message_t *message)
                        {       /* with MOBIKE, we do no implicit updates */
                                update_hosts(this, me, other);
                        }
-                       this->time.inbound = time(NULL);
                }
                status = this->task_manager->process_message(this->task_manager, message);
                if (status != DESTROY_ME)
@@ -2242,9 +2241,7 @@ static status_t roam(private_ike_sa_t *this, bool address)
                        src->destroy(src);
                        return SUCCESS;
                }
-               /* old address is not valid anymore, try with new one */
-               src->set_port(src, this->my_host->get_port(this->my_host));
-               set_my_host(this, src);
+               src->destroy(src);
        }
        
        /* update addresses with mobike, if supported ... */
index a5fe74a..54b7d0a 100644 (file)
@@ -329,6 +329,24 @@ static status_t build_i(private_ike_mobike_t *this, message_t *message)
        }
        else if (message->get_exchange_type(message) == INFORMATIONAL)
        {
+               host_t *old, *new;
+               
+               /* we check if the existing address is still valid */ 
+               old = message->get_source(message);
+               new = charon->kernel_interface->get_source_addr(charon->kernel_interface,
+                                                                               message->get_destination(message), old);
+               if (new)
+               {
+                       if (!new->ip_equals(new, old))
+                       {
+                               new->set_port(new, old->get_port(old));
+                               message->set_source(message, new);
+                       }
+                       else
+                       {
+                               new->destroy(new);
+                       }
+               }
                if (this->update)
                {
                        message->add_notify(message, FALSE, UPDATE_SA_ADDRESSES, chunk_empty);