sysctl() provides a count of number of bytes in the buffer. That is the
actual buffer length. Whereas looking for an interrupt entry with an
empty name could terminate too early, or overflow the end of the buffer.
The overflow will occur if the table of interrupt names is full.
Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D36628
These appear to simply be the style of arguments are left untouched and
only local variables are modified. While some may prefer that style
this simply serves to complicate things as they're perfectly writeable.
Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D36628
A similar change was made in svn r223931, but it was incomplete, working
only when the utility was invoked as "ncal". Fix the same issue when
invoking as "cal".
PR: 268936
Reported by: Ray Bellis <ray@bellis.me.uk>
MFC after: 2 weeks
Sponsored by: Axcient
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D38045
The previous code would skip as many entries at the end of the
array as there were zombies in the list. While here fix type
of cnt.
Submitted by: Ali Abdallah <ali.abdallah suse.com>
PR: 232702
MFC After: 2 weeks
-z is supposed to use only the NUL byte as EOL, but we were
inadvertently using both newline and NUL due to REG_NEWLINE in cflags.
The odds of anyone relying on this bsdgrep-specific bug are quite low,
so let's just fix it. At least one port in the wild has been reported
to expect the intended behavior.
Reported by: Hill Ma <maahiuzeon@gmail.com>
Triaged by: the self-proclaimed peanut gallery on Discord
Document the environment variables used by grep(1).
Reviewed by: pauamma, kevans
MFC after: 5 days
Differential Revision: https://reviews.freebsd.org/D37726
This subsystem is superseded by modern debugging facilities,
e.g. DTrace probes and TCP black box logging.
We intentionally leave SO_DEBUG in place, as many utilities may
set it on a socket. Also the tcp::debug DTrace probes look at
this flag on a socket.
Reviewed by: gnn, tuexen
Discussed with: rscheff, rrs, jtl
Differential revision: https://reviews.freebsd.org/D37694
This is a bit more readable, and this loop is probably unlikely to gain
any `continue` or `break`s.
Suggested by: pstef
Differential Revision: https://reviews.freebsd.org/D37676
The previous logic conflated some things... in this block:
- j: input characters rendered so far
- nc: number of characters in the line
- col: columns rendered so far
- hw: column width ((h)ard (w)idth?)
Comparing j to hw or col to nc are naturally wrong, as col and hw are
limits on their respective counters and nc is already brought down to hw
if the input line should be truncated to start with.
Right now, we end up easily truncating lines with tabs in them as we
count each tab for $tabwidth lines in the input line, but we really
should only be accounting for them in the column count. The problem is
most easily demonstrated by the two input files added for the tests,
the two tabbed lines lose at least a word or two even though there's
plenty of space left in the row for each side.
Reviewed by: bapt, pstef
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D37676
Instead of providing no /usr/bin/objdump when LLVM_BINUTILS is false.
PR: 267854 [exp-run]
Reviewed by: dim
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37445
For the TCP protocol inpcb storage specify allocation size that would
provide space to most of the data a TCP connection needs, embedding
into struct tcpcb several structures, that previously were allocated
separately.
The most import one is the inpcb itself. With embedding we can provide
strong guarantee that with a valid TCP inpcb the tcpcb is always valid
and vice versa. Also we reduce number of allocs/frees per connection.
The embedded inpcb is placed in the beginning of the struct tcpcb,
since in_pcballoc() requires that. However, later we may want to move
it around for cache line efficiency, and this can be done with a little
effort. The new intotcpcb() macro is ready for such move.
The congestion algorithm data, the TCP timers and osd(9) data are
also embedded into tcpcb, and temprorary struct tcpcb_mem goes away.
There was no extra allocation here, but we went through extra pointer
every time we accessed this data.
One interesting side effect is that now TCP data is allocated from
SMR-protected zone. Potentially this allows the TCP stacks or other
TCP related modules to utilize that for their own synchronization.
Large part of the change was done with sed script:
s/tp->ccv->/tp->t_ccv./g
s/tp->ccv/\&tp->t_ccv/g
s/tp->cc_algo/tp->t_cc/g
s/tp->t_timers->tt_/tp->tt_/g
s/CCV\(ccv, osd\)/\&CCV(ccv, t_osd)/g
Dependency side effect is that code that needs to know struct tcpcb
should also know struct inpcb, that added several <netinet/in_pcb.h>.
Differential revision: https://reviews.freebsd.org/D37127
mtflag is used to add pthread mutex locking around operations to make
them thread-safe. Setting the state to _SERVED is not conditional on
locking.
Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D37541
GCC 12 defaults to C++17 which removes (not just deprecates)
std::auto_ptr<>. Trying to use CXXSTD of c++03 doesn't work with
libc++ headers, but c++11 does.
Reviewed by: brooks, imp, emaste
Differential Revision: https://reviews.freebsd.org/D37531
trpt(8) was utility to pull TCP debugging data from the kernel
originating back from 4.2BSD. It is not used nowadays by TCP
developers. We have more powerful debugging facilities, e.g.
the Dtrace probing, the TCP black box logging and siftr.
Discussed with: rscheff, tuexen, rrs, jtl and others
I think this was probably just a typo. initifstat() continues around
a similar loop if the mib data fails to fetch, and fetch_ifstat() was
already using a FOREACH_SAFE loop here so expected to keep going.
Calling clearifstat() from the fetch routine also seems wrong, and the
sort_interface_list() call triggered by the existing needsort = 1 will
itself set needclear to trigger a future clearifstat().
Reported by: GCC 12 -Wuse-after-free
Differential Revision: https://reviews.freebsd.org/D36823
A small reduction in build infrastructure complexity; when we had both
Clang and GCC in the tree it was useful to have both built, and choose
one or the other to install as /usr/bin/cc. Now only Clang is in the
tree, and there is no point in building and installing base Clang but
not providing it as cc (and c++, cpp).
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37075
Previously the tests just verified if command line arguments raised an
error or not, they did not test how command line arguments affected
the output. This adds some sample (if simple) input and output to
each flag test as well as adding a few additional trivial tests.
Reviewed by: brooks
Differential Revision: https://reviews.freebsd.org/D36835
This uses the "::" extension to getopt() to handle options which take
an optional argument.
The updated flag tests were all wrong before and only passed because
the manual parser failed to raise errors when a required argument was
missing. The invalid argument test now gets a better error message.
Reviewed by: brooks, imp, emaste
Differential Revision: https://reviews.freebsd.org/D36834
This also updates various indices and counters from int to size_t to
pacify resulting -Wsign-compare warnings.
Reviewed by: brooks
Differential Revision: https://reviews.freebsd.org/D36833
Previously print_header() used sprintf() of a buffer to itself as a
kind of string builder but without checking for overflows. This
raised -Wformat-truncation and -Wrestrict warnings in GCC. Instead,
just conditionally print the new timestamp fields after the initial
strftime()-formatted string. While here, use sizeof(buf) with
strftime() rather than a magic number.
Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D36814
The implicit fall-through in the !D_FORCEASCII case caused null
characters to be treated as carriage returns honoring the D_STRIPCR,
D_FOLDBLANKS, and D_IGNOREBLANKS flags.
Reported by: GCC -Wimplicit-fallthrough
Reviewed by: bapt
Fixes: 3cbf98e2be diff: read whole files to determine if they are ASCII text
Differential Revision: https://reviews.freebsd.org/D36813
Have tcpstats (netstat -s) differentiate between received and sent
ECN-marked packets. Also account for IP ECN bits (on TCP packets)
even when the tcp session has not negotiated ECN support.
Event: IETF 115 Hackathon
Reviewed By: glebius, tuexen, #transport
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D37314
We already did the necessary $TMPDIR fallback, if it's going to be used.
Skip the later check so that we don't accidentally override our -p
argument.
Fixes: ac6f924e1c ("mktemp: add -p/--tmpdir argument")
Sponsored by: Klara, Inc.
In an e-mail Brian Walden wrote that:
"GWRL stands for Gottfried W. R. Luderer, the author of cut(1) and
paste(1), probably around 1978. Those came either from PWB or USG,
as he worked with, or for, Berkley Tague. Thus they made their way
into AT&T commercial UNIX, first into System III and the into System
V, and that's why they are missing from early BSD releases as they
didn't get into Research UNIX until the 8th Edition."
So update the HISTORY and AUTHORS sections for cut(1) and paste(1).
[1] https://minnie.tuhs.org/pipermail/tuhs/2020-January/019955.html
Reviewed by: pauamma, imp
Obtained from: OpenBSD (in partial)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D36048
This is a minor cosmetic change; re-organize slightly to set tmpdir to
_PATH_TMP if we didn't otherwise have a tmpdir candidate, then check the
trailing char before appending another slash.
While we're here, remove some bogus whitespace and add a test case for
this change.
Obtained from: https://github.com/apple-oss-distributions/shell_cmds
Sponsored by: Klara, Inc.
This matches other mktemp implementations, including OpenBSD and GNU.
The -p option can be used to provide a tmpdir prefix for specified
templates. Precedence works out like so:
-t flag:
- $TMPDIR
- -p directory
- /tmp
Implied -t flag (no arguments or only -d flag):
- -p directory
- $TMPDIR
- /tmp
Some tests have been added for mktemp(1) in the process.
Reviewed by: imp (earlier version), wosch
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D37121
GNU maketemp has long options for -d, -q, and -u, so let's add these
now for compatibility.
Reviewed by: emaste, imp, wosch
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D37120
The most accurate information I have found is that
tee(1) first appeared in Version 7 AT&T UNIX.
Reviewed by: pauamma
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D37206
Something else may have set errno, breaking the post-getline() logic
that tries to detect the getline() error. This was initially noted in
a jail on a system that has HPET, in a jail that does not expose
/dev/hpet0 -- we see an earlier error in libc's vdso bits.
Fixes: 5c053aa3c5 ("split: switch to getline() [...]")