]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/log
FreeBSD/stable/10.git
7 years agoMFC r299484, r301574
truckman [Wed, 15 Jun 2016 06:27:43 +0000 (06:27 +0000)]
MFC r299484, r301574

r299484 | cem | 2016-05-11 15:04:28 -0700 (Wed, 11 May 2016) | 13 lines

random(6): Fix double-close

In the case where a file lacks a trailing newline, there is some "evil" code to
reverse goto the tokenizing code ("make_token") for the final token in the
file.  In this case, 'fd' is closed more than once.  Use a negative sentinel
value to guard close(2), preventing the double close.

Ideally, this code would be restructured to avoid this ugly construction.

r301574 | truckman | 2016-06-07 19:14:05 -0700 (Tue, 07 Jun 2016) | 15 lines

Fix a (false positive?) Argument cannot be negative coverity defect.

Rather than guarding close(fd) with an fd >= 0 test and setting fd
to -1 when it is closed to avoid a potential double-close, just
move the close() call after the conditional "goto make_token".  This
moves the close() call totally outside the loop to avoid the
possibility of calling it twice.  This should also prevent a Coverity
warning about checking fd for validity after it was previously passed
to read().

Reported by: Coverity
CID: 10061231355335

git-svn-id: svn://svn.freebsd.org/base/stable/10@301917 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC 296291,301109
sephe [Wed, 15 Jun 2016 06:08:05 +0000 (06:08 +0000)]
MFC 296291,301109

296291
    hyperv/chan: Factor out the vcpu setting

    And use it for cpu0 assignment; it does not sound right to assume that
    cpu0 maps to vcpu0.  And this factored out function will be exposed to
    drivers, if driver specific CPU binding is needed, e.g. hn(4).

    Move default cpu select after saving channel offer message. This makes
    sure that all useful information of the channel has been setup.

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5504

301109
    hyperv/channel: Only cpu0 is supported as channel target cpu on WIN7

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC

git-svn-id: svn://svn.freebsd.org/base/stable/10@301916 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC 296181,296184,296187,296188,296252,296253,296289,296290
sephe [Wed, 15 Jun 2016 05:57:06 +0000 (05:57 +0000)]
MFC 296181,296184,296187,296188,296252,296253,296289,296290

296181
    hyperv/channel: Add debug sysctl nodes for channel indices

    It would serve as a debug tool, if the shared buffer ring's indices
    stopped updating.

    Submitted by:       HongJiang Zhang <honzhan microsoft com>
    Reviewed by:        sephe, Jun Su <junsu microsoft com>
    Modified by:        sephe
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5402

296184
    hyperv/hn: Switch to if_transmit by default after r296178

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5485

296187
    hyperv/hn: Utilize mbuf flowid

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5488

296188
    hyperv/channel: Add sysctl node for channel owner cpu

    And add sysctl node for sub-channel's channel id.

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5489

296252
    hyperv/hn: Set hash per-packet-info for each packet transmission

    So that the host could dispatch the TX done back to this TX ring's
    owner channel

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5498

296253
    hyperv/channel: Nuke useless stack variable

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5499

296289
    hyperv/chan: Add sysctl node to check whether monitor is allocated or not

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5502

296290
    hyperv/chan: Function renaming; no functional change

    The renamed function create a sysctl tree for channel, and many
    non-statistics nodes exists, so don't claim it only adds sysctl
    nodes for statistics.

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5503

git-svn-id: svn://svn.freebsd.org/base/stable/10@301915 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC 296180,297634
sephe [Wed, 15 Jun 2016 05:31:35 +0000 (05:31 +0000)]
MFC 296180,297634

296180
    hyperv: Use proper fence function to keep store-load order for msgs

    sfence only makes sure about the store-store order, which is not
    sufficient here.  Use atomic_thread_fence_seq_cst() as suggested
    jhb and kib (a locked op in the nutshell, which should have the

    Reviewed by:        jhb, kib, Jun Su <junsu microsoft com>
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5436

297634
    hyperv: Use mb() instead of atomic_thread_fence_seq_cst()

    Since atomic_thread_fence_seq_cst() will become compiler fence on UP kernel.

    Reviewed by:        kib, Dexuan Cui <decui microsoft com>
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5852

git-svn-id: svn://svn.freebsd.org/base/stable/10@301914 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC 296178
sephe [Wed, 15 Jun 2016 05:16:37 +0000 (05:16 +0000)]
MFC 296178

    buf_ring/drbr: Add buf_ring_peek_clear_sc and use it in drbr_peek

    Unlike buf_ring_peek, it only supports single consumer mode, and it
    clears the cons_head if DEBUG_BUFRING/INVARIANTS is defined.

    The normal use case of drbr_peek for network drivers is:

    m = drbr_peek(br);
    err = hw_spec_encap(&m); /* could m_defrag/m_collapse */
    (*)
    if (err) {
        if (m == NULL)
            drbr_advance(br);
        else
            drbr_putback(br, m);
        /* break the loop */
    }
    drbr_advance(br);

    The race is:
    If hw_spec_encap() m_defrag or m_collapse the mbuf, i.e. the old mbuf
    was freed, or like the Hyper-V's network driver, that transmission-
    done does not even require the TX lock; then on the other CPU at the
    (*) time, the freed mbuf could be recycled and being drbr_enqueue even
    before the current CPU had the chance to call drbr_{advance,putback}.
    This triggers a panic in drbr_enqueue duplicated element check, if
    DEBUG_BUFRING/INVARIANTS is defined.

    Use buf_ring_peek_clear_sc() in drbr_peek() to fix the above race.

    This change is a NO-OP, if neither DEBUG_BUFRING nor INVARIANTS are
    defined.

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5416

git-svn-id: svn://svn.freebsd.org/base/stable/10@301913 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC 296083,296084,296085,296086,296087,296088,296089
sephe [Wed, 15 Jun 2016 03:48:55 +0000 (03:48 +0000)]
MFC 296083,296084,296085,296086,296087,296088,296089

296083
    hyperv: Remove useless channel inbound_lock

    It serves no purpose.

    Reviewed by:        Hongjiang Zhang <honzhan microsoft com>
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5450

296084
    hyperv: Always set device for channels

    And unregister hv_device only for primary channels, who own the hv_device.

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5451

296085
    hyperv/hn: Pass channel as the channel callback argument

    This is the preamble to pass channel back to hn(4) upon TX/RX done.

    Reviewed by:        Hongjiang Zhang <honzhan microsoft com>
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5452

296086
    hyperv/hn: Pass channel to TX/RX done

    This is preamble to associate the TX/RX rings to their channel.

    While I'm here, revoke unused netvsc_recv_rollup.

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5453

296087
    hyperv/hn: Associate TX/RX ring with channel

    This fixes the TX/RX ring selection for TX/RX done.

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5454

296088
    hyperv/hn: Remove the useless num_outstanding_sends

    We rely on taskqueue draining now.

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5456

296089
    hyperv/hn: Make transmission path channel aware

    Chimney sending buffer still needs conversion, which will be done
    along with the upcoming vRSS support.

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5457

git-svn-id: svn://svn.freebsd.org/base/stable/10@301912 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC 296022,296024,296076
sephe [Wed, 15 Jun 2016 03:17:05 +0000 (03:17 +0000)]
MFC 296022,296024,296076

296022
    hyperv/hn: Implement ifnet.if_transmit method

    It will be turned on by default later.

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5415

296024
    hyperv/hn: Hold the TX ring lock then drain TX desc buf_ring

    Reported by:        Hongxiong Xian <v-hoxian microsoft com>
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC

296076
    hyperv: Use atomic_fetchadd_int to get GPADL id.

    Reviewed by:        Hongjiang Zhang <honzhan microsoft com>
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5439

git-svn-id: svn://svn.freebsd.org/base/stable/10@301911 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r301764:
jamie [Wed, 15 Jun 2016 01:59:55 +0000 (01:59 +0000)]
MFC r301764:

  Fix a vnode leak when giving a child jail a too-long path when
  debug.disablefullpath=1.

git-svn-id: svn://svn.freebsd.org/base/stable/10@301910 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r301760:
jamie [Wed, 15 Jun 2016 01:58:54 +0000 (01:58 +0000)]
MFC r301760:

  Re-order some jail parameter reading to prevent a vnode leak.

git-svn-id: svn://svn.freebsd.org/base/stable/10@301909 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r301758:
jamie [Wed, 15 Jun 2016 01:57:22 +0000 (01:57 +0000)]
MFC r301758:

  Clean up some logic in jail error messages, replacing a missing test and
  a redundant test with a single correct test.

git-svn-id: svn://svn.freebsd.org/base/stable/10@301908 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r301745:
jamie [Wed, 15 Jun 2016 01:56:20 +0000 (01:56 +0000)]
MFC r301745:

  Make sure the OSD methods for jail set and remove can't run concurrently,
  by holding allprison_lock exclusively (even if only for a moment before
  downgrading) on all paths that call PR_METHOD_REMOVE.  Since they may run
  on a downgraded lock, it's still possible for them to run concurrently
  with PR_METHOD_GET, which will need to use the prison lock.

git-svn-id: svn://svn.freebsd.org/base/stable/10@301907 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r301737:
jamie [Wed, 15 Jun 2016 01:54:17 +0000 (01:54 +0000)]
MFC r301737:

  Remove a comment that was part of copied code, and is misleading in
  the new location.

git-svn-id: svn://svn.freebsd.org/base/stable/10@301906 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r300983:
jamie [Wed, 15 Jun 2016 01:49:01 +0000 (01:49 +0000)]
MFC r300983:

  Mark jail(2), and the sysctls that it (and only it) uses as deprecated.
  jail(8) has long used jail_set(2), and those sysctl only cause confusion.

git-svn-id: svn://svn.freebsd.org/base/stable/10@301905 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r301293:
mav [Wed, 15 Jun 2016 01:42:53 +0000 (01:42 +0000)]
MFC r301293:
When negotiating NTB_SB01BASE_LOCKUP workaround, don't try to limit the
BAR size to 1MB.  According to Xeon v3 specifications and my tests, that
size register is write-once and so not writeable after BIOS written it.

Instead of that, make the code work with BAR of any sufficient size,
properly calculating offset within its base.  It also simplifies the code.

Sponsored by: iXsystems, Inc.

git-svn-id: svn://svn.freebsd.org/base/stable/10@301904 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r301292: When negotiating MSIX parameters, give other head time to see
mav [Wed, 15 Jun 2016 01:41:43 +0000 (01:41 +0000)]
MFC r301292: When negotiating MSIX parameters, give other head time to see
our NTB_MSIX_RECEIVED status, before making upper layers overwrite it.

This is not completely perfect, but now it works better then before.

Sponsored by: iXsystems, Inc.

git-svn-id: svn://svn.freebsd.org/base/stable/10@301903 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r300610: Re-enable write combining, disabled by default at r295486.
mav [Wed, 15 Jun 2016 01:39:43 +0000 (01:39 +0000)]
MFC r300610: Re-enable write combining, disabled by default at r295486.

if_ntb(4) strongly benefits from WC, improving throughput from 350Mbit/s
to 8-10Gbit/s on my tests.

git-svn-id: svn://svn.freebsd.org/base/stable/10@301902 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC 295919,295958,295964
sephe [Mon, 13 Jun 2016 09:02:08 +0000 (09:02 +0000)]
MFC 295919,295958,295964

295919
    hyperv/stor: Fix print format

    Detected by:        PVS Static Analysis
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5388

295958
    hyperv/utils: Code rearrange and cleanup

    Split heartbeat, shutdown and timesync out of utils code
    and name them properly.

    Submitted by:       Jun Su <junsu microsoft com>
    Reviewed by:        adrian, sephe, Hongjiang Zhang <honzhan microsoft com>
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5216

295964
    hyperv/vmbus: Use free(9) for interrupt page; it is allocated by malloc(9)

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5417

git-svn-id: svn://svn.freebsd.org/base/stable/10@301866 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agohyperv/hn: Hide unused function
sephe [Mon, 13 Jun 2016 08:44:29 +0000 (08:44 +0000)]
hyperv/hn: Hide unused function

Sponsored by: Microsoft OSTC

git-svn-id: svn://svn.freebsd.org/base/stable/10@301865 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC 295875,295876,295877,295916,295918
sephe [Mon, 13 Jun 2016 08:38:04 +0000 (08:38 +0000)]
MFC 295875,295876,295877,295916,295918

295875
    hyperv/hn: Rename TX related function and struct fields a bit

    Preamble to implement the ifnet.if_transmit method.

    Reviewed by:        adrian
    Approved by:        adrian (mentor)
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5344

295876
    hyperv/hn: Staticize and rename packet TX done function

    It is only used in hv_netvsc_drv_freebsd.c; and rename it to hn_tx_done()
    mainly to reserve "xmit" for ifnet.if_transmit implement.

    While I'm here, remove unapplied comment.

    Reviewed by:        adrian
    Approved by:        adrian (mentor)
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5345

295877
    hyperv/hn: Add TX method for txeof processing.

    Preamble to implement ifnet.if_transmit method.

    Reviewed by:        adrian
    Approved by:        adrian (mentor)
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5346

295916
    hyperv/hn: Factor out hn_send_pkt() from hn_start_locked()

    It will be shared w/ the upcoming ifnet.if_transmit method
    implementation.

    No functional change.

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5385

295918
    hyperv/hn: Use IFQ_DRV_PREPEND instead of IF_PREPEND

    IF_PREPEND promises out-of-order packet sending when the TX desc list
    is depleted. It was overlooked and copied blindly when the transmission
    path was partially rewritten.

    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5386

git-svn-id: svn://svn.freebsd.org/base/stable/10@301864 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agohyperv/hn: Fix mis-merge introduced by r301861.
sephe [Mon, 13 Jun 2016 08:18:45 +0000 (08:18 +0000)]
hyperv/hn: Fix mis-merge introduced by r301861.

git-svn-id: svn://svn.freebsd.org/base/stable/10@301863 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC 295748,295792,295793,295794
sephe [Mon, 13 Jun 2016 08:03:53 +0000 (08:03 +0000)]
MFC 295748,295792,295793,295794

295748
    hyperv/hn: Use buf_ring for txdesc list

    So one spinlock is avoided, which would be potentially dangerous for
    virtual machine, if the spinlock holder was scheduled out by the host,
    as noted by royger.

    Old spinlock based txdesc list is still kept around, so we could have
    a safe fallback.

    No performance regression nor improvement is observed.

    Reviewed by:        adrian
    Approved by:        adrian (mentor)
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5290

295792
    hyperv/hn: Add option to bind TX taskqueues to the specified CPU

    It will be used to help tracking host side transmission ring selection
    issue; and it will be turned on by default, once we have concrete result.

    Reviewed by:        adrian, Jun Su <junsu microsoft com>
    Approved by:        adrian (mento)
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5316

295793
    hyperv/hn: Enable IP header checksum offloading for WIN8 (WinServ2012)

    Tested on Windows Server 2012.

    Reviewed by:        adrian
    Approved by:        adrian (mentor)
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5317

295794
    hyperv/hn: Free the txdesc buf_ring when the TX ring is destroyed

    Reviewed by:        adrian
    Approved by:        adrian (mentor)
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5318

git-svn-id: svn://svn.freebsd.org/base/stable/10@301862 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC 295743,295744,295745,295746,295747
sephe [Mon, 13 Jun 2016 07:30:54 +0000 (07:30 +0000)]
MFC 295743,295744,295745,295746,295747

295743
    hyperv/hn: Change global tunable prefix to hw.hn

    And use SYSCTL+CTLFLAG_RDTUN for them.

    Suggested by:       adrian
    Reviewed by:        adrian, Hongjiang Zhang <honzhan microsoft com>
    Approved by:        adrian (mentor)
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5274

295744
    hyperv/hn: Split RX ring data structure out of softc

    This paves the way for upcoming vRSS stuffs and eases more code cleanup.

    Reviewed by:        adrian
    Approved by:        adrian (mentor)
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5275

295745
    hyperv/hn: Use taskqueue_enqueue()

    This also eases experiment on the non-fast taskqueue.

    Reviewed by:        adrian, Jun Su <junsu microsoft com>
    Approved by:        adrian (mentor)
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5276

295746
    hyperv/hn: Use non-fast taskqueue for transmission

    Performance stays same; so no need to use fast taskqueue here.

295747
    hyperv/hn: Split TX ring data structure out of softc

    This paves the way for upcoming vRSS stuffs and eases more code cleanup.

    Reviewed by:        adrian
    Approved by:        adrian (mentor)
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5283

git-svn-id: svn://svn.freebsd.org/base/stable/10@301861 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC 295740,295741,295742
sephe [Mon, 13 Jun 2016 07:03:00 +0000 (07:03 +0000)]
MFC 295740,295741,295742

295740
    hyperv/hn: Set the TCP ACK/data segment aggregation limit

    Set TCP ACK append limit to 1, i.e. aggregate 2 ACKs at most.  Aggregating
    anything more than 2 hurts TCP sending performance in hyperv.  This
    significantly improves the TCP sending performance when the number of
    concurrent connetion is low (2~8).  And it greatly stabilizes the TCP
    sending performance in other cases.

    Set TCP data segments aggregation length limit to 37500.  Without this
    limitation, hn(4) could aggregate ~45 TCP data segments for each
    connection (even at 64 or more connections) before dispatching them to
    socket code; large aggregation slows down ACK sending and eventually
    hurts/destabilizes TCP reception performance.  This setting stabilizes
    and improves TCP reception performance for >4 concurrent connections
    significantly.

    Make them sysctls so they could be adjusted.

    Reviewed by:        adrian, gallatin (previous version), hselasky (previous version)
    Approved by:        adrian (mentor)
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5185

295741
    hyperv/hn: Add option to allow sharing TX taskq between hn instances

    It is off by default.  This eases further experimenting on this driver.

    Reviewed by:        adrian
    Approved by:        adrian (mentor)
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5272

295742
    hyperv/hn: Always do transmission scheduling.

    This one gives the best performance so far.

    Reviewed by:        adrian
    Approved by:        adrian (mentor)
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5273

git-svn-id: svn://svn.freebsd.org/base/stable/10@301860 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC 295307,295308,295309,295606
sephe [Mon, 13 Jun 2016 06:38:46 +0000 (06:38 +0000)]
MFC 295307,295308,295309,295606

295307
    hyperv: Use standard taskqueue instead of hv_work_queue

    HyperV code was ported from Linux.  There is an implementation of
    work queue called hv_work_queue.  In FreeBSD, taskqueue could be
    used for the same purpose.  Convert all the consumer of hv_work_queue
    to use taskqueue, and remove work queue implementation.

    Submitted by:       Jun Su <junsu microsoft com>
    Reviewed by:        adrian, Hongjiang Zhang <honzhan microsoft com>
    Approved by:        adrian (mentor)
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D4963

295308
    hyperv: Use WAITOK in the places where we can wait

    And convert rndis non-hot path spinlock to mutex.

    Submitted by:       Jun Su <junsu microsoft com>
    Reviewed by:        adrian, sephe
    Approved by:        adrian (mentor)
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5081

295309
    hyperv: Use malloc for page allocation.

    We will eventually convert them to use busdma.

    Submitted by:       Jun Su <junsu microsoft com>
    Reviewed by:        adrian, sephe, Dexuan Cui <decui microsoft com>
    Approved by:        adrian (mentor)
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5087

295606
    hyperv/hn: Fix typo in comment

    Noticed by: avos
    Reviewed by:        adrian, avos, Hongjiang Zhang <honzhan microsoft com>
    Approved by:        adrian
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5199

git-svn-id: svn://svn.freebsd.org/base/stable/10@301859 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC 295304,295305,295306
sephe [Mon, 13 Jun 2016 06:24:41 +0000 (06:24 +0000)]
MFC 295304,295305,295306

295304
    hyperv/hn: Increase LRO entry count to 128 by default

    hn(4) only has one RX ring currently, so default 8 LRO entries
    are too small.

    Reviewed by:        adrian
    Approved by:        adrian (mentor)
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5166

295305
    hyperv/hn: Move LRO flush to the channel processing rollup

    This significantly increases LRO aggregation ratio when there are
    large amount of connections (improves reception performance a lot).

    Reviewed by:        adrian
    Approved by:        adrian (mentor)
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5167

295306
    hyperv/hn: Add an option to always do transmission scheduling

    It is off by default. This eases more experiment on hn(4).

    Reviewed by:        adrian, Hongjiang Zhang <honzhan microsoft com>
    Approved by:        adrian (mentor)
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5175

git-svn-id: svn://svn.freebsd.org/base/stable/10@301858 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC 295302,295303
sephe [Mon, 13 Jun 2016 06:09:02 +0000 (06:09 +0000)]
MFC 295302,295303

295302
    hyperv/hn: Factor out hn_encap() from hn_start_locked()

    It will be shared w/ upcoming ifnet.if_transmit implementaion.

    No functional changes.

    Reviewed by:        adrian
    Approved by:        adrian (mentor)
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5158

295303
    hyperv/hn: Recover half of the chimney sending space

    We lost half of the chimney sending space, because we mis-used
    ffs() on a 64 bits mask, where ffsl() should be used.

    While I'm here:
    - Use system atomic operation instead.
    - Stringent chimney sending index assertion.

    Reviewed by:        adrian
    Approved by:        adrian (mentor)
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5159

git-svn-id: svn://svn.freebsd.org/base/stable/10@301857 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC 295296,295297,295298,295299,295300,295301
sephe [Mon, 13 Jun 2016 05:43:42 +0000 (05:43 +0000)]
MFC 295296,295297,295298,295299,295300,295301

295296
    hyperv/hn: Avoid duplicate csum features settings

    - Record csum features in softc, so we don't need to duplicate the
      logic from attach path to ioctl path.
    - Protect if_capenable and if_hwassist changes by main lock.
    - Prefer turn on/off bits in if_hwassist explicitly instead of using
      XOR.

    Reviewed by:        adrian, Hongjiang Zhang <honzhan microsoft com>
    Approved by:        adrian (mentor)
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5085

295297
    hyperv/hn: Reorganize TX csum offloading

    - For non-TSO offloading, we don't need to access mbuf to know
      which csum offloading is requested, we can just use the
      CSUM_{IP,TCP,UDP} in the csum_flags.
    - For TSO offloading, we still can depend on CSUM_{TSO4,TSO6}
      in the csum_flags to tell whether the TSO packet is an IPv4
      TSO packet or an IPv6 TSO packet.

    This streamlines csum offloading handling (remove the two goto)
    and allows us the nuke the unnecessary get_transport_proto_type().

    Reviewed by:        adrian, Hongjiang Zhang <honzhan microsoft com>
    Approved by:        adrian (mentor)
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5098

295298
    hyperv/hn: Enable IP header checksum offloading

    So that:
    - TCP/IP stack will not do unnecessary IP header checksum for TSO
      packets.
    - Reduce guest load for non-TSO IP packets.

    Reviewed by:        adrian
    Approved by:        adrian (mentor)
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5099

295299
    hyperv/hn: Enable UDP RXCSUM

    Reviewed by:        adrian
    Approved by:        adrian (mentor)
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5102

295300
    hyperv/hn: Add sysctls to trust host side UDP and IP csum verification

    Reviewed by:        adrian, Hongjiang Zhang <honzhan microsoft com>
    Approved by:        adrian (mentor)
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5103

295301
    hyperv/hn: Obey IFCAP_RXCSUM configure

    Reviewed by:        adrian
    Approved by:        adrian (mentor)
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5104

git-svn-id: svn://svn.freebsd.org/base/stable/10@301856 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC 295295
sephe [Mon, 13 Jun 2016 05:13:52 +0000 (05:13 +0000)]
MFC 295295

    hyperv/stor: Fix the NULL pointer dereference

    Reported by:        Netapp
    Submitted by:       Hongjiang Zhang <honzhan microsoft com>
    Reviewed by:        adrian, sephe, Dexuan Cui <decui microsoft com>
    Approved by:        adrian (mentor)
    MFC after:  1 week
    Sponsored by:       Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5097

git-svn-id: svn://svn.freebsd.org/base/stable/10@301855 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC 294886
sephe [Mon, 13 Jun 2016 05:06:07 +0000 (05:06 +0000)]
MFC 294886

    hyperv/vmbus: Event handling code refactor.

    - Use taskqueue instead of swi for event handling.
    - Scan the interrupt flags in filter
    - Disable ringbuffer interrupt mask in filter to ensure no unnecessary
      interrupts.

    Submitted by:               Jun Su <junsu microsoft com>
    Reviewed by:                adrian, sephe, Dexuan <decui microsoft com>
    Approved by:                adrian (mentor)
    MFC after:          2 weeks
    Sponsored by:               Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D4920

git-svn-id: svn://svn.freebsd.org/base/stable/10@301854 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC 294701,294702,294703,294705,294788
sephe [Mon, 13 Jun 2016 03:28:37 +0000 (03:28 +0000)]
MFC 294701,294702,294703,294705,294788

294701
    hyperv/hn: Use m_copydata for chimney sending.

    While I'm here, move stack variables near their usage.

    Reviewed by:                adrian, delphij, Jun Su <junsu microsoft com>
    Approved by:                adrian (mentor)
    Sponsored by:               Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D4977

294702
    hyperv/hn: Remove unnecessary zeroing out the netvsc_packet

    All used fields are setup one by one, so there is no need to zero
    out this large struct.

    While I'm here, move the stack variable near its usage.

    Reviewed by:                adrian, delphij, Jun Su <junsu microsoft com>
    Approved by:                adrian (mentor)
    Sponsored by:               Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D4978

294703
    hyperv/hn: Trust host TCP segment checksum verification by default.

    According to all available information, VMSWITCH always does the
    TCP segment checksum verification before sending the segment to
    guest.

    Reviewed by:                adrian, delphij, Hongjiang Zhang <honzhan microsoft com>
    Approved by:                adrian (mentor)
    Sponsored by:               Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D4991

294705
    hyperv/vmbus: Avoid extra copy of page information.

    The page information array could contain up to 32 elements (i.e. 512B).
    And on network side w/ TSO, 11+ (176B+) elements, i.e. ~44K TSO packet,
    in the page information array is quite common.

    This saves us some cpu cycles.

    Reviewed by:                adrian, delphij
    Approved by:                adrian (mentor)
    Sponsored by:               Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D4992

294788
    hyperv/hn: Improve sending performance

    - Avoid main lock contention by trylock for if_start, if that fails,
      schedule TX taskqueue for if_start
    - Don't do direct sending if the packet to be sent is large, e.g.
      TSO packet.

    This change gives me stable 9.1Gbps TCP sending performance w/ TSO
    over a 10Gbe directly connected network (the performance fluctuated
    between 4Gbps and 9Gbps before this commit). It also improves non-
    TSO TCP sending performance a lot.

    Reviewed by:                adrian, royger
    Approved by:                adrian (mentor)
    Sponsored by:               Microsoft OSTC
    Differential Revision:      https://reviews.freebsd.org/D5074

git-svn-id: svn://svn.freebsd.org/base/stable/10@301850 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC 300985, 301103
sephe [Mon, 13 Jun 2016 03:03:08 +0000 (03:03 +0000)]
MFC 300985, 301103

r300985
bge: Support 5717 C0, which is almost same as 5720 A0

PR:         209758
Obtained from:      DragonFlyBSD d79f5d8f5fe94cd6769207b2901422977d502bc0
MFC after:  1 week

============

r301103
bge: Force chipid to 5720 A0 for 5717 C0 in an early place

Discussed with:     yongari
MFC after:  1 week
Sponsored by:       Microsoft OSTC

git-svn-id: svn://svn.freebsd.org/base/stable/10@301848 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC 293653
sephe [Mon, 13 Jun 2016 02:54:58 +0000 (02:54 +0000)]
MFC 293653

hyperv/kvp_daemon: Make poll(2) block indefinitely

Submitted by:       Jun Su <junsu microsoft com>
Reviewed by:        Dexuan Cui <decui microsoft com>, me, adrain
Approved by:        adrian
Sponsored by:       Microsoft OSTC
Differential Revision:      https://reviews.freebsd.org/D4762

git-svn-id: svn://svn.freebsd.org/base/stable/10@301847 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r300967:
dim [Sun, 12 Jun 2016 11:45:45 +0000 (11:45 +0000)]
MFC r300967:

Stop exposing the C11 _Atomic() macro in <sys/cdefs.h>, when compiling
for C++.  It clashes with the one in libc++'s <atomic> header.

(Previously, the _Atomic() macro was defined in <stdatomic.h>, which is
only for use with C11, but for various reasons it was moved to its
current location in r251804.)

Discussed with: bdrewery, ed

git-svn-id: svn://svn.freebsd.org/base/stable/10@301839 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r300395:
ngie [Sun, 12 Jun 2016 05:57:42 +0000 (05:57 +0000)]
MFC r300395:

Silence top(1) compiler warnings

The contrib/top code is no longer maintained upstream (last pulled 16 years
ago). The K&R-style followed by the code spews -Wimplicit-int and -Wreturn-type
warnings, amongst others. This silences 131 warnings with as little modification
as possible by adding necessary return types, definitions, headers, and header
guards, and missing header includes.

The 5 warnings that remain are due to undeclared ncurses references. I didn't
include curses.h and term.h because there are several local functions and macros
that conflict with those definitions.

git-svn-id: svn://svn.freebsd.org/base/stable/10@301836 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r301457:
kib [Sun, 12 Jun 2016 02:42:08 +0000 (02:42 +0000)]
MFC r301457:
Avoid spurious EINVAL in amd64 pmap_change_attr().

git-svn-id: svn://svn.freebsd.org/base/stable/10@301835 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoRedo MFC r300220,r300223:
ngie [Sat, 11 Jun 2016 11:28:29 +0000 (11:28 +0000)]
Redo MFC r300220,r300223:

Differential Revision: https://reviews.freebsd.org/D6803
Reviewed by: alc, kib
Sponsored by: EMC / Isilon Storage Division

r300220 (by cem):

sys/vmmeter.h: Fix trivial '-Wsign-compare' warning in common header

Frankly, it doesn't make sense for vm_pageout_wakeup_thresh to have a negative
value (it is only ever set to a fraction of v_free_min, which is unsigned and
also obviously non-negative). But I'm not going to try and convert every
non-negative scalar in the VM to unsigned today, so just cast it for the
comparison.

r300223 (by cem):

vm/vm_page.h: Fix trivial '-Wpointer-sign' warning

pq_vcnt, as a count of real things, has no business being negative. It is only
ever initialized by a u_int counter.

The warning came from the atomic_add_int() in vm_pagequeue_cnt_add().

Rectify the warning by changing the variable to u_int. No functional change.

Suggested by: Clang 3.3

git-svn-id: svn://svn.freebsd.org/base/stable/10@301833 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoRevert r301831 -- I forgot to add the diff from Phabricator
ngie [Sat, 11 Jun 2016 11:25:49 +0000 (11:25 +0000)]
Revert r301831 -- I forgot to add the diff from Phabricator

Pointyhat to: ngie (never commit without svn status half asleep)

git-svn-id: svn://svn.freebsd.org/base/stable/10@301832 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r300220,r300223:
ngie [Sat, 11 Jun 2016 11:24:30 +0000 (11:24 +0000)]
MFC r300220,r300223:

Differential Revision: https://reviews.freebsd.org/D6803
Reviewed by: alc, kib
Sponsored by: EMC / Isilon Storage Division

r300220 (by cem):

sys/vmmeter.h: Fix trivial '-Wsign-compare' warning in common header

Frankly, it doesn't make sense for vm_pageout_wakeup_thresh to have a negative
value (it is only ever set to a fraction of v_free_min, which is unsigned and
also obviously non-negative). But I'm not going to try and convert every
non-negative scalar in the VM to unsigned today, so just cast it for the
comparison.

r300223 (by cem):

vm/vm_page.h: Fix trivial '-Wpointer-sign' warning

pq_vcnt, as a count of real things, has no business being negative. It is only
ever initialized by a u_int counter.

The warning came from the atomic_add_int() in vm_pagequeue_cnt_add().

Rectify the warning by changing the variable to u_int. No functional change.

Suggested by: Clang 3.3

git-svn-id: svn://svn.freebsd.org/base/stable/10@301831 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r301584: Apply mergemaster r255428:
delphij [Sat, 11 Jun 2016 05:53:50 +0000 (05:53 +0000)]
MFC r301584: Apply mergemaster r255428:

Pass -n (do not emit comments) when saving mtree information for future
mergemaster(8) runs.

git-svn-id: svn://svn.freebsd.org/base/stable/10@301824 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r301570:
pfg [Sat, 11 Jun 2016 03:58:59 +0000 (03:58 +0000)]
MFC r301570:
libsupc++: Fix typo in symbol map.

This went mostly unnoticed with the deprecation of the GNU toolchain
in tier 1 platforms. Fix it now for the rest.

PR: 169901

git-svn-id: svn://svn.freebsd.org/base/stable/10@301822 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r301704:
ngie [Sat, 11 Jun 2016 01:37:59 +0000 (01:37 +0000)]
MFC r301704:

Test for strchr(3) returning NULL, not 0

git-svn-id: svn://svn.freebsd.org/base/stable/10@301820 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r301683:
ngie [Sat, 11 Jun 2016 01:34:41 +0000 (01:34 +0000)]
MFC r301683:

Fix typo with description for $ipv6_cpe_wanif (upstram -> upstream)

PR: 210146

git-svn-id: svn://svn.freebsd.org/base/stable/10@301818 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r300301, r300319:
pfg [Fri, 10 Jun 2016 22:07:17 +0000 (22:07 +0000)]
MFC r300301, r300319:
GCC: Add support for named initializers for anonymous structs/unions.

This is a C11 feature that is starting to get used in places such as Mesa.
This implementation takes a different approach to upstream and is
therefore not covered by GPLv3.

Obtained from: OpenBSD (CVS rev. 1.2)

git-svn-id: svn://svn.freebsd.org/base/stable/10@301817 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r300333:
pfg [Fri, 10 Jun 2016 21:47:37 +0000 (21:47 +0000)]
MFC r300333:
gas: Implement the .inst assembler directive for arm.

We normally use the binutils from ports but on other systems this
is required for building gcc 4.9.

Obtained from: OpenBSD (CVS rev. 1.5)

git-svn-id: svn://svn.freebsd.org/base/stable/10@301816 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoRecord mergeinfo for all complete commits done in the ioat(4) merge
ngie [Fri, 10 Jun 2016 18:47:11 +0000 (18:47 +0000)]
Record mergeinfo for all complete commits done in the ioat(4) merge
in r300661

This will make it easier for someone to determine what's missing when
running `svn mergeinfo --show-revs eligible`

r299353 wasn't recorded intentionally because it was only a "partial"
merge

Sponsored by: EMC / Isilon Storage Division

git-svn-id: svn://svn.freebsd.org/base/stable/10@301813 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r301296,r301297,r301300:
ngie [Fri, 10 Jun 2016 18:40:03 +0000 (18:40 +0000)]
MFC r301296,r301297,r301300:

r301296 (by cem):

ioat(4): Make channel indices unsigned

r301297 (by cem):

ioat(4): Export the number of available channels

r301300 (by cem):

ioat(4): Always log capabilities on attach

Different, relatively recent Intel Xeon hardware support radically different
features.  E.g., BDX support CRC32 while BDX-DE does not.

git-svn-id: svn://svn.freebsd.org/base/stable/10@301812 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r295618,r300100,r300531:
ngie [Fri, 10 Jun 2016 18:34:31 +0000 (18:34 +0000)]
MFC r295618,r300100,r300531:

r295618 (by cem):

NTB: workaround for high traffic hardware hang

This patch comes from Dave Jiang's Linux tree, davejiang/ntb.  It hasn't
been accepted into Linus' tree, so I do not have an authoritative SHA1
to point at.  Original commit log:

=====================================================================
A hardware errata causes the NTB to hang when heavy bi-directional
traffic in addition to the usage of BAR0/1 (where the registers reside,
including the doorbell registers to trigger interrupts).

This workaround is only available on Haswell and Broadwell platform.
The workaround is to enable split BAR in the BIOS to allow the 64bit
BAR4 to be split into two 32bit BAR4 and BAR5. The BAR4 shall be pointed
to LAPIC region of the remote host. We will bypass the db mechanism and
directly trigger the MSIX interrupts. The offsets and vectors are
exchanged during transport scratch pad negotiation. The scratch pads are
now overloaded in order to allow the exchange of the information. This
gets around using the doorbell and prevents the lockup with additional
pcode changes in BIOS.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
=====================================================================

Notable changes in the FreeBSD version of this patch:
* The MSIX BAR is configurable, like hw.ntb.b2b_mw_idx (msix_mw_idx).
  The Linux version of the patch only uses BAR4.
* MSIX negotiation aborts if the link goes down.

Obtained from: Linux (Dual BSD/GPL driver)

r300100 (by cem):

ntb_hw(4): Add sysctls for administrative/test link config, state

dev.ntb_hw.0.admin_up=0/1: Like ifconfig UP/DOWN.
dev.ntb_hw.0.active=0/1:   Like ifconfig 'status'

r300531 (by cem):

ntb_hw(4): Only record the first three MSIX vectors

Don't overrun the msix_data array by reading the (unused) link state
interrupt information.

git-svn-id: svn://svn.freebsd.org/base/stable/10@301811 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r299513,r299515:
ngie [Fri, 10 Jun 2016 18:21:05 +0000 (18:21 +0000)]
MFC r299513,r299515:

r299513 (by cem):

rtadvd(8): Don't use-after-free

This whole block of code as committed fully formed in r224144.  I'm not really
sure what the intent was, but it seems plausible that !persist ifis could need
other member cleanup.  Don't free the object until after we've finished
cleaning its members.

CID: 1006079

r299515 (by cem):

rtadvd(8): Fix use-after-close in cm_handler_client

cm_send() closes 'fd' on error.  In that case, bail out early without trying to
recv from or close 'fd' again.

CID: 1006078

git-svn-id: svn://svn.freebsd.org/base/stable/10@301809 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r299511:
ngie [Fri, 10 Jun 2016 18:13:41 +0000 (18:13 +0000)]
MFC r299511:
r299511 (by cem):

print_positional_test: Fix misuse of wchar APIs

These APIs take unit length, not byte length parameters.

CIDs: 133854313385441338545

git-svn-id: svn://svn.freebsd.org/base/stable/10@301808 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r299510:
ngie [Fri, 10 Jun 2016 18:10:32 +0000 (18:10 +0000)]
MFC r299510:
r299510 (by cem):

libmp: Fix trivial buffer overrun

fgetln yields a non-NUL-terminated buffer and its length.  This routine
attempted to NUL-terminate it, but did not allocate space for the NUL.  So,
allocate space for the NUL.

CID: 1017457

git-svn-id: svn://svn.freebsd.org/base/stable/10@301806 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r299508:
ngie [Fri, 10 Jun 2016 18:07:35 +0000 (18:07 +0000)]
MFC r299508:
r299508 (by cem):

kern_descrip_test: Fix trivial buffer overrun with readlink(2)

CID: 12299651229972

git-svn-id: svn://svn.freebsd.org/base/stable/10@301805 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r299507:
ngie [Fri, 10 Jun 2016 18:02:51 +0000 (18:02 +0000)]
MFC r299507:
r299507 (by cem):

rtadvd(8): Fix a typo in full msg receive logic

Check against the size of the struct, not the pointer.  Previously, a message
with a cm_len between 9 and 23 (inclusive) could cause int msglen to underflow
and read(2) to be invoked with msglen size (implicitly cast to signed),
overrunning the caller-provided buffer.

All users of cm_recv() supply a stack buffer.

On the other hand, the rtadvd control socket appears to only be writable by the
owner, who is probably root.

While here, correct some types to be size_t or ssize_t.

CID: 1008477
Security: unix socket remotes may overflow stack in rtadvd

git-svn-id: svn://svn.freebsd.org/base/stable/10@301803 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r300836:
ngie [Fri, 10 Jun 2016 17:57:50 +0000 (17:57 +0000)]
MFC r300836:

Quell false positives in svc_vc_create and svc_vc_create_conn with cd and xprt

Both cd and xprt will be non-NULL after their respective malloc(9) wrappers are
called (mem_alloc and svc_xprt_alloc, which calls mem_alloc) as mem_alloc
always gets called with M_WAITOK|M_ZERO today. Thus, testing for them being
non-NULL is incorrect -- it misleads Coverity and it misleads the reader.

Remove some unnecessary NULL initializations as a follow up to help solidify
the fact that these pointers will be initialized properly in sys/rpc/.. with
the interfaces the way they are currently.

CID: 100733810073391007340

git-svn-id: svn://svn.freebsd.org/base/stable/10@301801 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r299503,r299504:
ngie [Fri, 10 Jun 2016 15:47:20 +0000 (15:47 +0000)]
MFC r299503,r299504:

r299503 (by cem):

snd_hda(4): Don't pass bogus sizeof()s to unused sysctl arg2 parameter

None of the sysctl handlers in hdaa use the arg2 parameter, so just pass zero
instead.  Additionally, the sizes being passed in were suspect (size of the
pointer rather than the value).

CIDs: 10076941009679

r299504 (by cem):

snd_hda(4): Don't pass bogus sizeof()s to unused sysctl arg2 parameter (again)

More of the same sort of issue as r299503, just missed some sysctls added in a
different place than the others.

CIDs: 100769210096771009678

git-svn-id: svn://svn.freebsd.org/base/stable/10@301799 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r299502:
ngie [Fri, 10 Jun 2016 15:42:17 +0000 (15:42 +0000)]
MFC r299502:
r299502 (by cem):

nss/gethostby_test: fix broken vector iteration of gethostbyaddr h_aliases

h_aliases is a NULL-terminated rather than fixed-length array.  nitems() is not
a valid way to determine its end; instead, check for NULL.

CID: 1346578

git-svn-id: svn://svn.freebsd.org/base/stable/10@301798 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r301295:
cy [Fri, 10 Jun 2016 15:03:18 +0000 (15:03 +0000)]
MFC r301295:

Enable daily_ntpd_leapfile_enable by default. Otherwise an expired
leapfile will be ignored and ntpd will behave as if it has no
leapfile.

While here, remove an extraneous blank line.

Suggested by: ache

git-svn-id: svn://svn.freebsd.org/base/stable/10@301795 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r299496:
ngie [Fri, 10 Jun 2016 14:51:11 +0000 (14:51 +0000)]
MFC r299496:
r299496 (by cem):

atf map: Fix double-free in low memory error path

If atf_list_append(, X, ) fails, X is freed.  Don't free it again.

CID: 979936

git-svn-id: svn://svn.freebsd.org/base/stable/10@301793 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r299495:
ngie [Fri, 10 Jun 2016 14:48:10 +0000 (14:48 +0000)]
MFC r299495:
r299495 (by cem):

libkrb5: Fix potential double-free

If krb5_make_principal fails, tmp_creds.server may remain a pointer to freed
memory and then be double-freed.  After freeing it the first time, initialize
it to NULL, which causes subsequent krb5_free_principal calls to do the right
thing.

CID: 1273430

git-svn-id: svn://svn.freebsd.org/base/stable/10@301792 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r299494:
ngie [Fri, 10 Jun 2016 14:45:20 +0000 (14:45 +0000)]
MFC r299494:
r299494 (by cem):

subr_vmem: Fix double-free in error case of vmem_create

If vmem_init() fails, 'vm' is already destroyed and freed.  Don't free it
again.

CID: 1042110

git-svn-id: svn://svn.freebsd.org/base/stable/10@301791 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r299491:
ngie [Fri, 10 Jun 2016 14:40:41 +0000 (14:40 +0000)]
MFC r299491:
r299491 (by cem):

route6d(8): Fix potential double-free

In the case that the subsequent sysctl(3) call failed, 'buf' could be free(3)ed
repeatedly.  It isn't clear to me that that case is possible, but be clear and
do the right thing in case it is.

CID: 272537

git-svn-id: svn://svn.freebsd.org/base/stable/10@301789 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r299490:
ngie [Fri, 10 Jun 2016 14:33:21 +0000 (14:33 +0000)]
MFC r299490:
r299490 (by cem):

camcontrol(8): Fix another trivial double-free

CID: 1331222

git-svn-id: svn://svn.freebsd.org/base/stable/10@301788 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r299489:
ngie [Fri, 10 Jun 2016 14:31:03 +0000 (14:31 +0000)]
MFC r299489:
r299489 (by cem):

camcontrol(8): Fix trival double-free

CID: 1331223

git-svn-id: svn://svn.freebsd.org/base/stable/10@301786 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r299461:
ngie [Fri, 10 Jun 2016 14:13:24 +0000 (14:13 +0000)]
MFC r299461:
r299461 (by cem):

ffs_bswap: Copy one UFS dinode member at a time

No functional change.

CIDs: 974635, 974636, 977396, 977397, 977398, 977399

git-svn-id: svn://svn.freebsd.org/base/stable/10@301784 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r299460:
ngie [Fri, 10 Jun 2016 14:08:41 +0000 (14:08 +0000)]
MFC r299460:
r299460 (by cem):

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.

CID: 1006789

git-svn-id: svn://svn.freebsd.org/base/stable/10@301782 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r299387:
ngie [Fri, 10 Jun 2016 13:57:56 +0000 (13:57 +0000)]
MFC r299387:
r299387 (by cem):

netipsec: Fix minor style nit

Coverity points out that 'continue' is equivalent to 'break' in a do {}
while(false) loop.

CID: 1354983

git-svn-id: svn://svn.freebsd.org/base/stable/10@301780 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r301278
kib [Fri, 10 Jun 2016 04:04:55 +0000 (04:04 +0000)]
MFC r301278
Reduce number of iterations used for calibrating ICR read loop.

MFC r301279:
Record correct commit message for r301278.

git-svn-id: svn://svn.freebsd.org/base/stable/10@301776 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r300779, r300781, r300783, r300784, r300949, r301162, r301180
truckman [Fri, 10 Jun 2016 00:00:25 +0000 (00:00 +0000)]
MFC r300779, r300781, r300783, r300784, r300949, r301162, r301180

r300779 | truckman | 2016-05-26 14:40:13 -0700 (Thu, 26 May 2016) | 64 lines

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

[Remove some code that was added to the mq_append() inline function in
HEAD by r258457, which was not merged to stable/10.  The AQM patch
moved mq_append() from ip_dn_io.c to the new file ip_dn_private.h, so
we need to remove that copy of the r258457 changes.]
------------------------------------------------------------------------
r300781 | truckman | 2016-05-26 14:44:52 -0700 (Thu, 26 May 2016) | 7 lines

Modify BOUND_VAR() macro to wrap all of its arguments in () and tweak
its expression to work on powerpc and sparc64 (gcc compatibility).

Correct a typo in a nearby comment.

MFC after: 2 weeks (with r300779)

------------------------------------------------------------------------
r300783 | truckman | 2016-05-26 15:03:28 -0700 (Thu, 26 May 2016) | 4 lines

Correct a typo in a comment.

MFC after: 2 weeks (with r300779)

------------------------------------------------------------------------
r300784 | truckman | 2016-05-26 15:07:09 -0700 (Thu, 26 May 2016) | 5 lines

Include the new AQM files when compiling a kernel with options DUMMYNET.

Reported by: Nikolay Denev <nike_d AT cytexbg DOT com>
MFC after: 2 weeks (with r300779)

------------------------------------------------------------------------
r300949 | truckman | 2016-05-29 00:23:56 -0700 (Sun, 29 May 2016) | 10 lines

Cast some expressions that multiply a long long constant by a
floating point constant to int64_t.  This avoids the runtime
conversion of the the other operand in a set of comparisons from
int64_t to floating point and doing the comparisions in floating
point.

Suggested by: lidl
Submitted by: Rasool Al-Saadi <ralsaadi@swin.edu.au>
MFC after: 2 weeks (with r300779)

------------------------------------------------------------------------
r301162 | truckman | 2016-06-01 13:04:24 -0700 (Wed, 01 Jun 2016) | 9 lines

Replace constant expressions that contain multiplications by
fractional floating point values with integer divides.  This will
eliminate any chance that the compiler will generate code to evaluate
the expression using floating point at runtime.

Suggested by: bde
Submitted by: Rasool Al-Saadi <ralsaadi@swin.edu.au>
MFC after: 8 days (with r300779 and r300949)

------------------------------------------------------------------------
r301180 | truckman | 2016-06-01 17:42:15 -0700 (Wed, 01 Jun 2016) | 2 lines

Belatedly bump .Dd date for Dummynet AQM import in r300779.

Relnotes: yes

git-svn-id: svn://svn.freebsd.org/base/stable/10@301772 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r301513:
pfg [Thu, 9 Jun 2016 16:29:19 +0000 (16:29 +0000)]
MFC r301513:
indent(1): Fix old typo.

It's typedef, not typdef.

Obtained from: NetBSD (CVS rev. 1.14)

git-svn-id: svn://svn.freebsd.org/base/stable/10@301743 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r301465:
bdrewery [Thu, 9 Jun 2016 15:43:00 +0000 (15:43 +0000)]
MFC r301465:

  Fix bmake version upgrade logic to use the new bmake.

The '${WANT_MAKE} != "bmake"' logic seems wrong but is not being modified.

git-svn-id: svn://svn.freebsd.org/base/stable/10@301738 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r300870,r300884:
ngie [Wed, 8 Jun 2016 20:47:25 +0000 (20:47 +0000)]
MFC r300870,r300884:

r300870:

Unbreak the zfs(4) build

vm/vm_pageout.h grew a dependency on the bool typedef in r300865

arc.c didn't include sys/types.h, which included the definition for the typedef

Other items (ofed, drm2) might need to be chased for this commit.

Pointyhat to: alc

r300884:

Fix up r300870

The sys/types.h fix I proposed was only tested with zfs(4), not with
libzpool, which is where the build failure actually existed

Remove vm/vm_pageout.h from arc.c and zfs_vnops.c because they're both
unneeded

In collaboration with: kib

git-svn-id: svn://svn.freebsd.org/base/stable/10@301695 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r300624:
ngie [Wed, 8 Jun 2016 18:46:10 +0000 (18:46 +0000)]
MFC r300624:

Fix up r300385

I accidentally glossed over the fact that tmp is manipulated via strchr, so
if we tried to free `tmp` after r300385, it would have crashed.

Create a separate pointer (tmp2) to track the original allocation of `tmp`,
and free `tmp2` if `p->nc_lookups` can't be malloced

CID: 1356026

git-svn-id: svn://svn.freebsd.org/base/stable/10@301687 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r300385:
ngie [Wed, 8 Jun 2016 18:41:49 +0000 (18:41 +0000)]
MFC r300385:

Don't leak `tmp` if `p->nc_lookups` can't be malloced

git-svn-id: svn://svn.freebsd.org/base/stable/10@301684 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r300386:
ngie [Wed, 8 Jun 2016 18:27:44 +0000 (18:27 +0000)]
MFC r300386:

Don't leak `handle` if svc_tp_create(..) succeeds and allocating a new
struct xlist object fails

CID: 978277

git-svn-id: svn://svn.freebsd.org/base/stable/10@301682 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r300625:
ngie [Wed, 8 Jun 2016 18:22:54 +0000 (18:22 +0000)]
MFC r300625:

Remove unnecessary memset(.., 0, ..)'s

The mem_alloc macro calls calloc (userspace) / malloc(.., M_WAITOK|M_ZERO)
under the covers, so zeroing out memory is already handled by the underlying
calls

git-svn-id: svn://svn.freebsd.org/base/stable/10@301680 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r300861,r300862:
ngie [Wed, 8 Jun 2016 18:21:25 +0000 (18:21 +0000)]
MFC r300861,r300862:

r300861:

- Sort make variables
- Use SRCTOP instead of ad hoc definition for it

r300862:

Install ioatcontrol to /usr/bin by default instead of /

git-svn-id: svn://svn.freebsd.org/base/stable/10@301678 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r300856,r300857,r300858,r300874:
ngie [Wed, 8 Jun 2016 18:19:34 +0000 (18:19 +0000)]
MFC r300856,r300857,r300858,r300874:

r300856:

Initialize `t` with memset(.., 0, ..)

This will help ensure that we're not using random garbage on the stack by
accident with respect to the variable

r300857:

Document the default behavior for -c (0)

Bump .Dd for the change

r300858:

Fix description for -V in the -r case

t.verify_test = true is always set when -V is specified, regardless of whether
or not the tool is being run in raw mode

r300874:

Update usage(..)

- Document missing options
- Sync options with ioatcontrol(8).
- Make it clear that the first 2 parameters are always required.

git-svn-id: svn://svn.freebsd.org/base/stable/10@301677 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r300714:
ngie [Wed, 8 Jun 2016 18:15:51 +0000 (18:15 +0000)]
MFC r300714:

The readme provides a high-level overview of how to upgrade top(1).

Reviewed By: ngie

git-svn-id: svn://svn.freebsd.org/base/stable/10@301675 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r299699:
ngie [Wed, 8 Jun 2016 18:14:06 +0000 (18:14 +0000)]
MFC r299699:

Remove NO_WERROR from libbsnmp/Makefile.inc

This has been compiling without warnings with clang/gcc for a while now

Tested with: clang 3.8.0, gcc 4.2.x, gcc 5.x

git-svn-id: svn://svn.freebsd.org/base/stable/10@301673 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r299815:
ngie [Wed, 8 Jun 2016 18:08:06 +0000 (18:08 +0000)]
MFC r299815:

Remove NO_WERROR.clang from this Makefile

This compiles with clang without warnings

git-svn-id: svn://svn.freebsd.org/base/stable/10@301671 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r299806:
ngie [Wed, 8 Jun 2016 18:05:52 +0000 (18:05 +0000)]
MFC r299806:

Bump WARNS to 6

git-svn-id: svn://svn.freebsd.org/base/stable/10@301669 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r299834:
ngie [Wed, 8 Jun 2016 17:59:21 +0000 (17:59 +0000)]
MFC r299834:

Fix .Dd

Today is the 14th, not the 10th of May

git-svn-id: svn://svn.freebsd.org/base/stable/10@301667 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r294507,r294567,r299466:
ngie [Wed, 8 Jun 2016 17:49:03 +0000 (17:49 +0000)]
MFC r294507,r294567,r299466:

r294507 (by harti):

Fill the ifAlias leaf of the ifXTable with the interface description
if there is one available and it fits into the maximum size (64 characters).

r294567 (by bz):

Change the variable to a #define in order to make gcc happy which
otherwise will complain about "variably modified 'alias' at file scope".
Unbreaks the build on gcc platforms.

r299466 (by cem):

bsnmpd: Fix size of trapsink::comm to match other community arrays

This fixes a number of possible strcpy() buffer overruns between the various
community strings in trap.c.

CIDs: 100682010068211006822

git-svn-id: svn://svn.freebsd.org/base/stable/10@301663 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r256678,r256680,r260986,r272878,r286402:
ngie [Wed, 8 Jun 2016 17:43:04 +0000 (17:43 +0000)]
MFC r256678,r256680,r260986,r272878,r286402:

r256678 (by syrinx):

Fix SNMP Error response PDUs and properly encode them when using v3 auth/encryption.

r256680 (by syrinx):

Fix the -Wconversion warnings produced when compiling the SNMP agent.

r260986 (by harti):

Fix a problem with OBJECT IDENTIFIER encoding: need to check the
second subid to be less than 40, not the first when the first
subid is 0 or 1.

r272878 (by syrinx):

Fix a bug in decoding string indexes in snmp_target(3), thus causing
bsnmpd(1) to not send v3 notifications properly; while here add two
missing return statements which could lead to abort() in case of a
rollback

r286402 (by araujo):

Fix variable 'old' is used uninitialized whenever '&&' condition is false.
Spotted by clang.

git-svn-id: svn://svn.freebsd.org/base/stable/10@301661 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r299701:
ngie [Wed, 8 Jun 2016 17:34:37 +0000 (17:34 +0000)]
MFC r299701:

Move _bsnmptools_debug extern from bsnmpmap.c to bsnmptools.h

It was used in bsnmpmap.c but was stored in bsnmptools.c; moving the extern
to the header allows us to cover all of our bases for the variable, and allows
_bsnmptools_debug to be used in the future elsewhere -- not just bsnmpmap.c.

git-svn-id: svn://svn.freebsd.org/base/stable/10@301657 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r299778:
ngie [Wed, 8 Jun 2016 17:32:41 +0000 (17:32 +0000)]
MFC r299778:

Use a consistent errno save/restore pattern before running strtoul

- Save errno
- Set errno to 0
- Call strtoul
- Test errno (optional, but many calls to strtoul did this afterwards)

Some of the code was setting errno = 0 after calling strtoul, not setting
errno = 0, or setting errno to saved_errno after the call, but before the
test. These all have unwanted behavioral side-effects, depending on the
initial value of errno and whether or not the input to strtoul was correct
or incorrect.

git-svn-id: svn://svn.freebsd.org/base/stable/10@301656 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r299766:
ngie [Wed, 8 Jun 2016 17:30:29 +0000 (17:30 +0000)]
MFC r299766:

Fix logically dead code pointed out by clang/Coverity

parse_context, parse_user_security: test for validity of results from
parse_ascii(..) with by casting to int32_t and comparing to -1; comparing
unsigned types to negative values will always be false.

CID: 10114321011433

git-svn-id: svn://svn.freebsd.org/base/stable/10@301655 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r299810:
ngie [Wed, 8 Jun 2016 17:27:38 +0000 (17:27 +0000)]
MFC r299810:

Correct function names that failed in error messages

It should be calloc/strdup, not malloc

git-svn-id: svn://svn.freebsd.org/base/stable/10@301653 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r300947:
ngie [Wed, 8 Jun 2016 17:13:28 +0000 (17:13 +0000)]
MFC r300947:

Staticize variables only used in rpcbind.c

This is some low hanging fruit necessary for making this WARNS?= 6 clean

git-svn-id: svn://svn.freebsd.org/base/stable/10@301648 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r300945:
ngie [Wed, 8 Jun 2016 17:11:42 +0000 (17:11 +0000)]
MFC r300945:

Remove unnecessary caller_uaddr != NULL test before calling free on it

git-svn-id: svn://svn.freebsd.org/base/stable/10@301646 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r300942:
ngie [Wed, 8 Jun 2016 17:09:47 +0000 (17:09 +0000)]
MFC r300942:

Remove a useless if (x != NULL) check before calling free on allocated_uaddr

git-svn-id: svn://svn.freebsd.org/base/stable/10@301644 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r300867,r300932,r300934,r300941,r300972,r300973:
ngie [Wed, 8 Jun 2016 15:41:39 +0000 (15:41 +0000)]
MFC r300867,r300932,r300934,r300941,r300972,r300973:

r300867:

Only expose `hint_uaddr` in the ND_DEBUG case

This fixes a -Wunused-but-set-variable warning with gcc

r300932:

Catch malloc(3) errors and socket(2) errors

- malloc failing will result in a delayed segfault
- socket failing will result in delayed failures with setsockopt

Exit in the event that either of these high-level conditions are met.

CID: 976288, 976321, 976858

r300934:

Plug leak with ifp by calling freeifaddrs after calling getifaddrs

Obtained from: NetBSD v1.18

r300941:

Don't leak res in network_init(..)

Call freeaddrinfo on it after it's been used

CID: 1225050

r300972 (by markj):

Fix rpcbind init after r300941.

- getaddrinfo() sets res = NULL on failure and freeaddrinfo() always
  dereferences its argument, so we should only free the address list after
  a successful call.
- Address a second potential leak caused by getaddrinfo(AF_INET6)
  overwriting the address list returned by getaddrinfo(AF_INET).

X-MFC-With: r300941

r300973:

Follow up to r300932

In the event MK_INET6 != no in userspace, but is disabled in the
kernel, or if there aren't any IPv6 addresses configured in userspace
(for lo0 and all physical interfaces), rpcbind would terminate
immediately instead of silently failing on

Skip over the IPv6 block to its respective cleanup with freeifaddrs if
creating the socket failed instead of terminating rpcbind immediately

git-svn-id: svn://svn.freebsd.org/base/stable/10@301636 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r300387,r300388,r300389:
ngie [Wed, 8 Jun 2016 14:18:47 +0000 (14:18 +0000)]
MFC r300387,r300388,r300389:

r300387:

getnetid(..): consistently fclose fd at the end of the function

This mutes a false positive with cppcheck, but also helps eliminate future
potential issues with this variable

r300388:

Call endnetconfig on nc_handle sooner to avoid leaking nc_handle if tmpnconf
was NULL

This would theoretically happen if the netconfig protocol family and protocol
semantics were never matched.

CID: 978179

r300389:

nis_rpcent: don't leak resultbuf from yp_first(..)/yp_next(..)

If the buffer couldn't be adequately resized to accomodate an additional "\n",
it would leak resultbuf by breaking from the loop early

CID: 1016702

git-svn-id: svn://svn.freebsd.org/base/stable/10@301629 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r300939:
ngie [Wed, 8 Jun 2016 14:07:43 +0000 (14:07 +0000)]
MFC r300939:

Use require.progs with bc instead of require.files with /usr/bin/bc

This will make things more flexible if the program path changes in the future,
and the test in and of itself doesn't call /usr/bin/bc -- it just calls bc

git-svn-id: svn://svn.freebsd.org/base/stable/10@301627 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r300938:
ngie [Wed, 8 Jun 2016 14:06:34 +0000 (14:06 +0000)]
MFC r300938:

Remove the sa(8) tests if MK_ACCT == no when "make delete-old" is run

sa(8) is conditionally installed based on MK_ACCT != no today

git-svn-id: svn://svn.freebsd.org/base/stable/10@301626 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r300937:
ngie [Wed, 8 Jun 2016 14:05:08 +0000 (14:05 +0000)]
MFC r300937:

Remove the etcupdate tests if MK_RCS == no when "make delete-old" is run

etcupdate is conditionally installed based on MK_RCS != no today

git-svn-id: svn://svn.freebsd.org/base/stable/10@301625 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r300936:
ngie [Wed, 8 Jun 2016 14:01:42 +0000 (14:01 +0000)]
MFC r300936:

Remove the calendar tests if MK_CALENDAR == no when "make delete-old"
is run

git-svn-id: svn://svn.freebsd.org/base/stable/10@301623 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r300620,r300621:
ngie [Wed, 8 Jun 2016 13:58:47 +0000 (13:58 +0000)]
MFC r300620,r300621:

r300620:

Use reallocf instead of malloc to fix leak with outbuf_pmap

The previous code overwrote outbuf_pmap's memory with malloc once per
loop iteration, which leaked its memory; use reallocf instead to ensure
that memory is properly free'd each loop iteration.

Add a outbuf_pmap = NULL in the failure case to avoid a double-free
at the bottom of the function.

CID: 1038776

r300621:

Remove redundant NULLing of outbuf_pmap

If reallocf ever failed, outbuf_pmap would already be NULL

git-svn-id: svn://svn.freebsd.org/base/stable/10@301622 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r300430:
ngie [Wed, 8 Jun 2016 13:49:59 +0000 (13:49 +0000)]
MFC r300430:

Wrap EXPAND(..) macro with a do-while(0) loop and put a single statement on each line

As a positive side-effect, this eliminates the double semicolons reported by Coverity:
the macro contained a trailing semicolon, in addition to the semicolon placed on
each line where EXPAND(..) was called.

CID: 1194269

git-svn-id: svn://svn.freebsd.org/base/stable/10@301619 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r300428:
ngie [Wed, 8 Jun 2016 13:44:01 +0000 (13:44 +0000)]
MFC r300428:

Fix humanized decoding of struct stat with respect to .st_mtim

st_mtim was being incorrectly described as "stime=", not "mtime=". This was
introduced with the original feature commit (r176471).

PR: 209699

git-svn-id: svn://svn.freebsd.org/base/stable/10@301617 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r299844,r300931:
ngie [Wed, 8 Jun 2016 13:40:07 +0000 (13:40 +0000)]
MFC r299844,r300931:

r299844:

Make hostid_save depend on hostid

r300931:

Make netif REQUIRE hostid

As noted in the PR, if etc/rc.d/zvol is removed, netif will be run before
hostid, and the MAC address generated for any bridge devices will be
non-deterministic. Make the MAC address generated be deterministic for
bridge devices by explicitly REQUIRE'ing hostid.

This fixes up the rest of the PR, inadvertently committed in r299844

PR: 195188

git-svn-id: svn://svn.freebsd.org/base/stable/10@301615 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f