NetBSD/sys/netinet6
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
..
ah_aesxcbcmac.c Ansify + add a few comments, from Karl Sjödahl 2007-05-23 17:14:59 +00:00
ah_aesxcbcmac.h Multiple inclusion protection, as suggested by christos@ on tech-kern@ 2005-12-10 23:31:41 +00:00
ah_core.c Ansify + add a few comments, from Karl Sjödahl 2007-05-23 17:14:59 +00:00
ah_input.c Merge the socket locking patch: 2008-04-24 11:38:36 +00:00
ah_output.c Make IPSEC and FAST_IPSEC stats per-cpu. Use <net/net_stats.h> and 2008-04-23 06:09:04 +00:00
ah.h Merge the socket locking patch: 2008-04-24 11:38:36 +00:00
dest6.c Make ip6 and icmp6 stats per-cpu. 2008-04-15 03:57:04 +00:00
esp_aesctr.c Convert many of the uses of __attribute__ to equivalent 2007-12-25 18:33:32 +00:00
esp_aesctr.h Multiple inclusion protection, as suggested by christos@ on tech-kern@ 2005-12-10 23:31:41 +00:00
esp_core.c Ansify + add a few comments, from Karl Sjödahl 2007-05-23 17:14:59 +00:00
esp_input.c Merge the socket locking patch: 2008-04-24 11:38:36 +00:00
esp_output.c Make IPSEC and FAST_IPSEC stats per-cpu. Use <net/net_stats.h> and 2008-04-23 06:09:04 +00:00
esp_rijndael.c __unused removal on arguments; approved by core. 2006-11-16 01:32:37 +00:00
esp_rijndael.h Multiple inclusion protection, as suggested by christos@ on tech-kern@ 2005-12-10 23:31:41 +00:00
esp.h Merge the socket locking patch: 2008-04-24 11:38:36 +00:00
files.ipsec Merge kernel and userland rmd160 and sha2 implementation. 2006-10-27 21:20:48 +00:00
files.netinet6 Refactor in_cksum/in4_cksum/in6_cksum implementations: 2008-01-25 21:12:10 +00:00
frag6.c protocol "drain" functions can be called in interrupt context, so 2008-05-21 17:08:07 +00:00
icmp6_private.h Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
icmp6.c Fix for CVE-2008-3530 from matt@ 2008-10-03 08:23:06 +00:00
in6_cksum.c in6_cksum: use IN6_IS_SCOPE_EMBEDDABLE. 2008-03-10 22:34:40 +00:00
in6_gif.c *** Summary *** 2008-11-07 00:20:01 +00:00
in6_gif.h Merge the socket locking patch: 2008-04-24 11:38:36 +00:00
in6_ifattach.c *** Summary *** 2008-11-07 00:20:01 +00:00
in6_ifattach.h De-__P(). 2007-11-01 20:33:56 +00:00
in6_offload.c Eliminate address family-specific route caches (struct route, struct 2007-05-02 20:40:22 +00:00
in6_offload.h Eliminate address family-specific route caches (struct route, struct 2007-05-02 20:40:22 +00:00
in6_pcb.c Make the sysctl routines take out softnet_lock before dealing with 2008-08-20 18:35:20 +00:00
in6_pcb.h Eliminate address family-specific route caches (struct route, struct 2007-05-02 20:40:22 +00:00
in6_proto.c Merge the socket locking patch: 2008-04-24 11:38:36 +00:00
in6_src.c Make ip6 and icmp6 stats per-cpu. 2008-04-15 03:57:04 +00:00
in6_var.h Make the sysctl routines take out softnet_lock before dealing with 2008-08-20 18:35:20 +00:00
in6.c *** Summary *** 2008-11-07 00:20:01 +00:00
in6.h Convert many of the uses of __attribute__ to equivalent 2007-12-25 18:33:32 +00:00
ip6_etherip.c if_input needs to be called at splnet(). ok by cube. 2008-10-19 23:28:31 +00:00
ip6_etherip.h New EtherIP driver based on tap(4) and gif(4) by Hans Rosenfeld. 2006-11-23 04:07:07 +00:00
ip6_flow.c Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
ip6_forward.c Make IPSEC and FAST_IPSEC stats per-cpu. Use <net/net_stats.h> and 2008-04-23 06:09:04 +00:00
ip6_id.c Fix initializers. 2006-08-30 17:11:53 +00:00
ip6_input.c Change KERNEL_LOCK_ONE (wrong name) to KERNEL_LOCK (the right name). 2008-08-21 15:34:10 +00:00
ip6_mroute.c Convert socket options code to use a sockopt structure 2008-08-06 15:01:23 +00:00
ip6_mroute.h Convert socket options code to use a sockopt structure 2008-08-06 15:01:23 +00:00
ip6_output.c sockopt_getmbuf() may fail, handle that possibility 2008-10-27 20:03:07 +00:00
ip6_private.h Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
ip6_var.h Convert socket options code to use a sockopt structure 2008-08-06 15:01:23 +00:00
ip6protosw.h Convert socket options code to use a sockopt structure 2008-08-06 15:01:23 +00:00
ipcomp_core.c Back out previous. It broke the build. 2008-05-05 13:41:29 +00:00
ipcomp_input.c Back out previous. It broke the build. 2008-05-05 13:41:29 +00:00
ipcomp_output.c Back out previous. It broke the build. 2008-05-05 13:41:29 +00:00
ipcomp.h Make IPSEC and FAST_IPSEC stats per-cpu. Use <net/net_stats.h> and 2008-04-23 06:09:04 +00:00
ipsec_private.h Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
ipsec.c Move uidinfo to its own module in kern_uidinfo.c and include in rump. 2008-10-11 13:40:57 +00:00
ipsec.h Make IPSEC and FAST_IPSEC stats per-cpu. Use <net/net_stats.h> and 2008-04-23 06:09:04 +00:00
Makefile
mld6_var.h De-__P(). 2007-11-01 20:33:56 +00:00
mld6.c *** Summary *** 2008-11-07 00:20:01 +00:00
nd6_nbr.c Generalize previous fix so that both NS and NA packets are checked. 2008-07-31 18:24:07 +00:00
nd6_rtr.c bzero -> memset. Avoid some messy casts to sockaddr by using a 2008-10-24 21:30:34 +00:00
nd6.c *** Summary *** 2008-11-07 00:20:01 +00:00
nd6.h Constify the rt_addrinfo argument to the ifa_rtrequest member 2008-10-24 17:07:33 +00:00
pim6_var.h Make pim6 stats per-cpu. 2008-04-15 05:40:15 +00:00
pim6.h Multiple inclusion protection, as suggested by christos@ on tech-kern@ 2005-12-10 23:31:41 +00:00
raw_ip6.c Convert socket options code to use a sockopt structure 2008-08-06 15:01:23 +00:00
raw_ip6.h Make raw6 stats per-cpu. 2008-04-15 05:13:37 +00:00
route6.c Make ip6 and icmp6 stats per-cpu. 2008-04-15 03:57:04 +00:00
scope6_var.h Replace rote sockaddr_in6 initializations (memset(), set sa6_family, 2007-10-24 06:37:20 +00:00
scope6.c use __KERNEL_RCSID() 2007-12-11 12:29:11 +00:00
udp6_output.c Use sockaddr_in_init(). Wrap lines. No functional change intended. 2008-10-24 22:30:32 +00:00
udp6_private.h Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
udp6_usrreq.c Simplify the interface to netstat_sysctl() and allocate space for 2008-05-04 07:22:14 +00:00
udp6_var.h Merge the socket locking patch: 2008-04-24 11:38:36 +00:00
udp6.h Multiple inclusion protection, as suggested by christos@ on tech-kern@ 2005-12-10 23:31:41 +00:00