Commit Graph

55446 Commits

Author SHA1 Message Date
Suleiman Souhlal
fdedad764a ffs_mountfs() needs devvp to be locked, so lock it.
Glanced at by:	phk
Tested by:	pjd
MFC after:	3 days
2005-09-02 13:52:55 +00:00
Suleiman Souhlal
2611e5a6a9 Don't unbusy the devfs mount in vfs_mountroot_try() as it gets accessed
and unbusied in devfs_fixup(), which assumes that the devfs mount is
still locked.

Granced at by:	phk
MFC after:	3 days
2005-09-02 13:37:54 +00:00
Warner Losh
9baacb5117 MFp4: kill bogus comment 2005-09-02 03:15:51 +00:00
Pawel Jakub Dawidek
d8b464e51e In case of mac_check_vnode_rename_from() or vn_start_write() failure,
vn_finished_write() should not be called.

Reviewed by:	ssouhlal
MFC after:	3 days
2005-09-01 21:46:33 +00:00
Warner Losh
16e16d771c At some point in the past, we read the PROM by words. Now we read
PROM by bytes.  Adjust the extraction of the MAC address from this data
to reflect this change.

This gets the AX88x90 based PC Cards MAC address working again (my
UMAX Ethernet and Linksys EC2T cards now work).

MFC After: 3 days
2005-09-01 20:08:24 +00:00
John Baldwin
9a1bbc523c Typo in comment. 2005-09-01 16:41:42 +00:00
Warner Losh
b81b5c06b4 Treat resources that are 0xfffff.... as being 'unassigned'.
Reviewed by: jhb
Tested by: Mark Kirkwood
MFC After: 3 days
2005-09-01 02:42:34 +00:00
Pawel Jakub Dawidek
7ee3c044d0 - Add md_mtx lock to protect ID number and list of devices.
- Always check mdnew() return value, as even in !autounit case
  kthread_create() can fail.

Those two changes fix serval panics provked by simple stress test.

Tested by:	Kris The BugMagnet
MFC after:	3 days
2005-08-31 19:45:11 +00:00
Maksim Yevmenkin
82e1becc5f Fix dangling callout problem in the Bluetooth L2CAP code that leads to
panic. The panic happens when outgoing L2CAP connection descriptor is
deleted with the L2CAP command(s) pending in the queue. In this case when
the last L2CAP command is deleted (due to cleanup) and reference counter
for the L2CAP connection goes down to zero the auto disconnect timeout
is incorrectly set. pjd gets credit for tracking this down and committing
bandaid.

Reported by:	Jonatan B <onatan at gmail dot com>
MFC after:	3 days
2005-08-31 18:13:23 +00:00
John Baldwin
7b7b9810bd - Only call txp_release_resources() once if attach fails.
- Set errno to ENXIO instead of 0 in several attach failure cases.
- Setup the interrupt handler at the very end of txp_attach() after
  ether_ifattach().
- Various whitespace fixes in function prototypes.
2005-08-31 18:09:54 +00:00
John Baldwin
7afed9d69a Use if_printf() and device_printf() for printf's and remove the unit number
from the softc.

MFC after:	3 days
2005-08-31 18:03:18 +00:00
Warner Losh
2401a67b34 Update for a few recently discovered Olicom token ring cards:
OC3231 Token Ring + 28.8 modem
	OC3232 Token Ring + 33.6 modem
2005-08-31 17:00:48 +00:00
Yaroslav Tykhiy
eefbcf0e62 Use VLAN_TAG_VALUE() not only to read a dot1q tag
value from an m_tag, but also to set it.  This reduces
complex code duplication and improves its readability.

Alas, we shouldn't rename the macro to VLAN_TAG_LVALUE()
globally because that would cause pain for kernel module
port maintainers and vendors using FreeBSD as their codebase.
Added a clarifying comment instead.

Discussed with:	ru, glebius
X-MFC-After:	6.0-RELEASE (MFC is good just to reduce the diff)
2005-08-31 11:36:50 +00:00
Gleb Smirnoff
a3a90a725c net.graph.ngqfreemax has been deprecated. 2005-08-31 10:51:55 +00:00
Craig Rodrigues
1217bf6a9b FDOPT_NORETRY is an option, and must be compared with fd->options,
not fd->flags.

PR:		kern/85481
Submitted by:	Lev Levinson <llevinson at inbox dot ru>
MFC after:	1 day
2005-08-30 23:12:18 +00:00
Andre Oppermann
fdcc028d11 Changes and cleanups to m_sanity():
o for() instead of while() looping  over mbuf chain
o paren's around all flag checks
o more verbose function and purpose description
o some more style changes

Based on feedback from:	sam
2005-08-30 21:31:42 +00:00
Andre Oppermann
e0068c3a69 Unbreak m_demote() and put back the 'all' flag. Without it we cannot
correctly test for m_nextpkt in an mbuf chain.
2005-08-30 21:14:30 +00:00
John Baldwin
a6c222c739 Various locking fixes and mark MPSAFE:
- Add locked variants of start(), init(), ifmedia_upd(), and poll() and stop
  recursing on the driver lock.
- Add locking to ifmedia_upd() and ifmedia_sts().
- Use callout_*() instead of timeout/untimeout.
- Fix locking in ioctl().

Tested by:	Bob Bishop rb at gid dot co dot uk
MFC after:	3 days
2005-08-30 20:35:08 +00:00
Andre Oppermann
fbe816384a o Remove the 'all' flag from m_demote(). Users can simply call it with
m_demote(m->m_next) if they wish to start at the second mbuf in chain.
o Test m_type with == instead of &.
o Check m_nextpkt against NULL instead of implicit 0.

Based on feedback from:	sam
2005-08-30 20:07:49 +00:00
Craig Rodrigues
86330afe35 Prevent division by zero errors in sc_mouse_move()
by explicitly setting sc->font_width, in the same
places where sc->font_size is set, instead of
relying on the default initialized value of 0 for sc->font_width.

PR:		kern/84836
Reported by:	Andrey V. Elsukov <bu7cher at yandex dot ru>
MFC after:	2 days
2005-08-30 18:58:17 +00:00
Andre Oppermann
e0aec68255 Use the correct mbuf type for MGET(). 2005-08-30 16:35:27 +00:00
Andre Oppermann
71cb29001b Use the correct mbuf type for MGET(). 2005-08-30 16:28:46 +00:00
Andre Oppermann
e72b668b69 Test the mbuf flags against the correct constant. The previous version
worked as intended but only by chance.  MT_HEADER == M_PKTHDR == 0x2.
2005-08-30 16:21:51 +00:00
Tai-hwa Liang
8157976a26 Properly set ic_curchan before calling back to device driver to do channel
switching(ifconfig devX channel Y).  This fix should make channel changing
works again in monitor mode.

Submitted by:	sam
X-MFC-With:	other ic_curchan changes
2005-08-30 14:27:47 +00:00
Gleb Smirnoff
ba26134b19 Fix fallout from revision 1.77, mark outgoing packets with M_VLANTAG flag.
PR:		kern/80646
Reviewed by:	yar
MFC after:	3 days
2005-08-30 14:14:08 +00:00
Gleb Smirnoff
f2ba84d72d Lock down PPTP node, since it has many data structures, that won't survive
parallel ng_pptp_rcvdata():

- Add a per-node mutex.
- Acquire mutex during all ng_pptp_rcvdata() method.
- Make callouts protected by mutex. Now callouts count as
  netgraph writers, but there are plans to allow reader callouts
  for nodes, that have internal locking.
- Acquire mutex in ng_pptp_reset(), which can be triggered
  by a message or node shutdown.

PR:		kern/80035
Tested by:	Deomid Ryabkov <myself rojer.pp.ru>
Reviewed by:	Deomid Ryabkov <myself rojer.pp.ru>
2005-08-30 09:51:54 +00:00
Gleb Smirnoff
5e067d612f Add ng_callout_ini_mtx() macro. 2005-08-30 09:44:54 +00:00
Warner Losh
d121857765 Add back dropped if_media.h include 2005-08-30 05:24:53 +00:00
Nate Lawson
5308b2a64e Eliminate cpufreq levels for two cases that are less than optimal:
1. Walk the absolute list in reverse to prefer duplicated levels that have
a lower absolute setting, i.e. 800 Mhz/50% is better than 1600 Mhz/25% even
though both have the same actual frequency.  This also removes the need to
check for already-modified levels since by definition, those will be added
later in the sorted list.

2. Compare the absolute settings for derived levels and don't use the new
level if it's higher.  For example, a level of 800 Mhz/75% is preferable to
1600 Mhz/25% even though the latter has a lower total frequency.

This work is based on a patch from the submitter but reworked by myself.

Submitted by:	Tijl Coosemans (tijl/ulyssis.org)
2005-08-30 04:45:32 +00:00
Andre Oppermann
4da8443133 Add m_copymdata(struct mbuf *m, struct mbuf *n, int off, int len,
int prep, int how).

Copies the data portion of mbuf (chain) n starting from offset off
for length len to mbuf (chain) m.  Depending on prep the copied
data will be appended or prepended.  The function ensures that the
mbuf (chain) m will be fully writeable by making real (not refcnt)
copies of mbuf clusters.  For the prepending the function returns
a pointer to the new start of mbuf chain m and leaves as much
leading space as possible in the new first mbuf.

Reviewed by:	glebius
2005-08-29 20:15:33 +00:00
Scott Long
d85dcbcd54 Correct previous commit. 2005-08-29 20:06:02 +00:00
Andre Oppermann
a048affba5 Add m_sanity(struct mbuf *m, int sanitize) to do some heavy sanity
checking on mbuf's and mbuf chains.  Set sanitize to 1 to garble
illegal things and have them blow up later when used/accessed.

m_sanity()'s main purpose is for KASSERT()'s and debugging of non-
kosher mbuf manipulation (of which we have a number of).

Reviewed by:	glebius
2005-08-29 19:58:56 +00:00
Andre Oppermann
ed111688e9 Add m_demote(struct mbuf *m, int all) to clean up mbuf (chain) from
any tags and packet headers.  If "all" is set then the first mbuf
in the chain will be cleaned too.

This function is used before an mbuf, that arrived as packet with
m->flags & M_PKTHDR, is appended to an mbuf chain using m->m_next
(not m->m_nextpkt).

Reviewed by:	glebius
2005-08-29 19:45:39 +00:00
Warner Losh
919ccba73e Better comment 2005-08-29 18:45:21 +00:00
Søren Schmidt
f7da27dd85 In ata_mode2str() properly list -1 as UNSUPPORTED. 2005-08-29 18:19:06 +00:00
Warner Losh
667b0824d7 Fix another instance of old info re: miibus 2005-08-29 17:03:31 +00:00
Warner Losh
c3b6bc1a2a Fix obsolete comment.
MFC After: 2 days
2005-08-29 16:48:28 +00:00
Warner Losh
08daf78765 Eliminate bogus seatbelt in wi_cmd. This may have been appropriate
for the spl-era locking, but now that we can have multiple, concurrent
interrupts for multiple wi devices, having a global check to make sure
at most one of them was in wi_cmd no longer makes sense.

MFC After: 2 decifortnight
2005-08-29 15:46:41 +00:00
Yaroslav Tykhiy
e0d020b3c4 Unbreak stand-alone build of the de(4) module. 2005-08-29 15:18:04 +00:00
Gleb Smirnoff
3ff2ed9e6d Plug item leak in case when not all hooks are connected.
Found by:	David Vos <david.vos gmail.com>
2005-08-29 13:47:08 +00:00
Pawel Jakub Dawidek
3b37814794 Use KTR to log allocations and destructions of bios.
This should hopefully allow to track down "duplicate free of g_bio" panics.
2005-08-29 11:39:24 +00:00
Pawel Jakub Dawidek
e37a499443 Add 'depth' argument to CTRSTACK() macro, which allows to reduce number
of ktr slots used. If 'depth' is equal to 0, the whole stack will be
logged, just like before.
2005-08-29 11:34:08 +00:00
Poul-Henning Kamp
80447bf701 Add a missing dev_relthread() call.
Remove unused variable.

Spotted by:	Hans Petter Selasky <hselasky@c2i.net>
2005-08-29 11:14:18 +00:00
Søren Schmidt
84b3b6455f Fix support for the VIA 6421 controller. 2005-08-29 09:01:57 +00:00
Warner Losh
1e1bef8615 Global Village appears to be using 0x018c as its vendor ID, but this
doesn't appear in the official lists, so make a note of that.
2005-08-29 05:46:05 +00:00
Warner Losh
34a1ca7cc2 Simplify names. 2005-08-29 00:05:04 +00:00
Warner Losh
f1c4694df3 Finish conversion to bus space and make ed MP safe.
o Lock ed
o Fix extra newline in probe messages
o Eliminate gone.
o Make detach less-racy.
o Eliminate spl*
o Switch from timeout/untimeout to callout interface.
o Read/write card memory using bus_space calls.
o generalize readmem so that we don't need ifs in the code.
o Fix memory stuff to be consistant.
o Remove OLDCARD compat stuff.
o Mark interrupt as MPSAFE.

# sic, hpp not tested at all
# ISA and PCI attachments lightly tested
2005-08-28 23:56:25 +00:00
Suleiman Souhlal
a6c109d658 Fix a typo in vop_rename_pre() where we ended up using vholdl()
instead of vhold(), even though the vnode interlock is unlocked.

MFC after:	3 days
2005-08-28 23:00:11 +00:00
Lukas Ertl
1f710312a2 Prevent that sync operations can be started when they are already
in progress, and be a bit more user friendly in terms of error
messages returned from the kernel.
2005-08-28 18:16:31 +00:00
Marius Strobl
00d12766ef - Allow for VLAN-sized frames and set IFCAP_VLAN_MTU.
- On resume all registers have to be initialized again like after
  power-on so reset sc_inited in gem_suspend() in order get all of
  the registers set next time gem_init_regs() is called.
- On at least some ERI and GEM revisions GEM_MAC_RX_OVERFLOW happen
  often due to a silicon bug and re-initializing is all we can do
  about these errors so make handling them non-verbose.
- Remove a superfluous memset(3) call in gem_meminit(), all elements
  are initialized to 0 anyway.

MFC after:	1 week
2005-08-28 15:07:30 +00:00
Xin LI
e68796868a Fix kernel build.
Reported by:	tinderbox
2005-08-28 13:11:08 +00:00
Alan Cox
7f1ef325d7 Handle vm_map_wire()'s failure. 2005-08-28 05:38:40 +00:00
Alan Cox
5d3043ce9a Correctly handle vm_map_wire()'s failure. (See also revisions 1.81 and
1.82.)

Reviewed by:	tegge
2005-08-28 04:50:11 +00:00
Alan Cox
45e31b6034 Eliminate an unneeded reference on a vm object. If, in fact, the nearby
vm_map_find() fails, then the excess reference causes the vm object to be
leaked.

Reviewed by:	tegge
2005-08-28 00:24:58 +00:00
Alan Cox
4167396552 Revert the previous change for two reasons: (1) If vm_map_find() succeeds
but vm_map_wire() fails, then a vm object, vm map entries, and kernel_map
free space is leaked and (2) unwiring is handled automatically by
vm_map_remove().

Suggested by:   tegge
2005-08-28 00:19:54 +00:00
Pawel Jakub Dawidek
3ae0e7d8ae Verify length of the data to read as well. 2005-08-28 00:14:21 +00:00
Alan Cox
f564b2d253 MFamd64 revision 1.526
When pmap_allocpte() destroys a 2/4MB "superpage" mapping it does not
 reduce the pmap's resident count accordingly.  It should.
2005-08-27 19:51:14 +00:00
Joseph Koshy
c402059e2e Re-enable sampling on the AMD64. 2005-08-27 16:07:12 +00:00
Joseph Koshy
7ef5ed2bb1 - Special-case NMI handling on the AMD64.
On entry or exit from the kernel the 'alltraps' and 'doreti' code
  used taken by normal traps disables interrupts to protect the
  critical sections where it is setting up %gs.

  This protection is insufficient in the presence of NMIs since NMIs
  can be taken even when the processor has disabled normal interrupts.
  Thus the NMI handler needs to actually read MSR_GBASE on entry to
  the kernel to determine whether a swap of %gs using 'swapgs' is
  needed.  However, reads of MSRs are expensive and integrating this
  check into the 'alltraps'/'doreti' path would penalize normal
  interrupts.

- Teach DDB about the 'nmi_calltrap' symbol.

Reviewed by:	bde, peter (older versions of this change)
2005-08-27 16:03:40 +00:00
Craig Rodrigues
8739cd44d0 Rewrite linux_ifconf() to be more like ifconf() in net/if.c
so that we do not call uiomove() while IFNET_RLOCK() is held.
This eliminates the witness warning:

Calling uiomove() with the following non-sleepable locks held:
exclusive sleep mutex ifnet r = 0 (0xc096dd60) locked @
/usr/src/sys/modules/linux/../../compat/linux/linux_ioctl.c:2170

MFC after:	2 days
2005-08-27 14:44:10 +00:00
Andrew Thompson
68e84b98b2 Fix a panic in softclock() if the interface is destroyed with a bpf consumer
attached.

This is caused by bpf_detachd clearing IFF_PROMISC on the interface which does
a SIOCSIFFLAGS ioctl. The problem here is that while the interface has been
stopped, IFF_UP has not been cleared so IFF_UP != IFF_DRV_RUNNING, this causes
the ioctl function to init() the interface which resets the callouts.

The destroy then completes and frees the softc but softclock will panic on a
dead callout pointer.

Ensure ifp->if_flags matches reality by clearing IFF_UP when we destroy.

Silence from:	rwatson
Approved by:	mlaier (mentor)
MFC after:	3 days
2005-08-27 01:17:42 +00:00
Jung-uk Kim
c94d6dbee5 fix CardBus issue for Compaq R3000 series laptop
Approved by:	anholt (mentor)
2005-08-26 23:39:44 +00:00
Gleb Smirnoff
e3ea67a077 Add newline to debuging printf.
PR:		kern/85271
Submitted by:	Simon Morgan
2005-08-26 15:27:18 +00:00
Gleb Smirnoff
6f683eeed2 Cleanup the reader/writer policy in netgraph(4). Assign
either reader or writer flag on item in the function, that
allocates the item. Do not modify these flags when item is
applied or queued.
  The only exceptions are node and hook overrides - they can
change item flags to writer.
2005-08-26 15:14:33 +00:00
Lukas Ertl
df5175af0f Shuffle around the order in which the components are compiled.
This way, the VINUMDRIVE class is loaded before the VINUM class,
but since geom does the tasting for newly arrived classes
last-in-first-out, the VINUM class tastes first.

This removes the need to call gv_parse_config() in the drive
taste path.
2005-08-26 14:40:32 +00:00
John Baldwin
dbc2a95f40 - Use m_defrag() instead of homerolling our own variant
tulip_mbuf_compress().  If we fail to allocate a new mbuf to copy the
  data into, put the mbuf back in the driver's send queue so that we can
  retry it later rather than throwing the packet away.
- Use m_devget() instead of doing it inline ourselves in the
  TULIP_COPY_RXDATA case.  If we fail to allocate an mbuf to copy the data
  into, don't forget about the original mbuf cluster.  The old code would
  lose the pointer and leak the cluster in that case.  Now it doesn't lose
  it but always sticks the original rx buffer back into the receive ring
  after trying to copy the data out and send it up the stack.  Also, if we
  fail to allocate a new mbuf to copy the data into, log an input error.
  Also, don't combine the priming case with the received-a-packet case to
  make the code flow a bit clearer and easier to follow.
2005-08-26 14:27:38 +00:00
John Baldwin
721be80c83 Remove the el(4) driver for 3Com 3c501 ISA NICs from HEAD as threatened
earlier as no one has stepped up to test recent changes to the driver.
Oddly, the module was actually turned on on ia64 though I'm fairly certain
that no ia64 machine has ever had or will ever have an ISA slot.

Axe borrowed from:	phk
2005-08-26 13:42:04 +00:00
Pawel Jakub Dawidek
9d34e94d14 Verify offset before reading.
MFC after:	2 days
2005-08-26 12:50:08 +00:00
Takanori Watanabe
68a94b0d91 Oops, I forget to add item in files .
Pointed out by: pjd
2005-08-26 12:48:34 +00:00
Takanori Watanabe
7ba4d2eaeb Add NTFS labeling function.
Reviewed by:pjd
2005-08-26 11:35:10 +00:00
Dag-Erling Smørgrav
d09dfa2bfd Two minor optimizations of fdalloc():
- if minfd < fd_freefile (as is most often the case, since minfd is
   usually 0), set it to fd_freefile.

 - remove a call to fd_first_free() which duplicates work already done
   by fdused().

This change results in a small but measurable speedup for processes
with large numbers (several thousands) of open files.

PR:		kern/85176
Submitted by:	Divacky Roman <xdivac02@stud.fit.vutbr.cz>
MFC after:	3 weeks
2005-08-26 11:16:39 +00:00
Alan Cox
8c190069a2 Remedy the following three problems:
1. The amd64 pmap, unlike the i386 pmap, maintains a reference count
   for each page directory (PD) page.  However, in the transformation
   of the i386 pmap into the amd64 pmap, operations, such as
   pmap_copy() and pmap_object_init_pt(), that create 2MB "superpage"
   mappings by setting the PG_PS bit in a PD entry were not modified
   to adjust the underlying PD page's reference count.  Consequently,
   superpage mappings could disappear prematurely.

2. pmap_object_init_pt() could crash or corrupt memory if either the
   virtual address range being mapped crosses a 1GB boundary in the
   virtual address space or nothing is mapped in the 1GB area.

3. When pmap_allocpte() destroys a 2MB "superpage" mapping it does not
   reduce the pmap's resident count accordingly.  It should.  (This
   bug is inherited from i386.)

Discussed with: peter
Reviewed by:    tegge
2005-08-26 05:18:46 +00:00
Alexander Kabaev
83582626ad Unbreak compiles with ACPI_DEBUG. 2005-08-26 02:21:02 +00:00
Paul Saab
8910aa92ae For FreeBSD 4 binaries, when trying to read from a device that does
not exsist, do not have ioctl return an error, but instead set -1
in the data returned to the user.  This allows the HP bios flash
utilities to work without requiring changes to their code.

Reviewed by:	jhb
2005-08-26 01:00:19 +00:00
John Baldwin
4faaaed479 - Remove non-bus-dma code.
- Remove form feed characters.
- Fixup style of function declarations.
- Assume that an mbuf cluster is big enough to hold an ethernet frame.
  (This should really be using m_defrag(), but this diff is just simple
  changes for now.)
2005-08-25 21:06:56 +00:00
Stephan Uphoff
0e7bd54c71 NMI handler should not enable interrupts.
Tested by: kris@
MFC after:	3 weeks
2005-08-25 20:33:43 +00:00
John Baldwin
f8190d8dc8 Major rototill of this driver to add FreeBSD bus-dma support:
- Allocate arrays of metadata for the descriptors in the rx and tx rings
  and change the ring pointers to walk the metadata array rather than the
  actual descriptor rings.  Each metadata object contains a pointer to its
  descriptor, a pointer to any associated mbuf, and a pointer to the
  associated bus_dmamap_t in the bus_dma case.  The mbuf pointers replace
  the tulip_txq and tulip_rxq local ifqueue's in the softc.
- Add lots of KTR trace entries using a local KTR_TULIP level which
  defaults to 0, but can be changed to KTR_DEV at the top of the file
  when debugging.
- Rename tulip_init(), tulip_start(), tulip_ifinit(), and tulip_ifstart()
  to tulip_init_locked(), tulip_start_locked(), tulip_init(), and
  tulip_start(), respectively, to match the convention in other drivers.
- Add a TULIP_SP_MAC() macro to encode two bytes of the MAC address into
  the setup buffer and use that in place of lots of BYTE_ORDER #ifdef's.
  Also, remove an incorrect XXX comment I added earlier, the driver was
  correct (at least it does the same thing dc(4) does).  TULIP_SP_MAC
  was shamelessly copied from DC_SP_MAC() in dc(4).
- Remove the #ifdef'd NetBSD bus-dma code and replace it with FreeBSD
  bus-dma code that not only compiles but even works at runtime.
- Use callout_init_mtx() instead of just callout_init().
- Correct the various wrapper macros for bus_dmamap_sync() for the rx
  and tx buffers to only ask for the sync ops that they actually need.
- Tidy the #ifdef TULIP_COPY_RXDATA code by expanding an #ifdef a bit
  so it becomes easier to read at the expense of a couple of duplicated
  lines of code.  Also, use m_getcl() to get an mbuf cluster rather than
  MGETHDR() followed by MCLGET().
- Maintain the ring free (ri_free) count for the rx ring metadata since
  we no longer have tulip_rxq.ifq_len around to indicate how many mbuf's
  are currently in the rx ring.
- Add code to teardown bus_dma resources when attach fails and generally
  fixup attach to do a better job of cleaning up when it fails.  This
  gets us a good bit closer to possibly having a detach method someday
  and making this driver an unloadable module.
- Add some functions that can be called from ddb to dump the state of
  a descriptor ring and to dump the state of an individual descriptor.
- Various comment grammer and spelling fixes.

I have bus-dma turned on by default, but I've left the non-bus-dma code
around so that it can be turned off to aid in debugging should any problems
turn up later on.  I'll be removing the non-bus-dma code in a subsequent
commit.
2005-08-25 20:12:43 +00:00
Andre Oppermann
b0bd2fdbab Bump __FreeBSD_version for memmem(3). 2005-08-25 19:49:53 +00:00
Maksim Yevmenkin
f41317de66 Make sure ng_fec_init() uses the same calling convention as the rest of
the code, i.e. ng_fec_init() is called with the ifp->if_softc pointer and
NOT with the ifp pointer.

PR:		kern/85239
Reviewed by:	brooks
MFC after:	1 day
2005-08-25 17:00:02 +00:00
Søren Schmidt
071e98cbeb Dont set default mode to ATA_DMA_MAX on devices not capable of DMA. 2005-08-25 15:45:03 +00:00
Gleb Smirnoff
360856f60e - Refuse hashsize of 0, since it is invalid.
- Use defined constant instead of 512.
2005-08-25 13:57:00 +00:00
Robert Watson
7e994955ac De-spl parts of the routing socket code now generally protected
through locking; leave some spl references around code where there
are open questions about global variable references.  Also, add
an XXX regarding locking in sysctl.

MFC after:	3 days
2005-08-25 13:30:04 +00:00
Gleb Smirnoff
510b360fc0 When we have a published ARP entry for some IP address, do reply on
ARP requests only on the network where this IP address belong, to.

Before this change we did replied on all interfaces. This could
lead to an IP address conflict with host we are doing ARP proxy
for.

PR:		kern/75634
Reviewed by:	andre
2005-08-25 13:25:57 +00:00
Hajimu UMEMOTO
b3130703e6 get current temperature from _TMP during passive cooling is active.
it makes CPU freq transition smooth.
2005-08-25 11:31:30 +00:00
Hajimu UMEMOTO
9b96aa9ad7 initialize only ACPI_BUFFER to avoid race condition with passive
cooling thread which refers psv, tc1, tc2 and tsp.  The previous
code made the period where sc->tz_zone.tsp was zero, and it caused
panic at msleep().

Reported by:	keramida
Tested by:	keramida
2005-08-25 10:50:36 +00:00
Gleb Smirnoff
d7f56eabab Backout revision 1.54, because it exposes a worse problem, than
it fixes. I believe the problem lives somewhere outside ng_ksocket,
but until it is found, let the node be working.

PR:		kern/84952
PR:		kern/82413
MFC after:	3 days
2005-08-25 07:21:15 +00:00
Don Lewis
4053cae340 Track all lock relationships instead of pruning direct relationships
if an indirect relationship exists (keep both A->B->C and A->C).
This allows witness_checkorder() to use isitmychild() instead of
the much more expensive isitmydescendant() to check for valid lock
ordering.

Don't do an expensive tree walk to update the w_level values when
the tree is updated.  Only update the w_level values when using the
debugger to display the tree.

Nuke the experimental "witness_watch > 1" mode that only compared
w_level for the two locks.  This information is no longer maintained
at run time, and the use of isitmychild() in witness_checkorder
should bring performance close enough to the acceptable level that
this hack is not needed.

Report witness data structure allocation statistics under the
debug.witness sysctl.

Reviewed by:	jhb
MFC after:	30 days
2005-08-25 03:47:37 +00:00
John Baldwin
00d101cf1f - Remove redundant assertions that the driver lock is not held in attach()
and detach() since mtx_lock() will assert that already since the driver
  lock is not recursive.
- Move the call to callout_init_mtx() before hme_stop() so that the
  callout_stop() in hme_stop() doesn't operate on an uninitialized callout
  structure during attach.

Reported by:	yongari (2)
MFC after:	3 days
2005-08-24 20:28:56 +00:00
R. Imura
f373a82454 - Fix checking range of strings of struct iconv_add_in in libsmb and libkiconv,
- Add checking range of strings to iconv_sysctl_add().

Submitted by:	Rudolf Cejka
2005-08-24 12:38:26 +00:00
Paul Saab
4d3b134633 Remove a KASSERT in the sack path that fails because of a interaction
between sack and a bug in the "bad retransmit recovery" logic. This is
a workaround, the underlying bug will be fixed later.

Submitted by:   Mohan Srinivasan, Noritoshi Demizu
2005-08-24 02:48:45 +00:00
Paul Saab
b24de0e665 Fix up the comment for MAX_SACK_BLKS.
Submitted by:	Noritoshi Demizu
2005-08-24 02:47:16 +00:00
Ian Dowse
f1129b105e Provide the USB device release number along with other parameters
so that devd can match on it. This field was already available to
usbd and is used by a number of usbd.conf entries, so now it is
possible to transfer those entries to devd.conf.

Submitted by:	Anish Mistry
2005-08-23 21:32:49 +00:00
Poul-Henning Kamp
fc377cca01 End the MALLOC_DEFINE macro without the semi-colon, the caller supplies
that.

Spotted by:	Flexelint
2005-08-23 20:31:21 +00:00
Andrew Thompson
dba31bdea1 The mtu check in bridge_enqueue is bogus as the maximum Ethernet frame is
actually 1514, so comparing the mbuf length which includes the Ethernet header
to the interface MTU is wrong.

The check was a little over the top so just remove it.

Approved by:	mlaier (mentor)
MFC after:	3 days
2005-08-23 19:49:00 +00:00
Pawel Jakub Dawidek
a180109fa3 Verify if we can actually read the data at given offset.
Reported by:	Martin <nakal@nurfuerspam.de>
2005-08-23 18:55:38 +00:00
Andre Oppermann
ef8fd90476 Remove unnecessary IPSEC includes.
MFC after:	2 weeks
Sponsored by:	TCP/IP Optimization Fundraise 2005
2005-08-23 14:42:40 +00:00
Max Laier
0bdf5171c8 Don't loop back packets that have been routed by pf. This fixes an endless
loop where the same packet is sent over and over again.

Obtained from:	OpenBSD
Reported by:	Sergey Lapin
Tested by:	Sergey Lapin
MFC after:	7 days
2005-08-23 14:13:17 +00:00
Søren Schmidt
70037ab36a Apply fix for "pr82261 DMA-support on Sparc64 broken"
The Acer chip or wiring that SUN uses has problems that this patch
tries to work around.
Original patch by Marius Strobl, hacked into shape by me..
2005-08-23 08:53:01 +00:00
Don Lewis
ad9f180121 Back out the removal of LK_NOWAIT from the VOP_LOCK() call in
vlrureclaim() in vfs_subr.c 1.636  because waiting for the vnode
lock aggravates an existing race condition.  It is also undesirable
according to the commit log for 1.631.

Fix the tiny race condition that remains by rechecking the vnode
state after grabbing the vnode lock and grabbing the vnode interlock.

Fix the problem of other threads being starved (which 1.636 attempted
to fix by removing LK_NOWAIT) by calling uio_yield() periodically
in vlrureclaim().  This should be more deterministic than hoping
that VOP_LOCK() without LK_NOWAIT will block, which may not happen
in this loop.

Reviewed by:	kan
MFC after:	5 days
2005-08-23 03:44:06 +00:00
Maksim Yevmenkin
db37c09a49 Fix multiple typos in the mutex names. This fixes false positive (and pretty
strange looking too) LORs I have seen on my system. Pointy hat to goes to me.

MFC after:	1 day
2005-08-23 00:50:59 +00:00
Lukas Ertl
fdb9eda84f Correct the check if a plex is accessible in case it is not up.
This makes degraded RAID5 plexes actually work.
2005-08-22 23:24:26 +00:00
Andre Oppermann
23655387e9 o Fix a logic error when not doing mbuf cluster allocation.
o Change an old panic() to a clean function exit.

MFC after:	2 weeks
Sponsored by:	TCP/IP Optimization Fundraise 2005
2005-08-22 22:13:41 +00:00
Alan Cox
7380c1acb5 Pass the PDE from pmap_remove() to pmap_remove_page() so that the latter
procedure doesn't have to recompute it.
2005-08-22 20:02:40 +00:00
Christian S.J. Peron
93e39f0b93 Introduce two new ioctl(2) commands, BIOCLOCK and BIOCSETWF. These commands
enhance the security of bpf(4) by further relinquishing the privilege of
the bpf(4) consumer (assuming the ioctl commands are being implemented).

Once BIOCLOCK is executed, the device becomes locked which prevents the
execution of ioctl(2) commands which can change the underly parameters of the
bpf(4) device. An example might be the setting of bpf(4) filter programs or
attaching to different network interfaces.

BIOCSETWF can be used to set write filters for outgoing packets. Currently if
a bpf(4) consumer is compromised, the bpf(4) descriptor can essentially be used
as a raw socket, regardless of consumer's UID. Write filters give users the
ability to constrain which packets can be sent through the bpf(4) descriptor.

These features are currently implemented by a couple programs which came from
OpenBSD, such as the new dhclient and pflogd.

-Modify bpf_setf(9) to accept a "cmd" parameter. This will be used to specify
 whether a read or write filter is to be set.
-Add a bpf(4) filter program as a parameter to bpf_movein(9) as we will run the
 filter program on the mbuf data once we move the packet in from user-space.
-Rather than execute two uiomove operations, (one for the link header and the
 other for the packet data), execute one and manually copy the linker header
 into the sockaddr structure via bcopy.
-Restructure bpf_setf to compensate for write filters, as well as read.
-Adjust bpf(4) stats structures to include a bd_locked member.

It should be noted that the FreeBSD and OpenBSD implementations differ a bit in
the sense that we unconditionally enforce the lock, where OpenBSD enforces it
only if the calling credential is not root.

Idea from:	OpenBSD
Reviewed by:	mlaier
2005-08-22 19:35:48 +00:00
Joseph Koshy
e753fde4e6 On x86 processors, turn off any 'INTERRUPT' capabilities on PMCs
if the CPU does not have its local APIC enabled.

MFC after:	3 days
2005-08-22 18:20:41 +00:00
Joseph Koshy
744d67975f Return EOPNOTSUPP instead of EINVAL if a PMC allocation request
specifies a PMC capability (e.g., sampling) that is not supported
by hardware.  Return EINVAL early if the PMC class passed in is
not recognized.

MFC after:	3 days
2005-08-22 18:18:20 +00:00
Joseph Koshy
a8eb16c5ea Print PMC capabilities at module load time.
MFC after:	3 days
2005-08-22 17:51:08 +00:00
Andre Oppermann
936cd18dad Add socketoption IP_MINTTL. May be used to set the minimum acceptable
TTL a packet must have when received on a socket.  All packets with a
lower TTL are silently dropped.  Works on already connected/connecting
and listening sockets for RAW/UDP/TCP.

This option is only really useful when set to 255 preventing packets
from outside the directly connected networks reaching local listeners
on sockets.

Allows userland implementation of 'The Generalized TTL Security Mechanism
(GTSM)' according to RFC3682.  Examples of such use include the Cisco IOS
BGP implementation command "neighbor ttl-security".

MFC after:	2 weeks
Sponsored by:	TCP/IP Optimization Fundraise 2005
2005-08-22 16:13:08 +00:00
Andre Oppermann
6b773dff30 Always quote the entire TCP header when responding and allocate an mbuf
cluster if needed.

Fixes the TCP issues raised in I-D draft-gont-icmp-payload-00.txt.

This aids in-the-wild debugging a lot and allows the receiver to do
more elaborate checks on the validity of the response.

MFC after:	2 weeks
Sponsored by:	TCP/IP Optimization Fundraise 2005
2005-08-22 14:12:18 +00:00
Andre Oppermann
d56ea155bd Handle pure layer 2 broad- and multicasts properly and simplify related
checks.

PR:		kern/85052
Submitted by:	Dmitrij Tejblum <tejblum at yandex-team.ru>
MFC after:	3 days
2005-08-22 12:06:26 +00:00
Søren Schmidt
971846e49c Fix problem on Promise "mio" controllers and 48bit mode caused by last commit 2005-08-22 11:38:53 +00:00
Alan Cox
2c15852e1e Change pmap_extract() and pmap_extract_and_hold() to use PG_FRAME rather
than ~PDRMASK to extract the physical address of a superpage from a PDE.
The use of ~PDRMASK is problematic if the PDE has PG_NX set.  Specifically,
the PG_NX bit will be included in the physical address if ~PDRMASK is used.

Reviewed by:	peter
2005-08-22 07:23:51 +00:00
Hajimu UMEMOTO
b1a6f1d8a2 SADB_UPDATE did not return an error when key length is invalid.
Obtained from:	KAME
2005-08-22 07:05:14 +00:00
Joseph Koshy
d4d6be499f Turn off sampling modes on the AMD64 till the time I can track down
the reason for the double fault seen when sampling under load.

MFC after:	3 days
2005-08-22 02:59:51 +00:00
Warner Losh
fa949fc86d if_ral_pccard does not depend on pccard module directly, but rather
depends, like all other pccard drivers, indirectly through kobj on
pccard.  Therefore, it is not appropriate to force pccard to be loaded
when if_ral.ko is loaded.  This makes it possible to load if_ral w/o
loading pccard.ko on, eg, pci only systems.
2005-08-22 00:20:28 +00:00
Suleiman Souhlal
93373c422f Set the mountpoint path in the superblock (fs_fsmnt) at mount-time
so that it appears in the various messages (not cleanly unmounted,
filesystem full, etc). This has been broken since rev 1.261.
2005-08-21 22:06:41 +00:00
Gleb Smirnoff
03b25f5ddc In ng_callout() assert that supplied arguments are non-NULL. 2005-08-21 19:48:51 +00:00
Pawel Jakub Dawidek
1ec75877dc Stop callout before freeing memory, so it won't panic from softclock.
Reported by:	Jonatan B <onatan@gmail.com>
MFC after:	3 days
2005-08-21 19:16:27 +00:00
Pawel Jakub Dawidek
e5cd9375e4 Before freeing memory, assert that there is no pending callout.
MFC after:	3 days
2005-08-21 19:15:14 +00:00
Tor Egge
15da51f73c Don't set the COMPLETE flag in an inodedep structure before the related
inode has been written.
2005-08-21 18:19:06 +00:00
Pawel Jakub Dawidek
dd549194ae By default, when doing crypto work in software, start as many threads
as we have active CPUs and bind each thread to its own CPU.

MFC after:	3 days
2005-08-21 18:12:51 +00:00
Pawel Jakub Dawidek
b8db9f58da Remove stale comment (we now always start worker thread).
MFC after:	3 days
2005-08-21 18:06:35 +00:00
Pawel Jakub Dawidek
4e4aa37e75 mp_ncpus is always (properly) initialized, even on UP kernels, so just use it. 2005-08-21 18:03:31 +00:00
Andre Oppermann
bb10780f9f Commit correct version of the change and note the name of the new
sysctl: net.inet.icmp.quotelen and defaults to 8 bytes.

Pointy hat to:	andre
2005-08-21 15:18:00 +00:00
Andre Oppermann
e875dfb826 Add a sysctl to change to length of the quotation of the original
packet in an ICMP reply.  The minimum of 8 bytes is internally
enforced.  The maximum quotation is the remaining space in the
reply mbuf.

This option is added in response to the issues raised in I-D
draft-gont-icmp-payload-00.txt.

MFC after:	2 weeks
Spnsored by:	TCP/IP Optimizations Fundraise 2005
2005-08-21 15:09:07 +00:00
Damien Bergamini
30feefb1d2 Fix basic rates set for 802.11a/g operating modes. This can significantly
improve transfer rates in 802.11a/g.  Fix IFS settings in ral(4) too.

MFC after:	6 days
2005-08-21 14:16:20 +00:00
Andre Oppermann
a0866c8d4e Add an option to have ICMP replies to non-local packets generated with
the IP address the packet came through in.  This is useful for routers
to show in traceroutes the actual path a packet has taken instead of
the possibly different return path.

The new sysctl is named net.inet.icmp.reply_from_interface and defaults
to off.

MFC after:	2 weeks
2005-08-21 12:29:39 +00:00
Damien Bergamini
fb533d55c6 Enhanced WME (802.11e) support. 2005-08-21 09:52:18 +00:00
Alan Cox
8b78b3dc58 Introduce pmap_pml4e_to_pdpe() and pmap_pdpe_to_pde() and use them to avoid
recomputation of the pml4e and pdpe in pmap_copy(), pmap_protect(), and
pmap_remove().
2005-08-20 18:37:34 +00:00
Robert Watson
6cd8dee3c5 Silence "busy" warnings when unmounting devfs at system shutdown. This
is a workaround for non-symetric teardown of the file systems at
shutdown with respect to the mount order at boot.  The proper long term
fix is to properly detach devfs from the root mount before unmounting
each, and should be implemented, but since the problem is non-harmful,
this temporary band-aid will prevent false positive bug reports and
unnecessary error output for 6.0-RELEASE.

MFC after:	3 days
Tested by:	pav, pjd
2005-08-20 17:12:47 +00:00
Pawel Jakub Dawidek
b866c830d9 Back-out the change from revision 1.14 and allow for '/' in labels again.
Convinced by:	green, Gavin Atkinson, dougb, gordon
MFC after:	1 day
2005-08-20 17:05:47 +00:00
Damien Bergamini
ec01dc2bbc Add some necessary bits for upcoming 802.11e support:
o management of multiple tx rings (up to 4)
o setting of WME IE in association requests

Some features are still missing though, like the possibility to override
the default cwmin/cwmax/asfn values of each tx queues.
2005-08-20 16:49:03 +00:00
Stefan Farfeleder
a1f85d7f83 Move MINSIGSTKSZ from <machine/signal.h> to <machine/_limits.h> and rename
it to __MINSIGSTKSZ.  Define MINSIGSTKSZ in <sys/signal.h>.

This is done in order to use MINSIGSTKSZ for the macro PTHREAD_STACK_MIN
in <pthread.h> (soon <limits.h>) without having to include the whole
<sys/signal.h> header.

Discussed with:		bde
2005-08-20 16:44:41 +00:00
Damien Bergamini
d599e39db8 Remove IEEE80211_C_WPA from capabilities flags. WPA support is not fully
implemented in ipw.

MFC after:	1 week
2005-08-20 15:03:41 +00:00
Damien Bergamini
4ab4bbc6fe Export adapter's internal statistics sysctl even if IPW_DEBUG is not defined.
MFC after:	1 week
2005-08-20 14:41:16 +00:00
Damien Bergamini
94a7a9a24d Export adapter's internal statistics sysctl even if IWI_DEBUG is not defined.
MFC after:	1 week
2005-08-20 14:34:54 +00:00
Damien Bergamini
e0454c269b Don't automatically start scanning in if_init() if IEEE80211_ROAMING_MANUAL
flag is set.

MFC after:	1 week
2005-08-20 14:28:37 +00:00
Stefan Farfeleder
017261026e Remove a stale occurrence of 'alpha' in a comment. 2005-08-20 13:11:17 +00:00
Poul-Henning Kamp
1d45c50ec3 Properly un-giant-trick the cdevsw in fini_cdevsw()
Tripped over by:	Huang wen hui <huang@gddsn.org.cn>
2005-08-20 12:13:51 +00:00
Pawel Jakub Dawidek
efd9ac0dfc Add a __packed keyword to g_eli_metadata struct definition, so
sizeof(struct g_eli_metadata) will return the exact number of bytes needed
for storing it on the disk.
Without this change GELI was unusable on amd64 (and probably other 64-bit
archs), because sizeof(struct g_eli_metadata) was greater than 512 bytes
and geli(8) was failing on assertion.

Reported by:	Michael Reifenberger <mike@Reifenberger.com>
MFC after:	3 days
2005-08-20 10:43:03 +00:00
David Xu
86ef8e2671 Add missing brackets.
Noticed by: stefanf@
2005-08-19 22:30:13 +00:00
Pawel Jakub Dawidek
7a5c26fcbd Allow to change number of iterations for PKCS#5v2. It can only be used
when there is only one key set.

MFC after:	3 days
2005-08-19 22:19:25 +00:00
Pawel Jakub Dawidek
fcd46203c5 - Add a missing period.
- Fix number of spaces.

MFC after:	3 days
2005-08-19 22:16:26 +00:00
Pawel Jakub Dawidek
a95452ee8d Avoid code duplication and implement bitcount32() function in systm.h only.
Reviewed by:	cperciva
MFC after:	3 days
2005-08-19 22:10:19 +00:00
David Xu
8c6d7a8db8 Fix a LOR between sched_lock and sleep queue lock. 2005-08-19 13:35:34 +00:00
David Xu
f8ec133ed0 Move up code for testing KEF_HOLD to avoid ke_cpu being changed unexpectly
for PRI_ITHD and PRI_REALTIME threads.
2005-08-19 11:51:41 +00:00
Alan Cox
eb3d4a39fd Correct a performance bug in revision 1.462. The effect of the bug is to
execute the outer loop in procedures such as pmap_protect() many more times
than necessary.

Reviewed by:	tegge
2005-08-19 07:25:40 +00:00
Colin Percival
4f9dc74288 Pad the strings sccs[], version[], and osrelease[] up to a minimum of
128 bytes, 256 bytes, and 32 bytes respectively.  This makes it much
easier to identify when two kernels are identical apart from a version
number bump (as often happens on security branches).

Discussed on:	freebsd-arch, in May 2005
2005-08-19 01:49:15 +00:00
Christian S.J. Peron
4ddfb5312a Add missing braces around bpf_filter which were missed when I
merged the bpfstat code.

Pointed out by:	iedowse
Pointy hat to:	csjp
MFC after:	3 days
2005-08-18 22:30:52 +00:00
Andrew Thompson
23e7643185 Mark the callouts as MPSAFE as if_bridge has been giant-free since day 1.
Use the SMP friendly callout_init_mtx() while we are here.

Approved by:	mlaier (mentor)
MFC after:	3 days
2005-08-18 20:17:00 +00:00
John Baldwin
997452064e Various fixups to locking:
- Remove a lot of superfluous locking during attach.  There is no need
  to lock access to the driver until some other thread has a way of getting
  to it.  For ethernet drivers the other ways include registering an
  interrupt handler via bus_setup_intr(), calling ether_ifattach() to hook
  into the network stack, and kicking off a callout-driven timer via
  callout_reset().
- Use callout_* rather than timeout/untimeout.
- Break out of xl_rxeof() if IFF_DRV_RUNNING is clear after ifp->if_input
  returns to handle the case where the interface was stopped while we were
  passing a packet up the stack.  Don't call xl_rxeof() in xl_rxeof_task()
  unless IFF_DRV_RUNNING is set.  With these fixes in place, any
  outstanding task will gracefully terminate as soon as it gets a chance to
  run after the interface has been stopped via xl_stop().  As a result,
  taskqueue_drain() is no longer required in xl_stop().  The task is still
  drained in detach() however to make sure that detach() can safely destroy
  the driver mutex at the end of the function.
- Lock the driver lock in the ifmedia callouts and don't lock across
  ifmedia_ioctl() in xl_ioctl().

Note: glebius came up with most of (3) as well independently.  I took a
rather roundabout way of arriving at the same conclusion.

MFC after:	3 days
2005-08-18 19:24:30 +00:00
John Baldwin
c8b27aca43 Fixup locking and mark MPSAFE:
- Add locked versions of start and init.  The SRM_MEDIA code in dc_init()
  stayed in dc_init() instead of moving to dc_init_locked() to make the
  locking saner.
- Use callout_init_mtx().
- Fixup locking in detach and ioctl.
- Lock the driver in the ifmedia callouts.
- Don't recurse on the driver lock.
- De-spl.

MFC after:	3 days
2005-08-18 19:10:07 +00:00
Brooks Davis
dc7c539e33 When we started calling if_findindex() from if_alloc() with an empty
struct ifnet most of if_findindex() become a complex no-op.  Remove it
and replace it with a corrected version of the four line for loop it
devolved to plus some error handling.  This should probably be replaced
with subr_unit at some point.

Switch from checking ifaddr_byindex to ifnet_byindex when looking for
empty indexes.  Since we're doing this from if_alloc/if_free, we can
only be sure that ifnet_byindex will be correct.  This fixes panics when
loading the ef(4) module.  The panics were caused by the fact that
if_alloc was called four time before if_attach was called and thus
ifaddr_byindex was not set and the same unit was allocated again.  This
in turn caused the first if_attach to fail because the ifp was not the
one in ifnet_byindex(ifp->if_index).

Reported by:	"Wojciech A. Koszek" <dunstan at freebsd dot czest dot pl>
PR:		kern/84987
MFC After:	1 day
2005-08-18 18:36:40 +00:00
John Baldwin
2a3e25a07f Fixup locking for sf(4) and mark MPSAFE:
- Add locked variants of start, init, and ifmedia_upd.
- Use callout_* instead of timeout/untimeout.
- Don't recurse on the driver lock.
- Fixup locking in ioctl.
- Lock the driver lock in the ifmedia handlers rather than across
  ifmedia_ioctl().

Tested by:	brueffer
MFC after:	3 days
2005-08-18 17:09:16 +00:00
Hajimu UMEMOTO
1fea6ce7dd - don't forget to save freqency when priority is raised.
- nuke redundant variable initialization.
2005-08-18 16:41:25 +00:00
Hajimu UMEMOTO
5f36393468 don't forget to update curr_priority. even when frequency is
not changed, priority may be changed.
2005-08-18 16:08:56 +00:00
Yaroslav Tykhiy
252b6fe8b2 Define the target for opt_compat.h only if KERNBUILDDIR
is not defined, so that the module will get the
compatibility options from the current kernel configuration
if built with the latter, not with the world.
[Some other modules seem in need of fixing WRT this, too.]

Add more compatibility options found in GENERIC to the default
opt_compat.h.  While not all of them are used in the procfs code,
we can't tell for sure if the system .h files don't need them either,
so let's stay on the safe side.

Submitted by:	kensmith
Reviewed by:	ru
2005-08-18 14:50:08 +00:00
John Baldwin
5d2f4de5da Add aliases for atomic operations on 64-bit integers just like other
64-bit platforms.

MFC after:	1 week
2005-08-18 14:36:47 +00:00
Maxim Sobolev
536fde3465 In re_shutdown() mark interface as down since otherwise we will panic if
interrupt comes in later on, which can happen in some uncommon cases.

Another possible fix is to call re_detach() instead of re_stop(), like
ve(4) does, but I am not sure if the latter is really RTTD, so that stick
with this one-liner for now.

PR:		kern/80005
Approved by:	silence on -arch, no reply from selected network gurus
2005-08-18 14:29:01 +00:00
Yaroslav Tykhiy
421298311a Don't break local style. 2005-08-18 14:28:20 +00:00
Pawel Jakub Dawidek
e6d944d7c3 Fix bogus check. It was possible to panic the kernel by giving 0 length.
This is actually a local DoS, as every user can use /dev/crypto if there
is crypto hardware in the system and cryptodev.ko is loaded (or compiled
into the kernel).

Reported by:	Mike Tancsa <mike@sentex.net>
MFC after:	1 day
2005-08-18 11:58:03 +00:00
SUZUKI Shinsuke
2af9b91993 added a missing unlock (just do the same thing as in netinet/raw_ip.c)
Obtained from: KAME
MFC after: 3 days
2005-08-18 11:11:27 +00:00
Gleb Smirnoff
1ae954096e In order to support CARP interfaces kernel was taught to handle more
than one interface in one subnet. However, some userland apps rely on
the believe that this configuration is impossible.

Add a sysctl switch net.inet.ip.same_prefix_carp_only. If the switch
is on, then kernel will refuse to add an additional interface to
already connected subnet unless the interface is CARP. Default
value is off.

PR:			bin/82306
In collaboration with:	mlaier
2005-08-18 10:34:30 +00:00
Ian Dowse
4832a19173 Add a "comconsole_speed" loader variable that can be used to change
the serial console speed (i386 and amd64 only). If the previous
stage boot loader requested a serial console (RB_SERIAL or RB_MULTIPLE)
then the default speed is determined from the current serial port
speed. Otherwise it is set to 9600 or the value of BOOT_COMCONSOLE_SPEED
at compile time.

This makes it possible to set the serial port speed once in
/boot.config and the setting will propagate to boot2, loader and
the kernel serial console.
2005-08-18 01:39:43 +00:00
Ian Dowse
a00a259113 Add the ability to specify the boot2 serial console speed in
/boot.config or on the "boot:" prompt line via a "-S<speed>" flag,
e.g. "-h -S19200". This adds about 50 bytes to the size of boot2
and required a few other small changes to limit the size impact.
This changes only affects boot2; there are further loader changes
to follow.
2005-08-18 00:42:45 +00:00
Pawel Jakub Dawidek
ef0a6e203b Add VIA/ACE "PadLock" support as a crypto(9) driver.
HW donated by:			Mike Tancsa <mike@sentex.net>
Most of the code obtained from:	OpenBSD
MFC after:			3 days
2005-08-18 00:30:22 +00:00
Craig Rodrigues
a9d726bd18 Rename variables:
r_gdt -> saved_gdt
r_idt -> saved_idt
r_ldt -> saved_ldt

in order to prevent clashes with variables with same names
defined in <machine/segments.h>.  This fixes compilation of this
file with GCC 4.0.

Reviewed by:	njl
2005-08-18 00:28:25 +00:00
Brooks Davis
d3c497e1c8 Remove an unnecessicary bzero that was zeroing the softc's struct ifnet
pointer.

Submitted by:	brueffer
Reviewed by:	dfr
2005-08-17 18:53:06 +00:00
John Baldwin
8a8573fdb2 - Use htole32() instead of using bswap32() conditional on #if BYTE_ORDER.
- Don't set IFF_ALLMULTI in our ifnet's if_flags if we end up allowing
  all multicast due to limits in the MAC receive filters in hardware.

Requested by:	rwatson (2)
2005-08-17 17:46:51 +00:00
John Baldwin
6da5b383f1 Remove the unused TULIP_CSR_{READ,WRITE}BYTE macros. 2005-08-17 17:45:19 +00:00
John Baldwin
f512b596a8 Use callout_init_mtx() to simplify the stats callout.
MFC after:	3 days
2005-08-17 17:44:58 +00:00
John Baldwin
9eda9d7ac5 Add callout_drain()'s to foo_detach() after calling foo_stop() to make sure
that if softclock is running on another CPU and is blocked on our driver
lock, we will wait until it has acquired the lock, seen that it was
cancelled, dropped the lock, and awakened us so that we can safely destroy
the mutex.

MFC after:	3 days
2005-08-17 17:44:32 +00:00
John Baldwin
c98ae70c21 Fix locking in el(4) and mark mpsafe.
- Add locked variants of el_init and el_start.
- Don't initialize the mutex and lock it during el_probe().
- Do initialize the mutex during attach.  (el_probe() did destroy the mutex
  to cleanup, so this meant the driver was always using a destroyed mutex
  when it was running.)
- Setup the interrupt handler after ether_ifattach().
- Fix locking in el_detach() and el_ioctl().

Note: Since I couldn't actually find anyone with this hardware, I'm going
ahead and committing these changes so they won't be lost.  I'll remove the
driver in a week (real purpose of the MFC after below) unless someone pipes
up to test this.

MFC after:	1 week
Tested by:	gcc(1)
2005-08-17 17:36:47 +00:00
Hajimu UMEMOTO
c219fd0c5e don't raise cpu speed over the value when passive cooling is in
effect.  since CPU speed is restored by degrees, we cannot use
the facility of saving cpu speed by CPUFREQ_set() effectively.
so, we need to save the value when passive cooling is in effect.

Repoeted by:	Kevin Oberman <oberman__at__es.net>
2005-08-17 17:01:25 +00:00
Hajimu UMEMOTO
5d52565396 - fix race condition using sx lock.
- use TAILQ_FOREACH() for readability.

Suggested by:	jhb
2005-08-17 16:46:55 +00:00
Pawel Jakub Dawidek
dddd1d537a Always run dedicated kernel thread (even when we have hardware support).
There is no performance impact, but allows to allocate memory with
M_WAITOK flag.
As a side effect this simplify code a bit.

MFC after:	3 days
2005-08-17 15:25:57 +00:00
Pawel Jakub Dawidek
bf71eaacf1 We should now return 0. 2005-08-17 15:12:34 +00:00
Søren Schmidt
85047b1b0c Add support for working around controllers that cannot do DMA in 48bit mode.
The workaround use PIO mode above ~137GB to allow using the disk.
Add the Acer chips with rev < 0xc4 as first candidate.
2005-08-17 15:00:33 +00:00
Søren Schmidt
fb235b243c Use the bio field instead of the driver field as intended. 2005-08-17 14:50:18 +00:00
John Baldwin
f68d1644f8 Use device_printf() and if_printf() and remove ste_unit from the softc. 2005-08-17 14:37:39 +00:00
Pawel Jakub Dawidek
d1dca8a818 Even if crypto_dispatch() return an error, request is not canceled and
our callback will still be called, just to tell us that requested
failed...

Reported by:	Mike Tancsa <mike@sentex.net>
MFC after:	3 days
2005-08-17 14:34:52 +00:00
John Baldwin
45f3f78ced Catch up to ic_curchan changes by making the same change here that was made
in ipw(4) in the earlier ic_curchan mega commit.

Submitted by:	Øyvind Kolbu oyvind at kolbu dot ws
Tested by:	Stefan Ehmann shoesoft at gmx dot net
2005-08-17 14:08:52 +00:00
Pawel Jakub Dawidek
2be2b2eab5 We don't need to clear allocated memory. This will speed-up things a bit.
MFC after:	3 days
2005-08-17 14:08:50 +00:00
Ian Dowse
65ed954554 In the ufsdirhash_build() failure case for corrupted directories
or unreadable blocks, make sure to destroy the mutex we created.
Also fix an unrelated typo in a comment.

Found by:	Peter Holm's stress tests
Reviewed by:	dwmalone
MFC after:	3 days
2005-08-17 08:48:42 +00:00
Poul-Henning Kamp
516ad423b1 Handle device drivers with D_NEEDGIANT in a way which does not
penalize the 'good' drivers:  Allocate a shadow cdevsw and populate
it with wrapper functions which grab Giant
2005-08-17 08:19:52 +00:00
Pawel Jakub Dawidek
12e755355b Assert proper key size also in userland by defining KASSERT in !_KERNEL case. 2005-08-17 07:59:07 +00:00
Poul-Henning Kamp
a07b0febaa In vop_stdpathconf(ap) also default for _PC_NAME_MAX and _PC_PATH_MAX. 2005-08-17 06:59:23 +00:00
Christian S.J. Peron
8677689134 Ensure that file flags such as schg, sappnd (and others) are honored
by md(4). Before this change, it was possible to by-pass these flags
by creating memory disks which used a file as a backing store and
writing to the device.

This was discussed by the security team, and although this is problematic,
it was decided that it was not critical as we never guarantee that root will
be restricted.

This change implements the following behavior changes:

-If the user specifies the readonly flag, unset write operations before
 opening the file. If the FWRITE mask is unset, the device will be
 created with the MD_READONLY mask set. (readonly)
-Add a check in g_md_access which checks to see if the MD_READONLY mask
 is set, if so return EROFS
-Do not gracefully downgrade access modes without telling the user. Instead
 make the user specify their intentions for the device (assuming the file is
 read only). This seems like the more correct way to handle things.

This is a RELENG_6 candidate.

PR:		kern/84635
Reviewed by:	phk
2005-08-17 01:24:55 +00:00
Colin Percival
751a4770f7 Unbreak the world build (in sbin/gbde). This file is used by both
kernel and world, so KASSERT() needs to be wrapped within an #ifdef
_KERNEL / #endif pair.

Reported by:	krion, tinderbox
2005-08-17 00:24:20 +00:00
John Baldwin
ca5fc32d02 Fixup locking in if_my(4) and mark it MPSAFE:
- Add locked variants of my_start() and my_init().
- Assert that the lock is held in several places rather than recursing.
- Overhaul failure case handling in my_attach() so that it will actually
  clean up completely in each of the failure cases.
- Setup the interrupt after ether_ifattach() in my_attach().
- Remove unused callout handle from softc.
- Free the metadata for the descriptors my_in detach() (we leaked it
  before).
- Fix locking in my_ioctl().
- Remove spls.

Tested by:	brueffer
MFC after:	3 days
2005-08-16 20:39:30 +00:00
Poul-Henning Kamp
52d71e1a85 remove stale comments 2005-08-16 20:03:29 +00:00
Hajimu UMEMOTO
961f7f911f Save cpu level only when priority is greater than PRIO_USER
to make CPUFREQ_SET(NULL, prio) work.
TODO: implement saved_level as stack.

Reviewed by:	njl
2005-08-16 20:03:08 +00:00
Hajimu UMEMOTO
1c44678637 avoid exclusive sleep mutex. 2005-08-16 19:49:10 +00:00
Poul-Henning Kamp
b3740d656f Remove stale comment. 2005-08-16 19:47:42 +00:00
Poul-Henning Kamp
31cc57cdbd Collect the devfs related sysctls in one place 2005-08-16 19:25:02 +00:00
Poul-Henning Kamp
9c0af1310c Create a new internal .h file to communicate very private stuff
from kern_conf.c to devfs.

For now just two prototypes, more to come.
2005-08-16 19:08:01 +00:00
Pawel Jakub Dawidek
36c51ae068 Check key size for rijndael, as invalid key size can lead to kernel panic.
It checked other algorithms against this bug and it seems they aren't
affected.

Reported by:	Mike Tancsa <mike@sentex.net>
PR:		i386/84860
Reviewed by:	phk, cperciva(x2)
2005-08-16 18:59:00 +00:00
John Baldwin
207377b25e Clarify a comment. 2005-08-16 18:15:17 +00:00
Brooks Davis
7cf30146f0 - Move IF_ADDR_LOCK_DESTROY(ifp) from if_free to if_free_type.
- Add a note that additions should be made to if_free_type and not
  if_free to help avoid this in the future.

This apparently fixes a use after free in if_bridge and may fix bugs
in other direct if_free_type consumers.

Reported by:	thompsa
2005-08-16 17:02:35 +00:00
Lukas Ertl
664a97517f Make it possible to remove stale, left-over subdisks. 2005-08-16 15:12:44 +00:00