summaryrefslogtreecommitdiffstats
path: root/sys/net/if_tun.c
Commit message (Collapse)AuthorAgeFilesLines
...
* TUNSIFINFO now expects IFF_MULTICAST to be OR'd with either IFF_POINTOPOINTbrian2001-08-251-6/+4
| | | | | | or IFF_BROADCAST. If it's not, the IFF_MULTICAST is removed. This is in line with how NetBSD & OpenBSD do it.
* Don't terminate the uiomove() loop on a zero-length mbuf. It's notfenner2001-08-031-4/+3
| | | | | | | particularly nice that IPSEC inserts a zero-length mbuf into the chain, and that bug should be fixed too, but interfaces should be robust to bad input. Print the interface name when TUNDEBUG()ing about dropping an mbuf.
* Close a race where we were releasing the unit resource at the startbrian2001-06-201-2/+4
| | | | | | | | | | | | of tunclose() rather than the end, and tunopen() grabbed that unit before tunclose() finished (one process is allocating it while another is freeing it!). It may be worth hanging some sort of rw mutex around all specinfo calls where d_close and the detach handler get a write lock and all other functions get a read lock. This would guarantee certain levels of ``atomicity'' (is that a word?) that people may expect (I believe Solaris does something like this).
* Remove the SI_CHEAPCLONE flag when hanging resources off the dev_tbrian2001-06-181-0/+2
|
* Support /dev/tun cloning. Ansify if_tun.c while I'm there.brian2001-06-011-92/+129
| | | | | | | | | | | | | | Only tun0 -> tun32767 may now be opened as struct ifnet's if_unit is a short. It's now possible to open /dev/tun and get a handle back for an available tun device (use devname to find out what you got). The implementation uses rman by popular demand (and against my judgement) to track opened devices and uses the new dev_depends() to ensure that all make_dev()d devices go away before the module is unloaded. Reviewed by: phk
* Make if_tun's clone create SI_CHEAPCLONE devices.phk2001-05-251-0/+1
|
* Dont (ab)use drv2 to know if (si_flags & SI_NAMED) (pointed out by dd)brian2001-04-171-5/+3
| | | | Call cdevsw_remove when we unload.
* Allow MOD_UNLOADs of if_tun, and handle event handler registrationbrian2001-04-031-10/+42
| | | | | | | | failures in MOD_LOAD. Dodge duplicate make_dev() calls by (ab)using dev->si_drv2 to remember if we created the device node via a dev_clone callback before the d_open call.
* Return 0 and do nothing when we get a SIOCSIFFLAGS.brian2001-04-021-0/+1
| | | | | | | Without this, ifpromisc() always fails (after setting the IFF_PROMISC bit in ifp->if_flags) and bpf never bothers to turn promiscuous mode off. PR: 20188
* Send the remains (such as I have located) of "block major numbers" tophk2001-03-261-1/+0
| | | | the bit-bucket.
* Another round of the <sys/queue.h> FOREACH transmogriffer.phk2001-02-041-2/+1
| | | | | Created with: sed(1) Reviewed by: md5(1)
* Use <sys/queue.h> macro api rather than fondle its implementation detals.phk2001-02-031-4/+4
| | | | | Created with: /usr/bin/sed Reviewed by: /sbin/md5
* o Allow non-root users to open /dev/tun* (remove suser()brian2001-02-031-8/+5
| | | | | | | | | | | | | in tunopen()) o Change the default device permissions to 0600 root:wheel (were uucp:dialer) o Only let root (suser()) change the MTU This makes it possible for an administrator to open up the permissions on /dev/tun*, letting non-root programs service a tun interface. Co-operation is still required with a priviledged program that will configure the interface side of things.
* Pass the minor number rather than the unit number to make_dev()brian2001-02-021-2/+1
| | | | from the clone handler.
* Exterminate the use of PSEUDO_SET() with extreme prejudice.peter2001-01-311-11/+23
|
* Convert more malloc+bzero to malloc+M_ZERO.dwmalone2000-12-081-2/+1
| | | | | Submitted by: josh@zipperup.org Submitted by: Robert Drehmel <robd@gmx.net>
* Move the wakeup/signaling of the reader side of the tun device intojlemon2000-12-051-9/+18
| | | | | | a tunstart function, which is called when a packet is sucessfully placed on the queue. This allows us to properly do output byte accounting within the handoff routine.
* Lock down the network interface queues. The queue mutex must be obtainedjlemon2000-11-251-25/+6
| | | | | | | | | | | | | | before adding/removing packets from the queue. Also, the if_obytes and if_omcasts fields should only be manipulated under protection of the mutex. IF_ENQUEUE, IF_PREPEND, and IF_DEQUEUE perform all necessary locking on the queue. An IF_LOCK macro is provided, as well as the old (mutex-less) versions of the macros in the form _IF_ENQUEUE, _IF_QFULL, for code which needs them, but their use is discouraged. Two new macros are introduced: IF_DRAIN() to drain a queue, and IF_HANDOFF, which takes care of locking/enqueue, and also statistics updating/start if necessary.
* Have tuninit() return an error if an interface address is NULL.jlemon2000-11-021-19/+23
| | | | | | SIOCGIFSTATUS was returning at splimp(); fix this. (to be MFC'd) Submitted by: Marius Bendiksen
* BPF wants packets in host byte order whereas TUN_IFHEAD wants thembrian2000-10-151-5/+12
| | | | | | in network byte order. When we've got TUN_IFHEAD set, swap the AF byte order before passing a packet to bpf_mtap().
* Rename lminor() to dev2unit(). This function gives a linear unit numberphk2000-09-191-2/+2
| | | | | | | | | | | | which hides the 'hole' in the minor bits. Introduce unit2minor() to do the reverse operation. Fix some some make_dev() calls which didn't use UID_* or GID_* macros. Kill the v_hashchain alias macro, it hides the real relationship. Introduce experimental SI_CHEAPCLONE flag set it on cloned bpfs.
* Avoid the modules madness I inadvertently introduced by making thephk2000-09-021-14/+2
| | | | | | | | | | | | | | | | | | cloning infrastructure standard in kern_conf. Modules are now the same with or without devfs support. If you need to detect if devfs is present, in modules or elsewhere, check the integer variable "devfs_present". This happily removes an ugly hack from kern/vfs_conf.c. This forces a rename of the eventhandler and the standard clone helper function. Include <sys/eventhandler.h> in <sys/conf.h>: it's a helper #include like <sys/queue.h> Remove all #includes of opt_devfs.h they no longer matter.
* Remove all traces of Julians DEVFS (incl from kern/subr_diskslice.c)phk2000-08-201-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | Remove old DEVFS support fields from dev_t. Make uid, gid & mode members of dev_t and set them in make_dev(). Use correct uid, gid & mode in make_dev in disk minilayer. Add support for registering alias names for a dev_t using the new function make_dev_alias(). These will show up as symlinks in DEVFS. Use makedev() rather than make_dev() for MFSs magic devices to prevent DEVFS from noticing this abuse. Add a field for DEVFS inode number in dev_t. Add new DEVFS in fs/devfs. Add devfs cloning to: disk minilayer (ie: ad(4), sd(4), cd(4) etc etc) md(4), tun(4), bpf(4), fd(4) If DEVFS add -d flag to /sbin/inits args to make it mount devfs. Add commented out DEVFS to GENERIC
* Initialise ifnet::if_typebrian2000-07-171-0/+2
| | | | | PR: 17873 Submitted by: Kensaku Masuda <greg@greg.rim.or.jp>
* Track if_i{bytes,packets,errors}.mdodd2000-02-161-0/+4
| | | | Approved by: jkh
* Remove unused includesbrian2000-01-291-7/+0
|
* Redo the intrq.c idea asbrian2000-01-271-115/+2
| | | | int family_enqueue(sa_family_t, struct mbuf *);
* Move the *intrq variables into net/intrq.c and unconditionallybrian2000-01-241-21/+65
| | | | | | | | | | | include this in all kernels. Declare some const *intrq_present variables that can be checked by a module prior to using *intrq to queue data. Make the if_tun module capable of processing atm, ip, ip6, ipx, natm and netatalk packets when TUNSIFHEAD is ioctl()d on. Review not required by: freebsd-hackers
* Implement TUN[GS]IFHEAD ioctls. Passing a non-zero int to TUNSIFHEADbrian2000-01-231-39/+137
| | | | | | | | | | | tells that tun unit to prepend a four byte address family to packets queued for tunread() and to expect a four byte address family at the front of data received by tunwrite(). We queue any protocol received from the interface for tunread(), but only accept INET, INET6, IPX and NETATALK from tunwrite(). There is support for Xerox's NS stuff, but AFAICT config(8) doesn't ever define NS.
* Add a new TUNSIFPID ioctl to update the tun_pid (recorded inbrian2000-01-211-0/+3
| | | | tunopen) with the current pid.
* Zap #include "tun.h" (for NTUN) - which isn't used anymore.peter1999-09-271-2/+0
|
* Remove five now unused fields from struct cdevsw. They should neverphk1999-09-251-5/+0
| | | | | | | | have been there in the first place. A GENERIC kernel shrinks almost 1k. Add a slightly different safetybelt under nostop for tty drivers. Add some missing FreeBSD tags
* Remove NBPF conditionality of bpf calls in most of our network drivers.phk1999-09-251-9/+2
| | | | | | | | | | | | This means that we will not have to have a bpf and a non-bpf version of our driver modules. This does not open any security hole, because the bpf core isn't loadable The drivers left unchanged are the "cross platform" drivers where the respective maintainers are urged to DTRT, whatever that may be. Add a couple of missing FreeBSD tags.
* Give if_tun the "almost clone" makeover.phk1999-08-151-68/+60
|
* Back out redundant check, and remove the MAXMTU comparison as it'sbrian1999-08-061-7/+4
| | | | | outside of the (bogus) tuninfo mtu range. Pointed out by: bde
* Define IF_MAXMTU and IF_MINMTU and don't allow MTUs withbrian1999-08-061-3/+8
| | | | | | | | | out-of-range values. ``comparison is always 0'' warnings are silly ! Ok'd by: wollman, dg Advised by: bde
* Don't complain if 0 bytes are written to the tun device, simplybrian1999-07-261-1/+4
| | | | do nothing.
* fix a problem w/ zero byte writes to the tunnel device. It would bypassjmg1999-07-231-1/+1
| | | | | | | | | | the loop and not set an error, so we would then try to access an invalid mbuf... PR: 12780 Submitted by: bright@rush.net aka zb^3 a new record in length a pr was open... only about a half hour...
* Rename bpfilter to bpf.des1999-07-061-6/+6
|
* Add a new interface ioctl, to return "aux status".phk1999-06-191-1/+11
| | | | | | | | | | | | | | | | | | | This is inteded for to allow ifconfig to print various unstructured information from an interface. The data is returned from the kernel in ASCII form, see the comment in if.h for some technicalities. Canonical cut&paste example to be found in if_tun.c Initial use: Now tun* interfaces tell the PID of the process which opened them. Future uses could be (volounteers welcome!): Have ppp/slip interfaces tell which tty they use. Make sync interfaces return their media state: red/yellow/blue alarm, timeslot assignment and so on. Make ethernets warn about missing heartbeats and/or cables
* Simplify cdevsw registration.phk1999-05-311-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | The cdevsw_add() function now finds the major number(s) in the struct cdevsw passed to it. cdevsw_add_generic() is no longer needed, cdevsw_add() does the same thing. cdevsw_add() will print an message if the d_maj field looks bogus. Remove nblkdev and nchrdev variables. Most places they were used bogusly. Instead check a dev_t for validity by seeing if devsw() or bdevsw() returns NULL. Move bdevsw() and devsw() functions to kern/kern_conf.c Bump __FreeBSD_version to 400006 This commit removes: 72 bogus makedev() calls 26 bogus SYSINIT functions if_xe.c bogusly accessed cdevsw[], author/maintainer please fix. I4b and vinum not changed. Patches emailed to authors. LINT probably broken until they catch up.
* This commit should be a extensive NO-OP:phk1999-05-301-3/+19
| | | | | | | | | | | | | Reformat and initialize correctly all "struct cdevsw". Initialize the d_maj and d_bmaj fields. The d_reset field was not removed, although it is never used. I used a program to do most of this, so all the files now use the same consistent format. Please keep it that way. Vinum and i4b not modified, patches emailed to respective authors.
* In tunclose():brian1999-05-271-11/+15
| | | | | Delete all routes if IFF_RUNNING is set, irrespective of IFF_UP Unset IFF_RUNNING.
* Add sufficient braces to keep egcs happy about potentially ambiguouspeter1999-05-061-2/+2
| | | | if/else nesting.
* Suser() simplification:phk1999-04-271-1/+1
| | | | | | | | | | | | | | | | | | | 1: s/suser/suser_xxx/ 2: Add new function: suser(struct proc *), prototyped in <sys/proc.h>. 3: s/suser_xxx(\([a-zA-Z0-9_]*\)->p_ucred, \&\1->p_acflag)/suser(\1)/ The remaining suser_xxx() calls will be scrutinized and dealt with later. There may be some unneeded #include <sys/cred.h>, but they are left as an exercise for Bruce. More changes to the suser() API will come along with the "jail" code.
* Implement TUNSIFMODE and TUNSLMODE.des1999-03-241-1/+42
| | | | Submitted by: Alfred Perlstein <bright@cygnus.rush.net>
* Fix warnings in preparation for adding -Wall -Wcast-qual to thedillon1999-01-271-2/+2
| | | | kernel compile
* Undo #undef KERNEL hack for vnode.h to avoid vnode_if.h.peter1999-01-171-6/+0
| | | | | | | | | XXX It probably makes sense to have a flag for bsd.kern.mk to avoid these rules. XXX IO_NDELAY seems to be the main reason for it, when used in a cdevsw read or write "flag" context. Perhaps a redundant declaration somewhere like sys/conf.h might help remove the need for vnode.h in these device drivers in the first place.
* The "easy" fixes for compiling the kernel -Wunused: remove unreferenced staticarchie1998-12-071-1/+0
| | | | and local variables, goto labels, and functions declared but not defined.
* Installed the second patch attached to kern/7899 with some changes suggestedtruckman1998-11-111-11/+18
| | | | | | | | | | | | | | | | by bde, a few other tweaks to get the patch to apply cleanly again and some improvements to the comments. This change closes some fairly minor security holes associated with F_SETOWN, fixes a few bugs, and removes some limitations that F_SETOWN had on tty devices. For more details, see the description on the PR. Because this patch increases the size of the proc and pgrp structures, it is necessary to re-install the includes and recompile libkvm, the vinum lkm, fstat, gcore, gdb, ipfilter, ps, top, and w. PR: kern/7899 Reviewed by: bde, elvind
OpenPOWER on IntegriCloud