summaryrefslogtreecommitdiffstats
path: root/sys/net/if.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix the recent panics/LORs/hangs created by my kqueue commit by:ssouhlal2005-07-011-2/+2
| | | | | | | | | | | | | | | | | - Introducing the possibility of using locks different than mutexes for the knlist locking. In order to do this, we add three arguments to knlist_init() to specify the functions to use to lock, unlock and check if the lock is owned. If these arguments are NULL, we assume mtx_lock, mtx_unlock and mtx_owned, respectively. - Using the vnode lock for the knlist locking, when doing kqueue operations on a vnode. This way, we don't have to lock the vnode while holding a mutex, in filt_vfsread. Reviewed by: jmg Approved by: re (scottl), scottl (mentor override) Pointyhat to: ssouhlal Will be happy: everyone
* Spelling/grammer fixes in comment.brooks2005-06-171-1/+1
| | | | | Reported by: Hans Petter Selasky <hselasky at c2i dot net> Approved by: re (ifnet blanked)
* Return NULL instead of a bogus pointer from if_alloc when if_com_allocbrooks2005-06-121-6/+9
| | | | | | | | | | fails. Move detaching the ifnet from the ifindex_table into if_free so we can both keep the sanity checks and actually delete the ifnets. [0] Reported by: gallatin [0] Approved by: re (blanket)
* Stop embedding struct ifnet at the top of driver softcs. Instead thebrooks2005-06-101-14/+94
| | | | | | | | | | | | | | | | | | | | 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
* Send link state change notifications to /dev/devctl. This is needed tobrooks2005-06-061-0/+2
| | | | start the OpenBSD dhclient when links come up.
* Add hooks into the networking layer to support if_bridge. This changes structthompsa2005-06-051-0/+8
| | | | | | | ifnet so a buildworld is necessary. Approved by: mlaier (mentor) Obtained from: NetBSD
* Separate out address-detaching part of if_detach into if_purgeaddrs,peadar2005-05-251-30/+41
| | | | | | | | | so if_tap doesn't need to rely on locally-rolled code to do same. The observable symptom of if_tap's bzero'ing the address details was a crash in "ifconfig tap0" after an if_tap device was closed. Reported By: Matti Saarinen (mjsaarin at cc dot helsinki dot fi)
* Do not call all link state callbacks directly, but scheduleglebius2005-04-201-3/+23
| | | | | | | | | | a taskqueue(9) task. This fixes LORs and adds possibility to serve such events pseudorecursively, when link state change of interface causes subsequent change on other interfaces. Sponsored by: Rambler Reviewed by: sam, brooks, mux
* Zero the ifr.ifr_name buffer in ifconf() in order to avoidcperciva2005-04-151-0/+6
| | | | | | accidental disclosure of kernel memory to userland. Security: FreeBSD-SA-05:04.ifconf
* ifma_protospec is a pointer. Use NULL when assigning or compating it.glebius2005-03-201-2/+2
|
* Add a sysctl net.link.log_link_state_change, which allows toglebius2005-03-121-5/+13
| | | | | | suppress logging of interface link state changes. Requested by: sam, kan
* Change the definition of struct if_data's member ifi_epoch from wallbrooks2005-02-251-1/+1
| | | | | | | | | | | | | | | | | clock time to uptime because wall clock time may go backwards. This is a change in the API which will impact SNMP agents who are using ifi_epoch to set RFC2233's ifCounterDiscontinuityTime. None are know to exist today. This will not impact applications that are using the <index, epoch> tuple to verify interface uniqueness except that it eliminates a race which could lead to a false assumption of uniqueness. Because this is a behavior change, bump __FreeBSD_version. Discussed with: re (jhb, scottl) MFC after: 3 days Pointed out by: pkh (way back at EuroBSDCon) Pointy hat: brooks
* Typo in comment.glebius2005-02-221-1/+1
|
* - In if_link_state_change() extract function body from if-block, to improveglebius2005-02-221-19/+25
| | | | | | | | readability. - Call carp_carpdev_state() from if_link_state_change() if interface has associated CARP interface. Sponsored by: Rambler
* Add CARP (Common Address Redundancy Protocol), which allows multipleglebius2005-02-221-0/+18
| | | | | | | | | | | | | hosts to share an IP address, providing high availability and load balancing. Original work on CARP done by Michael Shalayeff, with many additions by Marco Pfatschbacher and Ryan McBride. FreeBSD port done solely by Max Laier. Patch by: mlaier Obtained from: OpenBSD (mickey, mcbride)
* Validate ifc->ifc_len before submitting its incarnation to sbuf_new,delphij2005-02-121-0/+4
| | | | | | | | | which will finally lead to kernel panic. Security: This prevents a local (root-launched) DoS Submitted by: Wojciech A. Koszek [dunstan at freebsd czest pl] PR: 77421 MFC After: 1 week
* Log changes of link state.glebius2005-01-301-0/+3
| | | | Reviewed by: rwatson
* This change adds reliability for Ethernet trunks built with ng_one2many:glebius2005-01-081-0/+6
| | | | | | | | | | - Introduce another ng_ether(4) callback ng_ether_link_state_p, which is called from if_link_state_change(), every time link is changed. - In ng_ether_link_state() send netgraph control message notifying of link state change to a node connected to "lower" hook. Reviewed by: sam MFC after: 2 weeks
* /* -> /*- for license, minor formatting changesimp2005-01-071-1/+1
|
* Cleanup link state change notification:sam2004-12-081-0/+26
| | | | | o add new if_link_state_change routine that deals with link state changes o change mii to use if_link_state_change
* Implement the check I was talking about in the previous message already.mlaier2004-11-301-4/+4
| | | | | | | | | | | | | | | | | Introduce domain_init_status to keep track of the init status of the domains list (surprise). 0 = uninitialized, 1 = initialized/unpopulated, 2 = initialized/done. Higher values can be used to support late addition of domains which right now "works", but is potential dangerous. I choose to only give a warning when doing so. Use domain_init_status with if_attachdomain[1]() to ensure that we have a complete domains list when we init the if_afdata array. Store the current value of domain_init_status in if_afdata_initialized. This way we can update if_afdata after a new protocol has been added (once that is allowed). Submitted by: se (with changes) Reviewed by: julian, glebius, se PR: kern/73321 (partly)
* Assign if_broadcastaddr to NULL not 0 in if_attach().rwatson2004-11-231-8/+10
| | | | | | | | | | | Printf() a warning if if_attachdomain() is called more than once on an interface to generate some noise on mailing lists when this occurs. Fix up style in if_start(), where spaces crept in instead of tabs at some point. MFC after: 1 week MFC note: Not the printf().
* Move if_handoff() from an inline in if_var.h to a function to if.crwatson2004-10-301-0/+25
| | | | | | | | | in orden to harden the ABI for 5.x; this will permit us to modify the locking in the ifnet packet dispatch without requiring drivers to be recompiled. MFC after: 3 days Discussed at: EuroBSDCon Developer's Summit
* Define IFF_LOCKGIANT() and IFF_UNLOCKGIANT() macros, which conditionallyrwatson2004-10-191-2/+30
| | | | | | | | | acquire Giant if the passed interface has IFF_NEEDSGIANT set on it. Modify calls into (ifp)->if_ioctl() in if.c to use these macros in order to ensure that Giant is held. MFC after: 3 days Bumped into by: jmg
* Call sbuf_finish() before sbuf_data() so as to not panic the system.green2004-09-221-0/+1
|
* Fix a LOR where ifconf() used copyout while holding a mutex. This LORbrooks2004-09-221-41/+51
| | | | | | | | was seen when configuring addresses on interfaces using ifconfig. This patch has been verified to work with over eight thousand addresses assigned to an interface. LOR id: 031
* Log the renaming of an interface. This should make it easier to followbrooks2004-09-181-0/+3
| | | | kernel log files.
* Re-add ifi_epoch, to struct if_data, this time replacing ifi_unusedbrooks2004-09-081-0/+1
| | | | | | | | | | | | to avoid ABI changes. It is set to the last time the interface counters were zeroed, currently the time if_attach() was called. It is intentended to be a valid value for RFC2233's ifCounterDiscontinuityTime and to make it easier for applications to verify that the interface they find at a given index is the one that was there last time they looked. Due to space constraints ifi_epoch is a time_t rather then a struct timeval. SNMP would prefer higher precision, but this unlikely to be useful in practice.
* don't call f_detach if the filter has alread removed the knote.. Thisjmg2004-09-061-3/+0
| | | | | | | | happens when a proc exits, but needs to inform the user that this has happened.. This also means we can remove the check for detached from proc and sig f_detach functions as this is doing in kqueue now... MFC after: 5 days
* Back out ifi_epoch. The ABI breakage is too disruptive this close tobrooks2004-09-021-1/+0
| | | | | 5-STABLE. ifi_epoch will shortly be reintroduced with less precistion using the space currently allocated to ifi_unused.
* Fix an assertion when if_down()ing a ALTQ managed interface. The lock shouldmlaier2004-09-011-0/+2
| | | | | | | | | have been in place all the time the mtx_assert in the ALTQ code just discovered the shortcoming. PR: i386/71195 Tested by: Bettan (PR originator), myself MFC after: 5 days
* Use a spare byte in struct if_data to store the structure size withoutbrooks2004-09-011-0/+1
| | | | | | | | | increasing it. Add code to ifconfig to use this size to find the sockaddr_dl after the struct if_data in the routing message. This allows struct if_data to grow (up to 255 bytes) without breaking ifconfig. Submitted by: peter
* Add a new variable, ifi_epoch, to struct if_data. It is set to the lastbrooks2004-08-301-0/+1
| | | | | | | | | | | | | time the interface counters were zeroed, currently the time if_attach() was called. It is indentended to be a valid value for RFC2233's ifCounterDiscontinuityTime and to make it easier for applications to verify that the interface they find at a given index is the one that was there last time they looked. An if_epoch "compatability" macro has not been created as ifi_epoch has never been a member of struct ifnet. Approved by: andre, bms, wollman
* When detaching an interface, don't leave an obsolete pointer to thebrooks2004-08-271-0/+1
| | | | | | | soon to be deleted struct ifnet around. PR: kern/52260 MFC After: 3 days
* Add locking to the kqueue subsystem. This also makes the kqueue subsystemjmg2004-08-151-19/+23
| | | | | | | | | | | | | a more complete subsystem, and removes the knowlege of how things are implemented from the drivers. Include locking around filter ops, so a module like aio will know when not to be unloaded if there are outstanding knotes using it's filter ops. Currently, it uses the MTX_DUPOK even though it is not always safe to aquire duplicate locks. Witness currently doesn't support the ability to discover if a dup lock is ok (in some cases). Reviewed by: green, rwatson (both earlier versions)
* Do not attempt to clean up data that has not been initialized yet.roam2004-08-061-4/+15
| | | | | | | This fixes two kernel panics on boot when the xl driver fails to allocate bus/port/memory resources. Reviewed by: silence on -net
* Add a new network interface flag, IFF_NEEDSGIANT, which will allowrwatson2004-07-271-0/+49
| | | | | | | | | | | | | | | | | | | | | | device drivers to declare that the ifp->if_start() method implemented by the driver requires Giant in order to operate correctly. Add a 'struct task' to 'struct ifnet' that can be used to execute a deferred ifp->if_start() in the event that if_start needs to be called in a Giant-free environment. To do this, introduce if_start(), a wrapper function for ifp->if_start(). If the interface can run MPSAFE, it directly dispatches into the interface start routine. If it can't run MPSAFE, we're running with debug.mpsafenet != 0, and Giant isn't currently held, the task is queued to execute in a swi holding Giant via if_start_deferred(). Modify if_handoff() to use if_start() instead of direct dispatch. Modify 802.11 to use if_start() instead of direct dispatch. This is intended to provide increased compatibility for non-MPSAFE network device drivers in the presence of Giant-free operation via asynchronous dispatch. However, this commit does not mark any network interfaces as IFF_NEEDSGIANT.
* Gratuitous whitespace change to un-wrap a short line.rwatson2004-07-181-2/+1
|
* Major overhaul of pseudo-interface cloning. Highlights include:brooks2004-06-221-242/+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
* Do the dreaded s/dev_t/struct cdev */phk2004-06-161-4/+4
| | | | Bump __FreeBSD_version accordingly.
* Transform tbr_dequeue into a function pointer in order to build drivers withmlaier2004-06-151-2/+2
| | | | | | ALTQ enabled versions of IFQ_* macros by default, as requested by serveral others. This is a follow-up to the quick fix I committed yesterday which turned off the ALTQ checks for non-ALTQ kernels.
* Link ALTQ to the build and break with ABI for struct ifnet. Please recompilemlaier2004-06-131-2/+19
| | | | | | | | | | | | your (network) modules as well as any userland that might make sense of sizeof(struct ifnet). This does not change the queueing yet. These changes will follow in a seperate commit. Same with the driver changes, which need case by case evaluation. __FreeBSD_version bump will follow. Tested-by: (i386)LINT
* arpcom untangling:luigi2004-04-241-2/+2
| | | | | | | | | | consistently with the rest of the code, use IFP2AC(ifp) to access the arpcom structure given the ifp. In this case also fix a difference in assumptions WRT the rest of the net/ sources: it is not the 'struct *softc' that starts with a 'struct arpcom', but a 'struct arpcom' that starts with a 'struct ifnet'
* Fix a recently introduced panic in if_detach() by delayingluigi2004-04-191-11/+11
| | | | | | the invalidation of ifindex_table[] entry. Probably this code should be moved even further down, but for the time being let's do it this way.
* Make if_(un)route static in if.c as they are called from if_up/if_down only.mlaier2004-04-181-2/+4
| | | | | | | This is also cleanup to make locking easier. Reviewed by: luigi Approved by: bms(mentor)
* Use if_link instead of the alias if_list, and change a for() intoluigi2004-04-161-1/+6
| | | | | | | | | | the TAILQ_FOREACH() form. Comment the need to store the same info (mac address for ethernet-type devices) in two different places. No functional changes. Even the compiler output should be unmodified by this change.
* Consistently use ifaddr_byindex() to access the link-level addressluigi2004-04-161-1/+1
| | | | | | | of an interface. No functional change. On passing, comment a likely bug in net/rtsock.c:sysctl_ifmalist() which, if confirmed, would deserve to be fixed and MFC'ed
* 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
* Don't allow interfaces to be renamed to the empty string.brooks2004-03-131-2/+4
| | | | | | While I'm here, errors aren't bools. Pointed out by: hmp
* Remove if_withname. It came in with the KAME import, but never gotbrooks2004-03-131-26/+0
| | | | | | | | used. Should someone need its functionality, it's a really expensive implementation of: ifnet_byindex(sdl->sdl_index) Reviewed by: bde, ume
OpenPOWER on IntegriCloud