git: if_clone: Refactor cloner lookup and unit extraction

2018-08-04 Thread Aaron LI


commit 2010725f220e9d634a6a5904b38db67627cb3a80
Author: Aaron LI 
Date:   Sat Aug 4 20:06:21 2018 +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.

Summary of changes:
 sys/net/if_clone.c | 105 +
 1 file changed, 73 insertions(+), 32 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/2010725f220e9d634a6a5904b38db67627cb3a80


-- 
DragonFly BSD source repository


git: if_clone: Fix if_clone_destroy() with renamed cloned interface

2018-08-04 Thread Aaron LI


commit 3b1300daa841e3b20ed7417394ab6039c5f2506b
Author: Aaron LI 
Date:   Sat Aug 4 20:30:04 2018 +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 tap
% ifconfig tap 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  and Brady OBrien
 for pointing out the above problem (1).

Summary of changes:
 sys/net/if_clone.c | 36 +++-
 1 file changed, 15 insertions(+), 21 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/3b1300daa841e3b20ed7417394ab6039c5f2506b


-- 
DragonFly BSD source repository


git: if_clone: Remove unneeded "ifc_namelen" from "struct if_clone"

2018-08-04 Thread Aaron LI


commit e224e5e71c0cee920b6a50d3397ff5e45be95e9a
Author: Aaron LI 
Date:   Sat Aug 4 20:13:39 2018 +0800

if_clone: Remove unneeded "ifc_namelen" from "struct if_clone"

The "strlen(ifc_name)" is used instead.

Summary of changes:
 sys/net/if_clone.c | 2 +-
 sys/net/if_clone.h | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/e224e5e71c0cee920b6a50d3397ff5e45be95e9a


-- 
DragonFly BSD source repository


git: if_clone: Move "struct if_clonereq" over from

2018-08-04 Thread Aaron LI


commit 687c518e9dcb04166a0c34c27d609eaf82d1a5e2
Author: Aaron LI 
Date:   Thu Jun 21 08:36:00 2018 +0800

if_clone: Move "struct if_clonereq" over from 

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  to be clearer.

Summary of changes:
 sbin/ifconfig/ifclone.c |  1 +
 sys/net/if.h| 14 ++
 sys/net/if_clone.h  | 13 +++--
 3 files changed, 14 insertions(+), 14 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/687c518e9dcb04166a0c34c27d609eaf82d1a5e2


-- 
DragonFly BSD source repository


git: if_clone: Fix if_clone_event invocation

2018-08-04 Thread Aaron LI


commit 0de0168f3274e2e1ddf79404ed32abbef82a8893
Author: Aaron LI 
Date:   Thu Jun 21 08:42:16 2018 +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.

Summary of changes:
 share/man/man9/EVENTHANDLER.9 | 6 +++---
 sys/net/if_clone.c| 5 ++---
 2 files changed, 5 insertions(+), 6 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/0de0168f3274e2e1ddf79404ed32abbef82a8893


-- 
DragonFly BSD source repository


git: if_clone: Refactor if_clone_create()

2018-08-04 Thread Aaron LI


commit 84cb91c376f39e5cbfcc52664bc818ac8154e0c6
Author: Aaron LI 
Date:   Fri Jun 22 21:47:22 2018 +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.

Summary of changes:
 sys/net/if_clone.c | 40 
 1 file changed, 20 insertions(+), 20 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/84cb91c376f39e5cbfcc52664bc818ac8154e0c6


-- 
DragonFly BSD source repository


git: Makefile.inc1: Print more variables on error

2018-08-04 Thread Aaron LI


commit 81c8572743904f1c4c2a1f44b4edbc274122ea11
Author: Aaron LI 
Date:   Fri Jun 15 13:01:54 2018 +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)

Summary of changes:
 Makefile.inc1 | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/81c8572743904f1c4c2a1f44b4edbc274122ea11


-- 
DragonFly BSD source repository


git: etc/login.conf: Fix COPYRIGHT file path

2018-08-04 Thread Aaron LI


commit e72f0762b947abfb33852312cbec661ce8761559
Author: Aaron LI 
Date:   Sun Aug 5 10:40:46 2018 +0800

etc/login.conf: Fix COPYRIGHT file path

Summary of changes:
 etc/login.conf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/e72f0762b947abfb33852312cbec661ce8761559


-- 
DragonFly BSD source repository


git: ifconfig(8): Use atexit() to ensure printing interface name

2018-08-04 Thread Aaron LI


commit e9e1626f77881d1971173b83792c178b084ff759
Author: Aaron LI 
Date:   Fri Jun 22 21:23:25 2018 +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.

Summary of changes:
 sbin/ifconfig/ifconfig.c | 28 
 1 file changed, 20 insertions(+), 8 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/e9e1626f77881d1971173b83792c178b084ff759


-- 
DragonFly BSD source repository


git: ifconfig(8): Use nitems() consistently

2018-08-04 Thread Aaron LI


commit b6b91ec7b04797351b4efc099cd2b5530c90a328
Author: Aaron LI 
Date:   Tue Mar 20 15:45:43 2018 +0800

ifconfig(8): Use nitems() consistently

Summary of changes:
 sbin/ifconfig/af_inet6.c|  4 +---
 sbin/ifconfig/ifbridge.c|  6 ++
 sbin/ifconfig/ifcarp.c  |  4 +---
 sbin/ifconfig/ifclone.c |  4 +---
 sbin/ifconfig/ifconfig.c|  6 +-
 sbin/ifconfig/ifieee80211.c | 12 +++-
 sbin/ifconfig/iflagg.c  | 10 --
 sbin/ifconfig/ifmedia.c |  4 +---
 sbin/ifconfig/ifvlan.c  |  4 +---
 sbin/ifconfig/regdomain.c   |  2 +-
 10 files changed, 16 insertions(+), 40 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/b6b91ec7b04797351b4efc099cd2b5530c90a328


-- 
DragonFly BSD source repository


git: ifconfig(8): Sync with FreeBSD a bit and various cleanups

2018-08-04 Thread Aaron LI


commit 46158ff547aeb44d75edbca7a8c8ecd565aec166
Author: Aaron LI 
Date:   Sat Mar 24 16:56:39 2018 +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.

Summary of changes:
 sbin/ifconfig/Makefile  |   6 +-
 sbin/ifconfig/af_inet.c |  21 ++---
 sbin/ifconfig/af_inet6.c|  45 +
 sbin/ifconfig/af_link.c |   8 +-
 sbin/ifconfig/ifbridge.c|  20 ++--
 sbin/ifconfig/ifcarp.c  |  13 +--
 sbin/ifconfig/ifclone.c |  22 +++--
 sbin/ifconfig/ifconfig.c| 127 -
 sbin/ifconfig/ifconfig.h|   9 +-
 sbin/ifconfig/ifieee80211.c | 224 
 sbin/ifconfig/iflagg.c  |  23 ++---
 sbin/ifconfig/ifmedia.c |  11 +--
 sbin/ifconfig/ifvlan.c  |  11 +--
 sbin/ifconfig/regdomain.c   |  29 +++---
 sbin/ifconfig/regdomain.h   |  16 +++-
 15 files changed, 299 insertions(+), 286 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/46158ff547aeb44d75edbca7a8c8ecd565aec166


-- 
DragonFly BSD source repository


git: ifconfig(8): Use strlcpy() instead of strncpy()

2018-08-04 Thread Aaron LI


commit 80d2947bc9bb9395f7b2e028b5582c23a2858812
Author: Aaron LI 
Date:   Fri Mar 23 09:37:13 2018 +0800

ifconfig(8): Use strlcpy() instead of strncpy()

Summary of changes:
 sbin/ifconfig/af_inet.c |  4 ++--
 sbin/ifconfig/ifcarp.c  |  4 ++--
 sbin/ifconfig/ifclone.c |  4 ++--
 sbin/ifconfig/ifconfig.c| 20 ++--
 sbin/ifconfig/ifieee80211.c | 20 ++--
 sbin/ifconfig/ifmedia.c | 11 +--
 sbin/ifconfig/ifvlan.c  |  2 +-
 7 files changed, 32 insertions(+), 33 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/80d2947bc9bb9395f7b2e028b5582c23a2858812


-- 
DragonFly BSD source repository


git: : Do not include for _KERNEL

2018-08-04 Thread Aaron LI


commit bff82488b6f45c2f067e4c552e649b1d3e07cd7c
Author: Aaron LI 
Date:   Tue Mar 20 16:04:41 2018 +0800

: Do not include  for _KERNEL

* Clean up an ancient leftover: do not include  from 

  for kernel stuffs.

* Adjust various files to include the necessary  header.

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

Summary of changes:
 sys/bus/u4b/net/if_udav.c |  2 ++
 sys/bus/u4b/usb_pf.c  |  1 +
 sys/dev/netif/ig_hal/e1000_osdep.c|  2 +-
 sys/dev/netif/mii_layer/acphy.c   |  1 +
 sys/dev/netif/mii_layer/amphy.c   |  1 +
 sys/dev/netif/mii_layer/e1000phy.c|  1 +
 sys/dev/netif/mii_layer/exphy.c   |  1 +
 sys/dev/netif/mii_layer/inphy.c   |  1 +
 sys/dev/netif/mii_layer/jmphy.c   |  1 +
 sys/dev/netif/mii_layer/lxtphy.c  |  1 +
 sys/dev/netif/mii_layer/mii_physubr.c |  1 +
 sys/dev/netif/mii_layer/mlphy.c   |  1 +
 sys/dev/netif/mii_layer/nsgphy.c  |  1 +
 sys/dev/netif/mii_layer/nsphy.c   |  1 +
 sys/dev/netif/mii_layer/pnaphy.c  |  1 +
 sys/dev/netif/mii_layer/qsphy.c   |  1 +
 sys/dev/netif/mii_layer/ruephy.c  |  1 +
 sys/dev/netif/mii_layer/tlphy.c   |  1 +
 sys/dev/netif/mii_layer/ukphy.c   |  1 +
 sys/dev/netif/mii_layer/xmphy.c   |  1 +
 sys/dev/netif/ral/if_ral_pci.c|  1 +
 sys/dev/netif/sln/if_sln.c|  4 ++--
 sys/emulation/ndis/subr_u4bd.c|  1 +
 sys/kern/kern_uuid.c  |  1 +
 sys/kern/sys_socket.c |  1 +
 sys/net/altq/altq_red.c   |  1 +
 sys/net/altq/altq_rio.c   |  1 +
 sys/net/altq/altq_rmclass.c   |  1 +
 sys/net/dummynet/ip_dummynet.c|  1 +
 sys/net/dummynet3/ip_dummynet3.c  |  1 +
 sys/net/if.h  |  8 +---
 sys/net/if_clone.c|  1 +
 sys/net/if_media.c|  1 +
 sys/net/if_mib.c  |  1 +
 sys/net/if_poll.c |  1 +
 sys/net/ipfw3/ip_fw3.c| 12 ++--
 sys/net/ipfw3_basic/ip_fw3_sync.c | 12 ++--
 sys/net/ipfw3_basic/ip_fw3_table.c| 12 ++--
 sys/net/ipfw3_layer2/ip_fw3_layer2.c  |  1 +
 sys/net/ipfw3_layer4/ip_fw3_layer4.c  | 13 +++--
 sys/net/net_osdep.c   |  1 +
 sys/net/pf/pf_norm.c  |  1 +
 sys/net/pfil.c|  1 +
 sys/net/route.c   |  1 +
 sys/net/rtsock.c  |  1 +
 sys/netbt/hci.h   |  3 ++-
 sys/netgraph/bridge/ng_bridge.c   |  1 +
 sys/netgraph/pppoe/ng_pppoe.c |  1 +
 sys/netinet/tcp_output.c  |  1 +
 sys/netproto/802_11/wlan/ieee80211_crypto.c   |  1 +
 sys/netproto/802_11/wlan/ieee80211_crypto_none.c  |  1 +
 sys/netproto/802_11/wlan/ieee80211_hwmp.c |  1 +
 sys/netproto/802_11/wlan/ieee80211_phy.c  |  1 +
 sys/netproto/802_11/wlan/ieee80211_ratectl.c  |  1 +
 sys/netproto/802_11/wlan/ieee80211_ratectl_none.c |  1 +
 sys/netproto/802_11/wlan/ieee80211_tdma.c |  1 +
 sys/netproto/802_11/wlan_acl/ieee80211_acl.c  |  1 +
 sys/netproto/802_11/wlan_ccmp/ieee80211_crypto_ccmp.c |  1 +
 sys/netproto/802_11/wlan_tkip/ieee80211_crypto_tkip.c |  1 +
 sys/netproto/802_11/wlan_wep/ieee80211_crypto_wep.c   |  1 +
 sys/netproto/802_11/wlan_xauth/ieee80211_xauth.c  |  1 +
 sys/vfs/nfs/nfs_vfsops.c  |  1 +
 62 files changed, 86 insertions(+), 35 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/bff82488b6f45c2f067e4c552e649b1d3e07cd7c


-- 
DragonFly BSD source repository


git: : Clean up unused forward declaration

2018-08-04 Thread Aaron LI


commit 03d44125d13c9b84745fca401c1fd8cefd5db97b
Author: Aaron LI 
Date:   Tue Mar 20 16:15:42 2018 +0800

: Clean up unused forward declaration

Also remove the inclusion of an unnecessary header .

Summary of changes:
 sys/net/if_var.h | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/03d44125d13c9b84745fca401c1fd8cefd5db97b


-- 
DragonFly BSD source repository


git: pc64 - If appropriate, determine TSC frequency via CPUID.

2018-08-04 Thread Imre Vadasz


commit 8b257adbda32b59bb93cb76a5daa122a9252f6c0
Author: Imre Vadász 
Date:   Sat Aug 4 17:09:26 2018 +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.

Summary of changes:
 sys/platform/pc64/x86_64/initcpu.c | 69 ++
 1 file changed, 69 insertions(+)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/8b257adbda32b59bb93cb76a5daa122a9252f6c0


-- 
DragonFly BSD source repository


git: if_tap: Interface type should be IFT_ETHER (2)

2018-08-04 Thread Aaron LI


commit e389314b1feb6a5659f5f52a71878f14c29091af
Author: Aaron LI 
Date:   Sat Aug 4 22:06:32 2018 +0800

if_tap: Interface type should be IFT_ETHER (2)

Ooops, forgot to include the necessary header  in the
last commit.

Summary of changes:
 sys/net/tap/if_tap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/e389314b1feb6a5659f5f52a71878f14c29091af


-- 
DragonFly BSD source repository


git: if_tap: Interface type should be IFT_ETHER

2018-08-04 Thread Aaron LI


commit ce57146ea9d232b3f8a60279de0bdf859bde4c3f
Author: Aaron LI 
Date:   Sat Aug 4 21:07:04 2018 +0800

if_tap: Interface type should be IFT_ETHER

Summary of changes:
 sys/net/tap/if_tap.c | 1 +
 1 file changed, 1 insertion(+)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/ce57146ea9d232b3f8a60279de0bdf859bde4c3f


-- 
DragonFly BSD source repository


git: corepower - Add support for Platform Energy Counter.

2018-08-04 Thread Imre Vadasz


commit 214ee9b53298179f8906c527caa25e5a212ec8c6
Author: Imre Vadász 
Date:   Sat Aug 4 10:58:17 2018 +0200

corepower - Add support for Platform Energy Counter.

Summary of changes:
 sys/cpu/x86_64/include/specialreg.h|  1 +
 sys/dev/powermng/corepower/corepower.c | 21 ++---
 2 files changed, 19 insertions(+), 3 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/214ee9b53298179f8906c527caa25e5a212ec8c6


-- 
DragonFly BSD source repository