summaryrefslogtreecommitdiffstats
path: root/sbin
Commit message (Collapse)AuthorAgeFilesLines
* ifconfig: fix wlan creation when unit number is not providedavos2016-06-081-0/+7
| | | | | | | (was broken after r300738). Reported by: Yoshihiro Ota <ota@j.email.ne.jp>, adrian Tested by: Yoshihiro Ota <ota@j.email.ne.jp>
* Bump date on ifconfig(8) and vlan(4) to reflect the changes madearaujo2016-06-081-1/+1
| | | | on revision r301496.
* Add support to priority code point (PCP) that is an 3-bit fieldaraujo2016-06-062-6/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* dhclient(1): correct obvious mismatch in get_char().pfg2016-06-031-2/+2
| | | | | | | | | 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
* Address feedback from hrs@ re: r301059 (ifconfig subnet mask)allanjude2016-06-025-67/+31
| | | | | | | | | | - 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
* Belatedly bump .Dd date for Dummynet AQM import in r300779.truckman2016-06-021-1/+1
|
* ifconfig(8) now supports some output formatting optionsallanjude2016-05-315-22/+250
| | | | | | | | | | | | | | | | 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
* Stop using the non-standard basename_r() function.ed2016-05-311-4/+10
| | | | | | | | | | | | | 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
* Add Documentation for missing ifconfig(8) flagsallanjude2016-05-291-0/+12
| | | | | | | | | | | autoconf / -autoconf deprecated / -deprecated pltime vltime PR: 209822 Submitted by: Sevan Janiyan <venture37@geeklan.co.uk> MFC after: 2 weeks
* Import the skein hashing algorithm, based on the threefish block cipherallanjude2016-05-292-7/+62
| | | | | | | | | | | | | 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
* Implement SHA-512 truncated (224 and 256 bits)allanjude2016-05-283-7/+39
| | | | | | | | | | | | | | | | | | | 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
* Import Dummynet AQM version 0.2.1 (CoDel, FQ-CoDel, PIE and FQ-PIE).truckman2016-05-262-2/+605
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* ifconfig: set by default FCC regulatory domain for wireless interfaces.avos2016-05-261-0/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix a couple of Coverity Unintended sign extension sign extensiontruckman2016-05-251-2/+2
| | | | | | | | | | | 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
* Fix a couple of new instances of a false positive Coverity buffertruckman2016-05-252-5/+6
| | | | | | | | | | | | | | 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
* Fix multiple Coverity Out-of-bounds access false postive issues in CAMtruckman2016-05-245-83/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add support for managing Shingled Magnetic Recording (SMR) drives.ken2016-05-197-17/+2169
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* dhclient: Fix the trivial buffer overruns correctlycem2016-05-181-1/+1
| | | | | | | | | | | | 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
* Revert r299512cem2016-05-181-14/+10
| | | | | | | | | | 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
* Make `ipfw internal olist` output more user friendly.ae2016-05-171-2/+35
| | | | | | | Print object type as string for known types. Obtained from: Yandex LLC Sponsored by: Yandex LLC
* Make named objects set-aware. Now it is possible to create namedae2016-05-171-0/+3
| | | | | | | | | | | | | | | | | | | 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
* Add an assertion to catch a potential underflow in an array indextruckman2016-05-161-0/+1
| | | | | | | | calculation, though this should not happen in the current code. Reported by: Coverity CID: 1008486 MFC after: 3 weeks
* For pointers use NULL instead of 0.araujo2016-05-161-1/+1
| | | | MFC after: 2 weeks.
* For pointers use NULL instead of 0.araujo2016-05-161-1/+1
| | | | MFC after: 2 weeks.
* For pointers use NULL instead of 0.araujo2016-05-161-4/+4
| | | | MFC after: 2 weeks.
* Use strlcpy() instead of strncpy() when copying ifname to ensuretruckman2016-05-1610-39/+41
| | | | | | | | | | | | | | | | | | 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
* routed(8): Use arc4random_uniform instead of arc4random.pfg2016-05-151-7/+2
| | | | | | | | | 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)
* routed(8): Misc. cleanups to squelch Coverity.pfg2016-05-152-4/+10
| | | | | | | | | | | | | 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.
* routed(8): Dereference before null check.pfg2016-05-151-1/+1
| | | | | | CID: 272432 Obtained from: NetBSD (CVS ref. 1.16) MFC after: 2 weeks.
* routed(8): Avoid NULL de-reference and two possible memory leaks.pfg2016-05-151-3/+9
| | | | | | | | | 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.
* Avoid NULL de-references.pfg2016-05-141-2/+2
| | | | | | CID: 271079 Obtained from: NetBSD MFC after: 2 weeks.
* routed(8): Use arc4random.pfg2016-05-141-2/+2
| | | | | CID: 1305962 Obtained from: NetBSD (CVS Rev. 1.34, Itojun)
* routed: Fix use after free.pfg2016-05-141-1/+2
| | | | | | | | | | 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
* routed(8): use NULL instead of zero for pointers.pfg2016-05-1410-227/+230
|
* Check for socket creation success before calling bind().truckman2016-05-121-10/+10
| | | | | Reported by: Coverity CID: 1194209
* dhclient: Fix some trivial buffer overrunscem2016-05-121-10/+14
| | | | | | | | | | 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
* camcontrol(8): Fix another trivial double-freecem2016-05-111-1/+3
| | | | | | Reported by: Coverity CID: 1331222 Sponsored by: EMC / Isilon Storage Division
* camcontrol(8): Fix trival double-freecem2016-05-111-0/+1
| | | | | | Reported by: Coverity CID: 1331223 Sponsored by: EMC / Isilon Storage Division
* fsck_ffs: Don't overrun mount device buffercem2016-05-111-0/+3
| | | | | | | | | | | | 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
* When rerooting, take the init(8) path from argv[0] instead of fetchingtrasz2016-05-111-16/+9
| | | | | | | | | | | | 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
* When rerooting, ignore ESRCH returned from kill(2). I couldn't reproducetrasz2016-05-111-1/+3
| | | | | | | | | 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
* Cosmetic fixes for growfs(8) - remove unneeded capitalization and a spurioustrasz2016-05-111-4/+4
| | | | | | | newline, clarify a message. MFC after: 1 month Sponsored by: The FreeBSD Foundation
* Update the example growfs(8) manual page to include information on howtrasz2016-05-101-9/+8
| | | | | | | | | | | 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
* Add "camcontrol reprobe" subcommand, and implement it for da(4).trasz2016-05-102-2/+62
| | | | | | | | | | | 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
* Rename getline with get_line to avoid collision with getline(3)bapt2016-05-101-2/+2
| | | | | 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
* ifconfig: fix check for 40 MHz channels while applying country/regdomain.avos2016-05-091-4/+0
| | | | | | | | | 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
* Add missing parameters -N and -l to reroot and halt usage()garga2016-05-061-2/+2
| | | | | | Approved by: bapt Sponsored by: Rubicon Communications (Netgate) Differential Revision: https://reviews.freebsd.org/D6173
* nvmecontrol.8: minor spelling fix.pfg2016-05-061-2/+2
| | | | No functional change.
* Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installedngie2016-05-046-29/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Improve performance and functionality of the bitstring(3) apiasomers2016-05-041-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
OpenPOWER on IntegriCloud