rc.d/wg: Match wg ifnames on wg_start
Specifying wg_interfaces="wg0" in /etc/rc.conf causes:
ifconfig: ioctl SIOCSIFNAME (set name): File exists
The interface name matching in the wg script is not matching the
'wg' interfaces thus trying to set a custom interface name.
Apparently expr does not interpret '+' from regex:
$ expr 'wg0' : 'wg[0-9]+$' && echo matched
0
Workaround it by using already working expr usage:
$ expr 'wg0' : 'wg[0-9][0-9]*$' && echo matched
3
matched
[2 lines not shown]
mount_cd9660(8): Simplify and clean up set_charset()
Simplify set_charset(), partly according to mount_ntfs(8).
Meanwhile, clean up the whitespace styles.
net: Improve rt_print() and rt_addrinfo_print() debug functions
- Update rt_print() to print the full interface name (if_xname) instead
of the underlying device name (if_dname).
- Update rt_addrinfo_print() to print flags, ifp and ifa; similar to
rt_print().
net: Fix panic in the rt_addrinfo_print() debug function
The 'rti_addrs' member is a bitmask of RTA_* values, not a count value,
so the rt_addrinfo_print() debug function would just panic.
Use RTAX_MAX instead to fix this bug. Meanwhile, add brief comments to
'rti_addrs' and 'rti_flags' members.
umount(8): Add -d option to detach vn(4) devices
The '-d' option tells umount(8) to detach the underlying vn(4) device if
the filesystem was mounted from it. Note that vn(4) is a virtual disk
and can provides multiple filesystems, so the vn(4) detaching can only
succeed when all the filesystems are umounted.
For example:
$ vnconfig -c vn dfly.img
vn4
$ mount_msdos /dev/vn4s1 /mnt/dfly/boot
$ mount_ufs /dev/vn4s2a /mnt/dfly/root
$ umount -d /mnt/dfly/boot
umount: VNIOCDETACH: /dev/vn4: Device busy
umount: detach of /dev/vn4s1 failed
$ umount -d /mnt/dfly/root
(now vn4 is detached)
A similar option exists in Linux's and FreeBSD's umount(8).
[3 lines not shown]
net: Clean up ifa_ifwithnet() and ifaof_ifpforaddr()
- Add the static inline function ifa_match_withmask() to deduplicate the
address match code in both functions.
- Use NULL instead of 0 for pointers.
- Minor style cleanups.
net: Improve rt_print() and rt_addrinfo_print() debug functions
- Update rt_print() to print the full interface name (if_xname) instead
of the underlying device name (if_dname).
- Update rt_addrinfo_print() to print flags, ifp and ifa; similar to
rt_print().
netinet: Improve the deletion of loopback route
When the target host address is still bound to another interface address
(e.g., an address on another interface added later), the loopback route
should be updated to point to that address instead of simply being
removed.
Given that our rtrequest1() only supports route addition and deletion,
but not route change, we have to first remove the original loopback
route and then re-add a route with the wanted interface address.
See also in_localip_more() and ifa_switch_loopback_route() in FreeBSD.
net: Fix panic in the rt_addrinfo_print() debug function
The 'rti_addrs' member is a bitmask of RTA_* values, not a count value,
so the rt_addrinfo_print() debug function would just panic.
Use RTAX_MAX instead to fix this bug. Meanwhile, add brief comments to
'rti_addrs' and 'rti_flags' members.
net: Integrate link_rtrequest() into rt_getifa()
When a route was inserted but had an invalid IFA (rt_ifa), the
link_rtrequest() would be called to fix it with a link-level gateway.
Move the link_rtrequest() logic into the pre-insertion rt_getifa() step,
and thus simplifies the IFA selection. This will also help the
forthcoming mangement of loopback routes for interface addresses.
Obtained-from: FreeBSD
- https://reviews.freebsd.org/D20076
- https://github.com/freebsd/freebsd-src/commit/2ad7ed6e4a84448234e9aaef3c9fa884848f7387
netinet: Auto add loopback routes to interface addresses
When adding an address to an interface, a loopback route will be created
to route the traffic targeting it through the lo0 interface. The
loopback route will also be removed when the corresponding interface
address is deleted.
In principle, this can help simplify the network input and output paths
by avoiding special handling of local addresses. That deserves some
further efforts.
Nonetheless, an immediate benefit goes to wg(4). Now we can access
(e.g., ping) from localhost a wg(4) interface's IPv4 addresses.
Previously it was broken because wg(4) is a virtual device and doesn't
have/use ARP. For Ethernet devices, the ether_output() function will
redirect the traffic targeting its own address to the loopback interface
by calling if_simloop().
Derived from FreeBSD; the major commits are:
[10 lines not shown]
netinet: Simplify the handling of INADDR_ANY in in_ifinit()
Just check the interface address whether is INADDR_ANY and ignore the
checks of netmask/dstaddr.
sockstat(1): Fix and improve output formatting
The main issue with the old formatting was that the FD column was
limited to 2 characters, so there would be no space between FD and PROTO
columns.
Increase the FD column to 5 characters, and increase the PID column to
6 characters. In addition, refactor the output formatting code to clean
up the mess.
While there, clean up the code a bit to save some type castings.
procfs(5): Add '/proc/self/exe' symlink support
* Add the /proc/self symlink that's the same as /proc/curproc.
* Add the /proc/<pid>/exe entry that's the same as /proc/<pid>/file.
The '/proc/self/exe' symlink has been already landed in NetBSD and
FreeBSD [0]. It could simplify some patches to ports that look for this
symlink.
[0] https://github.com/freebsd/freebsd-src/pull/976
GitHub PR: https://github.com/DragonFlyBSD/DragonFlyBSD/pull/22
sys/vfs/fuse: Some mmap related fixes, issues with sshfs and FUSE_FORGET
* Only issue FUSE_FSYNC when there is a file-handle associated with
the fuse_node.
* Be sure to flush the VM object on inactive before releasing the
file handle (fixes issues with mmap()).
* Don't issue FUSE_FORGET for now, it seems to confuse sshfs so either
I'm doing something wrong or ... don't know.
sys/vfs/fuse: Fix a ton more stuff
* Remove all the fuse_dent code. It is no longer needed.
* Remove signal mask wrappers. tsleep() isn't passing PCATCH so
signals are basically ignored.
* Add missing required FUSE_RELEASE operations (paired with CREATE/OPEN)
* Add missing required FUSE_FORGET operations (paired with LOOKUPs).
"." and ".." are not recorded by userland and do not need to be
forgotten (will confuse userland if they are).
* No reply is expected from FUSE_FORGET RPCs, add infrastructure to
handle this case.
* Index fuse_node's by their inode number, which greatly improves
hardlink handling.
[13 lines not shown]
sys/vfs/fuse: Fix a ton of stuff and get writes working
* Recode all the file I/O. Use the buffer cache properly, create a
backend for BIO strategy calls. mmap() should work properly now.
write() should also now work properly.
* For the moment issue vfinalize() when the opencount == 0 to force
the DFly kernel to dispose of inactive vnodes once all references
(including mmap references) are gone.
* Recode the filehandle (fh) tracking. File handles are assigned
in fuse_vop_open() and instead of being released in fuse_vop_close()
(which completely blows up mmap() operations), we now release
file handles in fuse_vop_inactive().
Remove the fh side allocation. The fh is now positively stored in
the fuse_node.
* Properly zero data structures allocated via the objcache.
[34 lines not shown]
Fix null dereference bug in fuse and re-enable it.
There was a null dereference bug in fuse if the subtype was null.
subtype is supposed to be optional, as demonstrated by the code, so test
it for null before copying it in from userspace.
Remove the redundant memcpy which appears to have been missed when the
code was changed to memset/copyinstr.