]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
6 years agoMFC r328081:
tuexen [Sat, 7 Apr 2018 21:09:51 +0000 (21:09 +0000)]
MFC r328081:

Add missing assignment to make sure non-first cmsgs are handled as such.

6 years agoMFC r328059:
tuexen [Sat, 7 Apr 2018 21:08:44 +0000 (21:08 +0000)]
MFC r328059:

Improve the printing of cmgs when the length is 0. Fix error handling.

6 years agoMFC r328058:
tuexen [Sat, 7 Apr 2018 21:07:47 +0000 (21:07 +0000)]
MFC r328058:

Using %p already prints "0x", so don't do it explicitly.

6 years agoMFC r328033:
tuexen [Sat, 7 Apr 2018 21:06:39 +0000 (21:06 +0000)]
MFC r328033:

Bump date, which I missed in r328014. Thanks to jhb@ for reporting.

6 years agoMFC r328015:
tuexen [Sat, 7 Apr 2018 21:05:39 +0000 (21:05 +0000)]
MFC r328015:

Decode msghdr argument of sendmsg() and recvmsg().

6 years agoMFC r328014:
tuexen [Sat, 7 Apr 2018 21:04:43 +0000 (21:04 +0000)]
MFC r328014:

Add support for decoding the nxt_flags, rcv_flags, and snd_flags of
SCTP level cmsgs.

6 years agoMFC r327995:
tuexen [Sat, 7 Apr 2018 21:03:46 +0000 (21:03 +0000)]
MFC r327995:

Add support for decoding the type of a cmsg.

6 years agoMFC r327994:
tuexen [Sat, 7 Apr 2018 21:02:42 +0000 (21:02 +0000)]
MFC r327994:

Simplify table generation.

6 years agoMFC r327967:
tuexen [Sat, 7 Apr 2018 21:01:43 +0000 (21:01 +0000)]
MFC r327967:

Improve support for sctp_generic_recvmsg() and sctp_generic_sendmsg()
and add support for sctp_generic_sendmsg_iov().

Handle the struct iovec argument and the struct sctp_sndrcvinfo
arguments.

6 years agoMFC r327966:
tuexen [Sat, 7 Apr 2018 21:00:21 +0000 (21:00 +0000)]
MFC r327966:

Add a function is decode the sinfo_flags of struct sctp_sndrcvinfo.

6 years agoMFC r327962:
tuexen [Sat, 7 Apr 2018 20:57:27 +0000 (20:57 +0000)]
MFC r327962:

Add support for the supported PR-SCTP policies.

6 years agoMFC r327961:
tuexen [Sat, 7 Apr 2018 20:56:07 +0000 (20:56 +0000)]
MFC r327961:

Mark the iovec parameters of writev() and readv() as IN and OUT.
This makes truss work on readv() as expected.

6 years agoMFC r327921:
tuexen [Sat, 7 Apr 2018 20:54:37 +0000 (20:54 +0000)]
MFC r327921:

Fix a typo introduced in r327919.

6 years agoMFC r327919:
tuexen [Sat, 7 Apr 2018 20:52:05 +0000 (20:52 +0000)]
MFC r327919:

Add support for readv() and writev() to truss.

Sponsored by:i Netflix, Inc.

6 years agoMFC r331061:
tuexen [Sat, 7 Apr 2018 20:47:25 +0000 (20:47 +0000)]
MFC r331061:

Set the inp_vflag consistently for accepted TCP/IPv6 connections when
net.inet6.ip6.v6only=0.

Without this patch, the inp_vflag would have INP_IPV4 and the
INP_IPV6 flags for accepted TCP/IPv6 connections if the sysctl
variable net.inet6.ip6.v6only is 0. This resulted in netstat
to report the source and destination addresses as IPv4 addresses,
even they are IPv6 addresses.

PR: 226421
Reviewed by: bz, hiren, kib
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D13514

6 years agoMFC r328488:
tuexen [Sat, 7 Apr 2018 20:44:30 +0000 (20:44 +0000)]
MFC r328488:

When using SCTP for sending probe packets, use INIT chunks for payloads
larger than or equal to 32 bytes. For smaller probe packets, keep using
SHUTDOWN-ACK chunks, possibly bundled with a PAD chunk.
Packets with INIT chunks more likely pass through firewalls. Therefore,
use them when possible.

6 years agoMFC r328478:
tuexen [Sat, 7 Apr 2018 20:42:06 +0000 (20:42 +0000)]
MFC r328478:

Add constant for the PAD chunk as defined in RFC 4820.
This will be used by traceroute and traceroute6 soon.

6 years agoMFC r328477:
tuexen [Sat, 7 Apr 2018 20:40:40 +0000 (20:40 +0000)]
MFC r328477:

Update references in comments, since the IDs have become an RFC long
time ago. Also cleanup whitespaces. No functional change.

6 years agoMFC r328066:
tuexen [Sat, 7 Apr 2018 20:39:09 +0000 (20:39 +0000)]
MFC r328066:

Fix a bug related to fast retransmissions.

When processing a SACK advancing the cumtsn-ack in fast recovery,
increment the miss-indications for all TSN's reported as missing.

Thanks to Fabian Ising for finding the bug and to Timo Voelker
for provinding a fix.

This fix moves also CMT related initialisation of some variables
to a more appropriate place.

6 years agoMFC r328028:
tuexen [Sat, 7 Apr 2018 20:37:44 +0000 (20:37 +0000)]
MFC r328028:

Don't provide a (meaningless) cmsg when proving a notification
in a recvmsg() call.

6 years agoMFC r327844:
tuexen [Sat, 7 Apr 2018 20:34:03 +0000 (20:34 +0000)]
MFC r327844:

Ensure that the vnet is set when calling pru_sockaddr() and
pru_peeraddr().

This is already true when called via kern_getsockname() and
kern_getpeername(). This patch sets it also, when they arecalled
via soo_fill_kinfo(). This is necessary, since the corresponding
functions for SCTP require the vnet to be set. Without this,
if a process having an wildcard bound SCTP socket is
terminated and a core is written, the kernel panics.

6 years agoMFC r326233:
tuexen [Sat, 7 Apr 2018 20:27:11 +0000 (20:27 +0000)]
MFC r326233:

Add to ipfw support for sending an SCTP packet containing an ABORT chunk.
This is similar to the TCP case. where a TCP RST segment can be sent.

There is one limitation: When sending an ABORT in response to an incoming
packet, it should be tested if there is no ABORT chunk in the received
packet. Currently, it is only checked if the first chunk is an ABORT
chunk to avoid parsing the whole packet, which could result in a DOS attack.

Thanks to Timo Voelker for helping me to test this patch.

MFC r327200:

When adding support for sending SCTP packets containing an ABORT chunk
to ipfw in https://svnweb.freebsd.org/changeset/base/326233,
a dependency on the SCTP stack was added to ipfw by accident.

This was noted by Kevel Bowling in https://reviews.freebsd.org/D13594
where also a solution was suggested. This patch is based on Kevin's
suggestion, but implements the required SCTP checksum computation
without any dependency on other SCTP sources.

While there, do some cleanups and improve comments.

Thanks to Kevin Kevin Bowling for reporting the issue and suggesting
a fix.

6 years agoMFC r326829:
tuexen [Sat, 7 Apr 2018 20:23:34 +0000 (20:23 +0000)]
MFC r326829:

Cleaup, no functional change.

6 years agoMFC r326672:
tuexen [Sat, 7 Apr 2018 20:22:04 +0000 (20:22 +0000)]
MFC r326672:

Retire SCTP_WITH_NO_CSUM option.

This option was used in the early days to allow performance measurements
extrapolating the use of SCTP checksum offloading. Since this feature
is now available, get rid of this option.
This also un-breaks the LINT kernel. Thanks to markj@ for making me
aware of the problem.

6 years agoMFC r325864:
tuexen [Sat, 7 Apr 2018 20:15:12 +0000 (20:15 +0000)]
MFC r325864:

Fix the handling of ERROR chunks which a lot of error causes.
While there, clean up the code.
Thanks to Felix Weinrank who found the bug by using fuzz-testing
the SCTP userland stack.

6 years agoMFC r325788:
tuexen [Sat, 7 Apr 2018 20:13:29 +0000 (20:13 +0000)]
MFC r325788:

Simply the code and use the full buffer for contigous chunk representation.

6 years agoMFC r325746:
tuexen [Sat, 7 Apr 2018 20:11:56 +0000 (20:11 +0000)]
MFC r325746:

Cleanup the handling of control chunks. While there fix some minor
bug related to clearing the assoc retransmit counter and the dup TSN
handling of NR-SACK chunks.

6 years agoMFC r325434:
tuexen [Sat, 7 Apr 2018 20:10:26 +0000 (20:10 +0000)]
MFC r325434:

Fix an accounting bug where data was counted twice if on the read
queue and on the ordered or unordered queue.
While there, improve the checking in INVARIANTs when computing the
a_rwnd.

6 years agoMFC r325370:
tuexen [Sat, 7 Apr 2018 20:08:17 +0000 (20:08 +0000)]
MFC r325370:

Allow the setting of the MTU for future paths using an SCTP socket option.
This functionality was missing.

6 years agoMFC r325284:
tuexen [Sat, 7 Apr 2018 20:06:50 +0000 (20:06 +0000)]
MFC r325284:

Fix the reporting of the MTU for SCTP sockets when using IPv6.

6 years agoMFC r325046:
tuexen [Sat, 7 Apr 2018 20:05:25 +0000 (20:05 +0000)]
MFC r325046:

Fix parsing error when processing cmsg in SCTP send calls. The bug is
related to a signed/unsigned mismatch.
This should most likely fix the issue in sctp_sosend reported by
Dmitry Vyukov on the freebsd-hackers mailing list and found by
running syzkaller.

6 years agoMFC r324971:
tuexen [Sat, 7 Apr 2018 20:03:35 +0000 (20:03 +0000)]
MFC r324971:

Fix a bug reported by Felix Weinrank using the libfuzzer on the
userland stack.

6 years agoMFC r324958:
tuexen [Sat, 7 Apr 2018 20:02:08 +0000 (20:02 +0000)]
MFC r324958:

Fix a bug in handling special ABORT chunks.
Thanks to Felix Weinrank for finding this issue using libfuzzer with
the userland stack.

6 years agoMFC r324954:
tuexen [Sat, 7 Apr 2018 20:00:58 +0000 (20:00 +0000)]
MFC r324954:

Fix a locking issue found by running AFL on the userland stack.
Thanks to Felix Weinrank for reporting the issue.

6 years agoMFC r324730:
tuexen [Sat, 7 Apr 2018 19:59:40 +0000 (19:59 +0000)]
MFC r324730:

Fix a signed/unsigned warning.

6 years agoMFC r324729:
tuexen [Sat, 7 Apr 2018 19:58:14 +0000 (19:58 +0000)]
MFC r324729:

Abort an SCTP association, when a DATA chunk is followed by an unknown
chunk with a length smaller than the minimum length.

Thanks to Felix Weinrank for making me aware of the problem.

6 years agoMFC r324638:
tuexen [Sat, 7 Apr 2018 19:56:34 +0000 (19:56 +0000)]
MFC r324638:

Fix the handling of parital and too short chunks.

Ensure that the current behaviour is consistent: stop processing
of the chunk, but finish the processing of the previous chunks.

This behaviour might be changed in a later commit to ABORT the
assoication due to a protocol violation, but changing this
is a separate issue.

MFC r324725

Fix a bug introduced in r324638.
Thanks to Felix Weinrank for making me aware of this.

MFC r324726:

Revert change which got in accidently.

6 years agoMFC r324615:
tuexen [Sat, 7 Apr 2018 19:44:41 +0000 (19:44 +0000)]
MFC r324615:

Code cleanup, not functional change.

This avoids taking a pointer of a packed structure which allows simpler
compilation of the userland stack.

6 years agoMFC r324317:
tuexen [Sat, 7 Apr 2018 19:42:53 +0000 (19:42 +0000)]
MFC r324317:

Ensure that the accept ABORT chunks with the T-bit set only the
a non-zero matching peer tag is provided.

6 years agoMFC r324218:
tuexen [Sat, 7 Apr 2018 19:40:48 +0000 (19:40 +0000)]
MFC r324218:

Whitespace changes: Remove leading spaces followed by a tab.

6 years agoMFC r324216:
tuexen [Sat, 7 Apr 2018 19:38:55 +0000 (19:38 +0000)]
MFC r324216:

Fix a bug which avoided that rules for matching port numbers for SCTP
packets where actually matched.
While there, make clean in the man-page that SCTP port numbers are
supported in rules.

6 years agoMFC r324122:
tuexen [Sat, 7 Apr 2018 19:23:51 +0000 (19:23 +0000)]
MFC r324122:

Fix reporting of probing size. This bug was introduced in r324119.

6 years agoMFC r324120:
tuexen [Sat, 7 Apr 2018 19:22:32 +0000 (19:22 +0000)]
MFC r324120:

Add SCTP and TCP as protocols for sending probe packets.

6 years agoMFC r324119:
tuexen [Sat, 7 Apr 2018 19:21:15 +0000 (19:21 +0000)]
MFC r324119:

* Update function definitions.
* Ensure that the datalen always describes the length after the IPv6
  header consistently, not matter which protocol us used for probes..
* Document that the default length is 20, not 12.
* Don't send inormation in probe packets which is not needed or
  even checked when the responses are processed.
* Address CID 978587.

This is mainly a cleanup preparing the addition of SCTP and TCP
as possible probe packet protocols.

6 years agoMFC r324056:
tuexen [Sat, 7 Apr 2018 19:19:25 +0000 (19:19 +0000)]
MFC r324056:

Remove unused function.

6 years agoMFC r323904:
tuexen [Sat, 7 Apr 2018 19:17:31 +0000 (19:17 +0000)]
MFC r323904:

Add missing locking. Found by Coverity while scanning the usrsctp
library.

6 years agoMFC r323902:
tuexen [Sat, 7 Apr 2018 19:16:06 +0000 (19:16 +0000)]
MFC r323902:

Add missing socket lock.

6 years agoMFC r323861:
tuexen [Sat, 7 Apr 2018 19:14:31 +0000 (19:14 +0000)]
MFC r323861:

Code cleanup, no functional change.

6 years agoMFC r323850:
tuexen [Sat, 7 Apr 2018 19:13:05 +0000 (19:13 +0000)]
MFC r323850:

Free the control structure after using is, not before.
Found by Coverity while scanning the usrsctp library.

6 years agoMFC r323847:
tuexen [Sat, 7 Apr 2018 19:11:21 +0000 (19:11 +0000)]
MFC r323847:

No need to wakeup, since sctp_add_to_readq() does it.

6 years agoMFC r323833:
tuexen [Sat, 7 Apr 2018 19:09:51 +0000 (19:09 +0000)]
MFC r323833:

Protect the address workqueue timer by a mutex.

6 years agoMFC r323776:
tuexen [Sat, 7 Apr 2018 18:08:42 +0000 (18:08 +0000)]
MFC r323776:

Fix a warning.

6 years agoMFC r323774:
tuexen [Sat, 7 Apr 2018 18:06:40 +0000 (18:06 +0000)]
MFC r323774:

Avoid an overflow when computing the staleness.
This issue was found by running libfuzz on the userland stack.

6 years agoMFC r323763:
tuexen [Sat, 7 Apr 2018 18:05:01 +0000 (18:05 +0000)]
MFC r323763:

Remove a no longer used variable.

Reported by: Felix Weinrank

6 years agoMFC r323670:
tuexen [Sat, 7 Apr 2018 18:02:17 +0000 (18:02 +0000)]
MFC r323670:

Fix an accounting bug and use sctp_timer_start to start a timer.

6 years agoMFC r323657:
tuexen [Sat, 7 Apr 2018 17:59:08 +0000 (17:59 +0000)]
MFC r323657:

Remove code not used on any platform currently supported.

6 years agoMFC r323505:
tuexen [Sat, 7 Apr 2018 17:54:38 +0000 (17:54 +0000)]
MFC r323505:

Export the UDP encapsualation port and the path state.

6 years agoMFC r323378:
tuexen [Sat, 7 Apr 2018 17:41:32 +0000 (17:41 +0000)]
MFC r323378:

Fix MTU computation. Coverity scanning usrsctp pointed to this code...

6 years agoMFC r323377:
tuexen [Sat, 7 Apr 2018 17:40:11 +0000 (17:40 +0000)]
MFC r323377:

Fix a locking issue found by Coverity scanning the usrsctp library.

6 years agoMFC r323376:
tuexen [Sat, 7 Apr 2018 17:38:38 +0000 (17:38 +0000)]
MFC r323376:

Fix locking issues found by Coverity scanning the usrsctp library.

6 years agoMFC r323374:
tuexen [Sat, 7 Apr 2018 17:36:53 +0000 (17:36 +0000)]
MFC r323374:

Silence a Coverity warning from scanning the usrsctp library.

6 years agoMFC r323372:
tuexen [Sat, 7 Apr 2018 17:35:04 +0000 (17:35 +0000)]
MFC r323372:

Savely remove a chunk from the control queue.
This bug was found by Coverity scanning the usrsctp library.

6 years agoMFC r323352:
tuexen [Sat, 7 Apr 2018 15:19:10 +0000 (15:19 +0000)]
MFC r323352:

The combination of IPv6 and SCTP is also supported.

6 years agoMFC r322967:
tuexen [Sat, 7 Apr 2018 15:16:57 +0000 (15:16 +0000)]
MFC r322967:

Fix blackhole detection.

There were two bugs related to the blackhole detection:
* The smalles size was tried more than two times.
* The restored MSS was not the original one, but the second
  candidate.

Sponsored by: Netflix, Inc.

6 years agoMFC r322812:
tuexen [Sat, 7 Apr 2018 15:10:08 +0000 (15:10 +0000)]
MFC r322812:

Avoid TCP log messages which are false positives.

The check for timestamps are too early to handle SYN-ACK correctly.
So move it down after the corresponing processing has been done.

MFC r322813:

Avoid TCP log messages which are false positives.

This is https://svnweb.freebsd.org/changeset/base/322812, just for
alternate TCP stacks.

PR: 216832
Obtained from: antonfb@hesiod.org

6 years agoMFC r321463:
tuexen [Sat, 7 Apr 2018 14:45:55 +0000 (14:45 +0000)]
MFC r321463:

Remove duplicate statement.

6 years agoMFC r321289:
tuexen [Sat, 7 Apr 2018 14:44:21 +0000 (14:44 +0000)]
MFC r321289:

Fix the explicit EOR mode. If the final messages is not complete, send
an ABORT.
Joint work with rrs@

6 years agoMFC r321205:
tuexen [Sat, 7 Apr 2018 14:43:01 +0000 (14:43 +0000)]
MFC r321205:

Avoid shadowed variables.

6 years agoMFC r321204:
tuexen [Sat, 7 Apr 2018 14:41:44 +0000 (14:41 +0000)]
MFC r321204:

Use memset/memcpy instead of bzero/bcopy.

Just use one variant instead of both. Use the memset/memcpy
ones since they cause less problems in crossplatform deployment.

6 years agoMFC r321197:
tuexen [Sat, 7 Apr 2018 14:40:21 +0000 (14:40 +0000)]
MFC r321197:

Fix the accounting and add code to detect errors in accounting.
Joint work with rrs@

6 years agoMFC r321034:
tuexen [Sat, 7 Apr 2018 14:38:58 +0000 (14:38 +0000)]
MFC r321034:

Fix the handling of Explicit EOR mode.

While there, appropriately handle the overhead depending on
the usage of DATA or I-DATA chunks. Take the overhead only
into account, when required.

Joint work with rrs@

6 years agoMFC r320653:
tuexen [Sat, 7 Apr 2018 14:37:16 +0000 (14:37 +0000)]
MFC r320653:
Move to open state after plausibility checks.

When doing this too early, the MIB counters go wrong.

6 years agoMFC r320650:
tuexen [Sat, 7 Apr 2018 14:35:46 +0000 (14:35 +0000)]
MFC r320650:

Don't hold a refcount on an stcb when it is not needed.
This improves the consistency with other parts of the code.

6 years agoMFC r322324: capsicum_helpers: Add FIODTYPE to default ioctls allowed
kevans [Sat, 7 Apr 2018 03:51:19 +0000 (03:51 +0000)]
MFC r322324: capsicum_helpers: Add FIODTYPE to default ioctls allowed

FIODTYPE will be needed by hexdump(1) to speed up the -s flag on devices
that should be able to support fseek(3); specifically, in an attempt to
correct for the fact that most tape drives don't support seeking yet don't
indicate as such when fseeko(3) is invoked.

6 years agoRegenerate src.conf(5) after r332162
kevans [Sat, 7 Apr 2018 03:02:07 +0000 (03:02 +0000)]
Regenerate src.conf(5) after r332162

This is a direct commit to stable/11

6 years agoMFC r330116, r330118, r330251, r330254
kevans [Sat, 7 Apr 2018 02:56:59 +0000 (02:56 +0000)]
MFC r330116, r330118, r330251, r330254

r330116:
Some missing LOADER_EFI build option descriptions

r330118:
Add missing punctuation to *_LOADER_EFI descriptions...

r330251:
Remove LOADER_EFI description files

LOADER_EFI functionality got folded into EFI as of r330248.

r330254:
Add descriptions for recently added loader options

6 years agoMFC r331651-r331653
brooks [Sat, 7 Apr 2018 00:23:49 +0000 (00:23 +0000)]
MFC r331651-r331653

r331651:
Copy flags over ifr_union directly rather than via casts through
ifr_data.

No functional change in practice.  If the sbni driver supported
64-bit big-endian system, this would be an ABI changes, but it is
i386-only.  The old version leaked a word of stack on 64-bit systems.

This eliminates the only assignment to ifr_data.

r331652:
Revert r331651 to recommit with proper commit metadata.

r331653:
Copy flags over ifr_union directly rather than via casts through
ifr_data.

No functional change in practice.  If the sbni driver supported
64-bit big-endian system, this would be an ABI changes, but it is
i386-only.  The old version leaked a word of stack on 64-bit systems.

This eliminates the only assignment to ifr_data.

Reviewed by: kib
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D14874

6 years agoMFC r331648:
brooks [Fri, 6 Apr 2018 23:31:47 +0000 (23:31 +0000)]
MFC r331648:

Improve copy-and-pasted versions of SIOCGIFADDR.

The original implementation used a reference to ifr_data and a cast to
do the equivalent of accessing ifr_addr. This was copied multiple
times since 1996.

Approved by: kib
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D14873

6 years agoMFC r330970, r331067, r331767, r331852, r331858
kevans [Fri, 6 Apr 2018 21:50:09 +0000 (21:50 +0000)]
MFC r330970, r331067, r331767, r331852, r331858

r330970:
libefi: UEFI_BOOT_VAR_GUID duplicates EFI_GLOBAL_VARIABLE

Drop UEFI_BOOT_VAR_GUID and use EFI_GLOBAL_VARIABLE.

r331067:
Only print boot order / boot current if we can get the variables from
the loader. Some UEFI implementations don't return all of them.

Sponsored by: Netflix

r331767:
efinet: Do not return only if ReceiveFilter fails

If the network interface or the uefi implementation do not support the
ReceiveFilter interface do not return only and just print a message.
U-Boot doesn't support is and likely never will. Also even if this fails
it doesn't mean that network in EFI isn't supported.

r331852:
fwohcireg.h is 99% the same between the boot loader and the
kernel. Delete it and fix up the 1% difference because there's no need
for them to be different.

r331858:
The Uninorth ID was really for Uninorth 2.

6 years agoMFC r331331: Apply r228478 (CTASSERT => _Static_assert()) to bootstrap.h
kevans [Fri, 6 Apr 2018 21:40:23 +0000 (21:40 +0000)]
MFC r331331: Apply r228478 (CTASSERT => _Static_assert()) to bootstrap.h

6 years agoMFC r330806-r330815, r330837, r330864, r330883
kevans [Fri, 6 Apr 2018 21:37:25 +0000 (21:37 +0000)]
MFC r330806-r330815, r330837, r330864, r330883

pc98 changes associated with the named commits are also included in this
commit, despite not having been made with the original commits due to its
removal in head.

r330806:
Minor cosmetic changes.

Make sure { on the same line as struct for all struct *devdesc.  Move
some type definitions to next to the dv_type define, since that's what
sets the d_type.

r330807:
We can't use d_opendata for blkio storage.

open_disk uses d_opendata for it's own purpse. We can't store blkio
there. Fortunately, blkio is stored elsewhere and we never actually
retrieve blkio from d_opendata. Eliminate it as a source of confusion.
Eliminate all stores of d_opendata in efi since this layer doesn't own
that field.

r330808:
Make struct libi386_devdesc match the struct devdesc better

Move data to top and call it d_opendata.

r330809:
Use the actual struct devdesc at the start of all *_devdesc structs

The current system is fragile and requires very careful layout of all
*_devdesc structures. It also makes it hard to change the base
devdesc. Take a page from CAM and put the 'header' in all the derived
classes and adjust the code to match.

For OFW, move the iHandle h_handle out of a slot conflicting with
d_opendata. Due to quirks in the alignment rules, this worked.
However changing the code to use d_opendata storage now that it's a
pointer is hard, so just have a separate field for it.

All other cleanups were to make the *_devdesc structures match where
they'd taken some liberties that were none-the-less compatible enough
to work.

r330810:
Remove d_type from devdesc. It's not needed as we can fetch it from
d_dev->dv_type when we need it.

r330811:
GC unused routines.

Sponsored by: Netflix

r330812:
Use the one-line-per-file pattern here, and sort the file names.

Sponsored by: Netflix

r330813:
Move the env convenience routines out of boot1.c.

These routines are more generally useful. Even though boot1 is on its
way out, it's better to make these common during the transition than
copy them.

r330814:
Star BootCurrent entry when booting.

Sponsored by: Netflix

r330815:
Print the load and device path as well as BootCurrent and BootOrder

Sponsored by: Netflix

r330837:
biosdisk.c should not set d_opendata.

Same as 330807, d_opendata is owned by open_disk and we should not
set it.

M    stand/i386/libi386/biosdisk.c

r330864:
Prefer uintXX_t to u_intXX_t

A foolish consistency is the hobgoblin of little minds, adored by
little statesmen and philosophers and divines. With consistency a
great soul has simply nothing to do. -- Ralph Waldo Emerson

r330883:
Fix typo that misteriously passes compilation.

6 years agostable/11: Mark EFI as a broken option on pc98
kevans [Fri, 6 Apr 2018 20:56:06 +0000 (20:56 +0000)]
stable/11: Mark EFI as a broken option on pc98

This is a direct commit to stable/11, due to pc98 removal in head.

6 years agoMFC r330365, r330371: OFW changes
kevans [Fri, 6 Apr 2018 20:27:55 +0000 (20:27 +0000)]
MFC r330365, r330371: OFW changes

r330365:
Move "common" Open Firmware parts of the loader used only on PowerPC to
the powerpc/ subdirectory. These have never used by SPARC and we have
no other (and almost certainly will have no other) Open Firmware platforms.
This makes the directory structure simpler and lets us avoid some
cargo-cult MI patterns on code that is, and always was,
architecture-specific.

r330371:
Where we can, pass the kernel an FDT facsimile of the OF device tree rather
than a pointer to Open Firmware by default. This eliminates a number of
potentially unsafe calls to firmware from the kernel and provides better
performance.

This feature is meant to be expanded until it is on by default
unconditionally and, ideally, we can then garbage-collect the
nightmare pile of hacks required to call into Open Firmware from a live
kernel.

6 years agoMFC r329190, r329315, r330131: metadata load file unification
kevans [Fri, 6 Apr 2018 20:24:50 +0000 (20:24 +0000)]
MFC r329190, r329315, r330131: metadata load file unification

r329190: Unify metadata load files for arm, mips, powerpc, sparc64

Summary:
All metadata.c files are very similar, with only trivial changes. Unify them
into a single common file, with minor special-casing where needed.

r329315: stand: Fix ubldr after r329190

metadata load files were consolidated in r329190, and these relocation fixup
bits were inadvertently dropped in the process. Re-add them to fix boot with
ubldr.

r330131: Fix module loading on arm after the metadata.c unification in
r329190. Arm modules need an additional address fixup not needed by other
platforms.

6 years agoMFC r330788: beri loader: Replace getc/putc with beri_ prefixed versions
kevans [Fri, 6 Apr 2018 19:59:27 +0000 (19:59 +0000)]
MFC r330788: beri loader: Replace getc/putc with beri_ prefixed versions

This matches a convention that we use, at least in ubldr, to prefix
getc/putc with a loader-specific prefix to avoid collisions. This was
encountered while trying to build the beri loader with MK_LOADER_LUA=yes.

6 years agoMFC r330249-r330250
kevans [Fri, 6 Apr 2018 19:54:10 +0000 (19:54 +0000)]
MFC r330249-r330250

r330249:
stand: Makefile SUBDIR cleanup

Use SUBDIR.${MK_*} where appropriate. r330248 eliminated most of the
offenders, sweep the rest under the rug.

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

r330250:
stand: Fix build after r330249

One does not simply convert to SUBDIR.yes in stand without making everything
else in the affected files SUBDIR.yes -- there are better ways to do this.

6 years agoRevert lua bits that snuck in with r332144
kevans [Fri, 6 Apr 2018 19:52:00 +0000 (19:52 +0000)]
Revert lua bits that snuck in with r332144

These will get re-MFC'd differently when we import lualoader from head. This
is a direct commit to stable/11

6 years agoMFC r330077, r330248
kevans [Fri, 6 Apr 2018 19:47:07 +0000 (19:47 +0000)]
MFC r330077, r330248

r330077:
Move EFI up to common makefile. There's no need for all these .if's
based on architecture.

Sponsored by: Netflix

r330248:
Create LOADER_UBOOT, and LOADER_OFW. Move these options out of
Makefile.${MACHINE_ARCH} and remove the now-empty files. Generate the
*32 directories on the necessary architectures (well, currently only
amd64) on the fly. Remove LOADER_EFI variable and co-locate it with
EFI.

6 years agoMFC r330056: libsa: replace remaining _write callbacks by null_write
kevans [Fri, 6 Apr 2018 19:34:21 +0000 (19:34 +0000)]
MFC r330056: libsa: replace remaining _write callbacks by null_write

There are some _write callbacks left only returning EROFS, replace them
by null_write. return EROFS from null_write().

6 years agoMFC r330026: libsa: Move MAXWAIT from net.h to net.c
kevans [Fri, 6 Apr 2018 19:24:04 +0000 (19:24 +0000)]
MFC r330026: libsa: Move MAXWAIT from net.h to net.c

It's not a setting that has any effect or use outside of the net.c context.

6 years agoMFC r329879, r329892
kevans [Fri, 6 Apr 2018 19:21:36 +0000 (19:21 +0000)]
MFC r329879, r329892

r329879:
libsa: Const-ify buffer argument of write(2) analog

r329892:
libsa: Change write(2)-alike prototype to match definition

Broken in r329879.

Apparently old GCC detects this, but modern GCC didn't.  Mea culpa.

6 years agoMFC r329859,r329860: Float protection in stand
kevans [Fri, 6 Apr 2018 19:17:59 +0000 (19:17 +0000)]
MFC r329859,r329860: Float protection in stand

r329859: Do not include float interfaces when using libsa.

We don't support float in the boot loaders, so don't include
interfaces for float or double in systems headers. In addition, take
the unusual step of spiking double and float to prevent any more
accidental seepage.

r329860: Floaty McFloatface is funnier...

6 years agoMFC r329758: Fix compilation with LOADER_DEBUG defined after r329725.
kevans [Fri, 6 Apr 2018 19:11:58 +0000 (19:11 +0000)]
MFC r329758: Fix compilation with LOADER_DEBUG defined after r329725.

6 years agoMFC r329745: load_elf.c: Use consistent indentation
kevans [Fri, 6 Apr 2018 19:10:11 +0000 (19:10 +0000)]
MFC r329745: load_elf.c: Use consistent indentation

As noted in D14267 load_elf.c has a variety of indentation styles.  Move
to standard 8 column hard tab indents, 4 space second level indents.
Also includes some whitespace cleanups found by clang-format.

6 years agoMFC r329345: Eliminate bsd.stand.mk and -fPIC 32-bit intel builds
kevans [Fri, 6 Apr 2018 19:01:08 +0000 (19:01 +0000)]
MFC r329345: Eliminate bsd.stand.mk and -fPIC 32-bit intel builds

OK. We don't really need a bsd.stand.mk, and it was causing a -fPIC
for the toolchain to be added (bogusly) when building on amd64. Pull
all relevant defs back into defs.mk and delete bsd.stand.mk.

This saves about 15-20k on i386 loader and zfsloader which when
combined with Lua give us a lot more stack space in those constrained
environments.

6 years agoMFC r329726, r329737, r329740
kevans [Fri, 6 Apr 2018 18:55:02 +0000 (18:55 +0000)]
MFC r329726, r329737, r329740

r329726:
Honor settings for including / excluding cd9660, ufs, ext2fs and msdos.

The Makefile gives the impression that ext2fs and msdos were excluded
(they weren't) and that you could exclude cd9660 and ufs support (you
couldn't). Allow those to be excluded.

We need to look, in the future, at trimming the number of supported
filesystems, and this will make that easier.

r329737:
Purely whitespace changes bringing this file closer to style(9).

Curiously, changing whitespace seems to cause the md5 of the .o files to differ
these days hence the following testing strategy:

Tested by: objdump -d | md5 (both in-tree clang and lang/gcc6)

r329740:
Further style(9) changes.

Tested by: objdump -d | md5 (both in-tree clang and lang/gcc6)

6 years agoMFC r329725, r329831
kevans [Fri, 6 Apr 2018 18:40:24 +0000 (18:40 +0000)]
MFC r329725, r329831

r329725:
Consolidate three copies of ZFS commands into a central location.

There's no reason to have multiple copies of lszfs and
reloadbe. Consolidate them into one location. Also ldi_get_size is the
same everywhere (except sparc64). Make it the same everywhere as the
common definition is more general and will work on spar64.

r329831:
Fix userboot w/ ZFS after r329725

r329725 cleaned up ZFS commands duplicated in multiple places, but userboot
was not setting HAVE_ZFS when MK_ZFS != "no". This resulted in a failure to
boot (as seen in PR 226118) in bhyve, with the following message:

/boot/userboot.so: Undefined symbol "ldi_get_size"

6 years agoMFC r329268, r329517
kevans [Fri, 6 Apr 2018 18:38:25 +0000 (18:38 +0000)]
MFC r329268, r329517

r329268:
efi: Only scan the BLKIO MEDIA once

Scan only the BLOCK IO MEDIA once instead of each time for each type of
device (fd, cd and hdd).
Leave the mechanism to free and reprobe all devices if one day we want
to implement a "dev rescan" thing.

r329517:
efi: Do not pad the efi devpath structure

This solve problem when booting with efi on armv7

6 years agoMFC efibootmgr: r326725-r326728, r326771, r326800-r326804, r326806, r327163
kevans [Fri, 6 Apr 2018 18:25:03 +0000 (18:25 +0000)]
MFC efibootmgr: r326725-r326728, r326771, r326800-r326804, r326806, r327163
 r327572-r327573, r327610-r327611, r327877, r331069

r326725:
Import Netflix's efibootmgr to help manage UEFI boot variables

efibootmgr manages the UEFI BootXXXX variables that implement the UEFI
Boot Manager protocol defined in the UEFI standards. It is modeled
after the Linux program of the same name with a mostly compatible set
of command line options. Since there's a fair amount of OS specifioc
code due to differeing names and methods of doing things, the
compatibility isn't 100%.

Basic functionality is implemented, though the more advanced next boot
functionality that's been defined elsewhere is unimplemented.

Submitted by: Matt Williams (with unix / efi path xlate by me)
Sponsored by: Netflix

r326726:
Forgotten in 326725

Release Notes: Yes

r326727:
Remove vestiges of -d and -p commands.
Fix two core dumps when optional data isn't specified.

Sponsored by: Netflix

r326728:
Indent multiple device path entries correctly.

Sponsored by: Netflix

r326771:
Unbreak gcc build by using (void) for functions that take no args.

Sponsored by: Netflix

r326800:
Check return value for set_bootvar and give a good error message.

CID: 1383601
Sponsored by: Netflix

r326801:
Don't leak new_data.

CID: 1383605
Sponsored by: Netflix

r326802:
Fix resource leak. Free converted description after printing it.
Also minor style sort of local vars.

CID: 1383606
Sponsored by: Netflix

r326803:
Free load_opt_buf after we're done with it.

CID: 1383607
Sponsored by: Netflix

r326804:
Add sanity testing against maximum sane lengths for device paths for
loader and kernel.

CID: 1383608
Sponsored by: Netflix

r326806:
Actually insert the free(d) call missed in r326802.

Noticed by: rpokala@

r327163:
Remove write-only opt and useless optlen variables.

This squashes the warning gebnerated by GCC 6.x. Since
variables that are now removed had come documentation
value, put relevant bits in comment, so they can be
resurrected from there when actually needed.

r327572:
Ensure that we have a description string. When unspecified, default to "".

Sponsored by: Netflix

r327573:
Free options before setting them. This will prevent us from leaking
memory when we have multiple copies of the same option from being
specified.

Sponsored by: Netflix

r327610:
Fix usage strings. -d and -p were removed before this was committed to
FreeBSD, but the strings weren't updated.

Sponsored by: Netflix

r327611:
There's no need / benefit from deleting the variable before we set it.

Sponsored by: Netflix

r327877:
Fix error in determining the next available boot slot.

Sponsored by: Netflix

r331069:
Make not getting BootOrder a warning, not a fatal error when printing.

Sponsored by: Netflix

Relnotes: yes

6 years agoMFC: r314875, r331963
jkim [Fri, 6 Apr 2018 18:23:42 +0000 (18:23 +0000)]
MFC: r314875, r331963

Catch up with Clang 6.0.