Commit Graph

8313 Commits

Author SHA1 Message Date
Sevan Janiyan
369cef877e Document which version of BSD first showed up in and add the version info
for NetBSD & FreeBSD.

PR:		212477
Approved by:	bcr (mentor)
MFC after:	4 days
Differential Revision:	https://reviews.freebsd.org/D8105
2016-10-02 23:44:52 +00:00
Sevan Janiyan
4cbf025741 Mention the version of NetBSD the utility originated from.
PR:		212476
Approved by:	bcr (mentor)
MFC after:	4 days
Differential Revision:	https://reviews.freebsd.org/D8105
2016-10-02 23:40:17 +00:00
Sevan Janiyan
0530a5214f dumpon(8) appears to be present in FreeBSD 2.0.5,
despite initial import of man page listed FreeBSD 2.1.

PR:		212445
Approved by:	bcr (mentor)
MFC after:	4 days
Differential Revision:	https://reviews.freebsd.org/D8105
2016-10-02 23:35:45 +00:00
Sevan Janiyan
b26d109830 dump(8) first appeared in V4 UNIX
http://minnie.tuhs.org/cgi-bin/utree.pl?file=V4/man/man8

PR:		212444
Approved by:	bcr (mentor)
Obtained from:	TUHS
MFC after:	4 days
Differential Revision:	https://reviews.freebsd.org/D8105
2016-10-02 23:30:28 +00:00
Sevan Janiyan
ed760cd867 dmesg(8) first appeared in 3BSD.
http://minnie.tuhs.org/cgi-bin/utree.pl?file=3BSD/usr/man/man1/dmesg.1m

PR:		212443
Approved by:	bcr (mentor)
Obtained from:	TUHS
MFC after:	4 days
Differential Revision:	https://reviews.freebsd.org/D8105
2016-10-02 23:26:41 +00:00
Sevan Janiyan
494b4bb3d3 ccdconfig first appeared in NetBSD 1.1
From NetBSD man page, confirmed with repo tags in CVS [1]
(there was also no 1.0a release according to [2])

[1] http://cvsweb.netbsd.org/bsdweb.cgi/src/sbin/ccdconfig/ccdconfig.c
[2] http://netbsd.org/releases/formal.html#history

PR:		212437
Approved by:	bcr (mentor)
Obtained from:	NetBSD
MFC after:	4 days
Differential Revision:	https://reviews.freebsd.org/D8105
2016-10-02 23:19:05 +00:00
Jilles Tjoelker
a7d1d41617 swapon(8): Update to reality: swapoff ignores -L and the late option in fstab.
MFC after:	1 week
2016-10-02 15:01:31 +00:00
Sevan Janiyan
05b831f644 Igor suggested moving sentence to new line.
Zap traililng whitespace.

PR:		212447
Approved by:	bcr (mentor)
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D8116
2016-10-02 14:32:04 +00:00
Marcelo Araujo
dc7c777336 Indicate that this is a locally administered MAC address.
Submitted by:	lidl
Differential Revision:	https://reviews.freebsd.org/D7903
2016-09-27 17:37:23 +00:00
Ruslan Bukin
5b1b1405e3 Use bsdlabel as we don't have hardlink disklabel -> bsdlabel on MIPS.
Sponsored by:	DARPA, AFRL
Sponsored by:	HEIF5
2016-09-26 14:01:41 +00:00
Alan Somers
0696afbe09 Mount msdosfs with longnames support by default.
The old behavior depended on the FAT version and on what files were in the
root directory. "mount_msdosfs -o shortnames" is still supported.

Reviewed by:	wblock, cem
Discussed with:	trasz, adrian, imp
MFC after:	4 weeks
X-MFC-Notes:	Don't MFC the removal of findwin95
Differential Revision:	https://reviews.freebsd.org/D8018
2016-09-23 19:05:07 +00:00
Conrad Meyer
85190f81bb dhclient(8): Enable numbered user class ID option
By adding it to the option priorities table.

PR:		184117
Submitted by:	Lowell Gilbert <freebsd-bugs-local at be-well.ilk.org>
Reported by:	Tomek CEDRO <cederom at tlen.pl>
Reviewed by:	jhb
Differential Revision:	https://reviews.freebsd.org/D7911
2016-09-20 19:21:41 +00:00
Pedro F. Giffuni
8967299b33 mount(1): Simplify by using asprintf(3)
Instead of strlen() + malloc() + snprintf, just use asprintf().
No functional change.

Obtained from:	OpenBSD (CVS Rev. 1.67)
2016-09-19 18:42:58 +00:00
Konstantin Belousov
944e0bab86 Consolidate four efi_next_descriptor() definitions.
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2016-09-18 17:38:02 +00:00
Marcelo Araujo
f405b03367 Invert calloc(3) argument order.
Reviewed by:	ed.
MFC after:	4 weeks.
Differential Revision:	https://reviews.freebsd.org/D7902
2016-09-16 05:33:08 +00:00
Allan Jude
0fcf43f6f3 Add missing history sections to a number of storage related man pages
gmultipath.8: Add HISTORY
	Adjust sentences with bad phrases picked up by igor

ggatec.8: Add HISTORY

ggated.8: Add HISTORY

ggatel.8: Add HISTORY
	Seperate out sentence as advised by igor.

hastctl.8: Add HISTORY

hastd.8: Add HISTORY
	Fix sentence highlighted by igor.

iscontrol.8: Add HISTORY

mdmfs.8: Add HISTORY
	Address issues raised by igor

mount_nfs.8: Add HISTORY
	Not sure where mount_nfs first showed up, but the verison used
	in the BSD's originates from 4.4BSD according to CSRG archive.

	Though commercial offerings from Sun and others covers older
	systems, eg https://groups.google.com/forum/#!topic/net.unix-wizards/lMe7aQikqJI

nandfs.8: Add HISTORY
	Adjust sentence in description to address bad phrase highlighted
	by igor.

nvmecontrol.8: Add HISTORY

PR:		212491
PR:		212498
PR:		212499
PR:		212500
PR:		212501
PR:		212502
PR:		212505
PR:		212508
PR:		212540
PR:		212543
PR:		212546
Submitted by:	Sevan Janiyan <venture37@geeklan.co.uk>
2016-09-16 04:28:31 +00:00
Marcelo Araujo
e700bef2dc Add an option called "random" that combined with "ether" can generate a
random MAC address for an Ethernet interface.

PR:		211984
Submitted by:	pi@
Reviewed by:	gnn, cem, jhb, lidl, rpokala, wblock
Approved by:	wblock (manpages)
2016-09-16 04:22:21 +00:00
Allan Jude
f1a6b7cb09 sbin/umount/umount.8: Amend HISTORY
umount first appeared in V1, confirmed using TUHS archive
http://minnie.tuhs.org/cgi-bin/utree.pl?file=V1/man/man1/umount.1

PR:		212554
Submitted by:	Sevan Janiyan <venture37@geeklan.co.uk>
2016-09-16 04:12:32 +00:00
Allan Jude
9dd4cc10f9 sbin/reboot/reboot.8: Amend HISTORY
A standalone reboot utility showed up in 4.0BSD, in AT&T UNIX init has a
case for reboot and is present in the version shipped with V5

either way, current entry is incorrect.

PR:		212548
Submitted by:	Sevan Janiyan <venture37@geeklan.co.uk>
2016-09-16 04:11:04 +00:00
Allan Jude
ef0a975fbe sbin/rcorder/rcorder.8: Amend HISTORY
rcorder appeared in FreeBSD 5.0.
Address issues raised by igor.

PR:		212547
Submitted by:	Sevan Janiyan <venture37@geeklan.co.uk>
2016-09-16 04:08:34 +00:00
Conrad Meyer
387016a576 dhclient: add support for interface-mtu (26)
Make dhclient set interface MTU if it was provided.

This version implements MTU setting in dhclient itself before it runs
dhclient-script.

PR:		206721
Submitted by:	novel@
Reported by:	Jarrod Petz <jlpetz at gmail.com>
Reviewed by:	cem, allanjude
Differential Revision:	https://reviews.freebsd.org/D5675
2016-09-02 21:14:29 +00:00
Warner Losh
bf0d940a2f The code only converts from bpbHugeSectors to bpbSectors if the sum of
the hidden and huge sectors is less than or equal MAXU16. When
formatting in Windows bpbSectors is still used for 63488 sectors and
2048 hidden (sum > MAXU16). The hidden sectors count is the number of
sectors before the FAT16 Boot Record so it shouldn't affect the sector
count. Attached patch (huge_sec_conversion.patch) to only check for
bpb.bpbHugeSectors <= MAXU16 when converting to bpbSectors.

Submitted by: Guy Yur
PR: 183234
2016-08-30 18:01:26 +00:00
Warner Losh
4a9fb9fb80 Remove CHS alignment. It's not needed and causes problems for the BBB
boot partition. NetBSD removed it in 1.10 in their repo some time ago.

Submitted by: Guy Yur
PR: 183234
2016-08-30 18:01:19 +00:00
Dimitry Andric
1fc157ae91 Define hastd's STRICT_ALIGN macro in a defined and portable way.
MFC after:	3 days
2016-08-28 21:26:11 +00:00
Alex Kozlov
c650c2f355 Remove last remnants of acd(4), mcd(4), and scd(4) drivers.
Approved by:	jhb
2016-08-25 19:36:58 +00:00
Alexander Motin
6377527147 Fix minor copy/paste bug.
Submitted by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after:	1 week
2016-08-24 15:13:42 +00:00
Eric Badger
6ff6aea629 Fix missing substitution of @SBINDIR@ in resolvconf scripts
Certain features, such as resolv_conf_passthrough=NULL, do not work
correctly due to this missing substitution.

Also remove the @PREFIX@ substitution, which is no longer needed.

Reviewed by:	pfg
Approved by:	vangyzen (mentor)
MFC after:	1 week
Sponsored by:	Dell Inc.
Differential Revision:	https://reviews.freebsd.org/D7572
2016-08-23 02:06:20 +00:00
Bjoern A. Zeeb
77ecef378a Remove the kernel optoion for IPSEC_FILTERTUNNEL, which was deprecated
more than 7 years ago in favour of a sysctl in r192648.
2016-08-21 18:55:30 +00:00
Kirk McKusick
6a5972db72 Fsck_ufs was using an int rather than a ufs2_daddr_t to store the
alternate superblock location when given in the -b option. When int
is 32-bits, block numbers larger than 2^32 would get truncated. This
commit changes the storage fpr the alternate superblock location
to a ufs2_daddr_t.

Submitted by: Dmitry Sivachenko <trtrmitya@gmail.com>
2016-08-19 00:03:41 +00:00
Andrey V. Elsukov
4a2ea55b11 Add an ability to attach comment to check-state rules.
MFC after:	1 week
2016-08-14 18:34:16 +00:00
Andrey V. Elsukov
58d358e5a1 Do not warn about ambiguous state name when we inspect a comment token.
Reported by:	lev
2016-08-14 18:05:41 +00:00
Andrey V. Elsukov
c5e85276ac Make statistics nat64lsn, nat64stl an nptv6 output netstat-like:
"@value @description" and fix build due to -Wformat errors.
2016-08-14 13:17:55 +00:00
Andrey V. Elsukov
57fb3b7a78 Add stats reset command implementation to NPTv6 module
to be able reset statistics counters.

Obtained from:	Yandex LLC
Sponsored by:	Yandex LLC
2016-08-13 16:45:14 +00:00
Andrey V. Elsukov
d8caf56e9e Add ipfw_nat64 module that implements stateless and stateful NAT64.
The module works together with ipfw(4) and implemented as its external
action module.

Stateless NAT64 registers external action with name nat64stl. This
keyword should be used to create NAT64 instance and to address this
instance in rules. Stateless NAT64 uses two lookup tables with mapped
IPv4->IPv6 and IPv6->IPv4 addresses to perform translation.

A configuration of instance should looks like this:
 1. Create lookup tables:
 # ipfw table T46 create type addr valtype ipv6
 # ipfw table T64 create type addr valtype ipv4
 2. Fill T46 and T64 tables.
 3. Add rule to allow neighbor solicitation and advertisement:
 # ipfw add allow icmp6 from any to any icmp6types 135,136
 4. Create NAT64 instance:
 # ipfw nat64stl NAT create table4 T46 table6 T64
 5. Add rules that matches the traffic:
 # ipfw add nat64stl NAT ip from any to table(T46)
 # ipfw add nat64stl NAT ip from table(T64) to 64:ff9b::/96
 6. Configure DNS64 for IPv6 clients and add route to 64:ff9b::/96
    via NAT64 host.

Stateful NAT64 registers external action with name nat64lsn. The only
one option required to create nat64lsn instance - prefix4. It defines
the pool of IPv4 addresses used for translation.

A configuration of instance should looks like this:
 1. Add rule to allow neighbor solicitation and advertisement:
 # ipfw add allow icmp6 from any to any icmp6types 135,136
 2. Create NAT64 instance:
 # ipfw nat64lsn NAT create prefix4 A.B.C.D/28
 3. Add rules that matches the traffic:
 # ipfw add nat64lsn NAT ip from any to A.B.C.D/28
 # ipfw add nat64lsn NAT ip6 from any to 64:ff9b::/96
 4. Configure DNS64 for IPv6 clients and add route to 64:ff9b::/96
    via NAT64 host.

Obtained from:	Yandex LLC
Relnotes:	yes
Sponsored by:	Yandex LLC
Differential Revision:	https://reviews.freebsd.org/D6434
2016-08-13 16:09:49 +00:00
Andrey V. Elsukov
d6eb9b0249 Restore "nat global" support.
Now zero value of arg1 used to specify "tablearg", use the old "tablearg"
value for "nat global". Introduce new macro IP_FW_NAT44_GLOBAL to replace
hardcoded magic number to specify "nat global". Also replace 65535 magic
number with corresponding macro. Fix typo in comments.

PR:		211256
Tested by:	Victor Chernov
MFC after:	3 days
2016-08-11 10:10:10 +00:00
Andrey V. Elsukov
b055e3be51 Fix formatting of setfib opcode.
Zero fib is correct value and it conflicts with IP_FW_TARG.
Use bprint_uint_arg() only when opcode contains IP_FW_TARG,
otherwise just print numeric value with cleared high-order bit.

MFC after:	3 days
2016-08-08 18:30:50 +00:00
Andrey V. Elsukov
78724b5251 Fix constructing of setdscp opcode with tablearg keyword.
setdscp's argument can have zero value that conflicts with IP_FW_TARG value.
Always set high-order bit if parser doesn't find tablearg keyword.

MFC after:	3 days
2016-08-08 18:10:30 +00:00
Luiz Otavio O Souza
7f8af000a9 Fix a regression in pf.conf while parsing the 'interval' keyword.
The bug was introduced by r287009.

PR:		210924
Submitted by:	kp@
Sponsored by:	Rubicon Communications (Netgate)
Pointy hat to:	loos
2016-08-05 02:19:03 +00:00
Kristof Provost
13cfafabf4 pfctl: Make most global variables static.
This will make it easier to link as a library.

Submitted by:	Christian Mauderer <christian.mauderer@embedded-brains.de>
2016-08-04 19:24:44 +00:00
Kristof Provost
233e1432b7 pfctl: Add missing __FBSDID to pfctl_osfp.c 2016-08-04 19:24:05 +00:00
Adrian Chadd
1cec2c734a [etherswitch] add LED API to the documentation and command line tool.
Submitted by:	Dan Nelson <dnelson_1901@yahoo.com>
2016-08-04 17:46:07 +00:00
Mariusz Zaborski
451cad50cd Fix misleading description of the -b option in the geli init command.
Reviewed by:		bjk, wblock
Differential Revision:	https://reviews.freebsd.org/D7226
Discussed with:		AllanJude
2016-08-03 18:02:10 +00:00
Kristof Provost
72a3cf0f41 pfctl: Use const where possible.
This adds const qualifiers where it is possible.

Submitted by:	Christian Mauderer <christian.mauderer@embedded-brains.de>
2016-08-02 20:32:02 +00:00
Kristof Provost
9a5e33be57 pfctl: Match prototype of pfctl_load_hostid.
The prototype and the implementation of the pfctl_load_hostid used a
different data type for one of the parameters.

Submitted by:	Christian Mauderer <christian.mauderer@embedded-brains.de>
2016-08-02 19:54:40 +00:00
Kristof Provost
0cd7a91aa7 pfctl: Allow TOS bits to be cleared
TOS value 0 is valid, so use 256 as an invalid value rather than zero.
This allows users to enforce TOS == 0 with pf.

Reported by:	Radek Krejča <radek.krejca@starnet.cz>
2016-08-02 15:41:42 +00:00
Andrey V. Elsukov
76d0325743 An old tables implementation had all tables preallocated,
so when user did `ipfw table N flush` it always worked, but now
when table N doesn't exist the kernel returns ESRCH error.
This isn't fatal error for flush and destroy commands. Do not
call err(3) when errno is equal to ESRCH. Also warn only when
quiet mode isn't enabled. This fixes a regression in behavior,
when old rules are loaded from file.
Also use correct value for switch in the table_swap().

Reported by:	Kevin Oberman
MFC after:	3 days
2016-08-01 13:38:48 +00:00
Pedro F. Giffuni
6a88c69fe0 resolvconf(8) now needs an additional @RESTARTCMD@ replacement when installing.
After r303062, which brought openresolv 3.8.1, we need to replace an
additional @RESTARTCMD@ in resolvconf.
Apply a read fix this time.

Submitted by:	Guy Yur
X-MFC with:	r303062
2016-07-31 18:14:42 +00:00
Pedro F. Giffuni
ce6b5c0ac4 resolvconf(8) now needs an additional @RESTARTCMD@ replacement when installing.
After r303062, which brought openresolv 3.8.1, we need to replace an
additional @RESTARTCMD@ in resolvconf.

Reported by:	Guy Yur
X-MFC with:	r303062
2016-07-31 02:54:27 +00:00
Marcelo Araujo
02c8c1182b Use nitems() from sys/param.h.
Sponsored by:	gandi.net (BSD Day Taiwan)
2016-07-30 06:19:34 +00:00
Andrey V. Elsukov
6a5d9be9fe Due to dropped mbuf in netisr queue route(8) can fall into infinity
loop of reading the rtsock's feed. When it used by some scripts,
this leads to growing number of not finished route(8) instances and
thus growing number of rtsock consumers. Add SIGALRM handler to prevent this.

Reviewed by:	melifaro
Obtained from:	Yandex LLC
MFC after:	2 weeks
Sponsored by:	Yandex LLC
2016-07-27 08:26:34 +00:00
Dag-Erling Smørgrav
ae1b731b5d Rewrite the GPT and MBR examples. For GPT, ensure that the boot partition
is large enough for gptzfsboot, which has doubled in size since 10.

PR:		211361
MFC after:	3 days
2016-07-25 11:25:33 +00:00
Andrey V. Elsukov
ed22e564b8 Add named dynamic states support to ipfw(4).
The keep-state, limit and check-state now will have additional argument
flowname. This flowname will be assigned to dynamic rule by keep-state
or limit opcode. And then can be matched by check-state opcode or
O_PROBE_STATE internal opcode. To reduce possible breakage and to maximize
compatibility with old rulesets default flowname introduced.
It will be assigned to the rules when user has omitted state name in
keep-state and check-state opcodes. Also if name is ambiguous (can be
evaluated as rule opcode) it will be replaced to default.

Reviewed by:	julian
Obtained from:	Yandex LLC
MFC after:	1 month
Relnotes:	yes
Sponsored by:	Yandex LLC
Differential Revision:	https://reviews.freebsd.org/D6674
2016-07-19 04:56:59 +00:00
Andrey V. Elsukov
b867e84e95 Add ipfw_nptv6 module that implements Network Prefix Translation for IPv6
as defined in RFC 6296. The module works together with ipfw(4) and
implemented as its external action module. When it is loaded, it registers
as eaction and can be used in rules. The usage pattern is similar to
ipfw_nat(4). All matched by rule traffic goes to the NPT module.

Reviewed by:	hrs
Obtained from:	Yandex LLC
MFC after:	1 month
Relnotes:	yes
Sponsored by:	Yandex LLC
Differential Revision:	https://reviews.freebsd.org/D6420
2016-07-18 19:46:31 +00:00
Cy Schubert
b04471d88a r302561 broke buildworld. This patch fixes that.
MFC after:	3 days
X-MFC with:	r302561
2016-07-11 13:41:40 +00:00
Andrey V. Elsukov
fcbdb770aa Flush buffer after output. This fixes adding new data to already
printed flows.

PR:		210882
MFC after:	3 days
2016-07-11 12:44:58 +00:00
Edward Tomasz Napierala
debc480e03 Add new unmount(2) flag, MNT_NONBUSY, to check whether there are
any open vnodes before proceeding. Make autounmound(8) use this flag.
Without it, even an unsuccessfull unmount causes filesystem flush,
which interferes with normal operation.

Reviewed by:	kib@
Approved by:	re (gjb@)
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D7047
2016-07-07 09:03:57 +00:00
Marcelo Araujo
8ac248ea27 Fix a regression introduced on revision r271909, when using argument -g
or several hops we have segmentation fault because we overwrite the same
structure to store information for host and gateway.

Submitted by:	Maryse Levavasseur <maryse.levavasseur@stormshield.eu>
Reworked by:	hrs
Approved by:	re (hrs)
Differential Revision:	https://reviews.freebsd.org/D6980
2016-07-05 07:01:42 +00:00
Andrey V. Elsukov
e62cd31f75 Hide warning about non-existent lookup tables and informational messages
about modified table entry when quied mode enabled.

Approved by:	re (hrs)
Obtained from:	Yandex LLC
2016-07-02 11:54:20 +00:00
Poul-Henning Kamp
6481f66b90 Do not coredump if the packet is too long in the global (non-interface
associated) instance.

The result is that the packet is dropped without an indication
that smaller MTU is advisable, which is not optimal, but better
than a NULL pointer deref.

Approved by:	re (glebius)
2016-06-28 20:10:30 +00:00
Alan Somers
4dad99bf48 Fix "sysctl vm.vmtotal" output on machines with > 2TB virtual memory
sbin/sysctl/sysctl.c
	Fix integer overflows in printf format strings

PR:		199673
Submitted by:	Vitaly Magerya
Reviewed by:	cem
Approved by:	re (marius)
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D6941
2016-06-24 14:58:37 +00:00
Kristof Provost
3e248e0fb4 pf: Filter on and set vlan PCP values
Adopt the OpenBSD syntax for setting and filtering on VLAN PCP values. This
introduces two new keywords: 'set prio' to set the PCP value, and 'prio' to
filter on it.

Reviewed by:    allanjude, araujo
Approved by:	re (gjb)
Obtained from:  OpenBSD (mostly)
Differential Revision:  https://reviews.freebsd.org/D6786
2016-06-17 18:21:55 +00:00
Andriy Voskoboinyk
7951c6aa9b ifconfig: fix wlan creation when unit number is not provided
(was broken after r300738).

Reported by:	Yoshihiro Ota <ota@j.email.ne.jp>, adrian
Tested by:	Yoshihiro Ota <ota@j.email.ne.jp>
2016-06-08 17:21:15 +00:00
Marcelo Araujo
a9254de740 Bump date on ifconfig(8) and vlan(4) to reflect the changes made
on revision r301496.
2016-06-08 04:18:57 +00:00
Marcelo Araujo
2ccbbd06d2 Add support to priority code point (PCP) that is an 3-bit field
which refers to IEEE 802.1p class of service and maps to the frame
priority level.

Values in order of priority are: 1 (Background (lowest)),
0 (Best effort (default)), 2 (Excellent effort),
3 (Critical applications), 4 (Video, < 100ms latency),
5 (Video, < 10ms latency), 6 (Internetwork control) and
7 (Network control (highest)).

Example of usage:
root# ifconfig em0.1 create
root# ifconfig em0.1 vlanpcp 3

Note:
The review D801 includes the pf(4) part, but as discussed with kristof,
we won't commit the pf(4) bits for now.
The credits of the original code is from rwatson.

Differential Revision:	https://reviews.freebsd.org/D801
Reviewed by:	gnn, adrian, loos
Discussed with: rwatson, glebius, kristof
Tested by:	many including Matthew Grooms <mgrooms__shrew.net>
Obtained from:	pfSense
Relnotes:	Yes
2016-06-06 09:51:58 +00:00
Pedro F. Giffuni
32ceeb31a1 dhclient(1): correct obvious mismatch in get_char().
Correct switch between current and previous line buffers when
encountering a carriage return in the input.

CID:		1305719
Obtained from:	OpenBSD (CVS rev. 1.30)
MFC after:	3 days
2016-06-03 03:40:39 +00:00
Allan Jude
776db16a76 Address feedback from hrs@ re: r301059 (ifconfig subnet mask)
- Use NI_MAXHOST to size buffers for getnameinfo()
- remove non-standard 'full' inet6 address printing
- remove 'no scope' option
- use strchr(3) to optimize replacing separator character in lladdrs

Reviewed by:	gnn, jhb
Differential Revision:	https://reviews.freebsd.org/D2856
2016-06-02 03:16:02 +00:00
Don Lewis
a25ffb5ab7 Belatedly bump .Dd date for Dummynet AQM import in r300779. 2016-06-02 00:42:15 +00:00
Allan Jude
7c2aa74437 ifconfig(8) now supports some output formatting options
specified by the -f flag or IFCONFIG_FORMAT environment variable, the user
can request that inet4 subnet masks be printed in CIDR or dotted-quad
notation, in addition to the traditional hex output.
inet6 prefixes can be printed in CIDR as well.

For more documentation see the ifconfig(8) man page.

PR:		169072
Requested by:	seanc, marcel, brd, many others
Reviewed by:	gnn, jhb (earlier version)
Relnotes:	yes
Sponsored by:	ScaleEngine Inc.
Differential Revision:	https://reviews.freebsd.org/D2856
2016-05-31 17:30:08 +00:00
Ed Schouten
e47c947e6e Stop using the non-standard basename_r() function.
This change makes the code use the POSIX basename() function. It has the
advantage that (if implemented correctly), it also imposes no restrict
on the pathname length.

Notice that I haven't added any error handling to the strdup() call. It
looks like none of the other calls to strdup() and malloc() performed by
this utility do it either.

Reviewed by:	hrs
Differential Revision:	https://reviews.freebsd.org/D6626
2016-05-31 06:45:19 +00:00
Allan Jude
6713512842 Add Documentation for missing ifconfig(8) flags
autoconf / -autoconf
deprecated / -deprecated
pltime
vltime

PR:		209822
Submitted by:	Sevan Janiyan <venture37@geeklan.co.uk>
MFC after:	2 weeks
2016-05-29 03:44:37 +00:00
Allan Jude
b468a9ff1d Import the skein hashing algorithm, based on the threefish block cipher
Connect it to userland (libmd, libcrypt, sbin/md5) and kernel (crypto.ko)

Support for skein as a ZFS checksum algorithm was introduced in r289422
but is disconnected because FreeBSD lacked a Skein implementation.

A further commit will enable it in ZFS.

Reviewed by:	cem
Sponsored by:	ScaleEngine Inc.
Differential Revision:	https://reviews.freebsd.org/D6166
2016-05-29 01:15:36 +00:00
Allan Jude
1780e40715 Implement SHA-512 truncated (224 and 256 bits)
This implements SHA-512/256, which generates a 256 bit hash by
calculating the SHA-512 then truncating the result. A different initial
value is used, making the result different from the first 256 bits of
the SHA-512 of the same input. SHA-512 is ~50% faster than SHA-256 on
64bit platforms, so the result is a faster 256 bit hash.

The main goal of this implementation is to enable support for this
faster hashing algorithm in ZFS. The feature was introduced into ZFS
in r289422, but is disconnected because SHA-512/256 support was missing.
A further commit will enable it in ZFS.

This is the follow on to r292782

Reviewed by:	cem
Sponsored by:	ScaleEngine Inc.
Differential Revision:	https://reviews.freebsd.org/D6061
2016-05-28 16:06:07 +00:00
Don Lewis
91336b403a Import Dummynet AQM version 0.2.1 (CoDel, FQ-CoDel, PIE and FQ-PIE).
Centre for Advanced Internet Architectures

Implementing AQM in FreeBSD

* Overview <http://caia.swin.edu.au/freebsd/aqm/index.html>

* Articles, Papers and Presentations
  <http://caia.swin.edu.au/freebsd/aqm/papers.html>

* Patches and Tools <http://caia.swin.edu.au/freebsd/aqm/downloads.html>

Overview

Recent years have seen a resurgence of interest in better managing
the depth of bottleneck queues in routers, switches and other places
that get congested. Solutions include transport protocol enhancements
at the end-hosts (such as delay-based or hybrid congestion control
schemes) and active queue management (AQM) schemes applied within
bottleneck queues.

The notion of AQM has been around since at least the late 1990s
(e.g. RFC 2309). In recent years the proliferation of oversized
buffers in all sorts of network devices (aka bufferbloat) has
stimulated keen community interest in four new AQM schemes -- CoDel,
FQ-CoDel, PIE and FQ-PIE.

The IETF AQM working group is looking to document these schemes,
and independent implementations are a corner-stone of the IETF's
process for confirming the clarity of publicly available protocol
descriptions. While significant development work on all three schemes
has occured in the Linux kernel, there is very little in FreeBSD.

Project Goals

This project began in late 2015, and aims to design and implement
functionally-correct versions of CoDel, FQ-CoDel, PIE and FQ_PIE
in FreeBSD (with code BSD-licensed as much as practical). We have
chosen to do this as extensions to FreeBSD's ipfw/dummynet firewall
and traffic shaper. Implementation of these AQM schemes in FreeBSD
will:
* Demonstrate whether the publicly available documentation is
  sufficient to enable independent, functionally equivalent implementations

* Provide a broader suite of AQM options for sections the networking
  community that rely on FreeBSD platforms

Program Members:

* Rasool Al Saadi (developer)

* Grenville Armitage (project lead)

Acknowledgements:

This project has been made possible in part by a gift from the
Comcast Innovation Fund.

Submitted by:	Rasool Al-Saadi <ralsaadi@swin.edu.au>
X-No objection:	core
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D6388
2016-05-26 21:40:13 +00:00
Andriy Voskoboinyk
b628bdccce ifconfig: set by default FCC regulatory domain for wireless interfaces.
Change default regulatory domain from DEBUG (no limitations;
exposes all device channels) to FCC; as a result, newly created wireless
interface with default settings will have less chances to violate
country-specific regulations.

This change will not affect drivers with pre-initialized regdomain
structure (currentry ath(4) and mwl(4)); in that case, the default
channel list must correspond to the default regdomain / country setting.

You can switch to another regdomain / country via corresponding
ifconfig(8) options; the driver must implement ic_getradiocaps()
method to restore full channel list.

Full country / regdomain list may be obtained via
'ifconfig <iface> list countries' command.

Example: change country to Germany:
ifconfig wlan0 down	# all wlans on the device must be down
ifconfig wlan0 country DE
ifconfig wlan0 up
# wpa_supplicant(8), dhclient(8) etc

At the creation time:
ifconfig wlan0 create wlandev wpi0 country DE

To make changes permanent add the following line to the rc.conf(5):
create_args_wlan0="country DE"

Tested with
 - Intel 3945BG (wpi(4)).
 - WUSB54GC (rum(4)).

Reviewed by:	adrian
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D6228
2016-05-26 13:14:08 +00:00
Don Lewis
e60dd0e86a Fix a couple of Coverity Unintended sign extension sign extension
defects.  When shifting an unsigned byte into the upper 8 bits of
an int and the resulting value is greater than 0x7FFFFFF, the result
will be sign extended when converting to a 64 bit unsigned long.
Fix by casting to (uint64_t) before the shift.

Reported by:	Coverity
CID:		1356044, 1356045
Reviewed by:	ken
2016-05-25 15:49:29 +00:00
Don Lewis
4992a19282 Fix a couple of new instances of a false positive Coverity buffer
overflow defect.  Use the new CCB_CLEAR_ALL_EXCEPT_HDR() macro
instead of the calling bzero() on the pointer to the header used
as an array and indexed by 1.

Don't leak a buffer after executing "goto restart_report" by
overwriting its pointer with the results of another calloc().
Be sure to clear the buffer before reusing it.  (CID 1356042)

Reported by:	Coverity
CID:		1356022, 1356034, 1356023, 1356035, 1356042
Reviewed by:	ken
2016-05-25 15:43:01 +00:00
Don Lewis
95320acebc Fix multiple Coverity Out-of-bounds access false postive issues in CAM
The currently used idiom for clearing the part of a ccb after its
header generates one or two Coverity errors for each time it is
used.  All instances generate an Out-of-bounds access (ARRAY_VS_SINGLETON)
error because of the treatment of the header as a two element array,
with a pointer to the non-existent second element being passed as
the starting address to bzero().  Some instances also alsp generate
Out-of-bounds access (OVERRUN) errors, probably because the space
being cleared is larger than the sizeofstruct ccb_hdr).

In addition, this idiom is difficult for humans to understand and
it is error prone.  The user has to chose the proper struct ccb_*
type (which does not appear in the surrounding code) for the sizeof()
in the length calculation.  I found several instances where the
length was incorrect, which could cause either an actual out of
bounds write, or incompletely clear the ccb.

A better way is to write the code to clear the ccb itself starting
at sizeof(ccb_hdr) bytes from the start of the ccb, and calculate
the length based on the specific type of struct ccb_* being cleared
as specified by the union ccb member being used.  The latter can
normally be seen in the nearby code.  This is friendlier for Coverity
and other static analysis tools because they will see that the
intent is to clear the trailing part of the ccb.

Wrap all of the boilerplate code in a convenient macro that only
requires a pointer to the desired union ccb member (or a pointer
to the union ccb itself) as an argument.

Reported by:	Coverity
CID:		1007578, 1008684, 1009724, 1009773, 1011304, 1011306
CID:		1011307, 1011308, 1011309, 1011310, 1011311, 1011312
CID:		1011313, 1011314, 1011315, 1011316, 1011317, 1011318
CID:		1011319, 1011320, 1011321, 1011322, 1011324, 1011325
CID:		1011326, 1011327, 1011328, 1011329, 1011330, 1011374
CID:		1011390, 1011391, 1011392, 1011393, 1011394, 1011395
CID:		1011396, 1011397, 1011398, 1011399, 1011400, 1011401
CID:		1011402, 1011403, 1011404, 1011405, 1011406, 1011408
CID:		1011409, 1011410, 1011411, 1011412, 1011413, 1011414
CID:		1017461, 1018387, 1086860, 1086874, 1194257, 1229897
CID:		1229968, 1306229, 1306234, 1331282, 1331283, 1331294
CID:		1331295, 1331535, 1331536, 1331539, 1331540, 1341623
CID:		1341624, 1341637, 1341638, 1355264, 1355324
Reviewed by:	scottl, ken, delphij, imp
MFH:		1 month
Differential Revision:	https://reviews.freebsd.org/D6496
2016-05-24 00:57:11 +00:00
Kenneth D. Merry
9a6844d55f Add support for managing Shingled Magnetic Recording (SMR) drives.
This change includes support for SCSI SMR drives (which conform to the
Zoned Block Commands or ZBC spec) and ATA SMR drives (which conform to
the Zoned ATA Command Set or ZAC spec) behind SAS expanders.

This includes full management support through the GEOM BIO interface, and
through a new userland utility, zonectl(8), and through camcontrol(8).

This is now ready for filesystems to use to detect and manage zoned drives.
(There is no work in progress that I know of to use this for ZFS or UFS, if
anyone is interested, let me know and I may have some suggestions.)

Also, improve ATA command passthrough and dispatch support, both via ATA
and ATA passthrough over SCSI.

Also, add support to camcontrol(8) for the ATA Extended Power Conditions
feature set.  You can now manage ATA device power states, and set various
idle time thresholds for a drive to enter lower power states.

Note that this change cannot be MFCed in full, because it depends on
changes to the struct bio API that break compatilibity.  In order to
avoid breaking the stable API, only changes that don't touch or depend on
the struct bio changes can be merged.  For example, the camcontrol(8)
changes don't depend on the new bio API, but zonectl(8) and the probe
changes to the da(4) and ada(4) drivers do depend on it.

Also note that the SMR changes have not yet been tested with an actual
SCSI ZBC device, or a SCSI to ATA translation layer (SAT) that supports
ZBC to ZAC translation.  I have not yet gotten a suitable drive or SAT
layer, so any testing help would be appreciated.  These changes have been
tested with Seagate Host Aware SATA drives attached to both SAS and SATA
controllers.  Also, I do not have any SATA Host Managed devices, and I
suspect that it may take additional (hopefully minor) changes to support
them.

Thanks to Seagate for supplying the test hardware and answering questions.

sbin/camcontrol/Makefile:
	Add epc.c and zone.c.

sbin/camcontrol/camcontrol.8:
	Document the zone and epc subcommands.

sbin/camcontrol/camcontrol.c:
	Add the zone and epc subcommands.

	Add auxiliary register support to build_ata_cmd().  Make sure to
	set the CAM_ATAIO_NEEDRESULT, CAM_ATAIO_DMA, and CAM_ATAIO_FPDMA
	flags as appropriate for ATA commands.

	Add a new get_ata_status() function to parse ATA result from SCSI
	sense descriptors (for ATA passthrough over SCSI) and ATA I/O
	requests.

sbin/camcontrol/camcontrol.h:
	Update the build_ata_cmd() prototype

	Add get_ata_status(), zone(), and epc().

sbin/camcontrol/epc.c:
	Support for ATA Extended Power Conditions features.  This includes
	support for all features documented in the ACS-4 Revision 12
	specification from t13.org (dated February 18, 2016).

	The EPC feature set allows putting a drive into a power power mode
	immediately, or setting timeouts so that the drive will
	automatically enter progressively lower power states after various
	idle times.

sbin/camcontrol/fwdownload.c:
	Update the firmware download code for the new build_ata_cmd()
	arguments.

sbin/camcontrol/zone.c:
	Implement support for Shingled Magnetic Recording (SMR) drives
	via SCSI Zoned Block Commands (ZBC) and ATA Zoned Device ATA
	Command Set (ZAC).

	These specs were developed in concert, and are functionally
	identical.  The primary differences are due to SCSI and ATA
	differences.  (SCSI is big endian, ATA is little endian, for
	example.)

	This includes support for all commands defined in the ZBC and
	ZAC specs.

sys/cam/ata/ata_all.c:
	Decode a number of additional ATA command names in ata_op_string().

	Add a new CCB building function, ata_read_log().

	Add ata_zac_mgmt_in() and ata_zac_mgmt_out() CCB building
	functions.  These support both DMA and NCQ encapsulation.

sys/cam/ata/ata_all.h:
	Add prototypes for ata_read_log(), ata_zac_mgmt_out(), and
	ata_zac_mgmt_in().

sys/cam/ata/ata_da.c:
	Revamp the ada(4) driver to support zoned devices.

	Add four new probe states to gather information needed for zone
	support.

	Add a new adasetflags() function to avoid duplication of large
	blocks of flag setting between the async handler and register
	functions.

	Add new sysctl variables that describe zone support and paramters.

	Add support for the new BIO_ZONE bio, and all of its subcommands:
	DISK_ZONE_OPEN, DISK_ZONE_CLOSE, DISK_ZONE_FINISH, DISK_ZONE_RWP,
	DISK_ZONE_REPORT_ZONES, and DISK_ZONE_GET_PARAMS.

sys/cam/scsi/scsi_all.c:
	Add command descriptions for the ZBC IN/OUT commands.

	Add descriptions for ZBC Host Managed devices.

	Add a new function, scsi_ata_pass() to do ATA passthrough over
	SCSI.  This will eventually replace scsi_ata_pass_16() -- it
	can create the 12, 16, and 32-byte variants of the ATA
	PASS-THROUGH command, and supports setting all of the
	registers defined as of SAT-4, Revision 5 (March 11, 2016).

	Change scsi_ata_identify() to use scsi_ata_pass() instead of
	scsi_ata_pass_16().

	Add a new scsi_ata_read_log() function to facilitate reading
	ATA logs via SCSI.

sys/cam/scsi/scsi_all.h:
	Add the new ATA PASS-THROUGH(32) command CDB.  Add extended and
	variable CDB opcodes.

	Add Zoned Block Device Characteristics VPD page.

	Add ATA Return SCSI sense descriptor.

	Add prototypes for scsi_ata_read_log() and scsi_ata_pass().

sys/cam/scsi/scsi_da.c:
	Revamp the da(4) driver to support zoned devices.

	Add five new probe states, four of which are needed for ATA
	devices.

	Add five new sysctl variables that describe zone support and
	parameters.

	The da(4) driver supports SCSI ZBC devices, as well as ATA ZAC
	devices when they are attached via a SCSI to ATA Translation (SAT)
	layer.  Since ZBC -> ZAC translation is a new feature in the T10
	SAT-4 spec, most SATA drives will be supported via ATA commands
	sent via the SCSI ATA PASS-THROUGH command.  The da(4) driver will
	prefer the ZBC interface, if it is available, for performance
	reasons, but will use the ATA PASS-THROUGH interface to the ZAC
	command set if the SAT layer doesn't support translation yet.
	As I mentioned above, ZBC command support is untested.

	Add support for the new BIO_ZONE bio, and all of its subcommands:
	DISK_ZONE_OPEN, DISK_ZONE_CLOSE, DISK_ZONE_FINISH, DISK_ZONE_RWP,
	DISK_ZONE_REPORT_ZONES, and DISK_ZONE_GET_PARAMS.

	Add scsi_zbc_in() and scsi_zbc_out() CCB building functions.

	Add scsi_ata_zac_mgmt_out() and scsi_ata_zac_mgmt_in() CCB/CDB
	building functions.  Note that these have return values, unlike
	almost all other CCB building functions in CAM.  The reason is
	that they can fail, depending upon the particular combination
	of input parameters.  The primary failure case is if the user
	wants NCQ, but fails to specify additional CDB storage.  NCQ
	requires using the 32-byte version of the SCSI ATA PASS-THROUGH
	command, and the current CAM CDB size is 16 bytes.

sys/cam/scsi/scsi_da.h:
	Add ZBC IN and ZBC OUT CDBs and opcodes.

	Add SCSI Report Zones data structures.

	Add scsi_zbc_in(), scsi_zbc_out(), scsi_ata_zac_mgmt_out(), and
	scsi_ata_zac_mgmt_in() prototypes.

sys/dev/ahci/ahci.c:
	Fix SEND / RECEIVE FPDMA QUEUED in the ahci(4) driver.

	ahci_setup_fis() previously set the top bits of the sector count
	register in the FIS to 0 for FPDMA commands.  This is okay for
	read and write, because the PRIO field is in the only thing in
	those bits, and we don't implement that further up the stack.

	But, for SEND and RECEIVE FPDMA QUEUED, the subcommand is in that
	byte, so it needs to be transmitted to the drive.

	In ahci_setup_fis(), always set the the top 8 bits of the
	sector count register.  We need it in both the standard
	and NCQ / FPDMA cases.

sys/geom/eli/g_eli.c:
	Pass BIO_ZONE commands through the GELI class.

sys/geom/geom.h:
	Add g_io_zonecmd() prototype.

sys/geom/geom_dev.c:
	Add new DIOCZONECMD ioctl, which allows sending zone commands to
	disks.

sys/geom/geom_disk.c:
	Add support for BIO_ZONE commands.

sys/geom/geom_disk.h:
	Add a new flag, DISKFLAG_CANZONE, that indicates that a given
	GEOM disk client can handle BIO_ZONE commands.

sys/geom/geom_io.c:
	Add a new function, g_io_zonecmd(), that handles execution of
	BIO_ZONE commands.

	Add permissions check for BIO_ZONE commands.

	Add command decoding for BIO_ZONE commands.

sys/geom/geom_subr.c:
	Add DDB command decoding for BIO_ZONE commands.

sys/kern/subr_devstat.c:
	Record statistics for REPORT ZONES commands.  Note that the
	number of bytes transferred for REPORT ZONES won't quite match
	what is received from the harware.  This is because we're
	necessarily counting bytes coming from the da(4) / ada(4) drivers,
	which are using the disk_zone.h interface to communicate up
	the stack.  The structure sizes it uses are slightly different
	than the SCSI and ATA structure sizes.

sys/sys/ata.h:
	Add many bit and structure definitions for ZAC, NCQ, and EPC
	command support.

sys/sys/bio.h:
	Convert the bio_cmd field to a straight enumeration.  This will
	yield more space for additional commands in the future.  After
	change r297955 and other related changes, this is now possible.
	Converting to an enumeration will also prevent use as a bitmask
	in the future.

sys/sys/disk.h:
	Define the DIOCZONECMD ioctl.

sys/sys/disk_zone.h:
	Add a new API for managing zoned disks.  This is very close to
	the SCSI ZBC and ATA ZAC standards, but uses integers in native
	byte order instead of big endian (SCSI) or little endian (ATA)
	byte arrays.

	This is intended to offer to the complete feature set of the ZBC
	and ZAC disk management without requiring the application developer
	to include SCSI or ATA headers.  We also use one set of headers
	for ioctl consumers and kernel bio-level consumers.

sys/sys/param.h:
	Bump __FreeBSD_version for sys/bio.h command changes, and inclusion
	of SMR support.

usr.sbin/Makefile:
	Add the zonectl utility.

usr.sbin/diskinfo/diskinfo.c
	Add disk zoning capability to the 'diskinfo -v' output.

usr.sbin/zonectl/Makefile:
	Add zonectl makefile.

usr.sbin/zonectl/zonectl.8
	zonectl(8) man page.

usr.sbin/zonectl/zonectl.c
	The zonectl(8) utility.  This allows managing SCSI or ATA zoned
	disks via the disk_zone.h API.  You can report zones, reset write
	pointers, get parameters, etc.

Sponsored by:	Spectra Logic
Differential Revision:	https://reviews.freebsd.org/D6147
Reviewed by:	wblock (documentation)
2016-05-19 14:08:36 +00:00
Conrad Meyer
fb0eab090e dhclient: Fix the trivial buffer overruns correctly
A DHCP client identifier is simply the hardware type (one byte) concatenated
with the hardware address (some variable number of bytes, but at most 16).
Limit the size of the temporary buffer to match and the rest of the
calculations shake out correctly.

This is a follow-up to the incorrect r299512, reverted in r300172.

CIDs:		1008682, 1305550
Sponsored by:	EMC / Isilon Storage Division
2016-05-18 23:41:55 +00:00
Conrad Meyer
4441bd735f Revert r299512
It broke client identifiers because I misunderstood the intent of the code.
There is still a minor issue detected by Coverity (at least, I can't find where
the code proves it isn't an issue).  I'll follow up with a better fix for the
CIDs.

Reported by:	Ian FREISLICH
Sponsored by:	EMC / Isilon Storage Division
2016-05-18 23:35:37 +00:00
Andrey V. Elsukov
825f02a9ed Make ipfw internal olist output more user friendly.
Print object type as string for known types.

Obtained from:	Yandex LLC
Sponsored by:	Yandex LLC
2016-05-17 11:22:08 +00:00
Andrey V. Elsukov
2685841b38 Make named objects set-aware. Now it is possible to create named
objects with the same name in different sets.

Add optional manage_sets() callback to objects rewriting framework.
It is intended to implement handler for moving and swapping named
object's sets. Add ipfw_obj_manage_sets() function that implements
generic sets handler. Use new callback to implement sets support for
lookup tables.
External actions objects are global and they don't support sets.
Modify eaction_findbyname() to reflect this.
ipfw(8) now may fail to move rules or sets, because some named objects
in target set may have conflicting names.
Note that ipfw_obj_ntlv type was changed, but since lookup tables
actually didn't support sets, this change is harmless.

Obtained from:	Yandex LLC
Sponsored by:	Yandex LLC
2016-05-17 07:47:23 +00:00
Don Lewis
c98907a4f4 Add an assertion to catch a potential underflow in an array index
calculation, though this should not happen in the current code.

Reported by:	Coverity
CID:		1008486
MFC after:	3 weeks
2016-05-16 08:07:32 +00:00
Marcelo Araujo
f8358c11a5 For pointers use NULL instead of 0.
MFC after:	2 weeks.
2016-05-16 00:36:12 +00:00
Marcelo Araujo
798a749aae For pointers use NULL instead of 0.
MFC after:	2 weeks.
2016-05-16 00:35:39 +00:00
Marcelo Araujo
2ef6931a15 For pointers use NULL instead of 0.
MFC after:	2 weeks.
2016-05-16 00:34:48 +00:00
Don Lewis
c871174916 Use strlcpy() instead of strncpy() when copying ifname to ensure
that it is NUL terminated.  Additional NUL padding is not required
for short names.

Use sizeof(destination) in a few places instead of IFNAMSIZ.

Cast afp->af_ridreq and afp->af_addreq  to make the intent of
the code more obvious.

Reported by:	Coverity
CID:		1009628, 1009630, 1009631, 1009632, 1009633, 1009635, 1009638
CID:		1009639, 1009640, 1009641, 1009642, 1009643, 1009644, 1009645
CID:		1009646, 1009647, 1010049, 1010050, 1010051, 1010052, 1010053
CID:		1010054, 1011293, 1011294, 1011295, 1011296, 1011297, 1011298
CID:		1011299, 1305821, 1351720, 1351721
MFC after:	1 week
2016-05-16 00:25:24 +00:00
Pedro F. Giffuni
bdfd68dca7 routed(8): Use arc4random_uniform instead of arc4random.
Use arc4random_uniform() when the desired random number upper bound
is not a power of two.

While here, we don't need srandom() and friends anymore.

Obtained from:	OpenBSD (CVS rev. 1.20)
2016-05-15 06:06:22 +00:00
Pedro F. Giffuni
e09d48f656 routed(8): Misc. cleanups to squelch Coverity.
table.c:
Copy into fixed size buffer.

trace.c:
Argument got dup2() cannot be negative.
Copy into fixed size buffer.

CID:		1006785, 1006786, 271301
Obtained from:	NetBSD
MFC after:	2 weeks.
2016-05-15 03:04:21 +00:00
Pedro F. Giffuni
65e2bd0ab8 routed(8): Dereference before null check.
CID:		272432
Obtained from:	NetBSD (CVS ref. 1.16)
MFC after:	2 weeks.
2016-05-15 02:41:20 +00:00
Pedro F. Giffuni
7b011d21db routed(8): Avoid NULL de-reference and two possible memory leaks.
The reports and fixes are straightforward but it's nice to be able
to confirm against NetBSD.

CID:		271080, 272306, 272307
Obtained from:	NetBSD (CVS ref. 1.21 - 1.23)
MFC after:	2 weeks.
2016-05-15 02:30:34 +00:00
Pedro F. Giffuni
5728318b35 Avoid NULL de-references.
CID:		271079
Obtained from:	NetBSD
MFC after:	2 weeks.
2016-05-14 23:32:03 +00:00
Pedro F. Giffuni
365cb451d3 routed(8): Use arc4random.
CID:		1305962
Obtained from:	NetBSD (CVS Rev. 1.34, Itojun)
2016-05-14 23:22:19 +00:00
Pedro F. Giffuni
0b279f8c94 routed: Fix use after free.
For the multihomed case, ifp be used after being freed. NULL the value
after freeing it and avoid getting into the branch without reassigning
a new value.

CID:		272671
Obtained from:	NetBSD
MFC after:	2 weeks
2016-05-14 23:07:26 +00:00
Pedro F. Giffuni
562c5a82cb routed(8): use NULL instead of zero for pointers. 2016-05-14 22:40:08 +00:00
Don Lewis
eeb6394364 Check for socket creation success before calling bind().
Reported by:	Coverity
CID:		1194209
2016-05-12 05:43:54 +00:00
Conrad Meyer
021b92e5ba dhclient: Fix some trivial buffer overruns
There was some confusion about how to limit a hardware address to at most 16
bytes.  In some cases it would overrun a byte off the end of the array.
Correct the types and rectify the overrun.

Reported by:	Coverity
CIDs:		1008682, 1305550
Sponsored by:	EMC / Isilon Storage Division
2016-05-12 04:28:22 +00:00
Conrad Meyer
fdaa5d1c07 camcontrol(8): Fix another trivial double-free
Reported by:	Coverity
CID:		1331222
Sponsored by:	EMC / Isilon Storage Division
2016-05-11 22:25:14 +00:00
Conrad Meyer
3aeebae9ca camcontrol(8): Fix trival double-free
Reported by:	Coverity
CID:		1331223
Sponsored by:	EMC / Isilon Storage Division
2016-05-11 22:22:49 +00:00
Conrad Meyer
333d028407 fsck_ffs: Don't overrun mount device buffer
Maybe this case is impossible.  Either way, when attempting to "/dev/"-prefix a
non-global device name, check that we do not overrun the f_mntfromname buffer.

In this case, truncating (with strlcpy or similar) would not be useful, since
the f_mntfromname result of getmntpt() is passed directly to open(2) later.

Reported by:	Coverity
CID:		1006789
Sponsored by:	EMC / Isilon Storage Division
2016-05-11 16:20:23 +00:00
Edward Tomasz Napierala
377b6d1e7c When rerooting, take the init(8) path from argv[0] instead of fetching
it via kern.proc.pathname sysctl(2).  In some cases - booting from NFS
or rerooting after replacing the init binary with a new one - the sysctl
would fail.  In other cases - after upgrading, which moves the old init
to /sbin/init.bak - it would return /sbin/init.bak, which is the actual
path of the running init, instead of /sbin/init.

Reported by:	Melissa Jenkins <melissa-freebsd at littlebluecar.co.uk>, jilles@
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-05-11 10:03:13 +00:00
Edward Tomasz Napierala
126ba2193b When rerooting, ignore ESRCH returned from kill(2). I couldn't reproduce
this by myself, but apparently it sometimes happens when rerooting from
single user mode.

Reported by:	jilles@
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-05-11 09:30:18 +00:00
Edward Tomasz Napierala
b8a1930fcf Cosmetic fixes for growfs(8) - remove unneeded capitalization and a spurious
newline, clarify a message.

MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-05-11 09:26:23 +00:00
Edward Tomasz Napierala
e49345fa3d Update the example growfs(8) manual page to include information on how
to make the system "notice" the updated disk size.

(Relnotes, since I've forget to set it for "camcontrol reprobe", and
it's worth mentioning.)

MFC after:	1 month
Relnotes:	yes
Sponsored by:	The FreeBSD Foundation
2016-05-10 18:28:38 +00:00
Edward Tomasz Napierala
d68fae5849 Add "camcontrol reprobe" subcommand, and implement it for da(4).
This makes it possible to manually force updating capacity data
after the disk got resized. Without it it might be neccessary to
reboot before FreeBSD notices updated disk size under eg VMWare.

Discussed with:	imp@
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D6108
2016-05-10 15:46:33 +00:00
Baptiste Daroussin
997f8ff84f Rename getline with get_line to avoid collision with getline(3)
When getline(3) in 2009 was added a _WITH_GETLINE guard has also been added.
This rename is made in preparation for the removal of this guard
2016-05-10 11:35:03 +00:00
Andriy Voskoboinyk
db930544a3 ifconfig: fix check for 40 MHz channels while applying country/regdomain.
Do not use 20 MHz channel list while checking 40 MHz channels;
it may be different. Just use the corresponding list instead.

Tested by:	Masachika ISHIZUKA <ish@amail.plala.or.jp>

PR:		209328
2016-05-09 16:15:52 +00:00
Renato Botelho
89d18e14f1 Add missing parameters -N and -l to reroot and halt usage()
Approved by:	bapt
Sponsored by:	Rubicon Communications (Netgate)
Differential Revision:	https://reviews.freebsd.org/D6173
2016-05-06 20:49:14 +00:00
Pedro F. Giffuni
eabd8f1210 nvmecontrol.8: minor spelling fix.
No functional change.
2016-05-06 03:11:34 +00:00
Enji Cooper
430f7286a5 Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed
after r298107

Summary of changes:

- Replace all instances of FILES/TESTS with ${PACKAGE}FILES. This ensures that
  namespacing is kept with FILES appropriately, and that this shouldn't need
  to be repeated if the namespace changes -- only the definition of PACKAGE
  needs to be changed
- Allow PACKAGE to be overridden by callers instead of forcing it to always be
  `tests`. In the event we get to the point where things can be split up
  enough in the base system, it would make more sense to group the tests
  with the blocks they're a part of, e.g. byacc with byacc-tests, etc
- Remove PACKAGE definitions where possible, i.e. where FILES wasn't used
  previously.
- Remove unnecessary TESTSPACKAGE definitions; this has been elided into
  bsd.tests.mk
- Remove unnecessary BINDIRs used previously with ${PACKAGE}FILES;
  ${PACKAGE}FILESDIR is now automatically defined in bsd.test.mk.
- Fix installation of files under data/ subdirectories in lib/libc/tests/hash
  and lib/libc/tests/net/getaddrinfo
- Remove unnecessary .include <bsd.own.mk>s (some opportunistic cleanup)

Document the proposed changes in share/examples/tests/tests/... via examples
so it's clear that ${PACKAGES}FILES is the suggested way forward in terms of
replacing FILES. share/mk/bsd.README didn't seem like the appropriate method
of communicating that info.

MFC after: never probably
X-MFC with: r298107
PR: 209114
Relnotes: yes
Tested with: buildworld, installworld, checkworld; buildworld, packageworld
Sponsored by: EMC / Isilon Storage Division
2016-05-04 23:20:53 +00:00
Alan Somers
8907f744ff Improve performance and functionality of the bitstring(3) api
Two new functions are provided, bit_ffs_at() and bit_ffc_at(), which allow
for efficient searching of set or cleared bits starting from any bit offset
within the bit string.

Performance is improved by operating on longs instead of bytes and using
ffsl() for searches within a long. ffsl() is a compiler builtin in both
clang and gcc for most architectures, converting what was a brute force
while loop search into a couple of instructions.

All of the bitstring(3) API continues to be contained in the header file.
Some of the functions are large enough that perhaps they should be uninlined
and moved to a library, but that is beyond the scope of this commit.

sys/sys/bitstring.h:
        Convert the majority of the existing bit string implementation from
        macros to inline functions.

        Properly protect the implementation from inadvertant macro expansion
        when included in a user's program by prefixing all private
        macros/functions and local variables with '_'.

        Add bit_ffs_at() and bit_ffc_at(). Implement bit_ffs() and
        bit_ffc() in terms of their "at" counterparts.

        Provide a kernel implementation of bit_alloc(), making the full API
        usable in the kernel.

        Improve code documenation.

share/man/man3/bitstring.3:
        Add pre-exisiting API bit_ffc() to the synopsis.

        Document new APIs.

        Document the initialization state of the bit strings
        allocated/declared by bit_alloc() and bit_decl().

        Correct documentation for bitstr_size(). The original code comments
        indicate the size is in bytes, not "elements of bitstr_t". The new
        implementation follows this lead. Only hastd assumed "elements"
        rather than bytes and it has been corrected.

etc/mtree/BSD.tests.dist:
tests/sys/Makefile:
tests/sys/sys/Makefile:
tests/sys/sys/bitstring.c:
        Add tests for all existing and new functionality.

include/bitstring.h
	Include all headers needed by sys/bitstring.h

lib/libbluetooth/bluetooth.h:
usr.sbin/bluetooth/hccontrol/le.c:
        Include bitstring.h instead of sys/bitstring.h.

sbin/hastd/activemap.c:
        Correct usage of bitstr_size().

sys/dev/xen/blkback/blkback.c
        Use new bit_alloc.

sys/kern/subr_unit.c:
        Remove hard-coded assumption that sizeof(bitstr_t) is 1.  Get rid of
        unrb.busy, which caches the number of bits set in unrb.map.  When
        INVARIANTS are disabled, nothing needs to know that information.
        callapse_unr can be adapted to use bit_ffs and bit_ffc instead.
        Eliminating unrb.busy saves memory, simplifies the code, and
        provides a slight speedup when INVARIANTS are disabled.

sys/net/flowtable.c:
        Use the new kernel implementation of bit-alloc, instead of hacking
        the old libc-dependent macro.

sys/sys/param.h
        Update __FreeBSD_version to indicate availability of new API

Submitted by:   gibbs, asomers
Reviewed by:    gibbs, ngie
MFC after:      4 weeks
Sponsored by:   Spectra Logic Corp
Differential Revision:  https://reviews.freebsd.org/D6004
2016-05-04 22:34:11 +00:00
Pedro F. Giffuni
dd3f00cbaf fsck_msdosfs: Adjust a check.
The on-disk FAT array does not include anything before CLUST_FIRST,
compensate in size check.

Obtained from:	NetBSD (CVS Rev. 1.20)
MFC after:	2 weeks
2016-05-04 22:27:22 +00:00
Marcelo Araujo
2c953857dd Use MIN macro from sys/param.h.
MFC after:	2 weeks
2016-05-02 01:40:31 +00:00
Marcelo Araujo
1120faab41 Use MIN/MAX macros from sys/param.h.
MFC after:	2 weeks.
2016-05-02 01:28:21 +00:00
Marcelo Araujo
0193043c46 Use MIN()/MAX() macros from sys/param.h.
Reviewed by:	trasz
MFC after:	2 weeks.
Differential Revision:	https://reviews.freebsd.org/D6118
2016-05-02 00:45:46 +00:00
Marcelo Araujo
e921a133f1 Use MIN() macro from sys/param.h.
Reviewed by:	trasz
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D6119
2016-05-02 00:44:19 +00:00
Pedro F. Giffuni
71a53e69d6 restore: promote some getfiles() parameters to size_t.
This is based on a change from OpenBSD:

"Fix restore so that it can actually restore files larger than 4GB by
changing the type of "size" to off_t in getfiles() plus little dependent
type cleanup, from Daniel Lucq."

It is an important for machines with 32 bit longs.
While here unsign the flags, also from OpenBSD.

Obtained from:	OpenBSD (through bitrig, I hate CVS)
MFC after:	2 weeks
2016-05-01 21:17:30 +00:00
Ed Schouten
e33d251e8e Remove useless calls to basename().
There are a couple of places in the source three where we call
basename() on constant strings. This is bad, because the prototype
standardized by POSIX allows the implementation to use its argument as a
storage buffer.

This change eliminates some of these unportable calls to basename() in
cases where it was only added for cosmetical reasons, namely to trim
argv[0]. There's nothing wrong with setting argv[0] to the full path.

Reviewed by:	jilles
Differential Revision:	https://reviews.freebsd.org/D6093
2016-05-01 08:22:11 +00:00
Pedro F. Giffuni
24229eeb2f restore: fix resource handle leak.
CID:		1007784
MFC after:	5 days
2016-05-01 02:39:39 +00:00
Pedro F. Giffuni
12527d70ac restore: drop casts for calloc(). 2016-05-01 02:31:22 +00:00
Pedro F. Giffuni
f32d2926b0 sbin: ake use of our rounddown() macro when sys/param.h is available.
No functional change.
2016-05-01 02:24:05 +00:00
Pedro F. Giffuni
312717174d sbin: use our howmany() macro when available through <sys/param.h>. 2016-05-01 02:19:49 +00:00
Pedro F. Giffuni
e451cf5f4c restore: fix memory leak.
CID:		272297
MFC after:	5 days
2016-04-30 22:51:09 +00:00
Pedro F. Giffuni
cac8854eb6 restore: use our howmany() instead of reinventing the macro. 2016-04-30 20:05:23 +00:00
Pedro F. Giffuni
fbcfcbbc5b fdisk: drop unused macro and make use of roundup()/rounddown(). 2016-04-30 19:58:54 +00:00
Pedro F. Giffuni
b68ac8007d sbin: minor spelling fixes.
No functional change.
2016-04-30 19:04:59 +00:00
Glen Barber
49dae58b28 Fix including Kyuafile in packaged base system.
Fix a related typo while here.

Note, this change results in the Kyuafile inclusion in the runtime
package, which needs to be fixed, however addresses the PR as far
as I can tell in my tests.

PR:		209114
Submitted by:	ngie
Sponsored by:	The FreeBSD Foundation
2016-04-29 05:28:40 +00:00
Enji Cooper
dc8a83a5b6 Remove logically impossible test in scsidoinquiry(..)
It was already done 4 lines prior and the value of error didn't change

MFC after: 3 days
Reported by: Coverity
CID: 1011236
Sponsored by: EMC / Isilon Storage Division
2016-04-28 21:17:23 +00:00
Marcelo Araujo
7de7df1554 Use macro MIN() from sys/param.h.
MFC after:	2 weeks.
2016-04-27 02:02:44 +00:00
Pedro F. Giffuni
11ec5dd04b fsck_ffs: Revert partially the unsigned changes.
Any value of uint16_t will be internally promoted to int so
changing them to an unsigned value doesn't help.

Missing revert value in suj_read().

X-MFC with:	r298551
2016-04-27 01:36:25 +00:00
Pedro F. Giffuni
4235bafa7e fsck_ffs: Revert partially the unsigned changes.
Any value of uint16_t will be internally promoted to int so
changing them to an unsigned value doesn't help.

Make clear we want to use uint32_t for closedisk()

X-MFC with:	r298551
2016-04-27 01:32:11 +00:00
Alan Somers
96edd3f3ee Add GEOM::physpath documentation to devd.conf(5)
Suggested by:	trasz
Reviewed by:	trasz
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D6063
2016-04-26 14:48:58 +00:00
Adrian Chadd
6605a047e7 [ifconfig] add STBC TX/RX configuration
This adds the ability to view and configure the STBC parameter for
both transmit and receive.

Whilst here, fix a typo for AMSDU.

TODO:

* manpage update
2016-04-26 01:30:29 +00:00
Pedro F. Giffuni
de497205b0 ifconfig: prevent some improbable signed integer overflows.
ic_nchans, from struct:ieee80211req_chaninfo, is an unsigned int.
Use an unsigned index to prevent overflowing the index.

Adopt unsigned integers in other cases where it is useful
to be aware of the unsigned quantities and there is no
risk of the values being negative.

MFC after:	1 week
2016-04-25 00:41:23 +00:00
Pedro F. Giffuni
0f8c0b0ae4 fsck_ffs: Adopt some type safety for the journalling checks.
fs_ncg is of type uint32, and we were indexing it with an int.
Fixed this using an unsigned type and adopt some other unsigned
indexes to remind us when we are dealing with unsigned numbers.

Reviewed by:	mckusick
MFC after:	5 days
2016-04-24 20:31:22 +00:00
Marcelo Araujo
091ea4a091 Use macro MAX() from sys/param.h.
MFC after:	2 weeks.
2016-04-22 03:32:14 +00:00
Marcelo Araujo
f4b72a8dd2 Use MIN()/MAX() macros from sys/param.h.
MFC after:	2 weeks.
2016-04-21 06:24:13 +00:00
Marcelo Araujo
67210fb3b8 Use MAX() from sys/param.h.
MFC after:	2 weeks.
2016-04-21 06:21:33 +00:00
Marcelo Araujo
6a25181bba Fix a missing blank space. 2016-04-21 06:14:30 +00:00
Marcelo Araujo
2d123458af Simplify the get_type() function.
Submitted by:	bde
Discussed with:	bde, jhb and pfg
MFC after:	2 weeks.
2016-04-21 06:11:24 +00:00
Sepherosa Ziehau
dd09ce3930 dhclient: Log a warning instead of bailing upon "illegal" options
In Azure, the DHCP servers add private option (id 0xf5), which contains
binary form of an IPv4 address. Once this option is converted to string
form, it could contain '$', e.g.

IPv4 address: 100.72.36.54
binary form: 0x64 0x48 0x24 0x36
string form: "dH$6"

dhclient bails upon "illegal" options like the above example, thus the
VM bring-up will fail.

Also as a side note, this "illegal" option detection was added in
OpenBSD ~11years ago:
http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sbin/dhclient/dhclient.c?rev=1.50&content-type=text/x-cvsweb-markup

And it was removed along with the removal of script support in OpenBSD
~3years ago:
http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sbin/dhclient/dhclient.c?rev=1.159&content-type=text/x-cvsweb-markup

Reported by:	Hongxiong Xian <v-hoxian microsoft com>
Reviewed by:	jhb, Dexuan Cui <decui microsoft com>
Tested by:	Hongxiong Xian <v-hoxian microsoft com>
Analyzed by:	Dong Liu <doliu microsoft com>
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D5853
2016-04-20 23:56:25 +00:00
Marcelo Araujo
974482aa61 Re-ident lines.
Requested by:	pfg
MFC after:	2 weeks.
2016-04-20 01:35:09 +00:00
Marcelo Araujo
fb4e4bd7f9 Use nitems() from sys/param.h.
MFC after:	2 weeks.
2016-04-20 01:05:54 +00:00
Marcelo Araujo
46df5db84e Use nitems() from sys/param.h.
MFC after:	2 weeks.
2016-04-20 00:55:35 +00:00
Enji Cooper
3ae587fde4 Don't leak fd on sectorsize malloc failure
Also, call endfsent after calling getfsent (i.e. when not explicitly called
with a swap device) for code cleanliness

CID: 1354785
Differential Revision: https://reviews.freebsd.org/D6014
X-MFC with: r298076
Reported by: Coverity
Reviewed by: cem
Sponsored by: EMC / Isilon Storage Division
2016-04-20 00:49:49 +00:00
Pedro F. Giffuni
05cfc40ab0 restore: use our roundup2/rounddown2() macros when param.h is available.
While here cleanup a little a malloc call.
2016-04-19 20:47:14 +00:00
Pedro F. Giffuni
4c8762f037 dump: use NULL instead of zero for pointers.
Clean out the casts from calloc(3) while here.
2016-04-19 19:13:33 +00:00
Pedro F. Giffuni
f3858ada3e fsck_msdosfs: use NULL instead of zero for pointers. 2016-04-19 19:08:37 +00:00
Edward Tomasz Napierala
e848a50ce6 Mention fsck_ffs -E in tunefs(8). It's non-obvious that one should
use it after enabling TRIM.

Reviewed by:	brueffer@
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D5928
2016-04-19 15:08:35 +00:00
Marcelo Araujo
286d197142 Use nitems() from sys/param.h.
MFC after:	2 weeks.
2016-04-19 11:12:57 +00:00