Commit Graph

25 Commits

Author SHA1 Message Date
ad 0efea177e3 Remove LKMs and switch to the module framework, pass 1.
Proposed on tech-kern@.
2008-11-12 12:35:50 +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 50fb102fe3 use aprint_*_dev and device_xname 2008-04-08 06:12:21 +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
dyoung 6f3852fab4 Constify struct ifnet->if_sadl and every use throughout the tree.
Add if_set_sadl() that both sets the link-layer address length and
replaces the current link-layer address with a new one, and use it
throughout the tree.
2007-12-20 21:08:17 +00:00
lukem 456279df8f use __KERNEL_RCSID() 2007-12-11 12:29:11 +00:00
ad a2a3828545 machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h 2007-10-19 11:59:34 +00:00
dyoung 71e77a61b4 Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).
2007-08-26 22:45:55 +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
elad d5ebb97b46 Consistent usage of KAUTH_GENERIC_ISSUSER. 2007-01-04 18:44:45 +00:00
rittera 26b97f3a17 Added innitialization to bs in ndis_getstate_80211. It was causing a compiler warning. Pointed out by Kulcsar Ferenc 2006-09-11 21:17:18 +00:00
ad 3029ac48c7 - Use the LWP cached credentials where sane.
- Minor cosmetic changes.
2006-07-21 16:48:45 +00:00
rittera 98c1d0c0f5 Replaced some #ifdef NDIS_LKM's which were commenting out debugging
information with #ifdef NDIS_DBG.  Also added a commented out #define NDIS_DBG
to ndis_var.h.
2006-05-29 20:49:03 +00:00
rittera 60d227b1f8 Some general cleaning up of if_ndis.c, and if_ndis_pci.c. Added
#ifdef NDIS_DBG around some printfs, and deleted some commented out code.
2006-05-26 19:27:49 +00:00
elad 2867b68bc3 integrate kauth. 2006-05-14 21:42:26 +00:00
rittera a96342da61 a few cosmetic changes to if_ndisvar.h 2006-04-24 00:10:17 +00:00
rittera 3441c2e772 Replaced all the device_printf's in if_ndis_pci.c with aprint_error() 2006-04-24 00:01:29 +00:00
rittera 03f0a1ac3d Replaced all the device_printf's in if_ndis.c with aprint_error() or
aprint_normal().  Now I just need to go through and do this for the rest of the files.
2006-04-23 22:53:43 +00:00
rittera bad11dd7e0 Replaced the device_printf's in ndis_ticktask() with printf(). For some reason
a uvm fault was occouring here.  I'm still looking in to figuring out why, but
this fixes the problem for now.
2006-04-23 19:30:19 +00:00
rittera 9225a5f961 A number of cosmetic changes to if_ndis.c. A lot of work needs to be done
cleaning up all the NDIS files.
2006-04-23 02:55:04 +00:00
rittera be97fc5a95 A number of minor changes for NDIS. (OK'd by phil)
1. Removed the makeoptions line from arch/i386/conf/GENERIC.  Now
ndis_driver_data.h is simply copied into the kernel build directory instead
of editing the config file to specify its location.

2. Uncommented lines in files.i386 and files.pci related to NDIS.  NDIS will
not be compiled into the kernel unless the two lines are uncommented from
GENERIC (I checked using nm), so there is no reason for this to be commented
out.

3. Added ndiscvt to usr.sbin/Makefile.
2006-04-18 16:49:19 +00:00
rittera a21b75e520 Removed the #include of ndis_driver_data.h, and replaced it with NDIS_DRV_DATA,
so that the location of the ndis_driver_data.h file which is built from
the Windows driver's .inf and .sys files using the ndiscvt utility can be
specified from the kernel configuration file.
2006-03-31 03:20:20 +00:00
rittera ace2baad8b Updated to the latest NDIS code. I added commented out lines in the files
arch/i386/conf/GENERIC, arch/i386/conf/files.i386 and dev/pci/files.pci which
can simply be uncommented to compile NDIS into the kernel.  I'll write some
documentation on this soon.

Note that NDIS is still somewhat experimental.  It is currently tested and
functions relatively well on on two cards:
1. Dell (Broadcom) TrueMobile 1400 Dual Band WLAN Mini-PCI
2. Intel EtherExpress Pro/100
2006-03-31 00:03:57 +00:00
rittera 5197fd087b applied iMil's patch 2006-03-30 23:07:37 +00:00
rittera 35ff82777b Added the original FreeBSD_54 files from sys/dev/if_ndis. 2006-03-30 22:57:56 +00:00