aboutsummaryrefslogtreecommitdiff
path: root/sys/netgraph/ng_device.c
Commit message (Collapse)AuthorAgeFilesLines
* net: clean up empty lines in .c and .h filesMateusz Guzik2020-09-011-1/+0
| | | | Notes: svn path=/head/; revision=365071
* I doubt anybody in the world uses ng_device, but its write method shouldGleb Smirnoff2020-02-051-0/+5
| | | | | | | also enter the network epoch when sending data from user level to netgraph. Notes: svn path=/head/; revision=357559
* sys: general adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-271-0/+2
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. No functional change intended. Notes: svn path=/head/; revision=326272
* Remove ifq_drops from struct ifqueue. Now queue drops are accounted inGleb Smirnoff2014-09-191-1/+0
| | | | | | | | | | | | | struct ifnet if_oqdrops. Some netgraph modules used ifqueue w/o ifnet. Accounting of queue drops is simply removed from them. There were no API to read this statistic. Sponsored by: Netflix Sponsored by: Nginx, Inc. Notes: svn path=/head/; revision=271856
* Mechanically substitute flags from historic mbuf allocator withGleb Smirnoff2012-12-051-1/+1
| | | | | | | | | | | | malloc(9) flags within sys. Exceptions: - sys/contrib not touched - sys/mbuf.h edited manually Notes: svn path=/head/; revision=243882
* Remove direct access to si_name.Ed Schouten2012-02-101-2/+3
| | | | | | | | | | | Code should just use the devtoname() function to obtain the name of a character device. Also add const keywords to pieces of code that need it to build properly. MFC after: 2 weeks Notes: svn path=/head/; revision=231378
* Node constructor methods are supposed to be called in syscallGleb Smirnoff2011-04-181-3/+1
| | | | | | | | | | context always. Convert nodes to consistently use M_WAITOK flag for memory allocation. Reviewed by: julian Notes: svn path=/head/; revision=220768
* Retire the MALLOC and FREE macros. They are an abomination unto style(9).Dag-Erling Smørgrav2008-10-231-3/+3
| | | | | | | MFC after: 3 months Notes: svn path=/head/; revision=184205
* Remove unit2minor() use from kernel code.Ed Schouten2008-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 Notes: svn path=/head/; revision=183381
* Rename m_getm() to m_getm2() and rewrite it to allocate up to page sizedAndre Oppermann2006-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 Notes: svn path=/head/; revision=163915
* Change m_uiotombuf so it will accept offset at which data should be copiedMaksim Yevmenkin2005-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 Notes: svn path=/head/; revision=145883
* o Use subr_unit allocator. This simplifies code much:Gleb Smirnoff2005-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. Notes: svn path=/head/; revision=143593
* Make WITNESS happier:Gleb Smirnoff2005-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 Notes: svn path=/head/; revision=141914
* Create a per-module mutex on MOD_LOAD, and destroy it on MOD_UNLOAD.Ruslan Ermilov2005-02-051-1/+24
| | | | | | | | | (This fixes witness_destroy() panic after module unload.) OK'ed by: rwatson, julian Notes: svn path=/head/; revision=141341
* /* -> /*- for license, minor formatting changesWarner Losh2005-01-071-1/+1
| | | | Notes: svn path=/head/; revision=139823
* tsleep => msleepRoman Kurakin2004-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 Notes: svn path=/head/; revision=139331
* Add myself to copyright.Gleb Smirnoff2004-11-101-0/+1
| | | | | | | Approved by: marks Notes: svn path=/head/; revision=137525
* Since last change moved ';' from macro to code, we need to embraceGleb Smirnoff2004-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 Notes: svn path=/head/; revision=137100
* Rename debug macro to DBG and indent it properly.Gleb Smirnoff2004-10-281-12/+13
| | | | | | | | Requested by: maxim Approved by: julian (mentor) Notes: svn path=/head/; revision=137022
* Major overhaul.Gleb Smirnoff2004-10-181-354/+267
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=136673
* In ng_device_newhook():Gleb Smirnoff2004-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) Notes: svn path=/head/; revision=132448
* 1. Make ng_device.h system include. This fixes module build.Gleb Smirnoff2004-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) Notes: svn path=/head/; revision=132446
* Remove 3rd clause from the licence.Mark Santcroos2004-06-291-2/+0
| | | | | | | Approved by: njl Notes: svn path=/head/; revision=131271
* Do the dreaded s/dev_t/struct cdev */Poul-Henning Kamp2004-06-161-7/+7
| | | | | | | Bump __FreeBSD_version accordingly. Notes: svn path=/head/; revision=130585
* Switch to using C99 sparse initialisers for the type methods array.Julian Elischer2004-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 Notes: svn path=/head/; revision=129823
* Device megapatch 4/6:Poul-Henning Kamp2004-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. Notes: svn path=/head/; revision=126080
* Device megapatch 1/6:Poul-Henning Kamp2004-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. Notes: svn path=/head/; revision=126076
* Get rid of the deprecated *LEN constants in favour of the newHartmut Brandt2004-01-261-1/+1
| | | | | | | *SIZ constants that include the trailing \0 byte. Notes: svn path=/head/; revision=125028
* Gigacommit to improve device-driver source compatibility betweenPoul-Henning Kamp2003-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) Notes: svn path=/head/; revision=111815
* Catch more uses of MIN().Alfred Perlstein2003-02-021-3/+0
| | | | Notes: svn path=/head/; revision=110234
* A node that creates a device entry in /dev (yay devfs)Julian Elischer2002-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 Notes: svn path=/head/; revision=98402