diff options
46 files changed, 546 insertions, 177 deletions
| diff --git a/contrib/llvm-project/clang/lib/Driver/ToolChains/FreeBSD.h b/contrib/llvm-project/clang/lib/Driver/ToolChains/FreeBSD.h index 7ab63905ed4f..7d090ba682b3 100644 --- a/contrib/llvm-project/clang/lib/Driver/ToolChains/FreeBSD.h +++ b/contrib/llvm-project/clang/lib/Driver/ToolChains/FreeBSD.h @@ -78,6 +78,11 @@ public:    void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs,                           llvm::opt::ArgStringList &CC1Args) const override; +  bool IsAArch64OutlineAtomicsDefault( +      const llvm::opt::ArgList &Args) const override { +    return true; +  } +    UnwindTableLevel    getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const override;    bool isPIEDefault(const llvm::opt::ArgList &Args) const override; diff --git a/lib/libc/gen/sysconf.3 b/lib/libc/gen/sysconf.3 index e38357b898a7..290ef0dc158c 100644 --- a/lib/libc/gen/sysconf.3 +++ b/lib/libc/gen/sysconf.3 @@ -25,7 +25,7 @@  .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF  .\" SUCH DAMAGE.  .\" -.Dd April 26, 2013 +.Dd August 30, 2025  .Dt SYSCONF 3  .Os  .Sh NAME @@ -77,7 +77,9 @@ The maximum number of supplemental groups.  .It Li _SC_NPROCESSORS_CONF  The number of processors configured.  .It Li _SC_NPROCESSORS_ONLN -The number of processors currently online. +The number of processors currently online, taking into account current jail +restrictions to report only the number of processors that are usable to the +process.  .It Li _SC_OPEN_MAX  One more than the maximum value the system may assign to a new file descriptor.  .It Li _SC_PAGESIZE diff --git a/lib/libc/gen/sysconf.c b/lib/libc/gen/sysconf.c index b5b732eed05d..87aedc07c110 100644 --- a/lib/libc/gen/sysconf.c +++ b/lib/libc/gen/sysconf.c @@ -72,6 +72,7 @@ long  sysconf(int name)  {  	struct rlimit rl; +	cpuset_t cpus;  	size_t len;  	int mib[2], sverrno, value;  	long lvalue, defaultresult; @@ -581,8 +582,21 @@ yesno:  		return (_POSIX_IPV6);  #endif -	case _SC_NPROCESSORS_CONF:  	case _SC_NPROCESSORS_ONLN: +		/* +		 * Consult our root set first, because our CPU availability +		 * may not match the total number of CPUs available on the +		 * system and we may have a non-uniform layout even within +		 * userland.  In particular, each jail has a root set that can +		 * be constrained by its parent and processes within the jail +		 * cannot widen beyond those constraints, so to those processes +		 * it makes sense to claim the more limited count. +		 */ +		if (cpuset_getaffinity(CPU_LEVEL_ROOT, CPU_WHICH_PID, -1, +		    sizeof(cpus), &cpus) == 0) +			return (CPU_COUNT(&cpus)); +		/* FALLTHROUGH */ +	case _SC_NPROCESSORS_CONF:  		if (_elf_aux_info(AT_NCPUS, &value, sizeof(value)) == 0)  			return ((long)value);  		mib[0] = CTL_HW; diff --git a/lib/libc/tests/sys/cpuset_test.c b/lib/libc/tests/sys/cpuset_test.c index 53d6a8215bbc..c8ad225fadfc 100644 --- a/lib/libc/tests/sys/cpuset_test.c +++ b/lib/libc/tests/sys/cpuset_test.c @@ -34,8 +34,10 @@  #include <sys/uio.h>  #include <sys/wait.h> +#include <assert.h>  #include <errno.h>  #include <stdio.h> +#include <stdlib.h>  #include <unistd.h>  #include <atf-c.h> @@ -107,6 +109,19 @@ skip_ltncpu(int ncpu, cpuset_t *mask)  		atf_tc_skip("Test requires %d or more cores.", ncpu);  } +static void +skip_ltncpu_root(int ncpu, cpuset_t *mask) +{ + +	CPU_ZERO(mask); +	ATF_REQUIRE_EQ(0, cpuset_getaffinity(CPU_LEVEL_ROOT, CPU_WHICH_PID, +	    -1, sizeof(*mask), mask)); +	if (CPU_COUNT(mask) < ncpu) { +		atf_tc_skip("Test requires cpuset root with %d or more cores.", +		    ncpu); +	} +} +  ATF_TC(newset);  ATF_TC_HEAD(newset, tc)  { @@ -234,9 +249,8 @@ ATF_TC_BODY(deadlk, tc)  }  static int -do_jail(int sock) +create_jail(void)  { -	struct jail_test_info info;  	struct iovec iov[2];  	char *name;  	int error; @@ -250,8 +264,22 @@ do_jail(int sock)  	iov[1].iov_base = name;  	iov[1].iov_len = strlen(name) + 1; -	if (jail_set(iov, 2, JAIL_CREATE | JAIL_ATTACH) < 0) +	error = jail_set(iov, 2, JAIL_CREATE | JAIL_ATTACH); +	free(name); +	if (error < 0)  		return (FAILURE_JAIL); +	return (0); +} + +static int +do_jail(int sock) +{ +	struct jail_test_info info; +	int error; + +	error = create_jail(); +	if (error != 0) +		return (error);  	/* Record parameters, kick them over, then make a swift exit. */  	CPU_ZERO(&info.jail_tidmask); @@ -641,6 +669,111 @@ ATF_TC_BODY(jail_attach_disjoint, tc)  	try_attach(jid, &smask);  } +struct nproc_info { +	long		nproc_init; +	long		nproc_final; +	long		nproc_global; +}; + +ATF_TC(jail_nproc); +ATF_TC_HEAD(jail_nproc, tc) +{ +	atf_tc_set_md_var(tc, "descr", +	    "Test that _SC_PROCESSORS_ONLN reflects jail cpuset constraints"); +} +ATF_TC_BODY(jail_nproc, tc) +{ +	cpuset_t jmask; +	struct nproc_info ninfo = { }; +	int sockpair[2]; +	cpusetid_t setid; +	ssize_t readsz; +	pid_t pid; +	int fcpu, error, pfd, sock; +	char okb = 0x7f, rcvb; + +	skip_ltncpu_root(2, &jmask); +	fcpu = CPU_FFS(&jmask) - 1; + +	/* +	 * Just adjusting our affinity should not affect the number of +	 * processors considered online- we want to be sure that it's only +	 * adjusted if our jail's root set is. +	 */ +	CPU_CLR(fcpu, &jmask); +	error = cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1, +	    sizeof(jmask), &jmask); +	ATF_REQUIRE_EQ(0, error); +	ATF_REQUIRE(sysconf(_SC_NPROCESSORS_ONLN) > CPU_COUNT(&jmask)); + +	ATF_REQUIRE_EQ(0, socketpair(PF_UNIX, SOCK_STREAM, 0, sockpair)); + +	/* We'll wait on the procdesc, too, so we can fail faster if it dies. */ +	ATF_REQUIRE((pid = pdfork(&pfd, 0)) != -1); + +	if (pid == 0) { +		/* First child sets up the jail. */ +		sock = sockpair[SP_CHILD]; +		close(sockpair[SP_PARENT]); + +		error = create_jail(); +		if (error != 0) +			_exit(error); + +		ninfo.nproc_init = sysconf(_SC_NPROCESSORS_ONLN); + +		/* Signal the parent that we're jailed. */ +		readsz = write(sock, &okb, sizeof(okb)); +		assert(readsz == sizeof(okb)); + +		/* Wait for parent to adjust our mask and signal OK. */ +		readsz = read(sock, &rcvb, sizeof(rcvb)); +		assert(readsz == sizeof(rcvb)); +		assert(rcvb == okb); + +		ninfo.nproc_final = sysconf(_SC_NPROCESSORS_ONLN); +		ninfo.nproc_global = sysconf(_SC_NPROCESSORS_CONF); +		readsz = write(sock, &ninfo, sizeof(ninfo)); +		assert(readsz == sizeof(ninfo)); + +		_exit(0); +	} + +	close(sockpair[SP_CHILD]); +	sock = sockpair[SP_PARENT]; + +	/* Wait for signal that they are jailed. */ +	readsz = read(sock, &rcvb, sizeof(rcvb)); +	assert(readsz == sizeof(rcvb)); +	assert(rcvb == okb); + +	/* Grab the cpuset id and adjust it. */ +	error = cpuset_getid(CPU_LEVEL_ROOT, CPU_WHICH_PID, pid, &setid); +	ATF_REQUIRE_EQ(0, error); +	error = cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_CPUSET, +	    setid, sizeof(jmask), &jmask); +	ATF_REQUIRE_EQ(0, error); + +	/* Signal OK to proceed. */ +	readsz = write(sock, &okb, sizeof(okb)); +	ATF_REQUIRE_EQ(sizeof(okb), readsz); + +	/* Grab our final nproc info. */ +	readsz = read(sock, &ninfo, sizeof(ninfo)); +	ATF_REQUIRE_EQ(sizeof(ninfo), readsz); + +	/* +	 * We set our own affinity to jmask, which is derived from *our* root +	 * set, at the beginning of the test.  The jail would inherit from this +	 * set, so we just re-use that mask here to confirm that +	 * _SC_NPROCESSORS_ONLN did actually drop in response to us limiting the +	 * jail, and that its _SC_NPROCESSORS_CONF did not. +	 */ +	ATF_REQUIRE_EQ(CPU_COUNT(&jmask) + 1, ninfo.nproc_init); +	ATF_REQUIRE_EQ(CPU_COUNT(&jmask) + 1, ninfo.nproc_global); +	ATF_REQUIRE_EQ(CPU_COUNT(&jmask), ninfo.nproc_final); +} +  ATF_TC(badparent);  ATF_TC_HEAD(badparent, tc)  { @@ -686,6 +819,7 @@ ATF_TP_ADD_TCS(tp)  	ATF_TP_ADD_TC(tp, jail_attach_prevbase);  	ATF_TP_ADD_TC(tp, jail_attach_plain);  	ATF_TP_ADD_TC(tp, jail_attach_disjoint); +	ATF_TP_ADD_TC(tp, jail_nproc);  	ATF_TP_ADD_TC(tp, badparent);  	return (atf_no_error());  } diff --git a/lib/libutil/login_class.c b/lib/libutil/login_class.c index c3c1b0ddda27..9478b4dc98ca 100644 --- a/lib/libutil/login_class.c +++ b/lib/libutil/login_class.c @@ -543,7 +543,7 @@ setusercontext(login_cap_t *lc, const struct passwd *pwd, uid_t uid, unsigned in      /* we need a passwd entry to set these */      if (pwd == NULL) -	flags &= ~(LOGIN_SETGROUP | LOGIN_SETLOGIN | LOGIN_SETMAC); +	flags &= ~(LOGIN_SETGROUP | LOGIN_SETLOGIN);      /* Set the process priority */      if (flags & LOGIN_SETPRIORITY) @@ -564,6 +564,27 @@ setusercontext(login_cap_t *lc, const struct passwd *pwd, uid_t uid, unsigned in  	}      } +    /* Set the sessions login */ +    if ((flags & LOGIN_SETLOGIN) && setlogin(pwd->pw_name) != 0) { +	syslog(LOG_ERR, "setlogin(%s): %m", pwd->pw_name); +	login_close(llc); +	return (-1); +    } + +    /* Inform the kernel about current login class */ +    if (lc != NULL && lc->lc_class != NULL && (flags & LOGIN_SETLOGINCLASS)) { +	error = setloginclass(lc->lc_class); +	if (error != 0) { +	    syslog(LOG_ERR, "setloginclass(%s): %m", lc->lc_class); +#ifdef notyet +	    login_close(llc); +	    return (-1); +#endif +	} +    } + +    setlogincontext(lc, pwd, flags); +      /* Set up the user's MAC label. */      if ((flags & LOGIN_SETMAC) && mac_is_present(NULL) == 1) {  	const char *label_string; @@ -572,8 +593,10 @@ setusercontext(login_cap_t *lc, const struct passwd *pwd, uid_t uid, unsigned in  	label_string = login_getcapstr(lc, "label", NULL, NULL);  	if (label_string != NULL) {  	    if (mac_from_text(&label, label_string) == -1) { -		syslog(LOG_ERR, "mac_from_text('%s') for %s: %m", -		    pwd->pw_name, label_string); +		syslog(LOG_ERR, "mac_from_text('%s') for %s %s: %m", +		    label_string, pwd != NULL ? "user" : "class", +		    pwd != NULL ? pwd->pw_name : lc->lc_class); +		login_close(llc);  		return (-1);  	    }  	    if (mac_set_proc(label) == -1) @@ -582,33 +605,15 @@ setusercontext(login_cap_t *lc, const struct passwd *pwd, uid_t uid, unsigned in  		error = 0;  	    mac_free(label);  	    if (error != 0) { -		syslog(LOG_ERR, "mac_set_proc('%s') for %s: %s", -		    label_string, pwd->pw_name, strerror(error)); +		syslog(LOG_ERR, "mac_set_proc('%s') for %s %s: %s", +		    label_string, pwd != NULL ? "user" : "class", +		    pwd != NULL ? pwd->pw_name : lc->lc_class, strerror(error)); +		login_close(llc);  		return (-1);  	    }  	}      } -    /* Set the sessions login */ -    if ((flags & LOGIN_SETLOGIN) && setlogin(pwd->pw_name) != 0) { -	syslog(LOG_ERR, "setlogin(%s): %m", pwd->pw_name); -	login_close(llc); -	return (-1); -    } - -    /* Inform the kernel about current login class */ -    if (lc != NULL && lc->lc_class != NULL && (flags & LOGIN_SETLOGINCLASS)) { -	error = setloginclass(lc->lc_class); -	if (error != 0) { -	    syslog(LOG_ERR, "setloginclass(%s): %m", lc->lc_class); -#ifdef notyet -	    login_close(llc); -	    return (-1); -#endif -	} -    } - -    setlogincontext(lc, pwd, flags);      login_close(llc);      /* This needs to be done after anything that needs root privs */ diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index 3d2632c1cf74..02d6c9c84a32 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -2618,6 +2618,8 @@ pfctl_apply_limit(struct pfctl *pf, const char *opt, unsigned int limit)  int  pfctl_load_limit(struct pfctl *pf, unsigned int index, unsigned int limit)  { +	static int restore_limit_handler_armed = 0; +  	if (pfctl_set_limit(pf->h, index, limit)) {  		if (errno == EBUSY)  			warnx("Current pool size exceeds requested %s limit %u", @@ -2626,6 +2628,9 @@ pfctl_load_limit(struct pfctl *pf, unsigned int index, unsigned int limit)  			warnx("Cannot set %s limit to %u",  			    pf_limits[index].name, limit);  		return (1); +	} else if (restore_limit_handler_armed == 0) { +		atexit(pfctl_restore_limits); +		restore_limit_handler_armed = 1;  	}  	return (0);  } @@ -3474,7 +3479,6 @@ main(int argc, char *argv[])  	if ((opts & PF_OPT_NOACTION) == 0) {  		pfctl_read_limits(pfh); -		atexit(pfctl_restore_limits);  	}  	if (opts & PF_OPT_DISABLE) diff --git a/share/examples/mdoc/example.4 b/share/examples/mdoc/example.4 index e627f81af530..6983fb75fada 100644 --- a/share/examples/mdoc/example.4 +++ b/share/examples/mdoc/example.4 @@ -26,6 +26,9 @@ module at boot time, place the following line in  .Bd -literal -offset indent  example_load="YES"  .Ed +.Sh DEPRECATION NOTICE +This driver is scheduled for removal prior to the release of +.Fx 13.0 .  .Sh DESCRIPTION  This is an example device driver manual page for the  .Nm diff --git a/share/man/man5/style.Makefile.5 b/share/man/man5/style.Makefile.5 index fe8754924575..9a2f1b069d99 100644 --- a/share/man/man5/style.Makefile.5 +++ b/share/man/man5/style.Makefile.5 @@ -1,7 +1,7 @@  .\"  .\" SPDX-License-Identifier: BSD-3-Clause  .\" -.\" Copyright (c) 2002-2003, 2023 David O'Brien <obrien@FreeBSD.org> +.\" Copyright (c) 2002-2003, 2023, 2025 David O'Brien <deo@NUXI.org>  .\" All rights reserved.  .\"  .\" Redistribution and use in source and binary forms, with or without @@ -28,7 +28,7 @@  .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF  .\" SUCH DAMAGE.  .\" -.Dd July 17, 2023 +.Dd October 29, 2025  .Dt STYLE.MAKEFILE 5  .Os  .Sh NAME @@ -179,6 +179,21 @@ settings between the  and  .Fl I Ns 's.  .It +Lists that span more than one line should be formatted as follows: +.Bd -literal -offset indent +SRCS+=<SP>\\ +<TAB>main.c<SP>\\ +<TAB>trace.c<SP>\\ +<TAB>zoo.c \\ +\& +.Ed +Specifically, the last item in the list should have a trailing '\\'. +This is to avoid causing a "false diff" or "false blame" when +a new item is appended at the end. +In general the list should be English language alphabetized. +A list of libraries or header inclusion paths are notable exceptions +if needed for proper building. +.It  Do not use GCCisms (such as  .Fl g  and @@ -233,9 +248,6 @@ For variables that are only checked with  .Fn defined ,  do not provide any fake value.  .El -.Pp -The desire to express a logical grouping often means not obeying some of the -above.  .Sh EXAMPLES  The simplest program  .Pa Makefile @@ -270,5 +282,7 @@ manual page and first appeared in  .An David O'Brien Aq deo@NUXI.org  .Sh BUGS  There are few hard and fast style rules here. +The desire to express a logical grouping sometimes means not obeying some of the +above.  The style of many things is too dependent on the context of the whole makefile,  or the lines surrounding it. diff --git a/sys/arm/broadcom/bcm2835/bcm2835_audio.c b/sys/arm/broadcom/bcm2835/bcm2835_audio.c index 13f309dd3f11..2df6ac76124f 100644 --- a/sys/arm/broadcom/bcm2835/bcm2835_audio.c +++ b/sys/arm/broadcom/bcm2835/bcm2835_audio.c @@ -132,6 +132,7 @@ struct bcm2835_audio_info {  	uint32_t flags_pending; +	int verbose_trace;  	/* Worker thread state */  	int worker_state;  }; @@ -140,6 +141,29 @@ struct bcm2835_audio_info {  #define BCM2835_AUDIO_LOCKED(sc)	mtx_assert(&(sc)->lock, MA_OWNED)  #define BCM2835_AUDIO_UNLOCK(sc)	mtx_unlock(&(sc)->lock) +#define BCM2835_LOG_ERROR(sc,...)				\ +	do {							\ +		device_printf((sc)->dev, __VA_ARGS__);		\ +	} while(0) + +#define BCM2835_LOG_INFO(sc,...)				\ +	do {							\ +		if (sc->verbose_trace > 0)			\ +			device_printf((sc)->dev, __VA_ARGS__);	\ +	} while(0) + +#define BCM2835_LOG_WARN(sc,...) \ +	do {							\ +		if (sc->verbose_trace > 1)			\ +			device_printf((sc)->dev, __VA_ARGS__);	\ +	} while(0) + +#define BCM2835_LOG_TRACE(sc,...)				\ +	do {							\ +		if(sc->verbose_trace > 2)			\ +			device_printf((sc)->dev, __VA_ARGS__);	\ +	} while(0) +  static const char *  dest_description(uint32_t dest)  { @@ -236,8 +260,9 @@ bcm2835_audio_callback(void *param, const VCHI_CALLBACK_REASON_T reason, void *m  					device_printf(sc->dev, "available_space == %d, count = %d, perr=%d\n",  					    ch->available_space, count, perr);  					device_printf(sc->dev, -					    "retrieved_samples = %lld, submitted_samples = %lld\n", -					    ch->retrieved_samples, ch->submitted_samples); +					    "retrieved_samples = %ju, submitted_samples = %ju\n", +					    (uintmax_t)ch->retrieved_samples, +					    (uintmax_t)ch->submitted_samples);  				}  				ch->available_space += count;  				ch->retrieved_samples += count; @@ -247,7 +272,8 @@ bcm2835_audio_callback(void *param, const VCHI_CALLBACK_REASON_T reason, void *m  		}  		BCM2835_AUDIO_UNLOCK(sc);  	} else -		printf("%s: unknown m.type: %d\n", __func__, m.type); +		BCM2835_LOG_WARN(sc, "%s: unknown m.type: %d\n", __func__, +		    m.type);  }  /* VCHIQ stuff */ @@ -259,13 +285,13 @@ bcm2835_audio_init(struct bcm2835_audio_info *sc)  	/* Initialize and create a VCHI connection */  	status = vchi_initialise(&sc->vchi_instance);  	if (status != 0) { -		printf("vchi_initialise failed: %d\n", status); +		BCM2835_LOG_ERROR(sc, "vchi_initialise failed: %d\n", status);  		return;  	}  	status = vchi_connect(NULL, 0, sc->vchi_instance);  	if (status != 0) { -		printf("vchi_connect failed: %d\n", status); +		BCM2835_LOG_ERROR(sc, "vchi_connect failed: %d\n", status);  		return;  	} @@ -297,7 +323,8 @@ bcm2835_audio_release(struct bcm2835_audio_info *sc)  	if (sc->vchi_handle != VCHIQ_SERVICE_HANDLE_INVALID) {  		success = vchi_service_close(sc->vchi_handle);  		if (success != 0) -			printf("vchi_service_close failed: %d\n", success); +			BCM2835_LOG_ERROR(sc, "vchi_service_close failed: %d\n", +			    success);  		vchi_service_release(sc->vchi_handle);  		sc->vchi_handle = VCHIQ_SERVICE_HANDLE_INVALID;  	} @@ -327,7 +354,9 @@ bcm2835_audio_start(struct bcm2835_audio_chinfo *ch)  		    &m, sizeof m, VCHI_FLAGS_BLOCK_UNTIL_QUEUED, NULL);  		if (ret != 0) -			printf("%s: vchi_msg_queue failed (err %d)\n", __func__, ret); +			BCM2835_LOG_ERROR(sc, +			    "%s: vchi_msg_queue failed (err %d)\n", __func__, +			    ret);  	}  } @@ -346,7 +375,9 @@ bcm2835_audio_stop(struct bcm2835_audio_chinfo *ch)  		    &m, sizeof m, VCHI_FLAGS_BLOCK_UNTIL_QUEUED, NULL);  		if (ret != 0) -			printf("%s: vchi_msg_queue failed (err %d)\n", __func__, ret); +			BCM2835_LOG_ERROR(sc, +			    "%s: vchi_msg_queue failed (err %d)\n", __func__, +			    ret);  	}  } @@ -362,7 +393,9 @@ bcm2835_audio_open(struct bcm2835_audio_info *sc)  		    &m, sizeof m, VCHI_FLAGS_BLOCK_UNTIL_QUEUED, NULL);  		if (ret != 0) -			printf("%s: vchi_msg_queue failed (err %d)\n", __func__, ret); +			BCM2835_LOG_ERROR(sc, +			    "%s: vchi_msg_queue failed (err %d)\n", __func__, +			    ret);  	}  } @@ -384,7 +417,9 @@ bcm2835_audio_update_controls(struct bcm2835_audio_info *sc, uint32_t volume, ui  		    &m, sizeof m, VCHI_FLAGS_BLOCK_UNTIL_QUEUED, NULL);  		if (ret != 0) -			printf("%s: vchi_msg_queue failed (err %d)\n", __func__, ret); +			BCM2835_LOG_ERROR(sc, +			    "%s: vchi_msg_queue failed (err %d)\n", __func__, +			    ret);  	}  } @@ -404,7 +439,9 @@ bcm2835_audio_update_params(struct bcm2835_audio_info *sc, uint32_t fmt, uint32_  		    &m, sizeof m, VCHI_FLAGS_BLOCK_UNTIL_QUEUED, NULL);  		if (ret != 0) -			printf("%s: vchi_msg_queue failed (err %d)\n", __func__, ret); +			BCM2835_LOG_ERROR(sc, +			    "%s: vchi_msg_queue failed (err %d)\n", __func__, +			    ret);  	}  } @@ -452,14 +489,15 @@ bcm2835_audio_write_samples(struct bcm2835_audio_chinfo *ch, void *buf, uint32_t  	    &m, sizeof m, VCHI_FLAGS_BLOCK_UNTIL_QUEUED, NULL);  	if (ret != 0) -		printf("%s: vchi_msg_queue failed (err %d)\n", __func__, ret); +		BCM2835_LOG_ERROR(sc, "%s: vchi_msg_queue failed (err %d)\n", +		    __func__, ret);  	while (count > 0) {  		int bytes = MIN((int)m.u.write.max_packet, (int)count);  		ret = vchi_msg_queue(sc->vchi_handle,  		    buf, bytes, VCHI_FLAGS_BLOCK_UNTIL_QUEUED, NULL);  		if (ret != 0) -			printf("%s: vchi_msg_queue failed: %d\n", +			BCM2835_LOG_ERROR(sc, "%s: vchi_msg_queue failed: %d\n",  			    __func__, ret);  		buf = (char *)buf + bytes;  		count -= bytes; @@ -577,7 +615,8 @@ bcm2835_audio_create_worker(struct bcm2835_audio_info *sc)  	sc->worker_state = WORKER_RUNNING;  	if (kproc_create(bcm2835_audio_worker, (void*)sc, &newp, 0, 0,  	    "bcm2835_audio_worker") != 0) { -		printf("failed to create bcm2835_audio_worker\n"); +		BCM2835_LOG_ERROR(sc, +		    "failed to create bcm2835_audio_worker\n");  	}  } @@ -830,6 +869,9 @@ vchi_audio_sysctl_init(struct bcm2835_audio_info *sc)  	SYSCTL_ADD_INT(ctx, tree, OID_AUTO, "starved",  			CTLFLAG_RD, &sc->pch.starved,  			sc->pch.starved, "number of starved conditions"); +	SYSCTL_ADD_INT(ctx, tree, OID_AUTO, "trace", +			CTLFLAG_RW, &sc->verbose_trace, +			sc->verbose_trace, "enable tracing of transfers");  }  static void @@ -861,6 +903,7 @@ bcm2835_audio_delayed_init(void *xsc)  	bcm2835_audio_open(sc);  	sc->volume = 75;  	sc->dest = DEST_AUTO; +	sc->verbose_trace = 0;      	if (mixer_init(sc->dev, &bcmmixer_class, sc)) {  		device_printf(sc->dev, "mixer_init failed\n"); diff --git a/sys/arm/mv/mv_cp110_icu.c b/sys/arm/mv/mv_cp110_icu.c index 25ec19bee575..d30f337f56fc 100644 --- a/sys/arm/mv/mv_cp110_icu.c +++ b/sys/arm/mv/mv_cp110_icu.c @@ -257,7 +257,7 @@ mv_cp110_icu_init(struct mv_cp110_icu_softc *sc, uint64_t addr)  		WR4(sc, ICU_SETSPI_SEI_AH, (addr >> 32) & UINT32_MAX);  		break;  	default: -		panic("Unkown ICU type."); +		panic("Unknown ICU type.");  	}  	sc->initialized = true; diff --git a/sys/arm/ti/cpsw/if_cpsw.c b/sys/arm/ti/cpsw/if_cpsw.c index dc3d8b1f9023..e2cc9ee0d7b2 100644 --- a/sys/arm/ti/cpsw/if_cpsw.c +++ b/sys/arm/ti/cpsw/if_cpsw.c @@ -1646,7 +1646,7 @@ cpsw_rx_dequeue(struct cpsw_softc *sc)  		port = (bd.flags & CPDMA_BD_PORT_MASK) - 1;  		KASSERT(port >= 0 && port <= 1, -		    ("patcket received with invalid port: %d", port)); +		    ("packet received with invalid port: %d", port));  		psc = device_get_softc(sc->port[port].dev);  		/* Set up mbuf */ diff --git a/sys/arm64/nvidia/tegra210/max77620_regulators.c b/sys/arm64/nvidia/tegra210/max77620_regulators.c index af1a5af20ec3..d52aeaef1287 100644 --- a/sys/arm64/nvidia/tegra210/max77620_regulators.c +++ b/sys/arm64/nvidia/tegra210/max77620_regulators.c @@ -364,7 +364,7 @@ max77620_get_sel(struct max77620_reg_sc *sc, uint8_t *sel)  	rv = RD1(sc->base_sc, sc->def->volt_reg, sel);  	if (rv != 0) { -		printf("%s: cannot read volatge selector: %d\n", +		printf("%s: cannot read voltage selector: %d\n",  		    regnode_get_name(sc->regnode), rv);  		return (rv);  	} @@ -384,7 +384,7 @@ max77620_set_sel(struct max77620_reg_sc *sc, uint8_t sel)  	rv = RM1(sc->base_sc, sc->def->volt_reg,  	    sc->def->volt_vsel_mask, sel);  	if (rv != 0) { -		printf("%s: cannot set volatge selector: %d\n", +		printf("%s: cannot set voltage selector: %d\n",  		    regnode_get_name(sc->regnode), rv);  		return (rv);  	} diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c index e110281f7c85..442ef1d30542 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -2123,7 +2123,7 @@ ctl_remove_initiator(struct ctl_port *port, int iid)  	mtx_assert(&softc->ctl_lock, MA_NOTOWNED);  	if (iid > CTL_MAX_INIT_PER_PORT) { -		printf("%s: initiator ID %u > maximun %u!\n", +		printf("%s: initiator ID %u > maximum %u!\n",  		       __func__, iid, CTL_MAX_INIT_PER_PORT);  		return (-1);  	} diff --git a/sys/cam/scsi/scsi_enc.c b/sys/cam/scsi/scsi_enc.c index 9705a0b890b4..65df32ead371 100644 --- a/sys/cam/scsi/scsi_enc.c +++ b/sys/cam/scsi/scsi_enc.c @@ -732,7 +732,7 @@ enc_update_request(enc_softc_t *enc, uint32_t action)  {  	if ((enc->pending_actions & (0x1 << action)) == 0) {  		enc->pending_actions |= (0x1 << action); -		ENC_DLOG(enc, "%s: queing requested action %d\n", +		ENC_DLOG(enc, "%s: queueing requested action %d\n",  		    __func__, action);  		if (enc->current_action == ENC_UPDATE_NONE)  			wakeup(enc->enc_daemon); diff --git a/sys/cam/scsi/scsi_enc_ses.c b/sys/cam/scsi/scsi_enc_ses.c index 3a362eaf11a4..838eecf78ad6 100644 --- a/sys/cam/scsi/scsi_enc_ses.c +++ b/sys/cam/scsi/scsi_enc_ses.c @@ -1623,7 +1623,7 @@ ses_process_status(enc_softc_t *enc, struct enc_fsm_state *state,  	} else {  		if (cur_stat <= last_stat)  			ENC_VLOG(enc, "Status page, exhausted objects before " -				"exhausing page\n"); +				"exhausting page\n");  		enc_update_request(enc, SES_PUBLISH_CACHE);  		err = 0;  	} diff --git a/sys/cddl/dev/fbt/aarch64/fbt_isa.c b/sys/cddl/dev/fbt/aarch64/fbt_isa.c index ffe2f37a6d16..6c789530442d 100644 --- a/sys/cddl/dev/fbt/aarch64/fbt_isa.c +++ b/sys/cddl/dev/fbt/aarch64/fbt_isa.c @@ -104,7 +104,7 @@ fbt_provide_module_function(linker_file_t lf, int symindx,  	 */  	 if (strcmp(name, "handle_el1h_sync") == 0 ||  	    strcmp(name, "do_el1h_sync") == 0) -		return (1); +		return (0);  	instr = (uint32_t *)(symval->value);  	limit = (uint32_t *)(symval->value + symval->size); diff --git a/sys/compat/linuxkpi/common/include/linux/pm.h b/sys/compat/linuxkpi/common/include/linux/pm.h index c8d943027909..932697e0eda8 100644 --- a/sys/compat/linuxkpi/common/include/linux/pm.h +++ b/sys/compat/linuxkpi/common/include/linux/pm.h @@ -97,4 +97,18 @@ pm_wakeup_event(struct device *dev __unused, unsigned int x __unused)  	pr_debug("%s: TODO\n", __func__);  } +/* + * We do not need to specify anything here as a VT switch always happens on + * suspend/resume. + */ +static inline void +pm_vt_switch_required(struct device *dev __unused, bool required __unused) +{ +} + +static inline void +pm_vt_switch_unregister(struct device *dev __unused) +{ +} +  #endif	/* _LINUXKPI_LINUX_PM_H */ diff --git a/sys/compat/linuxkpi/common/src/linux_page.c b/sys/compat/linuxkpi/common/src/linux_page.c index 628af17df853..9cc981b2ba43 100644 --- a/sys/compat/linuxkpi/common/src/linux_page.c +++ b/sys/compat/linuxkpi/common/src/linux_page.c @@ -345,6 +345,10 @@ retry:  	page = vm_page_grab_iter(vm_obj, pindex, VM_ALLOC_NOCREAT, &pages);  	if (page == NULL) {  		page = PHYS_TO_VM_PAGE(IDX_TO_OFF(pfn)); +		if (page == NULL) { +			pctrie_iter_reset(&pages); +			return (VM_FAULT_SIGBUS); +		}  		if (!vm_page_busy_acquire(page, VM_ALLOC_WAITFAIL)) {  			pctrie_iter_reset(&pages);  			goto retry; diff --git a/sys/contrib/vchiq/interface/vchiq_arm/vchiq_2835_arm.c b/sys/contrib/vchiq/interface/vchiq_arm/vchiq_2835_arm.c index 0150ce72f0a4..f4aee12dec53 100644 --- a/sys/contrib/vchiq/interface/vchiq_arm/vchiq_2835_arm.c +++ b/sys/contrib/vchiq/interface/vchiq_arm/vchiq_2835_arm.c @@ -204,8 +204,8 @@ vchiq_platform_init(VCHIQ_STATE_T *state)  	bcm_mbox_write(BCM2835_MBOX_CHAN_VCHIQ, (unsigned int)g_slot_phys);  	vchiq_log_info(vchiq_arm_log_level, -		"vchiq_init - done (slots %x, phys %x)", -		(unsigned int)vchiq_slot_zero, g_slot_phys); +		"vchiq_init - done (slots %zx, phys %zx)", +		(size_t)vchiq_slot_zero, g_slot_phys);     vchiq_call_connected_callbacks(); @@ -451,10 +451,7 @@ create_pagelist(char __user *buf, size_t count, unsigned short type,  	}  	vchiq_log_trace(vchiq_arm_log_level, -		"create_pagelist - %x (%d bytes @%p)", (unsigned int)pagelist, count, buf); - -	if (!pagelist) -		return -ENOMEM; +		"create_pagelist - %zx (%zu bytes @%p)", (size_t)pagelist, count, buf);  	addrs = pagelist->addrs;  	pages = (vm_page_t*)(addrs + num_pages); @@ -549,7 +546,7 @@ free_pagelist(BULKINFO_T *bi, int actual)  	pagelist = bi->pagelist;  	vchiq_log_trace(vchiq_arm_log_level, -		"free_pagelist - %x, %d (%lu bytes @%p)", (unsigned int)pagelist, actual, pagelist->length, bi->buf); +		"free_pagelist - %zx, %d (%u bytes @%p)", (size_t)pagelist, actual, pagelist->length, bi->buf);  	num_pages =  		(pagelist->length + pagelist->offset + PAGE_SIZE - 1) / diff --git a/sys/contrib/vchiq/interface/vchiq_arm/vchiq_arm.c b/sys/contrib/vchiq/interface/vchiq_arm/vchiq_arm.c index 763cd9ce9417..e25c4d738922 100644 --- a/sys/contrib/vchiq/interface/vchiq_arm/vchiq_arm.c +++ b/sys/contrib/vchiq/interface/vchiq_arm/vchiq_arm.c @@ -442,8 +442,8 @@ vchiq_ioctl(struct cdev *cdev, u_long cmd, caddr_t arg, int fflag,  #define	_IOC_TYPE(x)	IOCGROUP(x)  	vchiq_log_trace(vchiq_arm_log_level, -		 "vchiq_ioctl - instance %x, cmd %s, arg %p", -		(unsigned int)instance, +		 "vchiq_ioctl - instance %zx, cmd %s, arg %p", +		(size_t)instance,  		((_IOC_TYPE(cmd) == VCHIQ_IOC_MAGIC) &&  		(_IOC_NR(cmd) <= VCHIQ_IOC_MAX)) ?  		ioctl_names[_IOC_NR(cmd)] : "<invalid>", arg); @@ -745,8 +745,8 @@ vchiq_ioctl(struct cdev *cdev, u_long cmd, caddr_t arg, int fflag,  				break;  			}  			vchiq_log_info(vchiq_arm_log_level, -				"found bulk_waiter %x for pid %d", -				(unsigned int)waiter, current->p_pid); +				"found bulk_waiter %zx for pid %d", +				(size_t)waiter, current->p_pid);  			args.userdata = &waiter->bulk_waiter;  		}  		status = vchiq_bulk_transfer @@ -776,8 +776,8 @@ vchiq_ioctl(struct cdev *cdev, u_long cmd, caddr_t arg, int fflag,  			list_add(&waiter->list, &instance->bulk_waiter_list);  			lmutex_unlock(&instance->bulk_waiter_list_mutex);  			vchiq_log_info(vchiq_arm_log_level, -				"saved bulk_waiter %x for pid %d", -				(unsigned int)waiter, current->p_pid); +				"saved bulk_waiter %zx for pid %d", +				(size_t)waiter, current->p_pid);  			memcpy((void *)  				&(((VCHIQ_QUEUE_BULK_TRANSFER_T *) @@ -860,9 +860,9 @@ vchiq_ioctl(struct cdev *cdev, u_long cmd, caddr_t arg, int fflag,  					if (args.msgbufsize < msglen) {  						vchiq_log_error(  							vchiq_arm_log_level, -							"header %x: msgbufsize" +							"header %zx: msgbufsize"  							" %x < msglen %x", -							(unsigned int)header, +							(size_t)header,  							args.msgbufsize,  							msglen);  						WARN(1, "invalid message " @@ -1031,8 +1031,8 @@ vchiq_ioctl(struct cdev *cdev, u_long cmd, caddr_t arg, int fflag,  				ret = -EFAULT;  		} else {  			vchiq_log_error(vchiq_arm_log_level, -				"header %x: bufsize %x < size %x", -				(unsigned int)header, args.bufsize, +				"header %zx: bufsize %x < size %x", +				(size_t)header, args.bufsize,  				header->size);  			WARN(1, "invalid size\n");  			ret = -EMSGSIZE; @@ -1435,9 +1435,9 @@ vchiq_dump_platform_instances(void *dump_context)  			instance = service->instance;  			if (instance && !instance->mark) {  				len = snprintf(buf, sizeof(buf), -					"Instance %x: pid %d,%s completions " +					"Instance %zx: pid %d,%s completions "  						"%d/%d", -					(unsigned int)instance, instance->pid, +					(size_t)instance, instance->pid,  					instance->connected ? " connected, " :  						"",  					instance->completion_insert - @@ -1465,8 +1465,8 @@ vchiq_dump_platform_service_state(void *dump_context, VCHIQ_SERVICE_T *service)  	char buf[80];  	int len; -	len = snprintf(buf, sizeof(buf), "  instance %x", -		(unsigned int)service->instance); +	len = snprintf(buf, sizeof(buf), "  instance %zx", +		(size_t)service->instance);  	if ((service->base.callback == service_callback) &&  		user_service->is_vchi) { diff --git a/sys/dev/acpica/acpi_pcib_acpi.c b/sys/dev/acpica/acpi_pcib_acpi.c index 3913ec612f79..2fadd6cd32ee 100644 --- a/sys/dev/acpica/acpi_pcib_acpi.c +++ b/sys/dev/acpica/acpi_pcib_acpi.c @@ -179,7 +179,7 @@ acpi_pcib_producer_handler(ACPI_RESOURCE *res, void *context)  	switch (res->Type) {  	case ACPI_RESOURCE_TYPE_START_DEPENDENT:  	case ACPI_RESOURCE_TYPE_END_DEPENDENT: -		panic("host bridge has depenedent resources"); +		panic("host bridge has dependent resources");  	case ACPI_RESOURCE_TYPE_ADDRESS16:  	case ACPI_RESOURCE_TYPE_ADDRESS32:  	case ACPI_RESOURCE_TYPE_ADDRESS64: diff --git a/sys/dev/aic7xxx/aic79xx.c b/sys/dev/aic7xxx/aic79xx.c index cee45fa5cc8a..d25f5de282d0 100644 --- a/sys/dev/aic7xxx/aic79xx.c +++ b/sys/dev/aic7xxx/aic79xx.c @@ -2015,7 +2015,7 @@ ahd_handle_lqiphase_error(struct ahd_softc *ahd, u_int lqistat1)  		ahd_outb(ahd, CLRINT, CLRSCSIINT);  		ahd_unpause(ahd);  	} else { -		printf("Reseting Channel for LQI Phase error\n"); +		printf("Resetting Channel for LQI Phase error\n");  		AHD_CORRECTABLE_ERROR(ahd);  		ahd_dump_card_state(ahd);  		ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE); @@ -8179,7 +8179,7 @@ ahd_handle_scsi_status(struct ahd_softc *ahd, struct scb *scb)  					AHD_UNCORRECTABLE_ERROR(ahd);  					break;  				case SIU_PFC_TMF_NOT_SUPPORTED: -					printf("TMF not supportd\n"); +					printf("TMF not supported\n");  					AHD_UNCORRECTABLE_ERROR(ahd);  					break;  				case SIU_PFC_TMF_FAILED: @@ -8313,7 +8313,7 @@ ahd_handle_scsi_status(struct ahd_softc *ahd, struct scb *scb)  		break;  	}  	case SCSI_STATUS_OK: -		printf("%s: Interrupted for staus of 0???\n", +		printf("%s: Interrupted for status of 0???\n",  		       ahd_name(ahd));  		/* FALLTHROUGH */  	default: diff --git a/sys/dev/aic7xxx/aic7xxx.c b/sys/dev/aic7xxx/aic7xxx.c index 18f68b806948..ce7f8a062b49 100644 --- a/sys/dev/aic7xxx/aic7xxx.c +++ b/sys/dev/aic7xxx/aic7xxx.c @@ -78,7 +78,7 @@ struct ahc_hard_error_entry {  static struct ahc_hard_error_entry ahc_hard_errors[] = {  	{ ILLHADDR,	"Illegal Host Access" }, -	{ ILLSADDR,	"Illegal Sequencer Address referrenced" }, +	{ ILLSADDR,	"Illegal Sequencer Address referenced" },  	{ ILLOPCODE,	"Illegal Opcode in sequencer program" },  	{ SQPARERR,	"Sequencer Parity Error" },  	{ DPARERR,	"Data-path Parity Error" }, @@ -476,7 +476,7 @@ ahc_handle_seqint(struct ahc_softc *ahc, u_int intstat)  		aic_set_scsi_status(scb, hscb->shared_data.status.scsi_status);  		switch (hscb->shared_data.status.scsi_status) {  		case SCSI_STATUS_OK: -			printf("%s: Interrupted for staus of 0???\n", +			printf("%s: Interrupted for status of 0???\n",  			       ahc_name(ahc));  			break;  		case SCSI_STATUS_CMD_TERMINATED: diff --git a/sys/dev/ale/if_ale.c b/sys/dev/ale/if_ale.c index fa2306f1525e..09e0820d2c74 100644 --- a/sys/dev/ale/if_ale.c +++ b/sys/dev/ale/if_ale.c @@ -813,7 +813,7 @@ ale_sysctl_node(struct ale_softc *sc)  	/* Misc statistics. */  	ALE_SYSCTL_STAT_ADD32(ctx, child, "reset_brk_seq",  	    &stats->reset_brk_seq, -	    "Controller resets due to broken Rx sequnce number"); +	    "Controller resets due to broken Rx sequence number");  	tree = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "stats",  	    CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "ATE statistics"); diff --git a/sys/dev/gpio/acpi_gpiobus.c b/sys/dev/gpio/acpi_gpiobus.c index 0d2455cab399..0c31f4fec16d 100644 --- a/sys/dev/gpio/acpi_gpiobus.c +++ b/sys/dev/gpio/acpi_gpiobus.c @@ -304,6 +304,12 @@ acpi_gpiobus_attach_aei(struct acpi_gpiobus_softc *sc, ACPI_HANDLE handle)  		devi->gpiobus.pins[i] = pins[i + 1];  	free(pins, M_DEVBUF); +	status = AcpiAttachData(aei_handle, acpi_fake_objhandler, child); +	if (ACPI_FAILURE(status)) { +		printf("WARNING: Unable to attach object data to %s - %s\n", +		    acpi_name(aei_handle), AcpiFormatException(status)); +	} +  	bus_attach_children(sc->super_sc.sc_busdev);  } @@ -427,6 +433,16 @@ acpi_gpiobus_child_location(device_t bus, device_t child, struct sbuf *sb)  	return (0);  } +static void +acpi_gpiobus_child_deleted(device_t bus, device_t child) +{ +	struct acpi_gpiobus_ivar *devi = device_get_ivars(child); + +	if (acpi_get_device(devi->handle) == child) +		AcpiDetachData(devi->handle, acpi_fake_objhandler); +	gpiobus_child_deleted(bus, child); +} +  static device_method_t acpi_gpiobus_methods[] = {  	/* Device interface */  	DEVMETHOD(device_probe,		acpi_gpiobus_probe), @@ -437,6 +453,7 @@ static device_method_t acpi_gpiobus_methods[] = {  	DEVMETHOD(bus_read_ivar,	acpi_gpiobus_read_ivar),  	DEVMETHOD(bus_add_child,	acpi_gpiobus_add_child),  	DEVMETHOD(bus_child_location,	acpi_gpiobus_child_location), +	DEVMETHOD(bus_child_deleted,	acpi_gpiobus_child_deleted),  	DEVMETHOD_END  }; diff --git a/sys/dev/gpio/gpiobus.c b/sys/dev/gpio/gpiobus.c index 698b5e5fdd01..596e468d35f3 100644 --- a/sys/dev/gpio/gpiobus.c +++ b/sys/dev/gpio/gpiobus.c @@ -618,7 +618,7 @@ gpiobus_detach(device_t dev)  	    ("gpiobus mutex not initialized"));  	GPIOBUS_LOCK_DESTROY(sc); -	if ((err = bus_detach_children(dev)) != 0) +	if ((err = bus_generic_detach(dev)) != 0)  		return (err);  	rman_fini(&sc->sc_intr_rman); @@ -734,7 +734,7 @@ gpiobus_add_child(device_t dev, u_int order, const char *name, int unit)  	    sizeof(struct gpiobus_ivar)));  } -static void +void  gpiobus_child_deleted(device_t dev, device_t child)  {  	struct gpiobus_ivar *devi; diff --git a/sys/dev/gpio/gpiobus_internal.h b/sys/dev/gpio/gpiobus_internal.h index 58f862343403..be76450b2432 100644 --- a/sys/dev/gpio/gpiobus_internal.h +++ b/sys/dev/gpio/gpiobus_internal.h @@ -43,6 +43,7 @@ int gpiobus_read_ivar(device_t, device_t, int, uintptr_t *);  int gpiobus_acquire_pin(device_t, uint32_t);  void gpiobus_release_pin(device_t, uint32_t);  int gpiobus_child_location(device_t, device_t, struct sbuf *); +void gpiobus_child_deleted(device_t, device_t);  device_t gpiobus_add_child_common(device_t, u_int, const char *, int, size_t);  int gpiobus_add_gpioc(device_t); diff --git a/sys/dev/thunderbolt/nhi.c b/sys/dev/thunderbolt/nhi.c index 205e69c16253..30a72652535a 100644 --- a/sys/dev/thunderbolt/nhi.c +++ b/sys/dev/thunderbolt/nhi.c @@ -322,6 +322,7 @@ nhi_detach(struct nhi_softc *sc)  	tbdev_remove_interface(sc);  	nhi_pci_disable_interrupts(sc); +	nhi_pci_free_interrupts(sc);  	nhi_free_ring0(sc); diff --git a/sys/dev/thunderbolt/nhi_pci.c b/sys/dev/thunderbolt/nhi_pci.c index 7dacff523cef..865963e275ec 100644 --- a/sys/dev/thunderbolt/nhi_pci.c +++ b/sys/dev/thunderbolt/nhi_pci.c @@ -67,7 +67,7 @@ static int	nhi_pci_suspend(device_t);  static int	nhi_pci_resume(device_t);  static void	nhi_pci_free(struct nhi_softc *);  static int	nhi_pci_allocate_interrupts(struct nhi_softc *); -static void	nhi_pci_free_interrupts(struct nhi_softc *); +static void	nhi_pci_free_resources(struct nhi_softc *);  static int	nhi_pci_icl_poweron(struct nhi_softc *);  static device_method_t nhi_methods[] = { @@ -253,7 +253,7 @@ static void  nhi_pci_free(struct nhi_softc *sc)  { -	nhi_pci_free_interrupts(sc); +	nhi_pci_free_resources(sc);  	if (sc->parent_dmat != NULL) {  		bus_dma_tag_destroy(sc->parent_dmat); @@ -307,7 +307,7 @@ nhi_pci_allocate_interrupts(struct nhi_softc *sc)  	return (error);  } -static void +void  nhi_pci_free_interrupts(struct nhi_softc *sc)  {  	int i; @@ -319,7 +319,11 @@ nhi_pci_free_interrupts(struct nhi_softc *sc)  	}  	pci_release_msi(sc->dev); +} +static void +nhi_pci_free_resources(struct nhi_softc *sc) +{  	if (sc->irq_table != NULL) {  		bus_release_resource(sc->dev, SYS_RES_MEMORY,  		    sc->irq_table_rid, sc->irq_table); diff --git a/sys/dev/thunderbolt/nhi_var.h b/sys/dev/thunderbolt/nhi_var.h index 2b9e878af47d..e79ecc954c1f 100644 --- a/sys/dev/thunderbolt/nhi_var.h +++ b/sys/dev/thunderbolt/nhi_var.h @@ -217,6 +217,7 @@ struct nhi_dispatch {  int nhi_pci_configure_interrupts(struct nhi_softc *sc);  void nhi_pci_enable_interrupt(struct nhi_ring_pair *r);  void nhi_pci_disable_interrupts(struct nhi_softc *sc); +void nhi_pci_free_interrupts(struct nhi_softc *sc);  int nhi_pci_get_uuid(struct nhi_softc *sc);  int nhi_read_lc_mailbox(struct nhi_softc *, u_int reg, uint32_t *val);  int nhi_write_lc_mailbox(struct nhi_softc *, u_int reg, uint32_t val); diff --git a/sys/dev/usb/wlan/if_upgt.c b/sys/dev/usb/wlan/if_upgt.c index 1ab833301b3c..a860cc3e0fa9 100644 --- a/sys/dev/usb/wlan/if_upgt.c +++ b/sys/dev/usb/wlan/if_upgt.c @@ -1174,7 +1174,7 @@ upgt_eeprom_parse_freq3(struct upgt_softc *sc, uint8_t *data, int len)  		sc->sc_eeprom_freq3[channel] = freq3[i]; -		DPRINTF(sc, UPGT_DEBUG_FW, "frequence=%d, channel=%d\n", +		DPRINTF(sc, UPGT_DEBUG_FW, "frequency=%d, channel=%d\n",  		    le16toh(sc->sc_eeprom_freq3[channel].freq), channel);  	}  } @@ -1216,7 +1216,7 @@ upgt_eeprom_parse_freq4(struct upgt_softc *sc, uint8_t *data, int len)  			sc->sc_eeprom_freq4[channel][j].pad = 0;  		} -		DPRINTF(sc, UPGT_DEBUG_FW, "frequence=%d, channel=%d\n", +		DPRINTF(sc, UPGT_DEBUG_FW, "frequency=%d, channel=%d\n",  		    le16toh(freq4_1[i].freq), channel);  	}  } @@ -1244,7 +1244,7 @@ upgt_eeprom_parse_freq6(struct upgt_softc *sc, uint8_t *data, int len)  		sc->sc_eeprom_freq6[channel] = freq6[i]; -		DPRINTF(sc, UPGT_DEBUG_FW, "frequence=%d, channel=%d\n", +		DPRINTF(sc, UPGT_DEBUG_FW, "frequency=%d, channel=%d\n",  		    le16toh(sc->sc_eeprom_freq6[channel].freq), channel);  	}  } diff --git a/sys/dev/usb/wlan/if_zyd.c b/sys/dev/usb/wlan/if_zyd.c index 7affdcdce089..b7dfc941224d 100644 --- a/sys/dev/usb/wlan/if_zyd.c +++ b/sys/dev/usb/wlan/if_zyd.c @@ -827,7 +827,7 @@ zyd_cmd(struct zyd_softc *sc, uint16_t code, const void *idata, int ilen,  	if (error)  		device_printf(sc->sc_dev, "command timeout\n");  	STAILQ_REMOVE(&sc->sc_rqh, &rq, zyd_rq, rq); -	DPRINTF(sc, ZYD_DEBUG_CMD, "finsihed cmd %p, error = %d \n", +	DPRINTF(sc, ZYD_DEBUG_CMD, "finished cmd %p, error = %d \n",  	    &rq, error);  	return (error); diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c index b88169ba69d5..b61218958550 100644 --- a/sys/fs/nfsclient/nfs_clrpcops.c +++ b/sys/fs/nfsclient/nfs_clrpcops.c @@ -9760,7 +9760,7 @@ nfsm_split(struct mbuf *mp, uint64_t xfer)  		pgno++;  	} while (pgno < m->m_epg_npgs);  	if (pgno == m->m_epg_npgs) -		panic("nfsm_split: eroneous ext_pgs mbuf"); +		panic("nfsm_split: erroneous ext_pgs mbuf");  	m2 = mb_alloc_ext_pgs(M_WAITOK, mb_free_mext_pgs, 0);  	m2->m_epg_flags |= EPG_FLAG_ANON; diff --git a/sys/fs/nfsclient/nfs_clvfsops.c b/sys/fs/nfsclient/nfs_clvfsops.c index 5ea7eab07632..212c88f28930 100644 --- a/sys/fs/nfsclient/nfs_clvfsops.c +++ b/sys/fs/nfsclient/nfs_clvfsops.c @@ -927,7 +927,7 @@ nfs_mount(struct mount *mp)  	struct vnode *vp;  	struct thread *td;  	char *hst; -	u_char nfh[NFSX_FHMAX], krbname[100], dirpath[100], srvkrbname[100]; +	u_char nfh[NFSX_FHMAX], krbname[100], *dirpath, srvkrbname[100];  	char *cp, *opt, *name, *secname, *tlscertname;  	int nametimeo = NFS_DEFAULT_NAMETIMEO;  	int negnametimeo = NFS_DEFAULT_NEGNAMETIMEO; @@ -943,6 +943,7 @@ nfs_mount(struct mount *mp)  	newflag = 0;  	tlscertname = NULL;  	hst = malloc(MNAMELEN, M_TEMP, M_WAITOK); +	dirpath = malloc(MNAMELEN, M_TEMP, M_WAITOK);  	if (vfs_filteropt(mp->mnt_optnew, nfs_opts)) {  		error = EINVAL;  		goto out; @@ -1329,7 +1330,7 @@ nfs_mount(struct mount *mp)  			goto out;  	} else if (nfs_mount_parse_from(mp->mnt_optnew,  	    &args.hostname, (struct sockaddr_in **)&nam, dirpath, -	    sizeof(dirpath), &dirlen) == 0) { +	    MNAMELEN, &dirlen) == 0) {  		has_nfs_from_opt = 1;  		bcopy(args.hostname, hst, MNAMELEN);  		hst[MNAMELEN - 1] = '\0'; @@ -1387,7 +1388,7 @@ nfs_mount(struct mount *mp)  	if (has_nfs_from_opt == 0) {  		if (vfs_getopt(mp->mnt_optnew,  		    "dirpath", (void **)&name, NULL) == 0) -			strlcpy(dirpath, name, sizeof (dirpath)); +			strlcpy(dirpath, name, MNAMELEN);  		else  			dirpath[0] = '\0';  		dirlen = strlen(dirpath); @@ -1472,6 +1473,7 @@ out:  		MNT_IUNLOCK(mp);  	}  	free(hst, M_TEMP); +	free(dirpath, M_TEMP);  	return (error);  } diff --git a/sys/geom/geom_vfs.c b/sys/geom/geom_vfs.c index d9e9a6c82da1..9b5e5a84191f 100644 --- a/sys/geom/geom_vfs.c +++ b/sys/geom/geom_vfs.c @@ -153,7 +153,7 @@ g_vfs_done(struct bio *bip)  			g_print_bio("g_vfs_done():", bip, "error = %d%s",  			    bip->bio_error,  			    bip->bio_error != ENXIO ? "" : -			    " supressing further ENXIO"); +			    " suppressing further ENXIO");  		}  	}  	bp->b_error = bip->bio_error; diff --git a/sys/powerpc/include/openpicvar.h b/sys/powerpc/include/openpicvar.h index 3a170a8a35fe..12f01cb80406 100644 --- a/sys/powerpc/include/openpicvar.h +++ b/sys/powerpc/include/openpicvar.h @@ -28,6 +28,8 @@  #ifndef	_POWERPC_OPENPICVAR_H_  #define	_POWERPC_OPENPICVAR_H_ +#include <sys/kobj.h> +  #define OPENPIC_DEVSTR	"OpenPIC Interrupt Controller"  #define OPENPIC_IRQMAX	256	/* h/w allows more */ @@ -75,16 +77,11 @@ int	openpic_common_attach(device_t, uint32_t);  /*   * PIC interface.   */ -void	openpic_bind(device_t dev, u_int irq, cpuset_t cpumask, void **);  void	openpic_config(device_t, u_int, enum intr_trigger, enum intr_polarity); -void	openpic_dispatch(device_t, struct trapframe *);  void	openpic_enable(device_t, u_int, u_int, void **);  void	openpic_eoi(device_t, u_int, void *); -void	openpic_ipi(device_t, u_int); -void	openpic_mask(device_t, u_int, void *);  void	openpic_unmask(device_t, u_int, void *); -int	openpic_suspend(device_t dev); -int	openpic_resume(device_t dev); +DECLARE_CLASS(openpic_class);  #endif /* _POWERPC_OPENPICVAR_H_ */ diff --git a/sys/powerpc/ofw/openpic_ofw.c b/sys/powerpc/ofw/openpic_ofw.c index fdab55fb30f5..4083e9eba749 100644 --- a/sys/powerpc/ofw/openpic_ofw.c +++ b/sys/powerpc/ofw/openpic_ofw.c @@ -68,29 +68,15 @@ static device_method_t  openpic_ofw_methods[] = {  	/* Device interface */  	DEVMETHOD(device_probe,		openpic_ofw_probe),  	DEVMETHOD(device_attach,	openpic_ofw_attach), -	DEVMETHOD(device_suspend,	openpic_suspend), -	DEVMETHOD(device_resume,	openpic_resume),  	/* PIC interface */ -	DEVMETHOD(pic_bind,		openpic_bind), -	DEVMETHOD(pic_config,		openpic_config), -	DEVMETHOD(pic_dispatch,		openpic_dispatch), -	DEVMETHOD(pic_enable,		openpic_enable), -	DEVMETHOD(pic_eoi,		openpic_eoi), -	DEVMETHOD(pic_ipi,		openpic_ipi), -	DEVMETHOD(pic_mask,		openpic_mask), -	DEVMETHOD(pic_unmask,		openpic_unmask), -  	DEVMETHOD(pic_translate_code,	openpic_ofw_translate_code),  	DEVMETHOD_END  }; -static driver_t openpic_ofw_driver = { -	"openpic", -	openpic_ofw_methods, -	sizeof(struct openpic_softc), -}; +DEFINE_CLASS_1(openpic, openpic_ofw_driver, openpic_ofw_methods, +    sizeof(struct openpic_softc), openpic_class);  EARLY_DRIVER_MODULE(openpic, ofwbus, openpic_ofw_driver, 0, 0,      BUS_PASS_INTERRUPT); diff --git a/sys/powerpc/powermac/cpcht.c b/sys/powerpc/powermac/cpcht.c index 138aefda5cdb..448144c9749e 100644 --- a/sys/powerpc/powermac/cpcht.c +++ b/sys/powerpc/powermac/cpcht.c @@ -113,7 +113,7 @@ static device_method_t	cpcht_methods[] = {  struct cpcht_irq {  	enum {  	    IRQ_NONE, IRQ_HT, IRQ_MSI, IRQ_INTERNAL -	}		irq_type;  +	}		irq_type;  	int		ht_source; @@ -287,7 +287,7 @@ cpcht_configure_htbridge(device_t dev, phandle_t child)  			sc->htirq_map[irq].irq_type = IRQ_HT;  			sc->htirq_map[irq].ht_source = i; -			sc->htirq_map[irq].ht_base = sc->sc_data +  +			sc->htirq_map[irq].ht_base = sc->sc_data +  			    (((((s & 0x1f) << 3) | (f & 0x07)) << 8) | (ptr));  			PCIB_WRITE_CONFIG(dev, b, s, f, @@ -298,13 +298,13 @@ cpcht_configure_htbridge(device_t dev, phandle_t child)  			/*  			 * Apple uses a non-compliant IO/APIC that differs -			 * in how we signal EOIs. Check if this device was  +			 * in how we signal EOIs. Check if this device was  			 * made by Apple, and act accordingly.  			 */  			vend = PCIB_READ_CONFIG(dev, b, s, f,  			    PCIR_DEVVENDOR, 4);  			if ((vend & 0xffff) == 0x106b) -				sc->htirq_map[irq].apple_eoi =  +				sc->htirq_map[irq].apple_eoi =  				 (sc->htirq_map[irq].ht_base - ptr) + 0x60;  		}  	} @@ -318,7 +318,7 @@ cpcht_read_config(device_t dev, u_int bus, u_int slot, u_int func, u_int reg,  	vm_offset_t	caoff;  	sc = device_get_softc(dev); -	caoff = sc->sc_data +  +	caoff = sc->sc_data +  		(((((slot & 0x1f) << 3) | (func & 0x07)) << 8) | reg);  	if (bus == 0 && (!(sc->sc_populated_slots & (1 << slot)) || func > 0)) @@ -350,7 +350,7 @@ cpcht_write_config(device_t dev, u_int bus, u_int slot, u_int func,  	vm_offset_t	caoff;  	sc = device_get_softc(dev); -	caoff = sc->sc_data +  +	caoff = sc->sc_data +  		(((((slot & 0x1f) << 3) | (func & 0x07)) << 8) | reg);  	if (bus == 0 && (!(sc->sc_populated_slots & (1 << slot)) || func > 0)) @@ -520,16 +520,12 @@ static device_method_t  openpic_cpcht_methods[] = {  	DEVMETHOD(device_attach,	openpic_cpcht_attach),  	/* PIC interface */ -	DEVMETHOD(pic_bind,		openpic_bind),  	DEVMETHOD(pic_config,		openpic_cpcht_config), -	DEVMETHOD(pic_dispatch,		openpic_dispatch),  	DEVMETHOD(pic_enable,		openpic_cpcht_enable),  	DEVMETHOD(pic_eoi,		openpic_cpcht_eoi), -	DEVMETHOD(pic_ipi,		openpic_ipi), -	DEVMETHOD(pic_mask,		openpic_mask),  	DEVMETHOD(pic_unmask,		openpic_cpcht_unmask), -	{ 0, 0 }, +	DEVMETHOD_END  };  struct openpic_cpcht_softc { @@ -538,11 +534,8 @@ struct openpic_cpcht_softc {  	struct mtx sc_ht_mtx;  }; -static driver_t openpic_cpcht_driver = { -	"htpic", -	openpic_cpcht_methods, -	sizeof(struct openpic_cpcht_softc), -}; +DEFINE_CLASS_1(htpic, openpic_cpcht_driver, openpic_cpcht_methods, +    sizeof(struct openpic_cpcht_softc), openpic_class);  EARLY_DRIVER_MODULE(openpic, unin, openpic_cpcht_driver, 0, 0,      BUS_PASS_INTERRUPT); @@ -553,7 +546,7 @@ openpic_cpcht_probe(device_t dev)  	const char *type = ofw_bus_get_type(dev);  	if (strcmp(type, "open-pic") != 0) -                return (ENXIO); +		return (ENXIO);  	device_set_desc(dev, OPENPIC_DEVSTR);  	return (0); @@ -582,7 +575,7 @@ openpic_cpcht_attach(device_t dev)  	 * Interrupts 0-3 are internally sourced and are level triggered  	 * active low. Interrupts 4-123 are connected to a pulse generator  	 * and should be programmed as edge triggered low-to-high. -	 *  +	 *  	 * IBM CPC945 Manual, Section 9.3.  	 */ @@ -631,7 +624,7 @@ openpic_cpcht_config(device_t dev, u_int irq, enum intr_trigger trig,  		/* Mask the IRQ while we fiddle settings */  		out32rb(cpcht_irqmap[irq].ht_base + 4, ht_irq | HTAPIC_MASK); -		 +  		/* Program the interrupt sense */  		ht_irq &= ~(HTAPIC_TRIGGER_LEVEL | HTAPIC_REQUEST_EOI);  		if (trig == INTR_TRIGGER_EDGE) { @@ -671,7 +664,7 @@ openpic_cpcht_enable(device_t dev, u_int irq, u_int vec, void **priv)  		mtx_unlock_spin(&sc->sc_ht_mtx);  	} -		 +  	openpic_cpcht_eoi(dev, irq, *priv);  } diff --git a/sys/powerpc/powerpc/openpic.c b/sys/powerpc/powerpc/openpic.c index 0c717aaf6060..aa28f63cb6f5 100644 --- a/sys/powerpc/powerpc/openpic.c +++ b/sys/powerpc/powerpc/openpic.c @@ -225,7 +225,7 @@ openpic_common_attach(device_t dev, uint32_t node)   * PIC I/F methods   */ -void +static void  openpic_bind(device_t dev, u_int irq, cpuset_t cpumask, void **priv __unused)  {  	struct openpic_softc *sc; @@ -280,18 +280,7 @@ openpic_config(device_t dev, u_int irq, enum intr_trigger trig,  	openpic_write(sc, OPENPIC_SRC_VECTOR(irq), x);  } -static int -openpic_intr(void *arg) -{ -	device_t dev = (device_t)(arg); - -	/* XXX Cascaded PICs do not pass non-NULL trapframes! */ -	openpic_dispatch(dev, NULL); - -	return (FILTER_HANDLED); -} - -void +static void  openpic_dispatch(device_t dev, struct trapframe *tf)  {  	struct openpic_softc *sc; @@ -311,6 +300,17 @@ openpic_dispatch(device_t dev, struct trapframe *tf)  	}  } +static int +openpic_intr(void *arg) +{ +	device_t dev = (device_t)(arg); + +	/* XXX Cascaded PICs do not pass non-NULL trapframes! */ +	openpic_dispatch(dev, NULL); + +	return (FILTER_HANDLED); +} +  void  openpic_enable(device_t dev, u_int irq, u_int vector, void **priv __unused)  { @@ -343,7 +343,7 @@ openpic_eoi(device_t dev, u_int irq __unused, void *priv __unused)  	openpic_write(sc, OPENPIC_PCPU_EOI(cpuid), 0);  } -void +static void  openpic_ipi(device_t dev, u_int cpu)  {  	struct openpic_softc *sc; @@ -357,7 +357,7 @@ openpic_ipi(device_t dev, u_int cpu)  	sched_unpin();  } -void +static void  openpic_mask(device_t dev, u_int irq, void *priv __unused)  {  	struct openpic_softc *sc; @@ -393,7 +393,7 @@ openpic_unmask(device_t dev, u_int irq, void *priv __unused)  	}  } -int +static int  openpic_suspend(device_t dev)  {  	struct openpic_softc *sc; @@ -424,7 +424,7 @@ openpic_suspend(device_t dev)  	return (0);  } -int +static int  openpic_resume(device_t dev)  {      	struct openpic_softc *sc; @@ -453,3 +453,24 @@ openpic_resume(device_t dev)  	return (0);  } + +static device_method_t openpic_methods[] = { +	/* Device interface */ +	DEVMETHOD(device_suspend,	openpic_suspend), +	DEVMETHOD(device_resume,	openpic_resume), + +	/* PIC interface */ +	DEVMETHOD(pic_bind,		openpic_bind), +	DEVMETHOD(pic_config,		openpic_config), +	DEVMETHOD(pic_dispatch,		openpic_dispatch), +	DEVMETHOD(pic_enable,		openpic_enable), +	DEVMETHOD(pic_eoi,		openpic_eoi), +	DEVMETHOD(pic_ipi,		openpic_ipi), +	DEVMETHOD(pic_mask,		openpic_mask), +	DEVMETHOD(pic_unmask,		openpic_unmask), + +	DEVMETHOD_END +}; + +DEFINE_CLASS_0(openpic, openpic_class, openpic_methods, +    sizeof(struct openpic_softc)); diff --git a/sys/powerpc/psim/openpic_iobus.c b/sys/powerpc/psim/openpic_iobus.c index bf5bd8235a6c..21950e248b6d 100644 --- a/sys/powerpc/psim/openpic_iobus.c +++ b/sys/powerpc/psim/openpic_iobus.c @@ -69,22 +69,11 @@ static device_method_t  openpic_iobus_methods[] = {  	DEVMETHOD(device_probe,		openpic_iobus_probe),  	DEVMETHOD(device_attach,	openpic_iobus_attach), -	/* PIC interface */ -	DEVMETHOD(pic_config,		openpic_config), -	DEVMETHOD(pic_dispatch,		openpic_dispatch), -	DEVMETHOD(pic_enable,		openpic_enable), -	DEVMETHOD(pic_eoi,		openpic_eoi), -	DEVMETHOD(pic_ipi,		openpic_ipi), -	DEVMETHOD(pic_mask,		openpic_mask), -	DEVMETHOD(pic_unmask,		openpic_unmask), -	{ 0, 0 } +	DEVMETHOD_END  }; -static driver_t openpic_iobus_driver = { -	"openpic", -	openpic_iobus_methods, -	sizeof(struct openpic_softc) -}; +DEFINE_CLASS_1(openpic, openpic_iobus_driver, openpic_iobus_methods, +    sizeof(struct openpic_softc), openpic_class);  DRIVER_MODULE(openpic, iobus, openpic_iobus_driver, 0, 0); diff --git a/sys/security/audit/bsm_errno.c b/sys/security/audit/bsm_errno.c index 6bc110cf0237..1f3b12735b84 100644 --- a/sys/security/audit/bsm_errno.c +++ b/sys/security/audit/bsm_errno.c @@ -514,7 +514,7 @@ static const struct bsm_errno bsm_errnos[] = {  #else  	ERRNO_NO_LOCAL_MAPPING,  #endif -	ES("Authenticateion error") }, +	ES("Authentication error") },  	{ BSM_ERRNO_ENEEDAUTH,  #ifdef ENEEDAUTH  	ENEEDAUTH, diff --git a/tests/sys/netpfil/pf/Makefile b/tests/sys/netpfil/pf/Makefile index b363e0b17c76..9416f6abbdf1 100644 --- a/tests/sys/netpfil/pf/Makefile +++ b/tests/sys/netpfil/pf/Makefile @@ -90,6 +90,8 @@ ${PACKAGE}FILES+=	\  			pft_ether.py \  			pft_read_ipfix.py \  			rdr-srcport.py \ +			tftpd_inetd.conf \ +			tftpd_proxy_inetd.conf \  			utils.subr \  			utils.py diff --git a/tests/sys/netpfil/pf/proxy.sh b/tests/sys/netpfil/pf/proxy.sh index 78ce25930c04..a07bb259b544 100644 --- a/tests/sys/netpfil/pf/proxy.sh +++ b/tests/sys/netpfil/pf/proxy.sh @@ -88,7 +88,68 @@ ftp_cleanup()  	pft_cleanup  } +atf_test_case "tftp" "cleanup" +tftp_head() +{ +	atf_set descr 'Test tftp-proxy' +	atf_set require.user root +} + +tftp_body() +{ +	pft_init + +	epair_client=$(vnet_mkepair) +	epair_link=$(vnet_mkepair) + +	ifconfig ${epair_client}a 192.0.2.2/24 up +	route add -net 198.51.100.0/24 192.0.2.1 + +	vnet_mkjail fwd ${epair_client}b ${epair_link}a +	jexec fwd ifconfig lo0 127.0.0.1/8 up +	jexec fwd ifconfig ${epair_client}b 192.0.2.1/24 up +	jexec fwd ifconfig ${epair_link}a 198.51.100.1/24 up +	jexec fwd ifconfig lo0 127.0.0.1/8 up +	jexec fwd sysctl net.inet.ip.forwarding=1 + +	vnet_mkjail srv ${epair_link}b +	jexec srv ifconfig ${epair_link}b 198.51.100.2/24 up +	jexec srv route add default 198.51.100.1 + +	# Start tftp server in srv +	jexec srv /usr/sbin/inetd -p ${PWD}/inetd-srv.pid \ +	    $(atf_get_srcdir)/tftpd_inetd.conf + +	jexec fwd /usr/sbin/inetd -p ${PWD}/inetd-fwd.pid \ +	    $(atf_get_srcdir)/tftpd_proxy_inetd.conf + +	jexec fwd pfctl -e +	pft_set_rules fwd \ +		"nat on ${epair_link}a inet from 192.0.2.0/24 to any -> (${epair_link}a)" \ +		"nat-anchor \"tftp-proxy/*\"" \ +		"rdr-anchor \"tftp-proxy/*\"" \ +		"rdr pass on ${epair_client}b proto udp from 192.0.2.0/24 to any port 69 -> 127.0.0.1 port 69" \ +		"anchor \"tftp-proxy/*\"" \ +		"pass out proto udp from 127.0.0.1 to any port 69" + +	# Create a dummy file to download +	echo 'foo' > /tmp/remote.txt +	echo 'get remote.txt local.txt' | tftp 198.51.100.2 + +	# Compare the downloaded file to the original +	if ! diff -q local.txt /tmp/remote.txt; +	then +		atf_fail 'Failed to retrieve file' +	fi +} + +tftp_cleanup() +{ +	pft_cleanup +} +  atf_init_test_cases()  {  	atf_add_test_case "ftp" +	atf_add_test_case "tftp"  } diff --git a/tests/sys/netpfil/pf/tftpd_inetd.conf b/tests/sys/netpfil/pf/tftpd_inetd.conf new file mode 100644 index 000000000000..3554d0a7fb08 --- /dev/null +++ b/tests/sys/netpfil/pf/tftpd_inetd.conf @@ -0,0 +1,28 @@ +# +# SPDX-License-Identifier: BSD-2-Clause +# +# Copyright (c) 2025 Rubicon Communications, LLC (Netgate) +# +# 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. + +tftp	dgram	udp	wait	root	/usr/libexec/tftpd	tftpd -l -S -s /tmp +tftp	dgram	udp6	wait	root	/usr/libexec/tftpd	tftpd -l -S -s /tmp diff --git a/tests/sys/netpfil/pf/tftpd_proxy_inetd.conf b/tests/sys/netpfil/pf/tftpd_proxy_inetd.conf new file mode 100644 index 000000000000..aa5f000f3bba --- /dev/null +++ b/tests/sys/netpfil/pf/tftpd_proxy_inetd.conf @@ -0,0 +1,27 @@ +# +# SPDX-License-Identifier: BSD-2-Clause +# +# Copyright (c) 2025 Rubicon Communications, LLC (Netgate) +# +# 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. + +tftp	dgram	udp	wait	root	/usr/libexec/tftp-proxy tftp-proxy diff --git a/tools/tools/git/git-arc.sh b/tools/tools/git/git-arc.sh index 22df0c61293a..fa618cdcbc22 100644 --- a/tools/tools/git/git-arc.sh +++ b/tools/tools/git/git-arc.sh @@ -242,7 +242,7 @@ title2diff()  {      local title -    title=$(echo $1 | sed 's/"/\\"/g') +    title=$(echo "$1" | sed 's/"/\\"/g')      arc_list --no-ansi |          awk -F': ' '{              if (substr($0, index($0, FS) + length(FS)) == "'"$title"'") { @@ -470,7 +470,7 @@ gitarc__list()          title=$(git show -s --format=%s "$commit")          diff=$(echo "$openrevs" | \              awk -F'D[1-9][0-9]*: ' \ -            '{if ($2 == "'"$(echo $title | sed 's/"/\\"/g')"'") print $0}') +            '{if ($2 == "'"$(echo "$title" | sed 's/"/\\"/g')"'") print $0}')          if [ -z "$diff" ]; then              echo "No Review            : $title"          elif [ "$(echo "$diff" | wc -l)" -ne 1 ]; then | 
