Commit Graph

1145 Commits

Author SHA1 Message Date
christos
461a86f9bd merge christos-time_t 2009-01-11 02:45:45 +00:00
yamt
b1fea83762 remove extra semicolons. 2009-01-03 03:43:21 +00:00
cegger
dcf705893e use M_ZERO on malloc() and remove subsequent bzero(). 2008-12-19 18:49:37 +00:00
cegger
9b87d582bd kill MALLOC and FREE macros. 2008-12-17 20:51:31 +00:00
pooka
c6e7028d1c Make dom_maxrtkey of inet/inet6domain the size of the ip_encap pack
structures.  This is far from optimal, but gets rid of iffy
#ifdef INET in radix.c.  The radix bonsai still needs lots of love
before loading domains dynamically is possible...
2008-11-25 18:28:05 +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
plunky
8903ff8350 sockopt_getmbuf() may fail, handle that possibility 2008-10-27 20:03:07 +00:00
dyoung
420368fa25 Use sockaddr_in_init(). Wrap lines. No functional change intended. 2008-10-24 22:30:32 +00:00
dyoung
74264e2e40 bzero -> memset. Avoid some messy casts to sockaddr by using a
union of sockaddr_in6 and sockaddr.  No functional change intended.
2008-10-24 21:30:34 +00:00
dyoung
cf969cfa5a Constify the rt_addrinfo argument to the ifa_rtrequest member
function of struct ifaddr.
2008-10-24 17:07:33 +00:00
dyoung
ee1bfcb3e8 bzero -> memset. Do not "test truth" of pointers, but compare with
NULL, instead.  Do not gratuitously cast to void *.  Use NULL
instead of (type *)0.

No functional changes intended.
2008-10-24 16:54:18 +00:00
hans
c25473a894 if_input needs to be called at splnet(). ok by cube. 2008-10-19 23:28:31 +00:00
hans
b0d4e5c1a7 include bpf headers so that the bpf calls actually do something. ok by cube. 2008-10-16 18:56:56 +00:00
plunky
1bd707dd19 ip6_pcbopts() is called with the socket lock held, use M_NOWAIT 2008-10-12 15:24:10 +00:00
plunky
452f1527b6 ip6_pcbopt() is in the ctloutput path, we should not
sleep here because socket lock is held. use M_NOWAIT
2008-10-12 15:12:17 +00:00
plunky
76528ab801 convert ip6_[sg]etmoptions() to use sockopt(9) API
should be no functional change
2008-10-12 11:34:48 +00:00
plunky
aa5a0c9b51 do not sleep while allocating memory, socket lock is held
(use ENOBUFS for failure)
2008-10-12 10:25:04 +00:00
pooka
7e5aba5af0 Move uidinfo to its own module in kern_uidinfo.c and include in rump.
No functional change to uidinfo.
2008-10-11 13:40:57 +00:00
adrianp
2f48b72832 Fix for CVE-2008-3530 from matt@
Implement improved checking for MTU values on ICMP 'Packet Too Big Messages'
2008-10-03 08:23:06 +00:00
adrianp
93955a2e3d Fix from matt@ for malformed ICMPv6 MLD query (CVE-2008-2464). 2008-08-22 17:11:39 +00:00
matt
6c03151a48 Change KERNEL_LOCK_ONE (wrong name) to KERNEL_LOCK (the right name). 2008-08-21 15:34:10 +00:00
simonb
c5c6e8a42a Fix 8-spaces-vs-tab goop. 2008-08-20 22:58:42 +00:00
matt
34cedfb2bf Make the sysctl routines take out softnet_lock before dealing with
any data structures.

Change inet6ctlerrmap and zeroin6_addr to const.
2008-08-20 18:35:20 +00:00
plunky
fd7356a917 Convert socket options code to use a sockopt structure
instead of laying everything into an mbuf.

approved by core
2008-08-06 15:01:23 +00:00
matt
b89c8b7b61 Free the socket only after disposing of the PCB. 2008-08-04 06:47:52 +00:00
matt
a1469c2d6d Generalize previous fix so that both NS and NA packets are checked. 2008-07-31 18:24:07 +00:00
matt
fc3801b3c9 If a neighbor solictation isn't from the unspecified address, make sure
that the source address matches one of the interfaces address prefixes.
2008-07-31 18:01:36 +00:00
cegger
6e15fd7e81 remove undeclared caddr_t. makes i386 ALL kernel build again. 2008-06-27 09:16:21 +00:00
mlelstv
fa014c6383 Verify icmp type and code in IPSEC rules.
Fixes PR kern/39018
2008-06-27 05:18:58 +00:00
gmcgarry
4bb1ed1308 ioctl commands are unsigned long. ABI change to mrt6_ioctl() will affect 64-bit platforms. 2008-06-24 10:35:14 +00:00
dyoung
132e9baecf Cosmetic: join lines. 2008-05-22 22:25:05 +00:00
dyoung
a8ad22e5d9 Don't cast to void * unnecessarily. 2008-05-22 01:06:39 +00:00
dyoung
e47d9e31bc Cosmetic: don't cast NULL unnecessarily. 2008-05-22 01:05:38 +00:00
drochner
0a6f1919c0 protocol "drain" functions can be called in interrupt context, so
don't acquire softnet_lock
approved by ad
2008-05-21 17:08:07 +00:00
dyoung
9e7ef562d2 Simplify RT_DPRINTF() calls. 2008-05-15 01:33:28 +00:00
dyoung
ec34b3825c Change bzero() to memset(), non-overlapping bcopy() to memcpy().
Remove unnecessary casts to struct route *.
2008-05-13 17:53:52 +00:00
dyoung
323b0fda0c Compare route with NULL instead of testing truth. Where applicable,
s/0/NULL/.  s/u_char/uint8_t/.  Remove superfluous curly braces.
2008-05-11 20:19:44 +00:00
bouyer
993c458b34 Sync with ipv4 icmp_input(): make sure the mbuf is writable and
contains the entire icmp message befre calling icmp6_input().
should fix "panic: mbuf too short for IPv6 header" seen by several peoples.
2008-05-07 11:28:37 +00:00
ad
2bbb14eaa4 Back out previous. It broke the build. 2008-05-05 13:41:29 +00:00
ad
b407147f14 Move zlib out of net/ and into kern/. It would probably be better to use
the reachover Makefiles and libz, but this is already here and it works.
2008-05-04 23:07:09 +00:00
thorpej
b129a80c20 Simplify the interface to netstat_sysctl() and allocate space for
the collated counters using kmem_alloc().

PR kern/38577
2008-05-04 07:22:14 +00:00
martin
ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
yamt
fb7535aecb udp6_init: fix a comment. 2008-04-28 15:01:39 +00:00
ad
15e29e981b Merge the socket locking patch:
- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.
2008-04-24 11:38:36 +00:00
thorpej
caf49ea572 Make IPSEC and FAST_IPSEC stats per-cpu. Use <net/net_stats.h> and
netstat_sysctl().
2008-04-23 06:09:04 +00:00
thorpej
33326077b1 Use <net/net_stats.h> / netstat_sysctl(). 2008-04-23 05:26:50 +00:00
thorpej
0e499be12d Make pim6 stats per-cpu. 2008-04-15 05:40:15 +00:00
thorpej
27c227fe6e Explicitly include <sys/percpu.h>. 2008-04-15 05:23:33 +00:00
thorpej
16497cdf28 Make raw6 stats per-cpu. 2008-04-15 05:13:37 +00:00
thorpej
c2da059bc6 Make udp6 stats per-cpu. 2008-04-15 04:43:25 +00:00