From nobody Wed Dec 01 17:10:03 2021 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 3C5CD18CB32B; Wed, 1 Dec 2021 17:10:04 +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 4J45Dq6v4wz4dV6; Wed, 1 Dec 2021 17:10:03 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 CC66F5947; Wed, 1 Dec 2021 17:10:03 +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 1B1HA3MZ015779; Wed, 1 Dec 2021 17:10:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B1HA3W0015776; Wed, 1 Dec 2021 17:10:03 GMT (envelope-from git) Date: Wed, 1 Dec 2021 17:10:03 GMT Message-Id: <202112011710.1B1HA3W0015776@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 2b0a7984fec9 - stable/13 - if_stf: enable use in vnet jails 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: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 2b0a7984fec96d86b0467c0bd6b513451e59f7e3 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638378604; 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=6ilnPUF81MvGsknoU9mHiG4O5khsapS2jJvWUrs/8nE=; b=Pra2oxE9kFn41TR/qE7URD8bXAw4W0lQsgk/Wz49LZpgMQyyluXlTVKO4LiZU8Fu1BJHOS Xe7dHHhBzLkmVwtSfy+5bZ4plQshZWZMFQfoizz7M/3RcZWYKfbAkb6dGNu9NAXkBurQOn jN2QRAXUzyVi/IZZrRUHdq+X/sgGRIjpvi6bxtEL+4jYdQXM6Y47k0acIXQoyrX52Wz2yh y3lzFvu7QkXGOXBeO49+Dk5Qke9STDtxA1wMO1qV6M8ZjArJFq+jyIr4jBQte/7qG2h1JI Z7vOANVa6PK8QGyByB62KdxMktILm1kSiua6QvH/S4mFqg8d+H31srytlqgcGw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638378604; a=rsa-sha256; cv=none; b=liZeCT4bMUDoDhdBtbeuXTKPGlVHwVxFyIxZehvDZtBQOFKKDCdiNjRsciuqxmuUZh4wFe un3hSPVSja+a1BuhCLXvV6oVCZidzTFtVpCn15cGqP2dPqm03YluxumXf/WI27SIFVBk1/ Fb6TX0PBtBXfoe1CiV+QAVfuJrnW4tghXWvNP9TWKPt58ipn5uWUDmVHN6P8O74zfyQjk1 ifE50xVqSMDbqFED4PCP3fOer0nUV87mXkDQgjaCRUy/hVmH9qI4aHOWXZi6QWoVyPcyLw hs51Ykg3iYkvt/37hzNzHb4eOYNk+BQHoa6oflNiYisyobF1Xu/bwRRlXqfjmA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=2b0a7984fec96d86b0467c0bd6b513451e59f7e3 commit 2b0a7984fec96d86b0467c0bd6b513451e59f7e3 Author: Kristof Provost AuthorDate: 2021-11-05 11:01:37 +0000 Commit: Kristof Provost CommitDate: 2021-12-01 15:53:19 +0000 if_stf: enable use in vnet jails The cloner must be per-vnet so that cloned interfaces get destroyed when the vnet goes away. Otherwise we fail assertions in vnet_if_uninit(): panic: vnet_if_uninit:475 tailq &V_ifnet=0xfffffe01665fe070 not empty cpuid = 19 time = 1636107064 KDB: stack backtrace: db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe015d0cac60 vpanic() at vpanic+0x187/frame 0xfffffe015d0cacc0 panic() at panic+0x43/frame 0xfffffe015d0cad20 vnet_if_uninit() at vnet_if_uninit+0x7b/frame 0xfffffe015d0cad30 vnet_destroy() at vnet_destroy+0x170/frame 0xfffffe015d0cad60 prison_deref() at prison_deref+0x9b0/frame 0xfffffe015d0cadd0 sys_jail_remove() at sys_jail_remove+0x119/frame 0xfffffe015d0cae00 amd64_syscall() at amd64_syscall+0x12e/frame 0xfffffe015d0caf30 fast_syscall_common() at fast_syscall_common+0xf8/frame 0xfffffe015d0caf30 --- syscall (508, FreeBSD ELF64, sys_jail_remove), rip = 0x8011e920a, rsp = 0x7fffffffe788, rbp = 0x7fffffffe810 --- KDB: enter: panic MFC after: 3 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D32849 (cherry picked from commit 8e45fed3aefd00ff544efce8fedeba5e099d3d01) --- sys/net/if_stf.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/sys/net/if_stf.c b/sys/net/if_stf.c index 40f8a6f3a30a..a53e3ec01dc1 100644 --- a/sys/net/if_stf.c +++ b/sys/net/if_stf.c @@ -170,7 +170,8 @@ static int stf_ioctl(struct ifnet *, u_long, caddr_t); static int stf_clone_match(struct if_clone *, const char *); static int stf_clone_create(struct if_clone *, char *, size_t, caddr_t); static int stf_clone_destroy(struct if_clone *, struct ifnet *); -static struct if_clone *stf_cloner; +VNET_DEFINE_STATIC(struct if_clone *, stf_cloner); +#define V_stf_cloner VNET(stf_cloner) static const struct encap_config ipv4_encap_cfg = { .proto = IPPROTO_IPV6, @@ -282,17 +283,33 @@ stf_clone_destroy(struct if_clone *ifc, struct ifnet *ifp) return (0); } +static void +vnet_stf_init(const void *unused __unused) +{ + V_stf_cloner = if_clone_advanced(stfname, 0, stf_clone_match, + stf_clone_create, stf_clone_destroy); +} +VNET_SYSINIT(vnet_stf_init, SI_SUB_PSEUDO, SI_ORDER_ANY, vnet_stf_init, NULL); + +static void +vnet_stf_uninit(const void *unused __unused) +{ + if_clone_detach(V_stf_cloner); + V_stf_cloner = NULL; +} +VNET_SYSUNINIT(vnet_stf_uninit, SI_SUB_PSEUDO, SI_ORDER_ANY, vnet_stf_uninit, + NULL); + static int stfmodevent(module_t mod, int type, void *data) { switch (type) { case MOD_LOAD: - stf_cloner = if_clone_advanced(stfname, 0, stf_clone_match, - stf_clone_create, stf_clone_destroy); + /* Done in vnet_stf_init() */ break; case MOD_UNLOAD: - if_clone_detach(stf_cloner); + /* Done in vnet_stf_uninit() */ break; default: return (EOPNOTSUPP);