aboutsummaryrefslogtreecommitdiff
path: root/sys/net/if_loop.c
Commit message (Collapse)AuthorAgeFilesLines
* the rt parameter to ifa_rtrequest callbacks should always be non-null;Sam Leffler2005-02-241-2/+1
| | | | | | | | | eliminate grauitous ptr checks that follow ptr deref's Noticed by: Coverity Prevent analysis tool Notes: svn path=/head/; revision=142352
* /* -> /*- for license, minor formatting changesWarner Losh2005-01-071-1/+1
| | | | Notes: svn path=/head/; revision=139823
* Apply error and success logic consistently to the function netisr_queue() andAndre Oppermann2004-08-271-1/+1
| | | | | | | | | | | | | | | | | | | | | its users. netisr_queue() now returns (0) on success and ERRNO on failure. At the moment ENXIO (netisr queue not functional) and ENOBUFS (netisr queue full) are supported. Previously it would return (1) on success but the return value of IF_HANDOFF() was interpreted wrongly and (0) was actually returned on success. Due to this schednetisr() was never called to kick the scheduling of the isr. However this was masked by other normal packets coming through netisr_dispatch() causing the dequeueing of waiting packets. PR: kern/70988 Found by: MOROHOSHI Akihiko <moro@remus.dti.ne.jp> MFC after: 3 days Notes: svn path=/head/; revision=134391
* Avoid casts as lvalues.Alexander Kabaev2004-07-281-1/+1
| | | | Notes: svn path=/head/; revision=132780
* Do a pass over all modules in the kernel and make them return EOPNOTSUPPPoul-Henning Kamp2004-07-151-0/+2
| | | | | | | | | | | for unknown events. A number of modules return EINVAL in this instance, and I have left those alone for now and instead taught MOD_QUIESCE to accept this as "didn't do anything". Notes: svn path=/head/; revision=132199
* Those are unneeded too.Pawel Jakub Dawidek2004-06-271-1/+0
| | | | Notes: svn path=/head/; revision=131178
* Add two missing includes and remove two uneeded.Pawel Jakub Dawidek2004-06-271-1/+0
| | | | | | | | This is quite serious fix, because even with MAC framework compiled in, MAC entry points in those two files were simply ignored. Notes: svn path=/head/; revision=131177
* Major overhaul of pseudo-interface cloning. Highlights include:Brooks Davis2004-06-221-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Split the code out into if_clone.[ch]. - Locked struct if_clone. [1] - Add a per-cloner match function rather then simply matching names of the form <name><unit> and <name>. - Use the match function to allow creation of <interface>.<tag> vlan interfaces. The old way is preserved unchanged! - Also the match function to allow creation of stf(4) interfaces named stf0, stf, or 6to4. This is the only major user visible change in that "ifconfig stf" creates the interface stf rather then stf0 and does not print "stf0" to stdout. - Allow destroy functions to fail so they can refuse to delete interfaces. Currently, we forbid the deletion of interfaces which were created in the init function, particularly lo0, pflog0, and pfsync0. In the case of lo0 this was a panic implementation so it does not count as a user visiable change. :-) - Since most interfaces do not need the new functionality, an family of wrapper functions, ifc_simple_*(), were created to wrap old style cloner functions. - The IF_CLONE_INITIALIZER macro is replaced with a new incompatible IFC_CLONE_INITIALIZER and ifc_simple consumers use IFC_SIMPLE_DECLARE instead. Submitted by: Maurycy Pawlowski-Wieronski <maurycy at fouk.org> [1] Reviewed by: andre, mlaier Discussed on: net Notes: svn path=/head/; revision=130933
* Staticize <if>_clone_{create,destroy} functions.Brooks Davis2004-04-141-4/+4
| | | | | | | Reviewed by: mlaier Notes: svn path=/head/; revision=128209
* Remove advertising clause from University of California Regent'sWarner Losh2004-04-071-4/+0
| | | | | | | | | | license, per letter dated July 22, 1999 and email from Peter Wemm, Alan Cox and Robert Watson. Approved by: core, peter, alc, rwatson Notes: svn path=/head/; revision=128019
* Introduce lo_mtx to protect the global loopback softc list. I'm notRobert Watson2004-03-091-1/+7
| | | | | | | | | | | really sure why we have a softc list for if_loop, given that it can't be unloaded, but that's an issue to revisit in the future as corrupting the softc list would still cause panics. Reviewed by: benno Notes: svn path=/head/; revision=126778
* o eliminate widespread on-stack mbuf use for bpf by introducingSam Leffler2003-12-281-13/+5
| | | | | | | | | | | | | | | | a new bpf_mtap2 routine that does the right thing for an mbuf and a variable-length chunk of data that should be prepended. o while we're sweeping the drivers, use u_int32_t uniformly when when prepending the address family (several places were assuming sizeof(int) was 4) o return M_ASSERTVALID to BPF_MTAP* now that all stack-allocated mbufs have been eliminated; this may better be moved to the bpf routines Reviewed by: arch@ and several others Notes: svn path=/head/; revision=123922
* Introduce tcp_hostcache and remove the tcp specific metrics fromAndre Oppermann2003-11-201-11/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | the routing table. Move all usage and references in the tcp stack from the routing table metrics to the tcp hostcache. It caches measured parameters of past tcp sessions to provide better initial start values for following connections from or to the same source or destination. Depending on the network parameters to/from the remote host this can lead to significant speedups for new tcp connections after the first one because they inherit and shortcut the learning curve. tcp_hostcache is designed for multiple concurrent access in SMP environments with high contention and is hash indexed by remote ip address. It removes significant locking requirements from the tcp stack with regard to the routing table. Reviewed by: sam (mentor), bms Reviewed by: -net, -current, core@kame.net (IPv6 parts) Approved by: re (scottl) Notes: svn path=/head/; revision=122922
* Remove the m_defrag call from if_loop; testing with m_fragmentMike Silbersack2003-11-111-27/+0
| | | | | | | | | | has shown that the IPv6 stack can clearly handle fragmented mbuf chains without a problem. MFC after: 1 week Notes: svn path=/head/; revision=122498
* Replace the if_name and if_unit members of struct ifnet with new membersBrooks Davis2003-10-311-2/+1
| | | | | | | | | | | | | | | | if_xname, if_dname, and if_dunit. if_xname is the name of the interface and if_dname/unit are the driver name and instance. This change paves the way for interface renaming and enhanced pseudo device creation and configuration symantics. Approved By: re (in principle) Reviewed By: njl, imp Tested On: i386, amd64, sparc64 Obtained From: NetBSD (if_xname) Notes: svn path=/head/; revision=121816
* Always queue looped back packets (rather than potentially usingSam Leffler2003-10-291-1/+1
| | | | | | | | | | direct dispatch) to avoid extensive kernel stack usage and to avoid directly re-entering the network stack. The latter causes locking problems when, for example, a complete TCP handshake` happens w/o a context switch. Notes: svn path=/head/; revision=121698
* Introduce the notion of "persistent mbuf tags"; these are tags that staySam Leffler2003-10-291-0/+1
| | | | | | | | | | | | | | | | | with an mbuf until it is reclaimed. This is in contrast to tags that vanish when an mbuf chain passes through an interface. Persistent tags are used, for example, by MAC labels. Add an m_tag_delete_nonpersistent function to strip non-persistent tags from mbufs and use it to strip such tags from packets as they pass through the loopback interface and when turned around by icmp. This fixes problems with "tag leakage". Pointed out by: Jonathan Stone Reviewed by: Robert Watson Notes: svn path=/head/; revision=121645
* Delay if_lo module intialization until domain list has beenAlexander Kabaev2003-10-271-1/+1
| | | | | | | completely populated. This prevents a system crash on boot. Notes: svn path=/head/; revision=121596
* Locking for updates to routing table entries. Each rtentry gets a mutexSam Leffler2003-10-041-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | that covers updates to the contents. Note this is separate from holding a reference and/or locking the routing table itself. Other/related changes: o rtredirect loses the final parameter by which an rtentry reference may be returned; this was never used and added unwarranted complexity for locking. o minor style cleanups to routing code (e.g. ansi-fy function decls) o remove the logic to bump the refcnt on the parent of cloned routes, we assume the parent will remain as long as the clone; doing this avoids a circularity in locking during delete o convert some timeouts to MPSAFE callouts Notes: 1. rt_mtx in struct rtentry is guarded by #ifdef _KERNEL as user-level applications cannot/do-no know about mutex's. Doing this requires that the mutex be the last element in the structure. A better solution is to introduce an externalized version of struct rtentry but this is a major task because of the intertwining of rtentry and other data structures that are visible to user applications. 2. There are known LOR's that are expected to go away with forthcoming work to eliminate many held references. If not these will be resolved prior to release. 3. ATM changes are untested. Sponsored by: FreeBSD Foundation Obtained from: BSD/OS (partly) Notes: svn path=/head/; revision=120727
* Also ifdef the variable which becomes unused w/o INET6, fixing the buildMike Silbersack2003-08-091-0/+2
| | | | | | | | | after the previous commit. Noticed by: alc Notes: svn path=/head/; revision=118688
* #ifdef INET6 the if_loop packet defrag; since only the ipv6 stack (might)Mike Silbersack2003-08-091-0/+2
| | | | | | | | | | require this to be done, there's no reason to waste time doing it if ipv6 isn't compiled in. MFC after: 1 week Notes: svn path=/head/; revision=118681
* Replace a handrolled defrag function with m_defrag. The handrolledMike Silbersack2003-05-281-22/+15
| | | | | | | | | | | | | | | | | function couldn't handle chains of > MCLBYTES, and it had a bug which caused corruption and panics in certain low mbuf situations. Additionally, change the failure case so that looutput returns ENOBUFS rather than attempting to pass on non-defragmented mbuf chains. Finally, remove the printf which would happen every time the low memory situation occured. It served no useful purpose other than to clue me in as to what was causing the panic in question. :) MFC after: 4 days Notes: svn path=/head/; revision=115360
* Move MAC label storage for mbufs into m_tags from the m_pkthdr structure,Robert Watson2003-04-141-8/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | returning some additional room in the first mbuf in a chain, and avoiding feature-specific contents in the mbuf header. To do this: - Modify mbuf_to_label() to extract the tag, returning NULL if not found. - Introduce mac_init_mbuf_tag() which does most of the work mac_init_mbuf() used to do, except on an m_tag rather than an mbuf. - Scale back mac_init_mbuf() to perform m_tag allocation and invoke mac_init_mbuf_tag(). - Replace mac_destroy_mbuf() with mac_destroy_mbuf_tag(), since m_tag's are now GC'd deep in the m_tag/mbuf code rather than at a higher level when mbufs are directly free()'d. - Add mac_copy_mbuf_tag() to support m_copy_pkthdr() and related notions. - Generally change all references to mbuf labels so that they use mbuf_to_label() rather than &mbuf->m_pkthdr.label. This required no changes in the MAC policies (yay!). - Tweak mbuf release routines to not call mac_destroy_mbuf(), tag destruction takes care of it for us now. - Remove MAC magic from m_copy_pkthdr() and m_move_pkthdr() -- the existing m_tag support does all this for us. Note that we can no longer just zero the m_tag list on the target mbuf, rather, we have to delete the chain because m_tag's will already be hung off freshly allocated mbuf's. - Tweak m_tag copying routines so that if we're copying a MAC m_tag, we don't do a binary copy, rather, we initialize the new storage and do a deep copy of the label. - Remove use of MAC_FLAG_INITIALIZED in a few bizarre places having to do with mbuf header copies previously. - When an mbuf is copied in ip_input(), we no longer need to explicitly copy the label because it will get handled by the m_tag code now. - No longer any weird handling of MAC labels in if_loop.c during header copies. - Add MPC_LOADTIME_FLAG_LABELMBUFS flag to Biba, MLS, mac_test. In mac_test, handle the label==NULL case, since it can be dynamically loaded. In order to improve performance with this change, introduce the notion of "lazy MAC label allocation" -- only allocate m_tag storage for MAC labels if we're running with a policy that uses MAC labels on mbufs. Policies declare this intent by setting the MPC_LOADTIME_FLAG_LABELMBUFS flag in their load-time flags field during declaration. Note: this opens up the possibility of post-boot policy modules getting back NULL slot entries even though they have policy invariants of non-NULL slot entries, as the policy might have been loaded after the mbuf was allocated, leaving the mbuf without label storage. Policies that cannot handle this case must be declared as NOTLATE, or must be modified. - mac_labelmbufs holds the current cumulative status as to whether any policies require mbuf labeling or not. This is updated whenever the active policy set changes by the function mac_policy_updateflags(). The function iterates the list and checks whether any have the flag set. Write access to this variable is protected by the policy list; read access is currently not protected for performance reasons. This might change if it causes problems. - Add MAC_POLICY_LIST_ASSERT_EXCLUSIVE() to permit the flags update function to assert appropriate locks. - This makes allocation in mac_init_mbuf() conditional on the flag. Reviewed by: sam Obtained from: TrustedBSD Project Sponsored by: DARPA, Network Associates Laboratories Notes: svn path=/head/; revision=113487
* Introduce an M_ASSERTPKTHDR() macro which performs the very common taskDag-Erling Smørgrav2003-04-081-3/+3
| | | | | | | | | | of asserting that an mbuf has a packet header. Use it instead of hand- rolled versions wherever applicable. Submitted by: Hiten Pandya <hiten@unixdaemons.com> Notes: svn path=/head/; revision=113255
* Finish driving a stake through the heart of netns and the associatedPeter Wemm2003-03-051-11/+0
| | | | | | | | | ifdefs scattered around the place - its dead Jim! The SMB stuff had stolen AF_NS, make it official. Notes: svn path=/head/; revision=111926
* Update netisr handling; Each SWI now registers its queue, and all queueJonathan Lemon2003-03-041-9/+2
| | | | | | | | | | | | | drain routines are done by swi_net, which allows for better queue control at some future point. Packets may also be directly dispatched to a netisr instead of queued, this may be of interest at some installations, but currently defaults to off. Reviewed by: hsu, silby, jayanth, sam Sponsored by: DARPA, NAI Labs Notes: svn path=/head/; revision=111888
* Back out M_* changes, per decision of the TRB.Warner Losh2003-02-191-3/+3
| | | | | | | Approved by: trb Notes: svn path=/head/; revision=111119
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.Alfred Perlstein2003-01-211-3/+3
| | | | | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT. Notes: svn path=/head/; revision=109623
* don't reference a pkthdr after M_MOVE_PKTHDR has "remove it"; insteadSam Leffler2003-01-061-2/+2
| | | | | | | | | reference the pkthdr now in the destination of the move Sponsored by: Vernier Networks Notes: svn path=/head/; revision=108825
* Correct mbuf packet header propagation. Previously, packet headersSam Leffler2002-12-301-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | were sometimes propagated using M_COPY_PKTHDR which actually did something between a "move" and a "copy" operation. This is replaced by M_MOVE_PKTHDR (which copies the pkthdr contents and "removes" it from the source mbuf) and m_dup_pkthdr which copies the packet header contents including any m_tag chain. This corrects numerous problems whereby mbuf tags could be lost during packet manipulations. These changes also introduce arguments to m_tag_copy and m_tag_copy_chain to specify if the tag copy work should potentially block. This introduces an incompatibility with openbsd which we may want to revisit. Note that move/dup of packet headers does not handle target mbufs that have a cluster bound to them. We may want to support this; for now we watch for it with an assert. Finally, M_COPYFLAGS was updated to include M_FIRSTFRAG|M_LASTFRAG. Supported by: Vernier Networks Reviewed by: Robert Watson <rwatson@FreeBSD.org> Notes: svn path=/head/; revision=108466
* Under some circumstances, the loopback interface will allocate a newRobert Watson2002-12-181-0/+10
| | | | | | | | | | | | | | | | | | | mbuf for a packet looping back to provide alignment guarantees for KAME. Unfortunately, this code performs a direct copy of the header rather than using a header copying primitive (largely because we have sucky header copying primitives). This results in a multiple free of the MAC label in the header when the same label data is freed twice when the two mbufs with that header are freed. As a temporary work-around, clear the initialized flag on the label to prevent the duplicate free, which prevents panics on large unaligned loopback IP and IPv6 data. The real fix is to improve and make use of proper packet header copying routines here. Obtained from: TrustedBSD Project Sponsored by: DARPA, Network Associates Laboratories Notes: svn path=/head/; revision=108041
* network interface and link layer changes:Sam Leffler2002-11-151-1/+1
| | | | | | | | | | | | | | | o on input don't strip the Ethernet header from packets o input packet handling is now done with if_input o track changes to ether_ifattach/ether_ifdetach API o track changes to bpf tapping o call ether_ioctl for default handling of ioctl's o use constants from net/ethernet.h where possible Reviewed by: many Approved by: re Notes: svn path=/head/; revision=106939
* Replace aux mbufs with packet tags:Sam Leffler2002-10-161-2/+1
| | | | | | | | | | | | | | | | | | | | | | o instead of a list of mbufs use a list of m_tag structures a la openbsd o for netgraph et. al. extend the stock openbsd m_tag to include a 32-bit ABI/module number cookie o for openbsd compatibility define a well-known cookie MTAG_ABI_COMPAT and use this in defining openbsd-compatible m_tag_find and m_tag_get routines o rewrite KAME use of aux mbufs in terms of packet tags o eliminate the most heavily used aux mbufs by adding an additional struct inpcb parameter to ip_output and ip6_output to allow the IPsec code to locate the security policy to apply to outbound packets o bump __FreeBSD_version so code can be conditionalized o fixup ipfilter's call to ip_output based on __FreeBSD_version Reviewed by: julian, luigi (silent), -arch, -net, darren Approved by: julian, silence from everyone else Obtained from: openbsd (mostly) MFC after: 1 month Notes: svn path=/head/; revision=105194
* Move all unit number management cloned interfaces into the cloningBrooks Davis2002-05-251-16/+6
| | | | | | | | | | | code. The reverts the API change which made the <if>_clone_destory() functions return an int instead of void bringing us into closer alignment with NetBSD. Reviewed by: net (a long time ago) Notes: svn path=/head/; revision=97289
* Replace (deprecated ?) FREE() macro with direct calls to free()Luigi Rizzo2002-04-041-1/+1
| | | | Notes: svn path=/head/; revision=93752
* Simplify the interface cloning framework by handling unitMaxime Henrion2002-03-111-55/+9
| | | | | | | | | | | | unit allocation with a bitmap in the generic layer. This allows us to get rid of the duplicated rman code in every clonable interface. Reviewed by: brooks Approved by: phk Notes: svn path=/head/; revision=92081
* Add cloning support to the loopback interface.Brooks Davis2002-03-041-56/+99
| | | | | | | Submitted by: mux Notes: svn path=/head/; revision=91648
* sparc64 needs the same alingment fixes that alpha and ia64 do.Jake Burkholder2001-12-291-1/+1
| | | | | | | Submitted by: tmm Notes: svn path=/head/; revision=88660
* whitespace fixes.Jonathan Lemon2001-12-141-1/+1
| | | | Notes: svn path=/head/; revision=87914
* Pull post-4.4BSD change to sys/net/route.c from BSD/OS 4.2.Ruslan Ermilov2001-10-171-3/+3
| | | | | | | | | | | | | | | | | | | | | | | Have sys/net/route.c:rtrequest1(), which takes ``rt_addrinfo *'' as the argument. Pass rt_addrinfo all the way down to rtrequest1 and ifa->ifa_rtrequest. 3rd argument of ifa->ifa_rtrequest is now ``rt_addrinfo *'' instead of ``sockaddr *'' (almost noone is using it anyways). Benefit: the following command now works. Previously we needed two route(8) invocations, "add" then "change". # route add -inet6 default ::1 -ifp gif0 Remove unsafe typecast in rtrequest(), from ``rtentry *'' to ``sockaddr *''. It was introduced by 4.3BSD-Reno and never corrected. Obtained from: BSD/OS, NetBSD MFC after: 1 month PR: kern/28360 Notes: svn path=/head/; revision=85074
* Revision 1.32 corresponded to CSRG revision 8.2.Ruslan Ermilov2001-10-171-1/+1
| | | | Notes: svn path=/head/; revision=85051
* Add ia64 to the list of machines which don't do unaligned reads.Doug Rabson2001-10-051-1/+1
| | | | Notes: svn path=/head/; revision=84558
* Remove/comment tokens after #endif (#endif NETATALK)Peter Wemm2001-09-101-2/+2
| | | | Notes: svn path=/head/; revision=83268
* Sync with recent KAME.Hajimu UMEMOTO2001-06-111-12/+17
| | | | | | | | | | | | | | | | | | | | | This work was based on kame-20010528-freebsd43-snap.tgz and some critical problem after the snap was out were fixed. There are many many changes since last KAME merge. TODO: - The definitions of SADB_* in sys/net/pfkeyv2.h are still different from RFC2407/IANA assignment because of binary compatibility issue. It should be fixed under 5-CURRENT. - ip6po_m member of struct ip6_pktopts is no longer used. But, it is still there because of binary compatibility issue. It should be removed under 5-CURRENT. Reviewed by: itojun Obtained from: KAME MFC after: 3 weeks Notes: svn path=/head/; revision=78064
* "Fix" the previous initial attempt at fixing TUNABLE_INT(). This timePeter Wemm2001-06-081-1/+1
| | | | | | | | | | around, use a common function for looking up and extracting the tunables from the kernel environment. This saves duplicating the same function over and over again. This way typically has an overhead of 8 bytes + the path string, versus about 26 bytes + the path string. Notes: svn path=/head/; revision=77900
* Back out part of my previous commit. This was a last minute changePeter Wemm2001-06-071-1/+1
| | | | | | | | and I botched testing. This is a perfect example of how NOT to do this sort of thing. :-( Notes: svn path=/head/; revision=77853
* Make the TUNABLE_*() macros look and behave more consistantly like thePeter Wemm2001-06-061-2/+2
| | | | | | | | SYSCTL_*() macros. TUNABLE_INT_DECL() was an odd name because it didn't actually declare the int, which is what the name suggests it would do. Notes: svn path=/head/; revision=77843
* Exterminate the use of PSEUDO_SET() with extreme prejudice.Peter Wemm2001-01-311-14/+26
| | | | Notes: svn path=/head/; revision=71862
* Let M_PANIC go back to the private tree as its intention isn't understood wellBoris Popov2001-01-311-2/+1
| | | | | | | for now. Notes: svn path=/head/; revision=71859
* Use M_PANIC instead of if (sc == NULL) panic();Peter Wemm2001-01-291-1/+2
| | | | Notes: svn path=/head/; revision=71801