aboutsummaryrefslogtreecommitdiff
path: root/sys/net/if_tun.c
Commit message (Collapse)AuthorAgeFilesLines
* Pull in r267961 and r267973 again. Fix for issues reported will follow.Hans Petter Selasky2014-06-281-3/+1
| | | | Notes: svn path=/head/; revision=267992
* Revert r267961, r267973:Glen Barber2014-06-271-1/+3
| | | | | | | | | | | | | These changes prevent sysctl(8) from returning proper output, such as: 1) no output from sysctl(8) 2) erroneously returning ENOMEM with tools like truss(1) or uname(1) truss: can not get etype: Cannot allocate memory Notes: svn path=/head/; revision=267985
* Extend the meaning of the CTLFLAG_TUN flag to automatically check ifHans Petter Selasky2014-06-271-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | there is an environment variable which shall initialize the SYSCTL during early boot. This works for all SYSCTL types both statically and dynamically created ones, except for the SYSCTL NODE type and SYSCTLs which belong to VNETs. A new flag, CTLFLAG_NOFETCH, has been added to be used in the case a tunable sysctl has a custom initialisation function allowing the sysctl to still be marked as a tunable. The kernel SYSCTL API is mostly the same, with a few exceptions for some special operations like iterating childrens of a static/extern SYSCTL node. This operation should probably be made into a factored out common macro, hence some device drivers use this. The reason for changing the SYSCTL API was the need for a SYSCTL parent OID pointer and not only the SYSCTL parent OID list pointer in order to quickly generate the sysctl path. The motivation behind this patch is to avoid parameter loading cludges inside the OFED driver subsystem. Instead of adding special code to the OFED driver subsystem to post-load tunables into dynamically created sysctls, we generalize this in the kernel. Other changes: - Corrected a possibly incorrect sysctl name from "hw.cbb.intr_mask" to "hw.pcic.intr_mask". - Removed redundant TUNABLE statements throughout the kernel. - Some minor code rewrites in connection to removing not needed TUNABLE statements. - Added a missing SYSCTL_DECL(). - Wrapped two very long lines. - Avoid malloc()/free() inside sysctl string handling, in case it is called to initialize a sysctl from a tunable, hence malloc()/free() is not ready when sysctls from the sysctl dataset are registered. - Bumped FreeBSD version to indicate SYSCTL API change. MFC after: 2 weeks Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=267961
* Remove AppleTalk support.Gleb Smirnoff2014-03-141-6/+0
| | | | | | | | | | | | | AppleTalk was a network transport protocol for Apple Macintosh devices in 80s and then 90s. Starting with Mac OS X in 2000 the AppleTalk was a legacy protocol and primary networking protocol is TCP/IP. The last Mac OS X release to support AppleTalk happened in 2009. The same year routing equipment vendors (namely Cisco) end their support. Thus, AppleTalk won't be supported in FreeBSD 11.0-RELEASE. Notes: svn path=/head/; revision=263152
* Remove IPX support.Gleb Smirnoff2014-03-141-6/+0
| | | | | | | | | | | | | | IPX was a network transport protocol in Novell's NetWare network operating system from late 80s and then 90s. The NetWare itself switched to TCP/IP as default transport in 1998. Later, in this century the Novell Open Enterprise Server became successor of Novell NetWare. The last release that claimed to still support IPX was OES 2 in 2007. Routing equipment vendors (e.g. Cisco) discontinued support for IPX in 2011. Thus, IPX won't be supported in FreeBSD 11.0-RELEASE. Notes: svn path=/head/; revision=263140
* Teach every SIOCGIFSTATUS provider to fill in ifs->ascii anyway.Alexander V. Chernikov2014-01-071-1/+3
| | | | | | | | | | | | Remove old bits of data concat for 'ascii' field. Remove special SIOCGIFSTATUS handling from if.c (which Coverity yells at). Reported by: Coverity Coverity CID: 1147174 MFC after: 2 weeks Notes: svn path=/head/; revision=260394
* Restore the entropy gathering from the m_data pointer value, not theAdrian Chadd2013-11-021-1/+1
| | | | | | | | | m_data payload. After talking with markm/bde, this is what markm actually intended. Notes: svn path=/head/; revision=257548
* Convert the random entropy harvesting code to use a const void * pointerAdrian Chadd2013-11-011-1/+1
| | | | | | | | | | | | | | rather than just void *. Then, as part of this, convert a couple of mbuf m->m_data accesses to mtod(m, const void *). Reviewed by: markm Approved by: security-officer (delphij) Sponsored by: Netflix, Inc. Notes: svn path=/head/; revision=257525
* The r48589 promised to remove implicit inclusion of if_var.h soon. PrepareGleb Smirnoff2013-10-261-0/+1
| | | | | | | | | | | to this event, adding if_var.h to files that do need it. Also, include all includes that now are included due to implicit pollution via if_var.h Sponsored by: Netflix Sponsored by: Nginx, Inc. Notes: svn path=/head/; revision=257176
* Debug run. This now works, except that the "live" sources haven'tMark Murray2013-10-061-1/+1
| | | | | | | | | | | | | | | been tested. With all sources turned on, this unlocks itself in a couple of seconds! That is no my box, and there is no guarantee that this will be the case everywhere. * Cut debug prints. * Use the same locks/mutexes all the way through. * Be a tad more conservative about entropy estimates. Notes: svn path=/projects/random_number_generator/; revision=256086
* Snapshot. This passes the build test, but has not yet been finished or debugged.Mark Murray2013-10-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Contains: * Refactor the hardware RNG CPU instruction sources to feed into the software mixer. This is unfinished. The actual harvesting needs to be sorted out. Modified by me (see below). * Remove 'frac' parameter from random_harvest(). This was never used and adds extra code for no good reason. * Remove device write entropy harvesting. This provided a weak attack vector, was not very good at bootstrapping the device. To follow will be a replacement explicit reseed knob. * Separate out all the RANDOM_PURE sources into separate harvest entities. This adds some secuity in the case where more than one is present. * Review all the code and fix anything obviously messy or inconsistent. Address som review concerns while I'm here, like rename the pseudo-rng to 'dummy'. Submitted by: Arthur Mesh <arthurmesh@gmail.com> (the first item) Notes: svn path=/projects/random_number_generator/; revision=256042
* Clear knlist before destroying it in tap(4) and tun(4). This fixes laterGleb Smirnoff2013-10-021-0/+1
| | | | | | | | | crash, when a kqueue descriptor tries to dereference appropriate knotes. Approved by: re (kib) Notes: svn path=/head/; revision=256008
* Clean up SIOCSIFDSTADDR usage from ifnet drivers. The ioctl itself isGleb Smirnoff2013-09-111-4/+0
| | | | | | | | | | | extremely outdated, and I doubt that it was ever used for ifnet drivers. It was used for AF_INET sockets in pre-FreeBSD time. Approved by: re (hrs) Sponsored by: Nginx, Inc. Notes: svn path=/head/; revision=255471
* Bring in some behind-the-scenes development, mainly By Arthur Mesh,Mark Murray2013-09-071-2/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the rest by me. o Namespace cleanup; the Yarrow name is now restricted to where it really applies; this is in anticipation of being augmented or replaced by Fortuna in the future. Fortuna is mentioned, but behind #if logic, and is ignorable for now. o The harvest queue is pulled out into its own modules. o Entropy harvesting is emproved, both by being made more conservative, and by separating (a bit!) the sources. Available entropy crumbs are marginally improved. o Selection of sources is made clearer. With recent revelations, this will receive more work in the weeks and months to come. Submitted by: Arthur Mesh (partly) <arthurmesh@gmail.com> Notes: svn path=/head/; revision=255362
| * Snapshot; Do some running repairs on entropy harvesting. More needs to follow.Mark Murray2013-08-261-2/+1
| | | | | | | | Notes: svn path=/projects/random_number_generator/; revision=254928
* | Don't clear the unused SI_CHEAPCLONE flag in tap_create()/tuncreate().Davide Italiano2013-09-071-2/+0
|/ | | | | | | Reviewed by: kib Notes: svn path=/head/; revision=255360
* Add a missing module version declaration to if_tun(4).Mark Johnston2013-08-071-0/+1
| | | | | | | | | PR: 181078 Submitted by: Brandon Gooch <jamesbrandongooch@gmail.com> MFC after: 1 week Notes: svn path=/head/; revision=254020
* Add const qualifier to the dst parameter of the ifnet if_output method.Gleb Smirnoff2013-04-261-11/+9
| | | | Notes: svn path=/head/; revision=249925
* Mechanically substitute flags from historic mbuf allocator withGleb Smirnoff2012-12-051-3/+3
| | | | | | | | | | | | malloc(9) flags within sys. Exceptions: - sys/contrib not touched - sys/mbuf.h edited manually Notes: svn path=/head/; revision=243882
* Make the "struct if_clone" opaque to users of the cloning API. UsersGleb Smirnoff2012-10-161-12/+12
| | | | | | | | | | | | | | | now use function calls: if_clone_simple() if_clone_advanced() to initialize a cloner, instead of macros that initialize if_clone structure. Discussed with: brooks, bz, 1 year ago Notes: svn path=/head/; revision=241610
* Revert previous commit...Kevin Lo2012-10-101-1/+1
| | | | | | | Pointyhat to: kevlo (myself) Notes: svn path=/head/; revision=241394
* Prefer NULL over 0 for pointersKevin Lo2012-10-091-1/+1
| | | | Notes: svn path=/head/; revision=241370
* Remove an incorrect commentEd Maste2012-09-251-1/+0
| | | | Notes: svn path=/head/; revision=240932
* Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs.Ed Schouten2011-11-071-1/+1
| | | | | | | | | The SYSCTL_NODE macro defines a list that stores all child-elements of that node. If there's no SYSCTL_DECL macro anywhere else, there's no reason why it shouldn't be static. Notes: svn path=/head/; revision=227309
* Get rid of D_PSEUDO.Ed Schouten2011-10-181-1/+1
| | | | | | | | | | | | | It seems the D_PSEUDO flag was meant to allow make_dev() to return NULL. Nowadays we have a different interface for that; make_dev_p(). There's no need to keep it there. While there, remove an unneeded D_NEEDMINOR from the gpio driver. Discussed with: gonzo@ (gpio) Notes: svn path=/head/; revision=226500
* Fix a deficiency in the selinfo interface:Attilio Rao2011-08-251-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a selinfo object is recorded (via selrecord()) and then it is quickly destroyed, with the waiters missing the opportunity to awake, at the next iteration they will find the selinfo object destroyed, causing a PF#. That happens because the selinfo interface has no way to drain the waiters before to destroy the registered selinfo object. Also this race is quite rare to get in practice, because it would require a selrecord(), a poll request by another thread and a quick destruction of the selrecord()'ed selinfo object. Fix this by adding the seldrain() routine which should be called before to destroy the selinfo objects (in order to avoid such case), and fix the present cases where it might have already been called. Sometimes, the context is safe enough to prevent this type of race, like it happens in device drivers which installs selinfo objects on poll callbacks. There, the destruction of the selinfo object happens at driver detach time, when all the filedescriptors should be already closed, thus there cannot be a race. For this case, mfi(4) device driver can be set as an example, as it implements a full correct logic for preventing this from happening. Sponsored by: Sandvine Incorporated Reported by: rstone Tested by: pluknet Reviewed by: jhb, kib Approved by: re (bz) MFC after: 3 weeks Notes: svn path=/head/; revision=225177
* Tag mbufs of all incoming frames or packets with the interface's FIBBjoern A. Zeeb2011-07-031-0/+1
| | | | | | | | | | | | setting (either default or if supported as set by SIOCSIFFIB, e.g. from ifconfig). Submitted by: Alexander V. Chernikov (melifaro ipfw.ru) Reviewed by: julian MFC after: 2 weeks Notes: svn path=/head/; revision=223741
* Properly return an ENOBUFS error if a write to a tun(4) device failsJohn Baldwin2011-06-031-10/+7
| | | | | | | | | | | | | | due to m_uiotombuf() failing. While here, trim unneeded error handling related to tuninit() since it can never fail. Submitted by: Martin Birgmeier la5lbtyi aon at Reviewed by: glebius MFC after: 1 week Notes: svn path=/head/; revision=222651
* Fix white space nits and stylePyun YongHyeon2011-05-061-9/+7
| | | | Notes: svn path=/head/; revision=221552
* Do not increment collision counter if transmit have failed.Pyun YongHyeon2011-05-061-3/+1
| | | | | | | | | | Transmission error in tun(4) is queueing error(i.e. ENOBUFS) and it has nothing to do with collision. Reported by: Zeus V Panchenko (zeus <> ibs dot dn dot ua) Notes: svn path=/head/; revision=221548
* Only hide the ifa and not the tp under #ifdef INET as the tp is neededBjoern A. Zeeb2010-10-011-1/+1
| | | | | | | | | for locking evenwhen there is no INET. MFC after: 3 days Notes: svn path=/head/; revision=213328
* - Expand scope of tun/tap softc locks to cover more softc fields andJohn Baldwin2010-09-221-54/+34
| | | | | | | | | | | | | | | | | | | | driver-maintained ifnet fields (such as if_drv_flags). - Use soft locks as the mutex that protects each interface's knote list rather than using the global knote list lock. Also, use the softc for kn_hook instead of the cdev. - Use mtx_sleep() instead of tsleep() when blocking in the read routines. This fixes a lost wakeup race. - Remove D_NEEDGIANT now that the cdevsw routines use the softc lock where locking is needed. - Lock IFQ when calculating the result for FIONREAD in tap(4). tun(4) already did this. - Remove remaining spl calls. Submitted by: Marcin Cieslak saper of saper|info (3) MFC after: 2 weeks Notes: svn path=/head/; revision=213028
* Verify interface up status using its link state onlyQing Li2010-03-161-0/+2
| | | | | | | | | | | | | | | | | if the interface has such capability. The interface capability flag indicates whether such capability exists. This approach is much more backward compatible. Physical device driver changes will be part of another commit. Also updated the ifconfig utility to show the LINKSTATE capability if present. Reviewed by: rwatson, imp, juli MFC after: 3 days Notes: svn path=/head/; revision=205222
* In both if_tun and if_tap:Konstantin Belousov2010-02-281-9/+2
| | | | | | | | | | | | | | | | | | | Do not do additional dev_ref() on the newly created interface in the if_clone create method [1]. This reference is not needed and never removed, causing struct cdevpriv leakage. Remove the setting of SI_CHEAPCLONE flag as well, since it is unused. For dev_clone handlers, create cdevs with the call make_dev_credf(MAKEDEV_REF) instead of calling make_dev() and then dev_ref(), to avoid a race. Call drain_dev_clone_events() at the module unload time after dev_clone handler is deinstalled. Submitted by: Mikolaj Golub <to.my.trociny gmail com> [1] MFC after: 1 week Notes: svn path=/head/; revision=204464
* Merge the remainder of kern_vimage.c and vimage.h into vnet.c andRobert Watson2009-08-011-1/+1
| | | | | | | | | | | | | vnet.h, we now use jails (rather than vimages) as the abstraction for virtualization management, and what remained was specific to virtual network stacks. Minor cleanups are done in the process, and comments updated to reflect these changes. Reviewed by: bz Approved by: re (vimage blanket) Notes: svn path=/head/; revision=196019
* Update if_stf and if_tun to use if_addr_rlock()/if_addr_runlock() ratherRobert Watson2009-06-261-2/+2
| | | | | | | | | than IF_ADDR_LOCK()/IF_ADDR_UNLOCK() when iterating ifp->if_addrhead. MFC after: 6 weeks Notes: svn path=/head/; revision=195022
* Change the type of uio_resid member of struct uio from int to ssize_t.Konstantin Belousov2009-06-251-1/+1
| | | | | | | | | | | Note that this does not actually enable full-range i/o requests for 64 architectures, and is done now to update KBI only. Tested by: pho Reviewed by: jhb, bde (as part of the review of the bigger patch) Notes: svn path=/head/; revision=194990
* Add explicit includes for jail.h to the files that need them andBjoern A. Zeeb2009-06-171-0/+1
| | | | | | | remove the "hidden" one from vimage.h. Notes: svn path=/head/; revision=194368
* Get vnets from creds instead of threads where they're available, and fromJamie Gritton2009-06-151-1/+1
| | | | | | | | | | passed threads instead of curthread. Reviewed by: zec, julian Approved by: bz (mentor) Notes: svn path=/head/; revision=194252
* Adapt vfs kqfilter to the shared vnode lock used by zfs write vop. UseKonstantin Belousov2009-06-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | vnode interlock to protect the knote fields [1]. The locking assumes that shared vnode lock is held, thus we get exclusive access to knote either by exclusive vnode lock protection, or by shared vnode lock + vnode interlock. Do not use kl_locked() method to assert either lock ownership or the fact that curthread does not own the lock. For shared locks, ownership is not recorded, e.g. VOP_ISLOCKED can return LK_SHARED for the shared lock not owned by curthread, causing false positives in kqueue subsystem assertions about knlist lock. Remove kl_locked method from knlist lock vector, and add two separate assertion methods kl_assert_locked and kl_assert_unlocked, that are supposed to use proper asserts. Change knlist_init accordingly. Add convenience function knlist_init_mtx to reduce number of arguments for typical knlist initialization. Submitted by: jhb [1] Noted by: jhb [2] Reviewed by: jhb Tested by: rnoland Notes: svn path=/head/; revision=193951
* Move "options MAC" from opt_mac.h to opt_global.h, as it's now in GENERICRobert Watson2009-06-051-1/+0
| | | | | | | | | | | and used in a large number of files, but also because an increasing number of incorrect uses of MAC calls were sneaking in due to copy-and-paste of MAC-aware code without the associated opt_mac.h include. Discussed with: pjd Notes: svn path=/head/; revision=193511
* Acquire interfce address list lock while walking the interface addressRobert Watson2009-04-201-0/+2
| | | | | | | | | list during tun device initialization. MFC after: 2 weeks Notes: svn path=/head/; revision=191343
* Change if_output to take a struct route as its fourth argument in orderKip Macy2009-04-161-2/+2
| | | | | | | | | to allow passing a cached struct llentry * down to L2 Reviewed by: rwatson Notes: svn path=/head/; revision=191148
* The "tun?" dev need not be opened at all. One is allowed to performQing Li2008-12-251-4/+2
| | | | | | | | | | | | | | | the following operations, e.g.: 1) ifconfig tun0 create 2) ifconfig tun0 10.1.1.1 10.1.1.2 3) route add -net 192.103.54.0/24 -iface tun0 4) ifconfig tun0 destroy If cv wait on the TUN_CLOSED flag, then the last operation (4) will block forever. Revert the previous changes and fix the mtx_unlock() leak. Notes: svn path=/head/; revision=186497
* - Close a race during which the open flag could be cleared but the tun_softc ↵Kip Macy2008-12-251-2/+6
| | | | | | | | | | | | would still be referenced by adding a separate TUN_CLOSED flag that is set after tunclose is done referencing it. - drop the tun_mtx after the flag check to avoid holding it across if_detach which can recurse in to if_tun.c Notes: svn path=/head/; revision=186483
* Provide a condition variable to delay the cloned interfaceQing Li2008-12-221-3/+12
| | | | | | | | | | | destroy operation until the referenced clone device has been closed by the process properly. The behavior is now consistently with the previous release. Reviewed by: Kip Macy Notes: svn path=/head/; revision=186391
* Consider processes attaching/detaching from tun(4) devices as being linkChristian S.J. Peron2008-12-121-0/+2
| | | | | | | | | | | | | | state changes. This change modifies tunopen and tunclose to call the if_link_state_change() function. Among other things, this will result in devd(8) receiving events from devctl(4) for linkup/link down. This allows us to do several useful things, including initializing tunnel parameters and adding routes. Discussed on: freebsd-net@ MFC after: 2 weeks Notes: svn path=/head/; revision=185963
* convert calls to IFQ_HANDOFF to if_transmitKip Macy2008-11-221-1/+1
| | | | Notes: svn path=/head/; revision=185164
* Make tun(4) compile without INET.Bjoern A. Zeeb2008-11-051-0/+2
| | | | | | | MFC after: 2 months Notes: svn path=/head/; revision=184679
* Retire the MALLOC and FREE macros. They are an abomination unto style(9).Dag-Erling Smørgrav2008-10-231-1/+1
| | | | | | | MFC after: 3 months Notes: svn path=/head/; revision=184205