François Tigeot [Sun, 16 Sep 2018 07:20:37 +0000 (09:20 +0200)]
drm/linux: use pgprot_t
Matthew Dillon [Sat, 15 Sep 2018 04:45:20 +0000 (21:45 -0700)]
build - Remove cvs tags from COPYRIGHT
* Remove cvs tags from COPYRIGHT. An manual install will print the
content of the COPYRIGHT file during boot, there's no need to display
an old $FreeBSD tag.
Sascha Wildner [Fri, 14 Sep 2018 07:27:29 +0000 (09:27 +0200)]
newsyslog.conf: Fix an age old typo that caused weekly.log to rotate wrongly.
weekly.log's rotation isn't triggered by size.
Sascha Wildner [Sun, 9 Sep 2018 20:57:48 +0000 (22:57 +0200)]
kernel: Add some missing __printflike()s.
Sascha Wildner [Sun, 9 Sep 2018 19:09:10 +0000 (21:09 +0200)]
kernel: More adjustments to fix -Wint-in-bool-context warnings.
François Tigeot [Sat, 8 Sep 2018 12:26:15 +0000 (14:26 +0200)]
drm: Sync drm/drmP.h with Linux 4.7.10
Remove most generic kernel includes, in order to avoid Linux/DragonFly
keyword clashes as much as possible in the future.
François Tigeot [Sat, 8 Sep 2018 05:19:30 +0000 (07:19 +0200)]
drm: Add more Linux include files
François Tigeot [Fri, 7 Sep 2018 05:59:43 +0000 (07:59 +0200)]
drm: Use a dedicated .h file for configuration options
With-advice-from: swildner
Eitan Adler [Thu, 6 Sep 2018 01:44:21 +0000 (01:44 +0000)]
bsd-family-tree: add NetBSD 7.2
Also correct the origin of NetBSD 8.0, which was not derived from 7.x.
Obtained from: NetBSD
Sascha Wildner [Thu, 6 Sep 2018 00:57:10 +0000 (02:57 +0200)]
kernel: Fix some -Wint-in-bool-context warnings.
I.e., stop treating integers like booleans. In ix(4) I commented out
a problematic function that returns bool but tries to return -1 if
there was an error.
Imre Vadász [Tue, 4 Sep 2018 20:47:17 +0000 (22:47 +0200)]
kernel - Avoid a race between dfly_schedulerclock and usched_dfly_cpu_init.
* This race was repeatedly occuring during startup, running with multiple
virtual cpu cores in qemu (using TCG emulation on a DragonFly host).
Sascha Wildner [Tue, 4 Sep 2018 22:00:00 +0000 (00:00 +0200)]
kernel/gcc80: Add -Werror to the kernel and module builds.
Antonio Huete Jimenez [Tue, 4 Sep 2018 14:23:52 +0000 (07:23 -0700)]
nrelease/Makefile: Use net/isc-dhcp44-server
Sascha Wildner [Tue, 4 Sep 2018 07:59:53 +0000 (09:59 +0200)]
gcc80: Fix manual page links for the primary compiler.
Taken-from: zrj
Sascha Wildner [Tue, 4 Sep 2018 07:38:01 +0000 (09:38 +0200)]
gcc80: Clean up two Makefiles a bit (no functional change).
Based-on: zrj's work
Sascha Wildner [Tue, 4 Sep 2018 06:38:59 +0000 (08:38 +0200)]
More gcc80 adjustments.
Nothing spectacular.
Taken-from: zrj
Markus Pfeiffer [Mon, 3 Sep 2018 23:29:36 +0000 (23:29 +0000)]
kernel: unbreak buildkernel
Sascha Wildner [Mon, 3 Sep 2018 20:15:57 +0000 (22:15 +0200)]
gcc80: Enable -Werror for gcc80. Temporarily lower libpam's WARNS to 2.
The Resedacea upgrade introduced a warning which I'll fix later.
Matthew Dillon [Mon, 3 Sep 2018 20:14:54 +0000 (13:14 -0700)]
kernel - Fix missing brelse() in error path
* Fix missing brelse() in nvtruncbuf() in error path
Reported-by: myu
Matthew Dillon [Mon, 3 Sep 2018 17:25:35 +0000 (10:25 -0700)]
World - Change default compiler from gcc-5 to gcc-8
* Change the default compiler from gcc-5 to gcc-8.
gcc-5 will no longer be built by default. Setting
WORLD_ALTCOMPILER=all will build all three as before.
* Create CC hardlink for gcc80 so dports picks it up.
gcc80 is now the default for dports instead of 50.
* Adjust the Makefile's to make things easier the next time,
though they could still use more work.
Sascha Wildner [Sun, 2 Sep 2018 10:13:13 +0000 (12:13 +0200)]
dfregress(8): Use mkostemp() instead of mktemp() to fix some warnings.
François Tigeot [Sat, 1 Sep 2018 06:34:40 +0000 (08:34 +0200)]
drm/linux: Rewrite READ_ONCE() and WRITE_ONCE()
These macros were broken when used with some complex types like
pointers to pointers.
Matthew Dillon [Thu, 30 Aug 2018 05:10:49 +0000 (22:10 -0700)]
kernel - Fix a third missing wakeup() in kern_lock.c
* Fix a case where an lockmgr LK_EXCLUSIVE call with a
timeout blocks due to existing shared locks. If the
timeout occurs, the exclusive lock request is backed out.
However, if any new shared locks are attempted while
the EXREQ was pending (due to the exclusive priority
mechanism), those threads will block. The backout code
was not waking the blocked threads up for this situation.
* Fixed by issuing the wakeup() unconditionally for this
case. This is not a heavily traveled code path as locks
with timeouts rarely reach the actual timeout.
Aaron LI [Thu, 30 Aug 2018 13:36:07 +0000 (21:36 +0800)]
if_tun: Disallow to destroy an opened device
When a tun device (created via 'ifconfig') is opened, disallow to destroy
it (e.g., ifconfig destroy). Otherwise, a panic occurs when the caller
closes the device, since it has been already destroyed.
Following the previous fix to if_tap.
Aaron LI [Thu, 30 Aug 2018 13:13:27 +0000 (21:13 +0800)]
if_tap: Disallow to destroy an opened device
When a tap device (created via 'ifconfig') is opened, disallow to destroy
it (e.g., ifconfig destroy). Otherwise, a panic occurs when the caller
closes the device, since it has been already destroyed.
Test case:
[A]% ifconfig tap0 create
[B]% # run a program that opens '/dev/tap0' and keep it running
[A]% ifconfig tap0 destroy
[B]% # exit the program which will then close '/dev/tap0'
=> panic!
In addition:
* Add an assertion to tapclose() to assert the device must exist.
* Return EINVAL instead of ENOIX when try to destroy an manually created
tap device.
* Improve the function description a bit.
Matthew Dillon [Wed, 29 Aug 2018 17:11:34 +0000 (10:11 -0700)]
vkernel64 - Fix build
* Add missing CPUID_TO_APICID() macro which vm_page.c now needs.
Reminded-by: swildner
Matthew Dillon [Sun, 26 Aug 2018 18:52:59 +0000 (11:52 -0700)]
kernel - Fix startup race in usched_dfly
* Use a master configuration lock for usched_dfly's thread
creation, ensuring that no thread tries to check dfly_pcpu[]
until the whole thing has been initialized.
* Fixes occassional panic in usched_dfly on boot on many-cores
systems due to a lower-numbered usched thread triggering before
dfly_pcpu is completely initialized.
Matthew Dillon [Sat, 25 Aug 2018 17:10:08 +0000 (10:10 -0700)]
tmpfs - Fix rare deadlock
* Fix a deadlock which can occur between umount and tmpfs, and
possibly in other very rare situations.
* tmpfs holds the directory node locked when resolving a directory
entry. This results in a lock order reversal between the
directory's tmpfs_node lock and the vnode being locked.
Fixed by using a NOWAIT/UNLOCK/SLEEPFAIL/RETRY sequence.
Peeter Must [Tue, 28 Aug 2018 13:26:05 +0000 (16:26 +0300)]
kernel/apple_gmux: Unbreak loading i915.
* Commit
183e2373896e4ea605435a6bd8f943e8273bf8cd broke loading i915
on Apple MacBookPro laptops with dual GPUs and the gmux chip. The
reason is that whereas formely drm_init_pdev() and drm_fill_pdev()
where mere bookkeeping routines, the above commit relocates
assignment of irq from drm_drv.c:drm_attach() to drm_fill_pdev().
Since apple_gmux is loaded before i915, and apple_gmux initializes
a pdev structure including an irq for the graphics pci device, the
i915 which is loaded afterwards will get zero for an irq and hence
fails to attach.
* The temporary fix is to disable apple_gmux initializing a pci_dev
structure for bookkeeping purposes. This is not needed at the
moment since the primary purpose of apple_gmux is to switch to iGPU
so the user is not left with a frozen screen after loading i915. We
do not support switching between GPUs yet.
* When and if the initialization of graphics pci devices becomes
independent from the drm subsystem, we can make apple_gmux aware of
the various GPUs in the system.
Matthew Dillon [Fri, 24 Aug 2018 18:29:22 +0000 (11:29 -0700)]
docs - Update tuning.7
* Minor update to tuning.7.
Matthew Dillon [Fri, 24 Aug 2018 07:19:18 +0000 (00:19 -0700)]
kernel - Fix two missing wakeup()s in kern_lock.c
* Fix two cases where a shared lock request could block forever due
to missing wakeups for certain specific combinations of request flags.
Sascha Wildner [Thu, 23 Aug 2018 20:06:46 +0000 (22:06 +0200)]
Set autorehash in root's .cshrc.
Matthew Dillon [Thu, 23 Aug 2018 18:43:16 +0000 (11:43 -0700)]
kernel - Update AMD topology detection, scheduler NUMA work (TR2) (2)
* Pass un-mod'd physid to vm_numa_add_topology_mem(). This fixes the
match logic inside vm_numa_add_topology_mem().
Matthew Dillon [Thu, 23 Aug 2018 01:34:32 +0000 (18:34 -0700)]
kernel - Update AMD topology detection, scheduler NUMA work (TR2)
* Update AMD topology detection to use the correct cpuid. It
now properly detects the Threadripper 2990WX as having four nodes
with 8 cores and 2 threads per core, per node. It previously detected
the chip as one node with 32 cores and 2 threads per core.
* Report the basic detected topology without requiring bootverbose.
* Record information about how much memory is attached to each node.
We previously just assumed that it was symmetric. This will be
used by the scheduler.
* Fix instability in the scheduler when running on a large number
of cores. Flag 0x08 (on by default) is needed to actively
schedule overloaded threads onto other cores, but this operation
was being executed on all cores simultaneously which throws the
uload/ucount metrics into an unstable state, causing threads to
bounce around longer the necessary.
Fix by round-robining the operation based on something similar to
sched_ticks % cpuid.
This significantly improves heavy multi-tasking performance on systems
with many cores.
* Add memory-on-node weighting to the scheduler. This detects asymetric
NUMA configurations for situations where not all DIMM slots have been
populated, and for CPUs which are naturally assymetric such as the
2990WX which only has memory directly connected to two of its four
nodes.
This change will preferentially schedule threads onto nodes with
greater amounts of attached memory under light loads, and dig into
the less desirable cpu nodes as the load increases.
Imre Vadász [Sat, 18 Aug 2018 16:42:55 +0000 (18:42 +0200)]
ig4 - Stop I2C controller after checking that it's kind of functional.
Imre Vadász [Sat, 18 Aug 2018 16:41:47 +0000 (18:41 +0200)]
ig4 - We actually need to set the Rx threshold register one smaller.
* Setting the IG4_REG_RX_TL register to 1 was actually generating an
interrupt after 2 bytes were available in the Rx fifo. We need to set the
register to 0 to get an interrupt for 1 byte already.
Imre Vadász [Sat, 18 Aug 2018 10:58:40 +0000 (12:58 +0200)]
ig4 - Only enable interrupts when we want them. Otherwise keep mask at 0.
* This avoids possible interrupt storms, depending on the state of the I2C
controller before the driver attached.
* During attaching this clears the interrupt mask.
Imre Vadász [Sat, 18 Aug 2018 10:49:40 +0000 (12:49 +0200)]
ig4 - Use serializer instead of lockmgr lock.
* This allows us to use lwkt_serialize_handler_disable when stopping the
interrupt, which should be safer in case of detaching during an interrupt
storm.
Matthew Dillon [Sat, 18 Aug 2018 02:59:06 +0000 (19:59 -0700)]
hammer2 - Add the vfs.hammer2.cluster_write sysctl back in
* Value may be 0 or 1, defaults to 0 (disabled). Was previously
enabled.
* By default H2 no longer sets B_CLUSTEROK on dirty buffers being
written. Theoretically this shouldn't be a problem because H2
already uses a large 64KB buffer size.
* Should improve I/O throughput on high-performance SSDs by removing
kernel overhead and should also work better with vfsync's dirty
buffer scan which is already sorted.
Matthew Dillon [Sat, 18 Aug 2018 02:57:28 +0000 (19:57 -0700)]
kernel - remove BUF_TIMELOCK use in fast flush pass
* Remove the BUF_TIMELOCK call in the fast flush pass. This call can
cause unnecessary flush stalls due to clustered writes getting ahead
of the vfsync scan.
* Significantly improves filesystem flush performance to SSDs.
Matthew Dillon [Fri, 17 Aug 2018 23:52:45 +0000 (16:52 -0700)]
kernel - Refactor the TSC MP synchronization test
* Refactor the TSC MP synchronization test. Do not use cpusync.
Using cpusync results in O(N x N) worth of overhead instead of
O(N) worth of overhead.
Instead, have the per-cpu threads run the test simultaneously using
each other's data.
* We synchronize to the last TSC element that was saved on each cpu.
This probably needs a bit of work to ensure determinism, but at
the moment its good in that it synchronizes all cores off of a
single cache mastership change, instead of having them all compete
for cache mastership.
* Probably needs some fine tuning, at the moment I allow a slop of
10uS which is almost certainly too much. Note, however, that
SMP interactions can create ~1uS latencies on particular memory
accesses.
* Solves serious issues with the old test on 64 cpu threads.
These issues may also have been related to the ipiq fifo size
being too small.
Matthew Dillon [Fri, 17 Aug 2018 23:51:56 +0000 (16:51 -0700)]
kernel - Increase MAXCPUFIFO from 32 to 256
* Increase to 256, ensures that no deadlocks can occur on systems
with more than 32 cpu threads.
Sascha Wildner [Fri, 17 Aug 2018 15:51:38 +0000 (17:51 +0200)]
Revert "[zoneinfo] Add some missing zoneinfo files"
This reverts commit
e6c3cf619df176c8ebd2391f8f731dfefbc48fcd.
We do not need those files and they were left out intentionally.
Also, adding them broke installworld because we would have needed
new directories in /usr/share/zoneinfo via mtree.
Eitan Adler [Thu, 16 Aug 2018 15:13:16 +0000 (15:13 +0000)]
[zoneinfo] Add some missing zoneinfo files
Sascha Wildner [Wed, 15 Aug 2018 07:56:46 +0000 (09:56 +0200)]
Update the pciconf(8) database.
August 12, 2018 snapshot from https://pci-ids.ucw.cz
Sascha Wildner [Mon, 13 Aug 2018 19:01:18 +0000 (21:01 +0200)]
bsd-family-tree: Small sync with FreeBSD.
Matthew Dillon [Mon, 13 Aug 2018 04:03:28 +0000 (21:03 -0700)]
Build - for /rescue transition must make upgrade
* Must make upgrade before make rescue when transitioning to the new
/rescue topology.
* Must ensure certain header files are not present. make rescue
currently improperly uses /usr/include which can have all sorts of
cruft in it.
* This is a quick hack, will be fixed by a later cleanup of the
make rescue target to properly split it into buildworld (to build)
and installworld (to install).
Matthew Dillon [Mon, 30 Jul 2018 00:21:01 +0000 (17:21 -0700)]
hammer2 - Shift inode xop functions into hammer2_xop.c
* Move the inode related xop functions from hammer2_inode.c
to hammer2_xop.c. Leave the xop functions in strategy
and flush where they are.
* Fix desc macro.
Matthew Dillon [Sun, 29 Jul 2018 02:03:29 +0000 (19:03 -0700)]
hammer2 - Remote xop implementation part 1
* Normalize naming conventions for XOP functions.
* Change the XOP callback API to remove the hammer2_thread argument.
Pass the clindex and scratch buffer in directly.
* Change the XOP API to pass in a function descriptor instead of a
function pointer, create prototypes for DMSG send/receive XOPs which
will be used for XOP components which are DMSG based and not
local-storage based.
* Adjust comments.
Matthew Dillon [Sun, 29 Jul 2018 02:01:39 +0000 (19:01 -0700)]
kernel - Clear bp->b_error prior to initiating write I/O
* Clear bp->b_error prior to initiating write I/O so a lingering
b_error code from a retry that later succeeds is not retained.
Tomohiro Kusumi [Sun, 12 Aug 2018 11:26:59 +0000 (04:26 -0700)]
sys/vfs/autofs: Change u_xxx -> unsigned xxx
(ap->a_cmd and refcount apis are of u_xxx)
Sascha Wildner [Sat, 11 Aug 2018 20:39:07 +0000 (22:39 +0200)]
kernel/drm: Remove CONFIG_PCI as a kernel option.
The code does not link in the absence of it and neither do we expect
systems without PCI support configured, nor does it make sense for
DRM specific stuff in particular, so just set it unconditionally.
If anything, it could be tied to NPCI being >0 (to check if
"device pci" is in the kernel), but for that it would have to
actually build/link without CONFIG_PCI in the first place.
Sascha Wildner [Fri, 10 Aug 2018 20:30:26 +0000 (22:30 +0200)]
Sync ACPICA with Intel's version
20180810:
* Attempt to continue initially loading ACPI tables regardless of
malformed AML.
* Enhance acpiexec(8)'s -fi option and plug a memory leak in it.
For detailed list, please see sys/contrib/dev/acpica/changes.txt.
François Tigeot [Fri, 10 Aug 2018 19:11:19 +0000 (21:11 +0200)]
drm: Sync drm_pci.c with Linux 4.7.10
François Tigeot [Fri, 10 Aug 2018 19:07:16 +0000 (21:07 +0200)]
drm: Add CONFIG_PCI
François Tigeot [Thu, 9 Aug 2018 21:01:42 +0000 (23:01 +0200)]
drm/linux: Add field devfn to struct pci_dev
Sascha Wildner [Thu, 9 Aug 2018 12:32:06 +0000 (14:32 +0200)]
Move fpclassify.3 from libc to libm where it belongs.
Sascha Wildner [Thu, 9 Aug 2018 12:31:25 +0000 (14:31 +0200)]
Add back a signbit.3 manpage that was killed w/o providing a substitute.
Sascha Wildner [Thu, 9 Aug 2018 12:27:02 +0000 (14:27 +0200)]
fpgetround.3: Replace references to the former fenv.3 manual page.
OpenBSD's libm has 4 separate manual pages for these.
Sascha Wildner [Thu, 9 Aug 2018 11:41:47 +0000 (13:41 +0200)]
Remove two references (one commented) to a non-existant manpage.
Sascha Wildner [Thu, 9 Aug 2018 07:26:03 +0000 (09:26 +0200)]
Remove some documentation of the i386 specific fpresetsticky().
Aaron LI [Thu, 9 Aug 2018 02:40:36 +0000 (10:40 +0800)]
Revert "pf: Allow disappearing or not yet existing interfaces for ALTQ"
This reverts commit
0a887f91f9633448c99b9a5b7c6116a0a22d25d6.
1. It's incorrect to change the ifnet_unlock(). The original protection
range is used to make sure that the ifp does not get ripped out behind
our back.
2. We don't suffer from the issue that that commit was intended to fix.
Thanks-to: sephe
Aaron LI [Mon, 25 Jun 2018 09:59:15 +0000 (17:59 +0800)]
eventhandler.9: Update events list
* Remove "dev_clone"
* Add "iflladdr_event", "mountroot", and "usb_dev_configured".
Descriptions are taken from FreeBSD.
Aaron LI [Mon, 25 Jun 2018 09:31:16 +0000 (17:31 +0800)]
bpf: Move bpf_track event declaration to <net/bpf.h>
Move the declaration of the "bpf_track" event from <sys/eventhandler.h>
to <net/bpf.h>.
Document the "bpf_track" event in eventhandler.9 man page.
Based on FreeBSD.
Aaron LI [Mon, 25 Jun 2018 09:04:41 +0000 (17:04 +0800)]
eventhandler: Implement ifnet_link_event
The "ifnet_link_event" is triggered by the change of the link state of
an interface.
Taken-from: FreeBSD
Aaron LI [Mon, 25 Jun 2018 09:00:21 +0000 (17:00 +0800)]
eventhandler: Implement ifnet_event
Implement the "ifnet_event" which is triggered on interface up and down.
Taken-from: FreeBSD
Aaron LI [Thu, 21 Jun 2018 05:49:15 +0000 (13:49 +0800)]
if_loop: Use ifc->ifc_name and minor cleanups
* Use "ifc->ifc_name" instead of explicit "lo".
* Minor style updates.
Aaron LI [Tue, 26 Jun 2018 05:42:42 +0000 (13:42 +0800)]
pf.conf.5: Describe the use of interface group
Add the description on interface group, which is supported by DragonFly
BSD's PF now.
Meanwhile, bring in many small updates/fixes from FreeBSD.
Aaron LI [Tue, 26 Jun 2018 04:25:07 +0000 (12:25 +0800)]
Move pf.conf.5 and pf.os.5 to share/man/man5
Aaron LI [Thu, 21 Jun 2018 05:56:00 +0000 (13:56 +0800)]
net: Tweak some styles and comments
Aaron LI [Sat, 16 Jun 2018 15:18:20 +0000 (23:18 +0800)]
pf: Allow disappearing or not yet existing interfaces for ALTQ
Make ALTQ cope with disappearing interfaces (particularly common with
net/mpd4 and netgraph in general). This also allows to add queues for
an interface that is not yet existing, however, you have to provide
the bandwidth for the interface.
Meanwhile, simplify the ifnet_unlock() calls for ifunit() use.
Taken-from: FreeBSD (r177700)
Aaron LI [Sat, 16 Jun 2018 14:48:38 +0000 (22:48 +0800)]
pf: Fix and improve interface group support
The old PF code has broken partial support of the interface group.
Without this patch, loading the 'pf.ko' module will panic the system.
* Add event handlers of pfi_{attach,detach,change}_group_event()
to support the interface groups. Meanwhile, add event handler
of pfi_ifaddr_event() that is called when an address is set up
on an interface, and update pfi_{attach,detach}_event() handlers.
(Based on FreeBSD)
* Remove function pfi_kifaddr_update() as it is merged into
pfi_ifaddr_event() handler.
* Update pfi_initialize() and pfi_cleanup() functions (Based on
FreeBSD).
* Split function pfi_kif_find() out of pfi_kif_get().
(Based on OpenBSD)
* The PF module will be properly initialized on module load, so remove
extra pfi_initialize() calls.
* Rename malloc type 'PFI_MTYPE' to 'M_PFI', and merge with malloc type
'M_PFIADDRPL'.
* Staticize internal functions and variables.
* Some cleanups and style updates.
Thanks to sephe for the guidance.
Aaron LI [Thu, 21 Jun 2018 00:59:47 +0000 (08:59 +0800)]
pf: Update pfi_kif and pfi_kif_cmp structs
For struct "pfi_kif", add "pfik_name" entry while remove multiple obsolete
entries and macros. Rename "pfik_ifname" to "pfik_name" for "pfi_kif_cmp"
struct.
Based on both OpenBSD and FreeBSD.
Aaron LI [Thu, 21 Jun 2018 01:40:05 +0000 (09:40 +0800)]
if_pfsync: Depend on "pf" module and some cleanups
* Explicitly depend on the "pf" module to make sure it is initialized
later.
* Remove the unnecessary ksnprintf directive that sets if_xname.
* Order several directives in pfsync_clone_create(), making it more
consistent with pflog_clone_create().
Aaron LI [Thu, 21 Jun 2018 01:31:44 +0000 (09:31 +0800)]
if_pflog: Explicitly depend on "pf" and various cleanups
* Explicitly depend on the "pf" module to make sure it is initialized
later than the "pf" main module.
* Fix a missing lwkt token release in pflog_clone_create().
* Remove unnecessary kmalloc() check.
* Use if_initname() to properly set up if_{xname,dname,dunit}.
* Use pflogattach() in module load event handle.
* Staticize functions and variables.
* Remove the unused pflogrtrequest() function.
* Remove the "old_pfloghdr" struct from if_pflog.h.
* Mark some __unused variables.
Aaron LI [Sat, 16 Jun 2018 15:01:21 +0000 (23:01 +0800)]
ifconfig(8): Add group support
Obtained from FreeBSD, with some minor changes.
Aaron LI [Thu, 21 Jun 2018 06:40:31 +0000 (14:40 +0800)]
if_clone: Add cloned interface to the group of its device name
When a new interface is cloned, add it to the group of its device name,
e.g., cloned interfaces tapX will belong to group of "tap" by default.
Aaron LI [Sat, 16 Jun 2018 14:25:31 +0000 (22:25 +0800)]
net: Implement interface group support
The network interface group (aka ifgroup) functionality is currently only
used by the PF (still needs patch to make PF use the ifgroup), allowing
rules to use group names instead of the specific interface names, which
makes firewall rules more generic and simpler.
* The ifgroup data are stored at the following two places:
- The global list of 'struct ifg_group': each entry is a group which has
the name and members (a list of pointers to the interfaces).
- The per-ifnet 'if_groups' list, which records the groups that the
interface belongs to.
* Introduce the 'ifgroup_lock' locakmgr(9) to protect the global list
of 'struct ifg_group' and per-ifnet 'if_groups' list. The R/W locking
operations are provided by the ifgroup_lockmgr() function.
* Move the copyout() out of the locked loop in if_getgroups() and
if_getgroupmembers() functions.
* Fix several M_NOWAIT to be M_WAITOK.
* Use M_IFNET instead of M_TEMP for allocated ifgroup memory.
* Add SIOC[ADG]IFGROUP and SIOCGIFGMEMB ioctl's,
bump __DragonFly_version.
* Add invocations to group_{attach,change,detach}_event handlers.
* Update eventhandler.9 man page.
* Some style updates.
Great thanks to sephe for his patient guidance and review.
Credit to both FreeBSD and OpenBSD for the ifgroup functionality.
NOTE:
When delete the only group from an interface, which leaves an empty
group that will be destroyed, make sure the group_change_event event
is invoked *before* the group destroy (i.e., group_detach_event).
Both FreeBSD and OpenBSD have the ordering problem with group detach
event. Need to report the problem to them.
Aaron LI [Mon, 6 Aug 2018 07:36:41 +0000 (15:36 +0800)]
if_clone: Refactor out if_clone_createif() function
The new if_clone_createif() function will create a clone interface
with the given cloner and unit.
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.
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.
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.
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).
Aaron LI [Tue, 7 Aug 2018 02:40:31 +0000 (10:40 +0800)]
development.7: Update repo creation command
Reported-by: resolution (on IRC)
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.
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).
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.
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.
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.
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.
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.
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.
Aaron LI [Sun, 5 Aug 2018 02:40:46 +0000 (10:40 +0800)]
etc/login.conf: Fix COPYRIGHT file path
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)
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.
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.
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)
Aaron LI [Fri, 23 Mar 2018 01:37:13 +0000 (09:37 +0800)]
ifconfig(8): Use strlcpy() instead of strncpy()
Aaron LI [Tue, 20 Mar 2018 07:45:43 +0000 (15:45 +0800)]
ifconfig(8): Use nitems() consistently
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>.