vpp-swan: change flow in function for add route 43/39243/2
authorGabriel Oginski <[email protected]>
Fri, 14 Jul 2023 07:22:12 +0000 (07:22 +0000)
committerFan Zhang <[email protected]>
Wed, 19 Jul 2023 02:38:00 +0000 (02:38 +0000)
This patch addresses the issue when the list of available interfaces
is not up to date. Due to this issue adding a new route fails
and finally the connection is not established.

Type: fix
Signed-off-by: Gabriel Oginski <[email protected]>
Change-Id: I3a63c0dd99ebc28ea149b4b23867440937682761

extras/strongswan/vpp_sswan/kernel_vpp_ipsec.c
extras/strongswan/vpp_sswan/kernel_vpp_net.c
extras/strongswan/vpp_sswan/kernel_vpp_shared.h

index a48bd57..325a3d1 100644 (file)
 
 #define PRIO_BASE 384
 
-/**
- * Every 2 seconds, the thread responsible for collecting the available
- * interfaces will be executed.
- * Retrying 5 times every 1 second ensures that there is enough time to check
- * if the interface will be available.
- */
-#define N_RETRY_GET_IF 5
-
 u32 natt_port;
 
 /**
index 85e2768..82eea17 100644 (file)
@@ -159,18 +159,29 @@ manage_route (private_kernel_vpp_net_t *this, bool add, chunk_t dst,
   vl_api_fib_path_t *apath;
   bool exists = FALSE;
 
-  this->mutex->lock (this->mutex);
-  enumerator = this->ifaces->create_enumerator (this->ifaces);
-  while (enumerator->enumerate (enumerator, &entry))
+  for (int i = 0; i < N_RETRY_GET_IF; i++)
     {
-      if (streq (name, entry->if_name))
+      this->mutex->lock (this->mutex);
+      enumerator = this->ifaces->create_enumerator (this->ifaces);
+      while (enumerator->enumerate (enumerator, &entry))
        {
-         exists = TRUE;
-         break;
+         if (streq (name, entry->if_name))
+           {
+             exists = TRUE;
+             break;
+           }
        }
+      enumerator->destroy (enumerator);
+      this->mutex->unlock (this->mutex);
+
+      if (!exists)
+       {
+         DBG1 (DBG_NET, "if_name %s not found", name);
+         sleep (1);
+       }
+      else
+       break;
     }
-  enumerator->destroy (enumerator);
-  this->mutex->unlock (this->mutex);
 
   if (!exists)
     {
index c699d49..7e8d203 100644 (file)
  * limitations under the License.
  */
 
+/**
+ * Every 2 seconds, the thread responsible for collecting the available
+ * interfaces will be executed.
+ * Retrying 5 times every 1 second ensures that there is enough time to check
+ * if the interface will be available.
+ */
+#define N_RETRY_GET_IF 5
+
 typedef struct vac_t vac_t;
 
 /**