Lines Matching defs:wg
134 * - struct wg_softc is an instance of wg interfaces
158 * - Each wg has a mutex(9) wg_lock, and a rwlock(9) wg_rwlock
840 #define WG_PEER_READER_FOREACH(wgp, wg) \
841 PSLIST_READER_FOREACH((wgp), &(wg)->wg_peers, struct wg_peer, \
843 #define WG_PEER_WRITER_FOREACH(wgp, wg) \
844 PSLIST_WRITER_FOREACH((wgp), &(wg)->wg_peers, struct wg_peer, \
846 #define WG_PEER_WRITER_INSERT_HEAD(wgp, wg) \
847 PSLIST_WRITER_INSERT_HEAD(&(wg)->wg_peers, (wgp), wgp_peerlist_entry)
857 wg_rnh(struct wg_softc *wg, const int family)
863 return wg->wg_rtable_ipv4;
867 return wg->wg_rtable_ipv6;
883 IF_CLONE_INITIALIZER("wg", wg_clone_create, wg_clone_destroy);
903 wg_psref_class = psref_class_create("wg", IPL_SOFTNET);
1321 wg_destroy_session(struct wg_softc *wg, struct wg_session *wgs)
1331 wgs0 = thmap_del(wg->wg_sessions_byindex,
1334 garbage = thmap_stage_gc(wg->wg_sessions_byindex);
1345 thmap_gc(wg->wg_sessions_byindex, garbage);
1356 * wg_get_session_index(wg, wgs)
1359 * in wg's table of sessions by index.
1365 wg_get_session_index(struct wg_softc *wg, struct wg_session *wgs)
1382 wgs0 = thmap_put(wg->wg_sessions_byindex,
1390 * wg_put_session_index(wg, wgs)
1400 wg_put_session_index(struct wg_softc *wg, struct wg_session *wgs)
1408 wg_destroy_session(wg, wgs);
1435 wg_fill_msg_init(struct wg_softc *wg, struct wg_peer *wgp,
1482 cipher_key, 0, wg->wg_pubkey, sizeof(wg->wg_pubkey),
1491 wg_algo_dh_kdf(ckey, cipher_key, wg->wg_privkey, wgp->wgp_pubkey);
1529 * wg_initiator_priority(wg, wgp)
1571 wg_initiator_priority(struct wg_softc *wg, struct wg_peer *wgp)
1582 wg->wg_pubkey, sizeof(wg->wg_pubkey));
1593 wg_handle_msg_init(struct wg_softc *wg, const struct wg_msg_init *wgmi,
1609 wg->wg_pubkey, sizeof(wg->wg_pubkey),
1636 wg_algo_hash(hash, wg->wg_pubkey, sizeof(wg->wg_pubkey));
1649 wg_algo_dh_kdf(ckey, cipher_key, wg->wg_privkey, wgmi->wgmi_ephemeral);
1658 WG_LOG_RATECHECK(&wg->wg_ppsratecheck, LOG_DEBUG,
1660 if_name(&wg->wg_if));
1666 wgp = wg_lookup_peer_by_pubkey(wg, peer_pubkey, &psref_peer);
1680 if (__predict_false(wg_is_underload(wg, wgp, WG_MSG_TYPE_INIT))) {
1693 wg_send_cookie_msg(wg, wgp, wgmi->wgmi_sender,
1699 wg_send_cookie_msg(wg, wgp, wgmi->wgmi_sender,
1716 wg_algo_dh_kdf(ckey, cipher_key, wg->wg_privkey, wgp->wgp_pubkey);
1726 if_name(&wg->wg_if), wgp->wgp_name);
1742 if_name(&wg->wg_if), wgp->wgp_name);
1756 if (wg_initiator_priority(wg, wgp)) {
1762 wg_put_session_index(wg, wgs);
1772 wg_put_session_index(wg, wgs);
1780 wg_put_session_index(wg, wgs);
1793 wg_get_session_index(wg, wgs);
1823 wg_send_handshake_msg_resp(wg, wgp, wgs, wgmi);
1856 wg_get_so_by_af(struct wg_softc *wg, const int af)
1862 return wg->wg_so4;
1866 return wg->wg_so6;
1869 panic("wg: no such af: %d", af);
1923 wg_send_handshake_msg_init(struct wg_softc *wg, struct wg_peer *wgp)
1947 wg_put_session_index(wg, wgs);
1958 wg_get_session_index(wg, wgs);
1979 wg_fill_msg_init(wg, wgp, wgs, wgmi);
1981 error = wg->wg_ops->send_hs_msg(wgp, m); /* consumes m */
1991 wg_put_session_index(wg, wgs);
2006 wg_fill_msg_resp(struct wg_softc *wg, struct wg_peer *wgp,
2102 * wg_swap_sessions(wg, wgp)
2105 * wg for peer wgp. Publish it as the stable session, send queued
2111 wg_swap_sessions(struct wg_softc *wg, struct wg_peer *wgp)
2198 wg_handle_msg_resp(struct wg_softc *wg, const struct wg_msg_resp *wgmr,
2211 wg->wg_pubkey, sizeof(wg->wg_pubkey),
2225 wgs = wg_lookup_session_by_index(wg, wgmr->wgmr_receiver, &psref);
2241 if (__predict_false(wg_is_underload(wg, wgp, WG_MSG_TYPE_RESP))) {
2254 wg_send_cookie_msg(wg, wgp, wgmr->wgmr_sender,
2260 wg_send_cookie_msg(wg, wgp, wgmr->wgmr_sender,
2305 wg_algo_dh_kdf(ckey, NULL, wg->wg_privkey, wgmr->wgmr_ephemeral);
2326 if_name(&wg->wg_if), wgp->wgp_name);
2380 wg_swap_sessions(wg, wgp);
2389 wg_send_handshake_msg_resp(struct wg_softc *wg, struct wg_peer *wgp,
2408 wg_fill_msg_resp(wg, wgp, wgs, wgmr, wgmi);
2410 error = wg->wg_ops->send_hs_msg(wgp, m); /* consumes m */
2420 wg_lookup_peer_by_pubkey(struct wg_softc *wg,
2426 wgp = thmap_get(wg->wg_peers_bypubkey, pubkey, WG_STATIC_KEY_LEN);
2435 wg_fill_msg_cookie(struct wg_softc *wg, struct wg_peer *wgp,
2489 wg_algo_mac_cookie(key, sizeof(key), wg->wg_pubkey,
2490 sizeof(wg->wg_pubkey));
2500 wg_send_cookie_msg(struct wg_softc *wg, struct wg_peer *wgp,
2517 wg_fill_msg_cookie(wg, wgp, wgmc, sender, mac1, src);
2519 error = wg->wg_ops->send_hs_msg(wgp, m); /* consumes m */
2529 wg_is_underload(struct wg_softc *wg, struct wg_peer *wgp, int msgtype)
2618 wg_lookup_session_by_index(struct wg_softc *wg, const uint32_t index,
2624 wgs = thmap_get(wg->wg_sessions_byindex, &index, sizeof index);
2763 wg_validate_route(struct wg_softc *wg, struct wg_peer *wgp_expected,
2803 wgp = wg_pick_peer_by_sa(wg, sa, &psref);
2893 wg_handle_msg_data(struct wg_softc *wg, struct mbuf *m,
2916 wgs = wg_lookup_session_by_index(wg, wgmd->wgmd_receiver, &psref);
2970 if_name(&wg->wg_if), wgp->wgp_name,
3025 if_name(&wg->wg_if), wgp->wgp_name);
3039 if_name(&wg->wg_if), wgp->wgp_name,
3070 ok = wg_validate_route(wg, wgp, af, decrypted_buf);
3072 wg->wg_ops->input(&wg->wg_if, n, af);
3097 if_name(&wg->wg_if), wgp->wgp_name, addrstr);
3151 wg_handle_msg_cookie(struct wg_softc *wg, const struct wg_msg_cookie *wgmc)
3163 wgs = wg_lookup_session_by_index(wg, wgmc->wgmc_receiver, &psref);
3197 "error=%d\n", if_name(&wg->wg_if), wgp->wgp_name, error);
3214 wg_validate_msg_header(struct wg_softc *wg, struct mbuf *m)
3246 WG_LOG_RATECHECK(&wg->wg_ppsratecheck, LOG_DEBUG,
3247 "%s: Unexpected msg type: %u\n", if_name(&wg->wg_if),
3274 wg_handle_packet(struct wg_softc *wg, struct mbuf *m,
3281 m = wg_validate_msg_header(wg, m);
3289 wg_handle_msg_init(wg, (struct wg_msg_init *)wgm, src);
3292 wg_handle_msg_resp(wg, (struct wg_msg_resp *)wgm, src);
3295 wg_handle_msg_cookie(wg, (struct wg_msg_cookie *)wgm);
3298 wg_handle_msg_data(wg, m, src);
3309 wg_receive_packets(struct wg_softc *wg, const int af)
3320 so = wg_get_so_by_af(wg, af);
3335 wg_handle_packet(wg, m, src);
3354 wg_task_send_init_message(struct wg_softc *wg, struct wg_peer *wgp)
3364 if_name(&wg->wg_if));
3384 wg_send_handshake_msg_init(wg, wgp);
3388 wg_task_retry_handshake(struct wg_softc *wg, struct wg_peer *wgp)
3406 wg_put_session_index(wg, wgs);
3424 wg_task_send_init_message(wg, wgp);
3428 wg_task_establish_session(struct wg_softc *wg, struct wg_peer *wgp)
3465 wg_swap_sessions(wg, wgp);
3470 wg_task_endpoint_changed(struct wg_softc *wg, struct wg_peer *wgp)
3490 wg_task_send_keepalive_message(struct wg_softc *wg, struct wg_peer *wgp)
3506 wg_task_destroy_prev_session(struct wg_softc *wg, struct wg_peer *wgp)
3527 wg_put_session_index(wg, wgs);
3546 wg_put_session_index(wg, wgs);
3568 struct wg_softc *wg = wgp->wgp_sc;
3578 wg_task_send_init_message(wg, wgp);
3580 wg_task_retry_handshake(wg, wgp);
3582 wg_task_establish_session(wg, wgp);
3584 wg_task_endpoint_changed(wg, wgp);
3586 wg_task_send_keepalive_message(wg, wgp);
3588 wg_task_destroy_prev_session(wg, wgp);
3599 struct wg_softc *wg = container_of(job, struct wg_softc, wg_job);
3602 mutex_enter(wg->wg_intr_lock);
3603 while ((upcalls = wg->wg_upcalls) != 0) {
3604 wg->wg_upcalls = 0;
3605 mutex_exit(wg->wg_intr_lock);
3608 wg_receive_packets(wg, AF_INET);
3610 wg_receive_packets(wg, AF_INET6);
3612 mutex_enter(wg->wg_intr_lock);
3615 mutex_exit(wg->wg_intr_lock);
3619 wg_bind_port(struct wg_softc *wg, const uint16_t port)
3622 uint16_t old_port = wg->wg_listen_port;
3634 error = sobind(wg->wg_so4, sintosa(sin), curlwp);
3646 error = sobind(wg->wg_so6, sin6tosa(sin6), curlwp);
3651 wg->wg_listen_port = port;
3659 struct wg_softc *wg = cookie;
3666 mutex_enter(wg->wg_intr_lock);
3667 wg->wg_upcalls |= reason;
3668 threadpool_schedule_job(wg->wg_threadpool, &wg->wg_job);
3669 mutex_exit(wg->wg_intr_lock);
3694 struct wg_softc *wg = arg;
3700 /* Verify the mbuf chain is long enough to have a wg msg header. */
3733 wg_handle_msg_data(wg, m, src);
3750 wg_socreate(struct wg_softc *wg, int af, struct socket **sop)
3760 so->so_upcallarg = wg;
3763 inpcb_register_overudp_cb(sotoinpcb(so), wg_overudp_cb, wg);
3881 wg_alloc_peer(struct wg_softc *wg)
3887 wgp->wgp_sc = wg;
3939 struct wg_softc *wg = wgp->wgp_sc;
3942 rw_enter(wg->wg_rwlock, RW_WRITER);
3945 struct radix_node_head *rnh = wg_rnh(wg, wga->wga_family);
3956 if_name(&wg->wg_if), addrstr);
3959 rw_exit(wg->wg_rwlock);
3974 wg_destroy_session(wg, wgs);
3987 wg_destroy_session(wg, wgs);
4010 wg_destroy_all_peers(struct wg_softc *wg)
4017 mutex_enter(wg->wg_lock);
4018 WG_PEER_WRITER_FOREACH(wgp, wg) {
4020 wgp0 = thmap_del(wg->wg_peers_byname, wgp->wgp_name,
4023 garbage_byname = thmap_stage_gc(wg->wg_peers_byname);
4025 wgp0 = thmap_del(wg->wg_peers_bypubkey, wgp->wgp_pubkey,
4028 garbage_bypubkey = thmap_stage_gc(wg->wg_peers_bypubkey);
4030 wg->wg_npeers--;
4037 mutex_exit(wg->wg_lock);
4045 thmap_gc(wg->wg_peers_byname, garbage_byname);
4046 thmap_gc(wg->wg_peers_bypubkey, garbage_bypubkey);
4052 wg_destroy_peer_name(struct wg_softc *wg, const char *name)
4057 mutex_enter(wg->wg_lock);
4058 wgp = thmap_del(wg->wg_peers_byname, name, strlen(name));
4060 wgp0 = thmap_del(wg->wg_peers_bypubkey, wgp->wgp_pubkey,
4063 garbage_byname = thmap_stage_gc(wg->wg_peers_byname);
4064 garbage_bypubkey = thmap_stage_gc(wg->wg_peers_bypubkey);
4066 wg->wg_npeers--;
4067 if (wg->wg_npeers == 0)
4068 if_link_state_change(&wg->wg_if, LINK_STATE_DOWN);
4074 mutex_exit(wg->wg_lock);
4082 thmap_gc(wg->wg_peers_byname, garbage_byname);
4083 thmap_gc(wg->wg_peers_bypubkey, garbage_bypubkey);
4089 wg_if_attach(struct wg_softc *wg)
4092 wg->wg_if.if_addrlen = 0;
4093 wg->wg_if.if_mtu = WG_MTU;
4094 wg->wg_if.if_flags = IFF_MULTICAST;
4095 wg->wg_if.if_extflags = IFEF_MPSAFE;
4096 wg->wg_if.if_ioctl = wg_ioctl;
4097 wg->wg_if.if_output = wg_output;
4098 wg->wg_if.if_init = wg_init;
4100 wg->wg_if.if_start = wg_start;
4102 wg->wg_if.if_stop = wg_stop;
4103 wg->wg_if.if_type = IFT_OTHER;
4104 wg->wg_if.if_dlt = DLT_NULL;
4105 wg->wg_if.if_softc = wg;
4107 IFQ_SET_READY(&wg->wg_if.if_snd);
4109 if_initialize(&wg->wg_if);
4111 wg->wg_if.if_link_state = LINK_STATE_DOWN;
4112 if_alloc_sadl(&wg->wg_if);
4113 if_register(&wg->wg_if);
4115 bpf_attach(&wg->wg_if, DLT_NULL, sizeof(uint32_t));
4121 wg_if_detach(struct wg_softc *wg)
4123 struct ifnet *ifp = &wg->wg_if;
4132 struct wg_softc *wg;
4141 wg = kmem_zalloc(sizeof(*wg), KM_SLEEP);
4143 if_initname(&wg->wg_if, ifc->ifc_name, unit);
4145 PSLIST_INIT(&wg->wg_peers);
4146 wg->wg_peers_bypubkey = thmap_create(0, NULL, THMAP_NOCOPY);
4147 wg->wg_peers_byname = thmap_create(0, NULL, THMAP_NOCOPY);
4148 wg->wg_sessions_byindex = thmap_create(0, NULL, THMAP_NOCOPY);
4149 wg->wg_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NONE);
4150 wg->wg_intr_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_SOFTNET);
4151 wg->wg_rwlock = rw_obj_alloc();
4152 threadpool_job_init(&wg->wg_job, wg_job, wg->wg_intr_lock,
4153 "%s", if_name(&wg->wg_if));
4154 wg->wg_ops = &wg_ops_rumpkernel;
4156 error = threadpool_get(&wg->wg_threadpool, PRI_NONE);
4161 error = wg_socreate(wg, AF_INET, &wg->wg_so4);
4164 rn_inithead((void **)&wg->wg_rtable_ipv4,
4168 error = wg_socreate(wg, AF_INET6, &wg->wg_so6);
4171 rn_inithead((void **)&wg->wg_rtable_ipv6,
4175 error = wg_if_attach(wg);
4182 wg_destroy_all_peers(wg);
4183 wg_if_detach(wg);
4186 solock(wg->wg_so6);
4187 wg->wg_so6->so_rcv.sb_flags &= ~SB_UPCALL;
4188 sounlock(wg->wg_so6);
4191 solock(wg->wg_so4);
4192 wg->wg_so4->so_rcv.sb_flags &= ~SB_UPCALL;
4193 sounlock(wg->wg_so4);
4195 mutex_enter(wg->wg_intr_lock);
4196 threadpool_cancel_job(wg->wg_threadpool, &wg->wg_job);
4197 mutex_exit(wg->wg_intr_lock);
4199 if (wg->wg_rtable_ipv6 != NULL)
4200 free(wg->wg_rtable_ipv6, M_RTABLE);
4201 soclose(wg->wg_so6);
4205 if (wg->wg_rtable_ipv4 != NULL)
4206 free(wg->wg_rtable_ipv4, M_RTABLE);
4207 soclose(wg->wg_so4);
4210 threadpool_put(wg->wg_threadpool, PRI_NONE);
4211 fail0: threadpool_job_destroy(&wg->wg_job);
4212 rw_obj_free(wg->wg_rwlock);
4213 mutex_obj_free(wg->wg_intr_lock);
4214 mutex_obj_free(wg->wg_lock);
4215 thmap_destroy(wg->wg_sessions_byindex);
4216 thmap_destroy(wg->wg_peers_byname);
4217 thmap_destroy(wg->wg_peers_bypubkey);
4218 PSLIST_DESTROY(&wg->wg_peers);
4219 kmem_free(wg, sizeof(*wg));
4227 struct wg_softc *wg = container_of(ifp, struct wg_softc, wg_if);
4230 if (wg_user_mode(wg)) {
4231 rumpuser_wg_destroy(wg->wg_user);
4232 wg->wg_user = NULL;
4236 wg_destroy_all_peers(wg);
4237 wg_if_detach(wg);
4239 solock(wg->wg_so6);
4240 wg->wg_so6->so_rcv.sb_flags &= ~SB_UPCALL;
4241 sounlock(wg->wg_so6);
4244 solock(wg->wg_so4);
4245 wg->wg_so4->so_rcv.sb_flags &= ~SB_UPCALL;
4246 sounlock(wg->wg_so4);
4248 mutex_enter(wg->wg_intr_lock);
4249 threadpool_cancel_job(wg->wg_threadpool, &wg->wg_job);
4250 mutex_exit(wg->wg_intr_lock);
4252 if (wg->wg_rtable_ipv6 != NULL)
4253 free(wg->wg_rtable_ipv6, M_RTABLE);
4254 soclose(wg->wg_so6);
4257 if (wg->wg_rtable_ipv4 != NULL)
4258 free(wg->wg_rtable_ipv4, M_RTABLE);
4259 soclose(wg->wg_so4);
4261 threadpool_put(wg->wg_threadpool, PRI_NONE);
4262 threadpool_job_destroy(&wg->wg_job);
4263 rw_obj_free(wg->wg_rwlock);
4264 mutex_obj_free(wg->wg_intr_lock);
4265 mutex_obj_free(wg->wg_lock);
4266 thmap_destroy(wg->wg_sessions_byindex);
4267 thmap_destroy(wg->wg_peers_byname);
4268 thmap_destroy(wg->wg_peers_bypubkey);
4269 PSLIST_DESTROY(&wg->wg_peers);
4270 kmem_free(wg, sizeof(*wg));
4277 wg_pick_peer_by_sa(struct wg_softc *wg, const struct sockaddr *sa,
4291 rw_enter(wg->wg_rwlock, RW_READER);
4293 rnh = wg_rnh(wg, sa->sa_family);
4308 rw_exit(wg->wg_rwlock);
4313 wg_fill_msg_data(struct wg_softc *wg, struct wg_peer *wgp,
4330 struct wg_softc *wg = ifp->if_softc;
4343 if_name(&wg->wg_if));
4358 wgp = wg_pick_peer_by_sa(wg, dst, &wgp_psref);
4390 if_name(&wg->wg_if));
4468 struct wg_softc *wg = wgp->wgp_sc;
4508 wg_fill_msg_data(wg, wgp, wgs, wgmd);
4516 error = wg->wg_ops->send_data_msg(wgp, n); /* consumes n */
4525 if_statadd(&wg->wg_if, if_obytes, mlen);
4526 if_statinc(&wg->wg_if, if_opackets);
4534 * wg(4) starts operating within <1sec, or after 136 years of
4636 wg_rtable_add_route(struct wg_softc *wg, struct wg_allowedip *wga)
4642 rw_enter(wg->wg_rwlock, RW_WRITER);
4643 rnh = wg_rnh(wg, wga->wga_family);
4647 rw_exit(wg->wg_rwlock);
4656 wg_handle_prop_peer(struct wg_softc *wg, prop_dictionary_t peer,
4687 struct wg_peer *wgp = wg_alloc_peer(wg);
4821 error = wg_rtable_add_route(wg, wga);
4859 wg_ioctl_set_private_key(struct wg_softc *wg, struct ifdrv *ifd)
4887 memcpy(wg->wg_privkey, privkey, WG_STATIC_KEY_LEN);
4888 wg_calc_pubkey(wg->wg_pubkey, wg->wg_privkey);
4897 wg_ioctl_set_listen_port(struct wg_softc *wg, struct ifdrv *ifd)
4914 error = wg->wg_ops->bind_port(wg, (uint16_t)port);
4922 wg_ioctl_add_peer(struct wg_softc *wg, struct ifdrv *ifd)
4937 error = wg_handle_prop_peer(wg, prop_dict, &wgp);
4941 mutex_enter(wg->wg_lock);
4942 if (thmap_get(wg->wg_peers_bypubkey, wgp->wgp_pubkey,
4945 thmap_get(wg->wg_peers_byname, wgp->wgp_name,
4947 mutex_exit(wg->wg_lock);
4952 wgp0 = thmap_put(wg->wg_peers_bypubkey, wgp->wgp_pubkey,
4956 wgp0 = thmap_put(wg->wg_peers_byname, wgp->wgp_name,
4960 WG_PEER_WRITER_INSERT_HEAD(wgp, wg);
4961 wg->wg_npeers++;
4962 mutex_exit(wg->wg_lock);
4964 if_link_state_change(&wg->wg_if, LINK_STATE_UP);
4972 wg_ioctl_delete_peer(struct wg_softc *wg, struct ifdrv *ifd)
4992 error = wg_destroy_peer_name(wg, name);
4999 wg_is_authorized(struct wg_softc *wg, u_long cmd)
5005 KAUTH_NETWORK_INTERFACE_WG, au, &wg->wg_if,
5010 wg_ioctl_get(struct wg_softc *wg, struct ifdrv *ifd)
5023 if (wg_is_authorized(wg, SIOCGDRVSPEC)) {
5025 wg->wg_privkey, WG_STATIC_KEY_LEN))
5029 if (wg->wg_listen_port != 0) {
5031 wg->wg_listen_port))
5035 if (wg->wg_npeers == 0)
5044 WG_PEER_READER_FOREACH(wgp, wg) {
5069 if (wg_is_authorized(wg, SIOCGDRVSPEC)) {
5185 struct wg_softc *wg = ifp->if_softc;
5217 if (!wg_is_authorized(wg, cmd)) {
5222 error = wg_ioctl_set_private_key(wg, ifd);
5225 error = wg_ioctl_set_listen_port(wg, ifd);
5228 error = wg_ioctl_add_peer(wg, ifd);
5231 error = wg_ioctl_delete_peer(wg, ifd);
5239 return wg_ioctl_get(wg, ifd);
5264 error = wg_ioctl_linkstr(wg, ifd);
5267 wg->wg_ops = &wg_ops_rumpuser;
5277 if (!wg_user_mode(wg))
5292 strncpy(ifra->ifra_name, rumpuser_wg_get_tunname(wg->wg_user),
5294 error = rumpuser_wg_ioctl(wg->wg_user, cmd, ifra, AF_INET);
5306 strncpy(ifra->ifra_name, rumpuser_wg_get_tunname(wg->wg_user),
5308 error = rumpuser_wg_ioctl(wg->wg_user, cmd, ifra, AF_INET6);
5366 SYSCTL_SETUP(sysctl_net_wg_setup, "sysctl net.wg setup")
5372 CTLTYPE_NODE, "wg",
5373 SYSCTL_DESCR("wg(4)"),
5416 wg_user_mode(struct wg_softc *wg)
5419 return wg->wg_user != NULL;
5423 wg_ioctl_linkstr(struct wg_softc *wg, struct ifdrv *ifd)
5425 struct ifnet *ifp = &wg->wg_if;
5436 } else if (wg->wg_user != NULL) {
5455 error = rumpuser_wg_create(tun_name, wg, &wg->wg_user);
5466 struct wg_softc *wg = wgp->wgp_sc;
5483 error = rumpuser_wg_send_peer(wg->wg_user, wgsatosa(wgsa), iov, 1);
5509 struct wg_softc *wg = ifp->if_softc;
5552 rumpuser_wg_send_user(wg->wg_user, iov, 2);
5558 wg_bind_port_user(struct wg_softc *wg, const uint16_t port)
5561 uint16_t old_port = wg->wg_listen_port;
5566 error = rumpuser_wg_sock_bind(wg->wg_user, port);
5570 wg->wg_listen_port = port;
5578 rumpkern_wg_recv_user(struct wg_softc *wg, struct iovec *iov, size_t iovlen)
5580 struct ifnet *ifp = &wg->wg_if;
5607 rumpkern_wg_recv_peer(struct wg_softc *wg, struct iovec *iov, size_t iovlen)
5627 wg_handle_packet(wg, m, src);
5637 IF_MODULE(MODULE_CLASS_DRIVER, wg, "sodium,blake2s")