summaryrefslogtreecommitdiffstats
path: root/sys/net
Commit message (Collapse)AuthorAgeFilesLines
* Use new (inline) functions for calls into driver.phk2005-10-162-7/+5
|
* Make four more functions static that were missed in the last commit.thompsa2005-10-141-5/+5
|
* Change most of the bridge and stp funtions to static. This has highlightedthompsa2005-10-142-209/+226
| | | | | | | | | | | that the following funtions are not used, wrap in '#ifdef noused' for the moment. bstp_enable_change_detection bstp_disable_change_detection bstp_set_bridge_priority bstp_set_port_priority bstp_set_path_cost
* Further clean up the bridge hooks in if_ethersubr.c and ng_ether.cthompsa2005-10-144-31/+33
| | | | | | - 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-132-1/+13
| | | | | | 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-132-14/+10
| | | | | | the broadcast/multicast test to bridge_input(). Requested by: glebius
* Change the reference counting to count the number of cloned interfaces for eachthompsa2005-10-128-101/+61
| | | | | | | | | | | | | | | 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
* Be pedantic here: We're converting from network byte order to hostimp2005-10-121-2/+2
| | | | | | | byte order in these cases. This is a nop in terms of the generated code, but is logically incorrect. PR: 73852
* Do not unconditionally set a spanning tree port to forwarding as the link may bethompsa2005-10-111-1/+1
| | | | | | down when we attach. We wont get updated until a linkstate change happens. Go via bstp_ifupdstatus() which checks the media status first.
* 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
* Fixing a boot time panic(when if_fwip is compiled into kernel) by renamingavatar2005-10-061-3/+3
| | | | | | | | | module name to something that wouldn't conflict with sys/dev/firewire/firewire.c. Submitted by: Cai, Quanqing <caiquanqing at gmail dot com> PR: kern/82727 MFC after: 3 days
* Fix KASSERT function name in ether_output, use __func__ while I am here.thompsa2005-10-061-2/+2
|
* - Don't pollute opt_global.h with DEVICE_POLLING and introduceglebius2005-10-051-0/+1
| | | | | | | | | opt_device_polling.h - Include opt_device_polling.h into appropriate files. - Embrace with HAVE_KERNEL_OPTION_HEADERS the include in the files that can be compiled as loadable modules. Reviewed by: bde
* Protect PID initializations for statistics by the bpf descriptorcsjp2005-10-041-2/+6
| | | | | | | locks. Also while we are here, protect the bpf descriptor during knlist_remove{add} operations. Discussed with: rwatson
* Rename net.isr.enable to net.isr.dispatch.rwatson2005-10-041-5/+5
| | | | | | | | No compatibility code is provided, as this will be the production name as of 6.0. MFC after: 3 days Requested by: scottl
* 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
* Clean up consistency checks in if_setflag():yar2005-10-031-18/+11
| | | | | | . use KASSERT for all checks so that the source of an error can be detected; . use __func__ instead of spelling function name each time; . fix a typo.
* Log a message about entering or leaving permanently promiscuous mode,yar2005-10-031-6/+10
| | | | | | as it is done for usual promiscuous mode already. This info is important because promiscuous mode in the hands of a malicious party can jeopardize the whole network.
* Do not packet filter in the bridge_start() routine, locally generated packetsthompsa2005-10-021-20/+9
| | | | | | | are already filtered by the higher layers. Approved by: mlaier (mentor) MFC after: 3 days
* Big polling(4) cleanup.glebius2005-10-012-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | o Axe poll in trap. o Axe IFF_POLLING flag from if_flags. o Rework revision 1.21 (Giant removal), in such a way that poll_mtx is not dropped during call to polling handler. This fixes problem with idle polling. o Make registration and deregistration from polling in a functional way, insted of next tick/interrupt. o Obsolete kern.polling.enable. Polling is turned on/off with ifconfig. Detailed kern_poll.c changes: - Remove polling handler flags, introduced in 1.21. The are not needed now. - Forget and do not check if_flags, if_capenable and if_drv_flags. - Call all registered polling handlers unconditionally. - Do not drop poll_mtx, when entering polling handlers. - In ether_poll() NET_LOCK_GIANT prior to locking poll_mtx. - In netisr_poll() axe the block, where polling code asks drivers to unregister. - In netisr_poll() and ether_poll() do polling always, if any handlers are present. - In ether_poll_[de]register() remove a lot of error hiding code. Assert that arguments are correct, instead. - In ether_poll_[de]register() use standard return values in case of error or success. - Introduce poll_switch() that is a sysctl handler for kern.polling.enable. poll_switch() goes through interface list and enabled/disables polling. A message that kern.polling.enable is deprecated is printed. Detailed driver changes: - On attach driver announces IFCAP_POLLING in if_capabilities, but not in if_capenable. - On detach driver calls ether_poll_deregister() if polling is enabled. - In polling handler driver obtains its lock and checks IFF_DRV_RUNNING flag. If there is no, then unlocks and returns. - In ioctl handler driver checks for IFCAP_POLLING flag requested to be set or cleared. Driver first calls ether_poll_[de]register(), then obtains driver lock and [dis/en]ables interrupts. - In interrupt handler driver checks IFCAP_POLLING flag in if_capenable. If present, then returns.This is important to protect from spurious interrupts. Reviewed by: ru, sam, jhb
* Remove bridge(4) from the tree. if_bridge(4) is a full functionalmlaier2005-09-273-1447/+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)
* Fix an alignment panic my preserving the 2byte padding (ETHER_ALIGN) on ourthompsa2005-09-221-1/+1
| | | | | | | | | copied mbuf, which keeps the IP header 32-bit aligned. This copied mbuf is reinjected back into ether_input and off to the IP routines. Reported and tested by: Peter van Dijk Approved by: mlaier (mentor) MFC after: 3 days
* Several fixes to rt_setgate(), that fix problems with route changing:glebius2005-09-211-35/+30
| | | | | | | | | | | | | | | - Rearrange code so that in a case of failure the affected route is not changed. Otherwise, a bogus rtentry will be left and later rt_check() can recurse on its lock. [1] - Remove comment about protocol cloning. - Fix two places where rtentry mutex was recursed on, because accessed via two different pointers, that were actually pointing to the same rtentry in some cases. [1] - Return EADDRINUSE instead of bogus EDQUOT, in case when gateway uses the same route. [2] Reported & tested by: ps, Andrej Zverev <az inec.ru> [1] PR: kern/64090 [2]
* Use monotonic 'time_uptime' instead of 'time_second' as timebaseandre2005-09-191-1/+1
| | | | for rt->rt_rmx.rmx_expire.
* Use monotonic time_uptime instead of 'time_second' as timebaseandre2005-09-193-14/+14
| | | | for timeouts.
* Drop current rtentry lock before calling rt_getifa(). This fixes a LORglebius2005-09-191-3/+3
| | | | | | | and a possible recursive use of rtentry mutex. PR: kern/69356 Reviewed by: sam
* Take a first cut at cleaning up ifnet removal and multicast socketrwatson2005-09-181-0/+7
| | | | | | | | | | | | | | | | | | | | | | | panics, which occur when stale ifnet pointers are left in struct moptions hung off of inpcbs: - Add in_ifdetach(), which matches in6_ifdetach(), and allows the protocol to perform early tear-down on the interface early in if_detach(). - Annotate that if_detach() needs careful consideration. - Remove calls to in_pcbpurgeif0() in the handling of SIOCDIFADDR -- this is not the place to detect interface removal! This also removes what is basically a nasty (and now unnecessary) hack. - Invoke in_pcbpurgeif0() from in_ifdetach(), in both raw and UDP IPv4 sockets. It is now possible to run the msocket_ifnet_remove regression test using HEAD without panicking. MFC after: 3 days
* 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
* Undo a tad little optimization to bpf_mtap() introduced in rev. 1.95andre2005-09-141-4/+0
| | | | | | | | | which broke the correct handling of the BIOCGSEESENT flag in the bpf listener. PR: kern/56441 Submitted by: <vys at renet.ru> MFC after: 3 days
* Remove bogous semicolons at the end of the definitions ofandre2005-09-141-2/+2
| | | | | | | 'do { ... } while (0)' macros. PR: kern/83088 Sumbitted by: <antoine.brodin at laposte.net>
* In netkqfilter(), return EINVAL instead of 1 (EPERM) when a filter typerwatson2005-09-121-1/+1
| | | | | | is requested on a network interface file descriptor that is non-applicable. MFC after: 3 days
* Forward declare z_errmsg with static linkage since it is definedrodrigc2005-09-111-1/+1
| | | | with static linkage later in the file. Eliminates GCC 4.0 error.
* Protect interface and address lists using the appropriate mutex. Thesecsjp2005-09-101-16/+16
| | | | | | | | | | | | | | | | | | locks were not aquired because the user buffers were not wired, thus it was possible that that SYSCTL_OUT could sleep, causing a number of different problems such as lock ordering issues and dead locks. -Wire user supplied buffer to ensure SYSCTL_OUT will not sleep. -Pickup ifnet locks to protect the list. -Where applicable pickup address locks. -Pickup radix node head locks. -Remove splnet stubs -Remove various comments about locking here, because they are no longer needed. It is the hope that these changes will make sysctl_rtsock MP safe. MFC after: 3 weeks
* Forward declaring static variables as extern is invalid ISO-C. Now thatobrien2005-09-071-1/+1
| | | | GCC can properly handle forward static declarations, do this properly.
* Add support for multicast to the bridge and allow inet6 addresses to bethompsa2005-09-062-6/+28
| | | | | | | | | | | | | | | | 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
* Instead of caching the PID which opened the bpf descriptor, continuouslycsjp2005-09-052-4/+12
| | | | | | | | | | | | | | | | | refresh the PID which has the descriptor open. The PID is refreshed in various operations like ioctl(2), kevent(2) or poll(2). This produces more accurate information about current bpf consumers. While we are here remove the bd_pcomm member of the bpf stats structure because now that we have an accurate PID we can lookup the via the kern.proc.pid sysctl variable. This is the trick that NetBSD decided to use to deal with this issue. Special care needs to be taken when MFC'ing this change, as we have made a change to the bpf stats structure. What will end up happening is we will leave the pcomm structure but just mark it as being un-used. This way we keep the ABI in tact. MFC after: 1 month Discussed with: Rui Paulo < rpaulo at NetBSD dot org >
* reclaim sbuf and clear lock on error in ifconfsam2005-09-041-1/+4
| | | | | | Submitted by: Ted Unangst Reviewed by: rwatson MFC after: 3 days
* Use VLAN_TAG_VALUE() not only to read a dot1q tagyar2005-08-312-3/+8
| | | | | | | | | | | | | 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
* Fix a panic in softclock() if the interface is destroyed with a bpf consumerthompsa2005-08-271-0/+1
| | | | | | | | | | | | | | | | | | attached. This is caused by bpf_detachd clearing IFF_PROMISC on the interface which does a SIOCSIFFLAGS ioctl. The problem here is that while the interface has been stopped, IFF_UP has not been cleared so IFF_UP != IFF_DRV_RUNNING, this causes the ioctl function to init() the interface which resets the callouts. The destroy then completes and frees the softc but softclock will panic on a dead callout pointer. Ensure ifp->if_flags matches reality by clearing IFF_UP when we destroy. Silence from: rwatson Approved by: mlaier (mentor) MFC after: 3 days
* De-spl parts of the routing socket code now generally protectedrwatson2005-08-251-40/+20
| | | | | | | | through locking; leave some spl references around code where there are open questions about global variable references. Also, add an XXX regarding locking in sysctl. MFC after: 3 days
* The mtu check in bridge_enqueue is bogus as the maximum Ethernet frame isthompsa2005-08-231-7/+0
| | | | | | | | | | actually 1514, so comparing the mbuf length which includes the Ethernet header to the interface MTU is wrong. The check was a little over the top so just remove it. Approved by: mlaier (mentor) MFC after: 3 days
* 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
* Introduce two new ioctl(2) commands, BIOCLOCK and BIOCSETWF. These commandscsjp2005-08-223-24/+87
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | enhance the security of bpf(4) by further relinquishing the privilege of the bpf(4) consumer (assuming the ioctl commands are being implemented). Once BIOCLOCK is executed, the device becomes locked which prevents the execution of ioctl(2) commands which can change the underly parameters of the bpf(4) device. An example might be the setting of bpf(4) filter programs or attaching to different network interfaces. BIOCSETWF can be used to set write filters for outgoing packets. Currently if a bpf(4) consumer is compromised, the bpf(4) descriptor can essentially be used as a raw socket, regardless of consumer's UID. Write filters give users the ability to constrain which packets can be sent through the bpf(4) descriptor. These features are currently implemented by a couple programs which came from OpenBSD, such as the new dhclient and pflogd. -Modify bpf_setf(9) to accept a "cmd" parameter. This will be used to specify whether a read or write filter is to be set. -Add a bpf(4) filter program as a parameter to bpf_movein(9) as we will run the filter program on the mbuf data once we move the packet in from user-space. -Rather than execute two uiomove operations, (one for the link header and the other for the packet data), execute one and manually copy the linker header into the sockaddr structure via bcopy. -Restructure bpf_setf to compensate for write filters, as well as read. -Adjust bpf(4) stats structures to include a bd_locked member. It should be noted that the FreeBSD and OpenBSD implementations differ a bit in the sense that we unconditionally enforce the lock, where OpenBSD enforces it only if the calling credential is not root. Idea from: OpenBSD Reviewed by: mlaier
* Add missing braces around bpf_filter which were missed when Icsjp2005-08-181-2/+4
| | | | | | | | merged the bpfstat code. Pointed out by: iedowse Pointy hat to: csjp MFC after: 3 days
OpenPOWER on IntegriCloud