summaryrefslogtreecommitdiffstats
path: root/sys/net/if_vlan.c
Commit message (Collapse)AuthorAgeFilesLines
* Don't acquire a lock before calling vlan_unconfig().ru2006-03-091-2/+0
| | | | | | This fixes a panic when doing "ifconfig ... -vlandev". OK'ed by: glebius
* Don't to forget to unlock the rwlock on trunk before destroying it.yar2006-02-241-2/+3
| | | | | | This should fix panic on "kldunload if_vlan" while vlanX are still there. Reviewed by: glebius
* Bump the MODULE_VERSION for HEAD, as the vlan(4) API is different inemaste2006-02-101-1/+1
| | | | | | | RELENG_6, and would require a lower version number. Requested by: glebius Approved by: rwatson (mentor)
* Avoid frobbing IFF_UP at any cost (which is close toyar2006-02-101-2/+0
| | | | | | | | zero in this case.) A kernel driver has IFF_DRV_RUNNING at its full disposal while IFF_UP may be toggled only by humans or their daemonic deputies from the userland. MFC after: 3 days
* Add a MODULE_VERSION so that other modules (perhaps third-party) canemaste2006-02-091-0/+1
| | | | | | depend on this one. Approved by: rwatson (mentor)
* In vlan_config() first call vlan_inithash(), then lock mutex, becauseglebius2006-02-021-4/+6
| | | | vlan_inithash() calls malloc(M_WAITOK).
* Set IFF_BROADCAST and IFF_MULTICAST on vlan interfaces from theyar2006-01-311-2/+5
| | | | | | | | | | | | | | | | | | beginning and simply refuse to attach to a parent without either flag. Our network stack cannot handle well IFF_BROADCAST or IFF_MULTICAST on an interface changing on the fly. E.g., IP will or won't assign a broadcast address to an interface and join the all-hosts multicast group on it depending on its IFF_BROADCAST and IFF_MULTICAST settings. Should the flags alter later, IP will miss the change and keep using bogus settings. This can lead to evil things like supplying an invalid broadcast address or trying to leave a multicast group that hasn't been joined. So just avoid touching the flags since an interface was created. This has no practical purpose. Discussed with: -net, glebius, oleg MFC after: 1 week
* Merge the //depot/user/yar/vlan branch into CVS. It contains some collectiveglebius2006-01-301-120/+463
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | work by yar, thompsa and myself. The checksum offloading part also involves work done by Mihail Balikov. The most important changes: o Instead of global linked list of all vlan softc use a per-trunk hash. The size of hash is dynamically adjusted, depending on number of entries. This changes struct ifnet, replacing counter of vlans with a pointer to trunk structure. This change is an improvement for setups with big number of VLANs, several interfaces and several CPUs. It is a small regression for a setup with a single VLAN interface. An alternative to dynamic hash is a per-trunk static array with 4096 entries, which is a compile time option - VLAN_ARRAY. In my experiments the array is not an improvement, probably because such a big trunk structure doesn't fit into CPU cache. o Introduce an UMA zone for VLAN tags. Since drivers depend on it, the zone is declared in kern_mbuf.c, not in optional vlan(4) driver. This change is a big improvement for any setup utilizing vlan(4). o Use rwlock(9) instead of mutex(9) for locking. We are the first ones to do this! :) o Some drivers can do hardware VLAN tagging + hardware checksum offloading. Add an infrastructure for this. Whenever vlan(4) is attached to a parent or parent configuration is changed, the flags on vlan(4) interface are updated. In collaboration with: yar, thompsa In collaboration with: Mihail Balikov <mihail.balikov interbgc.com>
* Take if_baudrate from the parent. This fixes problem with SNMPglebius2005-11-281-0/+1
| | | | daemons reporting zero speed for vlan(4) interfaces.
* - Store pointer to the link-level address right in "struct ifnet"ru2005-11-111-1/+1
| | | | | | | | | | rather than in ifindex_table[]; all (except one) accesses are through ifp anyway. IF_LLADDR() works faster, and all (except one) ifaddr_byindex() users were converted to use ifp->if_addr. - Stop storing a (pointer to) Ethernet address in "struct arpcom", and drop the IFP2ENADDR() macro; all users have been converted to use IF_LLADDR() instead.
* - Make IFP2ENADDR() a pointer to IF_LLADDR() rather than anotherru2005-11-111-18/+2
| | | | | | | | copy of Ethernet address. - Change iso88025_ifattach() and fddi_ifattach() to accept MAC address as an argument, similar to ether_ifattach(), to make this work.
* Move the cloned interface list management in to if_clone. For some drivers thethompsa2005-11-081-3/+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
* - Do not raise IFF_DRV_OACTIVE flag in vlan_start, because thisglebius2005-11-061-2/+8
| | | | | | | can lead to stalled interface - Explain this fact in a comment. Reviewed by: rwatson, thompsa, yar
* Improve handling flags that must be propagatedyar2005-10-031-37/+84
| | | | | | | | | | to the parent interface, such as IFF_PROMISC and IFF_ALLMULTI. In addition, vlan(4) gains ability to migrate from one parent to another w/o losing its own flags. PR: kern/81978 MFC after: 2 weeks
* The arguments to printf() were swapped.ru2005-09-161-2/+2
|
* Do assorted nitpicking in diagnostics while I'm here:yar2005-09-161-9/+9
| | | | | | - Use __func__ consistently instead of copying function name to message strings. Code tends to migrate around source files. - DIAGNOSTIC is for information, INVARIANTS is for panics.
* It's nice to have relevant comments both in if {} and else {},yar2005-09-161-1/+4
| | | | not in just one of them.
* Test the new M_VLANTAG packet flag before callingyar2005-09-161-2/+5
| | | | | | | | | | m_tag_locate(). This adds little overhead of a simple bitwise operation in case hardware VLAN acceleration is on, yet saves the more expensive function call if the acceleration is off. Reviewed by: ru, glebius X-MFC-after: 6.0
* Use VLAN_TAG_VALUE() not only to read a dot1q tagyar2005-08-311-1/+1
| | | | | | | | | | | | | value from an m_tag, but also to set it. This reduces complex code duplication and improves its readability. Alas, we shouldn't rename the macro to VLAN_TAG_LVALUE() globally because that would cause pain for kernel module port maintainers and vendors using FreeBSD as their codebase. Added a clarifying comment instead. Discussed with: ru, glebius X-MFC-After: 6.0-RELEASE (MFC is good just to reduce the diff)
* Fix fallout from revision 1.77, mark outgoing packets with M_VLANTAG flag.glebius2005-08-301-0/+1
| | | | | | PR: kern/80646 Reviewed by: yar MFC after: 3 days
* Vlan interfaces change their type after ether_ifattach() so we needs tobrooks2005-08-151-1/+1
| | | | | | | | use if_free_type(ifp, IFT_ETHER) to delete them and stop leaking struct arpcoms. Reported by: thompsa MFC After: 3 days
* Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE andrwatson2005-08-091-7/+7
| | | | | | | | | | | | | | IFF_DRV_RUNNING, as well as the move from ifnet.if_flags to ifnet.if_drv_flags. Device drivers are now responsible for synchronizing access to these flags, as they are in if_drv_flags. This helps prevent races between the network stack and device driver in maintaining the interface flags field. Many __FreeBSD__ and __FreeBSD_version checks maintained and continued; some less so. Reviewed by: pjd, bz MFC after: 7 days
* Stop embedding struct ifnet at the top of driver softcs. Instead thebrooks2005-06-101-23/+30
| | | | | | | | | | | | | | | | | | | | 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
* - Call if_link_state_change() for each vlan, when link changesglebius2005-04-201-7/+4
| | | | | | | | | on parent. - Remove route.h include. - Fix comment about MII. Sponsored by: Rambler Reviewed by: yar
* Allocate the M_VLANTAG m_pkthdr flag, and use it to indicate thatru2005-02-181-0/+1
| | | | | | | | | | | | | | | | a packet has VLAN mbuf tag attached. This is faster to check than m_tag_locate(), and allows us to use the tags in non-vlan(4) VLAN producers. The first argument to VLAN_OUTPUT_TAG() is now unused but retained for backward compatibility. While here, embellish a fix in rev. 1.174 of if_ethersubr.c -- it now checks for packets with VLAN (mbuf) tags, and it should now be possible to bridge(4) on vlan(4)'s whose parent interfaces support VLAN decapsulation in hardware. Reviewed by: sam
* Fix spelling in a comment.yar2005-01-241-1/+1
|
* Reduce the global name space pollution.yar2005-01-231-2/+2
| | | | The cloner structure isn't referenced by name outside this file.
* /* -> /*- for license, minor formatting changesimp2005-01-071-1/+1
|
* Add locking to the kqueue subsystem. This also makes the kqueue subsystemjmg2004-08-151-1/+1
| | | | | | | | | | | | | 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)
* Stop tinkering with the parent's VLAN_MTU capability.yar2004-07-261-27/+7
| | | | | | | | | | | | | | | | | | Now it is user-controlled through ifconfig(8). The former ``automagic'' way of operation created more trouble than good. First, VLAN_MTU consumers other than vlan(4) had appeared, e.g., ng_vlan(4). Second, there was no way to disable VLAN_MTU manually if it were causing trouble, e.g., data corruption. Dropping the ``automagic'' should be completely invisible to the user since a) all the drivers supporting VLAN_MTU have it enabled by default, and in the first place b) there is only one driver that can really toggle VLAN_MTU in the hardware under its control (it's fxp(4), to which I added VLAN_MTU controls to illustrate the principle.)
* Actually free the unit when destroying the interface.brooks2004-07-221-0/+5
| | | | | | Reported by: la at delfi.lt Tested by: la at delfi.lt PR: 68618
* 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".
* Workaround a locking problem in vlan(4). vlan_setmulti() may be calledbms2004-07-041-2/+11
| | | | | | | | | | | | | with sleepable locks held from further up in the network stack, and attempts to allocate memory to hold multicast group membership information with M_WAITOK. This panic was triggered specifically when an exiting routing daemon process closes its raw sockets after joining multicast groups on them. While we're here, comment some possible locking badness. PR: kern/48560
* style(9)/whitespace cleanup while I'm in this file.bms2004-07-041-54/+55
|
* Add a couple of #ifdef DEBUG printf()s in vlan_input() I found to bejoerg2004-06-241-0/+6
| | | | | useful when debugging the ether_demux() problem (when bridging over VLANs).
* Major overhaul of pseudo-interface cloning. Highlights include:brooks2004-06-221-9/+142
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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
* Replace IF_HANDOFF with new IFQ_HANDOFF to enqueue with ALTQ once enabled onmlaier2004-06-151-1/+3
| | | | the respective drivers.
* if_printf() won't emit a newline unless told to.yar2004-05-261-2/+3
|
* After all the relevant drivers have been fixed, fix vlan(4) itselfyar2004-05-251-27/+27
| | | | | | | | | | WRT manipulating capabilities of the parent interface: - use ioctl(SIOCSIFCAP) to toggle VLAN_MTU (the way that was done before was just wrong); - use the right order of conditional clauses to set the MTU fudge (that is logically independent from toggling VLAN_MTU.)
* Consult parent's if_capenable for active VLAN-related capabilities.yar2004-05-231-1/+8
| | | | | | | | | | This change is possible since all the relevant drivers have been fixed to set if_capenable properly. The field if_capabilities tracks supported capabilities, which may be disabled administratively. Inheriting checksum offload support from the parent interface isn't that easy because the checksumming capabilities of the parent may be toggled on the fly. Disable the code for now.
* Added dependency on the miibus module.ru2004-05-211-0/+1
|
* Add route.h to pick up the rt_ifmsg() declaration.scottl2004-05-041-0/+1
|
* Link state change notification of ethernet media to the routing socket.andre2004-05-031-0/+25
| | | | | | | | | | | | | | | o Extend the if_data structure with an ifi_link_state field and provide the corresponding defines for the valid states. o The mii_linkchg() callback updates the ifi_link_state field and calls rt_ifmsg() to notify listeners on the routing socket in addition to the kqueue KNOTE. o If vlans are configured on a physical interface notify and update all vlan pseudo devices as well with the vlan_link_state() callback. No objections by: sam, wpaul, ru, bms Brucification by: bde
* arpcom untangling:luigi2004-04-241-1/+1
| | | | | | | | | | 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'
* backout the switch to use a zone for vlan tags; this requiressam2004-01-031-26/+4
| | | | vlans be present if any driver with h/w vlan tagging is configured
* switch vlan packet tag allocation to use a private zonesam2004-01-021-4/+26
|
* - vlan_start(): Increment the correct interface statistics member.ru2003-11-121-3/+3
| | | | | | Reviewed by: mdodd - vlan_input(): Macroize the VLAN tag extraction from mbuf.
* Replace the if_name and if_unit members of struct ifnet with new membersbrooks2003-10-311-4/+3
| | | | | | | | | | | | | 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)
* Use VLANNAME instead of "vlan".brooks2003-10-281-4/+4
|
* Add locking. We use a single lock to guard the global vlan list and alsosam2003-09-051-17/+47
| | | | | | | | to protect the vlan state in each ifnet (e.g. vlan count). The latter is probably better handled through an ifnet-centric means but since changes are infrequent shouldn't matter for now. Sponsored by: FreeBSD Foundation
OpenPOWER on IntegriCloud