Commit Graph

142 Commits

Author SHA1 Message Date
andvar cdc507f0d2 fix various typos in comment, documentation and log messages. 2022-05-24 20:50:17 +00:00
andvar 3746949308 fix few typos in comments, mainly in word "parameter". 2021-12-31 20:22:48 +00:00
riastradh 84990d4169 altq(9): Fix missing IFNET_LOCK around if_ioctl. 2021-12-31 14:25:47 +00:00
riastradh daeb11daa6 sys: Use if_ioctl wrapper function. 2021-12-31 14:24:50 +00:00
msaitoh 64b8fcaf71 s/failes/fails/ in comment. 2021-12-05 04:43:57 +00:00
christos 59d03a6b31 Remove FreeBSD blocks that did not compile anyway, and use l->l_cred
consistently.
2021-09-21 14:30:15 +00:00
andvar f9faf20aef fix typos in comments, mainly s/extention/extension/ and s/sufficent/sufficient/ 2021-09-03 21:54:58 +00:00
riastradh 30f7ac7ccf sys/altq: Memset zero before copyout.
Just in case of uninitialized padding which would lead to kernel
stack disclosure.  If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
2021-08-30 08:40:31 +00:00
andvar 2e0bf311b3 fix multiplei repetitive typos in comments, messages and documentation. mainly because copy paste code big amount of files are affected. 2021-08-17 22:00:26 +00:00
ozaki-r ef6d7f7d06 altq: fix CBQ with RED and/or pf 2021-07-21 07:34:44 +00:00
ozaki-r 7aed7fcdf7 altq, cbq: apply tweaks for PPP to only PPP interfaces 2021-07-21 06:49:25 +00:00
ozaki-r f5e9a1cfbc altq, cbq: change long to uint64_t for ILP32 archs
PR kern/56319
2021-07-21 06:47:33 +00:00
ozaki-r 6a54d26911 altq, cbq: treat time in nanoseconds
Time granularity in microseconds is sometimes not enough to provide
accurate bandwidth control; actual bandwidth on a capped class
can exceed its limit considerably in some cases.

Treating time in nanoseconds requires the following changes:
- Use timespec instead of timeval
- Use nanotime(9) instead of microtime(9)
- Change the type of some variables, especially *idle, to long
2021-07-21 06:41:22 +00:00
ozaki-r 46a774a5cf altq, cbq: convert ns_per_byte to ps_per_byte
Also the type of variables of it is changed to u_long from int.

This change provides fine-grain resolution of bandwidth.  For example
750 Mbps was treated as 800 Mbps internally because bandwidth was
represented as nanoseconds per byte.  Converting the representation
to picoseconds per byte enables to treat 750 Mbps as-is.

PR kern/56319
2021-07-21 06:33:30 +00:00
ozaki-r 392f41c939 altq, cbq: allow the root class to be default 2021-07-14 08:31:15 +00:00
ozaki-r db26d68b4e altq, cbq: allow no control class 2021-07-14 08:27:59 +00:00
ozaki-r 72f34ae608 altq, cbq: calculate a delay period based on a borrowed class
A delay period was calculated based on a suspended class even if the
class can borrow bandwidth from another class.  In that case a delay
period should be calculated based on a borrowed class.  Otherwise
a borrowing class can't borrow bandwidth correctly.
2021-07-13 08:23:39 +00:00
ozaki-r 6e3d43696b altq, cbq: apply the do-while idiom to TV_* macros 2021-07-13 08:04:31 +00:00
ozaki-r 646783b5af altq, cbq: don't increment the xmit counter of the root class twice wrongly 2021-07-13 07:59:48 +00:00
riastradh 434e200c00 Need opt_inet.h for #ifdef INET, INET6. 2020-03-05 07:46:36 +00:00
msaitoh 40064e2457 s/lenght/length/ 2019-12-26 04:53:11 +00:00
maxv 5c98710094 Remove the 't' argument from m_tag_find(). 2018-11-15 10:23:55 +00:00
mrg 62adeb39c4 simplify priq_class_create(): if the alloc for cl_q fails,
then only clean up required to to free cl.  delete all the
code at err_ret that was probably used in the past, and move
the free + return upon failure earlier.
2018-06-15 08:34:18 +00:00
christos 87fd18f8e5 s/static inline/static __inline/g for consistency. 2018-04-19 21:50:06 +00:00
riastradh a62f05d75e Reject negative indices.
(Would be nice to change the types too, and it's *probably* safe to
replace int by u_int, but I'm reluctant to touch the ioctl
definitions without at least a modicum more thought.  Also one of
them is a u_long, because why not?)

From Ilja Van Sprundel.
2017-07-28 13:58:47 +00:00
riastradh e80123a9be Zero buffers copied to userland to avoid stack disclosure.
From Ilja Van Sprundel.
2017-07-28 13:53:17 +00:00
ozaki-r 0eaf4e5356 Use if_acquire and if_release instead of using psref API directly
- Provide if_release for consistency to if_acquire
- Use if_acquire and if_release for ifp iterations
- Make ifnet_psref_class static
2017-03-14 09:03:08 +00:00
dholland 3419583c5d PR 51553 David Binderman: don't bother counting up backlogged classes
when not doing anything with the results.
2016-11-21 07:15:36 +00:00
knakahara 69c0ff04b9 apply if_start_lock() to L2 callers which call ifp->if_start() of device derivers 2016-06-20 08:30:58 +00:00
ozaki-r fe6d427551 Avoid storing a pointer of an interface in a mbuf
Having a pointer of an interface in a mbuf isn't safe if we remove big
kernel locks; an interface object (ifnet) can be destroyed anytime in any
packet processing and accessing such object via a pointer is racy. Instead
we have to get an object from the interface collection (ifindex2ifnet) via
an interface index (if_index) that is stored to a mbuf instead of an
pointer.

The change provides two APIs: m_{get,put}_rcvif_psref that use psref(9)
for sleep-able critical sections and m_{get,put}_rcvif that use
pserialize(9) for other critical sections. The change also adds another
API called m_get_rcvif_NOMPSAFE, that is NOT MP-safe and for transition
moratorium, i.e., it is intended to be used for places where are not
planned to be MP-ified soon.

The change adds some overhead due to psref to performance sensitive paths,
however the overhead is not serious, 2% down at worst.

Proposed on tech-kern and tech-net.
2016-06-10 13:31:43 +00:00
ozaki-r cef59834c4 Use M_GETCTX and M_SETCTX instead of open-coding rcvif
No functional change.
2016-05-16 09:53:59 +00:00
ozaki-r 040205ae93 Protect ifnet list with psz and psref
The change ensures that ifnet objects in the ifnet list aren't freed during
list iterations by using pserialize(9) and psref(9).

Note that the change adds a pslist(9) for ifnet but doesn't remove the
original ifnet list (ifnet_list) to avoid breaking kvm(3) users. We
shouldn't use the original list in the kernel anymore.
2016-05-12 02:24:16 +00:00
knakahara 40b1061c07 IFQ_ENQUEUE refactor (2/3) : eliminate pktattr argument from altq implemantation 2016-04-20 08:58:48 +00:00
christos 5172ed9e75 Prevent interface deletion from running into an infinite loop when altq closes.
$ cat /etc/altq.conf
interface ppp0 bandwidth 10M priq
class priq ppp0 high_class_ppp NULL priority 1
class priq ppp0 low_class_ppp NULL priority 0 default
filter ppp0 high_class_ppp 0 0 0 0 1
$ ifconfig ppp0 create
$ /etc/rc.d/altqd onestart
$ ifconfig ppp0 destroy
$ pkill altqd
XXX: pullup-7
2016-01-22 18:19:54 +00:00
uebayasi c41ff3d343 Build altq module. 2014-11-17 06:04:01 +00:00
snj f0a7346d21 src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
2014-10-18 08:33:23 +00:00
riastradh a3ea546522 Fix error branches to avoid leaks, noted by maxv@. 2014-08-18 03:14:12 +00:00
dholland f9228f4225 Add d_discard to all struct cdevsw instances I could find.
All have been set to "nodiscard"; some should get a real implementation.
2014-07-25 08:10:31 +00:00
ozaki-r 3745c9bdf3 Lock IFQ operations when NET_MPSAFE
- Introduce NET_MPSAFE
  - not defined by default
- Add ifq_lock to protect ifnet#if_snd
- Initialize ifq_lock and lock IFQ operations
  when NET_MPSAFE

When NET_MPSAFE isn't defined, this modification
doesn't change its behavior and adds trivial
performance overheads.

Discussed with matt@ on tech-net
2014-07-01 10:16:02 +00:00
rmind f7741dab17 - Move IFNET_*() macros under #ifdef _KERNEL.
- Replace TAILQ_FOREACH on ifnet with IFNET_FOREACH().
2014-05-17 20:44:24 +00:00
christos 55e6983cb7 kill sprintf 2014-03-20 20:51:40 +00:00
dholland a68f9396b6 Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
2014-03-16 05:20:22 +00:00
tls 3afd44cf08 First step of random number subsystem rework described in
<20111022023242.BA26F14A158@mail.netbsd.org>.  This change includes
the following:

	An initial cleanup and minor reorganization of the entropy pool
	code in sys/dev/rnd.c and sys/dev/rndpool.c.  Several bugs are
	fixed.  Some effort is made to accumulate entropy more quickly at
	boot time.

	A generic interface, "rndsink", is added, for stream generators to
	request that they be re-keyed with good quality entropy from the pool
	as soon as it is available.

	The arc4random()/arc4randbytes() implementation in libkern is
	adjusted to use the rndsink interface for rekeying, which helps
	address the problem of low-quality keys at boot time.

	An implementation of the FIPS 140-2 statistical tests for random
	number generator quality is provided (libkern/rngtest.c).  This
	is based on Greg Rose's implementation from Qualcomm.

	A new random stream generator, nist_ctr_drbg, is provided.  It is
	based on an implementation of the NIST SP800-90 CTR_DRBG by
	Henric Jungheim.  This generator users AES in a modified counter
	mode to generate a backtracking-resistant random stream.

	An abstraction layer, "cprng", is provided for in-kernel consumers
	of randomness.  The arc4random/arc4randbytes API is deprecated for
	in-kernel use.  It is replaced by "cprng_strong".  The current
	cprng_fast implementation wraps the existing arc4random
	implementation.  The current cprng_strong implementation wraps the
	new CTR_DRBG implementation.  Both interfaces are rekeyed from
	the entropy pool automatically at intervals justifiable from best
	current cryptographic practice.

	In some quick tests, cprng_fast() is about the same speed as
	the old arc4randbytes(), and cprng_strong() is about 20% faster
	than rnd_extract_data().  Performance is expected to improve.

	The AES code in src/crypto/rijndael is no longer an optional
	kernel component, as it is required by cprng_strong, which is
	not an optional kernel component.

	The entropy pool output is subjected to the rngtest tests at
	startup time; if it fails, the system will reboot.  There is
	approximately a 3/10000 chance of a false positive from these
	tests.  Entropy pool _input_ from hardware random numbers is
	subjected to the rngtest tests at attach time, as well as the
	FIPS continuous-output test, to detect bad or stuck hardware
	RNGs; if any are detected, they are detached, but the system
	continues to run.

	A problem with rndctl(8) is fixed -- datastructures with
	pointers in arrays are no longer passed to userspace (this
	was not a security problem, but rather a major issue for
	compat32).  A new kernel will require a new rndctl.

	The sysctl kern.arandom() and kern.urandom() nodes are hooked
	up to the new generators, but the /dev/*random pseudodevices
	are not, yet.

	Manual pages for the new kernel interfaces are forthcoming.
2011-11-19 22:51:18 +00:00
plunky 46d99009d7 rename the altq-defined INFINITY symbol to ALTQ_INFINITY
- it is not infinity
    - it is exposed to userland
    - it causes confusion when #include <math.h> follows
      (I don't know why GCC does not object to redefining the symbol)
2010-04-09 19:32:45 +00:00
dsl e0f6481d6a Move BLUE_STATS to a commented out line since it is always enabled in
the source file. Fixes PR/35390.
2009-12-06 14:03:23 +00:00
mbalmer 124961627e s/the the/the/ 2009-11-22 18:40:26 +00:00
dyoung 1a1d6a2158 Remove code bracketed by #ifdef __FreeBSD__. 2009-08-18 17:20:20 +00:00
tsutsui d779b85d3e Remove extra whitespace added by a stupid tool.
XXX: more in src/sys/arch
2009-04-18 14:58:02 +00:00
cegger e2cb85904d bcopy -> memcpy 2009-03-18 17:06:41 +00:00
dsl 454af1c0e8 Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
2009-03-14 15:35:58 +00:00