summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorMatthew Smith <mgsmith@netgate.com>2022-09-02 14:34:38 +0000
committerBeno�t Ganne <bganne@cisco.com>2022-09-08 13:41:54 +0000
commit6a3f0ab2fdc22e6e5d0bb8306a0161132f6294e4 (patch)
tree7884e4db3daf66ac7d34fe50276fe966cd9b6224 /src/plugins
parent503225c45832491b1a0374ad9db931aefc590d6f (diff)
wireguard: eliminate some calls to main thread
Type: improvement Roaming functionality allows the peer address to change. The main thread was being called to update a peer's address if necessary after processing a received packet. Check in the worker whether this is necessary before incurring the overhead of the RPC to the main thread. Signed-off-by: Matthew Smith <mgsmith@netgate.com> Change-Id: I02184b92dc658e0f57dd39993a3b2f9944187b45
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/wireguard/wireguard_input.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/plugins/wireguard/wireguard_input.c b/src/plugins/wireguard/wireguard_input.c
index 22850b832b4..f4d9132d948 100644
--- a/src/plugins/wireguard/wireguard_input.c
+++ b/src/plugins/wireguard/wireguard_input.c
@@ -837,8 +837,11 @@ wg_input_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
if (PREDICT_FALSE (peer_idx && (last_peer_time_idx != peer_idx)))
{
- wg_peer_update_endpoint_from_mt (*peer_idx, &out_src_ip,
- out_udp_src_port);
+ if (PREDICT_FALSE (
+ !ip46_address_is_equal (&peer->dst.addr, &out_src_ip) ||
+ peer->dst.port != out_udp_src_port))
+ wg_peer_update_endpoint_from_mt (*peer_idx, &out_src_ip,
+ out_udp_src_port);
wg_timers_any_authenticated_packet_received_opt (peer, time);
wg_timers_any_authenticated_packet_traversal (peer);
last_peer_time_idx = peer_idx;
@@ -970,8 +973,11 @@ wg_input_post (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame,
if (PREDICT_FALSE (peer_idx && (last_peer_time_idx != peer_idx)))
{
- wg_peer_update_endpoint_from_mt (*peer_idx, &out_src_ip,
- out_udp_src_port);
+ if (PREDICT_FALSE (
+ !ip46_address_is_equal (&peer->dst.addr, &out_src_ip) ||
+ peer->dst.port != out_udp_src_port))
+ wg_peer_update_endpoint_from_mt (*peer_idx, &out_src_ip,
+ out_udp_src_port);
wg_timers_any_authenticated_packet_received_opt (peer, time);
wg_timers_any_authenticated_packet_traversal (peer);
last_peer_time_idx = peer_idx;