From nobody Mon Jan 9 18:55:21 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NrNRs4js6z2pHD0; Mon, 9 Jan 2023 18:55:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NrNRs4FZrz4MyP; Mon, 9 Jan 2023 18:55:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673290521; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=k2QNYqYWVR/HXF6/04riGrkb0+wL+bhC1lv+xVLfbdU=; b=kWLfzReDo8P0njz1BwYQDIbgHURsbx4p9dKga9TcYGAd5yrsVrlSmLcsWahED83p16oEtL WEdfWBsDT3iNwfiIU1o6z+9swznXW+yHYmpbiGFURKuSHGzLYNlnU/bDx1tvUenDl6GcL3 +tl6TILlXH/sQpZLicF3A+BvrqFCuW2IrsYCwLHcA9X1GCfgKgqFrI+uRK5b+x4+8lgXHs aaXX46IvHBghl/9PX3xQQ6OFDvaT1XOamCpfuDRG9Q7+bSDCYRe7pGY3af9PSwB8+fZaV7 8oeNV3i8KaA9kLNdDOiNr+AjSkv450mMo8rwr4KDIxPck8Beew0PEsRVgBzy+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673290521; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=k2QNYqYWVR/HXF6/04riGrkb0+wL+bhC1lv+xVLfbdU=; b=TxPCLn9Q6Ze/X5b5W9DmyAf7ggCvosQckPAeIoQ9zXDA+XYPinIqKD1FzJT/QTUzrKLuy5 o19zRBT/xt6+heTDs7+vJmmAq+VZc7Z4cpIhm5mUkHatBGsnzCjVze8oe4q/hMnwtIWDww XDns89eqjsFKJTMn0lrw9FctLjOER2j5sHT0vFnCoOQ8CxD4CfHRntKanjWm5OLKEHFRo0 zcTffPOoXYgRo0eO6g3mMDu9TaY2e2bwr9DBdxUXItAeRifcvn/+SrAYx+3lm42jL8ANwE zlPoCFNEao3HLncHclim0yNCownxs5iFqT2mIjPGqpUocHeEfoTLCzVeC5Mz+Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1673290521; a=rsa-sha256; cv=none; b=xM+ZhQ3pdX1ic+N1IwJgIWc0e4H0zVRmVVqKEnZ9laWjppN8BZJlLnswz4ZuE/0nWF6a6P hWnE7Dti3zB82g0EYIFzZ5WnpPq1+trzAZeG+ajUnGPrOGHe02wwGlSGRl+F8kR91odBeZ 1bA5jhC7SNZKWggyTQwgR+SoBosFcR3QetIpMVFWGNYpb13AEeX96fe5WX82uWRFXimagZ eJlwOPtfgn25eZHCm5LNQdOiLJnlBhmAVdnK7zrYHB/ogocdXwjGKNDjlkKkmYLz3zhqNL q12ZGDvhFkKXrPAcZqoI4GtuOc8Sy5h8pJEFvimq2RJfgd8UpQ0gqTytl77uCA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4NrNRs3JFRzfj5; Mon, 9 Jan 2023 18:55:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 309ItLbM067923; Mon, 9 Jan 2023 18:55:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 309ItLaY067922; Mon, 9 Jan 2023 18:55:21 GMT (envelope-from git) Date: Mon, 9 Jan 2023 18:55:21 GMT Message-Id: <202301091855.309ItLaY067922@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alan Somers Subject: git: eb3f9a7aece9 - main - Switch wg(4) to the new if_clone KPI List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: eb3f9a7aece9473d678adddcf6aefe6c1eec0ac4 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=eb3f9a7aece9473d678adddcf6aefe6c1eec0ac4 commit eb3f9a7aece9473d678adddcf6aefe6c1eec0ac4 Author: Alan Somers AuthorDate: 2022-12-18 20:12:02 +0000 Commit: Alan Somers CommitDate: 2023-01-10 02:54:14 +0000 Switch wg(4) to the new if_clone KPI MFC after: 2 weeks Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D37740 --- sys/dev/wg/if_wg.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/sys/dev/wg/if_wg.c b/sys/dev/wg/if_wg.c index ac85386794c7..f6c8c2d52278 100644 --- a/sys/dev/wg/if_wg.c +++ b/sys/dev/wg/if_wg.c @@ -357,13 +357,15 @@ static struct wg_packet *wg_queue_dequeue_serial(struct wg_queue *); static struct wg_packet *wg_queue_dequeue_parallel(struct wg_queue *); static bool wg_input(struct mbuf *, int, struct inpcb *, const struct sockaddr *, void *); static void wg_peer_send_staged(struct wg_peer *); -static int wg_clone_create(struct if_clone *, int, caddr_t); +static int wg_clone_create(struct if_clone *ifc, char *name, size_t len, + struct ifc_data *ifd, struct ifnet **ifpp); static void wg_qflush(struct ifnet *); static inline int determine_af_and_pullup(struct mbuf **m, sa_family_t *af); static int wg_xmit(struct ifnet *, struct mbuf *, sa_family_t, uint32_t); static int wg_transmit(struct ifnet *, struct mbuf *); static int wg_output(struct ifnet *, struct mbuf *, const struct sockaddr *, struct route *); -static void wg_clone_destroy(struct ifnet *); +static int wg_clone_destroy(struct if_clone *ifc, struct ifnet *ifp, + uint32_t flags); static bool wgc_privileged(struct wg_softc *); static int wgc_get(struct wg_softc *, struct wg_data_io *); static int wgc_set(struct wg_softc *, struct wg_data_io *); @@ -2714,7 +2716,8 @@ wg_down(struct wg_softc *sc) } static int -wg_clone_create(struct if_clone *ifc, int unit, caddr_t params) +wg_clone_create(struct if_clone *ifc, char *name, size_t len, + struct ifc_data *ifd, struct ifnet **ifpp) { struct wg_softc *sc; struct ifnet *ifp; @@ -2768,7 +2771,7 @@ wg_clone_create(struct if_clone *ifc, int unit, caddr_t params) ifp->if_softc = sc; ifp->if_capabilities = ifp->if_capenable = WG_CAPS; - if_initname(ifp, wgname, unit); + if_initname(ifp, wgname, ifd->unit); if_setmtu(ifp, DEFAULT_MTU); ifp->if_flags = IFF_NOARP | IFF_MULTICAST; @@ -2787,6 +2790,7 @@ wg_clone_create(struct if_clone *ifc, int unit, caddr_t params) sx_xlock(&wg_sx); LIST_INSERT_HEAD(&wg_list, sc, sc_entry); sx_xunlock(&wg_sx); + *ifpp = ifp; return (0); free_aip4: RADIX_NODE_HEAD_DESTROY(sc->sc_aip4); @@ -2808,8 +2812,8 @@ wg_clone_deferred_free(struct noise_local *l) atomic_add_int(&clone_count, -1); } -static void -wg_clone_destroy(struct ifnet *ifp) +static int +wg_clone_destroy(struct if_clone *ifc, struct ifnet *ifp, uint32_t flags) { struct wg_softc *sc = ifp->if_softc; struct ucred *cred; @@ -2869,6 +2873,8 @@ wg_clone_destroy(struct ifnet *ifp) if_free(sc->sc_ifp); noise_local_free(sc->sc_local, wg_clone_deferred_free); + + return (0); } static void @@ -2911,8 +2917,12 @@ wg_init(void *xsc) static void vnet_wg_init(const void *unused __unused) { - V_wg_cloner = if_clone_simple(wgname, wg_clone_create, wg_clone_destroy, - 0); + struct if_clone_addreq req = { + .create_f = wg_clone_create, + .destroy_f = wg_clone_destroy, + .flags = IFC_F_AUTOUNIT, + }; + V_wg_cloner = ifc_attach_cloner(wgname, &req); } VNET_SYSINIT(vnet_wg_init, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY, vnet_wg_init, NULL); @@ -2921,7 +2931,7 @@ static void vnet_wg_uninit(const void *unused __unused) { if (V_wg_cloner) - if_clone_detach(V_wg_cloner); + ifc_detach_cloner(V_wg_cloner); } VNET_SYSUNINIT(vnet_wg_uninit, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY, vnet_wg_uninit, NULL); @@ -3015,7 +3025,7 @@ wg_module_deinit(void) VNET_FOREACH(vnet_iter) { struct if_clone *clone = VNET_VNET(vnet_iter, wg_cloner); if (clone) { - if_clone_detach(clone); + ifc_detach_cloner(clone); VNET_VNET(vnet_iter, wg_cloner) = NULL; } }