wg: Implement wg_peer_{set,get}_endpoint() to set the remote endpoint
commit9f69aef9c659f6223a4f71eef9afd8d77a890433
authorAaron LI <aly@aaronly.me>
Sat, 13 Jan 2024 08:19:38 +0000 (13 16:19 +0800)
committerAaron LI <aly@aaronly.me>
Thu, 8 Feb 2024 06:44:47 +0000 (8 14:44 +0800)
tree58ff5addb6575924dd4503e13f6d8481171354f5
parent70d1b63f626d2062a2ff5b344b80f6b48d78f8bb
wg: Implement wg_peer_{set,get}_endpoint() to set the remote endpoint

Moving the setting and getting the peer remote endpoint to their own
separate functions.  This cleans up the already lengthy
wg_ioctl_{set,get}() functions.

In addition, these two functions fix the following two issues:
- The 'p_endpoint_lock' wasn't acquired before setting/getting the
  endpoint address.
- The local address 'e_local' wasn't cleared when setting the remote
  endpoint address.

Referred-to: OpenBSD
sys/net/wg/if_wg.c