Commit Graph

68 Commits

Author SHA1 Message Date
christos 9a5d3f2817 replace bitmask_snprintf(9) with snprintb(3) 2008-12-16 22:35:21 +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
cegger 6a2e2c8cfd use device_lookup_private to get softc 2008-06-11 19:28:52 +00:00
cegger b574865ea4 gpio(4): Extend with open/close to request/release the ppbus(4) on open/close.
ppbus(4): Extend to attach on gpiobus.
From Hans Rosenfeld from tech-kern:
http://mail-index.netbsd.org/tech-kern/2008/04/28/msg001168.html
Hint: Hans sent me this diff which differs in the one from tech-kern in:
- 2-clause license
- sprinkled some consts
2008-04-29 14:07:36 +00:00
martin ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
ad a2249ef75c Make ntp, pmc, reboot, sysarch, time syscalls MPSAFE. 2008-04-21 12:56:30 +00:00
cegger 5db505451b Fix panics at boot and some other misc bugs. From Hans Rosenfeld. 2008-04-18 14:56:40 +00:00
cegger 376411d2dd device_t / softc split. From Hans Rosenfeld. 2008-04-16 09:39:01 +00:00
cegger 7b52308352 Use %zu format specifier for size_t. Fixes build error on shark. 2008-04-15 22:50:33 +00:00
cegger 2ae1aec4f9 Make this build without options LPT_VERBOSE and LPT_DEBUG. From Hans Rosenfeld. 2008-04-15 19:06:16 +00:00
cegger 57f80cdb16 Make this build. From Hans Rosenfeld. 2008-04-15 19:03:26 +00:00
cegger b849cd90e5 device_t / softc split. From Hans Rosenfeld 2008-04-15 15:02:28 +00:00
cegger 1b044f414a use aprint_*_dev and device_xname 2008-04-08 07:35:35 +00:00
tsutsui 40009ad586 struct lpt_softc doesn't have sc_dev in it. Use ppbus_dev.sc_dev. 2008-02-27 12:52:36 +00:00
dyoung 0ba85a6f89 Use device_t and accessors. Use &sc->sc_dev instead of cast to
device_t.  Remove superfluous detach warning.
2008-02-22 23:11:35 +00:00
dyoung 2ccede0a9c Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs.  This will ease extending the kernel and sharing of code
between drivers.

First steps:  Make the signature of ifioctl_common() match struct
ifinet->if_ioctl.  Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.
2008-02-07 01:21:52 +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 0664a0459b Start detangling lock.h from intr.h. This is likely to cause short term
breakage, but the mess of dependencies has been regularly breaking the
build recently anyhow.
2008-01-04 21:17:40 +00:00
perry 9b2b412c19 __FUNCTION__ -> __func__ 2007-12-15 00:39:14 +00:00
ad 6874e511b7 lockmgr -> mutex 2007-12-05 07:58:29 +00:00
ad a2a3828545 machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h 2007-10-19 11:59:34 +00:00
dyoung 2fc102750d Use ifreq_setaddr(), ifreq_getaddr(), sockaddr_in_init(), and
sockaddr_copy().  Constify.  Compare pointers with NULL, not 0.
Don't "test truth" of pointers, but compare with NULL.
2007-09-01 04:32:50 +00:00
drochner bac28a1dbc catch up with recent constification in struct ifnet 2007-04-04 16:31:05 +00:00
he 95f7f99810 Convert sc_inbuf and sc_outbuf from char* to void* to avoid introducing
casts in lpt.c.
2007-03-08 14:45:07 +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
drochner 747abe99e5 add zero initializers to make that compile again 2006-10-24 19:16:50 +00:00
kardel de4337ab21 merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
  time.tv_sec -> time_second
- struct timeval mono_time is gone
  mono_time.tv_sec -> time_uptime
- access to time via
	{get,}{micro,nano,bin}time()
	get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
  Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
  NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html
2006-06-07 22:33:33 +00:00
drochner fa6adb2a78 Disable "1284" device recognition early to work around
a misfeature in the mode switching / 1284 code.
(It refuses to switch the port mode to eg "PS2"
sometimes if no device speaking the PnP protocol
is connected. Should be fixed elsewhere, but this
is a can of worms.)
2006-05-10 10:33:40 +00:00
thorpej ec03de0c39 Use device_pprivate(). 2006-03-29 17:23:56 +00:00
thorpej 5887891a8d Use device_parent(). 2006-03-25 03:44:35 +00:00
rpaulo e868ae92cb PR/32381: Paul Shupak. Convert to ktrace-lwp. 2005-12-25 18:43:31 +00:00
perry 00d6acb4b6 bare asm -> __asm 2005-12-24 22:59:39 +00:00
perry 93124077ae Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete. 2005-12-24 20:27:29 +00:00
christos 95e1ffb156 merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
drochner 46ed4b50c4 s/locdesc_t/int/g 2005-08-26 12:42:11 +00:00
drochner 6e2d003046 more cast-qual and shadow fallout 2005-06-01 18:41:51 +00:00
perry f31bd063e9 nuke trailing whitespace 2005-02-27 00:26:58 +00:00
simonb 3cebd9325e White space nit- don't put a space before/after increment/decrement
operators.
2005-02-11 06:21:21 +00:00
drochner d758c65552 remove the ppbus_print_child() function which is pointless as used here 2004-09-13 12:49:58 +00:00
drochner bbd13d13d1 use interface attribute / locator passing versions
of config_search(),
and some KNF/whitespace cleanup
no functional changes
2004-09-08 20:12:20 +00:00
wiz f05e6f1a3a occured -> occurred. From Peter Postma. 2004-02-24 15:12:51 +00:00
jdolecek 63e9ee7bf5 add Gary Thorpe copyright notice 2004-02-10 21:55:38 +00:00
jdolecek e5d99e330f inform better of what exactly is printed in ppbus_scan_bus(), and only
print anything with PPBUS_VERBOSE || PPBUS_DEBUG
2004-02-10 18:13:12 +00:00
jdolecek 9300becc32 allow setting of interrupt usage, priming and auto LF behaviour
via ioctl; drop the traditional device minor mapping for those in favour
of setting via lptctl(8)

introduce notion of 'control' device (minor bit 0x100 set); ATM this
device always skips the priming, which allows device open even with
disconnected printer

this also changes the default for interrupt use - polling is used
by default now
2004-02-03 21:15:03 +00:00
jdolecek f44dc9ed8b overhaul the ioctl interface to be better suited for extensions and to
reduce number of separate ioctls - have only 'get mode', 'set mode',
'get flags', 'set flags'
2004-02-03 19:57:00 +00:00
jdolecek 9898c64ca9 g/c some unused/write-only/redundant lpt_softc stuff
some style changes in lptwrite() + some printfs adjusted
2004-02-03 18:48:39 +00:00
jdolecek f5e874fba4 make compilable with option DONTPROBE_1284 2004-02-01 17:28:48 +00:00
jdolecek 8081dfaa4b whitespace fixes, make LPTIO_DISABLE_DMA 'succeed' if DMA is not supported 2004-01-30 11:40:55 +00:00
jdolecek bb920938c0 whitespace police 2004-01-28 18:54:32 +00:00
jdolecek f06d010f7f make testbyte[] in lpt_detect() static const 2004-01-28 18:03:45 +00:00