Commit Graph

65 Commits

Author SHA1 Message Date
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
53485c0add Fix device/softc split. 2008-07-09 18:02:46 +00:00
joerg
ec7aeae0ff - device/softc split 2008-07-09 17:51:21 +00:00
cegger
17dbee905c use device_lookup_private to get softc 2008-06-12 21:46:21 +00:00
cegger
f5bd7c2196 use aprint_*_dev and device_xname 2008-04-06 07:23:57 +00:00
matt
dfba816635 Rototill the vax code. Switch to devicet/PRIV_ALLOC. Cleanup vax autoconf
code.  Move to prototype definitions.  staticfy, constify, avoid casting.
Use device_* accessors.
2008-03-11 05:34:01 +00:00
ad
a2a3828545 machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h 2007-10-19 11:59:34 +00:00
he
446d51fb9b Remove a now-unused local variable. 2007-09-06 08:14:30 +00:00
dyoung
dcd8923429 Change a bazillion occurrences of code resembling this,
error = (cmd == SIOCADDMULTI) ?
	    ether_addmulti(ifr, &sc->sc_ec) :
	    ether_delmulti(ifr, &sc->sc_ec);

	if (error == ENETRESET) {

to this,

	if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {

which does the same thing.

(A bazillion is a very large number.  This seems to make the i386
ALL kernel smaller by 3kB to 4kB.)

Use ifreq_getaddr() twice in es(4).

Whitespace nits.
2007-09-01 07:32:22 +00:00
he
89de8e1eca Cast to char* before doing pointer arithmetic. 2007-03-08 23:17:56 +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
ad
64c0514340 More vax changes. 2007-02-16 13:41:45 +00:00
christos
95e1ffb156 merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
ragge
a4a700a791 Fixes due to cast-qual addition. 2005-06-27 11:05:24 +00:00
perry
f31bd063e9 nuke trailing whitespace 2005-02-27 00:26:58 +00:00
perry
18db93c7f6 de-__P 2005-02-04 02:10:35 +00:00
he
6ef865c900 Include the <sys/bufq.h> header to allow these to compile again. 2004-10-31 12:52:55 +00:00
thorpej
e9818f5b5e When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.
2004-10-30 18:08:34 +00:00
wiz
d20841bb64 Uppercase CPU, plural is CPUs. 2004-02-13 11:36:08 +00:00
he
505125808c Work around gcc 2.95.3's inability to detect that "ret" is initialized.
Will be documented in doc/HACKS, and should be looked at again when
gcc 3.3.2 for vax is ready.
2003-11-06 00:25:50 +00:00
he
6a3911e9ce Make this compile, at least. 2003-11-04 23:19:12 +00:00
christos
808f08e986 Try to make this work. Havard will test it. 2003-11-04 23:01:13 +00:00
agc
aad01611e7 Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22364, verified by myself.
2003-08-07 16:26:28 +00:00
thorpej
d58deb08c2 Use PAGE_SIZE rather than NBPG.
XXX Except in one place which will require more work.
2003-04-01 01:58:14 +00:00
thorpej
24ab4adb9c Use PAGE_SIZE rather than NBPG. 2003-04-01 01:53:40 +00:00
thorpej
b97e4c2136 Merge the nathanw_sa branch. 2003-01-19 16:50:16 +00:00
bouyer
0a5eae1855 ragge said this chip should autopad, so just remove the check for len. 2003-01-15 22:08:08 +00:00
bouyer
84c7763ec2 Use a properly zeroed buffer to pad the packet to ETHER_MIN_LEN
XXX should it be ETHER_MIN_LEN - ETHER_CRC_LEN ?
2003-01-15 21:51:47 +00:00
matt
5d09a84558 Add multiple inclusion protection. 2003-01-06 21:02:18 +00:00
thorpej
72a7af27b0 Use aprint_normal() in cfprint routines. 2003-01-01 00:10:15 +00:00
thorpej
c9b3657ce9 Add trailing ; to CFATTACH_DECL. 2002-10-02 16:33:28 +00:00
thorpej
bacf3a10fa Use CFATTACH_DECL(). 2002-09-30 20:43:55 +00:00
thorpej
f818766afe Declare all cfattach structures const. 2002-09-27 20:31:45 +00:00
wiz
f7d76b1062 bcmp -> memcmp. 2002-05-22 16:03:14 +00:00
lukem
f61cbe7489 add RCSID 2001-11-13 12:51:12 +00:00
wiz
c52d355d71 "wierd" is weird. 2001-08-20 12:20:01 +00:00
thorpej
cb6f78fe5d bcopy -> memcpy 2001-07-18 16:53:52 +00:00
thorpej
c620771702 bzero -> memset 2001-07-18 16:51:39 +00:00
ragge
cae5d5a796 Lock the kernel lock at interrupt enter. 2001-06-04 21:31:28 +00:00
ragge
056e20f2cc Need to get the kernel lock when entering by interrupts. 2001-06-03 15:15:02 +00:00
ragge
667dd41596 Remove ethernet CRC on received packets. 2001-05-27 19:36:06 +00:00
thorpej
67e357f0a9 splimp -> splvm.
This, like all other uses of spl*() in VAX code, needs to be
scrutinized.
2001-04-12 20:38:25 +00:00
thorpej
08afcfb9bd ALTQ'ify. 2000-12-14 06:59:01 +00:00
thorpej
b84f740be0 Move bpfattach()/bpfdetach() calls into ether_ifattach()/ether_ifdetach(). 2000-11-15 01:02:11 +00:00
thorpej
7ca3fb9ef0 Move the check for "promisc + unicast + not for us" into ether_input(),
and change Ethernet drivers to always pass all received frames to
ether_input() (with a few exceptions, which are documented in the
code).
2000-10-01 23:32:39 +00:00
ragge
acb96154d0 More intelligent BI vector assignment. 2000-07-26 12:41:40 +00:00
ragge
8cc5c2c8f1 Rename NODESIZE to BI_NODESIZE. 2000-07-06 17:47:02 +00:00
mrg
b5e0d5686e remove include of <vm/vm.h> 2000-06-28 17:09:41 +00:00
mrg
2f159a1bac remove/move more mach vm header files:
<vm/pglist.h> -> <uvm/uvm_pglist.h>
	<vm/vm_inherit.h> -> <uvm/uvm_inherit.h>
	<vm/vm_kern.h> -> into <uvm/uvm_extern.h>
	<vm/vm_object.h> -> nothing
	<vm/vm_pager.h> -> into <uvm/uvm_pager.h>

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.
2000-06-26 14:20:25 +00:00
matt
2f85fe7adb Adjust to new evcnt stuff. 2000-06-05 00:09:17 +00:00