[APR-5544]libcharon: Check if the interface is available after terminate IKE SA
authorSeongsik Kim <sz.kim@samsung.com>
Mon, 28 Sep 2020 08:45:43 +0000 (17:45 +0900)
committerrobot <robot@samsung.com>
Wed, 14 Oct 2020 07:11:47 +0000 (16:11 +0900)
  [Jira] NEUS7920-26406
  [Problem] Even though there is no interface, a message is sent to the
    server after IKE SA terminate.
  [Cause] Send without checking if the interface is available.
  [Solution] Check if the interface is available.

Change-Id: I5b4b9b7ae64bed4ce7f3bb091df40ad05da82ad4
Signed-off-by: Seongsik Kim <sz.kim@samsung.com>
src/libcharon/control/controller.c

index 0c86275e206f74b85c4d976bdf521f0e469f9aa9..7a146585316eda8b72ae5950c01b24c38a3b58ed 100755 (executable)
@@ -569,6 +569,27 @@ METHOD(job_t, terminate_ike_execute, job_requeue_t,
        listener->ike_sa = ike_sa;
        listener->lock->unlock(listener->lock);
 
+#ifdef VOWIFI_CFG
+        char *iface;
+        if (charon->kernel->get_interface(charon->kernel, ike_sa->get_my_host(ike_sa), &iface))
+       {
+               DBG1(DBG_KNL, "HOST_IP %H is on interface %s", ike_sa->get_my_host(ike_sa), iface);
+        }
+       else
+       {
+               DBG1(DBG_KNL, "%H is not present on any interface. Deleting IKE_SA %s[%d] without sending message to server.", 
+                                               ike_sa->get_my_host(ike_sa), ike_sa->get_name(ike_sa), ike_sa->get_unique_id(ike_sa));
+
+               if (ike_sa->get_state(ike_sa) == IKE_ESTABLISHED)
+               {
+                       ike_sa->set_state(ike_sa, IKE_DELETING);
+               }
+
+               charon->bus->ike_updown(charon->bus, ike_sa, FALSE);
+               charon->ike_sa_manager->checkin_and_destroy(charon->ike_sa_manager,ike_sa);
+               return JOB_REQUEUE_NONE;
+        }
+#endif
        if (ike_sa->delete(ike_sa, listener->options.force) != DESTROY_ME)
        {       /* delete queued */
                listener->status = FAILED;