summaryrefslogtreecommitdiffstats
path: root/sys/net/if_disc.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix some statements in disc(4) and about it:yar2007-03-261-1/+1
| | | | | - ifnet is no more embedded in softc; - the interface name is `disc', not `ds'.
* Revise network interface cloning to take an optional opaquesam2006-07-091-2/+2
| | | | | | | | | parameter that can specify configuration parameters: o rev cloner api's to add optional parameter block o add SIOCCREATE2 that accepts parameter data o rev vlan support to use new api (maintain old code) Reviewed by: arch@
* Fix the following bpf(4) race condition which can result in a panic:csjp2006-06-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (1) bpf peer attaches to interface netif0 (2) Packet is received by netif0 (3) ifp->if_bpf pointer is checked and handed off to bpf (4) bpf peer detaches from netif0 resulting in ifp->if_bpf being initialized to NULL. (5) ifp->if_bpf is dereferenced by bpf machinery (6) Kaboom This race condition likely explains the various different kernel panics reported around sending SIGINT to tcpdump or dhclient processes. But really this race can result in kernel panics anywhere you have frequent bpf attach and detach operations with high packet per second load. Summary of changes: - Remove the bpf interface's "driverp" member - When we attach bpf interfaces, we now set the ifp->if_bpf member to the bpf interface structure. Once this is done, ifp->if_bpf should never be NULL. [1] - Introduce bpf_peers_present function, an inline operation which will do a lockless read bpf peer list associated with the interface. It should be noted that the bpf code will pickup the bpf_interface lock before adding or removing bpf peers. This should serialize the access to the bpf descriptor list, removing the race. - Expose the bpf_if structure in bpf.h so that the bpf_peers_present function can use it. This also removes the struct bpf_if; hack that was there. - Adjust all consumers of the raw if_bpf structure to use bpf_peers_present Now what happens is: (1) Packet is received by netif0 (2) Check to see if bpf descriptor list is empty (3) Pickup the bpf interface lock (4) Hand packet off to process From the attach/detach side: (1) Pickup the bpf interface lock (2) Add/remove from bpf descriptor list Now that we are storing the bpf interface structure with the ifnet, there is is no need to walk the bpf interface list to locate the correct bpf interface. We now simply look up the interface, and initialize the pointer. This has a nice side effect of changing a bpf interface attach operation from O(N) (where N is the number of bpf interfaces), to O(1). [1] From now on, we can no longer check ifp->if_bpf to tell us whether or not we have any bpf peers that might be interested in receiving packets. In collaboration with: sam@ MFC after: 1 month
* Force this interface to be RUNNING.glebius2005-11-111-0/+1
|
* Move the cloned interface list management in to if_clone. For some drivers thethompsa2005-11-081-21/+0
| | | | | | | | | | softc lists and associated mutex are now unused so these have been removed. Calling if_clone_detach() will now destroy all the cloned interfaces for the driver and in most cases is all thats needed to unload. Idea by: brooks Reviewed by: brooks
* Change the reference counting to count the number of cloned interfaces for eachthompsa2005-10-121-14/+6
| | | | | | | | | | | | | | | cloner. This ensures that ifc->ifc_units is not prematurely freed in if_clone_detach() before the clones are destroyed, resulting in memory modified after free. This could be triggered with if_vlan. Assert that all cloners have been destroyed when freeing the memory. Change all simple cloners to destroy their clones with ifc_simple_destroy() on module unload so the reference count is properly updated. This also cleans up the interface destroy routines and allows future optimisation. Discussed with: brooks, pjd, -current Reviewed by: brooks
* Fix some long standing bugs in writing to the BPF device attached todwmalone2005-06-261-6/+5
| | | | | | | | | | | | | | | | | | | | | | | | a DLT_NULL interface. In particular: 1) Consistently use type u_int32_t for the header of a DLT_NULL device - it continues to represent the address family as always. 2) In the DLT_NULL case get bpf_movein to store the u_int32_t in a sockaddr rather than in the mbuf, to be consistent with all the DLT types. 3) Consequently fix a bug in bpf_movein/bpfwrite which only permitted packets up to 4 bytes less than the MTU to be written. 4) Fix all DLT_NULL devices to have the code required to allow writing to their bpf devices. 5) Move the code to allow writing to if_lo from if_simloop to looutput, because it only applies to DLT_NULL devices but was being applied to other devices that use if_simloop possibly incorrectly. PR: 82157 Submitted by: Matthew Luckie <mjl@luckie.org.nz> Approved by: re (scottl)
* Stop embedding struct ifnet at the top of driver softcs. Instead thebrooks2005-06-101-6/+9
| | | | | | | | | | | | | | | | | | | | struct ifnet or the layer 2 common structure it was embedded in have been replaced with a struct ifnet pointer to be filled by a call to the new function, if_alloc(). The layer 2 common structure is also allocated via if_alloc() based on the interface type. It is hung off the new struct ifnet member, if_l2com. This change removes the size of these structures from the kernel ABI and will allow us to better manage them as interfaces come and go. Other changes of note: - Struct arpcom is no longer referenced in normal interface code. Instead the Ethernet address is accessed via the IFP2ENADDR() macro. To enforce this ac_enaddr has been renamed to _ac_enaddr. - The second argument to ether_ifattach is now always the mac address from driver private storage rather than sometimes being ac_enaddr. Reviewed by: sobomax, sam
* the rt parameter to ifa_rtrequest callbacks should always be non-null;sam2005-02-241-3/+1
| | | | | | eliminate grauitous ptr checks that follow ptr deref's Noticed by: Coverity Prevent analysis tool
* /* -> /*- for license, minor formatting changesimp2005-01-071-1/+1
|
* Do a pass over all modules in the kernel and make them return EOPNOTSUPPphk2004-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".
* Replace a bzero() after malloc() with M_ZERO.bms2004-07-061-2/+1
|
* Style.bms2004-07-061-13/+15
|
* Major overhaul of pseudo-interface cloning. Highlights include:brooks2004-06-221-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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
* Remove advertising clause from University of California Regent'simp2004-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
* Introduce disc_mtx to protect the global softc list in if_disc.rwatson2004-03-091-8/+29
| | | | | | | | | | | Since there are two destroy paths for if_disc interfaces -- module unload and cloan interface destroy, create a new utility function disc_destroy(), which is callded on a softc after it has been removed from the global softc list; the cloaner and module unload entry paths will both remove it before calling disc_destroy(). Reviewed by: pjd
* o eliminate widespread on-stack mbuf use for bpf by introducingsam2003-12-281-14/+1
| | | | | | | | | | | | | 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
* Replace the if_name and if_unit members of struct ifnet with new membersbrooks2003-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)
* Locking for updates to routing table entries. Each rtentry gets a mutexsam2003-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)
* Introduce an M_ASSERTPKTHDR() macro which performs the very common taskdes2003-04-081-2/+1
| | | | | | | 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>
* Back out M_* changes, per decision of the TRB.imp2003-02-191-1/+1
| | | | Approved by: trb
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.alfred2003-01-211-1/+1
| | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.
* network interface and link layer changes:sam2002-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
* Make discard devices clonable and unloadable. Also, change thebrooks2002-05-251-15/+57
| | | | interface name from ds# to disc#.
* minor style fix.jlemon2001-12-141-1/+1
|
* Pull post-4.4BSD change to sys/net/route.c from BSD/OS 4.2.ru2001-10-171-2/+2
| | | | | | | | | | | | | | | | | | | | 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
* This file was a horrible mixture of styles old and new.markm2001-06-161-27/+16
| | | | Apply style(9).
* Exterminate the use of PSEUDO_SET() with extreme prejudice.peter2001-01-311-4/+25
|
* udp IPv6 support, IPv6/IPv4 tunneling support in kernel,shin1999-12-071-0/+5
| | | | | | | | | | packet divert at kernel for IPv6/IPv4 translater daemon This includes queue related patch submitted by jburkhol@home.com. Submitted by: queue related patch from jburkhol@home.com Reviewed by: freebsd-arch, cvs-committers Obtained from: KAME project
* Set the queue length.phk1999-11-121-0/+1
|
* Remove NBPF conditionality of bpf calls in most of our network drivers.phk1999-09-251-5/+0
| | | | | | | | | | | | This means that we will not have to have a bpf and a non-bpf version of our driver modules. This does not open any security hole, because the bpf core isn't loadable The drivers left unchanged are the "cross platform" drivers where the respective maintainers are urged to DTRT, whatever that may be. Add a couple of missing FreeBSD tags.
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* Rename bpfilter to bpf.des1999-07-061-4/+4
|
* Make the use of 'disc' vs 'ds' as prefix consistent by making all 'disc'.eivind1998-12-141-15/+15
| | | | This fix the conflict of having two functions called 'dsioctl()'.
* This commit fixes various 64bit portability problems required fordfr1998-06-071-3/+3
| | | | | | | | | | FreeBSD/alpha. The most significant item is to change the command argument to ioctl functions from int to u_long. This change brings us inline with various other BSD versions. Driver writers may like to use (__FreeBSD_version == 300003) to detect this change. The prototype FreeBSD/alpha machdep will follow in a couple of days time.
* Make INET a proper option.eivind1998-01-081-1/+2
| | | | | | | | | | | | This will not make any of object files that LINT create change; there might be differences with INET disabled, but hardly anything compiled before without INET anyway. Now the 'obvious' things will give a proper error if compiled without inet - ipx_ip, ipfw, tcp_debug. The only thing that _should_ work (but can't be made to compile reasonably easily) is sppp :-( This commit move struct arpcom from <netinet/if_ether.h> to <net/if_arp.h>.
* Removed unused #includes.bde1997-08-021-21/+1
|
* Don't include <sys/ioctl.h> in the kernel. Stage 2: includebde1997-03-241-2/+2
| | | | <sys/sockio.h> instead of <sys/ioctl.h> in network files.
* Back out part 1 of the MCFH that changed $Id$ to $FreeBSD$. We are notpeter1997-02-221-1/+1
| | | | ready for it yet.
* Make the long-awaited change from $Id$ to $FreeBSD$jkh1997-01-141-1/+1
| | | | | | | | This will make a number of things easier in the future, as well as (finally!) avoiding the Id-smashing problem which has plagued developers for so long. Boy, I'm glad we're not using sup anymore. This update would have been insane otherwise.
* Remove some historical cruft inherited from the loopback driver in whichwollman1996-10-071-6/+1
| | | | | there were three possible different code paths through which we could discard a packet (which, after all, is the entire function of this interface).
* Change the use if ifnet.if_lastchange to be more in line withgpalmer1996-06-101-2/+1
| | | | | SNMP requirements. Update description of ifnet.if_lastchange in if.h to indicate this.
* Removed never-used #includes of <machine/cpu.h>. Many were apparentlybde1996-04-071-2/+1
| | | | copied from bad examples.
* Clean up Ethernet drivers:wollman1996-02-061-3/+3
| | | | | | | | - fill in and use ifp->if_softc - use if_bpf rather than private cookie variables - change bpf interface to take advantage of this - call ether_ifattach() directly from Ethernet drivers - delete kludge in if_attach() that did this indirectly
* Added a prototype.bde1995-12-031-2/+3
| | | | | | Declared dsioctl() as static consistently. Note that both if_disc.c and subr_diskslice.c use the same prefix `ds' and there is a name conflict for dsioctl().
* Finished (?) cleaning up sysinit stuff.bde1995-12-021-4/+4
|
* Second batch of cleanup changes.phk1995-10-291-4/+1
| | | | | This time mostly making a lot of things static and some unused variables here and there.
* Fix BPf to generate a header mbuf for writes.wollman1995-09-221-1/+9
| | | | | | | | Fix loopback and discard interfaces to understand BPF writes. (These two from Bill Fenner to fix PR 512.) Move ifpromisc() from bpf.c to if.c as suggested by comment in BPF. Send a notice to the log when promiscuous mode is enabled.
* Fixed init functions argument type - caddr_t -> void *. Fixed a couple ofdg1995-09-091-3/+3
| | | | compiler warnings.
* Fix several sysinit functions that had the wrong type and unnecessarilybde1995-08-301-4/+6
| | | | | | external linkage. Remove useless comments saying that SYSINIT() does system initialization.
OpenPOWER on IntegriCloud