Hello, Let me ask "ok",
The diff fixes the problem as follows: Configure wg0 without wgrtable # ifconfig wg0 create wgport 7111 wgkey `openssl rand -base64 32` up # ifconfig wg0 wg0: flags=80c3<UP,BROADCAST,RUNNING,NOARP,MULTICAST> mtu 1420 index 6 priority 0 llprio 3 wgport 7111 wgpubkey OVDrQ6wTjZckC12gcUk8aeoYvF5oZ0wuyH17eZcS2BA= groups: wg afterwards, we start using a rtable which belongs rdomain 0, # netstat -R Rdomain 0 Interfaces: lo0 vio0 vio1 enc0 pflog0 wg0 Routing tables: 0 1 then we want to configure wgrtable to use that rtable, # ifconfig wg0 wgrtable 1 ifconfig: SIOCSWG: Address already in use # After the diff, the command is executed successfully. # ifconfig wg0 wgrtable 1 # ok? When changing wgrtable to a rtable which belongs to the same rdomain of the old one, close the existing socket first to prevent EADDRINUSE. Index: sys/net/if_wg.c =================================================================== RCS file: /var/cvs/openbsd/src/sys/net/if_wg.c,v retrieving revision 1.26 diff -u -p -r1.26 if_wg.c --- sys/net/if_wg.c 21 Jul 2022 11:26:50 -0000 1.26 +++ sys/net/if_wg.c 22 Jul 2022 01:59:14 -0000 @@ -750,6 +750,16 @@ wg_bind(struct wg_softc *sc, in_port_t * int retries = 0; retry: #endif + + if (port == sc->sc_udp_port && + rtable_l2(rtable) == rtable_l2(sc->sc_udp_rtable)) { + /* changing rtable in the same domain */ + wg_socket_close(&sc->sc_so4); +#ifdef INET6 + wg_socket_close(&sc->sc_so6); +#endif + } + if ((ret = wg_socket_open(&so4, AF_INET, &port, &rtable, sc)) != 0) return ret;