wg: Refactor socket create/bind/close operations
commita36b0bc581ec78f5ed39de882b9745efd907087e
authorAaron LI <aly@aaronly.me>
Tue, 28 Nov 2023 02:28:59 +0000 (28 10:28 +0800)
committerAaron LI <aly@aaronly.me>
Thu, 8 Feb 2024 06:44:46 +0000 (8 14:44 +0800)
tree9f92d77239ee45cdff74c9452691866e44e83a97
parent26251bb09d8da78963cf07c6e24324b599bc6367
wg: Refactor socket create/bind/close operations

- Add the wg_socket_open() function to do socket creation and binding
  for one AF, and then use it to simplify the wg_socket_init() function.
  Meanwhil, wg_socket_bind() thus becomes obsolete and is removed.
- Clean up wg_socket_uninit(), wg_socket_set_cookie() and
  wg_socket_set_sockopt().
- Add the 'so_lock' lock to protect the 'struct wg_socket' fields.
  Update wg_send() accordingly.
- Add a comment about EADDRNOTAVAIL and single-stack support.

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