Commit Graph

148604 Commits

Author SHA1 Message Date
Robert Watson
6c7ffe9340 Break at_ifawithnet() into two variants:
- at_ifawithnet(), which acquires an locks it needs and returns an
  at_ifaddr reference.
- at_ifawithnet_locked(), which relies on the caller locking
  at_ifaddr_list, and returns a pointer rather than a reference.

Update various consumers to prefer one or the other, including ether
and fddi output, to properly release at_ifaddr references.

Rework at_control() to manage locking and references in a manner
identical to in_control().

MFC after:	6 weeks
2009-06-24 10:32:44 +00:00
Robert Watson
9087bd7925 Reduce debugging output for netatalk routing events.
MFC after:	3 days
2009-06-24 10:28:30 +00:00
Konstantin Belousov
7a8af8eee2 Initialize the uip to silence gcc warning that seems to sneak in in some
build environments.

Reported by:	alc, bf1783 at googlemail com
2009-06-24 09:26:33 +00:00
Robert Watson
5c66449004 Lock if_addrhead when iterating, and where necessary acquire and release
ifadr references in if_sppp.

MFC after:	6 weeks
2009-06-24 08:53:23 +00:00
Robert Watson
fe0ecfd64d Make stf_getsrcifa6() return a reference to an in6_ifaddr rather than
a pointer, and dispose of the references when no longer needed.

MFC after:	6 weeks
2009-06-24 08:52:09 +00:00
John Hay
65a4957806 Do not stop the loop when an empty or deleted directory entry is found.
Rather just skip over it.
2009-06-24 06:42:13 +00:00
Colin Percival
c17e4d0b6e Add detection of UFS filesystems.
PR:		bin/135565
Submitted by:	Daniel O'Connor
Reviewed by:	randi
MFC after:	1 month
2009-06-24 04:56:13 +00:00
Alan Cox
26f4eea53f The bits set in a page's dirty mask are a subset of the bits set in its
valid mask.  Consequently, there is no need to perform a bit-wise and of
the page's dirty and valid masks in order to determine which parts of a
page are dirty and valid.

Eliminate an unnecessary #include.
2009-06-24 04:45:03 +00:00
Ariff Abdullah
f3bf5def20 Slight comment fix. 2009-06-24 02:01:16 +00:00
Xin LI
47f8598e50 Update SCCS IDs for Berkeley DB 1.86 merge. 2009-06-24 01:15:10 +00:00
Xin LI
fc35a18481 style: operators should appear at the line end if we have to wrap. 2009-06-24 01:14:17 +00:00
Xin LI
66a9ad5d10 Add a note about the implication of secure level setting against kldload,
and cross reference security(7).
2009-06-23 23:56:56 +00:00
Xin LI
efa952cd30 Merge fmtcheck() prototype change.
Obtained from:	NetBSD
2009-06-23 23:53:35 +00:00
Xin LI
eb4bd20c17 Use const instead of __const, and merge the license change from NetBSD.
Obtained from:	NetBSD
2009-06-23 23:52:12 +00:00
Xin LI
b59dcaeeb3 - Use size_t instead of int when appropriate;
- Use C99 sparse initialization.

With these changes ifconfig(8) is WARNS=2 clean.
2009-06-23 23:49:52 +00:00
Xin LI
ad852a184d %.s expects an int as the length specifier, so cast properly. 2009-06-23 23:37:25 +00:00
Xin LI
560daf85d9 Use strlcpy() instead of manually setting the last byte of the array to \0. 2009-06-23 23:34:46 +00:00
Xin LI
884f7c03dd Use strlcpy() instead of explicitly set \0 on the tail of the array. 2009-06-23 23:32:24 +00:00
Xin LI
431586a895 Staticify internal routines. 2009-06-23 23:30:56 +00:00
Xin LI
75d2ea6c50 Merge NetBSD revision 1.14: humanize_number.c is now 2-clause BSD licensed.
(humanize_number.3 intentionally hold back until I make sure why we didn't
merged dehumanize_number(3)).

Obtained from:	NetBSD
2009-06-23 23:27:35 +00:00
Xin LI
ece41d22fe K&R -> ANSI 2009-06-23 23:20:09 +00:00
Xin LI
db995e0027 Use C99 initialization when necessary; apply static to internal rountines.
This makes nfsstat WARNS=3 clean.
2009-06-23 23:18:19 +00:00
Xin LI
4f619e0e57 K&R -> ANSI 2009-06-23 23:17:04 +00:00
Alexander Motin
9f23a6caa4 Make algorithm a bit more bulletproof. 2009-06-23 23:16:37 +00:00
Xin LI
1946089b52 Use getprogname() instead of referencing __progname. 2009-06-23 23:16:00 +00:00
Jilles Tjoelker
689f1cbba5 Quote -x tracing output so it is unambiguous.
It is usually but not always suitable for re-input to the shell.

Approved by:	ed (mentor) (implicit)
2009-06-23 22:53:34 +00:00
Jeff Roberson
50c202c592 Implement a facility for dynamic per-cpu variables.
- Modules and kernel code alike may use DPCPU_DEFINE(),
   DPCPU_GET(), DPCPU_SET(), etc. akin to the statically defined
   PCPU_*.  Requires only one extra instruction more than PCPU_* and is
   virtually the same as __thread for builtin and much faster for shared
   objects.  DPCPU variables can be initialized when defined.
 - Modules are supported by relocating the module's per-cpu linker set
   over space reserved in the kernel.  Modules may fail to load if there
   is insufficient space available.
 - Track space available for modules with a one-off extent allocator.
   Free may block for memory to allocate space for an extent.

Reviewed by:    jhb, rwatson, kan, sam, grehan, marius, marcel, stas
2009-06-23 22:42:39 +00:00
Edwin Groothuis
9cf330555a Remove duplicate if-statement on gmt_is_set in gmtsub().
MFC after:	1 week
2009-06-23 22:28:44 +00:00
David Christensen
d037d7aed6 - Added code to read bootcode firwmare version.
- Created dedicated shared memory access routines.

MFC after:	One week
2009-06-23 22:19:27 +00:00
Jeff Roberson
c76ee82799 - Use cpuset_t and the CPU_ macros in place of cpumask_t so that ULE
supports arbitrary numbers of cpus rather than being limited by
   cpumask_t to the number of bits in a long.
2009-06-23 22:12:37 +00:00
Bjoern A. Zeeb
88d166bf19 Make callers to in6_selectsrc() and in6_pcbladdr() pass in memory
to save the selected source address rather than returning an
unreferenced copy to a pointer that might long be gone by the
time we use the pointer for anything meaningful.

Asked for by:	rwatson
Reviewed by:	rwatson
2009-06-23 22:08:55 +00:00
Alexander Motin
9e9be26906 Fix variable name. 2009-06-23 22:08:25 +00:00
Jilles Tjoelker
e2451bddff Add tests for r194774.
Approved by:	ed (mentor) (implicit)
2009-06-23 22:03:56 +00:00
Jilles Tjoelker
4f6e4215a0 Do not fork for a subshell if it is the last thing this shell is doing
(EV_EXIT). The fork is still done as normal if any traps are active.

In many cases, the fork can be avoided even without this change by using {}
instead of (), but in practice many scripts use (), likely because the
syntax is simpler.

Example:
  sh -c '(/bin/sleep 10)& sleep 1;ps -p $! -o comm='
Now prints "sleep" instead of "sh". $! is more useful this way.
Most shells (dash, bash, pdksh, ksh93, zsh) seem to print "sleep" for this.

Example:
  sh -c '( ( ( (ps jT))))'
Now shows no waiting shell processes instead of four.
Most shells (dash, bash, pdksh, ksh93, zsh) seem to show zero or one.

PR:		bin/74404
Approved by:	ed (mentor) (implicit)
2009-06-23 21:50:06 +00:00
Rick Macklem
73f4ccbd29 When mountd.c parses the nfsv4 root line(s) in /etc/exports, it
allocates data structures that are never linked into the tree or free'd.
As such, mountd would leak memory every time it parsed an nfsv4 root line.
This patch frees up those structures to plug the leak.

Approved by:	kib (mentor)
2009-06-23 21:48:04 +00:00
Alexander Motin
96c5d068d8 Rework r193814:
While general idea of patch was good, it was not working properly due the way
it was implemented. When we are using same timer interrupt for several of
hard/prof/stat purposes we should not send several IPIs same time to other
CPUs. Sending several IPIs same time leads to terrible accounting/profiling
results due to strong synchronization effect, when the second interrupt
handler accounts processing of the first one.
Interlink timer events in a such way, that no more then one IPI is sent for
any original timer interrupt.
2009-06-23 21:45:33 +00:00
Ed Schouten
9801591468 Improve my last commit: use a separate condvar to serialize.
The advantage of using a separate condvar is that we can just use
cv_signal(9) instead of cv_broadcast(9). It makes no sense to wake up
multiple threads. It also makes the TTY code easier to understand.
t_dcdwait sounds totally unrelated.
2009-06-23 21:43:02 +00:00
Joel Dahl
0930c50786 Add one more reference to SEE ALSO. Sort while here.
Submitted by:	ariff
2009-06-23 21:37:12 +00:00
Ed Schouten
2d41cf3a24 Use dcdwait to block threads to serialize writes.
I suspect the usage of bgwait causes a lot of spurious wakeups when
threads are blocked in the background, because they will be woken up
each time a write() call is performed.

Also wakeup dcdwait when the TTY is abandoned.
2009-06-23 21:33:26 +00:00
Joel Dahl
d775d1b346 Bring in a few mdoc/language fixes.
Submitted by:	ru
2009-06-23 21:24:21 +00:00
Konstantin Belousov
c9253e931d Usermode portion of the support for swap allocation accounting:
- update for getrlimit(2) manpage;
- support for setting RLIMIT_SWAP in login class;
- addition to the limits(1) and sh and csh limit-setting builtins;
- tuning(7) documentation on the sysctls controlling overcommit.

In collaboration with:	pho
Reviewed by:	alc
Approved by:	re (kensmith)
2009-06-23 20:57:27 +00:00
Konstantin Belousov
3364c323e6 Implement global and per-uid accounting of the anonymous memory. Add
rlimit RLIMIT_SWAP that limits the amount of swap that may be reserved
for the uid.

The accounting information (charge) is associated with either map entry,
or vm object backing the entry, assuming the object is the first one
in the shadow chain and entry does not require COW. Charge is moved
from entry to object on allocation of the object, e.g. during the mmap,
assuming the object is allocated, or on the first page fault on the
entry. It moves back to the entry on forks due to COW setup.

The per-entry granularity of accounting makes the charge process fair
for processes that change uid during lifetime, and decrements charge
for proper uid when region is unmapped.

The interface of vm_pager_allocate(9) is extended by adding struct ucred *,
that is used to charge appropriate uid when allocation if performed by
kernel, e.g. md(4).

Several syscalls, among them is fork(2), may now return ENOMEM when
global or per-uid limits are enforced.

In collaboration with:	pho
Reviewed by:	alc
Approved by:	re (kensmith)
2009-06-23 20:45:22 +00:00
Jilles Tjoelker
224fbf9fd6 sh: Improve handling of setjmp/longjmp volatile:
- remove ineffective and unnecessary (void) &var; [1]
- remove some unnecessary volatile keywords
- add a necessary volatile keyword
- save the old handler before doing something that could use the saved
  value

Submitted by:	Christoph Mallon [1]
Approved by:	ed (mentor)
2009-06-23 20:45:12 +00:00
Marius Strobl
d54384d976 - Update regarding the support for SBus GEM added in r194763.
- Improve the description a bit and add a reference to vlan(4).
2009-06-23 20:38:35 +00:00
Marius Strobl
9ba2b298df - Initialize the ifnet structure, especially if_dname, before probing
the PHYs as some PHY drivers use it (but probably shouldn't). How
  gem(4) has worked with brgphy(4) on powerpc without this so far is
  unclear to me.
- Introduce a dying flag which is set during detach and checked in
  gem_ioctl() in order to prevent active BPF listeners to clear
  promiscuous mode which may lead to the tick callout being restarted
  which will trigger a panic once it's actually gone.
- In gem_stop() reset rather than just disable the transmitter and
  receiver in order to ensure we're not unloading DMA maps still in
  use by the hardware. [1]
- The blanking time is specified in PCI clocks so we should use twice
  the value when operating at 66MHz.
- Spell some 2 as ETHER_ALIGN and a 19 as GEM_STATUS_TX_COMPLETION_SHFT
  to make the actual intentions clear.
- As we don't unload the peak attempts counter ignore its overflow
  interrupts.
- Remove a stale setting of a variable to GEM_TD_INTERRUPT_ME which
  isn't used afterwards.
- For optimum performance increment the TX kick register in multiples
  of 4 if possible as suggested by the documentation.
- Partially revert r164931; drivers should only clear the watchdog
  timer if all outstanding TX descriptors are done.
- Fix some debugging strings.
- Add a missing BUS_DMASYNC_POSTWRITE in gem_rint().
- As the error paths in the interrupt handler are generally unlikely
  predict them as false.
- Add support for the SBus version of the GEM controller. [2]
- Add some lock assertions.
- Improve some comments.
- Fix some more or less cosmetic issues in the code of the PCI front-end.
- Change some softc members to be unsigned where more appropriate and
  remove unused ones.

Approved by:	re (kib)
Obtained from:	NetBSD (partially) [2], OpenBSD [1]
MFC after:	2 weeks
2009-06-23 20:36:59 +00:00
Jamie Gritton
b97457e2e6 Add a limit for child jails via the "children.cur" and "children.max"
parameters.  This replaces the simple "allow.jails" permission.

Approved by:	bz (mentor)
2009-06-23 20:35:51 +00:00
Andrew Gallatin
bb8ddc66ea - Fix bug where device would loose promisc setting when reset.
- Allow all rss hash modes to be chosen
2009-06-23 20:22:34 +00:00
Robert Watson
8c0fec805f Modify most routines returning 'struct ifaddr *' to return references
rather than pointers, requiring callers to properly dispose of those
references.  The following routines now return references:

  ifaddr_byindex
  ifa_ifwithaddr
  ifa_ifwithbroadaddr
  ifa_ifwithdstaddr
  ifa_ifwithnet
  ifaof_ifpforaddr
  ifa_ifwithroute
  ifa_ifwithroute_fib
  rt_getifa
  rt_getifa_fib
  IFP_TO_IA
  ip_rtaddr
  in6_ifawithifp
  in6ifa_ifpforlinklocal
  in6ifa_ifpwithaddr
  in6_ifadd
  carp_iamatch6
  ip6_getdstifaddr

Remove unused macro which didn't have required referencing:

  IFP_TO_IA6

This closes many small races in which changes to interface
or address lists while an ifaddr was in use could lead to use of freed
memory (etc).  In a few cases, add missing if_addr_list locking
required to safely acquire references.

Because of a lack of deep copying support, we accept a race in which
an in6_ifaddr pointed to by mbuf tags and extracted with
ip6_getdstifaddr() doesn't hold a reference while in transmit.  Once
we have mbuf tag deep copy support, this can be fixed.

Reviewed by:	bz
Obtained from:	Apple, Inc. (portions)
MFC after:	6 weeks (portions)
2009-06-23 20:19:09 +00:00
Robert Noland
abcd328be6 Add some sysctl info so that we can see what is going on with vblanks.
MFC after:	3 days
2009-06-23 20:19:02 +00:00
Sam Leffler
ea158edaa6 Now that we have UARTs running with fast interrupt handlers the ata
driver's i/o ops must be locked to avoid chaos.  Extend the cambria
bus tag to support ata and add a spin lock.  The ata driver is
hacked to use that instead of it's builtin hack for ixp425.  Once
the ata driver is fixed to not be confused about byte order we can
generalize the cambria bus tag code and make it generally useful.

While here take advantage of our being ixp435-specific to remove
delays when switching between byte+word accesses and to eliminate
the 2us delay for the uarts (the spin lock overhead looks to do
this for us).
2009-06-23 19:29:23 +00:00