]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
5 years agoMFC r341540:
hselasky [Wed, 12 Dec 2018 11:38:00 +0000 (11:38 +0000)]
MFC r341540:
libibverbs: Fix memory leak in ibv_read_sysfs_file().

Testing packetdrill using valgrind resulted in finding a memory leak in
ibv_read_sysfs_file(). The attached patch fixes it.

Submitted by: tuexen@
Sponsored by:   Mellanox Technologies

5 years agoMFC r341539:
hselasky [Wed, 12 Dec 2018 11:36:03 +0000 (11:36 +0000)]
MFC r341539:
krping: Fix for memory leak in error case.

Sponsored by:   Mellanox Technologies

5 years agoMFC r341538:
hselasky [Wed, 12 Dec 2018 11:35:00 +0000 (11:35 +0000)]
MFC r341538:
ipoib: Notify on modify QP failure only when relevant

Modify QP can fail and it can be acceptable, like when moving from RST to
ERR state, all the rest are not acceptable and a message to the log
should be printed.

The current code prints on all failures and many messages like:
"Failed to modify QP to ERROR state" appear, even when supported by the
state machine of the QP object.

Linux commit:
5dc78ad1904db597bdb4427f3ead437aae86f54c

MFC after:      1 week
Sponsored by:   Mellanox Technologies

5 years agoMFC r341537:
hselasky [Wed, 12 Dec 2018 11:33:14 +0000 (11:33 +0000)]
MFC r341537:
ipoib: increase the non-cm queue length

When a packet needs fragmentation, it might generate more than 3 fragments.
With the queue length 3, all fragments are generated faster than the
queue is drained, which effectively drops fourth and later fragments on
the floor.

Submitted by:   kib@
Sponsored by:   Mellanox Technologies

5 years agoMFC r341536:
hselasky [Wed, 12 Dec 2018 11:31:54 +0000 (11:31 +0000)]
MFC r341536:
ipoib: Don't do a light flush when MTU is unchanged.

When changing the MTU of ibX network interfaces, check that the MTU was really
changed before requesting an update of the multicast rules. Else we might go
into an infinite loop joining and leaving ibX multicast groups towards the
opensm master interface.

Sponsored by:   Mellanox Technologies

5 years agoMFC r341535:
hselasky [Wed, 12 Dec 2018 11:30:21 +0000 (11:30 +0000)]
MFC r341535:
ipoib: correct setting MTU from inside ipoib(4).

It is not enough to set ifnet->if_mtu to change the interface MTU.
System saves the MTU for route in the radix tree, and route cache keeps
the interface MTU as well. Since addition of the multicast group causes
recalculation of MTU, even bringing the interface up changes MTU from
4042 to 1500, which makes the system configuration inconsistent. Worse,
ip_output() prefers route MTU over interface MTU, so large packets are
not fragmented and dropped on floor.

Fix it for ipoib(4) using the same approach (or hack) as was applied
for it_tun/if_tap in r339012.  Thanks to bz@ for giving the hint.

Submitted by:   kib@
Sponsored by:   Mellanox Technologies

5 years agoMFC r339012:
hselasky [Wed, 12 Dec 2018 11:29:21 +0000 (11:29 +0000)]
MFC r339012:
For changing the MTU on tun/tap devices, it should not matter whether it
is done via using ifconfig, which uses a SIOCSIFMTU ioctl() command, or
doing it using a TUNSIFINFO/TAPSIFINFO ioctl() command.
Without this patch, for IPv6 the new MTU is not used when creating routes.
Especially, when initiating TCP connections after increasing the MTU,
the old MTU is still used to compute the MSS.
Thanks to ae@ and bz@ for helping to improve the patch.

Reviewed by: ae@, bz@
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D17180

5 years agoMFC r341534:
hselasky [Wed, 12 Dec 2018 11:16:32 +0000 (11:16 +0000)]
MFC r341534:
ibcore: Fix clearing of bound device interface.

Binding to a loopback device is not allowed. Make sure the destination
device address is global by clearing the bound device interface.
Only do this conditionally, else link local addresses won't work.

Sponsored by:   Mellanox Technologies

5 years agoMFC r341533:
hselasky [Wed, 12 Dec 2018 11:14:52 +0000 (11:14 +0000)]
MFC r341533:
ibcore: ip6_dev_find() needs to know the scope ID.

Else the wrong network device can be returned for link-local addresses.

Sponsored by:   Mellanox Technologies

5 years agoMFC r341532:
hselasky [Wed, 12 Dec 2018 11:01:23 +0000 (11:01 +0000)]
MFC r341532:
ibcore: Fix sleeping in atomic when RoCE is used

A couple of places in the CM do

    spin_lock_irq(&cm_id_priv->lock);
    ...
    if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))

However when the underlying transport is RoCE, this leads to a sleeping function
being called with the lock held - the callchain is

    cm_alloc_response_msg() ->
      ib_create_ah_from_wc() ->
        ib_init_ah_from_wc() ->
          rdma_addr_find_l2_eth_by_grh() ->
            rdma_resolve_ip()

and rdma_resolve_ip() starts out by doing

    req = kzalloc(sizeof *req, GFP_KERNEL);

not to mention rdma_addr_find_l2_eth_by_grh() doing

    wait_for_completion(&ctx.comp);

to wait for the task that rdma_resolve_ip() queues up.

Fix this by moving the AH creation out of the lock.

Linux commit:
c76161181193985087cd716fdf69b5cb6cf9ee85

Sponsored by:   Mellanox Technologies

5 years agoMFC r341531:
hselasky [Wed, 12 Dec 2018 10:58:49 +0000 (10:58 +0000)]
MFC r341531:
ibcore: Add missing unref of netdevice.

Sponsored by:   Mellanox Technologies

5 years agoMFC r341530:
hselasky [Wed, 12 Dec 2018 10:56:53 +0000 (10:56 +0000)]
MFC r341530:
ibcore: Fix loopback with rdma-cm.

Trying to validate loopback fails because rtalloc1() resolves system
local addresses to the loopback network interface, lo0. Fix this by
explicitly checking for loopback during validation of the source
and destination network address. If the source address belongs to
a local network interface and is equal to the destination address,
there is no need to run the destination address through rtalloc1().

Sponsored by:   Mellanox Technologies

5 years agoMFC r341529:
hselasky [Wed, 12 Dec 2018 10:54:41 +0000 (10:54 +0000)]
MFC r341529:
ibcore: Make sure all VNETs are scanned for VLAN interfaces.

The master network interface and the VLANs may reside in different VNETs.
Make sure that all VNETs are searched when scanning for GID entries.

Submitted by:   netapp
Sponsored by:   Mellanox Technologies

5 years agoMFC r341528:
hselasky [Wed, 12 Dec 2018 10:34:10 +0000 (10:34 +0000)]
MFC r341528:
ibcore: Always check return value from ib_init_ah_from_wc().

This prevents code from accepting RoCEv1 connections when
only ROCEv2 is enabled and vice versa.

Linux commit:
0c4386ec77cfcd0ccbdbe8c2e67dd3a49b2a4c7f

Sponsored by:   Mellanox Technologies

5 years agoMFC r341527:
hselasky [Wed, 12 Dec 2018 10:31:49 +0000 (10:31 +0000)]
MFC r341527:
ibcore: Add missing check for failure.

Sponsored by:   Mellanox Technologies

5 years agoMFC r341526:
hselasky [Wed, 12 Dec 2018 10:29:48 +0000 (10:29 +0000)]
MFC r341526:
ibcore: Fix an array index check

The array ib_mad_mgmt_class_table.method_table has MAX_MGMT_CLASS
(80) elements. Hence compare the array index with that value instead
of with IB_MGMT_MAX_METHODS (128). This patch avoids that Coverity
reports the following:

Overrunning array class->method_table of 80 8-byte elements at element index 127
(byte offset 1016) using index convert_mgmt_class(mad_hdr->mgmt_class)
(which evaluates to 127).

Linux commit:
2fe2f378dd45847d2643638c07a7658822087836

Sponsored by:   Mellanox Technologies

5 years agoMFC r341525:
hselasky [Wed, 12 Dec 2018 10:26:49 +0000 (10:26 +0000)]
MFC r341525:
ibcore: Check ib_find_pkey() return value.

Linux commit:
d3a2418ee36a59bc02e9d454723f3175dcf4bfd9

Sponsored by:   Mellanox Technologies

5 years agoMFC r341524:
hselasky [Wed, 12 Dec 2018 10:24:43 +0000 (10:24 +0000)]
MFC r341524:
ibcore: Add support for IB_SPEED_HDR in sysfs rate printout.

Sponsored by:   Mellanox Technologies

5 years agoMFC r341523:
hselasky [Wed, 12 Dec 2018 10:22:10 +0000 (10:22 +0000)]
MFC r341523:
ibcore: Don't access invalid port.

The port number in the listen_id_priv has been observed to be zero which
means no port has been selected. The current code lacks a check for invalid
port number.

Sponsored by:   Mellanox Technologies

5 years agoMFC r341522:
hselasky [Wed, 12 Dec 2018 10:19:47 +0000 (10:19 +0000)]
MFC r341522:
ibcore: Discard unused error codes.

Sponsored by:   Mellanox Technologies

5 years agoMFC r341521:
hselasky [Wed, 12 Dec 2018 10:17:36 +0000 (10:17 +0000)]
MFC r341521:
ibcore: Make sure GID index variable gets initialized.

Sponsored by:   Mellanox Technologies

5 years agoMFC r341520:
hselasky [Wed, 12 Dec 2018 10:14:52 +0000 (10:14 +0000)]
MFC r341520:
linuxkpi: Really check if PCI is offline

Currently we always return false if for PCI offline query.
Try to read PCI config, if the return value if 0xffff probably the
PCI is offline.

Sponsored by:   Mellanox Technologies

5 years agoMFC r341519:
hselasky [Wed, 12 Dec 2018 10:12:14 +0000 (10:12 +0000)]
MFC r341519:
linuxkpi: properly implement netif_carrier_ok().

Submitted by:   kib@
Sponsored by:   Mellanox Technologies

5 years agoMFC r341518:
hselasky [Wed, 12 Dec 2018 10:09:23 +0000 (10:09 +0000)]
MFC r341518:
linuxkpi: Fix for use-after-free when tearing down character devices.

Make sure we hold a reference on the character device for every opened file
to prevent the character device to be freed prematurely.

Sponsored by:   Mellanox Technologies

5 years agoMFC r341591:
hselasky [Wed, 12 Dec 2018 10:05:41 +0000 (10:05 +0000)]
MFC r341591:
Fix build of the atomic long LinuxKPI header file on some platforms.

Sponsored by: Mellanox Technologies

5 years agoMFC r341517 and r341592:
hselasky [Wed, 12 Dec 2018 10:01:40 +0000 (10:01 +0000)]
MFC r341517 and r341592:
linuxkpi: implement idr_is_empty() and ida_is_empty().

Submitted by:   kib@
Sponsored by:   Mellanox Technologies

5 years agoMFC r341469:
ae [Wed, 12 Dec 2018 08:59:06 +0000 (08:59 +0000)]
MFC r341469:
  Add assertion to check that named object has correct type.

5 years agoMFC: r339289: Resolve a hang in ZFS during vnode reclaimation
allanjude [Tue, 11 Dec 2018 19:34:25 +0000 (19:34 +0000)]
MFC: r339289: Resolve a hang in ZFS during vnode reclaimation

  This is caused by a deadlock between zil_commit() and zfs_zget()
  Add a way for zfs_zget() to break out of the retry loop in the common case

PR: 229614, 231117
Reported by: grembo, jhb, Andreas Sommer, others
Relnotes: yes
Sponsored by: Klara Systems

5 years agoAs part of the general cleanup of the ipfilter code, special cases
cy [Tue, 11 Dec 2018 01:49:06 +0000 (01:49 +0000)]
As part of the general cleanup of the ipfilter code, special cases
are committed separately to document fixing them separately from
the general cleanup. In this case we don't want to hide the utter
brokenness of what is being fixed.

Clean up a discombobulated block of #if's, with one block unreachable.
ip_fil.c is used in ipftest which is used to dry-run test ipfilter
rules in userspace without loading them in the kernel. The call to
(*ifp->if_output) matches that in the FreeBSD kernel.

Further testing and work will be required to make ipftest fully
functional.

5 years agoMFC r340322-r340324,r340327: periodic/etc/weekly/340.noid
eugen [Mon, 10 Dec 2018 14:24:41 +0000 (14:24 +0000)]
MFC r340322-r340324,r340327: periodic/etc/weekly/340.noid

Prevent periodic/etc/weekly/340.noid from descending into root directories
of jails. Jails have their own user/group databases and this script
can produce multiple false warnings, not to mention significant extra
load in case of large jailed subtrees. Leave this check for jailed
invocations of the same script.

5 years agoMFC r340321: Move definition of $jail_conf variable to /etc/defaults/rc.conf
eugen [Mon, 10 Dec 2018 14:12:04 +0000 (14:12 +0000)]
MFC r340321: Move definition of $jail_conf variable to /etc/defaults/rc.conf
from jail startup script so it can be successfully queried
with the command "sysrc jail_conf".

5 years agoMFC r340319: jail(8): introduce new command option -e to exhibit
eugen [Mon, 10 Dec 2018 13:47:05 +0000 (13:47 +0000)]
MFC r340319: jail(8): introduce new command option -e to exhibit
a list of configured non-wildcard jails with their parameters,
no matter running or not.

The option -e takes separator argument that is used
to separate printed parameters. It will be used with following
additions to system periodic scripts to differentiate parts
of directory tree belonging jails as opposed to host's.

5 years agoMFC r341448:
kib [Mon, 10 Dec 2018 01:39:40 +0000 (01:39 +0000)]
MFC r341448:
Print type designator 'D' for the KF_TYPE_DEV files.

5 years agoMFC r341447:
kib [Mon, 10 Dec 2018 01:38:48 +0000 (01:38 +0000)]
MFC r341447:
Improve procstat reporting for the linux cdev file descriptors.

5 years agoMFC r341439:
kib [Mon, 10 Dec 2018 00:59:10 +0000 (00:59 +0000)]
MFC r341439:
Provide naive but self-contained implementations of memset(3) and
bzero(3) for rtld.

5 years agoMFC r341441:
kib [Mon, 10 Dec 2018 00:57:56 +0000 (00:57 +0000)]
MFC r341441:
Some fixes for LD_BIND_NOW + ifuncs.

5 years agoMFC r340046, r340050
araujo [Sun, 9 Dec 2018 06:42:06 +0000 (06:42 +0000)]
MFC r340046, r340050

r340046:
Add support ps/2 scancodes for NumLock, ScrollLock and numerical keypad
keys.

PR: 213835
Submitted by: Vasily Postnicov <ivan.zhmudo@gmail.com>
Relnotes: Yes
Sponsored by: iXsystems Inc.

r340050:
Remove printf for debug purpose forgotten on r340046.

Reported by: Dmitry Luhtionov <dmitryluhtionov@gmail.com>

5 years agoMFC r316939:
avos [Sun, 9 Dec 2018 05:35:22 +0000 (05:35 +0000)]
MFC r316939:
[lib80211] fix a missing cleanup path.

PR: lib/218655
Reported by: <valentin.vergez@stormshield.eu>

5 years agoMFC: r340745, fix CU: output of the --debug-dump=decodedline.
sobomax [Sun, 9 Dec 2018 03:07:45 +0000 (03:07 +0000)]
MFC: r340745, fix CU: output of the --debug-dump=decodedline.

Differential Revision: https://reviews.freebsd.org/D18290

5 years agoMFC r341397:
kib [Sun, 9 Dec 2018 00:42:56 +0000 (00:42 +0000)]
MFC r341397:
Correct accuracy of the barrier writes accounting.

5 years agoMFC r341377, r341388 (fixup):
cy [Sat, 8 Dec 2018 17:50:00 +0000 (17:50 +0000)]
MFC r341377, r341388 (fixup):

Restore handling of PMTU discovery, removed through an unifdef(1)
following the MFV of r254219 into r255332. In addition the 'FreeBSD'
macro was never defined in ipfilter 5.1.2 thus it never would have
been enabled in the first place.

This work is prompted by a general cleanup of the IP Filter code
prompted by working to resolve a PR. More to follow.

5 years agoMFC r341384:
cy [Sat, 8 Dec 2018 17:28:52 +0000 (17:28 +0000)]
MFC r341384:

Remove IFF_DRVRLOCK as it is used in IRIX only (and we all know IRIX
is dead). This includes collaterally removing code shared by HP/UX,
SGI, and Linux, where IP Filter will in all likelihood for various
reasons never run again.

5 years agoMFC r341375:
kib [Sat, 8 Dec 2018 00:48:10 +0000 (00:48 +0000)]
MFC r341375:
Allow to create swap zone larger than v_page_count / 2.

5 years agoMFC r341374:
kib [Sat, 8 Dec 2018 00:47:22 +0000 (00:47 +0000)]
MFC r341374:
Correct the tunable name in the message.

PR: 231577

5 years agoMFC r340245: ping(8): improve diagnostics in case of wrong arguments.
eugen [Sat, 8 Dec 2018 00:33:20 +0000 (00:33 +0000)]
MFC r340245: ping(8): improve diagnostics in case of wrong arguments.

  For example, in case of super-user:
  $ sudo ping -s -64 127.0.0.1
  PING 127.0.0.1 (127.0.0.1): -64 data bytes
  ping: sendto: Invalid argument

  For unprivileged user:
  $ ping -s -64 127.0.0.1
  ping: packet size too large: 18446744073709551552 > 56: Operation not permitted

  Fix this by switching from strtoul() to strtol() for integer arguments
  and adding explicit checks for negative values.

5 years agoMFC r341280:
cy [Fri, 7 Dec 2018 21:42:41 +0000 (21:42 +0000)]
MFC r341280:

Clean up a rather useless conditional structure member definition.

5 years agoMFC r341008:
ae [Fri, 7 Dec 2018 09:39:37 +0000 (09:39 +0000)]
MFC r341008:
  Fix possible panic during ifnet detach in rtsock.

  The panic can happen, when some application does dump of routing table
  using sysctl interface. To prevent this, set IFF_DYING flag in
  if_detach_internal() function, when ifnet under lock is removed from
  the chain. In sysctl_rtsock() take IFNET_RLOCK_NOSLEEP() to prevent
  ifnet detach during routes enumeration. In case, if some interface was
  detached in the time before we take the lock, add the check, that ifnet
  is not DYING. This prevents access to memory that could be freed after
  ifnet is unlinked.

  Differential Revision: https://reviews.freebsd.org/D18338

5 years agoMFC r340863:
kib [Fri, 7 Dec 2018 00:39:34 +0000 (00:39 +0000)]
MFC r340863:
Generalize ELF parse_notes().

5 years agoMFC r340862:
kib [Fri, 7 Dec 2018 00:38:21 +0000 (00:38 +0000)]
MFC r340862:
Trivial reduction of the code duplication, reuse the return FALSE code.

5 years agoFix kenv handling in stable/11 following r337333
kevans [Thu, 6 Dec 2018 19:18:51 +0000 (19:18 +0000)]
Fix kenv handling in stable/11 following r337333

The aforementioned commit merged revised static_env/static_hint handling to
allow static_env and loader env to coexist with the variable
loader_env.disabled=0. init_static_kenv had been rewritten slighly in an
attempt to maintain historical behavior: the static environment and loader
environment are mutually exclusive, unless the latter disables the former.

The rewritten version botched this by only setting up the loader environment
if the static environment was empty or if the loader environment was
specifically enabled. It was never given a chance to disable the static
environment, so the default behavior was broken unless the loader
environment was specifically enabled by the static environment.

Rewrite this again to do the right thing:
- Setup the static environment and check loader_env.disabled; if it's
  explicitly enabled, we're done.
- Check static_{env,hints}.disabled and "empty out" the respective
  environments as needed
- Finally, check: if the static environment is not empty and we've not
  explicitly re-enabled the static environment with loader_env.disabled=0,
  we tear the loader environment (which was setup to 'keep things simple')
  down again.

Future commits to head (and subsequently MFC'd) will likely zero these
environments out if they're disabled since this normally happens when
they're merged into the dynamic environment.

This is a direct commit to stable/11 because this particular bug does not
apply to head.

Fixes: r337333
Reported by: bde

5 years agoMFC r339827:
yuripv [Thu, 6 Dec 2018 11:52:07 +0000 (11:52 +0000)]
MFC r339827:
localedef: define characters in "space" class also as "print", except
for the known conflicts ("control" characters can't be "print"able).
POSIX doesn't explicitly forbid this, and actually includes <space>
character in "print".

PR: 225692
Reviewed by: bapt, cem (previous version), pfg (previous version)
Differential Revision: https://reviews.freebsd.org/D17467

5 years agoMFC r339311, r339313:
yuripv [Thu, 6 Dec 2018 11:49:52 +0000 (11:49 +0000)]
MFC r339311, r339313:
Restore some of the ctype definitions reported in the PR from pre-CLDR
data, namely 0xE000-0xF8FF private use area, and 0xFF00-0xFFF half- and
fullwidth punctuation.

While here, update tools/tools/locale/README based on my experience
rebuilding the locale data.

PR: 225692
Reviewed by: bapt, cem (previous version)
Differential Revision: https://reviews.freebsd.org/D17471

5 years agoMFC r340111:
bapt [Thu, 6 Dec 2018 08:27:56 +0000 (08:27 +0000)]
MFC r340111:

nfsd: Factorize code

Factorize code by using struct sockaddr_storage to handle both ipv6 and ipv4

Discussed with: rmacklem
Reviewed by: manu
Sponsored by: Gandi.net
Differential Revision: https://reviews.freebsd.org/D13223

5 years agoMFC r341265:
cy [Thu, 6 Dec 2018 04:28:39 +0000 (04:28 +0000)]
MFC r341265:

Remove an old comment/code and replace with a comment that
directly references a NetBSD commit.

5 years agonetmap: fix module Makefile
vmaffione [Wed, 5 Dec 2018 15:05:26 +0000 (15:05 +0000)]
netmap: fix module Makefile

Reported by: mav

5 years agoMFC r339042:
tuexen [Tue, 4 Dec 2018 22:52:15 +0000 (22:52 +0000)]
MFC r339042:

Mitigate providing a timing signal if the COOKIE or AUTH
validation fails.
Thanks to jmg@ for reporting the issue, which was discussed in
https://admbugs.freebsd.org/show_bug.cgi?id=878

5 years agoMFC r341335:
tuexen [Tue, 4 Dec 2018 22:25:24 +0000 (22:25 +0000)]
MFC r341335:

Limit option_len for the TCP_CCALGOOPT.

Limiting the length to 2048 bytes seems to be acceptable, since
the values used right now are using 8 bytes.
This issue was found by using syzkaller.

Reviewed by: glebius, bz, rrs
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D18366

5 years agoDocument SA-18:14.
gjb [Tue, 4 Dec 2018 19:55:39 +0000 (19:55 +0000)]
Document SA-18:14.

Sponsored by: The FreeBSD Foundation

5 years agoMFC r341442, r341443:
markj [Tue, 4 Dec 2018 19:07:10 +0000 (19:07 +0000)]
MFC r341442, r341443:
Plug memory disclosures via ptrace(2).

5 years agoMFC r341484
gordon [Tue, 4 Dec 2018 18:32:50 +0000 (18:32 +0000)]
MFC r341484

Always treat firmware request and response sizes as unsigned.

This fixes an incomplete bounds check on the guest-supplied request
size where a very large request size could be interpreted as a negative
value and not be caught by the bounds check.

Submitted by: jhb
Reported by:  Reno Robert
Approved by:  so
Security:     FreeBSD-SA-18:14.bhyve
Security:     CVE-2018-17160

5 years agoMFC r341430
vmaffione [Tue, 4 Dec 2018 17:53:56 +0000 (17:53 +0000)]
MFC r341430

netmap(4): improve man page

Reviewed by:    bcr
Differential Revision:  https://reviews.freebsd.org/D18057

5 years agoMFC r341145
vmaffione [Tue, 4 Dec 2018 17:49:44 +0000 (17:49 +0000)]
MFC r341145

cxgbe: revert r309725

After the fix contained in r341144, cxgbe does not need anymore
to set the IFCAP_NETMAP flag manually.

Reviewed by:    np
Approved by:    gnn (mentor)
Differential Revision:  https://reviews.freebsd.org/D17987

5 years agoMFC r341144
vmaffione [Tue, 4 Dec 2018 17:47:43 +0000 (17:47 +0000)]
MFC r341144

netmap: set IFCAP_NETMAP in if_capabilities

Revision r307394 removed (by mistake) the code that sets IFCAP_NETMAP
in if_capabilities on netmap_attach. This patch reverts this change.

Reviewed by:    np
Approved by:    gnn (mentor)
Differential Revision:  https://reviews.freebsd.org/D17987

5 years agoMFC r340475
vmaffione [Tue, 4 Dec 2018 17:46:06 +0000 (17:46 +0000)]
MFC r340475

ifnet(9): Add description of IFCAP_NETMAP

Describe IFCAP_NETMAP adding a cross reference to netmap(4).

Reviewed by:    bcr, 0mp
Approved by:    gnn (mentor)
Differential Revision:  https://reviews.freebsd.org/D17988

5 years agoMFC r340436
vmaffione [Tue, 4 Dec 2018 17:44:12 +0000 (17:44 +0000)]
MFC r340436

vtnet: fix netmap support

netmap(4) support for vtnet(4) was incomplete and had multiple bugs.
This commit fixes those bugs to bring netmap on vtnet in a functional state.

Changelist:
  - handle errors returned by virtqueue_enqueue() properly (they were
    previously ignored)
  - make sure netmap XOR rest of the kernel access each virtqueue.
  - compute the number of netmap slots for TX and RX separately, according to
    whether indirect descriptors are used or not for a given virtqueue.
  - make sure sglist are freed according to their type (mbufs or netmap
    buffers)
  - add support for mulitiqueue and netmap host (aka sw) rings.
  - intercept VQ interrupts directly instead of intercepting them in txq_eof
    and rxq_eof. This simplifies the code and makes it easier to make sure
    taskqueues are not running for a VQ while it is in netmap mode.
  - implement vntet_netmap_config() to cope with changes in the number of queues.

Reviewed by:    bryanv
Approved by:    gnn (mentor)
Sponsored by:   Sunny Valley Networks
Differential Revision:  https://reviews.freebsd.org/D17916

5 years agoMFC r339639
vmaffione [Tue, 4 Dec 2018 17:40:56 +0000 (17:40 +0000)]
MFC r339639

netmap: align codebase to the current upstream (sha 8374e1a7e6941)

Changelist:
    - Move large parts of VALE code to a new file and header netmap_bdg.[ch].
      This is useful to reuse the code within upcoming projects.
    - Improvements and bug fixes to pipes and monitors.
    - Introduce nm_os_onattach(), nm_os_onenter() and nm_os_onexit() to
      handle differences between FreeBSD and Linux.
    - Introduce some new helper functions to handle more host rings and fake
      rings (netmap_all_rings(), netmap_real_rings(), ...)
    - Added new sysctl to enable/disable hw checksum in emulated netmap mode.
    - nm_inject: add support for NS_MOREFRAG

Approved by:    gnn (mentor)
Differential Revision:  https://reviews.freebsd.org/D17364

5 years agoMFC r341094:
kib [Tue, 4 Dec 2018 16:53:28 +0000 (16:53 +0000)]
MFC r341094:
Improve sigonstack().

5 years agoMFC r327860: ANSIfy function definitions in sys/vm/
emaste [Tue, 4 Dec 2018 15:04:48 +0000 (15:04 +0000)]
MFC r327860: ANSIfy function definitions in sys/vm/

5 years agoMFC r341073:
ae [Tue, 4 Dec 2018 09:18:28 +0000 (09:18 +0000)]
MFC r341073:
  Do not limit the mbuf queue length for keepalive packets.

  It was unlimited before overhaul, and one user reported that this limit
  can be reached easily.

  PR: 233562

5 years agoMFC r340135: Make ng_pptpgre(8) netgraph node be able to restore order
eugen [Tue, 4 Dec 2018 07:48:43 +0000 (07:48 +0000)]
MFC r340135: Make ng_pptpgre(8) netgraph node be able to restore order
for packets reordered in transit instead of dropping them altogether.
It uses sequence numbers of PPtPGRE packets.

A set of new sysctl(8) added to control this ability or disable it:

net.graph.pptpgre.reorder_max (1) defines maximum length of node's
private reorder queue used to keep data waiting for late packets.
Zero value disables reordering. Default value 1 allows the node to restore
the order for two packets swapped in transit. Greater values allow the node
to deliver packets being late after more packets in sequence
at cost of increased kernel memory usage.

net.graph.pptpgre.reorder_timeout (1) defines time value in miliseconds
used to wait for late packets. It may be useful to increase this
if reordering spot is distant.

5 years agoMFC r340110: ipfw(8): clarify layer2 processing abilities
eugen [Tue, 4 Dec 2018 07:34:47 +0000 (07:34 +0000)]
MFC r340110: ipfw(8): clarify layer2 processing abilities

Make it clear that ipfw action set for layer2 frames is a bit limited.

PR: 59835
Reviewed by: yuripv
Differential Revision: https://reviews.freebsd.org/D17719

5 years agoMFC r340325
vmaffione [Tue, 4 Dec 2018 07:30:02 +0000 (07:30 +0000)]
MFC r340325

netmap: pkt-gen: several updates from upstream

Various improvements to the netmap pkt-gen program:

 - indentation fixes
 - support for IPV6
 - fixes to checksum computation
 - support for NS_MOREFRAG
 - rate limiting in ping mode

Reviewed by:    bcr, 0mp
Approved by:    gnn (mentor)
Differential Revision:  https://reviews.freebsd.org/D17698

5 years agoDocument SA-18:13, EN-18:13, EN-18:14, EN-18:15.
gjb [Mon, 3 Dec 2018 19:02:14 +0000 (19:02 +0000)]
Document SA-18:13, EN-18:13, EN-18:14, EN-18:15.

Sponsored by: The FreeBSD Foundation

5 years agoMFC r340279
vmaffione [Mon, 3 Dec 2018 17:51:22 +0000 (17:51 +0000)]
MFC r340279

netmap: add load balancer program

Add the lb program, which is able to load-balance input traffic
received from a netmap port over M groups, with N netmap pipes in
each group. Each received packet is forwarded to one of the pipes
chosen from each group (using an L3/L4 connection-consistent hash function).
This also adds a man page for lb and some cross-references in related
man pages.

Reviewed by:    bcr, 0mp
Approved by:    gnn (mentor)
Differential Revision:  https://reviews.freebsd.org/D17735

5 years agoMFC r339685
vmaffione [Mon, 3 Dec 2018 17:46:53 +0000 (17:46 +0000)]
MFC r339685

netmap: add man page for the vale-ctl program

Added man page for vale-ctl program.
Small fixes to vale-ctl, including the support for -m option
(to specify the netmap memory allocator id).

Reviewed by:    0mp
Approved by:    gnn (mentor)
Differential Revision:  https://reviews.freebsd.org/D17683

5 years agoMFC r339659
vmaffione [Mon, 3 Dec 2018 17:40:54 +0000 (17:40 +0000)]
MFC r339659

netmap: add man page for the bridge program

Added bridge(8).
Also, minor fixes to the netmap "bridge" application:
 - indentation fixes and code cleanup
 - better usage description
 - better processing of netmap flags

Reviewed by:    0mp
Approved by:    gnn (mentor)
Differential Revision:  https://reviews.freebsd.org/D17664

5 years agoMFC r340095: Remove apparently unused 0-byte files that cause grief on Windows
emaste [Mon, 3 Dec 2018 02:33:53 +0000 (02:33 +0000)]
MFC r340095: Remove apparently unused 0-byte files that cause grief on Windows

r235274 added a sort regression test (it operates by comparing output
against GNU sort).  The commit included a number of 0-byte files, one
of which ends in a trailing . which reportedly breaks svn/git checkouts
on Windows.

It appears these were added accidentally, so just remove them.

PR: 232479

5 years agoMFC r341247:
markj [Sun, 2 Dec 2018 18:08:27 +0000 (18:08 +0000)]
MFC r341247:
Update the free page count when blacklisting pages.

PR: 231296

5 years agoMFC r340922:
kib [Sun, 2 Dec 2018 12:51:49 +0000 (12:51 +0000)]
MFC r340922:
Avoid unneeded check in vmspace_alloc().

5 years agoMFC r338317:
mmel [Sun, 2 Dec 2018 07:45:22 +0000 (07:45 +0000)]
MFC r338317:

  Fix wrong offset calculation for R_ARM_TLS_TPOFF32 relocations.  TLS_TCB_SIZE
  is already accounted in defobj-> tlsoffset so all these symbols were
  incorrectly relocated by +8.

5 years agoMFC r340867:
cy [Sat, 1 Dec 2018 18:23:41 +0000 (18:23 +0000)]
MFC r340867:

FreeBSD 7 has been history for many moons. Remove some dead code.

5 years agoMFC r340868:
cy [Sat, 1 Dec 2018 18:17:51 +0000 (18:17 +0000)]
MFC r340868:

An OSF/1 ifdef makes absolutley no sense in a FreeBSD specific source
file.

5 years agoMFC r340909:
cy [Sat, 1 Dec 2018 18:09:17 +0000 (18:09 +0000)]
MFC r340909:

Combine two lines into one following unifdef for r255332.

5 years agoMFC r339548
vmaffione [Sat, 1 Dec 2018 12:08:16 +0000 (12:08 +0000)]
MFC r339548

man: fix vale(4) port naming

The current documentation describing the syntax of a VALE port is wrong.
This patch fixes it to make it consistent.

Differential Revision: https://reviews.freebsd.org/D17411

5 years agoMFC r339502
oshogbo [Fri, 30 Nov 2018 19:58:55 +0000 (19:58 +0000)]
MFC r339502
  Add link to the setproctitle_fast function.

5 years agoMFC r340765
arybchik [Fri, 30 Nov 2018 09:58:11 +0000 (09:58 +0000)]
MFC r340765

sfxge(4): cleanup: move into right place

Due to incorrect merge the piece of code was put in incorrect
place and diverge from libefx in other locations.

Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18024

5 years agoThis is a direct commit to the stable/11 branch. This would have been
cy [Fri, 30 Nov 2018 06:45:53 +0000 (06:45 +0000)]
This is a direct commit to the stable/11 branch. This would have been
MFC r340754 except that etc/rc.d has been moved in HEAD which would
have resulted in a tree conflict if merged.

Allow forced start of ipmon in special cases where testing is desired
(or other special cases) and when ipfilter is disabled in rc.conf but
started by other means.

5 years agoMFC r337812,r337814,r337820,r341068:
dab [Fri, 30 Nov 2018 02:06:30 +0000 (02:06 +0000)]
MFC r337812,r337814,r337820,r341068:

Fix several memory leaks (r337812 & r337814).

The libkqueue tests have several places that leak memory by using an
idiom like:

  puts(kevent_to_str(kevp));

Rework to save the pointer returned from kevent_to_str() and then
free() it after it has been used.

r337812 also fixed a bug in the netmap kevent code. The inclusion of
that fix was an oversight that I didn't notice until this
MFC. Reference the code review and PR here in the MFC for
completeness.

r337820 & r341068 were white-space only changes as a follow-up to
r337812 & r337814:

After r337820, which "corrected" some spaces-instead-of-tab whitespace
issues in the libkqueue tests, jmg@ pointed out that these files were
originally space-based, not tab-spaced, and so the correction should
have been to get rid of the tabs that had been introduced in previous
changes, not the spaces. This change does that. This is a whitespace
only change; no functional change is intended.

PR:  206053
Differential Revision:    https://reviews.freebsd.org/D16531
Sponsored by: Dell EMC Isilon

5 years agoMFC r340483 (by jtl):
markj [Thu, 29 Nov 2018 20:38:23 +0000 (20:38 +0000)]
MFC r340483 (by jtl):
Add some additional length checks to the IPv4 fragmentation code.

5 years agoMFC r340968:
markj [Thu, 29 Nov 2018 15:56:46 +0000 (15:56 +0000)]
MFC r340968:
Plug routing sysctl leaks.

5 years agoMFC r340976:
yuripv [Thu, 29 Nov 2018 15:07:59 +0000 (15:07 +0000)]
MFC r340976:
vi: fix UTF-8 detection.

PR: 202290
Submitted by: lampa@fit.vutbr.cz
Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D17950

5 years agoMFC r340978-340979: ipfw.8: new section to EXAMPLES: SELECTIVE MIRRORING
eugen [Thu, 29 Nov 2018 01:28:13 +0000 (01:28 +0000)]
MFC r340978-340979: ipfw.8: new section to EXAMPLES: SELECTIVE MIRRORING

5 years agoMFC r340442
sef [Thu, 29 Nov 2018 01:05:21 +0000 (01:05 +0000)]
MFC r340442

mountd has no way to configure the listen queue depth; rather than add a new
option, we pass -1 down to listen, which causes it to use the
kern.ipc.soacceptqueue sysctl.

Approved by: mav
Sponsored by: iXsystems Inc

5 years agoMFC r340983:
gjb [Thu, 29 Nov 2018 00:28:08 +0000 (00:28 +0000)]
MFC r340983:
 Fix NTP query on GCE due to unresolved hostname.

PR: 232456
Submitted by: Lucas Kanashiro
Sponsored by: The FreeBSD Foundation

5 years agoMFC r340995
vangyzen [Wed, 28 Nov 2018 21:20:51 +0000 (21:20 +0000)]
MFC r340995

Prevent kernel stack disclosure in signal delivery

On arm64 and riscv platforms, sendsig() failed to zero the signal
frame before copying it out to userspace.  Zero it.

On arm, I believe all the contents of the frame were initialized,
so there was no disclosure.  However, explicitly zero the whole frame
because that fact could inadvertently change in the future,
it's more clear to the reader, and I could be wrong in the first place.

Security: similar to FreeBSD-EN-18:12.mem and CVE-2018-17155
Sponsored by: Dell EMC Isilon

5 years agoMFC r340994
vangyzen [Wed, 28 Nov 2018 21:19:58 +0000 (21:19 +0000)]
MFC r340994

Prevent kernel stack disclosure in getcontext/swapcontext

Expand r338982 to cover freebsd32 interfaces on amd64, mips, and powerpc.

Security: FreeBSD-EN-18:12.mem
Security: CVE-2018-17155
Sponsored by: Dell EMC Isilon

5 years agoMFC r340730, r340731:
markj [Wed, 28 Nov 2018 17:00:18 +0000 (17:00 +0000)]
MFC r340730, r340731:
Add taskqueue_quiesce(9) and use it to implement taskq_wait().

PR: 227784

5 years agoMFC r340409
vangyzen [Tue, 27 Nov 2018 22:33:58 +0000 (22:33 +0000)]
MFC r340409

Make no assertions about lock state when the scheduler is stopped.

Change the assert paths in rm, rw, and sx locks to match the lock
and unlock paths.  I did this for mutexes in r306346.

Reported by: Travis Lane <tlane@isilon.com>
Sponsored by: Dell EMC Isilon

5 years agoMFC r340257
vangyzen [Tue, 27 Nov 2018 19:40:18 +0000 (19:40 +0000)]
MFC r340257

in6_ifattach_linklocal: handle immediate removal of the new LLA

If another thread immediately removes the link-local address
added by in6_update_ifa(), in6ifa_ifpforlinklocal() can return NULL,
so the following assertion (or dereference) is wrong.
Remove the assertion, and handle NULL somewhat better than panicking.
This matches all of the other callers of in6_update_ifa().

PR: 219250
Reviewed by: bz, dab (both an earlier version)
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D17898

5 years agoMFC r340898:
markj [Tue, 27 Nov 2018 17:10:00 +0000 (17:10 +0000)]
MFC r340898:
Ensure that knotes do not get registered when KQ_CLOSING is set.

PR: 228858