summaryrefslogtreecommitdiffstats
path: root/sys/netgraph/ng_device.c
Commit message (Collapse)AuthorAgeFilesLines
* Retire the MALLOC and FREE macros. They are an abomination unto style(9).des2008-10-231-3/+3
| | | | MFC after: 3 months
* Remove unit2minor() use from kernel code.ed2008-09-261-1/+1
| | | | | | | | | | | | | | | When I changed kern_conf.c three months ago I made device unit numbers equal to (unneeded) device minor numbers. We used to require bitshifting, because there were eight bits in the middle that were reserved for a device major number. Not very long after I turned dev2unit(), minor(), unit2minor() and minor2unit() into macro's. The unit2minor() and minor2unit() macro's were no-ops. We'd better not remove these four macro's from the kernel, because there is a lot of (external) code that may still depend on them. For now it's harmless to remove all invocations of unit2minor() and minor2unit(). Reviewed by: kib
* Rename m_getm() to m_getm2() and rewrite it to allocate up to page sizedandre2006-11-021-1/+1
| | | | | | | | | | | | | | mbuf clusters. Add a flags parameter to accept M_PKTHDR and M_EOR mbuf chain flags. Provide compatibility macro for m_getm() calling m_getm2() with M_PKTHDR set. Rewrite m_uiotombuf() to use m_getm2() for mbuf allocation and do the uiomove() in a tight loop over the mbuf chain. Add a flags parameter to accept mbuf flags to be passed to m_getm2(). Adjust all callers for the extra parameter. Sponsored by: TCP/IP Optimization Fundraise 2005 MFC after: 3 month
* Change m_uiotombuf so it will accept offset at which data should be copiedemax2005-05-041-1/+1
| | | | | | | | | | to the mbuf. Offset cannot exceed MHLEN bytes. This is currently used to fix Ethernet header alignment problem on alpha and sparc64. Also change all users of m_uiotombuf to pass proper offset. Reviewed by: jmg, sam Tested by: Sten Spans "sten AT blinkenlights DOT nl" MFC after: 1 week
* o Use subr_unit allocator. This simplifies code much:glebius2005-03-141-95/+33
| | | | | | | | | - Remove get_free_unit(). - Remove SLIST of nodes. - Remove global mutex. o Increase NGD_MAX to 999. o Move ngd_mod_event() up to netgraph methods.
* Make WITNESS happier:glebius2005-02-141-20/+14
| | | | | | | | - refactor ngd_constructor, so that make_dev() is called without any locks held, since it mallocs memory with M_WAITOK flag. - rename global mtx, to have name different to per-node mtx MFC after: 2 weeks
* Create a per-module mutex on MOD_LOAD, and destroy it on MOD_UNLOAD.ru2005-02-051-1/+24
| | | | | | (This fixes witness_destroy() panic after module unload.) OK'ed by: rwatson, julian
* /* -> /*- for license, minor formatting changesimp2005-01-071-1/+1
|
* tsleep => msleeprik2004-12-261-2/+2
| | | | | | | | | read sys/kern/kern_synch.c, msleep (): KASSERT(timo != 0 || mtx_owned(&Giant) || mtx != NULL, ("sleeping without a mutex")); MFC after: 3 days
* Add myself to copyright.glebius2004-11-101-0/+1
| | | | Approved by: marks
* Since last change moved ';' from macro to code, we need to embraceglebius2004-10-311-2/+2
| | | | | | | | macros with 'do {} while (0)' to avoid error in case macro is not defined. Prodded by: julian, archie Pointy hat to: glebius
* Rename debug macro to DBG and indent it properly.glebius2004-10-281-12/+13
| | | | | Requested by: maxim Approved by: julian (mentor)
* Major overhaul.glebius2004-10-181-358/+271
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | List of functional changes: - Make a single device per single node with a single hook. This gives us parrallelizm, which can't be achieved on a single node with many devices/hooks. This also gives us flexibility - we can play with a particular device node, not affecting others. - Remove read queue as it is. Use struct ifqueue instead. This change removes a lot of extra memcpy()ing, m_devget()ting and m_copymem()ming. In ng_device_receivedata() we enqueue an mbuf and wake readers. In ngdread() we take one mbuf from qeueue and uiomove() it to userspace. If no mbuf is present we optionally block. [1] - In ngdwrite() we create an mbuf from uio using m_uiotombuf(). This is faster then uiomove() into buffer, and then m_copydata(), and this is much better than huge m_pullup(). - Perform locking of device - Perform locking of connection list. - Clear out _rcvmsg method, since it does nothing good yet. - Implement NGM_DEVICE_GET_DEVNAME message. - #if 0 ioctl method, while nothing is done here yet. - Return immediately from ngdwrite() if uio_resid == 0. List of tidyness changes: - Introduce device2priv(), to remove cut'n'paste. - Use MALLOC/FREE, instead of malloc/free. - Use unit2minor(). - Use UID_ROOT/GID_WHEEL instead of 0/0. - Define NGD_DEVICE_DEVNAME, use it. - Use more nice macros for debugging. [2] - Return Exxx, not -1. style(9) changes: - No "#endif" after short block. - Break long lines. - Remove extra spaces, add needed spaces. [1] Obtained from: if_tun.c [2] Obtained from: ng_pppoe.c Reviewed by: marks Approved by: julian (mentor) MFC after: 1 month
* In ng_device_newhook():glebius2004-07-201-38/+38
| | | | | | | | | | | | | | | | | | | | | | | | | - Return meaningful return errorcodes. - Free previously allocated connection in error cases. In ng_device_rcvdata(): - Return meaningful return errorcodes. - Detach mbuf from netgraph item, and free the item before doing any other actions that may return from method. - Do not call strange malloc() for buffer. [1] - In case of any error jump to end, where mbuf is freed. In ng_device_disconnect(): - Return meaningful return errorcodes. - Free disconnected connection. style(9) in mentioned above functions: - Remove '/* NGD_DEBUG */', when only one line is ifdef'ed. - Remove extra braces to easier reading. - Add space after comma in function calls. PR: kern/41881 (part) Reviewed by: marks Approved by: julian (mentor)
* 1. Make ng_device.h system include. This fixes module build.glebius2004-07-201-10/+8
| | | | | | | | | 2. Sort includes, while here. 3. s/NULL/0/ in NG_SEND_MSG_HOOK(), since ng_ID_t is integer. PR: kern/41881 (part) Reviewed by: marks Approved by: julian (mentor)
* Remove 3rd clause from the licence.marks2004-06-291-2/+0
| | | | Approved by: njl
* Do the dreaded s/dev_t/struct cdev */phk2004-06-161-7/+7
| | | | Bump __FreeBSD_version accordingly.
* Switch to using C99 sparse initialisers for the type methods array.julian2004-05-291-12/+9
| | | | | | | | Should make no binary difference. Submitted by: Gleb Smirnoff <glebius@cell.sick.ru> Reviewed by: Harti Brandt <harti@freebsd.org> MFC after: 1 week
* Device megapatch 4/6:phk2004-02-211-0/+2
| | | | | | | | Introduce d_version field in struct cdevsw, this must always be initialized to D_VERSION. Flip sense of D_NOGIANT flag to D_NEEDGIANT, this involves removing four D_NOGIANT flags and adding 145 D_NEEDGIANT flags.
* Device megapatch 1/6:phk2004-02-211-2/+0
| | | | | | | Free approx 86 major numbers with a mostly automatically generated patch. A number of strategic drivers have been left behind by caution, and a few because they still (ab)use their major number.
* Get rid of the deprecated *LEN constants in favour of the newharti2004-01-261-1/+1
| | | | *SIZ constants that include the trailing \0 byte.
* Gigacommit to improve device-driver source compatibility betweenphk2003-03-031-13/+8
| | | | | | | | | | | | | branches: Initialize struct cdevsw using C99 sparse initializtion and remove all initializations to default values. This patch is automatically generated and has been tested by compiling LINT with all the fields in struct cdevsw in reverse order on alpha, sparc64 and i386. Approved by: re(scottl)
* Catch more uses of MIN().alfred2003-02-021-3/+0
|
* A node that creates a device entry in /dev (yay devfs)julian2002-06-181-0/+637
so that /dev/mumble can be the entrypoint to some networking graph, e.g. a tunnel or a remote tape drive or whatever... Not fully tested (by me) yet. Submitted by: Mark Santcroos <marks@ripe.net> MFC after: 3 weeks
OpenPOWER on IntegriCloud