dragonfly.git
5 years agoif_clone: Check cloner name to avoid duplicate in if_clone_attach()
Aaron LI [Sun, 5 Aug 2018 16:34:25 +0000 (00:34 +0800)]
if_clone: Check cloner name to avoid duplicate in if_clone_attach()

Change if_clone_attach() to check the cloner name instead of the pointer
to avoid duplicate, also to return EEXIST instead of panic.

5 years agoif_clone: Refactor out if_clone_{alloc,free}_unit() functions
Aaron LI [Sun, 5 Aug 2018 16:10:54 +0000 (00:10 +0800)]
if_clone: Refactor out if_clone_{alloc,free}_unit() functions

Refactor out if_clone_{alloc,free}_unit() functions from
if_clone_{create,destroy}() functions.

5 years agoif_clone: Remove useless code wrongly added in 84cb91c376f
Aaron LI [Sun, 5 Aug 2018 16:09:53 +0000 (00:09 +0800)]
if_clone: Remove useless code wrongly added in 84cb91c376f

The code was inteded to obtain the created interface and add an
interface group for it, which is a work in progress.

5 years agoFix up more files for the <net/if.h> / <net/if_var.h> split (fixes LINT64).
Sascha Wildner [Tue, 7 Aug 2018 17:55:33 +0000 (19:55 +0200)]
Fix up more files for the <net/if.h> / <net/if_var.h> split (fixes LINT64).

5 years agodevelopment.7: Update repo creation command
Aaron LI [Tue, 7 Aug 2018 02:40:31 +0000 (10:40 +0800)]
development.7: Update repo creation command

Reported-by: resolution (on IRC)
5 years agodrm: Sync drm_read() with Linux 4.7.10
François Tigeot [Sun, 5 Aug 2018 15:07:46 +0000 (17:07 +0200)]
drm: Sync drm_read() with Linux 4.7.10

This should fix various issues related to multithreaded races
and make the drm subsystem more robust.

5 years agoif_clone: Fix if_clone_destroy() with renamed cloned interface
Aaron LI [Sat, 4 Aug 2018 12:30:04 +0000 (20:30 +0800)]
if_clone: Fix if_clone_destroy() with renamed cloned interface

Since the interface can be renamed (SIOCSIFNAME), it's very wrong for
if_clone_destroy() to determine the unit number from interface name,
which has the following two serious problems:

(1) One may only change the unit number in the interface name, then
trying to destroy the interface will panic the system. e.g.,
% ifconfig tap0 create
% ifconfig tap0 name tap99999999
% ifconfig tap99999999 destroy
-> panic: if_clone_destroy: bit is already cleared

(2) The renamed interface cannot be destroyed anymore. e.g.,
% ifconfig tap0 create
% ifconfig tap0 name test
% ifconfig test destroy
-> ifconfig: SIOCIFDESTROY: Invalid argument

Fix the code to use the 'if_dunit' as the correct interface unit number.

Thanks to Jason A. Donenfeld <jason@zx2c4.com> and Brady OBrien
<brady.obrien128@gmail.com> for pointing out the above problem (1).

5 years agoif_clone: Refactor cloner lookup and unit extraction
Aaron LI [Sat, 4 Aug 2018 12:06:21 +0000 (20:06 +0800)]
if_clone: Refactor cloner lookup and unit extraction

Break down the old 'if_clone_lookup()' function into the following 3
functions:

- if_name2unit(): extract the unit number from the interface name.
  Obtained from FreeBSD and has fixes (disallow leading zeros; avoid
  unit overflow).

- if_clone_match(): check whether the cloner matches the interface name.

- new if_clone_lookup(): only lookup the cloner for the interface name.

5 years agoif_clone: Remove unneeded "ifc_namelen" from "struct if_clone"
Aaron LI [Sat, 4 Aug 2018 12:13:39 +0000 (20:13 +0800)]
if_clone: Remove unneeded "ifc_namelen" from "struct if_clone"

The "strlen(ifc_name)" is used instead.

5 years agoif_clone: Move "struct if_clonereq" over from <net/if.h>
Aaron LI [Thu, 21 Jun 2018 00:36:00 +0000 (08:36 +0800)]
if_clone: Move "struct if_clonereq" over from <net/if.h>

The "if_clonereq" struct is __BSD_VISIBLE and is only used by ifconfig(8)
userland tool (via searching "if_clonereq" in the dports grok), so it's
safe to move it to <net/if_clone.h> to be clearer.

5 years agoif_clone: Refactor if_clone_create()
Aaron LI [Fri, 22 Jun 2018 13:47:22 +0000 (21:47 +0800)]
if_clone: Refactor if_clone_create()

In the wildcard case (the caller passes the interface name without
a unit number), if_clone_create() should update the passed name
parameter with the allocated unit number in order to make the caller
know the name of the cloned interface, e.g., ifconfig(8) compares
the passed and returned interface name.  Therefore the caller should
preserve enough space (given by the "len" parameter) to hold the full
interface name.  This shouldn't be a problem since the caller generally
use the "struct if_clonereq" which has enough space for the name.

For the name update code, use simple and clear strlcpy() to replace the
hack with a for loop and obscure snprintf(), and return ENOSPC instead
of panic.

Simplify the ifnet lock a bit.

5 years agoif_clone: Explicitly include <sys/eventhandler.h>
Aaron LI [Tue, 20 Mar 2018 08:11:46 +0000 (16:11 +0800)]
if_clone: Explicitly include <sys/eventhandler.h>

Eventhandler is used there, so include the <sys/eventhandler.h> header
explicitly.

Minor style updates.

5 years agoif_clone: Fix if_clone_event invocation
Aaron LI [Thu, 21 Jun 2018 00:42:16 +0000 (08:42 +0800)]
if_clone: Fix if_clone_event invocation

As the parameter passed to the "if_clone_event" handler indicates, this
event should be triggered when a new interface cloner is *attached*,
rather than when a clone interface is created.  (Based on FreeBSD)

Update the eventhandler.9 man page accordingly.

5 years agoetc/login.conf: Fix COPYRIGHT file path
Aaron LI [Sun, 5 Aug 2018 02:40:46 +0000 (10:40 +0800)]
etc/login.conf: Fix COPYRIGHT file path

5 years agoMakefile.inc1: Print more variables on error
Aaron LI [Fri, 15 Jun 2018 05:01:54 +0000 (13:01 +0800)]
Makefile.inc1: Print more variables on error

Print the .MAKE.MODE, PATH, MAKESYSPATH, MAKEOBJDIRPREFIX, DESTDIR,
SHELL, .SHELL, .MAKE.MAKEFILES, and .PATH variables on error.
(Based on FreeBSD: share/mk/{local,meta}.sys.mk)

5 years agoifconfig(8): Use atexit() to ensure printing interface name
Aaron LI [Fri, 22 Jun 2018 13:23:25 +0000 (21:23 +0800)]
ifconfig(8): Use atexit() to ensure printing interface name

The ifconfig program may not exit at the end of its main() function,
so use atexit(printifnamemaybe) to ensure the interface name (e.g.,
newly cloned but with wildcard name) is printed on exit.
(Taken from FreeBSD)

Use "return (0)" instead of "exit(0)" in the main() function.

Minor whitespace updates.

5 years agoifconfig(8): Sync with FreeBSD a bit and various cleanups
Aaron LI [Sat, 24 Mar 2018 08:56:39 +0000 (16:56 +0800)]
ifconfig(8): Sync with FreeBSD a bit and various cleanups

* Sync ifconfig.c a bit with FreeBSD; replace several warnx() with
  errx(), and improve error messages a bit.

* Remove unnecessary exit() after Perror().

* Sync if_clone.c with FreeBSD.

* Add inclusion guard to ifconfig.h.

* Make iseq() a static function for ifieee80211.c and regdomain.c,
  replacing the duplicate definitions of it; and use iseq()
  consistently to replace strncasecmp() and strcasecmp().

* Move "struct ident" from regdomain.c to regdomain.h, and add and use
  "enum IdentType".

* Various whitespace cleanups.

* Cleanup header file inclusion: remove duplicates, and reorder a bit.

* Fix various signed vs. unsigned comparisons.

* Fix some compilation warnings, and raise WARNS to 3.

5 years agoifconfig(8): Default to AF_LOCAL sockets for non-family-specific operations
Aaron LI [Fri, 23 Mar 2018 01:40:57 +0000 (09:40 +0800)]
ifconfig(8): Default to AF_LOCAL sockets for non-family-specific operations

This allows the query operations to work in non-IPv4 jails, as will be necessary
in a future possible non-INET networking.

Obtained-from: FreeBSD (r18964)

5 years agoifconfig(8): Use strlcpy() instead of strncpy()
Aaron LI [Fri, 23 Mar 2018 01:37:13 +0000 (09:37 +0800)]
ifconfig(8): Use strlcpy() instead of strncpy()

5 years agoifconfig(8): Use nitems() consistently
Aaron LI [Tue, 20 Mar 2018 07:45:43 +0000 (15:45 +0800)]
ifconfig(8): Use nitems() consistently

5 years ago<net/if_var.h>: Clean up unused forward declaration
Aaron LI [Tue, 20 Mar 2018 08:15:42 +0000 (16:15 +0800)]
<net/if_var.h>: Clean up unused forward declaration

Also remove the inclusion of an unnecessary header <sys/systm.h>.

5 years ago<net/if.h>: Do not include <net/if_var.h> for _KERNEL
Aaron LI [Tue, 20 Mar 2018 08:04:41 +0000 (16:04 +0800)]
<net/if.h>: Do not include <net/if_var.h> for _KERNEL

* Clean up an ancient leftover: do not include <net/if_var.h> from <net/if.h>
  for kernel stuffs.

* Adjust various files to include the necessary <net/if_var.h> header.

NOTE:
I have also tested removing the inclusion of <net/if.h> from <net/if_var.h>,
therefore add <net/if.h> inclusion for those files that need it but only
included <net/if_var.h>.  For some files, the header inclusion orderings are
also adjusted.

5 years agopc64 - If appropriate, determine TSC frequency via CPUID.
Imre Vadász [Sat, 4 Aug 2018 15:09:26 +0000 (17:09 +0200)]
pc64 - If appropriate, determine TSC frequency via CPUID.

On Intel systems with Skylake and newer CPUs, and on modern Atom CPUs this
avoids the ca. 200ms TSC calibration process at the beginning of booting.

On most modern Intel CPUs the TSC frequency can be determined via CPUID
information. For the most modern generations this is quite well documented.
If the CPUID information doesn't directly specify the "crystal clock",
we use the frequency values given in Intel's "Software Developer's Manual"
for the different cpu variants.

Since the "crystal clock" seems to exactly match the HPET frequency that we
use in the calibration, this method should be at least as good as our
calibration procedure.

Setting the tunable hw.tsc_ignore_cpuid=1 forces the kernel to calibrate
the TSC if it would otherwise just use the CPUID information.

5 years agoif_tap: Interface type should be IFT_ETHER (2)
Aaron LI [Sat, 4 Aug 2018 14:06:32 +0000 (22:06 +0800)]
if_tap: Interface type should be IFT_ETHER (2)

Ooops, forgot to include the necessary header <net/if_types.h> in the
last commit.

5 years agoif_tap: Interface type should be IFT_ETHER
Aaron LI [Sat, 4 Aug 2018 13:07:04 +0000 (21:07 +0800)]
if_tap: Interface type should be IFT_ETHER

5 years agocorepower - Add support for Platform Energy Counter.
Imre Vadász [Sat, 4 Aug 2018 08:58:17 +0000 (10:58 +0200)]
corepower - Add support for Platform Energy Counter.

5 years agotun.4: Do not mention tunoutput() anymore
Aaron LI [Fri, 3 Aug 2018 12:10:56 +0000 (20:10 +0800)]
tun.4: Do not mention tunoutput() anymore

The tunoutput() function was renamed to be tunifoutput(), and it's an
internal function and doesn't provide useful information here.

5 years agodevfs: Minor style fixes
Aaron LI [Fri, 3 Aug 2018 12:09:19 +0000 (20:09 +0800)]
devfs: Minor style fixes

5 years agofdisk, gpt - Support trim on recent kernels
Matthew Dillon [Wed, 1 Aug 2018 21:38:34 +0000 (14:38 -0700)]
fdisk, gpt - Support trim on recent kernels

* Recent kernels removed the 'trim' sysctls.  Devices now allow trim by
  default.

* Fix the fdisk -E option to no longer try to use the sysctls.

* Add trim support to gpt init (-E).

* Fix swapon -e, change option to -E to match gpt and fdisk
  (-e still supported and does the same thing).

5 years agodrm: Sync drm_bufs.c with Linux 4.7.10
François Tigeot [Wed, 1 Aug 2018 19:27:14 +0000 (21:27 +0200)]
drm: Sync drm_bufs.c with Linux 4.7.10

5 years agohammer2 - Add destroy-inum directive
Matthew Dillon [Wed, 1 Aug 2018 17:14:46 +0000 (10:14 -0700)]
hammer2 - Add destroy-inum directive

* Add support for destroying screwed up inodes (e.g. inodes with CRC
  failures and such).

  hammer2 -s filesystem destroy-inum inode_number

  This will attempt to destroy an inode number without reading it,
  allowing the removal of dead inodes from a corrupted filesystem.

* This is similar to 'hammer2 destroy path', which destroys dead
  directory entries, but acts on the inode instead of on the
  directory entry.

5 years agodrm: simplify authentication management
François Tigeot [Tue, 31 Jul 2018 21:04:04 +0000 (23:04 +0200)]
drm: simplify authentication management

5 years agoif_tap: Remove the unnecessary forward declaration in if_tap.h
Aaron LI [Tue, 31 Jul 2018 11:59:45 +0000 (19:59 +0800)]
if_tap: Remove the unnecessary forward declaration in if_tap.h

5 years agoif_tun: Add TUNGIFNAME ioctl to get the interface name
Aaron LI [Tue, 31 Jul 2018 11:47:37 +0000 (19:47 +0800)]
if_tun: Add TUNGIFNAME ioctl to get the interface name

This ioctl helps to get the name of the network interface associated
with the tun control device via its file descriptor.  One generally
obtains such a file descriptor by opening the tun autocloner (i.e.,
/dev/tun).  While the devname(3) or fdevname(3) functions can be used
to determine the name of the actually created tun device, but there is
no easy way to get the name of the associated network interface, which
is though initially the same as the device name but can be renamed.

Bump __DragonFly_version and update tun.4 man page.

See also the relevant Linux patch that added TUNGETIFF to tun:
https://lists.linuxfoundation.org/pipermail/virtualization/2008-August/011546.html

5 years agoif_tun: Clean up tunioctl()
Aaron LI [Tue, 31 Jul 2018 11:43:48 +0000 (19:43 +0800)]
if_tun: Clean up tunioctl()

Introduce a variable 'caddr_t data' to make code cleaner.  Also improve
the switch flow a bit.

Based on: if_tap.c

5 years agodrm: More Linux 4.7.10 synchronization
François Tigeot [Mon, 30 Jul 2018 20:44:20 +0000 (22:44 +0200)]
drm: More Linux 4.7.10 synchronization

* Add missing event handling code

* Sync or add a few drm_fops.c functions

* Remove unneeded kqueue locking

5 years agohammer2 - Do not assert when shifting around error'd BREFs
Matthew Dillon [Mon, 30 Jul 2018 19:04:49 +0000 (12:04 -0700)]
hammer2 - Do not assert when shifting around error'd BREFs

* When adjusting the radix tree and shifting around BREFs, do not
  assert if the related chain has cached an error (such as a CRC
  error).  The BREF itself can still be moved.

5 years agoinstall(1): Fix building on release and older systems.
Sascha Wildner [Sat, 28 Jul 2018 12:48:16 +0000 (14:48 +0200)]
install(1): Fix building on release and older systems.

While here, add a comment about this to mtree(8)'s Makefile too.

5 years agoinstall(1): Add a -l flag for creating hard or soft links
François Tigeot [Sat, 28 Jul 2018 06:50:52 +0000 (08:50 +0200)]
install(1): Add a -l flag for creating hard or soft links

* This flag was originally introduced in NetBSD in March 1997 and then added
  to FreeBSD in January 2013.

* It will make it easier to update dports(7) from FreeBSD ports.

* The previous DragonFly-specific -l flag was no longer used.

Obtained-from: NetBSD and FreeBSD

5 years agosys/vfs/autofs: Make {test,nlookup}_fs_root() return bool
Tomohiro Kusumi [Thu, 26 Jul 2018 18:18:25 +0000 (11:18 -0700)]
sys/vfs/autofs: Make {test,nlookup}_fs_root() return bool

Change return type of DragonFly specific utility functions for
triggering (very different from FreeBSD, NetBSD and OpenBSD).

5 years agosys/vfs/autofs: Cleanup
Tomohiro Kusumi [Thu, 26 Jul 2018 18:14:09 +0000 (11:14 -0700)]
sys/vfs/autofs: Cleanup

5 years agoMove jail staffs from <net/if.h> and <netinet/in.h> to <sys/jail.h>
Aaron LI [Tue, 20 Mar 2018 07:52:54 +0000 (15:52 +0800)]
Move jail staffs from <net/if.h> and <netinet/in.h> to <sys/jail.h>

* <net/if.h>: Move out prison_if() function prototype to <sys/jail.h>

* <netinet/in.h>: Move out prison_replace_wildcards() and prison_remote_ip()
  function prototypes to <sys/jail.h>

* Include <sys/jail.h> header for those files in need of it

Obtained-from: FreeBSD (r72786)

5 years agokernel: Use nitems() from <sys/param.h> instead of custom define
Aaron LI [Tue, 20 Mar 2018 07:48:55 +0000 (15:48 +0800)]
kernel: Use nitems() from <sys/param.h> instead of custom define

Since <sys/param.h> is already included in these files.

5 years agodisklabel64(8): Remove an obsolete comment
Aaron LI [Tue, 24 Jul 2018 01:22:59 +0000 (09:22 +0800)]
disklabel64(8): Remove an obsolete comment

Also consistently use the locally defined streq() function.

5 years agosys/gpt.h: Add new entry types and CTASSERT
Aaron LI [Tue, 24 Jul 2018 01:20:14 +0000 (09:20 +0800)]
sys/gpt.h: Add new entry types and CTASSERT

Obtained-from: FreeBSD

5 years agomtree(8): Replace our mtree(8) with NetBSD's version.
Sascha Wildner [Wed, 25 Jul 2018 17:41:01 +0000 (19:41 +0200)]
mtree(8): Replace our mtree(8) with NetBSD's version.

This is a re-commit of 2f6d3139ecacca3533517516db002cf436f78918 with
some bootstrap fixes added so that it builds on systems that do not
yet have strsvis() and a couple of other functions in their libc.

6 years agobsd-family-tree: announce NetBSD 8.0
Eitan Adler [Sun, 11 Mar 2018 02:19:27 +0000 (02:19 +0000)]
bsd-family-tree: announce NetBSD 8.0

5 years agodrm: Partial sync with Linux 4.7.10
François Tigeot [Tue, 24 Jul 2018 21:21:05 +0000 (23:21 +0200)]
drm: Partial sync with Linux 4.7.10

* Implement O_NONBLOCK support on /dev/dri/cardN

* Use filp->private_data in more places

* Add locking directives

5 years agoena.4: Add a missing space.
Sascha Wildner [Tue, 24 Jul 2018 18:51:53 +0000 (20:51 +0200)]
ena.4: Add a missing space.

5 years agosys/vfs/autofs: Cleanups
Tomohiro Kusumi [Sun, 22 Jul 2018 16:06:47 +0000 (09:06 -0700)]
sys/vfs/autofs: Cleanups

5 years agoopenssh: Fix some merging mistakes I made.
Sascha Wildner [Tue, 24 Jul 2018 11:40:42 +0000 (13:40 +0200)]
openssh: Fix some merging mistakes I made.

5 years agoMerge branch 'vendor/OPENSSH'
Sascha Wildner [Tue, 24 Jul 2018 11:25:57 +0000 (13:25 +0200)]
Merge branch 'vendor/OPENSSH'

5 years agoClean up the OpenSSH vendor branch a tiny bit.
Sascha Wildner [Tue, 24 Jul 2018 10:43:52 +0000 (12:43 +0200)]
Clean up the OpenSSH vendor branch a tiny bit.

5 years agoopenpam: Sync OpenPAM modules a bit with FreeBSD.
Sascha Wildner [Tue, 24 Jul 2018 07:55:49 +0000 (09:55 +0200)]
openpam: Sync OpenPAM modules a bit with FreeBSD.

Not much to see here, except some bugfixes. Oh, and ed25519 support
in pam_ssh.

5 years agoRevert "mtree(8): Replace our mtree(8) with NetBSD's version."
Sascha Wildner [Mon, 23 Jul 2018 11:26:33 +0000 (13:26 +0200)]
Revert "mtree(8): Replace our mtree(8) with NetBSD's version."

This reverts commit 2f6d3139ecacca3533517516db002cf436f78918.

The upgrade breaks compilation of mtree on a release box during the
bootstrap-tools stage. I don't want to keep this broken until I've
found a good solution.

5 years agoboot/efi: Sync our TianoCore EDK II headers with the UDK2018 branch.
Sascha Wildner [Mon, 23 Jul 2018 11:00:23 +0000 (13:00 +0200)]
boot/efi: Sync our TianoCore EDK II headers with the UDK2018 branch.

5 years agodrm: Reduce drm_bufs.c differences with Linux 4.7.10
François Tigeot [Sun, 22 Jul 2018 20:37:13 +0000 (22:37 +0200)]
drm: Reduce drm_bufs.c differences with Linux 4.7.10

5 years agomtree(8): Replace our mtree(8) with NetBSD's version.
Sascha Wildner [Sun, 22 Jul 2018 14:57:40 +0000 (16:57 +0200)]
mtree(8): Replace our mtree(8) with NetBSD's version.

Some of its files will be used by other stuff we want to upgrade or
bring in, such as install(1) and makefs(8).

Since mtree(8) is a bootstrap tool and I want this to be painless,
I've imported some other source files that mtree(8) uses, such as
from mknod(1), which we don't have, as part of mtree(8).

5 years agokernel/ena: Hook the ena(4) driver into the build.
Sascha Wildner [Sun, 22 Jul 2018 13:32:49 +0000 (15:32 +0200)]
kernel/ena: Hook the ena(4) driver into the build.

5 years agokernel/ena: Port the ena(4) driver to DragonFly.
Brad Hoffman [Wed, 18 Jul 2018 14:41:03 +0000 (14:41 +0000)]
kernel/ena: Port the ena(4) driver to DragonFly.

This work is based on an initial (non-building) patch by swildner
and also contains work by dillon. Special thanks to Colin Percival
and sephe for their help and assistance.

The driver works but should still be considered experimental.

Useful dports are:

devel/awscli
net/bsdec2-image-upload
sysutils/ec2-scripts

5 years agokernel: Bring in FreeBSD's ena(4) driver unchanged and unhooked.
Sascha Wildner [Wed, 18 Jul 2018 16:54:07 +0000 (18:54 +0200)]
kernel: Bring in FreeBSD's ena(4) driver unchanged and unhooked.

This is a driver for Amazon's Elastic Network Adapter family,
for EC2 instances that support it.

5 years agodrm: Sync a few bits with Linux 4.7.10
François Tigeot [Sat, 21 Jul 2018 16:20:06 +0000 (18:20 +0200)]
drm: Sync a few bits with Linux 4.7.10

5 years agodrm: dev->dma_lock doesn't exist
François Tigeot [Sat, 21 Jul 2018 16:02:58 +0000 (18:02 +0200)]
drm: dev->dma_lock doesn't exist

5 years agodrm/linux: add agp_backend.h
François Tigeot [Sat, 21 Jul 2018 15:01:58 +0000 (17:01 +0200)]
drm/linux: add agp_backend.h

5 years agokernel/icu: Fix a typo.
Sascha Wildner [Sat, 21 Jul 2018 11:35:07 +0000 (13:35 +0200)]
kernel/icu: Fix a typo.

5 years agosysctl_add_oid.9: Improve a bit.
Sascha Wildner [Sat, 21 Jul 2018 11:07:48 +0000 (13:07 +0200)]
sysctl_add_oid.9: Improve a bit.

Add missing .Nm and fix the arguments of 4 macros. Note that we can't
really have them as being of the type of the actual arg until we fix
a number of int to uintmax_t in the sysctl code itself.

5 years agovmstat: Add -o option to report objcache usage.
Sepherosa Ziehau [Sat, 21 Jul 2018 08:59:14 +0000 (16:59 +0800)]
vmstat: Add -o option to report objcache usage.

5 years agombuf: Reduce objcache name verbosity.
Sepherosa Ziehau [Sat, 21 Jul 2018 08:58:49 +0000 (16:58 +0800)]
mbuf: Reduce objcache name verbosity.

5 years agokernel: Port some remaining, yet unused, *_TRYLOCK() functions.
Sascha Wildner [Sat, 21 Jul 2018 08:50:11 +0000 (10:50 +0200)]
kernel: Port some remaining, yet unused, *_TRYLOCK() functions.

This is just for cleanup and obviously changes nothing.

5 years agokernel: Fix some wrong porting of *_TRYLOCK() macros.
Sascha Wildner [Sat, 21 Jul 2018 08:45:29 +0000 (10:45 +0200)]
kernel: Fix some wrong porting of *_TRYLOCK() macros.

Of these three, only CHN_TRYLOCK() is used in actual, active code,
but it is in the SNDCTL_DSP_SYNCSTART ioctl which in turn is not
used in base or in dports.

ARCMSR_LOCK_TRY() and PCM_TRYLOCK() are not used at all.

5 years agokernel/drm: Use more straightforward lockmgr_try().
Sascha Wildner [Sat, 21 Jul 2018 08:36:36 +0000 (10:36 +0200)]
kernel/drm: Use more straightforward lockmgr_try().

5 years agokernel/lockmgr: Add lockmgr_try().
Sascha Wildner [Sat, 21 Jul 2018 08:28:17 +0000 (10:28 +0200)]
kernel/lockmgr: Add lockmgr_try().

It just adds LK_NOWAIT to the flags and returns whether the
lock was obtained.

It is similar to other functions such as spin_trylock() or
FreeBSD's mtx_trylock() and can be used to port the latter.

Note that like these functions, it returns TRUE if successful,
while lockmgr() returns 0 if successful. This difference was
the source of minor confusion and porting mistakes in the past.
In fact, our driver porting document also didn't point out this
difference. I will fix some of these little issues in a separate
commit.

5 years agoobjcache: Add sysctl to expose objcache statistics.
Sepherosa Ziehau [Sat, 21 Jul 2018 08:07:13 +0000 (16:07 +0800)]
objcache: Add sysctl to expose objcache statistics.

5 years agodisklabel64.8: Fix several "disklabel" to be "disklabel32"
Aaron LI [Sat, 21 Jul 2018 05:07:56 +0000 (13:07 +0800)]
disklabel64.8: Fix several "disklabel" to be "disklabel32"

And improve a sentence.

5 years agoUpdate the pciconf(8) database.
Sascha Wildner [Fri, 20 Jul 2018 12:11:54 +0000 (14:11 +0200)]
Update the pciconf(8) database.

June 29, 2018 snapshot from https://pci-ids.ucw.cz

5 years agokernel/sysctl: Add handling of uint32_t.
Sascha Wildner [Fri, 20 Jul 2018 11:38:22 +0000 (13:38 +0200)]
kernel/sysctl: Add handling of uint32_t.

5 years agorc: Bring in a simple mechanism to run rc scripts only once.
Brad Hoffman [Wed, 18 Jul 2018 14:41:03 +0000 (14:41 +0000)]
rc: Bring in a simple mechanism to run rc scripts only once.

The basic mechanism is: If /firstboot exists, rc will also run all
scripts that have the "firstboot" keyword, then delete /firstboot.

This is a simpler version of FreeBSD's work. Specifically, we hardcode
the firstboot sentinel's name to /firstboot and we also remove it a
bit more simply because we assume that at the end of /etc/rc, root is
R/W.

This mechanism is used for example by sysutils/ec2-scripts and is in
preparation for the upcoming ena(4) driver import.

Based-on: FreeBSD

5 years agoif_tun: Allow IP packets of length TUNMRU with TUNSIFHEAD set
Aaron LI [Tue, 17 Jul 2018 11:57:55 +0000 (19:57 +0800)]
if_tun: Allow IP packets of length TUNMRU with TUNSIFHEAD set

Obtained-from: FreeBSD (revision 300205)

5 years agoif_tun: Raise maximum MTU to be 65535 bytes
Aaron LI [Thu, 5 Jul 2018 06:08:43 +0000 (14:08 +0800)]
if_tun: Raise maximum MTU to be 65535 bytes

This is used, for example, by packetdrill to test with MTU's up to the
maximum value.

Taken-from: FreeBSD (revision 300603)

5 years agoif_tun: Disallow change network device type
Aaron LI [Mon, 9 Jul 2018 04:45:24 +0000 (12:45 +0800)]
if_tun: Disallow change network device type

Disallow ioctl(2) to change the network device type of tun(4).
Otherwise, page faults and panics can happen when access uninitialized
fields in the "struct ifnet" which are specific to the network device
type.

Obtained-from: FreeBSD (revision 326362)

5 years agoif_tun: Implement interface clone support
Aaron LI [Sun, 8 Jul 2018 13:07:20 +0000 (21:07 +0800)]
if_tun: Implement interface clone support

Now 'ifconfig tunX create' and 'ifconfig tunX destroy' work.

The tun device will be automatically destroyed when being closed,
except for the manually created tun device/interface by
'ifconfig tunX create', similar to the tap(4) device.

This interface clone support is based on the if_tap device.

5 years agoif_tun: Better name interface-related functions
Aaron LI [Sun, 8 Jul 2018 11:55:36 +0000 (19:55 +0800)]
if_tun: Better name interface-related functions

Rename interface-related functions to be 'tunifxxx', and reorder a
bit to better group them.

Tweak the styles and improve debug messages a bit.

5 years agoif_tun: Add sysctl net.link.tun.{refcnt,debug}
Aaron LI [Sun, 8 Jul 2018 02:17:20 +0000 (10:17 +0800)]
if_tun: Add sysctl net.link.tun.{refcnt,debug}

Add read-only sysctl net.link.tun.refcnt to show the number of opened
devices.

Add sysctl net.link.tun.debug to be a alias to debug.if_tun_debug.

5 years agoif_tun: Support module load and unload
Aaron LI [Sun, 8 Jul 2018 01:43:12 +0000 (09:43 +0800)]
if_tun: Support module load and unload

Track the created tun devices in a list, and record the number of opened
tun devices.  Destroy all tun devices when unloading the module.

Mainly based on if_tap.

5 years agoif_tun: Add "cdev_t tun_dev" to tun_softc struct
Aaron LI [Sat, 7 Jul 2018 15:21:18 +0000 (23:21 +0800)]
if_tun: Add "cdev_t tun_dev" to tun_softc struct

Similar to if_tap, save the tun device in the tun_softc struct.

5 years agoif_tun: Use pointer to ifnet in tun_softc struct
Aaron LI [Sat, 7 Jul 2018 15:16:19 +0000 (23:16 +0800)]
if_tun: Use pointer to ifnet in tun_softc struct

Use a pointer to the ifnet struct in the tun_softc struct, instead of
embedding a full ifnet struct in it.  (similar to FreeBSD's)

Use if_alloc() to allocate the ifnet struct.

5 years agoif_tun: Update tun.4 man page to match the code
Aaron LI [Tue, 17 Jul 2018 11:04:12 +0000 (19:04 +0800)]
if_tun: Update tun.4 man page to match the code

Mainly follow FreeBSD's tun.4, refer to NetBSD's tun.4, and with my own
minor adjustments.

5 years agoif_tun: Some small tweaks and cleanups
Aaron LI [Sat, 7 Jul 2018 12:49:04 +0000 (20:49 +0800)]
if_tun: Some small tweaks and cleanups

* Consistently use the TUN define instead of "tun".

* Use variable "sc" instead of "tp" to refer to "struct tun_softc".

* Use variable "ifp" (struct ifnet *) to make code more readable.

* Static the bitmap variable.

* Various style tweaks.

5 years agoif_tap: Restore SIOCGIFFLAGS, SIOC[GS]IFADDR ioctls for tapioctl()
Aaron LI [Thu, 19 Jul 2018 07:04:35 +0000 (15:04 +0800)]
if_tap: Restore SIOCGIFFLAGS, SIOC[GS]IFADDR ioctls for tapioctl()

These ioctls allow basic control of the network interface via the device
file (/dev/tapX).  For example, our vke(4) device currently uses the
'SIOCGIFADDR' ioctl.

5 years agolibc - MFC resolver fix
Matthew Dillon [Tue, 17 Jul 2018 18:37:20 +0000 (11:37 -0700)]
libc - MFC resolver fix

* Allows intermediate domain names with an underscore.

* Fixes lookups of 'www.office.com' and 'www.newegg.com', and
  probably other domains.

Reported-by: kerma
Diagnosed-by: kerma, tautology
5 years agoRevert "if_tap: Get rid of arpcom struct from tap_softc struct"
Aaron LI [Tue, 17 Jul 2018 09:58:35 +0000 (17:58 +0800)]
Revert "if_tap: Get rid of arpcom struct from tap_softc struct"

This reverts commit 78e1ab4a8fc0074361116dedb55e6dc02baea351, with
minor adjustments to reduce the diff.

Thank sephe for pointint out the problem with that commit, which
breaks the 'ether_ifattach()' as well as some IPv6 stuffs that
assume the existence of 'arpcom'.

5 years agoioctl.9: Remove some obsolete commented out info.
Sascha Wildner [Tue, 17 Jul 2018 09:23:47 +0000 (11:23 +0200)]
ioctl.9: Remove some obsolete commented out info.

5 years agoif_tap: Disallow change network device type
Aaron LI [Tue, 17 Jul 2018 06:29:44 +0000 (14:29 +0800)]
if_tap: Disallow change network device type

Disallow ioctl(2) to change the network device type of tap(4).
Otherwise, page faults and panics can happen when access uninitialized
fields in the "struct ifnet" which are specific to the network device
type.

Obtained-from: FreeBSD (revision 326362)

5 years agoif_tap: Add TAPGIFNAME ioctl to get interface name
Aaron LI [Fri, 13 Jul 2018 07:43:07 +0000 (15:43 +0800)]
if_tap: Add TAPGIFNAME ioctl to get interface name

This is a convenient shortcut to obtain the network interface name using
file descriptor for character device.

This ioctl is obtained from FreeBSD (revision 182880) which was further
obtained from NetBSD.  This ioctl is used by softwares such as QEMU.

Bump __DragonFly_version and update tap.4 man page.

5 years agoif_tap: Remove the broken vmnet support
Aaron LI [Fri, 13 Jul 2018 05:04:35 +0000 (13:04 +0800)]
if_tap: Remove the broken vmnet support

The vmnet feature provided by tap(4) was intended to be used by the
VMWare port that runs as the server side to communicate with its clients.
However, our tap(4) was updated a lot in the past but left the vmnet
function broken.  In addition, we don't have the VMWare server and thus
the vmnet function isn't needed in the foreseeable future.
So just remove it.

Discussed-with: swildner, sephe

5 years agoif_tap: Update tap.4 man page to match the code
Aaron LI [Mon, 9 Jul 2018 10:53:42 +0000 (18:53 +0800)]
if_tap: Update tap.4 man page to match the code

Remove the description on FIONBIO ioctl since ours doesn't support it.

Mainly taken from FreeBSD, with some improvements.

5 years agoif_tap: Return error instead of system panic
Aaron LI [Sun, 8 Jul 2018 08:37:24 +0000 (16:37 +0800)]
if_tap: Return error instead of system panic

Return error when failed to create/find the device and to allocate
the interface struct, instead of system panic.

5 years agoif_tap: Remove redundant unit from tapcreate() and tun_softc
Aaron LI [Sun, 8 Jul 2018 07:16:56 +0000 (15:16 +0800)]
if_tap: Remove redundant unit from tapcreate() and tun_softc

The tap interface unit number is the same as minor number of the
associated tap device, so remove the redundant "unit" argument
from tapcreate() function as well as the "tap_unit" entry from
tun_softc struct.

Meanwhile, improve the debug messages.

5 years agoif_tap: Get rid of arpcom struct from tap_softc struct
Aaron LI [Sun, 8 Jul 2018 06:09:29 +0000 (14:09 +0800)]
if_tap: Get rid of arpcom struct from tap_softc struct

Remove the ancient arpcom struct from the tap_softc struct,
meanwhile introduce the "tap_ifp" member that points to the
interface (ifnet struct) associating with the tap device.

5 years agoif_tap: Destroy the autoclone device when unload module
Aaron LI [Sun, 8 Jul 2018 04:30:55 +0000 (12:30 +0800)]
if_tap: Destroy the autoclone device when unload module

Use destroy_autoclone_dev(), which replaces both devfs_clone_handler_del()
and devfs_clone_bitmap_uninit(), to destroy the autoclone device /dev/tap
when unload the module.

Without this fix, the autoclone device /dev/tap is left over when the
module is unloaded.