wireguard: fix wg-output-tun feature configuration
[vpp.git] / src / plugins / wireguard / wireguard_peer.c
old mode 100755 (executable)
new mode 100644 (file)
index b41118f..0c93a25
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2020 Doc.ai and/or its affiliates.
+ * Copyright (c) 2020 Cisco and/or its affiliates.
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at:
@@ -80,6 +81,7 @@ wg_peer_clear (vlib_main_t * vm, wg_peer_t * peer)
   for (int i = 0; i < WG_N_TIMERS; i++)
     {
       peer->timers[i] = ~0;
+      peer->timers_dispatched[i] = 0;
     }
 
   peer->last_sent_handshake = vlib_time_now (vm) - (REKEY_TIMEOUT + 1);
@@ -289,13 +291,13 @@ wg_peer_add (u32 tun_sw_if_index,
     return (VNET_API_ERROR_INVALID_SW_IF_INDEX);
 
   /* *INDENT-OFF* */
-  pool_foreach (peer, wg_peer_pool,
-  ({
+  pool_foreach (peer, wg_peer_pool)
+   {
     if (!memcmp (peer->remote.r_public, public_key, NOISE_PUBLIC_KEY_LEN))
     {
       return (VNET_API_ERROR_ENTRY_ALREADY_EXISTS);
     }
-  }));
+  }
   /* *INDENT-ON* */
 
   if (pool_elts (wg_peer_pool) > MAX_PEERS)
@@ -345,9 +347,6 @@ wg_peer_remove (index_t peeri)
   wgi = wg_if_get (wg_if_find_by_sw_if_index (peer->wg_sw_if_index));
   wg_if_peer_remove (wgi, peeri);
 
-  vnet_feature_enable_disable ("ip4-output", "wg-output-tun",
-                              peer->wg_sw_if_index, 0, 0, 0);
-
   noise_remote_clear (wmp->vlib_main, &peer->remote);
   wg_peer_clear (wmp->vlib_main, peer);
   pool_put (wg_peer_pool, peer);
@@ -361,11 +360,11 @@ wg_peer_walk (wg_peer_walk_cb_t fn, void *data)
   index_t peeri;
 
   /* *INDENT-OFF* */
-  pool_foreach_index(peeri, wg_peer_pool,
+  pool_foreach_index (peeri, wg_peer_pool)
   {
     if (WALK_STOP == fn(peeri, data))
       return peeri;
-  });
+  }
   /* *INDENT-ON* */
   return INDEX_INVALID;
 }