3 years agoinitrd: Rework build and install stages
Aaron LI [Sat, 24 Nov 2018 10:52:03 +0000 (18:52 +0800)]
initrd: Rework build and install stages

* Rewrite the Makefile to provide only the 'all' and 'install' targets.
  Do not separate the handling of the rescue tools and initrd image.
  Thus greatly simplify the whole logic.

  The 'all' target will build the rescue tools and initrd contents, and
  does not require root priviledge, while the 'install' target will
  install the rescue tools to the system, create the initrd image and
  install it.

* Update the top-level makefiles to call the new 'all' and 'install'.
  The 'buildworld' target now doesn't require root priviledge, same as
  before the refactoring in 9b724c0dcb2b9548a82d28d97e34375f64668669.

* Only provide the 'initrd' top-level target to keep it simple.  This
  target will install the rescue tools and initrd image built by the
  'buildworld', overwriting the existing ones.

* Clean up the nrelease/Makefile a bit, since 'installworld' will also
  install the rescue tools and initrd image in such a case.

* Update the mkinitrd.sh script a bit.

* Update the build(7) man page and clean up a bit.

Reviewed-by: swildner
3 years agorc.d/wpa_supplicant: Prefer the DPorts version for the moment
Aaron LI [Sun, 25 Nov 2018 09:39:41 +0000 (17:39 +0800)]
rc.d/wpa_supplicant: Prefer the DPorts version for the moment

We now also ship the wpa_supplicant from DPorts, which has several
important security fixes than the base one, so prefer the DPorts
wpa_supplicant if it exists for the moment.

This patch allows us to bring the base wpa_supplicant up-to-date and
switch back to it later without requiring users to modify their

3 years agobuild - Add security/wpa_supplicant to nrelease
Matthew Dillon [Sun, 25 Nov 2018 07:44:21 +0000 (23:44 -0800)]
build - Add security/wpa_supplicant to nrelease

* Add security/wpa_supplicant to the nrelease build.  This ensures
  that the latest wpa_supplicant is available on release.  The
  wpa_supplicant in the base system exists only to help bootstrap
  systems when the port is not installed.

3 years agokernel - Fix probable callout race
Matthew Dillon [Sun, 25 Nov 2018 07:39:15 +0000 (23:39 -0800)]
kernel - Fix probable callout race

* Fix a probable callout race in kern/kern_event.c.  It is possible
  for the callout to be requeued during teardown and for the
  structure to subsequently become corrupted.

  Manifests as 'stuck' processes (still ^C'able if PCATCH is flagged),
  and sleeps which do not expire.  Can be triggered by synth bulk runs.

* Increase maximum number of kqueue timers from 4096 to 65536.  This
  limit will have to be moved to uidinfo (but not in this commit).

3 years ago<sys/param.h>: Adjust __DragonFly_version.
Sascha Wildner [Sat, 24 Nov 2018 18:02:08 +0000 (19:02 +0100)]
<sys/param.h>: Adjust __DragonFly_version.

3 years agoUpdates for new 5.5 master. v5.5.0
Justin C. Sherrill [Fri, 23 Nov 2018 03:38:50 +0000 (22:38 -0500)]
Updates for new 5.5 master.

3 years agoinstaller: Add serial detection
Diederik de Groot [Sun, 14 Oct 2018 23:53:19 +0000 (01:53 +0200)]
installer: Add serial detection

- The installer script now asks for TERM type when in serial port console.
- Make sure dfui is not left running using trap/cleanup

3 years agotest: Attempt to fix vnodeinfo.c (2)
Antonio Huete Jimenez [Thu, 22 Nov 2018 19:15:11 +0000 (20:15 +0100)]
test: Attempt to fix vnodeinfo.c (2)

3 years agosio: Correct how DDB option is checked
Antonio Huete Jimenez [Thu, 22 Nov 2018 11:30:38 +0000 (12:30 +0100)]
sio: Correct how DDB option is checked

3 years agotest: Fix some debug programs
Antonio Huete Jimenez [Thu, 22 Nov 2018 09:16:48 +0000 (10:16 +0100)]
test: Fix some debug programs

3 years agotest: Remove no longer relevant ttyinfo.c
Antonio Huete Jimenez [Thu, 22 Nov 2018 09:16:30 +0000 (10:16 +0100)]
test: Remove no longer relevant ttyinfo.c

3 years agokernel: Move vnode_index to sys/vnode.h
Antonio Huete Jimenez [Wed, 21 Nov 2018 23:51:19 +0000 (00:51 +0100)]
kernel: Move vnode_index to sys/vnode.h

- This allows userland programs (test/debug) to use that structure.

3 years agokernel - Refactor inum stat data for sockets
Matthew Dillon [Wed, 21 Nov 2018 21:06:24 +0000 (13:06 -0800)]
kernel - Refactor inum stat data for sockets

* Assign a dummy inode number to all sockets.  We previously were
  only assigning a dummy inode number to unix domain sockets.  Use
  the new pcpu facility and store the inum in the socket structure.

* Rip out the old inode number assigner for unix domain sockets, it
  was using an atomic_fetchadd_long() on a global variable, introducing
  unnecessary SMP stalls.  And it was specific to unix domain sockets.
  The new facility is generic to all sockets and uses a pcpu data

3 years agokernel - Add uid, gid, and inum to stat data for pipes
Matthew Dillon [Wed, 21 Nov 2018 20:37:08 +0000 (12:37 -0800)]
kernel - Add uid, gid, and inum to stat data for pipes

* fstat(pipefd) now populations additional fields. uid, gid,
  and inum.  In-line with other BSDs and Linux.  Not sure why
  any program would use the inum field but... now its populated.

* Add an anonymous inode allocator to the pcpu structure.  No
  atomic ops required.  Basically just does:

  pipe->inum = gd->gd_anoninum++ * ncpus + gd->gd_cpuid + 2;

* Facility can be used for other things as needed.

Suggested-by: mjg
3 years agoinet: Recalculate the packet hash for IP encapsulation.
Sepherosa Ziehau [Tue, 20 Nov 2018 13:13:18 +0000 (21:13 +0800)]
inet: Recalculate the packet hash for IP encapsulation.

Some NICs, noticeably igb(4) and ix(4), calculate the packet hash
based on the encapsulated IP datagram instead of the outmost header.

Force packet hash recalculation using the outmost for encapsulated
packets; this is done on the encap_input() path, which leaves enough
room for us to utilize the NIC feature mentioned above.

Reported-by: dillon@
3 years agostf/gre: Make sure the input packet's hash is recalculated.
Sepherosa Ziehau [Tue, 20 Nov 2018 12:39:47 +0000 (20:39 +0800)]
stf/gre: Make sure the input packet's hash is recalculated.

3 years agokernel: Fix some -Wundef corner cases.
Sascha Wildner [Mon, 19 Nov 2018 18:07:35 +0000 (19:07 +0100)]
kernel: Fix some -Wundef corner cases.

When those modules were built outside buildkernel, NVN and NSNP would
not be defined, so provide some defaults.

3 years agoinet6: Set net.inet6.icmp6.nd6_onlink_ns_rfc4861 to 1 by default.
Sepherosa Ziehau [Mon, 19 Nov 2018 13:50:15 +0000 (21:50 +0800)]
inet6: Set net.inet6.icmp6.nd6_onlink_ns_rfc4861 to 1 by default.

It is almost required by contemporary INET6 deployment.

3 years agoinet6: Make non-prefix and directly reachable inet6 routes work (2).
Sepherosa Ziehau [Mon, 19 Nov 2018 13:45:30 +0000 (21:45 +0800)]
inet6: Make non-prefix and directly reachable inet6 routes work (2).

Generalize "non-prefix and directly reachable" inet6 routes lookup,
instead of specializing the ifa_rtrequest method as we did in

NOTE: net.inet6.icmp6.nd6_onlink_ns_rfc4861 MUST be on.

Reported-by: aly@
Tested-by: aly@
3 years agomtree(8): Bring in a fix from NetBSD.
Sascha Wildner [Mon, 19 Nov 2018 08:03:02 +0000 (09:03 +0100)]
mtree(8): Bring in a fix from NetBSD.

Thanks for sevan@netbsd for handling upstream.

3 years agoadd subdevice id 0x5260 for iwn 6035 series
Tobias Heilig [Mon, 29 Oct 2018 00:26:31 +0000 (01:26 +0100)]
add subdevice id 0x5260 for iwn 6035 series

3 years agokernel: Add -Wundef to our default kernel warning options.
Sascha Wildner [Sun, 18 Nov 2018 09:05:32 +0000 (10:05 +0100)]
kernel: Add -Wundef to our default kernel warning options.

It will warn when an undefined identifier is evaluated in an "#if"
directive and would be replaced with zero.

After the last such warnings were fixed in September, we can now do

3 years agokernel: Clean up the warning flags a bit.
Sascha Wildner [Sun, 18 Nov 2018 09:02:31 +0000 (10:02 +0100)]
kernel: Clean up the warning flags a bit.

We had both -Winline and -Wno-inline.

3 years agofetch.9: Document fuwordadd{32,64}().
Sascha Wildner [Sat, 17 Nov 2018 20:25:37 +0000 (21:25 +0100)]
fetch.9: Document fuwordadd{32,64}().

3 years agodhcpcd.8: Comment out some info on /dev management.
Sascha Wildner [Sat, 17 Nov 2018 18:42:35 +0000 (19:42 +0100)]
dhcpcd.8: Comment out some info on /dev management.

It is not configured in DragonFly.

While here, fix some trailing whitespace and an .Xr misuse.

3 years agoresolvconf.conf.5: Fix some mandoc warnings.
Sascha Wildner [Sat, 17 Nov 2018 18:47:57 +0000 (19:47 +0100)]
resolvconf.conf.5: Fix some mandoc warnings.

3 years agoRevert "drm/linux: Fix vmap()"
François Tigeot [Sat, 17 Nov 2018 13:41:21 +0000 (14:41 +0100)]
Revert "drm/linux: Fix vmap()"

This reverts commit c9f83a72b5c7c2f29b40b404aa63767b20a7422c.

It introduced instability on Broadwell platforms.

Reported-by: Daniel Bilik
3 years agorc.d/dhcpcd: Fix passing of extra arguments
Aaron LI [Sat, 17 Nov 2018 02:28:22 +0000 (10:28 +0800)]
rc.d/dhcpcd: Fix passing of extra arguments

Before this fix, 'dhcpcd' ignores extra arguments when calling
'run_rc_command()', which causes '/etc/rc.d/dhcpcd restart <ifname>' to
fail.  Fix this issue by passing all arguments to 'run_rc_command()'.

3 years agosshlockout.8: Use a display instead of .Cd in the SYNOPSIS.
Sascha Wildner [Fri, 16 Nov 2018 16:26:01 +0000 (17:26 +0100)]
sshlockout.8: Use a display instead of .Cd in the SYNOPSIS.

.Cd is only for kernel configuration options.

3 years agoAdd "device uether" to various manual pages' synopses.
Sascha Wildner [Fri, 16 Nov 2018 12:15:07 +0000 (13:15 +0100)]
Add "device uether" to various manual pages' synopses.

It is needed to be compiled in.

Reported-by: aly
3 years agorc.d/ip6addrctl: Fix REQUIRE and afexists()
Aaron LI [Fri, 16 Nov 2018 03:01:28 +0000 (11:01 +0800)]
rc.d/ip6addrctl: Fix REQUIRE and afexists()

* DragonFly doesn't has the 'FILESYSTEMS' rc target.

* I forgot to implement the 'afexists()' function when import this.
  However, FreeBSD's 'afexists()' relies 'kern.features.<feature>'
  sysctls to determine whether the address family is supported, but
  DragonFly doesn't allow this.  So come up with a little 'has_inet6()'
  function for this rc script use only.

Reported-by: Thomas Nikolajsen <thomas.nikolajsen@mail.dk>
3 years agoexamples: Fix build
Antonio Huete Jimenez [Thu, 15 Nov 2018 19:39:59 +0000 (20:39 +0100)]
examples: Fix build

- While here hook 'firmware' to the main Makefile

3 years agosyscons - Increase static buffer size for ttyv0.
Imre Vadász [Thu, 15 Nov 2018 12:53:02 +0000 (13:53 +0100)]
syscons - Increase static buffer size for ttyv0.

* This allows the console on the EFI framebuffer to fill the whole screen
  on "odd" resolutions. This only takes up slightly less than 12KB extra
  space in the kernel binary size.

3 years agodrm/ttm: Remove sf_buf usage
François Tigeot [Wed, 14 Nov 2018 18:35:30 +0000 (19:35 +0100)]
drm/ttm: Remove sf_buf usage

* Use Linux memory allocation/mapping functions instead.

* Opportunistically sync some code with Linux

3 years agodrm/linux: Add a few GFP_XXX values
François Tigeot [Wed, 14 Nov 2018 17:42:49 +0000 (18:42 +0100)]
drm/linux: Add a few GFP_XXX values

3 years agorc.d: Introduce 'dhcp_client' to wrap over dhclient and dhcpcd
Aaron LI [Thu, 25 Oct 2018 12:25:03 +0000 (20:25 +0800)]
rc.d: Introduce 'dhcp_client' to wrap over dhclient and dhcpcd

The new 'dhcp_client' rc script is a wrapper to start either dhclient(8)
or dhcpcd(8) based on the value of the 'dhcp_client' rc variable.

Other rc scripts are updated to depend on this wrapper instead of the
explicit 'dhclient'.  This eases the migration from dhclient(8) to
dhcpcd(8) later.

Update rc.conf.5 and dhcp.8 man pages accordingly.

Meanwhile, remove the two obsolete variables 'dhcp_{program,flags}' from

3 years agodhcpcd: Add rc script rc.d/dhcpcd
Aaron LI [Fri, 19 Oct 2018 15:28:29 +0000 (23:28 +0800)]
dhcpcd: Add rc script rc.d/dhcpcd

The dhcpcd supports both DHCPv4 and DHCPv6.

3 years agonetwork.subr: Support IPv6 in dhcpif()
Aaron LI [Wed, 14 Nov 2018 09:49:03 +0000 (17:49 +0800)]
network.subr: Support IPv6 in dhcpif()

Extend the 'dhcpif()' to support checking the interface needs DHCP for
IPv4-only, IPv6-only or either.

The 'dhcpcd' rc script in the following commit will use this new feature
to determine whether dhcpcd should do DHCPv4 or DHCPv6 or both.

3 years agonetwork.subr: Add ipv6if()
Aaron LI [Thu, 25 Oct 2018 17:05:20 +0000 (01:05 +0800)]
network.subr: Add ipv6if()

This function determines whether the given interface should be
configured for IPv6.  This function will be used to determine whether to
apply DHCPv6 to an interface in the following commit.

Taken from FreeBSD, but modified to consider ${ipv6_enable}.

3 years agonetwork.subr: Support IPv6 in ifconfig_getargs()
Aaron LI [Thu, 25 Oct 2018 12:11:28 +0000 (20:11 +0800)]
network.subr: Support IPv6 in ifconfig_getargs()

Update the 'ifconfig_getargs()' to accept the address family option
to support the extraction of IPv6 arguments of an interface, which
is configured using 'ipv6_ifconfig_<ifname>="..."'.

Obtained from FreeBSD; but FreeBSD uses 'ifconfig_<ifname>_ipv6'.

3 years agodhcpcd: Add upgrade notes to README.DRAGONFLY
Aaron LI [Fri, 19 Oct 2018 07:34:05 +0000 (15:34 +0800)]
dhcpcd: Add upgrade notes to README.DRAGONFLY

3 years agodhcpcd: Bind to system
Aaron LI [Fri, 19 Oct 2018 07:32:31 +0000 (15:32 +0800)]
dhcpcd: Bind to system

This only makes 'dhcpcd' be built and installed, and doesn't affect the
existing 'dhclient'.

3 years agodhcpcd: Apply local modifications
Aaron LI [Fri, 19 Oct 2018 06:54:55 +0000 (14:54 +0800)]
dhcpcd: Apply local modifications

* The modification to 'src/if.c' makes it can be build with
  '-Werror=implicit-fallthrough', which is enabled with '-Wextra'.
  However, both swildner and I still don't understand why such a
  modification is needed :(

* In 'src/ipv6.c', explicitly suppress the '#warning' on
  IPV6_POLLADDRFLAG, an IPv6 feature that dfly currently doesn't

3 years agodhcpcd: Generate src/dhcpcd-embedded.[ch]
Aaron LI [Fri, 19 Oct 2018 06:41:10 +0000 (14:41 +0800)]
dhcpcd: Generate src/dhcpcd-embedded.[ch]

$ cd src
$ ./genembedc > dhcpcd-embedded.c
$ ./genembedh > dhcpcd-embedded.h
$ rm genembed[ch] dhcpcd-embedded.[ch].in dhcpcd-definitions.conf

3 years agoMerge branch 'vendor/DHCPCD'
Aaron LI [Wed, 14 Nov 2018 12:51:02 +0000 (20:51 +0800)]
Merge branch 'vendor/DHCPCD'

Import dhcpcd 7.0.8

3 years agodhcpcd: Add READMEs
Aaron LI [Fri, 19 Oct 2018 06:32:39 +0000 (14:32 +0800)]
dhcpcd: Add READMEs

3 years agoImport dhcpcd 7.0.8
Aaron LI [Fri, 19 Oct 2018 06:22:17 +0000 (14:22 +0800)]
Import dhcpcd 7.0.8

Version: 7.0.8
Date: 2018 August 20
URL: https://github.com/rsmarples/dhcpcd/releases
Homepage: https://roy.marples.name/projects/dhcpcd

3 years agokernel - Fix sack NULL pointer dereference
Matthew Dillon [Tue, 13 Nov 2018 19:12:36 +0000 (11:12 -0800)]
kernel - Fix sack NULL pointer dereference

* sack_block_lookup() can get confused when the passed-in sequence
  number appears to be less than sblk_start and greater than sblk_end.
  This situation can occur when the signed integer delta test has an
  overflow due to (sblk_end - seq) overflowing the sign bit verses
  (sblk_start - seq).

  The result is that sack_block_lookup() can crash on a NULL pointer

* Check for the case, complain, and try to allow it.  Though I suspect
  if the case occurs at all SACK will wind up with a broken list anyway.

* I don't think this case can occur under normal conditions since TCP
  buffers do not grow to 2GB+ in size, so the crash we got was triggered
  by either an accidently malformed packet or an intentional one.

3 years agokernel - Fix SMP race in procfs
Matthew Dillon [Tue, 13 Nov 2018 19:10:47 +0000 (11:10 -0800)]
kernel - Fix SMP race in procfs

* procfs was not locking its pid hash table.  Implement a per-slot
  spinlock.  The hash is populated only for pid directories that are
  pushed into (e.g. ls /proc/<pid> vs ls /proc).

* Fixes a fairly rare crash that can only occur when procfs is used

3 years agodrm/ttm: Sync ttm_execbuf_util.c with Linux
François Tigeot [Sun, 11 Nov 2018 08:18:03 +0000 (09:18 +0100)]
drm/ttm: Sync ttm_execbuf_util.c with Linux

3 years agodrm/ttm: Sync ttm_lock.c with Linux
François Tigeot [Sat, 10 Nov 2018 08:31:20 +0000 (09:31 +0100)]
drm/ttm: Sync ttm_lock.c with Linux

3 years agoterminfo: Build and install tmux and tmux-256color
Aaron LI [Sat, 10 Nov 2018 01:08:23 +0000 (09:08 +0800)]
terminfo: Build and install tmux and tmux-256color

3 years agodrm/linux: Add send_sig()
François Tigeot [Fri, 9 Nov 2018 17:34:19 +0000 (18:34 +0100)]
drm/linux: Add send_sig()

3 years agorc.conf.5: Document ip6addrctl_{policy,verbose} explicitly
Aaron LI [Thu, 8 Nov 2018 01:13:04 +0000 (09:13 +0800)]
rc.conf.5: Document ip6addrctl_{policy,verbose} explicitly

Suggested-by: swildner
3 years agodrm/ttm: Rework ttm_io_prot()
François Tigeot [Wed, 7 Nov 2018 22:18:51 +0000 (23:18 +0100)]
drm/ttm: Rework ttm_io_prot()

Change it to be as close to the Linux version as possible.

3 years agokernel - Fix typo from b227f3f50d5dc0f when filling in kpmap header.
Imre Vadász [Tue, 6 Nov 2018 19:52:36 +0000 (20:52 +0100)]
kernel - Fix typo from b227f3f50d5dc0f when filling in kpmap header.

3 years agocrypto - Avoid including opensslconf.h when using openssl/md5.h in kernel.
Imre Vadász [Mon, 5 Nov 2018 22:14:40 +0000 (23:14 +0100)]
crypto - Avoid including opensslconf.h when using openssl/md5.h in kernel.

3 years agokernel - Make the wdog.h and gpio.h includes conditional in kern_shutdown.c.
Imre Vadász [Mon, 5 Nov 2018 22:13:00 +0000 (23:13 +0100)]
kernel - Make the wdog.h and gpio.h includes conditional in kern_shutdown.c.

3 years agokernel - Fix build when neither INET nor INET6 options are set.
Imre Vadász [Sat, 3 Nov 2018 19:51:06 +0000 (20:51 +0100)]
kernel - Fix build when neither INET nor INET6 options are set.

3 years agodrm/linux: fix pgprot_xxx functions
François Tigeot [Tue, 6 Nov 2018 17:32:51 +0000 (18:32 +0100)]
drm/linux: fix pgprot_xxx functions

3 years agorc.d/Makefile: Break some long lines, sort dntpd.
Sascha Wildner [Tue, 6 Nov 2018 04:28:07 +0000 (05:28 +0100)]
rc.d/Makefile: Break some long lines, sort dntpd.

3 years agodrm/linux: Fix vmap()
François Tigeot [Mon, 5 Nov 2018 21:15:18 +0000 (22:15 +0100)]
drm/linux: Fix vmap()

Page protection information was not being used.

3 years agorc.subr: Add list_vars() function
Aaron LI [Mon, 5 Nov 2018 20:31:38 +0000 (04:31 +0800)]
rc.subr: Add list_vars() function

Taken-from: FreeBSD

3 years agorc.d: Add ip6addrctl (enabled by default with policy AUTO)
Aaron LI [Mon, 5 Nov 2018 20:25:17 +0000 (04:25 +0800)]
rc.d: Add ip6addrctl (enabled by default with policy AUTO)

Bring in the ip6addrctl rc script from FreeBSD.  It is enabled by
default with policy "AUTO", so the IPv4/IP6 preference is configured on
startup.  The rc variable "ip6addrctl_policy" is used to adjust the
preference (AUTO, ipv6_prefer, ipv6_prefer).

See the rc.conf(5) man page for more details.

3 years agoBring in ip6addrctl(8) from FreeBSD
Aaron LI [Mon, 5 Nov 2018 19:22:15 +0000 (03:22 +0800)]
Bring in ip6addrctl(8) from FreeBSD

The ip6addrctl(8) manages the policy table of source and destination
address selection for ougoing IPv4 and IPv6 packets.

For example, this utility can be used to configure that IPv4 is
preferred on a dual-stack machine, which by default prefers IPv6.

3 years agolibc/mktemp: Pass flags to open()
Simon Arlott [Sat, 3 Nov 2018 20:08:07 +0000 (20:08 +0000)]
libc/mktemp: Pass flags to open()

The flags from the functions that call _gettemp() are never used.

They should be included in the call to open(), otherwise features like
O_CLOEXEC don't work.

(1) Checked FreeBSD and it behaves the same way as this fix.
(2) Improve the style a bit.

3 years agonet/if: Call if_ioctl() if the protocol didn't handle the ioctl
Aaron LI [Sun, 4 Nov 2018 09:55:53 +0000 (17:55 +0800)]
net/if: Call if_ioctl() if the protocol didn't handle the ioctl

This allows for a non-interface socket (like AF_LOCAL which ifconfig(8)
now uses since commit d4e856128472e2e79172aebf65f19f527ac0010f) to use
a broader class of interface ioctls.

This fixes the regression in ifconfig(8) that is introduced by the above
mentioned commit, which changed ifconfig(8) to use AF_LOCAL socket by
default and thus caused some ioctls failures.  For example:

dfly# ifconfig tap0 create
dfly# ifconfig tap0 up
dfly# ifconfig bridge0 create
dfly# ifconfig bridge0 addm tap0

dfly# ifconfig bridge0
bridge0: flags=8002<BROADCAST,MULTICAST> mtu 1500
        ether be:48:6d:6d:a6:1f
        groups: bridge

dfly# ifconfig bridge0
bridge0: flags=8002<BROADCAST,MULTICAST> mtu 1500
        ether be:48:6d:6d:a6:1f
        priority 32768 hellotime 2 fwddelay 15 maxage 20
        member: tap0 flags=3<LEARNING,DISCOVER>
        groups: bridge

Do not pass the SIOCSIF{ADDR,BRDADDR,DSTADDR,NETMASK} iotcls to the
drivers because they may assume these ioctls come from an already
privileged layer and thus skip credentials check and input validation.

While there, improve a NULL check.

Taken-from: FreeBSD (r190151, r255442)
Reviewed-by: dillon, sephe
3 years agoboot - Slow down the nfs twiddle
Matthew Dillon [Sun, 4 Nov 2018 06:55:49 +0000 (23:55 -0700)]
boot - Slow down the nfs twiddle

* Slow down the twiddle rate when reading via nfs, it unnecessarily
  slows down the boot, by a lot.

3 years agodrm/ttm: Remove ttm_bo_unreserve_core()
François Tigeot [Sat, 3 Nov 2018 14:18:38 +0000 (15:18 +0100)]
drm/ttm: Remove ttm_bo_unreserve_core()

* This function was DragonFly-specific and apparently
  isn't even needed anymore

* Sync the changed code with Linux as of ecff665f5e3f1c6909353e00b9420e45ae23d995
  "drm/ttm: make ttm reservation calls behave like reservation calls"

3 years agodrm: Add linux/rwlock.h
François Tigeot [Sat, 3 Nov 2018 13:07:50 +0000 (14:07 +0100)]
drm: Add linux/rwlock.h

3 years agovkernel - Fix tty panic
Matthew Dillon [Sat, 3 Nov 2018 00:25:35 +0000 (17:25 -0700)]
vkernel - Fix tty panic

* Fix messed up gettoken/reltoken sequence for the vkernel,
  bug was introduced in recent tty work.

Reported-by: tuxillo
3 years agodmesg(8): Allow seeing backslashes in dmesg output.
Sascha Wildner [Fri, 2 Nov 2018 16:28:53 +0000 (17:28 +0100)]
dmesg(8): Allow seeing backslashes in dmesg output.

This caused confusion already in ACPICA bug reports with pathnames
containing backslashes.

Taken-from: NetBSD

3 years agolibc/vis: Use thread-safe mbrtoc() and wcrtomb().
Sascha Wildner [Fri, 2 Nov 2018 16:26:59 +0000 (17:26 +0100)]
libc/vis: Use thread-safe mbrtoc() and wcrtomb().

Taken-from: FreeBSD

3 years agoSync ACPICA with Intel's version 20181031.
Sascha Wildner [Fri, 2 Nov 2018 08:58:43 +0000 (09:58 +0100)]
Sync ACPICA with Intel's version 20181031.

* Fix an Operation Region regression, fixing accurate checking for
  region conflicts.

* Add support for 2-byte extended opcodes in the code that continues
  parsing during the table load phase.

* Eliminate a no longer used global variable.

For detailed list, please see sys/contrib/dev/acpica/changes.txt.

3 years agoSync zoneinfo database with tzdata2018g from ftp://ftp.iana.org/tz/releases
Sascha Wildner [Fri, 2 Nov 2018 08:04:13 +0000 (09:04 +0100)]
Sync zoneinfo database with tzdata2018g from ftp://ftp.iana.org/tz/releases

* Morocco switched to permanent +01 on 2018-10-27.

* Change HDT to HWT/HPT for WWII-era abbreviations in Hawaii.

For a detailed list of changes, see share/zoneinfo/NEWS.

3 years agoboot - Handle tftp block overflows
Matthew Dillon [Fri, 2 Nov 2018 02:06:14 +0000 (19:06 -0700)]
boot - Handle tftp block overflows

* Properly truncate the block number when comparing against the
  incoming packet.  TFTP only implements 16-bit block numbers.
  This allows the boot loader to access files larger than 32MB
  via TFTP.

* Twiddle every 256 reads instead of every 16.

* Note that TFTP is not really a suitable protocol for loading the
  kernel because the ELF loader seeks past the debug info which
  can be well over a hundred megabytes in order to get to the syms.
  NFS is preferred.

3 years agoJust note that the previous commit was to hammer2 only.
Sascha Wildner [Wed, 31 Oct 2018 09:34:00 +0000 (10:34 +0100)]
Just note that the previous commit was to hammer2 only.

The tmpfs logic turned out to be correct after closer review.

3 years agokernel/{hammer2,tmpfs}: Fix ENOTDIR/EISDIR logic.
Sascha Wildner [Wed, 31 Oct 2018 09:27:27 +0000 (10:27 +0100)]
kernel/{hammer2,tmpfs}: Fix ENOTDIR/EISDIR logic.

It caused confusion like this:

vm64# touch /usr/obj/t
vm64# rmdir /usr/obj/t
rmdir: /usr/obj/t: Is a directory

Likewise unlink(2) on a directory also gives the wrong error
("Not a directory").

This also causes Ruby's unlink() file method to fail.

Reported-by: tuxillo
3 years agotmpfs - Use atomic_fetchadd_long() to allocate inode numbers
Matthew Dillon [Wed, 31 Oct 2018 01:50:03 +0000 (18:50 -0700)]
tmpfs - Use atomic_fetchadd_long() to allocate inode numbers

* Since DFly inode numbers are 64 bits wide, tmpfs just increments a
  per-mount counter to allocate a new inode.

* We had some old code in tmpfs to allocate inode numbers which wrapped
  a tmpfs mount lock around the increment.  This is totally unnecessary.
  Use atomic_fetchadd_long() instead.

Reported-by: mjg
3 years agokernel - Fix getsockname() on unnamed AF_LOCAL sockets
Matthew Dillon [Wed, 31 Oct 2018 01:48:35 +0000 (18:48 -0700)]
kernel - Fix getsockname() on unnamed AF_LOCAL sockets

* Fix getsockname() on unnamed AF_LOCAL sockets.  The socket structure
  does not actually bother storing a sockaddr, so sa is returned NULL.
  In this situation, just dummy-up an AF_LOCAL sockaddr.

* Don't bother copyout()ing sa_len unless it has changed.

Reported-by: tuxillo
3 years agobsd-family-tree: Sync with FreeBSD (OpenBSD 6.4).
Sascha Wildner [Sun, 28 Oct 2018 16:53:12 +0000 (17:53 +0100)]
bsd-family-tree: Sync with FreeBSD (OpenBSD 6.4).

3 years agosound - Allow /dev/sndstat to be opened multiple times from one process.
Imre Vadász [Fri, 26 Oct 2018 20:14:47 +0000 (22:14 +0200)]
sound - Allow /dev/sndstat to be opened multiple times from one process.

* This still isn't great, but at least it's enough to make pulseaudio's
  oss module detect the audio devices correctly.

* This now uses the buf->uio_offset, instead of trying to track the read
  position ourselves in the driver with sndstat_bufptr.

3 years ago<sys/sysproto.h>: Add back one needed newline and regenerate header.
Sascha Wildner [Sat, 27 Oct 2018 07:45:04 +0000 (09:45 +0200)]
<sys/sysproto.h>: Add back one needed newline and regenerate header.

3 years ago<sys/sysproto.h>: Fix excessive newlines.
Sascha Wildner [Sat, 27 Oct 2018 07:39:25 +0000 (09:39 +0200)]
<sys/sysproto.h>: Fix excessive newlines.

3 years ago<sys/wait.h>: Put the enum name under __BSD_VISIBLE.
Sascha Wildner [Sat, 27 Oct 2018 06:26:44 +0000 (08:26 +0200)]
<sys/wait.h>: Put the enum name under __BSD_VISIBLE.

POSIX only defines idtype_t. In <sys/procctl.h> i just left it because
that whole file isn't covered by the standard anyway.

While here, cleanup whitespace a little bit and clarify DragonFly or
FreeBSD a bit better in a comment.

3 years agobuild - refactor rescue and initrd handling
Matthew Dillon [Sat, 27 Oct 2018 01:33:57 +0000 (18:33 -0700)]
build - refactor rescue and initrd handling

* buildworld now builds the rescue directory tree and initrd
  image in /usr/obj.

* installworld will install the rescue and initrd stuff if it
  does not exist on the destination.  If rescue or initrd stuff
  is already installed, it is not overwritten.

* Add 'installrescue' and 'installinitrd' targets.  These will
  copy the rescue and initrd image built by buildworld.

* The normal 'rescue' and 'initrd' targets are unchanged and
  should build (from scratch) and install the rescue and initrd

* NOTE: crunchgen is currently hacked to add system paths when
  WORLDBUILD is defined, in order to access native binaries
  for 'uniq' and a few others, instead of building them in

  In particular, we have to use the native 'vnconfig' binary
  as building one in crosstools might not be compatible with
  the currently running system.  buildworld now uses 'vn' to
  create the initrd image.

  Possibly needs some work.

3 years agokernel - Refactor kbmux arrays
Matthew Dillon [Sat, 27 Oct 2018 01:17:36 +0000 (18:17 -0700)]
kernel - Refactor kbmux arrays

* Get rid of the generally insane dynamic reallocation code for
  these tiny arrays and set a fixed limit of 16 keyboards.

* Add a sanity check in kbd_intr() to deal with potential interrupt
  races against installation of a new keyboard.

3 years agolibc - Add kpmap shortcut for gettimeofday()
Matthew Dillon [Sat, 27 Oct 2018 01:08:35 +0000 (18:08 -0700)]
libc - Add kpmap shortcut for gettimeofday()

* If the kern.gettimeofday_quick sysctl is set to 1, libc's
  gettimeofday() will use the tick-granular realtime in
  the kpmap instead of making a system call.  The sysctl
  defaults to 0 (off).

* Useful in situations where gettimeofday() interferes with
  benchmarks, but otherwise not recommended.

* Running programs react instantly to changes in this sysctl.

3 years agosys/conf/files: Move vmx a bit up.
Sascha Wildner [Fri, 26 Oct 2018 13:38:02 +0000 (15:38 +0200)]
sys/conf/files: Move vmx a bit up.

3 years agoVirtio_Balloon implementation for DragonFly
Diederik de Groot [Mon, 1 Oct 2018 23:00:05 +0000 (01:00 +0200)]
Virtio_Balloon implementation for DragonFly

- Initial check-in of fbsd virtio_balloon (freebsd/freebsd@1537078)
- Update virtio_balloon man page
- Fix vtballoon_alloc_intrs to deal nicely with number of provided interrupts.
- Use a backoff scheme when allocating vm_pages:
  - VM_ALLOC_NORMAL for normal (low memory presure) situation;
  - VM_ALLOC_SYSTEM + increased sleep timeout, for high memory presure circumstances.
  The latter will allow the system to swap other pages out if necessary.
- Implemented suggestions made by ivadasz
  - Added virtio_teardown_intr handling to vtballoon_detach
  - Added config_change_intr handling
  - Fixed virtio_setup_intr
- Add debug_level sysctl for tracing.
- Add collection of guest memory/pagefault statistics
- Completed/Updated header definitions
- Don't use VM_ALLOC_INTERRUPT. Add better inflate/deflate debug output to thread_sleep function
- Don't collect stats when initialially loaded (Reported by tuxillo).

3 years agoLINT64: Add comments to the virtio devices.
Sascha Wildner [Fri, 26 Oct 2018 12:42:29 +0000 (14:42 +0200)]
LINT64: Add comments to the virtio devices.

3 years agobuild - Fix buildworld from DFly releases prior to 5.0.
Matthew Dillon [Fri, 26 Oct 2018 02:56:40 +0000 (19:56 -0700)]
build - Fix buildworld from DFly releases prior to 5.0.

* Fix mkmagic to not use the magic.h in /usr/include.  It
  needs the magic.h generated via libmagic.  Since mkmagic
  must be built prior to libmagic, we generate a local magic.h
  just for mkmagic.

* Fixes buildworld from DFly releases prior to 5.0.

3 years agosound - Fix mmap handling for /dev/dsp* devices.
Imre Vadász [Thu, 25 Oct 2018 22:53:08 +0000 (00:53 +0200)]
sound - Fix mmap handling for /dev/dsp* devices.

* The d_mmap function is expected to return a page index, not an address,
  the the atop() function for this as usual.

3 years ago<sys/signal.h>: Discard old non-POSIX union members.
Sascha Wildner [Thu, 25 Oct 2018 17:31:53 +0000 (19:31 +0200)]
<sys/signal.h>: Discard old non-POSIX union members.

The only thing I found that still uses the old names is www/nginx,
a fix for which is in DeltaPorts:


While here, fix a small whitespace issue.

3 years agorc.conf.5: Remove the obsolete reference to named(8)
Aaron LI [Thu, 25 Oct 2018 12:07:18 +0000 (20:07 +0800)]
rc.conf.5: Remove the obsolete reference to named(8)

3 years agoSync /etc/pccard_ether with FreeBSD
Aaron LI [Thu, 25 Oct 2018 05:48:56 +0000 (13:48 +0800)]
Sync /etc/pccard_ether with FreeBSD

Our original 'pccard_ether' became unnecessarily complex as a big part of
the work is already implemented in 'network.subr', so just bring FreeBSD's
version over (with 'checkauto()' ignored as we don't support it).

NOTE: The 'pccard_ether' is still disabled by default on DragonFly.

3 years agoarp(8): Add option -i to limit operations to one interface
Aaron LI [Thu, 25 Oct 2018 05:16:47 +0000 (13:16 +0800)]
arp(8): Add option -i to limit operations to one interface

This allows to limit the scope of operation to the ARP entries on a
particular interface, which should be useful on machines with lots of
network interfaces, e.g., inter-VLAN routers.

This new option will also be used in /etc/pccard_ether.

Taken from FreeBSD (r117729, r154162) with modifications.

3 years ago<sys/eventhandler.h>: Move the include inside the guard.
Sascha Wildner [Thu, 25 Oct 2018 08:27:37 +0000 (10:27 +0200)]
<sys/eventhandler.h>: Move the include inside the guard.

3 years ago<sys/stdint.h>: Move the includes inside the guard.
Sascha Wildner [Thu, 25 Oct 2018 07:54:46 +0000 (09:54 +0200)]
<sys/stdint.h>: Move the includes inside the guard.

3 years agoSync zoneinfo database with tzdata2018f from ftp://ftp.iana.org/tz/releases
Sascha Wildner [Wed, 24 Oct 2018 18:27:06 +0000 (20:27 +0200)]
Sync zoneinfo database with tzdata2018f from ftp://ftp.iana.org/tz/releases

* Volgograd moves from +03 to +04 on 2018-10-28.

* Fiji ends DST 2019-01-13, not 2019-01-20.

* Most of Chile changes DST dates, effective 2019-04-06.

* Use PST and PDT for Philippine time.

* Various adjustments to past timestamps.

* Miscellaneous fixes and adjustments.

For a detailed list of changes, see share/zoneinfo/NEWS.