Commit Graph

92 Commits

Author SHA1 Message Date
pooka 51dbd2b805 add braces for symmetry 2009-01-04 18:41:36 +00:00
tsutsui 2c79796d32 Use binuptime(9) and emulate 1GiHz (2^30) counter rather than
nanouptime(9) and 1GHz counter to avoid extra rescaling.
Suggested and reviewed by kardel@.
2008-11-25 23:10:43 +00:00
tsutsui 953d0b8986 In machclk functions always emulate 1GHz counter using nanotime(9)
since it has enough resolution via timecounter(9).
Using machine dependent cpu_counter() is not MP safe
and it won't work even on UP with Speedstep etc.

No particular comment on tech-kern, and also closes PR kern/39835.
2008-11-25 15:59:10 +00:00
dyoung de87fe677d *** Summary ***
When a link-layer address changes (e.g., ifconfig ex0 link
02🇩🇪ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address.  (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior.  Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability.  KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR.  In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr.  That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR.  In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR.  For example, pull ..._init() out of any switch
statement that looks like this:

        switch (...->sa_family) {
        case ...:
                ..._init();
                ...
                break;
        ...
        default:
                ..._init();
                ...
                break;
        }

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

        switch (x & (IFF_UP|IFF_RUNNING)) {
        case 0:
                ...
                break;
        case IFF_RUNNING:
                ...
                break;
        case IFF_UP:
                ...
                break;
        case IFF_UP|IFF_RUNNING:
                ...
                break;
        }

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure.  Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls.  In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source.  In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively.  Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset.  Delete unnecessary casts to void *.  Use
sockaddr_in_init() and sockaddr_in6_init().  Compare pointers with
NULL instead of "testing truth".  Replace some instances of (type
*)0 with NULL.  Change some K&R prototypes to ANSI C, and join
lines.
2008-11-07 00:20:01 +00:00
joerg cba79e0ec4 Add support for source address hashhing in ALTQs WFQ. This allows to
easily distribute bandwidth for huge number of clients for incoming
traffic.
2008-09-11 17:58:59 +00:00
gmcgarry c08c4f3cf3 Don't redefine INFINITY. 2008-08-29 00:40:42 +00:00
christos aa389c698d Use more timespecs internally. From Alexander Shishkin and me.
Welcome to 4.99.70, 30 more to go for 100.
2008-07-15 16:18:08 +00:00
yamt fff57c5525 merge yamt-pf42 branch.
(import newer pf from OpenBSD 4.2)

ok'ed by peter@.  requested by core@
2008-06-18 09:06:25 +00:00
ad 50e2f52a23 Use MI cpu_counter() interface. 2008-05-10 15:11:10 +00:00
joerg 3615cf7715 Now that __HAVE_TIMECOUNTER and __HAVE_GENERIC_TODR are invariants,
remove the conditionals and the code associated with the undef case.
2008-01-20 18:09:03 +00:00
ad a2a3828545 machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h 2007-10-19 11:59:34 +00:00
pooka 96356ccdfd init tbr_callout in all cases (hi ad!) 2007-09-04 14:17:16 +00:00
ad 88ab7da936 Merge some of the less invasive changes from the vmlocking branch:
- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
2007-07-09 20:51:58 +00:00
hubertf 708be2b580 Remove duplicate #include <sys/kauth.h>
From: Slava Semushin <php-coder@altlinux.ru>
2007-03-26 22:43:19 +00:00
he ee019f102d Use mtod(m, char*) when doing pointer arithmetic on the result.
Patch from Andreas Wrede.
2007-03-05 22:50:32 +00:00
christos 53524e44ef Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
hubertf 142c2a33ba Remove duplicate #includes, patch contributed in private mail
by Slava Semushin <slava.semushin@gmail.com>.

To verify that no nasty side effects of duplicate includes (or their
removal) have an effect here, I've compiled an i386/ALL kernel with
and without the patch, and the only difference in the resulting .o
files was in shifted line numbers in some assert() calls.
The comparison of the .o files was based on the output of "objdump -D".

Thanks to martin@ for the input on testing.
2007-01-24 13:08:11 +00:00
rpaulo f60d1114d3 Comment out #ident. 2006-12-20 17:03:20 +00:00
christos 168cd830d2 __unused removal on arguments; approved by core. 2006-11-16 01:32:37 +00:00
peter 9cc4e60c56 Don't allow to initialize an interface with MTU smaller than one.
This prevents a divide by zero and fixes PR #21474.

ok tron@
2006-10-28 11:35:17 +00:00
mrg 43ce2a503f avoid shadowing "delay" 2006-10-24 02:48:04 +00:00
elad 0c8de7ee9e Kill another KAUTH_GENERIC_ISSUSER. 2006-10-20 22:04:13 +00:00
elad b8093b8985 Kill some KAUTH_GENERIC_ISSUSER. 2006-10-20 21:55:56 +00:00
peter bc26ed070a Don't enable ALTQ in altq_pfattach. Enabling/disabling of ALTQ is already
done in the pf(4) code (pf_ioctl.c).

From OpenBSD.
2006-10-15 13:17:13 +00:00
peter 463fbff409 Only compile in pf specific code when pf is configured.
Fixes kernel build when ALTQ is configured and pf not.
2006-10-13 09:57:28 +00:00
peter 0f87202ad8 Use another number for JOBS_CLEAR because it clashes with PRIQ_CLEAR. 2006-10-12 21:13:53 +00:00
peter dd191f37f3 Merge the peter-altq branch.
(sync with KAME & add support for using ALTQ with pf(4)).
2006-10-12 19:59:07 +00:00
christos 4d595fd7b1 - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
2006-10-12 01:30:41 +00:00
christos 116c50293c add missing initializer 2006-09-03 04:28:16 +00:00
ad 3029ac48c7 - Use the LWP cached credentials where sane.
- Minor cosmetic changes.
2006-07-21 16:48:45 +00:00
rpaulo 700760bd47 Add ALTQ_PRIQ. 2006-06-19 20:40:48 +00:00
christos c946f0d4db fix timecounter fallout 2006-06-07 23:58:03 +00:00
christos fc6d984beb kauth fallout 2006-05-15 00:05:16 +00:00
elad 874fef3711 integrate kauth. 2006-05-14 21:19:33 +00:00
christos e41fa8a52e Complete the FREE -> free transition and add more NULL checks for malloc
returns. Although these cannot happen because M_WAITOK, the rest of the
code does them already, so this is good for consistency. From Mindaugas
2006-04-23 16:57:22 +00:00
christos d53df8e839 Use malloc/free instead of MALLOC/FREE and M_ZERO instead of memset. 2006-04-23 06:46:39 +00:00
wiz 5d1e8b2745 Fix some typos. 2006-02-25 02:28:55 +00:00
perry fbae48b901 Change "inline" back to "__inline" in .h files -- C99 is still too
new, and some apps compile things in C89 mode. C89 keywords stay.

As per core@.
2006-02-16 20:17:12 +00:00
perry 5f1c88d70d Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete. 2005-12-24 20:06:46 +00:00
christos 95e1ffb156 merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
mrg d53dd8a3f3 rename shadowing variable delay to nowdelay. 2005-07-13 11:28:58 +00:00
christos 57c5a942be add a missing const. 2005-06-06 02:49:15 +00:00
perry 477853c351 nuke trailing whitespace 2005-02-26 22:58:54 +00:00
abs b2ac72dc61 Fix URL to Wu-chang Feng's BLUE 2004-06-26 07:22:11 +00:00
itojun afa9c2cdac hide in-kernel structure by _KERNEL 2004-06-22 12:45:57 +00:00
simonb 9bc855a931 s/the the/the/ (only in sources that aren't regularly imported from
elsewhere).
2004-04-23 02:58:27 +00:00
itojun d2f1c029b9 kill sprintf, use snprintf 2004-04-21 18:40:37 +00:00
wiz 73e1501b98 parameter with two es. From Peter Postma. 2004-02-24 15:22:01 +00:00
wiz e365329be5 Spell length with h after t. Inspired by a commit by brad@openbsd. 2004-02-13 18:02:05 +00:00
wiz d20841bb64 Uppercase CPU, plural is CPUs. 2004-02-13 11:36:08 +00:00