Commit Graph

9784 Commits

Author SHA1 Message Date
Cy Schubert
5e13b104a4 ipfilter userland: Fix whitespace errors
Replace leading spaces with a tabs on affected lines.

MFC after:	1 month
2022-01-03 18:06:44 -08:00
Cy Schubert
27fc223414 ipfilter userland: Remove trailing whitespace
MFC after:	1 month
2022-01-03 18:06:44 -08:00
Cy Schubert
2582ae5740 ipfilter: Adjust userland returns to conform to style(9)
Adjust ipfilter's userland return statements to conform to style(9).

MFC after:	1 month
2022-01-03 18:06:43 -08:00
Cy Schubert
9be9c1c084 ipfilter: INLINE --> inline
Replace the INLINE macro with inline. Some ancient compilers supported
__inline__ instead of inline. The INLINE hack compensated for it.
Ancient compilers are history.

Reported by:	glebius
MFC after:	1 month
2022-01-03 18:06:42 -08:00
Cy Schubert
efeb8bffe3 ipflter: ANSIfy userland function declarations
Convert ipfilter userland function declarations from K&R to ANSI. This
syncs our function declarations with NetBSD hg commit 75edcd7552a0
(apply our changes). Though not copied from NetBSD, this change was
partially inspired by NetBSD's work and inspired by style(9).

Reviewed by:		glebius (for #network)
MFC after:		1 month
Differential Revision:	https://reviews.freebsd.org/D33595
2022-01-03 18:06:42 -08:00
Kristof Provost
9d406e088e dnctl: Support reading config from file like ipfw(8)
Extend the dnctl (dummynet config) tool to be able to read commands from
a file, just like ipfw already does.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D33627
2022-01-03 09:50:18 +01:00
Alan Somers
6226477a46 Various fixes for ggatec and ggated
Dynamically size buffers in ggatec. Instead of static size on the stack.
Add flush support.

Submitted by:	Johannes Totz <jo@bruelltuete.com>
MFC after:	2 weeks
Reviewed by:	asomers
Differential Revision: https://reviews.freebsd.org/D31722
2022-01-02 17:53:55 -07:00
Jessica Clarke
5b13fa7987 ufs: Rework shortlink handling to avoid subobject overflows
Shortlinks occupy the space of both di_db and di_ib when used. However,
everywhere that wants to read or write a shortlink takes a pointer do
di_db and promptly runs off the end of it into di_ib. This is fine on
most architectures, if a little dodgy. However, on CHERI, the compiler
can optionally restrict the bounds on pointers to subobjects to just
that subobject, in order to mitigate intra-object buffer overflows, and
this is enabled in CheriBSD's pure-capability kernels.

Instead, clean this up by inserting a union such that a new di_shortlink
can be added with the right size and element type, avoiding the need to
cast and allowing the use of the DIP macro to access the field. This
also mirrors how the ext2fs code implements extents support, with the
exact same structure other than having a uint32_t i_data[] instead of a
char di_shortlink[].

Reviewed by:	mckusick, jhb
Differential Revision:	https://reviews.freebsd.org/D33650
2022-01-02 20:55:36 +00:00
Ed Maste
c217390359 route: use NULL for null ptr in getaddr call, not 0
Style(9) prefers NULL.

Sponsored by:	The FreeBSD Foundation
2022-01-01 12:02:17 -05:00
Cy Schubert
d740faa30a ipfilter userland: Revert the ipmon part of a6fb9bbea7
a6fb9bbea7 caused incorrect formatting of ipmon log output.

Fixes:		a6fb9bbea7
MFC after:	immediately
2021-12-27 01:10:52 -08:00
Cy Schubert
7cb2d7c413 ipfilter userland: Path fixup no longer required
Since the move of ipfilter from contrib to sbin adjusting the source path
is no longer required.

Fixes:		41edb306f0
MFC after:	1 month
2021-12-27 00:40:18 -08:00
Emmanuel Vadot
93c4369096 pkgbase: Put more binaries/lib in runtime
Move some needed binaries/libs from FreeBSD-utilities to FreeBSD_runtime.
This is everything needed to boot to multiuser with FreeBSD-rc installed.

MFC after:	2 weeks
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D33435
2021-12-21 10:17:27 +01:00
Emmanuel Vadot
0855e37c72 pkgbase: Put sconfig in FreeBSD-utilities
There is no need to have it in runtime as it's not essential.

MFC after:	2 weeks
Sponsored by:	Beckhoff Automation GmbH & Co. KG
2021-12-21 10:16:08 +01:00
Emmanuel Vadot
9e94953e66 Revert "amd64: Do not build sconfig"
This reverts commit a46856c3f9.

Requested by:	glebius
2021-12-21 10:14:45 +01:00
Cy Schubert
41edb306f0 ipfilter: Move userland bits to sbin
Through fixes and improvements our ipfilter sources have diverged
enough to warrant move from contrib into sbin/ipf. Now that I'm
planning on implementing MSS clamping as in iptables it makes more
sense to move ipfilter to sbin.

This is the second of three commits of the ipfilter move.

Suggested by glebius on two occaions.

Suggested by and discussed with:	glebius
Reviewed by:				glebius, kp (for #network)
MFC after:				1 month
Differential Revision:		https://reviews.freebsd.org/D33510
2021-12-20 06:16:33 -08:00
Cy Schubert
3b9b51fe46 ipfilter: Move kernel bits to netpfil
Through fixes and improvements our ipfilter sources have diverged
enough to warrant move from contrib into sys/netpil. Now that I'm
planning on implementing MSS clamping as in iptables it makes more
sense to move ipfilter to netpfil.

This is the first of three commits the ipfilter move.

Suggested by glebius on two occaions.

Suggested by and discussed with:	glebius
Reviewed by:				glebius, kp (for #network)
MFC after:				1 month
Differential Revision:		https://reviews.freebsd.org/D33510
2021-12-20 06:16:33 -08:00
Warner Losh
7090cba410 fsutil: forward declare struct fstab
Fix the build by forward declaring struct fstab.

Sponsored by:		Netflix
2021-12-15 19:38:28 -07:00
Kirk McKusick
c72372c693 Update fsck(8) to ignore failures from a check program for a filesystem
when the fstab(5) entry for the filesystem has the "failok" attribute.

Reviewed by:  kib
PR:           246201
MFC after:    2 weeks
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D33424
2021-12-15 16:53:46 -08:00
Warner Losh
c6b2efb64e route(8): Remove obsolete information
xns and osi are no longer relevant (or supported) so remove their
vestiges.

Noticed by:	phk
Sponsored by:	Netflix
2021-12-15 16:07:35 -07:00
Emmanuel Vadot
a46856c3f9 amd64: Do not build sconfig
We do not build the drivers for this arch so no need to build the
configuration tools.

MFC after:	2 weeks
Sponsored by:	Beckhoff Automation GmbH & Co. KG
2021-12-15 17:39:36 +01:00
Konstantin Belousov
b49b6e0f95 swapon(8): adapt to the new swapoff(2) interface
also fix test sys/audit/administrative.c.

Reviewed by:	brooks
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33343
2021-12-09 02:48:59 +02:00
Kyle Evans
ace38c58fb savecore: emit information about saved cores under verbose
Declare how many cores we saved, and where we saved them to.  Drop a
comment about emitting little information; it's obvious from the block
in question that we emit nothing without verbose.

Reviewed by:	markj
Sponsored by:	NetApp, Inc.
Sponsored by:	Klara, Inc.
X-NetApp-PR:	#65
Differential Revision:	https://reviews.freebsd.org/D31393
2021-12-07 18:39:34 -06:00
Hans Petter Selasky
83237efcdb kldstat(8): style(9) fixes.
No functional change intended.

Differential revision:  https://reviews.freebsd.org/D32506
Submitted by:   christos@
MFC after:      1 week
Sponsored by:   NVIDIA Networking
2021-12-07 11:40:22 +01:00
Kristof Provost
73fd0eaf59 pfsync: fix incorrect enabling of defer mode
When we exposed the PFSYNCF_OK flag to userspace in 5f5bf88949 we
unintentionally caused defer mode to always be enabled.
The ioctl check only looked for nonzero, not for the PFSYNCF_DEFER flag.

Fix this check and ensure ifconfig sets the flag.

Reviewed by:	glebius
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D33244
2021-12-06 13:25:14 +01:00
Warner Losh
4de76195ce sysctl: Small style fix
Slightly reorder to make this look better. No functional change.

Sponsored by:		Netflix
2021-12-05 21:40:47 -07:00
Stefan Eßer
5e04571cf3 sys/bitset.h: reduce visibility of BIT_* macros
Add two underscore characters "__" to names of BIT_* and BITSET_*
macros to move them to the implementation name space and to prevent
a name space pollution due to BIT_* macros in 3rd party programs with
conflicting parameter signatures.

These prefixed macro names are used in kernel header files to define
macros in e.g. sched.h, sys/cpuset.h and sys/domainset.h.

If C programs are built with either -D_KERNEL (automatically passed
when building a kernel or kernel modules) or -D_WANT_FREENBSD_BITSET
(or this macros is defined in the source code before including the
bitset macros), then all macros are made visible with their previous
names, too. E.g., both __BIT_SET() and BIT_SET() are visible with
either of _KERNEL or _WANT_FREEBSD_BITSET defined.

The main reason for this change is that some 3rd party sources
including sched.h have been found to contain conflicting BIT_*
macros.

As a work-around, parts of shed.h have been made conditional and
depend on _WITH_CPU_SET_T being set when sched.h is included.
Ports that expect the full functionality provided by sched.h need
to be built with -D_WITH_CPU_SET_T. But this leads to conflicts if
BIT_* macros are defined in that program, too.

This patch set makes all of sched.h visible again without this
parameter being passed and without any name space pollution due
to BIT_* macros becoming visible when sched.h is included.

This patch set will be backported to the STABLE branches, but ports
will need to use -D_WITH_CPU_SET_T as long as there are supported
releases that do not contain these patches.

Reviewed by:	kib, markj
MFC after:	1 month
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D33235
2021-12-05 23:00:25 +01:00
Konstantin Belousov
1aa249c935 swapoff(8): add -f flag
to force swapout by ignoring the heuristic that calculates amount of
allocated memory against total of RAM plus remaining swap.

Reviewed by:	markj
Discussed with:	alc
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33165
2021-12-05 00:20:58 +02:00
Ed Maste
a4ef9e58bc sbin: build ping if at least one of INET & INET6 is enabled
It does not build (and serves no purpose) if neither is true (i.e.,
building WITHOUT_INET and WITHOUT_INET6).  Also add an explicit error
in ping to make this case clear.

PR:		260082
Sponsored by:	The FreeBSD Foundation
2021-11-28 13:05:39 -05:00
Konstantin Belousov
3ede04c78c ldconfig(8): check for no-args command line after options are parsed
Default action for ldconfig is specified as -R AKA 'append', and for
no-args (without options changing default actions), ldconfig should
append empty list of directories to current list.  But because the check
was done before options were parsed out, presence of any option turned
off default rescan.

As result, innocently-looked commands like `ldconfig -v' were interpreted
as setting directory hints list to one specified on the command line,
i.e. empty.

Reported by:	https://github.com/mesonbuild/meson/issues/9592
Reviewed by:	emaste
Tested by:	jbeich
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33058
2021-11-25 01:55:04 +02:00
Konstantin Belousov
af91158706 ldconfig: use libexec/rtld-elf/rtld_paths.h
instead of duplicating definitions using slighly different macro names.

Reviewed by:	emaste
Tested by:	jbeich
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33058
2021-11-25 01:55:04 +02:00
Konstantin Belousov
b828161d12 ldconfig(8): nostd/-s does nothing
Remove the option from man page and summary.  Silently ignore it when
parsing command line for backward compatibility.

Reviewed by:	emaste
Tested by:	jbeich
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33058
2021-11-25 01:55:03 +02:00
Konstantin Belousov
3f2c6f5598 ldconfig: start of cleanup
Use bool.
Use local variables instead of static.
Remove non-functional debugging override of hints file path.
Use explicit exit() instead of return from main.
Minor style tweaks.

Reviewed by:	emaste
Tested by:	jbeich
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33058
2021-11-25 01:55:03 +02:00
Konstantin Belousov
83511ce5c4 ldconfig: remove a comment which is another remnant of a.out support
Noted and reviewed by:	emaste
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33058
2021-11-25 01:55:03 +02:00
Mark Johnston
517373f723 natd: Remove uneeded in_cksum.h includes
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2021-11-24 13:31:16 -05:00
Warner Losh
a8935083b5 devmatch: Allow devmatch_blocklist to be set in kenv too
Add in all the variables set in the kenv variable devmatch_blocklist
too. This allows blocking autoloading from the boot loader.

Sponsored by:		Netflix
Reviewed by:		0mp
Differential Revision:	https://reviews.freebsd.org/D32171
2021-11-21 08:54:45 -07:00
Kristof Provost
19dc644511 if_stf: add 6rd support
Implement IPv6 Rapid Deployment (RFC5969) on top of the existing 6to4
(RFC3056) if_stf code.

PR:		253328
Reviewed by:	hrs
Obtained from:	pfSense
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D33037
2021-11-20 19:29:01 +01:00
Ed Maste
3f9acedb02 growfs: do not error if filesystem is already requested size
For some cloud/virtualization use cases it can be convenient to grow the
filesystem on boot any time the disk/partition happens to be larger, but
not fail if it remains the same size.

Continue to emit a message if we have no action to take, but exit with
status 0 if the size remains the same.

Reviewed by:	trasz
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D32856
2021-11-15 15:40:57 -05:00
Kirk McKusick
e38717c128 Fix regression to verbose behavior introduced in 68bff4a07e.
Reported by:    Brad Davis (brd)
Reviewed by:    Kristof Provost (kp)
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D32736
Sponsored by:   Netflix
2021-11-11 12:11:25 -08:00
Hans Petter Selasky
ad8f078f66 ifconfig(8): Don't set network interface capabilities when there is no change.
A quick grep through the kernel code shows network drivers compute the
changed bits of network capabilities after a SIOCSIFCAP IOCTL(2) by
using the bitwise exclusive or operation. When the set capabilities
are equal to the already read capabilities, no action will be taken.

Let ifconfig(8) predict this case and skip the SIOCSIFCAP IOCTL(2)
system call.

Discussed with:	kib@ (revert change in case of issues)
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2021-11-10 15:50:52 +01:00
Hans Petter Selasky
337c814316 kldstat(8): Fix indentation, whitespace to tabs.
No functional change intended.

Differential revision:  https://reviews.freebsd.org/D32502
Submitted by:   christos@
MFC after:      1 week
Sponsored by:   NVIDIA Networking
2021-11-09 22:12:19 +01:00
Mike Karels
d8237b9555 ifconfig: warn if setting an Internet address without mask
Add a postproc function for af_inet, and add interface flags as a
parameter.  Check there if setting an address without a mask unless
the interface is loopback or point-to-point, where mask is not really
meaningful; warn if so.  This will hopefully be an error in the future.

MFC after:	1 month
Reviewd by:	bz
Differential Revision: https://reviews.freebsd.org/D32709
2021-11-09 09:33:01 -06:00
Zhenlei Huang
55b0acc092 ifconfig.8: Add the missing option -vlanhwcsum
Commit 9b776960c3 documented a new option
vlanhwcsum but missed the opposite one -vlanhwcsum.

Reviewed by:	kp
Differential Revision:	https://reviews.freebsd.org/D32887
2021-11-08 11:12:43 +01:00
Andriy Gapon
c01a46d4ac camcontrol: dump received data for MMC command even if it is unknown
For example, EXT_CSD can be read like this:
    # camcontrol mmcsdcmd 2:0:0 -c 8 -a 0 -f 0x35 -l 512
    CMD 8 arg 0 flags 35
    MMCIO: error 0, 00000900 00000000 00000000 00000000
    No command-specific decoder for CMD 8
    0000   00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
    0010   39 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |9...............|
    ...
    0100   00 00 00 00 00 00 00 00 01 08 00 01 02 02 00 00  |................|
    ...
    01e0   00 00 00 00 00 00 00 00 00 81 c7 00 00 01 03 07  |................|
    01f0   05 00 03 01 3f 3f 01 01 01 00 00 00 00 00 00 00  |....??..........|

MFC after:	2 weeks
2021-11-06 19:25:57 +02:00
Kristof Provost
76c5eecc34 pf: Introduce ridentifier
Allow users to set a number on rules which will be exposed as part of
the pflog header.
The intent behind this is to allow users to correlate rules across
updates (remember that pf rules continue to exist and match existing
states, even if they're removed from the active ruleset) and pflog.

Obtained from:	pfSense
MFC after:	3 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D32750
2021-11-05 09:39:56 +01:00
Xin LI
890cae1977 fsck_msdosfs: truncate directory entry when the head pointer is invalid.
As far as we know, there is no FAT implementation that supported hard
links, and our msdosfs driver assumed one cluster chain is only
referenced by one directory entry and clears it out when the file is
deleted.  On the other hand, the current code would proceed with
checkchain() when the directory entry's head cluster is a valid numbered
cluster without checking if it was a valid head node of a cluster chain.

So if the cluster do not being a chain (e.g. CLUST_FREE, CLUST_BAD),
or was already referenced by another directory entry, this would
trigger an assertion in check_chain() at a later time.

Fix this by giving the user an option to truncate the directory entry
when the head cluster is an invalid cluster, an visited head node,
or not a head node.

Reported by:	NetApp (kevans@)
Reviewed by:	kevans, emaste (no objection)
MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D32699
2021-11-03 22:09:32 -07:00
Warner Losh
80f21bb039 vt: fix git mismerge
I made a mistaking in merging the final commits for the devctl changes. This
adds the 'hushed' variable and has the correct dates for the manuals.

Pointy hat to: imp
2021-11-03 16:20:41 -06:00
Warner Losh
cc48eb70d1 vt: fix typo
Notifcation -> Notification
2021-11-03 16:12:55 -06:00
Warner Losh
4ac3d08a96 vt: Add devctl message for bells
Generate VT events when the bell beeps. When coupled with disabling the
bell,this allows custom bells to be rung when we'd otherwise beep.

Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D32656
2021-11-03 16:03:51 -06:00
Zhenlei Huang
7acd322ebe devfs.rules: Correctly unhide pf in vnet jails
Revision 9e9be081d8 introduced a new devfs rule devfsrules_jail_vnet. It
includes rule devfsrules_jail which include other rules. Unfortunately
devfs could not recursively parse the action include and thus
devfsrules_jail_vnet will expose all nodes.

PR:		255660
Reviewed by:	kp
Obtained from:	Gijs Peskens <gijs@peskens.net>
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D32814
2021-11-03 12:50:13 +01:00
Kirk McKusick
68bff4a07e Allow GEOM utilities to specify a -v option.
Geom utilities (geli(8), glabel(8), gmirror(8), gpart(8), gmirror(8),
gmountver(8), etc) all use the geom(8) utility as their back end
to process their commands and pass them into the kernel. Creating
a new utility requires no more than filling out a template describing
the commands and arguments that the utility supports. Consider the
specification for the very simple gmountver(8) utility:

struct g_command class_commands[] = {
	{ "create", G_FLAG_VERBOSE | G_FLAG_LOADKLD, NULL,
	    {
		G_OPT_SENTINEL
	    },
	    "[-v] prov ..."
	},
	{ "destroy", G_FLAG_VERBOSE, NULL,
	    {
		{ 'f', "force", NULL, G_TYPE_BOOL },
		G_OPT_SENTINEL
	    },
	    "[-fv] name"
	},
	G_CMD_SENTINEL
};

It has just two commands of its own: "create" and "destroy" along
with the four standard commands "list", "status", "load", and
"unload" provided by the base geom(8) utility. The base geom(8)
utility allows each command to use the G_FLAG_VERBOSE flag to specify
that a command should accept the -v flag and when the -v flag is
given the utility prints "Done." if the command completes successfully.
In the above example, both of the commands set the G_FLAG_VERBOSE,
so have the -v option available. In addition the "destroy" command
accepts the -f boolean flag to force the destruction.

If the "destroy" command wanted to also print out verbose information,
it would need to explicitly declare its intent by adding a line:

		{ 'v', "verbose", NULL, G_TYPE_BOOL },

Before this change, the geom utility would silently ignore the above
line in the configuration file, so it was impossible for the utility
to know that the -v flag had been set on the command. With this
change a geom command can explicitly specify a -v option with a
line as given above and handle it as it would any other option. If
both a -v option and G_FLAG_VERBOSE are specified for a command
then both types of verbose information will be output when that
command is run with -v.

MFC after:    1 week
Sponsored by: Netflix
2021-10-28 22:50:50 -07:00