From owner-svn-src-releng@freebsd.org Thu Sep 10 23:57:00 2020 Return-Path: Delivered-To: svn-src-releng@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BD60D3E73DD; Thu, 10 Sep 2020 23:57:00 +0000 (UTC) (envelope-from gjb@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BnbQh4c1Tz4p8p; Thu, 10 Sep 2020 23:57:00 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 81BF61B388; Thu, 10 Sep 2020 23:57:00 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 08ANv0k6066508; Thu, 10 Sep 2020 23:57:00 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 08ANv084066503; Thu, 10 Sep 2020 23:57:00 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <202009102357.08ANv084066503@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Thu, 10 Sep 2020 23:57:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-releng@freebsd.org Subject: svn commit: r365618 - in releng/12.2: release/pkg_repos sys/conf sys/sys X-SVN-Group: releng X-SVN-Commit-Author: gjb X-SVN-Commit-Paths: in releng/12.2: release/pkg_repos sys/conf sys/sys X-SVN-Commit-Revision: 365618 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-releng@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the release engineering / security commits to the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2020 23:57:00 -0000 Author: gjb Date: Thu Sep 10 23:56:59 2020 New Revision: 365618 URL: https://svnweb.freebsd.org/changeset/base/365618 Log: - Copy stable/12@r365545 to releng/12.2 as part of the 12.2-RELEASE cycle. - Update from PRERELEASE to BETA1. - Set the default pkg(7) repository to 'quarterly'. - Bump __FreeBSD_version. - Prune svn:mergeinfo from the new branch. Approved by: re (implicit) Sponsored by: Rubicon Communications, LLC (netgate.com) Added: - copied from r365545, stable/12/ Directory Properties: releng/12.2/ (props changed) Modified: releng/12.2/release/pkg_repos/release-dvd.conf releng/12.2/sys/conf/newvers.sh releng/12.2/sys/sys/param.h Modified: releng/12.2/release/pkg_repos/release-dvd.conf ============================================================================== --- stable/12/release/pkg_repos/release-dvd.conf Wed Sep 9 23:11:55 2020 (r365545) +++ releng/12.2/release/pkg_repos/release-dvd.conf Thu Sep 10 23:56:59 2020 (r365618) @@ -1,6 +1,6 @@ # $FreeBSD$ release: { - url: "pkg+http://pkg.FreeBSD.org/${ABI}/latest", + url: "pkg+http://pkg.FreeBSD.org/${ABI}/quarterly", mirror_type: "srv", signature_type: "fingerprints", fingerprints: "/usr/share/keys/pkg", Modified: releng/12.2/sys/conf/newvers.sh ============================================================================== --- stable/12/sys/conf/newvers.sh Wed Sep 9 23:11:55 2020 (r365545) +++ releng/12.2/sys/conf/newvers.sh Thu Sep 10 23:56:59 2020 (r365618) @@ -49,7 +49,7 @@ TYPE="FreeBSD" REVISION="12.2" -BRANCH=${BRANCH_OVERRIDE:-PRERELEASE} +BRANCH=${BRANCH_OVERRIDE:-BETA1} RELEASE="${REVISION}-${BRANCH}" VERSION="${TYPE} ${RELEASE}" Modified: releng/12.2/sys/sys/param.h ============================================================================== --- stable/12/sys/sys/param.h Wed Sep 9 23:11:55 2020 (r365545) +++ releng/12.2/sys/sys/param.h Thu Sep 10 23:56:59 2020 (r365618) @@ -60,7 +60,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1201525 /* Master, propagated to newvers */ +#define __FreeBSD_version 1202000 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From owner-svn-src-releng@freebsd.org Fri Sep 11 15:30:49 2020 Return-Path: Delivered-To: svn-src-releng@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 20FF23DE3AD; Fri, 11 Sep 2020 15:30:49 +0000 (UTC) (envelope-from mav@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Bp08905dlz4V1p; Fri, 11 Sep 2020 15:30:49 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DAE93260FF; Fri, 11 Sep 2020 15:30:48 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 08BFUmYq035913; Fri, 11 Sep 2020 15:30:48 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 08BFUliP035907; Fri, 11 Sep 2020 15:30:47 GMT (envelope-from mav@FreeBSD.org) Message-Id: <202009111530.08BFUliP035907@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 11 Sep 2020 15:30:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-releng@freebsd.org Subject: svn commit: r365634 - in releng/12.2/sys/powerpc: include powernv powerpc ps3 pseries X-SVN-Group: releng X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in releng/12.2/sys/powerpc: include powernv powerpc ps3 pseries X-SVN-Commit-Revision: 365634 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-releng@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the release engineering / security commits to the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2020 15:30:49 -0000 Author: mav Date: Fri Sep 11 15:30:47 2020 New Revision: 365634 URL: https://svnweb.freebsd.org/changeset/base/365634 Log: MFC r342852 (by cem): powerpc: Fix regression introduced in r342771 In r342771, I introduced a regression in Power by abusing the platform smp_topo() method as a shortcut for providing the MI information needed for the stated sysctls. The smp_topo() method was already called later by sched_ule (under the name cpu_topo()), and initializes a static array of scheduler topology information. I had skimmed the smp_topo_foo() functions and assumed they were idempotent; empirically, they are not (or at least, detect re-initialization and panic). Do the cleaner thing I should have done in the first place and add a platform method specifically for core- and thread-count probing. PR: 249250 Approved by: re (gjb) Modified: releng/12.2/sys/powerpc/include/platform.h releng/12.2/sys/powerpc/powernv/platform_powernv.c releng/12.2/sys/powerpc/powerpc/mp_machdep.c releng/12.2/sys/powerpc/powerpc/platform.c releng/12.2/sys/powerpc/powerpc/platform_if.m releng/12.2/sys/powerpc/ps3/platform_ps3.c releng/12.2/sys/powerpc/pseries/platform_chrp.c Directory Properties: releng/12.2/ (props changed) Modified: releng/12.2/sys/powerpc/include/platform.h ============================================================================== --- releng/12.2/sys/powerpc/include/platform.h Fri Sep 11 14:18:47 2020 (r365633) +++ releng/12.2/sys/powerpc/include/platform.h Fri Sep 11 15:30:47 2020 (r365634) @@ -58,6 +58,7 @@ int platform_smp_get_bsp(struct cpuref *); int platform_smp_start_cpu(struct pcpu *); void platform_smp_timebase_sync(u_long tb, int ap); void platform_smp_ap_init(void); +void platform_smp_probe_threads(void); const char *installed_platform(void); void platform_probe_and_attach(void); Modified: releng/12.2/sys/powerpc/powernv/platform_powernv.c ============================================================================== --- releng/12.2/sys/powerpc/powernv/platform_powernv.c Fri Sep 11 14:18:47 2020 (r365633) +++ releng/12.2/sys/powerpc/powernv/platform_powernv.c Fri Sep 11 15:30:47 2020 (r365634) @@ -71,6 +71,7 @@ static int powernv_smp_get_bsp(platform_t, struct cpur static void powernv_smp_ap_init(platform_t); #ifdef SMP static int powernv_smp_start_cpu(platform_t, struct pcpu *cpu); +static void powernv_smp_probe_threads(platform_t); static struct cpu_group *powernv_smp_topo(platform_t plat); #endif static void powernv_reset(platform_t); @@ -89,6 +90,7 @@ static platform_method_t powernv_methods[] = { PLATFORMMETHOD(platform_smp_get_bsp, powernv_smp_get_bsp), #ifdef SMP PLATFORMMETHOD(platform_smp_start_cpu, powernv_smp_start_cpu), + PLATFORMMETHOD(platform_smp_probe_threads, powernv_smp_probe_threads), PLATFORMMETHOD(platform_smp_topo, powernv_smp_topo), #endif @@ -403,8 +405,8 @@ powernv_smp_start_cpu(platform_t plat, struct pcpu *pc return (0); } -static struct cpu_group * -powernv_smp_topo(platform_t plat) +static void +powernv_smp_probe_threads(platform_t plat) { char buf[8]; phandle_t cpu, dev, root; @@ -436,21 +438,26 @@ powernv_smp_topo(platform_t plat) } smp_threads_per_core = nthreads; + if (mp_ncpus % nthreads == 0) + mp_ncores = mp_ncpus / nthreads; +} - if (mp_ncpus % nthreads != 0) { +static struct cpu_group * +powernv_smp_topo(platform_t plat) +{ + if (mp_ncpus % smp_threads_per_core != 0) { printf("WARNING: Irregular SMP topology. Performance may be " "suboptimal (%d threads, %d on first core)\n", - mp_ncpus, nthreads); + mp_ncpus, smp_threads_per_core); return (smp_topo_none()); } - mp_ncores = mp_ncpus / nthreads; - /* Don't do anything fancier for non-threaded SMP */ - if (nthreads == 1) + if (smp_threads_per_core == 1) return (smp_topo_none()); - return (smp_topo_1level(CG_SHARE_L1, nthreads, CG_FLAG_SMT)); + return (smp_topo_1level(CG_SHARE_L1, smp_threads_per_core, + CG_FLAG_SMT)); } #endif Modified: releng/12.2/sys/powerpc/powerpc/mp_machdep.c ============================================================================== --- releng/12.2/sys/powerpc/powerpc/mp_machdep.c Fri Sep 11 14:18:47 2020 (r365633) +++ releng/12.2/sys/powerpc/powerpc/mp_machdep.c Fri Sep 11 15:30:47 2020 (r365634) @@ -182,8 +182,7 @@ next: } #ifdef SMP - /* Probe mp_ncores and smp_threads_per_core as a side effect. */ - (void)cpu_topo(); + platform_smp_probe_threads(); #endif } Modified: releng/12.2/sys/powerpc/powerpc/platform.c ============================================================================== --- releng/12.2/sys/powerpc/powerpc/platform.c Fri Sep 11 14:18:47 2020 (r365633) +++ releng/12.2/sys/powerpc/powerpc/platform.c Fri Sep 11 15:30:47 2020 (r365634) @@ -242,6 +242,12 @@ platform_smp_ap_init() PLATFORM_SMP_AP_INIT(plat_obj); } +void +platform_smp_probe_threads(void) +{ + PLATFORM_SMP_PROBE_THREADS(plat_obj); +} + #ifdef SMP struct cpu_group * cpu_topo(void) Modified: releng/12.2/sys/powerpc/powerpc/platform_if.m ============================================================================== --- releng/12.2/sys/powerpc/powerpc/platform_if.m Fri Sep 11 14:18:47 2020 (r365633) +++ releng/12.2/sys/powerpc/powerpc/platform_if.m Fri Sep 11 15:30:47 2020 (r365634) @@ -84,6 +84,10 @@ CODE { { return; } + static void platform_null_smp_probe_threads(void) + { + return; + } }; /** @@ -195,6 +199,13 @@ METHOD int smp_start_cpu { METHOD void smp_ap_init { platform_t _plat; } DEFAULT platform_null_smp_ap_init; + +/** + * @brief Probe mp_ncores and smp_threads_per_core for early MI code + */ +METHOD void smp_probe_threads { + platform_t _plat; +} DEFAULT platform_null_smp_probe_threads; /** * @brief Return SMP topology Modified: releng/12.2/sys/powerpc/ps3/platform_ps3.c ============================================================================== --- releng/12.2/sys/powerpc/ps3/platform_ps3.c Fri Sep 11 14:18:47 2020 (r365633) +++ releng/12.2/sys/powerpc/ps3/platform_ps3.c Fri Sep 11 15:30:47 2020 (r365634) @@ -70,6 +70,7 @@ static int ps3_smp_first_cpu(platform_t, struct cpuref static int ps3_smp_next_cpu(platform_t, struct cpuref *cpuref); static int ps3_smp_get_bsp(platform_t, struct cpuref *cpuref); static int ps3_smp_start_cpu(platform_t, struct pcpu *cpu); +static void ps3_smp_probe_threads(platform_t); static struct cpu_group *ps3_smp_topo(platform_t); #endif static void ps3_reset(platform_t); @@ -87,6 +88,7 @@ static platform_method_t ps3_methods[] = { PLATFORMMETHOD(platform_smp_next_cpu, ps3_smp_next_cpu), PLATFORMMETHOD(platform_smp_get_bsp, ps3_smp_get_bsp), PLATFORMMETHOD(platform_smp_start_cpu, ps3_smp_start_cpu), + PLATFORMMETHOD(platform_smp_probe_threads, ps3_smp_probe_threads), PLATFORMMETHOD(platform_smp_topo, ps3_smp_topo), #endif @@ -243,11 +245,16 @@ ps3_smp_start_cpu(platform_t plat, struct pcpu *pc) return ((pc->pc_awake) ? 0 : EBUSY); } -static struct cpu_group * -ps3_smp_topo(platform_t plat) +static void +ps3_smp_probe_threads(platform_t plat) { mp_ncores = 1; smp_threads_per_core = 2; +} + +static struct cpu_group * +ps3_smp_topo(platform_t plat) +{ return (smp_topo_1level(CG_SHARE_L1, 2, CG_FLAG_SMT)); } #endif Modified: releng/12.2/sys/powerpc/pseries/platform_chrp.c ============================================================================== --- releng/12.2/sys/powerpc/pseries/platform_chrp.c Fri Sep 11 14:18:47 2020 (r365633) +++ releng/12.2/sys/powerpc/pseries/platform_chrp.c Fri Sep 11 15:30:47 2020 (r365634) @@ -78,6 +78,7 @@ static void chrp_smp_ap_init(platform_t); static int chrp_cpuref_init(void); #ifdef SMP static int chrp_smp_start_cpu(platform_t, struct pcpu *cpu); +static void chrp_smp_probe_threads(platform_t plat); static struct cpu_group *chrp_smp_topo(platform_t plat); #endif static void chrp_reset(platform_t); @@ -103,6 +104,7 @@ static platform_method_t chrp_methods[] = { PLATFORMMETHOD(platform_smp_get_bsp, chrp_smp_get_bsp), #ifdef SMP PLATFORMMETHOD(platform_smp_start_cpu, chrp_smp_start_cpu), + PLATFORMMETHOD(platform_smp_probe_threads, chrp_smp_probe_threads), PLATFORMMETHOD(platform_smp_topo, chrp_smp_topo), #endif @@ -499,13 +501,13 @@ chrp_smp_start_cpu(platform_t plat, struct pcpu *pc) return ((pc->pc_awake) ? 0 : EBUSY); } -static struct cpu_group * -chrp_smp_topo(platform_t plat) +static void +chrp_smp_probe_threads(platform_t plat) { struct pcpu *pc, *last_pc; - int i, ncores, ncpus; + int i, ncores; - ncores = ncpus = 0; + ncores = 0; last_pc = NULL; for (i = 0; i <= mp_maxid; i++) { pc = pcpu_find(i); @@ -514,23 +516,29 @@ chrp_smp_topo(platform_t plat) if (last_pc == NULL || pc->pc_hwref != last_pc->pc_hwref) ncores++; last_pc = pc; - ncpus++; } mp_ncores = ncores; + if (mp_ncpus % ncores == 0) + smp_threads_per_core = mp_ncpus / ncores; +} - if (ncpus % ncores != 0) { +static struct cpu_group * +chrp_smp_topo(platform_t plat) +{ + + if (mp_ncpus % mp_ncores != 0) { printf("WARNING: Irregular SMP topology. Performance may be " - "suboptimal (%d CPUS, %d cores)\n", ncpus, ncores); + "suboptimal (%d CPUS, %d cores)\n", mp_ncpus, mp_ncores); return (smp_topo_none()); } /* Don't do anything fancier for non-threaded SMP */ - if (ncpus == ncores) + if (mp_ncpus == mp_ncores) return (smp_topo_none()); - smp_threads_per_core = ncpus / ncores; - return (smp_topo_1level(CG_SHARE_L1, ncpus / ncores, CG_FLAG_SMT)); + return (smp_topo_1level(CG_SHARE_L1, smp_threads_per_core, + CG_FLAG_SMT)); } #endif From owner-svn-src-releng@freebsd.org Sat Sep 12 18:58:37 2020 Return-Path: Delivered-To: svn-src-releng@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 321AF3E0484; Sat, 12 Sep 2020 18:58:37 +0000 (UTC) (envelope-from kp@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BphjT0brpz4NdN; Sat, 12 Sep 2020 18:58:37 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EC36319C18; Sat, 12 Sep 2020 18:58:36 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 08CIwaeW062992; Sat, 12 Sep 2020 18:58:36 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 08CIwaxU062991; Sat, 12 Sep 2020 18:58:36 GMT (envelope-from kp@FreeBSD.org) Message-Id: <202009121858.08CIwaxU062991@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Sat, 12 Sep 2020 18:58:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-releng@freebsd.org Subject: svn commit: r365669 - releng/12.2/sys/net X-SVN-Group: releng X-SVN-Commit-Author: kp X-SVN-Commit-Paths: releng/12.2/sys/net X-SVN-Commit-Revision: 365669 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-releng@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the release engineering / security commits to the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Sep 2020 18:58:37 -0000 Author: kp Date: Sat Sep 12 18:58:36 2020 New Revision: 365669 URL: https://svnweb.freebsd.org/changeset/base/365669 Log: MFC r365457: net: mitigate vnet / epair cleanup races There's a race where dying vnets move their interfaces back to their original vnet, and if_epair cleanup (where deleting one interface also deletes the other end of the epair). This is commonly triggered by the pf tests, but also by cleanup of vnet jails. As we've not yet been able to fix the root cause of the issue work around the panic by not dereferencing a NULL softc in epair_qflush() and by not re-attaching DYING interfaces. This isn't a full fix, but makes a very common panic far less likely. PR: 244703, 238870 Approved by: re (gjb) Modified: releng/12.2/sys/net/if.c releng/12.2/sys/net/if_epair.c Directory Properties: releng/12.2/ (props changed) Modified: releng/12.2/sys/net/if.c ============================================================================== --- releng/12.2/sys/net/if.c Sat Sep 12 18:42:14 2020 (r365668) +++ releng/12.2/sys/net/if.c Sat Sep 12 18:58:36 2020 (r365669) @@ -1280,6 +1280,10 @@ if_vmove(struct ifnet *ifp, struct vnet *new_vnet) ifindex_free_locked(ifp->if_index); IFNET_WUNLOCK(); + /* Don't re-attach DYING interfaces. */ + if (ifp->if_flags & IFF_DYING) + return; + /* * Perform interface-specific reassignment tasks, if provided by * the driver. Modified: releng/12.2/sys/net/if_epair.c ============================================================================== --- releng/12.2/sys/net/if_epair.c Sat Sep 12 18:42:14 2020 (r365668) +++ releng/12.2/sys/net/if_epair.c Sat Sep 12 18:58:36 2020 (r365669) @@ -609,8 +609,14 @@ epair_qflush(struct ifnet *ifp) struct epair_softc *sc; sc = ifp->if_softc; - KASSERT(sc != NULL, ("%s: ifp=%p, epair_softc gone? sc=%p\n", - __func__, ifp, sc)); + + /* + * See epair_clone_destroy(), we can end up getting called twice. + * Don't do anything on the second call. + */ + if (sc == NULL) + return; + /* * Remove this ifp from all backpointer lists. The interface will not * usable for flushing anyway nor should it have anything to flush From owner-svn-src-releng@freebsd.org Sat Sep 12 19:33:30 2020 Return-Path: Delivered-To: svn-src-releng@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4DFEA3E1250; Sat, 12 Sep 2020 19:33:30 +0000 (UTC) (envelope-from bz@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BpjTk1dsvz4RQG; Sat, 12 Sep 2020 19:33:30 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1B0B119E50; Sat, 12 Sep 2020 19:33:30 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 08CJXTbw088007; Sat, 12 Sep 2020 19:33:29 GMT (envelope-from bz@FreeBSD.org) Received: (from bz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 08CJXPsZ087986; Sat, 12 Sep 2020 19:33:25 GMT (envelope-from bz@FreeBSD.org) Message-Id: <202009121933.08CJXPsZ087986@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bz set sender to bz@FreeBSD.org using -f From: "Bjoern A. Zeeb" Date: Sat, 12 Sep 2020 19:33:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-releng@freebsd.org Subject: svn commit: r365670 - in releng/12.2: lib/lib80211 sbin/ifconfig share/man/man4 sys/contrib/dev/ath/ath_hal/ar9300 sys/dev/an sys/dev/ath sys/dev/ath/ath_dfs/null sys/dev/ath/ath_hal sys/dev/ath/at... X-SVN-Group: releng X-SVN-Commit-Author: bz X-SVN-Commit-Paths: in releng/12.2: lib/lib80211 sbin/ifconfig share/man/man4 sys/contrib/dev/ath/ath_hal/ar9300 sys/dev/an sys/dev/ath sys/dev/ath/ath_dfs/null sys/dev/ath/ath_hal sys/dev/ath/ath_hal/ah_regdomain sys/de... X-SVN-Commit-Revision: 365670 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-releng@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the release engineering / security commits to the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Sep 2020 19:33:30 -0000 Author: bz Date: Sat Sep 12 19:33:25 2020 New Revision: 365670 URL: https://svnweb.freebsd.org/changeset/base/365670 Log: MFS r365608: Merge WiFi net80211, drivers, and management in order to support better 11n and upcoming 11ac. This includes an ath(4) update, some run(4) 11n support, 11n for otus(4), A-MPDU, A-MSDU, A-MPDU+A-MSDU and Fast frames options, scanning fixes, enhanced PRIV checks for jails, restored parent device name printing, improvements for upcoming VHT support, lots of under-the-hood infrastructure improvements, new device ID, debug tools updates, some whitespace changes (to make future MFCs easier). This does not include (most) epoch(9) related changes as too much other infrastructure was not merged for that. Tested on: some ath(4) AP, run(4) STA, and rtwn(4) STA Discussed with: adrian (extremely briefly) Sponsored by: Rubicon Communications, LLC (d/b/a "Netgate") [partially] Approved by: re (gjb) Relnotes: yes Added: releng/12.2/tools/tools/ath/athani/ - copied from r365608, stable/12/tools/tools/ath/athani/ Modified: releng/12.2/lib/lib80211/lib80211_regdomain.c releng/12.2/lib/lib80211/lib80211_regdomain.h releng/12.2/lib/lib80211/regdomain.xml releng/12.2/sbin/ifconfig/ifieee80211.c releng/12.2/share/man/man4/ath.4 releng/12.2/share/man/man4/net80211.4 releng/12.2/share/man/man4/run.4 releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300.h releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_ani.c releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_eeprom.c releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_freebsd.c releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_misc.c releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_phy.c releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_reset.c releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_stub_funcs.c releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_stub_funcs.h releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300eep.h releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300template_ap121.h releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300template_aphrodite.h releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300template_cus157.h releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300template_generic.h releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300template_hb112.h releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300template_hb116.h releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300template_osprey_k31.h releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300template_wasp_2.h releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300template_xb112.h releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300template_xb113.h releng/12.2/sys/dev/an/if_an.c releng/12.2/sys/dev/ath/ah_osdep.c releng/12.2/sys/dev/ath/ah_osdep_ar5210.c releng/12.2/sys/dev/ath/ah_osdep_ar5211.c releng/12.2/sys/dev/ath/ah_osdep_ar5212.c releng/12.2/sys/dev/ath/ah_osdep_ar5416.c releng/12.2/sys/dev/ath/ah_osdep_ar9300.c releng/12.2/sys/dev/ath/ath_dfs/null/dfs_null.c releng/12.2/sys/dev/ath/ath_hal/ah.c releng/12.2/sys/dev/ath/ath_hal/ah.h releng/12.2/sys/dev/ath/ath_hal/ah_eeprom_9287.c releng/12.2/sys/dev/ath/ath_hal/ah_eeprom_9287.h releng/12.2/sys/dev/ath/ath_hal/ah_eeprom_v14.c releng/12.2/sys/dev/ath/ath_hal/ah_eeprom_v3.c releng/12.2/sys/dev/ath/ath_hal/ah_eeprom_v3.h releng/12.2/sys/dev/ath/ath_hal/ah_eeprom_v4k.c releng/12.2/sys/dev/ath/ath_hal/ah_internal.h releng/12.2/sys/dev/ath/ath_hal/ah_regdomain.c releng/12.2/sys/dev/ath/ath_hal/ah_regdomain/ah_rd_domains.h releng/12.2/sys/dev/ath/ath_hal/ah_regdomain/ah_rd_freqbands.h releng/12.2/sys/dev/ath/ath_hal/ah_soc.h releng/12.2/sys/dev/ath/ath_hal/ar5210/ar5210.h releng/12.2/sys/dev/ath/ath_hal/ar5210/ar5210_recv.c releng/12.2/sys/dev/ath/ath_hal/ar5210/ar5210_reset.c releng/12.2/sys/dev/ath/ath_hal/ar5211/ar5211.h releng/12.2/sys/dev/ath/ath_hal/ar5211/ar5211_keycache.c releng/12.2/sys/dev/ath/ath_hal/ar5211/ar5211_misc.c releng/12.2/sys/dev/ath/ath_hal/ar5211/ar5211_phy.c releng/12.2/sys/dev/ath/ath_hal/ar5211/ar5211_recv.c releng/12.2/sys/dev/ath/ath_hal/ar5211/ar5211_xmit.c releng/12.2/sys/dev/ath/ath_hal/ar5211/ar5211phy.h releng/12.2/sys/dev/ath/ath_hal/ar5211/ar5211reg.h releng/12.2/sys/dev/ath/ath_hal/ar5212/ar2316.c releng/12.2/sys/dev/ath/ath_hal/ar5212/ar2317.c releng/12.2/sys/dev/ath/ath_hal/ar5212/ar2413.c releng/12.2/sys/dev/ath/ath_hal/ar5212/ar2425.c releng/12.2/sys/dev/ath/ath_hal/ar5212/ar5111.c releng/12.2/sys/dev/ath/ath_hal/ar5212/ar5112.c releng/12.2/sys/dev/ath/ath_hal/ar5212/ar5212.h releng/12.2/sys/dev/ath/ath_hal/ar5212/ar5212_ani.c releng/12.2/sys/dev/ath/ath_hal/ar5212/ar5212_interrupts.c releng/12.2/sys/dev/ath/ath_hal/ar5212/ar5212_keycache.c releng/12.2/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c releng/12.2/sys/dev/ath/ath_hal/ar5212/ar5212_phy.c releng/12.2/sys/dev/ath/ath_hal/ar5212/ar5212_recv.c releng/12.2/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c releng/12.2/sys/dev/ath/ath_hal/ar5212/ar5212_xmit.c releng/12.2/sys/dev/ath/ath_hal/ar5212/ar5212phy.h releng/12.2/sys/dev/ath/ath_hal/ar5212/ar5413.c releng/12.2/sys/dev/ath/ath_hal/ar5312/ar5312_eeprom.c releng/12.2/sys/dev/ath/ath_hal/ar5312/ar5312_gpio.c releng/12.2/sys/dev/ath/ath_hal/ar5312/ar5312_interrupts.c releng/12.2/sys/dev/ath/ath_hal/ar5312/ar5312_reset.c releng/12.2/sys/dev/ath/ath_hal/ar5312/ar5312reg.h releng/12.2/sys/dev/ath/ath_hal/ar5312/ar5315_gpio.c releng/12.2/sys/dev/ath/ath_hal/ar5416/ar2133.c releng/12.2/sys/dev/ath/ath_hal/ar5416/ar5416.h releng/12.2/sys/dev/ath/ath_hal/ar5416/ar5416_ani.c releng/12.2/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c releng/12.2/sys/dev/ath/ath_hal/ar5416/ar5416_beacon.c releng/12.2/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c releng/12.2/sys/dev/ath/ath_hal/ar5416/ar5416_cal.h releng/12.2/sys/dev/ath/ath_hal/ar5416/ar5416_gpio.c releng/12.2/sys/dev/ath/ath_hal/ar5416/ar5416_power.c releng/12.2/sys/dev/ath/ath_hal/ar5416/ar5416_recv.c releng/12.2/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c releng/12.2/sys/dev/ath/ath_hal/ar5416/ar5416_spectral.c releng/12.2/sys/dev/ath/ath_hal/ar5416/ar5416_xmit.c releng/12.2/sys/dev/ath/ath_hal/ar5416/ar5416desc.h releng/12.2/sys/dev/ath/ath_hal/ar5416/ar5416reg.h releng/12.2/sys/dev/ath/ath_hal/ar9001/ar9130_attach.c releng/12.2/sys/dev/ath/ath_hal/ar9001/ar9160_attach.c releng/12.2/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c releng/12.2/sys/dev/ath/ath_hal/ar9002/ar9280_olc.c releng/12.2/sys/dev/ath/ath_hal/ar9002/ar9285.c releng/12.2/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c releng/12.2/sys/dev/ath/ath_hal/ar9002/ar9285_btcoex.c releng/12.2/sys/dev/ath/ath_hal/ar9002/ar9285_diversity.c releng/12.2/sys/dev/ath/ath_hal/ar9002/ar9285_reset.c releng/12.2/sys/dev/ath/ath_hal/ar9002/ar9287_attach.c releng/12.2/sys/dev/ath/ath_hal/ar9002/ar9287_cal.c releng/12.2/sys/dev/ath/ath_hal/ar9002/ar9287_reset.c releng/12.2/sys/dev/ath/ath_rate/amrr/amrr.c releng/12.2/sys/dev/ath/ath_rate/onoe/onoe.c releng/12.2/sys/dev/ath/ath_rate/sample/sample.c releng/12.2/sys/dev/ath/ath_rate/sample/sample.h releng/12.2/sys/dev/ath/ath_rate/sample/tx_schedules.h releng/12.2/sys/dev/ath/if_ath.c releng/12.2/sys/dev/ath/if_ath_ahb.c releng/12.2/sys/dev/ath/if_ath_beacon.c releng/12.2/sys/dev/ath/if_ath_beacon.h releng/12.2/sys/dev/ath/if_ath_btcoex.c releng/12.2/sys/dev/ath/if_ath_dfs.c releng/12.2/sys/dev/ath/if_ath_drv.c releng/12.2/sys/dev/ath/if_ath_ioctl.c releng/12.2/sys/dev/ath/if_ath_led.c releng/12.2/sys/dev/ath/if_ath_lna_div.c releng/12.2/sys/dev/ath/if_ath_misc.h releng/12.2/sys/dev/ath/if_ath_pci.c releng/12.2/sys/dev/ath/if_ath_pci_devlist.h releng/12.2/sys/dev/ath/if_ath_rate.c releng/12.2/sys/dev/ath/if_ath_rx.c releng/12.2/sys/dev/ath/if_ath_rx_edma.c releng/12.2/sys/dev/ath/if_ath_spectral.c releng/12.2/sys/dev/ath/if_ath_sysctl.c releng/12.2/sys/dev/ath/if_ath_tx.c releng/12.2/sys/dev/ath/if_ath_tx.h releng/12.2/sys/dev/ath/if_ath_tx_edma.c releng/12.2/sys/dev/ath/if_ath_tx_ht.c releng/12.2/sys/dev/ath/if_athioctl.h releng/12.2/sys/dev/ath/if_athrate.h releng/12.2/sys/dev/ath/if_athvar.h releng/12.2/sys/dev/bwi/bwimac.c releng/12.2/sys/dev/bwi/bwiphy.c releng/12.2/sys/dev/bwi/bwirf.c releng/12.2/sys/dev/bwi/if_bwi.c releng/12.2/sys/dev/bwi/if_bwi_pci.c releng/12.2/sys/dev/bwi/if_bwireg.h releng/12.2/sys/dev/bwn/if_bwn.c releng/12.2/sys/dev/bwn/if_bwn_pci.c releng/12.2/sys/dev/bwn/if_bwn_pcivar.h releng/12.2/sys/dev/bwn/if_bwn_phy_g.c releng/12.2/sys/dev/bwn/if_bwnvar.h releng/12.2/sys/dev/iwm/if_iwm.c releng/12.2/sys/dev/iwn/if_iwn.c releng/12.2/sys/dev/mwl/if_mwl.c releng/12.2/sys/dev/mwl/if_mwl_pci.c releng/12.2/sys/dev/mwl/mwlreg.h releng/12.2/sys/dev/otus/if_otus.c releng/12.2/sys/dev/otus/if_otusreg.h releng/12.2/sys/dev/rtwn/if_rtwn.c releng/12.2/sys/dev/rtwn/if_rtwn_beacon.c releng/12.2/sys/dev/rtwn/if_rtwn_calib.c releng/12.2/sys/dev/rtwn/if_rtwn_cam.c releng/12.2/sys/dev/rtwn/if_rtwn_efuse.c releng/12.2/sys/dev/rtwn/if_rtwn_fw.c releng/12.2/sys/dev/rtwn/if_rtwn_fw.h releng/12.2/sys/dev/rtwn/if_rtwn_ridx.h releng/12.2/sys/dev/rtwn/if_rtwn_rx.c releng/12.2/sys/dev/rtwn/if_rtwn_rx.h releng/12.2/sys/dev/rtwn/if_rtwn_task.c releng/12.2/sys/dev/rtwn/if_rtwn_tx.c releng/12.2/sys/dev/rtwn/if_rtwnreg.h releng/12.2/sys/dev/rtwn/if_rtwnvar.h releng/12.2/sys/dev/rtwn/pci/rtwn_pci_attach.c releng/12.2/sys/dev/rtwn/pci/rtwn_pci_reg.c releng/12.2/sys/dev/rtwn/pci/rtwn_pci_rx.c releng/12.2/sys/dev/rtwn/pci/rtwn_pci_tx.c releng/12.2/sys/dev/rtwn/pci/rtwn_pci_var.h releng/12.2/sys/dev/rtwn/rtl8188e/pci/r88ee.h releng/12.2/sys/dev/rtwn/rtl8188e/pci/r88ee_reg.h releng/12.2/sys/dev/rtwn/rtl8188e/r88e.h releng/12.2/sys/dev/rtwn/rtl8188e/r88e_beacon.c releng/12.2/sys/dev/rtwn/rtl8188e/r88e_calib.c releng/12.2/sys/dev/rtwn/rtl8188e/r88e_chan.c releng/12.2/sys/dev/rtwn/rtl8188e/r88e_fw.c releng/12.2/sys/dev/rtwn/rtl8188e/r88e_init.c releng/12.2/sys/dev/rtwn/rtl8188e/r88e_led.c releng/12.2/sys/dev/rtwn/rtl8188e/r88e_priv.h releng/12.2/sys/dev/rtwn/rtl8188e/r88e_reg.h releng/12.2/sys/dev/rtwn/rtl8188e/r88e_rf.c releng/12.2/sys/dev/rtwn/rtl8188e/r88e_rom.c releng/12.2/sys/dev/rtwn/rtl8188e/r88e_rx.c releng/12.2/sys/dev/rtwn/rtl8188e/r88e_tx.c releng/12.2/sys/dev/rtwn/rtl8188e/usb/r88eu.h releng/12.2/sys/dev/rtwn/rtl8188e/usb/r88eu_attach.c releng/12.2/sys/dev/rtwn/rtl8188e/usb/r88eu_init.c releng/12.2/sys/dev/rtwn/rtl8192c/pci/r92ce.h releng/12.2/sys/dev/rtwn/rtl8192c/pci/r92ce_attach.c releng/12.2/sys/dev/rtwn/rtl8192c/pci/r92ce_calib.c releng/12.2/sys/dev/rtwn/rtl8192c/pci/r92ce_fw.c releng/12.2/sys/dev/rtwn/rtl8192c/pci/r92ce_init.c releng/12.2/sys/dev/rtwn/rtl8192c/pci/r92ce_priv.h releng/12.2/sys/dev/rtwn/rtl8192c/pci/r92ce_reg.h releng/12.2/sys/dev/rtwn/rtl8192c/pci/r92ce_rx.c releng/12.2/sys/dev/rtwn/rtl8192c/pci/r92ce_tx.c releng/12.2/sys/dev/rtwn/rtl8192c/r92c.h releng/12.2/sys/dev/rtwn/rtl8192c/r92c_attach.c releng/12.2/sys/dev/rtwn/rtl8192c/r92c_beacon.c releng/12.2/sys/dev/rtwn/rtl8192c/r92c_calib.c releng/12.2/sys/dev/rtwn/rtl8192c/r92c_chan.c releng/12.2/sys/dev/rtwn/rtl8192c/r92c_fw.c releng/12.2/sys/dev/rtwn/rtl8192c/r92c_init.c releng/12.2/sys/dev/rtwn/rtl8192c/r92c_priv.h releng/12.2/sys/dev/rtwn/rtl8192c/r92c_reg.h releng/12.2/sys/dev/rtwn/rtl8192c/r92c_rf.c releng/12.2/sys/dev/rtwn/rtl8192c/r92c_rom.c releng/12.2/sys/dev/rtwn/rtl8192c/r92c_rx.c releng/12.2/sys/dev/rtwn/rtl8192c/r92c_tx.c releng/12.2/sys/dev/rtwn/rtl8192c/r92c_tx_desc.h releng/12.2/sys/dev/rtwn/rtl8192c/usb/r92cu.h releng/12.2/sys/dev/rtwn/rtl8192c/usb/r92cu_attach.c releng/12.2/sys/dev/rtwn/rtl8192c/usb/r92cu_init.c releng/12.2/sys/dev/rtwn/rtl8192c/usb/r92cu_led.c releng/12.2/sys/dev/rtwn/rtl8192c/usb/r92cu_priv.h releng/12.2/sys/dev/rtwn/rtl8192c/usb/r92cu_reg.h releng/12.2/sys/dev/rtwn/rtl8192c/usb/r92cu_rx.c releng/12.2/sys/dev/rtwn/rtl8192c/usb/r92cu_tx.c releng/12.2/sys/dev/rtwn/rtl8192c/usb/r92cu_tx_desc.h releng/12.2/sys/dev/rtwn/rtl8192e/r92e.h releng/12.2/sys/dev/rtwn/rtl8192e/r92e_chan.c releng/12.2/sys/dev/rtwn/rtl8192e/r92e_priv.h releng/12.2/sys/dev/rtwn/rtl8192e/usb/r92eu.h releng/12.2/sys/dev/rtwn/rtl8812a/r12a.h releng/12.2/sys/dev/rtwn/rtl8812a/r12a_beacon.c releng/12.2/sys/dev/rtwn/rtl8812a/r12a_calib.c releng/12.2/sys/dev/rtwn/rtl8812a/r12a_caps.c releng/12.2/sys/dev/rtwn/rtl8812a/r12a_chan.c releng/12.2/sys/dev/rtwn/rtl8812a/r12a_fw.c releng/12.2/sys/dev/rtwn/rtl8812a/r12a_fw_cmd.h releng/12.2/sys/dev/rtwn/rtl8812a/r12a_init.c releng/12.2/sys/dev/rtwn/rtl8812a/r12a_led.c releng/12.2/sys/dev/rtwn/rtl8812a/r12a_priv.h releng/12.2/sys/dev/rtwn/rtl8812a/r12a_reg.h releng/12.2/sys/dev/rtwn/rtl8812a/r12a_rf.c releng/12.2/sys/dev/rtwn/rtl8812a/r12a_rom.c releng/12.2/sys/dev/rtwn/rtl8812a/r12a_rx.c releng/12.2/sys/dev/rtwn/rtl8812a/r12a_tx.c releng/12.2/sys/dev/rtwn/rtl8812a/r12a_tx_desc.h releng/12.2/sys/dev/rtwn/rtl8812a/usb/r12au.h releng/12.2/sys/dev/rtwn/rtl8812a/usb/r12au_attach.c releng/12.2/sys/dev/rtwn/rtl8812a/usb/r12au_init.c releng/12.2/sys/dev/rtwn/rtl8812a/usb/r12au_rx.c releng/12.2/sys/dev/rtwn/rtl8812a/usb/r12au_tx.c releng/12.2/sys/dev/rtwn/rtl8821a/r21a.h releng/12.2/sys/dev/rtwn/rtl8821a/r21a_beacon.c releng/12.2/sys/dev/rtwn/rtl8821a/r21a_calib.c releng/12.2/sys/dev/rtwn/rtl8821a/r21a_chan.c releng/12.2/sys/dev/rtwn/rtl8821a/r21a_fw.c releng/12.2/sys/dev/rtwn/rtl8821a/r21a_init.c releng/12.2/sys/dev/rtwn/rtl8821a/r21a_led.c releng/12.2/sys/dev/rtwn/rtl8821a/r21a_priv.h releng/12.2/sys/dev/rtwn/rtl8821a/r21a_reg.h releng/12.2/sys/dev/rtwn/rtl8821a/r21a_rom.c releng/12.2/sys/dev/rtwn/rtl8821a/r21a_rx.c releng/12.2/sys/dev/rtwn/rtl8821a/usb/r21au.h releng/12.2/sys/dev/rtwn/rtl8821a/usb/r21au_attach.c releng/12.2/sys/dev/rtwn/rtl8821a/usb/r21au_dfs.c releng/12.2/sys/dev/rtwn/rtl8821a/usb/r21au_init.c releng/12.2/sys/dev/rtwn/usb/rtwn_usb_attach.c releng/12.2/sys/dev/rtwn/usb/rtwn_usb_attach.h releng/12.2/sys/dev/rtwn/usb/rtwn_usb_ep.c releng/12.2/sys/dev/rtwn/usb/rtwn_usb_reg.c releng/12.2/sys/dev/rtwn/usb/rtwn_usb_tx.c releng/12.2/sys/dev/usb/usbdevs releng/12.2/sys/dev/usb/wlan/if_rsu.c releng/12.2/sys/dev/usb/wlan/if_run.c releng/12.2/sys/dev/usb/wlan/if_runreg.h releng/12.2/sys/dev/usb/wlan/if_runvar.h releng/12.2/sys/dev/usb/wlan/if_zyd.c releng/12.2/sys/dev/wi/if_wavelan_ieee.h releng/12.2/sys/dev/wi/if_wi.c releng/12.2/sys/dev/wi/if_wi_macio.c releng/12.2/sys/dev/wi/if_wi_pccard.c releng/12.2/sys/dev/wi/if_wi_pci.c releng/12.2/sys/dev/wpi/if_wpireg.h releng/12.2/sys/dev/wtap/if_wtap.c releng/12.2/sys/kern/kern_jail.c releng/12.2/sys/net80211/_ieee80211.h releng/12.2/sys/net80211/ieee80211.c releng/12.2/sys/net80211/ieee80211.h releng/12.2/sys/net80211/ieee80211_adhoc.c releng/12.2/sys/net80211/ieee80211_amrr.c releng/12.2/sys/net80211/ieee80211_ddb.c releng/12.2/sys/net80211/ieee80211_freebsd.c releng/12.2/sys/net80211/ieee80211_freebsd.h releng/12.2/sys/net80211/ieee80211_hostap.c releng/12.2/sys/net80211/ieee80211_ht.c releng/12.2/sys/net80211/ieee80211_ht.h releng/12.2/sys/net80211/ieee80211_input.h releng/12.2/sys/net80211/ieee80211_ioctl.c releng/12.2/sys/net80211/ieee80211_ioctl.h releng/12.2/sys/net80211/ieee80211_node.c releng/12.2/sys/net80211/ieee80211_node.h releng/12.2/sys/net80211/ieee80211_output.c releng/12.2/sys/net80211/ieee80211_phy.h releng/12.2/sys/net80211/ieee80211_power.c releng/12.2/sys/net80211/ieee80211_proto.c releng/12.2/sys/net80211/ieee80211_proto.h releng/12.2/sys/net80211/ieee80211_regdomain.c releng/12.2/sys/net80211/ieee80211_scan_sta.c releng/12.2/sys/net80211/ieee80211_scan_sw.c releng/12.2/sys/net80211/ieee80211_sta.c releng/12.2/sys/net80211/ieee80211_sta.h releng/12.2/sys/net80211/ieee80211_var.h releng/12.2/sys/net80211/ieee80211_vht.c releng/12.2/sys/net80211/ieee80211_vht.h releng/12.2/sys/sys/priv.h releng/12.2/tools/tools/ath/Makefile releng/12.2/tools/tools/ath/ath_ee_9300_print/main.c releng/12.2/tools/tools/ath/athratestats/main.c releng/12.2/tools/tools/net80211/wlanstats/main.c releng/12.2/tools/tools/net80211/wlanstats/wlanstats.c Directory Properties: releng/12.2/ (props changed) Modified: releng/12.2/lib/lib80211/lib80211_regdomain.c ============================================================================== --- releng/12.2/lib/lib80211/lib80211_regdomain.c Sat Sep 12 18:58:36 2020 (r365669) +++ releng/12.2/lib/lib80211/lib80211_regdomain.c Sat Sep 12 19:33:25 2020 (r365670) @@ -192,7 +192,7 @@ decode_flag(struct mystate *mt, const char *p, int len FLAG(IEEE80211_CHAN_VHT40), FLAG(IEEE80211_CHAN_VHT80), /* - * XXX VHT80_80? This likely should be done by + * XXX VHT80P80? This likely should be done by * 80MHz chan logic in net80211 / ifconfig. */ FLAG(IEEE80211_CHAN_VHT160), Modified: releng/12.2/lib/lib80211/lib80211_regdomain.h ============================================================================== --- releng/12.2/lib/lib80211/lib80211_regdomain.h Sat Sep 12 18:58:36 2020 (r365669) +++ releng/12.2/lib/lib80211/lib80211_regdomain.h Sat Sep 12 19:33:25 2020 (r365670) @@ -73,10 +73,10 @@ struct regdomain { netband_head bands_11b; /* 11b operation */ netband_head bands_11g; /* 11g operation */ netband_head bands_11a; /* 11a operation */ - netband_head bands_11ng;/* 11ng operation */ - netband_head bands_11na;/* 11na operation */ - netband_head bands_11ac;/* 11ac 5GHz operation */ - netband_head bands_11acg;/* 11ac 2GHz operation */ + netband_head bands_11ng; /* 11ng operation */ + netband_head bands_11na; /* 11na operation */ + netband_head bands_11ac; /* 11ac 5GHz operation */ + netband_head bands_11acg; /* 11ac 2GHz operation */ LIST_ENTRY(regdomain) next; }; Modified: releng/12.2/lib/lib80211/regdomain.xml ============================================================================== --- releng/12.2/lib/lib80211/regdomain.xml Sat Sep 12 18:58:36 2020 (r365669) +++ releng/12.2/lib/lib80211/regdomain.xml Sat Sep 12 19:33:25 2020 (r365670) @@ -111,6 +111,44 @@ IEEE80211_CHAN_HT40 + + + + 17 + IEEE80211_CHAN_HT20 + IEEE80211_CHAN_VHT20 + + + + 17 + IEEE80211_CHAN_HT40 + IEEE80211_CHAN_VHT40 + + + + 17 + IEEE80211_CHAN_HT40 + IEEE80211_CHAN_VHT80 + + + + 17 + IEEE80211_CHAN_HT20 + IEEE80211_CHAN_VHT20 + + + + 17 + IEEE80211_CHAN_HT40 + IEEE80211_CHAN_VHT40 + + + + 17 + IEEE80211_CHAN_HT40 + IEEE80211_CHAN_VHT80 + + @@ -1735,6 +1773,21 @@ 20 20 IEEE80211_CHAN_A + + 5180 5240 + 20 20 + IEEE80211_CHAN_A + + + 5180 5240 + 40 20 + IEEE80211_CHAN_A + + + 5180 5240 + 80 20 + IEEE80211_CHAN_A + 5180 5240 40 20 @@ -1823,6 +1876,21 @@ 5745 5805 20 20 + IEEE80211_CHAN_A + + + 5745 5805 + 20 20 + IEEE80211_CHAN_A + + + 5745 5805 + 40 20 + IEEE80211_CHAN_A + + + 5745 5805 + 80 20 IEEE80211_CHAN_A Modified: releng/12.2/sbin/ifconfig/ifieee80211.c ============================================================================== --- releng/12.2/sbin/ifconfig/ifieee80211.c Sat Sep 12 18:58:36 2020 (r365669) +++ releng/12.2/sbin/ifconfig/ifieee80211.c Sat Sep 12 19:33:25 2020 (r365670) @@ -125,8 +125,19 @@ #define IEEE80211_NODE_AMSDU_RX 0x040000 /* AMSDU rx enabled */ #define IEEE80211_NODE_AMSDU_TX 0x080000 /* AMSDU tx enabled */ #define IEEE80211_NODE_VHT 0x100000 /* VHT enabled */ +#define IEEE80211_NODE_LDPC 0x200000 /* LDPC enabled */ +#define IEEE80211_NODE_UAPSD 0x400000 /* UAPSD enabled */ #endif +/* XXX should also figure out where to put these for k/u-space sharing. */ +#ifndef IEEE80211_FVHT_VHT +#define IEEE80211_FVHT_VHT 0x000000001 /* CONF: VHT supported */ +#define IEEE80211_FVHT_USEVHT40 0x000000002 /* CONF: Use VHT40 */ +#define IEEE80211_FVHT_USEVHT80 0x000000004 /* CONF: Use VHT80 */ +#define IEEE80211_FVHT_USEVHT160 0x000000008 /* CONF: Use VHT160 */ +#define IEEE80211_FVHT_USEVHT80P80 0x000000010 /* CONF: Use VHT 80+80 */ +#endif + #define MAXCHAN 1536 /* max 1.5K channels */ #define MAXCOL 78 @@ -1804,6 +1815,12 @@ set80211ldpc(const char *val, int d, int s, const stru set80211(s, IEEE80211_IOC_LDPC, ldpc, 0, NULL); } +static void +set80211uapsd(const char *val, int d, int s, const struct afswtch *rafp) +{ + set80211(s, IEEE80211_IOC_UAPSD, d, 0, NULL); +} + static DECL_CMD_FUNC(set80211ampdulimit, val, d) { @@ -2159,8 +2176,6 @@ regdomain_addchans(struct ieee80211req_chaninfo *ci, /* * VHT first - HT is a subset. - * - * XXX TODO: VHT80p80, VHT160 is not yet done. */ if (flags & IEEE80211_CHAN_VHT) { if ((chanFlags & IEEE80211_CHAN_VHT20) && @@ -2184,7 +2199,20 @@ regdomain_addchans(struct ieee80211req_chaninfo *ci, "VHT80 channel\n", freq); continue; } - + if ((chanFlags & IEEE80211_CHAN_VHT160) && + (flags & IEEE80211_CHAN_VHT160) == 0) { + if (verbose) + printf("%u: skip, not a " + "VHT160 channel\n", freq); + continue; + } + if ((chanFlags & IEEE80211_CHAN_VHT80P80) && + (flags & IEEE80211_CHAN_VHT80P80) == 0) { + if (verbose) + printf("%u: skip, not a " + "VHT80+80 channel\n", freq); + continue; + } flags &= ~IEEE80211_CHAN_VHT; flags |= chanFlags & IEEE80211_CHAN_VHT; } @@ -2370,7 +2398,7 @@ regdomain_makechannels( &dc->dc_chaninfo); } - /* XXX TODO: VHT80_80, VHT160 */ + /* XXX TODO: VHT80P80, VHT160 */ } if (!LIST_EMPTY(&rd->bands_11ng) && dc->dc_htcaps != 0) { @@ -2631,6 +2659,10 @@ getflags(int flags) *cp++ = 't'; if (flags & IEEE80211_NODE_AMSDU_RX) *cp++ = 'r'; + if (flags & IEEE80211_NODE_UAPSD) + *cp++ = 'U'; + if (flags & IEEE80211_NODE_LDPC) + *cp++ = 'L'; *cp = '\0'; return flagstring; } @@ -3840,8 +3872,8 @@ list_stations(int s) , "TXSEQ" , "RXSEQ" ); - else - printf("%-17.17s %4s %4s %4s %4s %4s %6s %6s %4s %-7s\n" + else + printf("%-17.17s %4s %4s %4s %4s %4s %6s %6s %4s %-12s\n" , "ADDR" , "AID" , "CHAN" @@ -3875,8 +3907,8 @@ list_stations(int s) , gettxseq(si) , getrxseq(si) ); - else - printf("%s %4u %4d %3dM %4.1f %4d %6d %6d %-4.4s %-7.7s" + else + printf("%s %4u %4d %3dM %4.1f %4d %6d %6d %-4.4s %-12.12s" , ether_ntoa((const struct ether_addr*) si->isi_macaddr) , IEEE80211_AID(si->isi_associd) @@ -3937,8 +3969,11 @@ get_chaninfo(const struct ieee80211_channel *c, int pr if (IEEE80211_IS_CHAN_TURBO(c)) strlcat(buf, " Turbo", bsize); if (precise) { - /* XXX should make VHT80U, VHT80D */ - if (IEEE80211_IS_CHAN_VHT80(c) && + if (IEEE80211_IS_CHAN_VHT80P80(c)) + strlcat(buf, " vht/80p80", bsize); + else if (IEEE80211_IS_CHAN_VHT160(c)) + strlcat(buf, " vht/160", bsize); + else if (IEEE80211_IS_CHAN_VHT80(c) && IEEE80211_IS_CHAN_HT40D(c)) strlcat(buf, " vht/80-", bsize); else if (IEEE80211_IS_CHAN_VHT80(c) && @@ -3992,10 +4027,11 @@ print_chaninfo(const struct ieee80211_channel *c, int static int chanpref(const struct ieee80211_channel *c) { + + if (IEEE80211_IS_CHAN_VHT80P80(c)) + return 90; if (IEEE80211_IS_CHAN_VHT160(c)) return 80; - if (IEEE80211_IS_CHAN_VHT80_80(c)) - return 75; if (IEEE80211_IS_CHAN_VHT80(c)) return 70; if (IEEE80211_IS_CHAN_VHT40(c)) @@ -4767,6 +4803,23 @@ getid(int s, int ix, void *data, size_t len, int *plen return 0; } +static int +getdevicename(int s, void *data, size_t len, int *plen) +{ + struct ieee80211req ireq; + + (void) memset(&ireq, 0, sizeof(ireq)); + (void) strlcpy(ireq.i_name, name, sizeof(ireq.i_name)); + ireq.i_type = IEEE80211_IOC_IC_NAME; + ireq.i_val = -1; + ireq.i_data = data; + ireq.i_len = len; + if (ioctl(s, SIOCG80211, &ireq) < 0) + return (-1); + *plen = ireq.i_len; + return (0); +} + static void ieee80211_status(int s) { @@ -5288,30 +5341,40 @@ end: break; } } + if (get80211val(s, IEEE80211_IOC_UAPSD, &val) != -1) { + switch (val) { + case 0: + LINE_CHECK("-uapsd"); + break; + case 1: + LINE_CHECK("uapsd"); + break; + } + } } if (IEEE80211_IS_CHAN_VHT(c) || verbose) { getvhtconf(s); - if (vhtconf & 0x1) + if (vhtconf & IEEE80211_FVHT_VHT) LINE_CHECK("vht"); else LINE_CHECK("-vht"); - if (vhtconf & 0x2) + if (vhtconf & IEEE80211_FVHT_USEVHT40) LINE_CHECK("vht40"); else LINE_CHECK("-vht40"); - if (vhtconf & 0x4) + if (vhtconf & IEEE80211_FVHT_USEVHT80) LINE_CHECK("vht80"); else LINE_CHECK("-vht80"); - if (vhtconf & 0x8) - LINE_CHECK("vht80p80"); - else - LINE_CHECK("-vht80p80"); - if (vhtconf & 0x10) + if (vhtconf & IEEE80211_FVHT_USEVHT160) LINE_CHECK("vht160"); else LINE_CHECK("-vht160"); + if (vhtconf & IEEE80211_FVHT_USEVHT80P80) + LINE_CHECK("vht80p80"); + else + LINE_CHECK("-vht80p80"); } if (get80211val(s, IEEE80211_IOC_WME, &wme) != -1) { @@ -5481,6 +5544,12 @@ end: } LINE_BREAK(); + + if (getdevicename(s, data, sizeof(data), &len) < 0) + return; + LINE_CHECK("parent interface: %s", data); + + LINE_BREAK(); } static int @@ -5872,6 +5941,8 @@ static struct cmd ieee80211_cmds[] = { DEF_CMD("-ldpctx", -1, set80211ldpc), DEF_CMD("ldpc", 3, set80211ldpc), /* NB: tx+rx */ DEF_CMD("-ldpc", -3, set80211ldpc), + DEF_CMD("uapsd", 1, set80211uapsd), + DEF_CMD("-uapsd", 0, set80211uapsd), DEF_CMD("puren", 1, set80211puren), DEF_CMD("-puren", 0, set80211puren), DEF_CMD("doth", 1, set80211doth), @@ -5904,16 +5975,16 @@ static struct cmd ieee80211_cmds[] = { DEF_CMD("-ht40", 0, set80211htconf), DEF_CMD("ht", 3, set80211htconf), /* NB: 20+40 */ DEF_CMD("-ht", 0, set80211htconf), - DEF_CMD("vht", 1, set80211vhtconf), - DEF_CMD("-vht", 0, set80211vhtconf), - DEF_CMD("vht40", 2, set80211vhtconf), - DEF_CMD("-vht40", -2, set80211vhtconf), - DEF_CMD("vht80", 4, set80211vhtconf), - DEF_CMD("-vht80", -4, set80211vhtconf), - DEF_CMD("vht80p80", 8, set80211vhtconf), - DEF_CMD("-vht80p80", -8, set80211vhtconf), - DEF_CMD("vht160", 16, set80211vhtconf), - DEF_CMD("-vht160", -16, set80211vhtconf), + DEF_CMD("vht", IEEE80211_FVHT_VHT, set80211vhtconf), + DEF_CMD("-vht", 0, set80211vhtconf), + DEF_CMD("vht40", IEEE80211_FVHT_USEVHT40, set80211vhtconf), + DEF_CMD("-vht40", -IEEE80211_FVHT_USEVHT40, set80211vhtconf), + DEF_CMD("vht80", IEEE80211_FVHT_USEVHT80, set80211vhtconf), + DEF_CMD("-vht80", -IEEE80211_FVHT_USEVHT80, set80211vhtconf), + DEF_CMD("vht160", IEEE80211_FVHT_USEVHT160, set80211vhtconf), + DEF_CMD("-vht160", -IEEE80211_FVHT_USEVHT160, set80211vhtconf), + DEF_CMD("vht80p80", IEEE80211_FVHT_USEVHT80P80, set80211vhtconf), + DEF_CMD("-vht80p80", -IEEE80211_FVHT_USEVHT80P80, set80211vhtconf), DEF_CMD("rifs", 1, set80211rifs), DEF_CMD("-rifs", 0, set80211rifs), DEF_CMD("smps", IEEE80211_HTCAP_SMPS_ENA, set80211smps), Modified: releng/12.2/share/man/man4/ath.4 ============================================================================== --- releng/12.2/share/man/man4/ath.4 Sat Sep 12 18:58:36 2020 (r365669) +++ releng/12.2/share/man/man4/ath.4 Sat Sep 12 19:33:25 2020 (r365670) @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\"/ -.Dd April 14, 2014 +.Dd June 16, 2020 .Dt ATH 4 .Os .Sh NAME @@ -60,10 +60,10 @@ The driver provides support for wireless network adapters based on the Atheros AR5210, AR5211, AR5212, AR5416 and AR9300 programming APIs. These APIs are used by a wide variety of chips; most all chips with -a PCI and/or CardBus interface are supported. +a PCI, PCIe and/or CardBus interface are supported. .Pp Supported features include 802.11 and 802.3 frames, power management, BSS, -IBSS, MBSS, TDMA, and host-based access point operation modes. +IBSS, MBSS, WDS/DWDS TDMA, and host-based access point operation modes. All host/device interaction is via DMA. .Pp Please note that from FreeBSD-9.0, the @@ -148,12 +148,13 @@ For more information on configuring this device, see .Pp Devices supported by the .Nm -driver come in either Cardbus or mini-PCI packages. -Wireless cards in Cardbus slots may be inserted and ejected on the fly. +driver come in Cardbus, ExpressCard, Mini-PCI and Mini-PCIe packages. +Wireless cards in Cardbus and ExpressCard slots may be inserted and +ejected on the fly. .Sh HARDWARE The .Nm -driver supports all Atheros Cardbus and PCI cards, +driver supports all Atheros Cardbus, ExpressCard, PCI and PCIe cards, except those that are based on the AR5005VL chipset. .Sh EXAMPLES Join a specific BSS network with WEP encryption: @@ -293,8 +294,7 @@ device driver first appeared in Revision A1 of the D-LINK DWL-G520 and DWL-G650 are based on an Intersil PrismGT chip and are not supported by this driver. .Sh BUGS -The driver does not fully enable power-save operation of the chip -in station mode; consequently power use is suboptimal (e.g. on a laptop). +The driver does supports optional station mode power-save operation. .Pp The AR5210 can only do WEP in hardware; consequently hardware assisted WEP is disabled in order to allow software implementations of TKIP and CCMP to Modified: releng/12.2/share/man/man4/net80211.4 ============================================================================== --- releng/12.2/share/man/man4/net80211.4 Sat Sep 12 18:58:36 2020 (r365669) +++ releng/12.2/share/man/man4/net80211.4 Sat Sep 12 19:33:25 2020 (r365670) @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 10, 2009 +.Dd August 7, 2020 .Dt NET80211 4 .Os .Sh NAME @@ -393,6 +393,16 @@ Valid values are: and .Dv IEEE80211_HWMP_ROOTMODE_RANN (send broadcast Root Announcement (RANN) frames). +.It Dv IEEE80211_IOC_IC_NAME +Return the underlying hardware +.Xr device 9 +name in the buffer pointed to by +.Va i_data +and the name length including terminating NUL character in +.Va i_len . +If the buffer length is too small to hold the full name +.Er EINVAL +will be returned. .It Dv IEEE80211_IOC_INACTIVITY Return whether or not the system handles inactivity processing in .Va i_val . Modified: releng/12.2/share/man/man4/run.4 ============================================================================== --- releng/12.2/share/man/man4/run.4 Sat Sep 12 18:58:36 2020 (r365669) +++ releng/12.2/share/man/man4/run.4 Sat Sep 12 19:33:25 2020 (r365670) @@ -16,7 +16,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 8, 2018 +.Dd June 16, 2020 .Dt RUN 4 .Os .Sh NAME @@ -251,5 +251,5 @@ driver was written by .Sh CAVEATS The .Nm -driver does not support any of the 802.11n capabilities offered by the +driver supports some of the 11n capabilities found in the RT2800, RT3000 and RT3900 chipsets. Modified: releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300.h ============================================================================== --- releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300.h Sat Sep 12 18:58:36 2020 (r365669) +++ releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300.h Sat Sep 12 19:33:25 2020 (r365670) @@ -19,18 +19,14 @@ #include "ar9300_freebsd_inc.h" -#define AH_BIG_ENDIAN 4321 -#define AH_LITTLE_ENDIAN 1234 - -#if _BYTE_ORDER == _BIG_ENDIAN -#define AH_BYTE_ORDER AH_BIG_ENDIAN -#else -#define AH_BYTE_ORDER AH_LITTLE_ENDIAN -#endif - /* XXX doesn't belong here */ #define AR_EEPROM_MODAL_SPURS 5 +/* Ensure that AH_BYTE_ORDER is defined */ +#ifndef AH_BYTE_ORDER +#error AH_BYTE_ORDER needs to be defined! +#endif + /* * (a) this should be N(a), * (b) FreeBSD does define nitems, @@ -43,10 +39,8 @@ #include "ah_devid.h" #include "ar9300eep.h" /* For Eeprom definitions */ - #define AR9300_MAGIC 0x19741014 - /* MAC register values */ #define INIT_CONFIG_STATUS 0x00000000 @@ -1396,7 +1390,7 @@ extern void ar9300_wowoffload_download_ns_info(struct extern HAL_BOOL ar9300_reset(struct ath_hal *ah, HAL_OPMODE opmode, struct ieee80211_channel *chan, HAL_HT_MACMODE macmode, u_int8_t txchainmask, u_int8_t rxchainmask, HAL_HT_EXTPROTSPACING extprotspacing, - HAL_BOOL b_channel_change, HAL_STATUS *status, int is_scan); + HAL_BOOL b_channel_change, HAL_STATUS *status, HAL_RESET_TYPE reset_type, int is_scan); extern HAL_BOOL ar9300_lean_channel_change(struct ath_hal *ah, HAL_OPMODE opmode, struct ieee80211_channel *chan, HAL_HT_MACMODE macmode, u_int8_t txchainmask, u_int8_t rxchainmask); extern HAL_BOOL ar9300_set_reset_reg(struct ath_hal *ah, u_int32_t type); @@ -1406,7 +1400,7 @@ extern u_int16_t ar9300_is_single_ant_power_save_poss extern void ar9300_set_operating_mode(struct ath_hal *ah, int opmode); extern HAL_BOOL ar9300_phy_disable(struct ath_hal *ah); extern HAL_BOOL ar9300_disable(struct ath_hal *ah); -extern HAL_BOOL ar9300_chip_reset(struct ath_hal *ah, struct ieee80211_channel *); +extern HAL_BOOL ar9300_chip_reset(struct ath_hal *ah, struct ieee80211_channel *, HAL_RESET_TYPE type); extern HAL_BOOL ar9300_calibration(struct ath_hal *ah, struct ieee80211_channel *chan, u_int8_t rxchainmask, HAL_BOOL longcal, HAL_BOOL *isIQdone, int is_scan, u_int32_t *sched_cals); extern void ar9300_reset_cal_valid(struct ath_hal *ah, Modified: releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_ani.c ============================================================================== --- releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_ani.c Sat Sep 12 18:58:36 2020 (r365669) +++ releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_ani.c Sat Sep 12 19:33:25 2020 (r365670) @@ -462,13 +462,55 @@ ar9300_ani_control(struct ath_hal *ah, HAL_ANI_CMD cmd u_int level = param; u_int is_on; + HALDEBUG(ah, HAL_DEBUG_ANI, "%s: cmd=%d, param=%d, chan=%p, funcmask=0x%08x\n", + __func__, + cmd, + param, + chan, + ahp->ah_ani_function); + + if (chan == NULL && cmd != HAL_ANI_MODE) { HALDEBUG(ah, HAL_DEBUG_UNMASKABLE, "%s: ignoring cmd 0x%02x - no channel\n", __func__, cmd); return AH_FALSE; } - switch (cmd & ahp->ah_ani_function) { + /* + * These two control the top-level cck/ofdm immunity levels and will + * program the rest of the values. + */ + if (cmd == HAL_ANI_NOISE_IMMUNITY_LEVEL) { + if (param > HAL_ANI_OFDM_NUM_LEVEL) + return AH_FALSE; + ar9300_ani_set_odfm_noise_immunity_level(ah, param); + return AH_TRUE; + } + + if (cmd == HAL_ANI_CCK_NOISE_IMMUNITY_LEVEL) { + if (param > HAL_ANI_CCK_NUM_LEVEL) + return AH_FALSE; + ar9300_ani_set_cck_noise_immunity_level(ah, param); + return AH_TRUE; + } + + /* + * Check to see if this command is available in the + * current operating mode. + */ + if (((1 << cmd) & ahp->ah_ani_function) == 0) { + HALDEBUG(ah, HAL_DEBUG_ANI, + "%s: early check: invalid cmd 0x%02x (allowed=0x%02x)\n", + __func__, cmd, ahp->ah_ani_function); + return AH_FALSE; + } + + /* + * The rest of these program in the requested parameter values + * into the PHY. + */ + switch (cmd) { + case HAL_ANI_OFDM_WEAK_SIGNAL_DETECTION: { int m1_thresh_low, m2_thresh_low; @@ -887,13 +929,16 @@ ar9300_ani_reset(struct ath_hal *ah, HAL_BOOL is_scann /* only allow a subset of functions in AP mode */ if (AH_PRIVATE(ah)->ah_opmode == HAL_M_HOSTAP) { if (IS_CHAN_2GHZ(ichan)) { - ahp->ah_ani_function = (HAL_ANI_SPUR_IMMUNITY_LEVEL | - HAL_ANI_FIRSTEP_LEVEL | - HAL_ANI_MRC_CCK); + ahp->ah_ani_function = (1 << HAL_ANI_SPUR_IMMUNITY_LEVEL) | + (1 << HAL_ANI_FIRSTEP_LEVEL) | + (1 << HAL_ANI_MRC_CCK); } else { ahp->ah_ani_function = 0; } + } else { + ahp->ah_ani_function = HAL_ANI_ALL; } + /* always allow mode (on/off) to be controlled */ ahp->ah_ani_function |= HAL_ANI_MODE; @@ -1172,6 +1217,7 @@ ar9300_ani_ar_poll(struct ath_hal *ah, const HAL_NODE_ cck_phy_err_cnt = OS_REG_READ(ah, AR_PHY_ERR_2); /* Populate HAL_ANISTATS */ + /* XXX TODO: are these correct? */ if (ani_stats) { ani_stats->cckphyerr_cnt = cck_phy_err_cnt - ani_state->cck_phy_err_count; @@ -1212,18 +1258,32 @@ ar9300_ani_ar_poll(struct ath_hal *ah, const HAL_NODE_ return; } + /* + * Calculate the OFDM/CCK phy error rate over the listen time interval. + * This is used in subsequent math to see if the OFDM/CCK phy error rate + * is above or below the threshold checks. + */ + ofdm_phy_err_rate = ani_state->ofdm_phy_err_count * 1000 / ani_state->listen_time; cck_phy_err_rate = ani_state->cck_phy_err_count * 1000 / ani_state->listen_time; HALDEBUG(ah, HAL_DEBUG_ANI, - "%s: listen_time=%d OFDM:%d errs=%d/s CCK:%d errs=%d/s ofdm_turn=%d\n", + "%s: listen_time=%d (total: %d) OFDM:%d errs=%d/s CCK:%d errs=%d/s ofdm_turn=%d\n", __func__, listen_time, + ani_state->listen_time, ani_state->ofdm_noise_immunity_level, ofdm_phy_err_rate, ani_state->cck_noise_immunity_level, cck_phy_err_rate, ani_state->ofdms_turn); + /* + * Check for temporary noise spurs. This is intended to be used by + * rate control to check if we should try higher packet rates or not. + * If the noise period is short enough then we shouldn't avoid trying + * higher rates but if the noise is high/sustained then it's likely + * not a great idea to try the higher MCS rates. + */ if (ani_state->listen_time >= HAL_NOISE_DETECT_PERIOD) { old_phy_noise_spur = ani_state->phy_noise_spur; if (ofdm_phy_err_rate <= ani_state->ofdm_trig_low && @@ -1236,7 +1296,7 @@ ar9300_ani_ar_poll(struct ath_hal *ah, const HAL_NODE_ } if (old_phy_noise_spur != ani_state->phy_noise_spur) { HALDEBUG(ah, HAL_DEBUG_ANI, - "%s: enviroment change from %d to %d\n", + "%s: environment change from %d to %d\n", __func__, old_phy_noise_spur, ani_state->phy_noise_spur); } } @@ -1259,6 +1319,10 @@ ar9300_ani_ar_poll(struct ath_hal *ah, const HAL_NODE_ ar9300_ani_lower_immunity(ah); ani_state->ofdms_turn = !ani_state->ofdms_turn; } + /* + * Force an ANI restart regardless of whether the lower immunity + * level was met. + */ HALDEBUG(ah, HAL_DEBUG_ANI, "%s: 1 listen_time=%d ofdm=%d/s cck=%d/s - " "calling ar9300_ani_restart\n", @@ -1292,6 +1356,13 @@ ar9300_ani_ar_poll(struct ath_hal *ah, const HAL_NODE_ ani_state->ofdms_turn = AH_TRUE; } } + + /* + * Note that currently this poll function doesn't reset the listen + * time after it accumulates a second worth of error samples. + * It will continue to accumulate samples until a counter overflows, + * or a raise threshold is met, or 5 seconds passes. + */ } /* Modified: releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_eeprom.c ============================================================================== --- releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_eeprom.c Sat Sep 12 18:58:36 2020 (r365669) +++ releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_eeprom.c Sat Sep 12 19:33:25 2020 (r365670) @@ -3040,6 +3040,33 @@ ar9300_eeprom_set_transmit_power(struct ath_hal *ah, ahp->reg_dmn = ath_hal_getctl(ah, chan); /* + * After reading FCC/OET 13TR1003 (Directional Gain of IEEE 802.11 + * MIMO devices employing cyclic delay diversity) and looking at what + * ath9k does, let's disable the CDD check until it's clearer exactly + * how the maximum cap should be applied here. + * + * Right now the CDD check is simply unconditionally reducing the + * gain of legacy and 1/2 stream rates depending upon the chainmask. + * (CDD is used when transmitting rates that don't already use up the + * full set of streams - eg OFDM or MCS0-7 on a 2 or 3 chain TX path.) + * + * It's dropping the 2-chain TX by 3dB and 3-chain by 5dB to "meet" + * power spectral density requirements but it's not currently taking + * into account how close to the regulatory limit the hardware/antenna + * system is already at. It doesn't help that the conductive testing + * limits have the array gain at 0dB for all AR9300/derivative + * configurations. + * + * It also doesn't let us do single chain transmit at the full allowed + * power for the regulatory/CTL limits as it subtracts it from what's + * programmed into the hardware. + * + * ath9k doesn't factor any of the CDD stuff into account, so I'm going + * to disable it here and in the TPC path until I get a better idea + * of what to really do here. + */ +#if 0 + /* * Always use CDD/direct per rate power table for register based approach. * For FCC, CDD calculations should factor in the array gain, hence * this adjust call. ETSI and MKK does not have this requirement. @@ -3050,6 +3077,7 @@ ar9300_eeprom_set_transmit_power(struct ath_hal *ah, __func__); ar9300_adjust_reg_txpower_cdd(ah, target_power_val_t2); } +#endif if (ar9300_eeprom_get(ahp, EEP_PAPRD_ENABLED)) { for (i = 0; i < ar9300_rate_size; i++) { Modified: releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_freebsd.c ============================================================================== --- releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_freebsd.c Sat Sep 12 18:58:36 2020 (r365669) +++ releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_freebsd.c Sat Sep 12 19:33:25 2020 (r365670) @@ -355,7 +355,7 @@ ar9300_attach_freebsd_ops(struct ath_hal *ah) ah->ah_setRxDP = ar9300_set_rx_dp; ah->ah_enableReceive = ar9300_enable_receive; ah->ah_stopDmaReceive = ar9300_stop_dma_receive_freebsd; - ah->ah_startPcuReceive = ar9300_start_pcu_receive_freebsd; + ah->ah_startPcuReceive = ar9300_start_pcu_receive; ah->ah_stopPcuReceive = ar9300_stop_pcu_receive; ah->ah_setMulticastFilter = ar9300_set_multicast_filter; ah->ah_setMulticastFilterIndex = ar9300SetMulticastFilterIndex; @@ -543,6 +543,7 @@ ar9300_reset_freebsd(struct ath_hal *ah, HAL_OPMODE op HAL_HT_EXTPROTSPACING_20, /* always 20Mhz channel spacing */ bChannelChange, status, + resetType, AH_FALSE); /* XXX should really extend ath_hal_reset() */ return (r); @@ -678,14 +679,6 @@ ar9300_reset_cal_valid_freebsd(struct ath_hal *ah, return (is_cal_done); } - -void -ar9300_start_pcu_receive_freebsd(struct ath_hal *ah) -{ - - /* is_scanning flag == NULL */ - ar9300_start_pcu_receive(ah, AH_FALSE); -} /* * FreeBSD will just pass in the descriptor value as 'pa'. Modified: releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_misc.c ============================================================================== --- releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_misc.c Sat Sep 12 18:58:36 2020 (r365669) +++ releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_misc.c Sat Sep 12 19:33:25 2020 (r365670) @@ -1263,15 +1263,13 @@ ar9300_get_diag_state(struct ath_hal *ah, int request, if (ani == AH_NULL) return AH_FALSE; /* Convert ar9300 HAL to FreeBSD HAL ANI state */ - /* XXX TODO: add all of these to the HAL ANI state structure */ bzero(&ahp->ext_ani_state, sizeof(ahp->ext_ani_state)); - /* XXX should this be OFDM or CCK noise immunity level? */ ahp->ext_ani_state.noiseImmunityLevel = ani->ofdm_noise_immunity_level; ahp->ext_ani_state.spurImmunityLevel = ani->spur_immunity_level; ahp->ext_ani_state.firstepLevel = ani->firstep_level; ahp->ext_ani_state.ofdmWeakSigDetectOff = ani->ofdm_weak_sig_detect_off; - /* mrc_cck_off */ - /* cck_noise_immunity_level */ + ahp->ext_ani_state.mrcCck = !! ani->mrc_cck_off; + ahp->ext_ani_state.cckNoiseImmunityLevel = ani->cck_noise_immunity_level; ahp->ext_ani_state.listenTime = ani->listen_time; @@ -1289,12 +1287,18 @@ ar9300_get_diag_state(struct ath_hal *ah, int request, 0 : sizeof(HAL_ANI_STATS); return AH_TRUE; case HAL_DIAG_ANI_CMD: + { + HAL_ANI_CMD savefunc = ahp->ah_ani_function; if (argsize != 2*sizeof(u_int32_t)) { return AH_FALSE; } + /* temporarly allow all functions so we can override */ + ahp->ah_ani_function = HAL_ANI_ALL; ar9300_ani_control( ah, ((const u_int32_t *)args)[0], ((const u_int32_t *)args)[1]); + ahp->ah_ani_function = savefunc; return AH_TRUE; + } #if 0 case HAL_DIAG_TXCONT: /*AR9300_CONTTXMODE(ah, (struct ath_desc *)args, argsize );*/ Modified: releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_phy.c ============================================================================== --- releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_phy.c Sat Sep 12 18:58:36 2020 (r365669) +++ releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_phy.c Sat Sep 12 19:33:25 2020 (r365670) @@ -55,10 +55,12 @@ static inline void ar9300_init_rate_txpower_stbc(struc const HAL_RATE_TABLE *rt, HAL_BOOL is40, int rt_ss_offset, int rt_ds_offset, int rt_ts_offset, u_int8_t chainmask); +#if 0 static inline void ar9300_adjust_rate_txpower_cdd(struct ath_hal *ah, const HAL_RATE_TABLE *rt, HAL_BOOL is40, int rt_ss_offset, int rt_ds_offset, int rt_ts_offset, u_int8_t chainmask); +#endif #define AR9300_11A_RT_OFDM_OFFSET 0 HAL_RATE_TABLE ar9300_11a_table = { @@ -442,6 +444,8 @@ ar9300_adjust_reg_txpower_cdd(struct ath_hal *ah, ((int16_t)AH_MIN((ahp->twice_antenna_reduction - (ahp->twice_antenna_gain + AR9300_TXBF_2TX_ARRAY_GAIN)), 0)); cdd_power = ahp->upper_limit[1] + twice_array_gain; + + HALDEBUG(ah, HAL_DEBUG_CALIBRATE, "%s: 2 chain; cdd_power=%d", __func__, cdd_power); /* Adjust OFDM legacy rates as well */ for (i = ALL_TARGET_LEGACY_6_24; i <= ALL_TARGET_LEGACY_54; i++) { if (power_per_rate[i] > cdd_power) { @@ -471,6 +475,7 @@ ar9300_adjust_reg_txpower_cdd(struct ath_hal *ah, ((int16_t)AH_MIN((ahp->twice_antenna_reduction - (ahp->twice_antenna_gain + AR9300_TXBF_3TX_ARRAY_GAIN)), 0)); cdd_power = ahp->upper_limit[2] + twice_array_gain; + HALDEBUG(ah, HAL_DEBUG_CALIBRATE, "%s: 3 chain; cdd_power=%d", __func__, cdd_power); /* Adjust OFDM legacy rates as well */ for (i = ALL_TARGET_LEGACY_6_24; i <= ALL_TARGET_LEGACY_54; i++) { if (power_per_rate[i] > cdd_power) { @@ -531,6 +536,7 @@ ar9300_init_rate_txpower(struct ath_hal *ah, u_int mod AR9300_11NA_RT_HT_SS_OFFSET, AR9300_11NA_RT_HT_DS_OFFSET, AR9300_11NA_RT_HT_TS_OFFSET, chainmask); +#if 0 /* For FCC the array gain has to be factored for CDD mode */ if (is_reg_dmn_fcc(ath_hal_getctl(ah, chan))) { ar9300_adjust_rate_txpower_cdd(ah, rt, is40, @@ -538,6 +544,7 @@ ar9300_init_rate_txpower(struct ath_hal *ah, u_int mod AR9300_11NA_RT_HT_DS_OFFSET, AR9300_11NA_RT_HT_TS_OFFSET, chainmask); } +#endif break; case HAL_MODE_11G: ar9300_init_rate_txpower_cck(ah, rt, power_per_rate, chainmask); @@ -561,6 +568,7 @@ ar9300_init_rate_txpower(struct ath_hal *ah, u_int mod AR9300_11NG_RT_HT_SS_OFFSET, AR9300_11NG_RT_HT_DS_OFFSET, AR9300_11NG_RT_HT_TS_OFFSET, chainmask); +#if 0 /* For FCC the array gain needs to be factored for CDD mode */ if (is_reg_dmn_fcc(ath_hal_getctl(ah, chan))) { ar9300_adjust_rate_txpower_cdd(ah, rt, is40, @@ -568,6 +576,7 @@ ar9300_init_rate_txpower(struct ath_hal *ah, u_int mod AR9300_11NG_RT_HT_DS_OFFSET, AR9300_11NG_RT_HT_TS_OFFSET, chainmask); } +#endif break; default: HALDEBUG(ah, HAL_DEBUG_POWER_MGMT, "%s: invalid mode 0x%x\n", @@ -941,6 +950,10 @@ ar9300_init_rate_txpower_stbc(struct ath_hal *ah, cons return; } +/* + * To see why this is disabled, look at ar9300_eeprom.c for FCC/OET 13TR1003. + */ +#if 0 static inline void ar9300_adjust_rate_txpower_cdd(struct ath_hal *ah, const HAL_RATE_TABLE *rt, HAL_BOOL is40, @@ -1037,6 +1050,7 @@ ar9300_adjust_rate_txpower_cdd(struct ath_hal *ah, con return; } +#endif void ar9300_disp_tpc_tables(struct ath_hal *ah) { Modified: releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_reset.c ============================================================================== --- releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_reset.c Sat Sep 12 18:58:36 2020 (r365669) +++ releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_reset.c Sat Sep 12 19:33:25 2020 (r365670) @@ -2064,7 +2064,7 @@ ar9300_set_rf_mode(struct ath_hal *ah, struct ieee8021 * Places the hardware into reset and then pulls it out of reset */ HAL_BOOL -ar9300_chip_reset(struct ath_hal *ah, struct ieee80211_channel *chan) +ar9300_chip_reset(struct ath_hal *ah, struct ieee80211_channel *chan, HAL_RESET_TYPE reset_type) { struct ath_hal_9300 *ahp = AH9300(ah); int type = HAL_RESET_WARM; @@ -2080,8 +2080,13 @@ ar9300_chip_reset(struct ath_hal *ah, struct ieee80211 */ if (ahp->ah_chip_full_sleep || (ah->ah_config.ah_force_full_reset == 1) || + (reset_type == HAL_RESET_FORCE_COLD) || + (reset_type == HAL_RESET_BBPANIC) || OS_REG_READ(ah, AR_Q_TXE) || (OS_REG_READ(ah, AR_CR) & AR_CR_RXE)) { + HALDEBUG(ah, HAL_DEBUG_RESET, + "%s: full reset; reset_type=%d, full_sleep=%d\n", + __func__, reset_type, ahp->ah_chip_full_sleep); type = HAL_RESET_COLD; } @@ -4510,7 +4515,7 @@ HAL_BOOL ar9300_reset(struct ath_hal *ah, HAL_OPMODE opmode, struct ieee80211_channel *chan, HAL_HT_MACMODE macmode, u_int8_t txchainmask, u_int8_t rxchainmask, HAL_HT_EXTPROTSPACING extprotspacing, HAL_BOOL b_channel_change, - HAL_STATUS *status, int is_scan) + HAL_STATUS *status, HAL_RESET_TYPE reset_type, int is_scan) { #define FAIL(_code) do { ecode = _code; goto bad; } while (0) u_int32_t save_led_state; @@ -4864,7 +4869,7 @@ ar9300_reset(struct ath_hal *ah, HAL_OPMODE opmode, st /* Mark PHY inactive prior to reset, to be undone in ar9300_init_bb () */ ar9300_mark_phy_inactive(ah); - if (!ar9300_chip_reset(ah, chan)) { + if (!ar9300_chip_reset(ah, chan, reset_type)) { HALDEBUG(ah, HAL_DEBUG_RESET, "%s: chip reset failed\n", __func__); FAIL(HAL_EIO); } Modified: releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_stub_funcs.c ============================================================================== --- releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_stub_funcs.c Sat Sep 12 18:58:36 2020 (r365669) +++ releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_stub_funcs.c Sat Sep 12 19:33:25 2020 (r365670) @@ -691,7 +691,7 @@ ar9300_Stub_StopDmaReceive(struct ath_hal *ah) } void -ar9300_Stub_StartPcuReceive(struct ath_hal *ah) +ar9300_Stub_StartPcuReceive(struct ath_hal *ah, HAL_BOOL is_scanning) { ath_hal_printf(ah, "%s: called\n", __func__); Modified: releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_stub_funcs.h ============================================================================== --- releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_stub_funcs.h Sat Sep 12 18:58:36 2020 (r365669) +++ releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_stub_funcs.h Sat Sep 12 19:33:25 2020 (r365670) @@ -112,7 +112,7 @@ extern void ar9300_Stub_SetRxDP(struct ath_hal *ah, ui HAL_RX_QUEUE); extern void ar9300_Stub_EnableReceive(struct ath_hal *ah); extern HAL_BOOL ar9300_Stub_StopDmaReceive(struct ath_hal *ah); -extern void ar9300_Stub_StartPcuReceive(struct ath_hal *ah); +extern void ar9300_Stub_StartPcuReceive(struct ath_hal *ah, HAL_BOOL); extern void ar9300_Stub_StopPcuReceive(struct ath_hal *ah); extern void ar9300_Stub_SetMulticastFilter(struct ath_hal *ah, uint32_t filter0, uint32_t filter1); Modified: releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300eep.h ============================================================================== --- releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300eep.h Sat Sep 12 18:58:36 2020 (r365669) +++ releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300eep.h Sat Sep 12 19:33:25 2020 (r365670) @@ -18,13 +18,17 @@ #define _ATH_AR9300_EEP_H_ #include "opt_ah.h" - #include "ah.h" #if defined(WIN32) || defined(WIN64) #pragma pack (push, ar9300, 1) #endif +/* Ensure that AH_BYTE_ORDER is defined */ +#ifndef AH_BYTE_ORDER +#error AH_BYTE_ORDER needs to be defined! +#endif + /* FreeBSD extras - should be in ah_eeprom.h ? */ #define AR_EEPROM_EEPCAP_COMPRESS_DIS 0x0001 #define AR_EEPROM_EEPCAP_AES_DIS 0x0002 @@ -345,11 +349,13 @@ typedef struct CalCtlEdgePwr { u_int8_t flag :2, t_power :6; } __packed CAL_CTL_EDGE_PWR; -#else +#elif AH_BYTE_ORDER == AH_LITTLE_ENDIAN typedef struct CalCtlEdgePwr { u_int8_t t_power :6, flag :2; } __packed CAL_CTL_EDGE_PWR; +#else +#error AH_BYTE_ORDER undefined! #endif typedef struct ospCalCtlData_5G { Modified: releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300template_ap121.h ============================================================================== --- releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300template_ap121.h Sat Sep 12 18:58:36 2020 (r365669) +++ releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300template_ap121.h Sat Sep 12 19:33:25 2020 (r365670) @@ -25,6 +25,11 @@ #ifndef __ar9300templateAP121_h__ #define __ar9300templateAP121_h__ +/* Ensure that AH_BYTE_ORDER is defined */ +#ifndef AH_BYTE_ORDER +#error AH_BYTE_ORDER needs to be defined! +#endif + static ar9300_eeprom_t ar9300_template_ap121= { Modified: releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300template_aphrodite.h ============================================================================== --- releng/12.2/sys/contrib/dev/ath/ath_hal/ar9300/ar9300template_aphrodite.h Sat Sep 12 18:58:36 2020 (r365669) *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-releng@freebsd.org Sat Sep 12 21:50:27 2020 Return-Path: Delivered-To: svn-src-releng@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A82733E35D7; Sat, 12 Sep 2020 21:50:27 +0000 (UTC) (envelope-from bz@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BpmWl4HyJz4Xyf; Sat, 12 Sep 2020 21:50:27 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 769381B8E8; Sat, 12 Sep 2020 21:50:27 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 08CLoR2A069561; Sat, 12 Sep 2020 21:50:27 GMT (envelope-from bz@FreeBSD.org) Received: (from bz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 08CLoPNf069552; Sat, 12 Sep 2020 21:50:25 GMT (envelope-from bz@FreeBSD.org) Message-Id: <202009122150.08CLoPNf069552@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bz set sender to bz@FreeBSD.org using -f From: "Bjoern A. Zeeb" Date: Sat, 12 Sep 2020 21:50:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-releng@freebsd.org Subject: svn commit: r365673 - in releng/12.2: sbin/rtsol usr.sbin/rtsold X-SVN-Group: releng X-SVN-Commit-Author: bz X-SVN-Commit-Paths: in releng/12.2: sbin/rtsol usr.sbin/rtsold X-SVN-Commit-Revision: 365673 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-releng@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the release engineering / security commits to the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Sep 2020 21:50:27 -0000 Author: bz Date: Sat Sep 12 21:50:25 2020 New Revision: 365673 URL: https://svnweb.freebsd.org/changeset/base/365673 Log: MFS r365630 (markj, bz) - Capsicumize rtsol(8) and rtsold(8). - Avoid relying on pollution from libcasper.h. - Add script for "M bit". Approved by: re (gjb) Added: releng/12.2/usr.sbin/rtsold/cap_llflags.c - copied unchanged from r365630, stable/12/usr.sbin/rtsold/cap_llflags.c releng/12.2/usr.sbin/rtsold/cap_script.c - copied unchanged from r365630, stable/12/usr.sbin/rtsold/cap_script.c releng/12.2/usr.sbin/rtsold/cap_sendmsg.c - copied unchanged from r365630, stable/12/usr.sbin/rtsold/cap_sendmsg.c Deleted: releng/12.2/usr.sbin/rtsold/probe.c Modified: releng/12.2/sbin/rtsol/Makefile releng/12.2/usr.sbin/rtsold/Makefile releng/12.2/usr.sbin/rtsold/dump.c releng/12.2/usr.sbin/rtsold/if.c releng/12.2/usr.sbin/rtsold/rtsock.c releng/12.2/usr.sbin/rtsold/rtsol.c releng/12.2/usr.sbin/rtsold/rtsold.8 releng/12.2/usr.sbin/rtsold/rtsold.c releng/12.2/usr.sbin/rtsold/rtsold.h Directory Properties: releng/12.2/ (props changed) Modified: releng/12.2/sbin/rtsol/Makefile ============================================================================== --- releng/12.2/sbin/rtsol/Makefile Sat Sep 12 20:20:55 2020 (r365672) +++ releng/12.2/sbin/rtsol/Makefile Sat Sep 12 21:50:25 2020 (r365673) @@ -18,10 +18,24 @@ PACKAGE=runtime PROG= rtsol -SRCS= rtsold.c rtsol.c if.c probe.c dump.c rtsock.c +SRCS= cap_llflags.c \ + cap_script.c \ + cap_sendmsg.c \ + dump.c \ + if.c \ + rtsol.c \ + rtsold.c \ + rtsock.c MAN= +LIBADD= util -WARNS?= 3 -CFLAGS+= -DSMALL +.include + +.if ${MK_DYNAMICROOT} == "no" +.warning ${PROG} built without libcasper support +.elif ${MK_CASPER} != "no" && !defined(RESCUE) +CFLAGS+= -DWITH_CASPER +LIBADD+= cap_syslog casper nv +.endif .include Modified: releng/12.2/usr.sbin/rtsold/Makefile ============================================================================== --- releng/12.2/usr.sbin/rtsold/Makefile Sat Sep 12 20:20:55 2020 (r365672) +++ releng/12.2/usr.sbin/rtsold/Makefile Sat Sep 12 21:50:25 2020 (r365673) @@ -17,8 +17,22 @@ PROG= rtsold MAN= rtsold.8 MLINKS= rtsold.8 rtsol.8 -SRCS= rtsold.c rtsol.c if.c probe.c dump.c rtsock.c +SRCS= cap_llflags.c \ + cap_script.c \ + cap_sendmsg.c \ + dump.c \ + if.c \ + rtsock.c \ + rtsol.c \ + rtsold.c -WARNS?= 3 +LIBADD= util + +.include + +.if ${MK_CASPER} != "no" +CFLAGS+= -DWITH_CASPER +LIBADD+= casper cap_syslog nv +.endif .include Copied: releng/12.2/usr.sbin/rtsold/cap_llflags.c (from r365630, stable/12/usr.sbin/rtsold/cap_llflags.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ releng/12.2/usr.sbin/rtsold/cap_llflags.c Sat Sep 12 21:50:25 2020 (r365673, copy of r365630, stable/12/usr.sbin/rtsold/cap_llflags.c) @@ -0,0 +1,158 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2018 The FreeBSD Foundation + * + * This software was developed by Mark Johnston under sponsorship from + * the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include "rtsold.h" + +/* + * A service to fetch the flags for the link-local IPv6 address on the specified + * interface. This cannot easily be done in capability mode because we need to + * use the routing socket sysctl API to find the link-local address of a + * particular interface. The SIOCGIFCONF ioctl is one other option, but as + * currently implemented it is less flexible (it cannot report the required + * buffer length), and hard-codes a buffer length limit. + */ + +static int +llflags_get(const char *ifname, int *flagsp) +{ + struct in6_ifreq ifr6; + struct ifaddrs *ifap, *ifa; + struct sockaddr_in6 *sin6; + int error, s; + + s = socket(PF_INET6, SOCK_DGRAM, 0); + if (s < 0) + return (-1); + + if (getifaddrs(&ifap) != 0) + return (-1); + error = -1; + for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) { + if (strcmp(ifa->ifa_name, ifname) != 0) + continue; + if (ifa->ifa_addr->sa_family != AF_INET6) + continue; + + sin6 = (struct sockaddr_in6 *)(void *)ifa->ifa_addr; + if (!IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) + continue; + + memset(&ifr6, 0, sizeof(ifr6)); + if (strlcpy(ifr6.ifr_name, ifname, sizeof(ifr6.ifr_name)) >= + sizeof(ifr6.ifr_name)) { + freeifaddrs(ifap); + errno = EINVAL; + return (-1); + } + memcpy(&ifr6.ifr_ifru.ifru_addr, sin6, sin6->sin6_len); + if (ioctl(s, SIOCGIFAFLAG_IN6, &ifr6) < 0) { + error = errno; + freeifaddrs(ifap); + errno = error; + return (-1); + } + + *flagsp = ifr6.ifr_ifru.ifru_flags6; + error = 0; + break; + } + (void)close(s); + freeifaddrs(ifap); + if (error == -1) + errno = ENOENT; + return (error); +} + +int +cap_llflags_get(cap_channel_t *cap, const char *ifname, int *flagsp) +{ +#ifdef WITH_CASPER + nvlist_t *nvl; + int error; + + nvl = nvlist_create(0); + nvlist_add_string(nvl, "cmd", "get"); + nvlist_add_string(nvl, "ifname", ifname); + nvl = cap_xfer_nvlist(cap, nvl); + if (nvl == NULL) + return (-1); + error = (int)dnvlist_get_number(nvl, "error", 0); + if (error == 0) + *flagsp = (int)nvlist_get_number(nvl, "flags"); + nvlist_destroy(nvl); + if (error != 0) + errno = error; + return (error == 0 ? 0 : -1); +#else + (void)cap; + return (llflags_get(ifname, flagsp)); +#endif +} + +#ifdef WITH_CASPER +static int +llflags_command(const char *cmd, const nvlist_t *limits __unused, + nvlist_t *nvlin, nvlist_t *nvlout) +{ + const char *ifname; + int flags; + + if (strcmp(cmd, "get") != 0) + return (EINVAL); + ifname = nvlist_get_string(nvlin, "ifname"); + if (llflags_get(ifname, &flags) != 0) + return (errno); + nvlist_add_number(nvlout, "flags", flags); + return (0); +} + +CREATE_SERVICE("rtsold.llflags", NULL, llflags_command, 0); +#endif /* WITH_CASPER */ Copied: releng/12.2/usr.sbin/rtsold/cap_script.c (from r365630, stable/12/usr.sbin/rtsold/cap_script.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ releng/12.2/usr.sbin/rtsold/cap_script.c Sat Sep 12 21:50:25 2020 (r365673, copy of r365630, stable/12/usr.sbin/rtsold/cap_script.c) @@ -0,0 +1,236 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2018 The FreeBSD Foundation + * + * This software was developed by Mark Johnston under sponsorship from + * the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include "rtsold.h" + +/* + * Run the script and return the write end of a pipe to the main process. + * Return -1 and set errno on error. + */ +static int +script_run(char **argv) +{ + pid_t pid; + int fd[2], null; + + if (pipe(fd) != 0) + return (-1); + if ((pid = fork()) < 0) + return (-1); + if (pid == 0) { + (void)close(fd[1]); + null = open("/dev/null", O_RDWR); + if (null < 0) + _exit(1); + if (dup2(fd[0], STDIN_FILENO) != STDIN_FILENO) + _exit(1); + + closefrom(3); + (void)execve(argv[0], argv, NULL); + _exit(1); + } else + (void)close(fd[0]); + + return (fd[1]); +} + +int +cap_script_run(cap_channel_t *cap, const char *const *argv) +{ +#ifdef WITH_CASPER + nvlist_t *nvl; + size_t argc; + int error, wfd; + + for (argc = 0; argv[argc] != NULL; argc++) + ; + + nvl = nvlist_create(0); + nvlist_add_string(nvl, "cmd", "script_run"); + nvlist_add_string_array(nvl, "argv", argv, argc); + nvl = cap_xfer_nvlist(cap, nvl); + if (nvl == NULL) + return (-1); + + error = (int)dnvlist_get_number(nvl, "error", 0); + if (error == 0) + wfd = nvlist_take_descriptor(nvl, "fd"); + nvlist_destroy(nvl); + if (error != 0) + errno = error; + return (error == 0 ? wfd : -1); +#else + (void)cap; + return (script_run(__DECONST(char **, argv))); +#endif +} + +/* + * Wait for a child process to exit, and return its status. + * Return -1 and set errno upon error. + */ +static int +script_wait(int *statusp) +{ + int error; + + error = wait(statusp); + return (error >= 0 ? 0 : -1); +} + +int +cap_script_wait(cap_channel_t *cap, int *statusp) +{ +#ifdef WITH_CASPER + nvlist_t *nvl; + int error; + + nvl = nvlist_create(0); + nvlist_add_string(nvl, "cmd", "script_wait"); + nvl = cap_xfer_nvlist(cap, nvl); + if (nvl == NULL) + return (-1); + + error = (int)dnvlist_get_number(nvl, "error", 0); + if (error == 0) + *statusp = (int)nvlist_get_number(nvl, "status"); + nvlist_destroy(nvl); + if (error != 0) + errno = error; + return (error == 0 ? 0 : -1); +#else + (void)cap; + return (script_wait(statusp)); +#endif +} + +#ifdef WITH_CASPER +static int +script_command(const char *cmd, const nvlist_t *limits, nvlist_t *nvlin, + nvlist_t *nvlout) +{ + cap_rights_t rights; + const char *const *iargv, *const *scripts; + char **argv; + size_t argc, i, nscripts; + int fd, status; + + if (strcmp(cmd, "script_wait") == 0) { + /* Wait for the result of a previous "script_run" command. */ + if (script_wait(&status) == -1) + return (errno); + nvlist_add_number(nvlout, "status", status); + return (0); + } + if (strcmp(cmd, "script_run") != 0) + return (EINVAL); + + /* + * Validate the argv against the limits specified at initialization + * time. + */ + iargv = nvlist_get_string_array(nvlin, "argv", &argc); + if (argc == 0) + return (EINVAL); + scripts = nvlist_get_string_array(limits, "scripts", &nscripts); + for (i = 0; i < nscripts; i++) + if (strcmp(iargv[0], scripts[i]) == 0) + break; + if (i == nscripts) + return (EINVAL); + + /* + * The nvlist API does not permit NULL pointers in an array, so we have + * to add the nul terminator ourselves. Yuck. + */ + argv = calloc(argc + 1, sizeof(*argv)); + if (argv == NULL) + return (errno); + memcpy(argv, iargv, sizeof(*argv) * argc); + + fd = script_run(argv); + if (fd < 0) + return (errno); + + (void)caph_rights_limit(fd, cap_rights_init(&rights, CAP_WRITE)); + nvlist_move_descriptor(nvlout, "fd", fd); + return (0); +} + +static int +script_limit(const nvlist_t *oldlimits, const nvlist_t *newlimits __unused) +{ + const char *name; + void *cookie; + int nvtype; + bool hasscripts; + + /* Limits may only be set once. */ + if (oldlimits != NULL) + return (ENOTCAPABLE); + + cookie = NULL; + hasscripts = false; + while ((name = nvlist_next(newlimits, &nvtype, &cookie)) != NULL) { + if (nvtype == NV_TYPE_STRING_ARRAY && + strcmp(name, "scripts") == 0) + hasscripts = true; + else + return (EINVAL); + } + if (!hasscripts) + return (EINVAL); + return (0); +} + +CREATE_SERVICE("rtsold.script", script_limit, script_command, 0); +#endif /* WITH_CASPER */ Copied: releng/12.2/usr.sbin/rtsold/cap_sendmsg.c (from r365630, stable/12/usr.sbin/rtsold/cap_sendmsg.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ releng/12.2/usr.sbin/rtsold/cap_sendmsg.c Sat Sep 12 21:50:25 2020 (r365673, copy of r365630, stable/12/usr.sbin/rtsold/cap_sendmsg.c) @@ -0,0 +1,282 @@ +/* $KAME: probe.c,v 1.17 2003/10/05 00:09:36 itojun Exp $ */ + +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (C) 1998 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "rtsold.h" + +static int +getsocket(int *sockp, int proto) +{ + cap_rights_t rights; + int sock; + + if (*sockp >= 0) + return (0); + + if ((sock = socket(AF_INET6, SOCK_RAW, proto)) < 0) + return (-1); + cap_rights_init(&rights, CAP_CONNECT, CAP_SEND); + if (caph_rights_limit(sock, &rights) != 0) + return (-1); + *sockp = sock; + + return (0); +} + +static ssize_t +sendpacket(int sock, struct sockaddr_in6 *dst, uint32_t ifindex, int hoplimit, + const void *data, size_t len) +{ + uint8_t cmsg[CMSG_SPACE(sizeof(struct in6_pktinfo)) + + CMSG_SPACE(sizeof(int))]; + struct msghdr hdr; + struct iovec iov; + struct in6_pktinfo *pi; + struct cmsghdr *cm; + + memset(&hdr, 0, sizeof(hdr)); + hdr.msg_name = dst; + hdr.msg_namelen = sizeof(*dst); + hdr.msg_iov = &iov; + hdr.msg_iovlen = 1; + hdr.msg_control = cmsg; + hdr.msg_controllen = sizeof(cmsg); + + iov.iov_base = __DECONST(void *, data); + iov.iov_len = len; + + /* Specify the outbound interface. */ + cm = CMSG_FIRSTHDR(&hdr); + cm->cmsg_level = IPPROTO_IPV6; + cm->cmsg_type = IPV6_PKTINFO; + cm->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo)); + pi = (struct in6_pktinfo *)(void *)CMSG_DATA(cm); + memset(&pi->ipi6_addr, 0, sizeof(pi->ipi6_addr)); /*XXX*/ + pi->ipi6_ifindex = ifindex; + + /* Specify the hop limit of the packet for safety. */ + cm = CMSG_NXTHDR(&hdr, cm); + cm->cmsg_level = IPPROTO_IPV6; + cm->cmsg_type = IPV6_HOPLIMIT; + cm->cmsg_len = CMSG_LEN(sizeof(int)); + memcpy(CMSG_DATA(cm), &hoplimit, sizeof(int)); + + return (sendmsg(sock, &hdr, 0)); +} + +static int +probe_defrouters(uint32_t ifindex, uint32_t linkid) +{ + static int probesock = -1; + struct sockaddr_in6 dst; + struct in6_defrouter *p, *ep; + char *buf; + size_t len; + int mib[4]; + + if (ifindex == 0) + return (0); + if (getsocket(&probesock, IPPROTO_NONE) != 0) + return (-1); + + mib[0] = CTL_NET; + mib[1] = PF_INET6; + mib[2] = IPPROTO_ICMPV6; + mib[3] = ICMPV6CTL_ND6_DRLIST; + if (sysctl(mib, nitems(mib), NULL, &len, NULL, 0) < 0) + return (-1); + if (len == 0) + return (0); + + memset(&dst, 0, sizeof(dst)); + dst.sin6_family = AF_INET6; + dst.sin6_len = sizeof(dst); + + buf = malloc(len); + if (buf == NULL) + return (-1); + if (sysctl(mib, nitems(mib), buf, &len, NULL, 0) < 0) + return (-1); + ep = (struct in6_defrouter *)(void *)(buf + len); + for (p = (struct in6_defrouter *)(void *)buf; p < ep; p++) { + if (ifindex != p->if_index) + continue; + if (!IN6_IS_ADDR_LINKLOCAL(&p->rtaddr.sin6_addr)) + continue; + dst.sin6_addr = p->rtaddr.sin6_addr; + dst.sin6_scope_id = linkid; + (void)sendpacket(probesock, &dst, ifindex, 1, NULL, 0); + } + free(buf); + + return (0); +} + +static int +rssend(uint32_t ifindex, uint32_t linkid, const void *data, size_t len) +{ + static int rssock = -1; + struct sockaddr_in6 dst; + ssize_t n; + + if (getsocket(&rssock, IPPROTO_ICMPV6) != 0) + return (-1); + + memset(&dst, 0, sizeof(dst)); + dst.sin6_family = AF_INET6; + dst.sin6_len = sizeof(dst); + dst.sin6_addr = (struct in6_addr)IN6ADDR_LINKLOCAL_ALLROUTERS_INIT; + dst.sin6_scope_id = linkid; + + n = sendpacket(rssock, &dst, ifindex, 255, data, len); + if (n < 0 || (size_t)n != len) + return (-1); + return (0); +} + +int +cap_probe_defrouters(cap_channel_t *cap, struct ifinfo *ifinfo) +{ +#ifdef WITH_CASPER + nvlist_t *nvl; + int error; + + nvl = nvlist_create(0); + nvlist_add_string(nvl, "cmd", "probe_defrouters"); + nvlist_add_number(nvl, "ifindex", ifinfo->sdl->sdl_index); + nvlist_add_number(nvl, "linkid", ifinfo->linkid); + + nvl = cap_xfer_nvlist(cap, nvl); + if (nvl == NULL) + return (errno); + error = (int)dnvlist_get_number(nvl, "error", 0); + nvlist_destroy(nvl); + errno = error; + return (error == 0 ? 0 : -1); +#else + (void)cap; + return (probe_defrouters(ifinfo->sdl->sdl_index, ifinfo->linkid)); +#endif +} + +int +cap_rssend(cap_channel_t *cap, struct ifinfo *ifinfo) +{ + int error; + +#ifdef WITH_CASPER + nvlist_t *nvl = nvlist_create(0); + nvlist_add_string(nvl, "cmd", "rssend"); + nvlist_add_number(nvl, "ifindex", ifinfo->sdl->sdl_index); + nvlist_add_number(nvl, "linkid", ifinfo->linkid); + nvlist_add_binary(nvl, "data", ifinfo->rs_data, ifinfo->rs_datalen); + + nvl = cap_xfer_nvlist(cap, nvl); + if (nvl == NULL) + return (errno); + error = (int)dnvlist_get_number(nvl, "error", 0); + nvlist_destroy(nvl); + errno = error; +#else + (void)cap; + error = rssend(ifinfo->sdl->sdl_index, ifinfo->linkid, ifinfo->rs_data, + ifinfo->rs_datalen); +#endif + + ifinfo->probes++; + if (error != 0 && (errno != ENETDOWN || dflag > 0)) { + error = errno; + warnmsg(LOG_ERR, __func__, "sendmsg on %s: %s", + ifinfo->ifname, strerror(errno)); + errno = error; + } + return (error == 0 ? 0 : -1); +} + +#ifdef WITH_CASPER +static int +sendmsg_command(const char *cmd, const nvlist_t *limits __unused, nvlist_t *nvlin, + nvlist_t *nvlout __unused) +{ + const void *data; + size_t len; + uint32_t ifindex, linkid; + int error; + + if (strcmp(cmd, "probe_defrouters") != 0 && + strcmp(cmd, "rssend") != 0) + return (EINVAL); + + ifindex = (uint32_t)nvlist_get_number(nvlin, "ifindex"); + linkid = (uint32_t)nvlist_get_number(nvlin, "linkid"); + if (strcmp(cmd, "probe_defrouters") == 0) { + error = probe_defrouters(ifindex, linkid); + } else { + data = nvlist_get_binary(nvlin, "data", &len); + error = rssend(ifindex, linkid, data, len); + } + if (error != 0) + return (errno); + return (0); +} + +CREATE_SERVICE("rtsold.sendmsg", NULL, sendmsg_command, 0); +#endif /* WITH_CASPER */ Modified: releng/12.2/usr.sbin/rtsold/dump.c ============================================================================== --- releng/12.2/usr.sbin/rtsold/dump.c Sat Sep 12 20:20:55 2020 (r365672) +++ releng/12.2/usr.sbin/rtsold/dump.c Sat Sep 12 21:50:25 2020 (r365673) @@ -34,6 +34,7 @@ */ #include +#include #include #include @@ -42,21 +43,20 @@ #include #include -#include -#include +#include +#include #include #include -#include +#include +#include #include "rtsold.h" -static FILE *fp; +static const char * const ifstatstr[] = + { "IDLE", "DELAY", "PROBE", "DOWN", "TENTATIVE" }; -static void dump_interface_status(void); -static const char * const ifstatstr[] = {"IDLE", "DELAY", "PROBE", "DOWN", "TENTATIVE"}; - -static void -dump_interface_status(void) +void +rtsold_dump(FILE *fp) { struct ifinfo *ifi; struct rainfo *rai; @@ -64,8 +64,14 @@ dump_interface_status(void) struct timespec now; char ntopbuf[INET6_ADDRSTRLEN]; - clock_gettime(CLOCK_MONOTONIC_FAST, &now); + if (fseek(fp, 0, SEEK_SET) != 0) { + warnmsg(LOG_ERR, __func__, "fseek(): %s", strerror(errno)); + return; + } + (void)ftruncate(fileno(fp), 0); + (void)clock_gettime(CLOCK_MONOTONIC_FAST, &now); + TAILQ_FOREACH(ifi, &ifinfo_head, ifi_next) { fprintf(fp, "Interface %s\n", ifi->ifname); fprintf(fp, " probe interval: "); @@ -78,6 +84,8 @@ dump_interface_status(void) } fprintf(fp, " interface status: %s\n", ifi->active > 0 ? "active" : "inactive"); + fprintf(fp, " managed config: %s\n", + ifi->managedconfig ? "on" : "off"); fprintf(fp, " other config: %s\n", ifi->otherconfig ? "on" : "off"); fprintf(fp, " rtsold status: %s\n", ifstatstr[ifi->state]); @@ -121,18 +129,28 @@ dump_interface_status(void) fprintf(fp, "\n"); } } + fflush(fp); } -void -rtsold_dump_file(const char *dumpfile) +FILE * +rtsold_init_dumpfile(const char *dumpfile) { + cap_rights_t rights; + FILE *fp; + if ((fp = fopen(dumpfile, "w")) == NULL) { - warnmsg(LOG_WARNING, __func__, "open a dump file(%s): %s", + warnmsg(LOG_WARNING, __func__, "opening a dump file(%s): %s", dumpfile, strerror(errno)); - return; + return (NULL); } - dump_interface_status(); - fclose(fp); + + cap_rights_init(&rights, CAP_FSTAT, CAP_FTRUNCATE, CAP_SEEK, CAP_WRITE); + if (caph_rights_limit(fileno(fp), &rights) != 0) { + warnmsg(LOG_WARNING, __func__, "caph_rights_limit(%s): %s", + dumpfile, strerror(errno)); + return (NULL); + } + return (fp); } const char * Modified: releng/12.2/usr.sbin/rtsold/if.c ============================================================================== --- releng/12.2/usr.sbin/rtsold/if.c Sat Sep 12 20:20:55 2020 (r365672) +++ releng/12.2/usr.sbin/rtsold/if.c Sat Sep 12 21:50:25 2020 (r365673) @@ -34,10 +34,11 @@ */ #include -#include -#include +#include #include #include +#include +#include #include #include @@ -51,6 +52,7 @@ #include #include +#include #include #include #include @@ -63,16 +65,28 @@ #include "rtsold.h" static int ifsock; - -static int get_llflag(const char *); static void get_rtaddrs(int, struct sockaddr *, struct sockaddr **); int ifinit(void) { - ifsock = rssock; + cap_rights_t rights; + int sock; - return(0); + sock = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6); + if (sock < 0) { + warnmsg(LOG_ERR, __func__, "socket(): %s", + strerror(errno)); + return (-1); + } + if (caph_rights_limit(sock, cap_rights_init(&rights, CAP_IOCTL)) < 0) { + warnmsg(LOG_ERR, __func__, "caph_rights_limit(): %s", + strerror(errno)); + (void)close(sock); + return (-1); + } + ifsock = sock; + return (0); } int @@ -150,10 +164,9 @@ interface_up(char *name) } close(s); - llflag = get_llflag(name); - if (llflag < 0) { + if (cap_llflags_get(capllflags, name, &llflag) != 0) { warnmsg(LOG_WARNING, __func__, - "get_llflag() failed, anyway I'll try"); + "cap_llflags_get() failed, anyway I'll try"); return (0); } @@ -273,8 +286,6 @@ lladdropt_fill(struct sockaddr_dl *sdl, struct nd_opt_ "unsupported link type(%d)", sdl->sdl_type); exit(1); } - - return; } struct sockaddr_dl * @@ -331,58 +342,6 @@ if_nametosdl(char *name) free(buf); return (ret_sdl); } - -/*------------------------------------------------------------*/ - -/* get ia6_flags for link-local addr on if. returns -1 on error. */ -static int -get_llflag(const char *name) -{ - struct ifaddrs *ifap, *ifa; - struct in6_ifreq ifr6; - struct sockaddr_in6 *sin6; - int s; - - if ((s = socket(PF_INET6, SOCK_DGRAM, 0)) < 0) { - warnmsg(LOG_ERR, __func__, "socket(SOCK_DGRAM): %s", - strerror(errno)); - exit(1); - } - if (getifaddrs(&ifap) != 0) { - warnmsg(LOG_ERR, __func__, "getifaddrs: %s", - strerror(errno)); - exit(1); - } - - for (ifa = ifap; ifa; ifa = ifa->ifa_next) { - if (strlen(ifa->ifa_name) != strlen(name) || - strncmp(ifa->ifa_name, name, strlen(name)) != 0) - continue; - if (ifa->ifa_addr->sa_family != AF_INET6) - continue; - sin6 = (struct sockaddr_in6 *)(void *)ifa->ifa_addr; - if (!IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) - continue; - - memset(&ifr6, 0, sizeof(ifr6)); - strlcpy(ifr6.ifr_name, name, sizeof(ifr6.ifr_name)); - memcpy(&ifr6.ifr_ifru.ifru_addr, sin6, sin6->sin6_len); - if (ioctl(s, SIOCGIFAFLAG_IN6, &ifr6) < 0) { - warnmsg(LOG_ERR, __func__, - "ioctl(SIOCGIFAFLAG_IN6): %s", strerror(errno)); - exit(1); - } - - freeifaddrs(ifap); - close(s); - return (ifr6.ifr_ifru.ifru_flags6); - } - - freeifaddrs(ifap); - close(s); - return (-1); -} - static void get_rtaddrs(int addrs, struct sockaddr *sa, struct sockaddr **rti_info) Modified: releng/12.2/usr.sbin/rtsold/rtsock.c ============================================================================== --- releng/12.2/usr.sbin/rtsold/rtsock.c Sat Sep 12 20:20:55 2020 (r365672) +++ releng/12.2/usr.sbin/rtsold/rtsock.c Sat Sep 12 21:50:25 2020 (r365673) @@ -33,10 +33,11 @@ */ #include +#include +#include #include -#include #include -#include +#include #include #include @@ -46,6 +47,7 @@ #include #include *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***