pjd [Mon, 16 Aug 2010 21:59:56 +0000 (21:59 +0000)]
The 'size' variable is there to limit how many bytes we want to copy from
'addr'. It is very likely that size of 'addr' is larger than 'size', so checking
strlcpy() return value is bogus.
jilles [Mon, 16 Aug 2010 17:18:08 +0000 (17:18 +0000)]
sh: Get rid of unnecessary non-standard empty lists.
POSIX does not allow constructs like:
if cmd; then fi
{ }
Add a colon dummy command, except in a test that verifies that such empty
lists do not cause crashes when used as a function definition.
andre [Mon, 16 Aug 2010 14:24:00 +0000 (14:24 +0000)]
Add uma_zone_get_max() to obtain the effective limit after a call
to uma_zone_set_max().
The UMA zone limit is not exactly set to the value supplied but
rounded up to completely fill the backing store increment (a page
normally). This can lead to surprising situations where the number
of elements allocated from UMA is higher than the supplied limit
value. The new get function reads back the effective value so that
the supplied limit value can be adjusted to the real limit.
ed [Mon, 16 Aug 2010 12:19:36 +0000 (12:19 +0000)]
Mark functions and variables as static.
All these functions and variables are local to this compilation unit, so
there is no reason why we shouldn't mark them static. This slightly
reduces the binary size.
des [Mon, 16 Aug 2010 11:32:20 +0000 (11:32 +0000)]
In setusercontext(), do not apply user settings unless running as the
user in question (usually but not necessarily because we were called
with LOGIN_SETUSER). This plugs a hole where users could raise their
resource limits and expand their CPU mask.
gabor [Sun, 15 Aug 2010 22:15:04 +0000 (22:15 +0000)]
- Revert strlcpy() changes to memcpy() because it's more efficient and
former may be safer but in this case it doesn't add extra
safety [1]
- Fix -w option [2]
- Fix handling of GREP_OPTIONS [3]
- Fix --line-buffered
- Make stdin input imply --line-buffered so that tail -f can be piped
to grep [4]
- Imply -h if single file is grepped, this is the GNU behaviour
- Reduce locking overhead to gain some more performance [5]
- Inline some functions to help the compiler better optimize the code
- Use shortcut for empty files [6]
jilles [Sun, 15 Aug 2010 21:06:53 +0000 (21:06 +0000)]
sh: Fix break/continue/return sometimes not skipping the rest of dot script.
In our implementation and most others, a break or continue in a dot script
can break or continue a loop outside the dot script. This should cause all
further commands in the dot script to be skipped. However, cmdloop() did not
know about this and continued to parse and execute commands from the dot
script.
As described in the man page, a return in a dot script in a function returns
from the function, not only from the dot script. There was a similar issue
as with break and continue. In various other shells, the return appears to
return from the dot script, but POSIX seems not very clear about this.
jh [Sun, 15 Aug 2010 17:49:41 +0000 (17:49 +0000)]
- Check that strtoul(3) succeeds to convert the entire string in a few
places.
- In getasciilabel(), set the disk type only when a valid type is given.
des [Sun, 15 Aug 2010 14:55:32 +0000 (14:55 +0000)]
no-op commit to note that the example given in the previous commit is
a very bad one, since the shift does not actually overflow. This is
a better example (assuming uint64_t = unsigned long long):
andre [Sun, 15 Aug 2010 13:25:18 +0000 (13:25 +0000)]
Fix the interaction between 'ICMP fragmentation needed' MTU updates,
path MTU discovery and the tcp_minmss limiter for very small MTU's.
When the MTU suggested by the gateway via ICMP, or if there isn't
any the next smaller step from ip_next_mtu(), is lower than the
floor enforced by net.inet.tcp.minmss (default 216) the value is
ignored and the default MSS (512) is used instead. However the
DF flag in the IP header is still set in tcp_output() preventing
fragmentation by the gateway.
Fix this by using tcp_minmss as the MSS and clear the DF flag if
the suggested MTU is too low. This turns off path MTU dissovery
for the remainder of the session and allows fragmentation to be
done by the gateway.
Only MTU's smaller than 256 are affected. The smallest official
MTU specified is for AX.25 packet radio at 256 octets.
andre [Sun, 15 Aug 2010 09:30:13 +0000 (09:30 +0000)]
Add more logging points for failures in syncache_socket() to
report when a new socket couldn't be created because one of
in_pcbinshash(), in6_pcbconnect() or in_pcbconnect() failed.
Logging is conditional on net.inet.tcp.log_debug being enabled.
imp [Sun, 15 Aug 2010 08:49:07 +0000 (08:49 +0000)]
Given the lag between introducing the options-compat and fixing the
bug in the config file was long, and merged to stable, we have to bump
the version here so that stable/8 kernels can have their required
version number bumped to make sure the right config is used.
imp [Sun, 15 Aug 2010 08:44:32 +0000 (08:44 +0000)]
Turns out that it is a bad idea to have a missing compat option be a
fatal condition. While it works out really well for diagnosing the
case where you want it, but don't have it, it works really badly for
the case where you don't have it and don't want it. Remove the printf
and exit pair. Replate it with simple return to silently ignore this
condition.
This is needed to fix the COMPAT_IA32 being required in options.* in
stable, but we need to run this change through -current first...
andre [Sat, 14 Aug 2010 21:41:33 +0000 (21:41 +0000)]
When using TSO and sending more than TCP_MAXWIN sendalot is set
and we loop back to 'again'. If the remainder is less or equal
to one full segment, the TSO flag was not cleared even though
it isn't necessary anymore. Enabling the TSO flag on a segment
that doesn't require any offloaded segmentation by the NIC may
cause confusion in the driver or hardware.
Reset the internal tso flag in tcp_output() on every iteration
of sendalot.
andre [Sat, 14 Aug 2010 21:04:27 +0000 (21:04 +0000)]
Change the messages of the ICMP bad port bandwidth limiter from
a kernel printf to a log output with the priority of LOG_NOTICE.
This way the messages still show up in /var/log/messages but no
longer spam the console every other second on busy servers that
are port scanned:
"Limiting open port RST response from 114 to 100 packets/sec"
andre [Sat, 14 Aug 2010 20:40:55 +0000 (20:40 +0000)]
Disable TCP inflight limiter by default.
It was experimental and interferes with the normal congestion control
algorithms by instating a separate, possibly lower, ceiling for the
amount of data that is in flight to the remote host. With high speed
internet connections the inflight limit frequently has been estimated
too low due to the noisy nature of the RTT measurements.
This code gives way for the upcoming pluggable congestion control
framework. It is the task of the congestion control algorithm to
set the congestion window and amount of inflight data without external
interference.
des [Sat, 14 Aug 2010 14:34:36 +0000 (14:34 +0000)]
Simplify expand_number() by combining the (unrolled) loop with the
switch. Since expand_number() does not accept negative numbers, switch
from int64_t to uint64_t; this makes it easier to check for overflow.
bz [Sat, 14 Aug 2010 14:13:44 +0000 (14:13 +0000)]
In rip6_input(), in case of multicast, we might skip the normal processing
and go to the next iteration early if multicast filtering would decide that
this socket shall not receive the data.
Unlock the pcb in that case or we leak the read lock and next time trying
to get a write lock, would hang forever.
PR: kern/149608
Submitted by: Chris Luke (chrisy flirble.org)
MFC after: 3 days
bschmidt [Sat, 14 Aug 2010 09:29:42 +0000 (09:29 +0000)]
Initialize ni_txrate after txparams have been setup. Some drivers
calculate various things prior to association based on ni_txrate and
rely on it being nonzero.
jkim [Fri, 13 Aug 2010 22:08:42 +0000 (22:08 +0000)]
Reset switchtime to zero rather than the current CPU ticker (TSC) value.
It is more appropriate in this context because TSC MSR is reset to zero
when the CPU is restarted from S3 and above. Move acpi_resync_clock() back
to where it was before r211202. It does not make a difference any more.
jkim [Fri, 13 Aug 2010 20:43:19 +0000 (20:43 +0000)]
Enforce ACPI timer as the timecounter hardware before we change sleep state
unless it is the current timer. When we have resumed successfully, restore
the previous timecounter hardware if it was changed earlier. Only the ACPI
timer is guaranteed to increase monotonically between S-state changes.
zec [Fri, 13 Aug 2010 18:17:32 +0000 (18:17 +0000)]
When moving an ethernet ifnet from one vnet to another, destroy the
associated ng_ether netgraph node in the current vnet, and create a
new one in the target vnet.
ume [Fri, 13 Aug 2010 06:39:54 +0000 (06:39 +0000)]
- When there is no room for returning the result, nss backend
have to return ERANGE and terminate with NS_RETURN.
- When gethostbyname_r(3) and the friends end with an error,
set errno to the value nss backend returns, and return errno
value.
imp [Thu, 12 Aug 2010 22:46:31 +0000 (22:46 +0000)]
This depends on ACPI, so only build on i386:i386, amd64:amd64 and
ia64:ia64. It can't possibly work on pc98, or any of the embedded
platforms, since they lack ACPI.
gibbs [Thu, 12 Aug 2010 19:50:40 +0000 (19:50 +0000)]
Allow interrupt driven config hooks to be registered from config hook callbacks.
Interrupt driven configuration hooks serve two purposes: they are a
mechanism for registering for a callback that is invoked once interrupt
services are available, and they hold off root device selection so long
as any configuration hooks are still active. Before this change, it was
not possible to safely register additional hooks from the context of a
configuration hook callback. The need for this feature arises when
interrupts are required to discover new devices (e.g. access to the XenStore
to find para-virtualized devices) which in turn also require the ability
to hold off root device selection until some lengthy, interrupt driven,
configuration task has completed (e.g. Xen front/back device driver
negotiation).
More specifically, the mutex protecting the list of active configuration
hooks is never held during a callback, and static information is used
to ensure proper ordering and only a single callback to each hook even
when faced with registration or removal of a hook during an active run.
jkim [Thu, 12 Aug 2010 17:17:05 +0000 (17:17 +0000)]
Add the half of time-of-day clock resolution when we adjust system time from
time-of-day clock or vice versa. For x86 systems, RTC resolution is one
second and we used to lose up to one second whenever we initialize system
time from RTC or write system time back to RTC. With this change, margin
of error per conversion is roughly between -0.5 and +0.5 second rather
than between -1 and 0 second. Note that it does not take care of errors
from getnanotime(9) (which is up to 1/hz second) or CLOCK_GETTIME() latency.
These are just too expensive to correct and it is not worthy of the cost.
mdf [Thu, 12 Aug 2010 16:54:43 +0000 (16:54 +0000)]
Fix compile. It seemed better to have memguard.c include opt_vm.h in
case future compile-time knobs were added that it wants to use.
Also add include guards and forward declarations to vm/memguard.h.
jh [Thu, 12 Aug 2010 15:29:07 +0000 (15:29 +0000)]
Allow user created symbolic links to cover device files and directories
if the device file appears during or after the link creation.
User created symbolic links are now inserted at the head of the
directory entry list after the "." and ".." entries. A new directory
entry flag DE_COVERED indicates that an entry is covered by a symbolic
link.
PR: kern/114057
Reviewed by: kib
Idea from: kib
Discussed on: freebsd-current (mostly silence)
adrian [Thu, 12 Aug 2010 14:16:57 +0000 (14:16 +0000)]
Fix crunchide to work on sparc64 and perhaps other 64 bit platforms.
I used the wrong type when setting st_name in the symbol table entry
struct. It's an Elf64_Word which is defined as an unsigned 32 bit int
on both 32 and 64 bit platforms.
To make things sensible, define some new macros to use as "word" macros
and use those, rather than simply using the explicit 32 bit macros.
attilio [Thu, 12 Aug 2010 13:46:43 +0000 (13:46 +0000)]
Revert r211176:
As long as interrupts are disabled and there is not explicit call to
sched_add() there can't be any preemption there, thus the calls may be
consistent.
jchandra [Thu, 12 Aug 2010 11:00:45 +0000 (11:00 +0000)]
SMP support in n64.
- Enable KX and UX bits on CPU startup for non-boot CPUs
- Keep the KX bit when in userspace - XTLB handler needs it to access
PCPU data
- revert r210638 partly - we don't need to enable KX on kernel entry
now
jchandra [Thu, 12 Aug 2010 10:09:28 +0000 (10:09 +0000)]
Implement pmap changes suggested by alc@:
1. Move dirty bit emulation code that is duplicted for kernel and user
in trap.c to a function pmap_emulate_modified() in pmap.c.
2. While doing dirty bit emulation, it is not necessary to update the
TLB entry on all CPUs using smp_rendezvous(), we can just update the
TLB entry on the current CPU, and let the other CPUs update their TLB
entry lazily if they get an exception.
jchandra [Thu, 12 Aug 2010 09:15:27 +0000 (09:15 +0000)]
Optimization for pmap_kenter(), call pmap_update_page() only when
necessary. On SMP, pmap_update_page() can be costly as it needs a
a smp_rendezvous().
jchandra [Thu, 12 Aug 2010 09:03:21 +0000 (09:03 +0000)]
Re-arrange the pmap calls that use smp_rendezvous() on SMP, so that their
per-cpu variants are also available to be called. The per-cpu variants
are needed for some later optimizations.
Also remove unnecessary casts, do some style fixes.
kib [Thu, 12 Aug 2010 08:36:23 +0000 (08:36 +0000)]
The buffers b_vflags field is not always properly protected by
bufobj lock. If b_bufobj is not NULL, then bufobj lock should be
held when manipulating the flags. Not doing this sometimes leaves
BV_BKGRDINPROG to be erronously set, causing softdep' getdirtybuf() to
stuck indefinitely in "getbuf" sleep, waiting for background write to
finish which is not actually performed.
Add BO_LOCK() in the cases where it was missed.
In collaboration with: pho
Tested by: bz
Reviewed by: jeff
MFC after: 1 month