misc: move to new pool_foreach macros
[vpp.git] / src / plugins / wireguard / wireguard_if.c
index 46abdf6..f7eb5a1 100644 (file)
@@ -250,6 +250,13 @@ wg_if_create (u32 user_instance,
 
   *sw_if_indexp = (u32) ~ 0;
 
+  /*
+   * Check if the required port is already in use
+   */
+  udp_dst_port_info_t *pi = udp_get_dst_port_info (&udp_main, port, UDP_IP4);
+  if (pi)
+    return VNET_API_ERROR_UDP_PORT_TAKEN;
+
   /*
    * Allocate a wg_if instance. Either select on dynamically
    * or try to use the desired user_instance number.
@@ -366,11 +373,11 @@ wg_if_walk (wg_if_walk_cb_t fn, void *data)
   index_t wgii;
 
   /* *INDENT-OFF* */
-  pool_foreach_index (wgii, wg_if_pool,
+  pool_foreach_index (wgii, wg_if_pool)
   {
     if (WALK_STOP == fn(wgii, data))
       break;
-  });
+  }
   /* *INDENT-ON* */
 }