From nobody Wed Dec 01 17:10:05 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 0D1E318CB2ED; Wed, 1 Dec 2021 17:10:06 +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 4J45Ds3v90z4d9k; Wed, 1 Dec 2021 17:10:05 +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 403BA5B87; Wed, 1 Dec 2021 17:10:05 +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 1B1HA50X016138; Wed, 1 Dec 2021 17:10:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B1HA5fb016135; Wed, 1 Dec 2021 17:10:05 GMT (envelope-from git) Date: Wed, 1 Dec 2021 17:10:05 GMT Message-Id: <202112011710.1B1HA5fb016135@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: e66cd95ea544 - stable/12 - 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/12 X-Git-Reftype: branch X-Git-Commit: e66cd95ea5442fa0c3373e654f4833cb1cc61caf Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638378605; 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=dNqpQLIiDZPg161wmch3zOQZUmm65cosmyi909pQ3sc=; b=AWZLyWSmDMbjaMlHM+atDTFNBRebLbr3bEGmsPXh5vtRHCAiUwmnOch36JLpm8YoQvKSij lNgIv0iPIdsiCz9g2zwKL2cyQJdtC63DVRvMa6FH9ZuRfDEKQIqcgDihUKEXNNJXF/7C+b OasLbJrewop9DISiSbYx5vAjumvcoz/ZiSes/Z5hGaObm+G/EB49spCWhuRCkiWp9T13Ch sNsv1UE4TgUhEKVudfNk+z+oIdDGOhbW8pUcrSNKOMTP+CE/O6zmri8nDlGgSkH81SBLtI i5AY3Ezo7FGqmPM884Bh4uywYlgnj1dwLM4Z7uZLRmXly3CEqFNQMoatcv5kkw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638378605; a=rsa-sha256; cv=none; b=s62pcWg0B91sgJ1DOTFhFE5nOhqIE19aXQIwMgehrPMoyB5Pv28sxHraGa7p48p+v/EBef twtXxfaVfWcQkwjFmaD3tTSwHGhiK3EJMqdDAUnO3wFKIIK4JPvAOPlOaHSofkmv8Qf/Z1 TejEwaK/7hrJsDBRdonNgtCq6udwW4xDQwpnj+JXO52cS2REGCYV45zLhDmgBxlXzOMxnq PbKfSDlwFVEsOhr7RbQNdgpIrgzrwKL4sFQaA7JrGJEu608ahuZ8BcvVk1jolqKMs/PSXs ACJF1nEtUV5ec6mjEazgKImuCyHOr1KRtI28EUdpjxtM7vPExUF1KxFgM+KGrQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=e66cd95ea5442fa0c3373e654f4833cb1cc61caf commit e66cd95ea5442fa0c3373e654f4833cb1cc61caf Author: Kristof Provost AuthorDate: 2021-11-05 11:01:37 +0000 Commit: Kristof Provost CommitDate: 2021-11-30 07:41:04 +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 225bd30b6bd3..f9abe4c6a630 100644 --- a/sys/net/if_stf.c +++ b/sys/net/if_stf.c @@ -168,7 +168,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, @@ -280,17 +281,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);