summaryrefslogtreecommitdiffstats
path: root/sys/net/if_ethersubr.c
Commit message (Collapse)AuthorAgeFilesLines
* Move the bridge hook after the loopback check so that IFF_SIMPLEX is honouredthompsa2006-08-251-8/+8
| | | | | | on member interfaces. This makes us the same as OpenBSD/NetBSD. MFC after: 3 days
* Remove the dependency of bridgestp.h on if_bridgevar.h by moving a couple ofthompsa2006-07-271-1/+0
| | | | private structures to if_bridge.c.
* Fixing compilation bustage: net/if_bridgevar.h depends on net/bridgestp.h.avatar2006-07-271-0/+1
|
* Unbreak byte counters when network interfaces are in monitor mode bycsjp2006-03-031-8/+8
| | | | | | | | | | re-organizing the monitor return logic. We perform interface monitoring checks after we have determined if the CRC is still on the packet, if it is, m_adj() is called which will adjust the packet length. This ensures that we are not including CRC lengths in the byte counters for each packet. Discussed with: andre, glebius
* Properly initialize args structure before passing it to ipfw_chk(): havingoleg2006-02-031-0/+1
| | | | | | | | uninitialized args.inp is unhealthy for uid/gid/jail ipfw rules. PR: kern/92589 Approved by: glebius (mentor) MFC after: 1 week
* Merge the //depot/user/yar/vlan branch into CVS. It contains some collectiveglebius2006-01-301-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Return mbuf pointer or NULL from ip_fastforward() as the mbuf pointerandre2006-01-181-1/+1
| | | | | | | | | | | may have changed by m_pullup() during fastforward processing. While this is a bug it is actually never triggered in real world situations and it is not remotely exploitable. Found by: Coverity Prevent(tm) Coverity ID: CID780 Sponsored by: TCP/IP Optimization Fundraise 2005
* 1) remove useless check of loop_copy - corresponding code was removed inoleg2005-12-221-5/+5
| | | | | | | | rev. 1.70 five years ago. 2) convert loop_copy to "non-negative" flag Approved by: glebius (mentor) MFC after: 2 weeks
* Change from a callback in if_ethersubr to using EVENTHANDLER in order to detachthompsa2005-12-171-7/+0
| | | | | | | span ports when they disappear. The span port does not have a pointer to the softc so revert r1.31 and bring back the softc linked-list. MFC after: 2 weeks
* Purge layer specific mbuf flags on layer crossings to avoid confusingandre2005-11-181-0/+3
| | | | | | upper or lower layers. Sponsored by: TCP/IP Optimization Fundraise 2005
* - Store pointer to the link-level address right in "struct ifnet"ru2005-11-111-8/+7
| | | | | | | | | | 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-10/+5
| | | | | | | | 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.
* Further clean up the bridge hooks in if_ethersubr.c and ng_ether.cthompsa2005-10-141-14/+5
| | | | | | - move the function pointer definitions to if_bridgevar.h - move most of the logic to the new BRIDGE_INPUT and BRIDGE_OUTPUT macros - remove unneeded functions from if_bridgevar.h and sort a little.
* From 101 ways to panic your kernel.thompsa2005-10-131-0/+8
| | | | | | Use bridge_ifdetach() to notify the bridge that a member has been detached. The bridge can then remove it from its interface list and not try to send out via a dead pointer.
* Consolidate two adjacent conditional blocksjulian2005-10-131-5/+1
| | | | | | | I actually believe the code in question should be elsewhere (in the preceding function). MFC after: 1 week
* Remove a stale comment.ru2005-10-131-1/+0
|
* Clean up the if_bridge hooks a bit in if_ethersubr.c and ng_ether.c, movethompsa2005-10-131-13/+0
| | | | | | the broadcast/multicast test to bridge_input(). Requested by: glebius
* A deja vu of:glebius2005-10-071-1/+4
| | | | | | | | | | | | | | http://lists.freebsd.org/pipermail/cvs-src/2004-October/033496.html The same problem applies to if_bridge(4), too. - Copy-and-paste the if_bridge(4) related block from if_ethersubr.c to ng_ether.c - Add XXXs, so that copy-and-paste would be noticed by any future editors of this code. - Also add XXXs near if_bridge(4) declarations. Silence from: thompsa
* Fix KASSERT function name in ether_output, use __func__ while I am here.thompsa2005-10-061-2/+2
|
* Remove bridge(4) from the tree. if_bridge(4) is a full functionalmlaier2005-09-271-33/+2
| | | | | | | | replacement and has additional features which make it superior. Discussed on: -arch Reviewed by: thompsa X-MFC-after: never (RELENG_6 as transition period)
* Add support for multicast to the bridge and allow inet6 addresses to bethompsa2005-09-061-1/+1
| | | | | | | | | | | | | | | | assigned to the interface. IPv6 auto-configuration is disabled. An IPv6 link-local address has a link-local scope within one link, the spec is unclear for the bridge case and it may cause scope violation. An address can be assigned in the usual way; ifconfig bridge0 inet6 xxxx:... Tested by: bmah Reviewed by: ume (netinet6) Approved by: mlaier (mentor) MFC after: 1 week
* Don't loop back packets that have been routed by pf. This fixes an endlessmlaier2005-08-231-1/+2
| | | | | | | | | loop where the same packet is sent over and over again. Obtained from: OpenBSD Reported by: Sergey Lapin Tested by: Sergey Lapin MFC after: 7 days
* Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE andrwatson2005-08-091-1/+2
| | | | | | | | | | | | | | 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
* When allocating link layer ifnet address list entries inrwatson2005-08-021-2/+6
| | | | | | | | | ifp->if_resolvemulti(), do so with M_NOWAIT rather than M_WAITOK, so that a mutex can be held over the call. In the FDDI code, add a missing M_ZERO. Consumers are already aware that if_resolvemulti() can fail. MFC after: 1 week
* Add some KASSERTS to catch null pointers.phk2005-07-211-1/+10
|
* Stop embedding struct ifnet at the top of driver softcs. Instead thebrooks2005-06-101-13/+50
| | | | | | | | | | | | | | | | | | | | 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
* Add dummynet(4) support to if_bridge, this code is largely based on bridge.c.thompsa2005-06-101-1/+2
| | | | | | | This is the final piece to match bridge.c in functionality, we can now be a drop-in replacement. Approved by: mlaier (mentor)
* Fix indentation of two comment blocks from the last commit.thompsa2005-06-051-10/+10
| | | | Approved by: mlaier (mentor)
* Add hooks into the networking layer to support if_bridge. This changes structthompsa2005-06-051-0/+48
| | | | | | | ifnet so a buildworld is necessary. Approved by: mlaier (mentor) Obtained from: NetBSD
* Fix ef(4) driver when kernel compiled w/o IPX.sobomax2005-03-061-1/+1
| | | | MFC after: 3 days
* Fix long lines in comment introduced in previous commit.glebius2005-02-241-5/+6
|
* When prepending an LCC SNAP header to an atalk outgoing ethernet packet,rwatson2005-02-221-1/+1
| | | | | | | allocate the additional mbuf (if needed) using a non-sleeping memory allocation. MFC after: 7 days
* Add CARP (Common Address Redundancy Protocol), which allows multipleglebius2005-02-221-0/+26
| | | | | | | | | | | | | 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)
* Allocate the M_VLANTAG m_pkthdr flag, and use it to indicate thatru2005-02-181-4/+4
| | | | | | | | | | | | | | | | 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
* Check for non-NULL ac_netgraph field in interface arpcom, instead ofglebius2005-02-141-4/+4
| | | | | | checking global presence of ng_ether(4). Reviewed by: ru
* If no vlan(4) interfaces are configured for the interface, and theru2005-02-141-3/+10
| | | | | | | | | driver did VLAN decapsulation in hardware, we were passing a frame as if it came for the parent (non-VLAN) interface. Stop this from happening. Reminded by: glebius Security: This could pose a security risk in some setups
* - Reduce number of arguments passed to dummynet_io(), we already have cookieglebius2005-01-161-2/+1
| | | | | in struct ip_fw_args itself. - Remove redundant &= 0xffff from dummynet_io().
* o Clean up interface between ip_fw_chk() and its callers:glebius2005-01-141-4/+6
| | | | | | | | | | | | | | | | - ip_fw_chk() returns action as function return value. Field retval is removed from args structure. Action is not flag any more. It is one of integer constants. - Any action-specific cookies are returned either in new "cookie" field in args structure (dummynet, future netgraph glue), or in mbuf tag attached to packet (divert, tee, some future action). o Convert parsing of return value from ip_fw_chk() in ipfw_check_{in,out}() to a switch structure, so that the functions are more readable, and a future actions can be added with less modifications. Approved by: andre MFC after: 2 months
* /* -> /*- for license, minor formatting changesimp2005-01-071-1/+1
|
* Fix packet flow when both ng_ether(4) and bridge(4) are in use:glebius2004-10-121-46/+2
| | | | | | | | | | | | | | | - push all bridge logic from if_ethersubr.c into bridge.c make bridge_in() return mbuf pointer (or NULL). - call only bridge_in() from ether_input(), after ng_ether_input() was optinally called. - call bridge_in() from ng_ether_rcv_upper(). Long description: http://lists.freebsd.org/mailman/htdig/freebsd-net/2004-May/003881.html Reported by: Jian-Wei Wang <jwwang at FreeBSD.csie.NCTU.edu.tw> Tested by: myself, Sergey Lyubka Reviewed by: sam Approved by: julian (mentor) MFC after: 2 months
* When harvesting entropy from an ethernet mbuf, do so before freeing therwatson2004-10-111-1/+1
| | | | | | mbuf. RELENG_5 candidate.
* Add a new network interface flag, IFF_NEEDSGIANT, which will allowrwatson2004-07-271-0/+2
| | | | | | | | | | | | | | | | | | | | | | 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.
* Use ETHER_IS_MULTICAST() consistently in ether_resolvemulti().bms2004-07-091-1/+1
| | | | Reviewed by: jmallett
* Don't announce the ethernet address when it's 00:00:00:00:00:00. It'sbrooks2004-07-021-2/+7
| | | | | not of any interest. This primairly happens when vlan(4) interfaces are created.
* When considering an ethernet frame that is not destined for us, do notjoerg2004-06-241-3/+9
| | | | | | | | | | | | | | only allow this to be further processed when bridging is active on that interface, but also if the current packet has a VLAN tag and VLANs are active on our interface. This gives the VLAN layers a chance to also consider the packet (and perhaps drop it instead of the main dispatcher). This fixes a situation where bridging was only active on VLAN interfaces but ether_demux() called on behalf of the main interface had already thrown the packet away. MFC after: 4 weeks
* Make dependencies on the TCP/IP stack conditional on INET / INET6. Thisdes2004-06-241-0/+21
| | | | | | makes it possible to build a kernel with NIC drivers but no TCP/IP stack. Sponsored by: Teleplan AS
* Replace IF_HANDOFF with new IFQ_HANDOFF to enqueue with ALTQ once enabled onmlaier2004-06-151-1/+3
| | | | the respective drivers.
* Add helper functions to calculate the standard ethernet CRC innaddy2004-06-021-0/+73
| | | | | | | | | little/big endian fashion, so that network drivers can just reference the standard implementation and don't have to bring their own. As discussed on arch@. Obtained from: NetBSD
* Add some missing <sys/module.h> includes which are masked by thephk2004-05-301-0/+1
| | | | one on death-row in <sys/kernel.h>
* This commit does two things:luigi2004-04-251-18/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. rt_check() cleanup: rt_check() is only necessary for some address families to gain access to the corresponding arp entry, so call it only in/near the *resolve() routines where it is actually used -- at the moment this is arpresolve(), nd6_storelladdr() (the call is embedded here), and atmresolve() (the call is just before atmresolve to reduce the number of changes). This change will make it a lot easier to decouple the arp table from the routing table. There is an extra call to rt_check() in if_iso88025subr.c to determine the routing info length. I have left it alone for the time being. The interface of arpresolve() and nd6_storelladdr() now changes slightly: + the 'rtentry' parameter (really a hint from the upper level layer) is now passed unchanged from *_output(), so it becomes the route to the final destination and not to the gateway. + the routines will return 0 if resolution is possible, non-zero otherwise. + arpresolve() returns EWOULDBLOCK in case the mbuf is being held waiting for an arp reply -- in this case the error code is masked in the caller so the upper layer protocol will not see a failure. 2. arpcom untangling Where possible, use 'struct ifnet' instead of 'struct arpcom' variables, and use the IFP2AC macro to access arpcom fields. This mostly affects the netatalk code. === Detailed changes: === net/if_arcsubr.c rt_check() cleanup, remove a useless variable net/if_atmsubr.c rt_check() cleanup net/if_ethersubr.c rt_check() cleanup, arpcom untangling net/if_fddisubr.c rt_check() cleanup, arpcom untangling net/if_iso88025subr.c rt_check() cleanup netatalk/aarp.c arpcom untangling, remove a block of duplicated code netatalk/at_extern.h arpcom untangling netinet/if_ether.c rt_check() cleanup (change arpresolve) netinet6/nd6.c rt_check() cleanup (change nd6_storelladdr)
OpenPOWER on IntegriCloud