Home | History | Annotate | Download | only in net
History log of /src/sys/net/if_tap.c
RevisionDateAuthorComments
 1.136  10-Nov-2024  mlelstv Add MBUFTRACE
 1.135  08-Sep-2024  rillig fix a/an grammar in obvious cases
 1.134  18-Aug-2024  rin if_tap: Explicitly include "opt_net_mpsafe.h", NFC

because it was included via <net/if.h> anyway.
 1.133  05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.132  17-Apr-2024  riastradh tap(4): Just use mutex_enter.

PR kern/58167
 1.131  17-Apr-2024  riastradh tap(4): Use DETACH_FORCE with config_detach.

It doesn't make a difference here, because tap_detach never fails,
but let's make it more obvious at the call site that failure is
forbidden here.

No functional change intended.

PR kern/58166
 1.130  17-Apr-2024  riastradh tap(4): Prune dead branches around tap_dev_destroyer.

No functional change intended.

PR kern/58166
 1.129  17-Apr-2024  riastradh tap(4): Prune dead branches around tap_dev_close.

No functional change intended.

PR kern/58166
 1.128  06-Jan-2023  ozaki-r tap: link up an interface cloned from /dev/tap

Fix PR 57155 (partially)
 1.127  10-Apr-2022  andvar branches: 1.127.4;
fix various typos in comments and output/log messages.
 1.126  31-Mar-2022  pgoyette For device modules that provide both auto-config and /dev/xxx
interfaces, make sure that initialization and destruction
follow the proper sequence. This is triggered by the recent
changes to the devsw stuff; per riastradh@ the required call
sequence is:

devsw_attach()
config_init_component() or config_cf*_attach()
...
config_fini_component() or config_cf*_detach()
devsw_detach()

While here, add a few missing calls to some of the detach
routines.

Testing of these changes has been limited to:
1. compile without build break
2. no related test failures from atf
3. modload/modunload work as well as
before.

No functional device testing done, since I don't have any
of these devices. Let me know of any damage I might cause
here!

XXX Some of the modules affected by this commit are already
XXX broken; see kern/56772. This commit does not break
any additional modules (as far as I know).
 1.125  28-Mar-2022  riastradh driver(9): devsw_detach never fails. Make it return void.

Prune a whole lotta dead branches as a result of this. (Some logic
calling this is also wrong for other reasons; devsw_detach is final
-- you should never have any reason to decide to roll it back. To be
cleaned up in subsequent commits...)

XXX kernel ABI change to devsw_detach signature requires bump
 1.124  26-Sep-2021  thorpej Use seltrue_filtops rather than rolling our own with filt_seltrue.
 1.123  26-Sep-2021  thorpej Change the kqueue filterops::f_isfd field to filterops::f_flags, and
define a flag FILTEROP_ISFD that has the meaning of the prior f_isfd.
Field and flag name aligned with OpenBSD.

This does not constitute a functional or ABI change, as the field location
and size, and the value placed in that field, are the same as the previous
code, but we're bumping __NetBSD_Version__ so 3rd-party module source code
can adapt, as needed.

NetBSD 9.99.89
 1.122  16-Jun-2021  riastradh if_attach and if_initialize cannot fail, don't test return value

These were originally made failable back in 2017 when if_initialize
allocated a softint in every interface for link state changes, so
that it could fail gracefully instead of panicking:

https://mail-index.NetBSD.org/source-changes/2017/10/23/msg089053.html

However, this spawned many seldom- or never-tested error branches,
which are risky to have around. And that softint in every interface
has since been replaced by a single global workqueue, because link
state changes require thread context but not low latency or high
throughput:

https://mail-index.NetBSD.org/source-changes/2020/02/06/msg113759.html

So there is no longer any reason for if_initialize to fail. (The
subroutine if_stats_init can't fail because percpu_alloc can't fail
either.)

There is a snag: the softint_establish in if_percpuq_create could
fail, potentially leading to bad consequences later on trying to use
the softint. This change doesn't introduce any new bugs because of
the snag -- if_percpuq_attach was already broken. However, the snag
can be better addressed without spawning error branches, either by
using a single softint or making softints less scarce.

(Separate commit will change the signatures of if_attach and
if_initialize to return void, scheduled to ride whatever is the next
convenient kernel bump.)

Patch and testing on amd64 and evbmips64-eb by maya@; commit message
soliloquy, and compile-testing on evbppc/i386/earmv7hf, by me.
 1.121  18-Dec-2020  thorpej branches: 1.121.4;
Use sel{record,remove}_knote().
 1.120  30-Oct-2020  christos branches: 1.120.2;
use c99 initializers
 1.119  27-Sep-2020  roy tap: Report link state based on if the interface has been opened or not

While a nice addition, it does render tap(4) useless as a bridge(4)
endpoint. We now have vether(4) for use as bridge endpoint.
 1.118  26-Sep-2020  roy tap: Remove media from this virtual interface

It serves no purpose at all.
 1.117  04-Feb-2020  thorpej Use ifmedia_fini().
 1.116  29-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.115  06-Jan-2020  christos branches: 1.115.2;
Add missing packet filter hooks, byte accounting.
 1.114  16-Oct-2019  knakahara Fix missing kpreempt_disable() before softint_schedule() like if_vmx.c:r1.51.
 1.113  29-May-2019  msaitoh branches: 1.113.2;
Even if we don't use MII(4), use the common path of SIOC[GS]IFMEDIA in
sys/net/if_ethersubr.c if we can.
- Add ec_ifmedia into struct ethercom.
- ec_mii in struct ethercom is kept and used as it is. It might be used in
future. Note that some Ethernet drivers which _DOESN'T_ use mii(4) use
ec_mii for keeping the if_media. Those should be changed in future.
 1.112  21-May-2019  msaitoh KNF. No functional change.
 1.111  26-Apr-2019  pgoyette Some more empty-string --> NULL conversions for module dependencies
 1.110  16-Apr-2019  msaitoh The path of SOICSIFMEDA or TAPGIFNAME calls are as follows:

doifioctl()

pre-convert (if_cvtcmd_43_hook & ifreqo2n)

(*ifp->if_ioctl)(ifp, cmd, data);

post-convert (ifreqn2o)

so it's not required to check OSIOCSIFMEDIA and OTAPGIFNAME in if_tap.c.
Those two command is converted to new command in if_cvtcmd_43_hook and
always new commands are seen in tap_ioctl().

OK'd by pgoyette.
 1.109  25-Mar-2019  pgoyette Put the #ifdef where it belongs (after defining the out2 label which is
referenced only inside #ifdef block)
 1.108  25-Mar-2019  pgoyette Resequence the activities in tapdetach() so that no new units can be
created, either by opening /dev/tap or ifconfig tapx create, before
checking to see if we have any active units.
 1.107  03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.106  26-Jun-2018  msaitoh branches: 1.106.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.105  19-Dec-2017  ozaki-r branches: 1.105.2;
Don't set IFEF_MPSAFE unless NET_MPSAFE at this point

Because recent investigations show that interfaces with IFEF_MPSAFE need to
follow additional restrictions to work with the flag safely. We should enable it
on an interface by default only if the interface surely satisfies the
restrictions, which are described in if.h.

Note that enabling IFEF_MPSAFE solely gains a few benefit on performance because
the network stack is still serialized by the big kernel locks by default.
 1.104  30-Nov-2017  christos add fo_name so we can identify the fileops in a simple way.
 1.103  29-Nov-2017  jmcneill set IFEF_MPSAFE
 1.102  29-Nov-2017  jmcneill Make tap(4) MP-safe.
 1.101  30-Oct-2017  ozaki-r Set IFEF_NO_LINK_STATE_CHANGE flag to pseudo devices that don't use if_link_state_change
 1.100  23-Oct-2017  msaitoh - If if_initialize() failed in the attach function, free resources and return.
- KNF
 1.99  12-Feb-2017  skrll branches: 1.99.4; 1.99.6;
Whitespace
 1.98  12-Feb-2017  skrll Convert to kmem(9)
 1.97  12-Feb-2017  skrll Typo in comment
 1.96  12-Feb-2017  skrll KNF (sort #include <sys/...>) and remove a duplicate
 1.95  07-Feb-2017  skrll KNF and trailing whitespace. No functional change.
 1.94  15-Dec-2016  ozaki-r branches: 1.94.2;
Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.93  02-Oct-2016  christos MFREE -> m_free
 1.92  15-Aug-2016  christos remove MODULAR/COMPAT_40 ifdef.
 1.91  14-Aug-2016  christos fix rump tests.
 1.90  08-Aug-2016  kre create++, destroy--
 1.89  08-Aug-2016  pgoyette Typo (missing ampersand)
 1.88  08-Aug-2016  pgoyette Final part of fixing if_tap. The module needs to attach its cdevsw (and
detach it later).
 1.87  08-Aug-2016  pgoyette Add the devsw_attach stuff, since the tap device can be accessed via
/dev/tap

This is a partial fix for the build. The rump tap component will be
fixed shortly.
 1.86  08-Aug-2016  pgoyette Partial fix - restore creation of our sysctl subtree for _MODULE
builds (it's already handled for built-in builds via registration
in a link-set).

XXX The build is still broken in rump...
 1.85  07-Aug-2016  christos modularize some more drivers and merge the module glue
 1.84  10-Jun-2016  ozaki-r branches: 1.84.2;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.83  09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.82  20-Aug-2015  christos include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.
 1.81  17-Dec-2014  ozaki-r Replace if_attach of if_tap with if_initialize and if_register
 1.80  07-Nov-2014  ozaki-r branches: 1.80.2;
Complete the initialization of tap_softc before if_attach

Basically we should complete the initializaiton of softc before if_attach
because once if_attach is called if_detach can be called for the softc
before returning from if_attach. In case of tap, mutex_destroy can be
called before mutex_init that comes after if_attach.
 1.79  03-Oct-2014  skrll Remove unneeded #include
 1.78  05-Sep-2014  matt Try not to use f_data, use f_{vnode,socket,pipe,mqueue,kqueue,ksem} to get
a correctly typed pointer.
 1.77  25-Jul-2014  dholland Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.76  07-May-2014  cube Prevent a race between tap_dev_poll() and tap_start() by making sure the
call to selrecord() happens at splnet(). Fixes kern/47506 and kern/46199.
 1.75  20-Apr-2014  aymeric Call mutex_destroy() on sc_kqlock in tap_detach(). Found by LOCKDEBUG.
 1.74  20-Mar-2014  skrll branches: 1.74.2;
Mechanically replace simplelock with kmutex_t.
 1.73  16-Mar-2014  dholland Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
 1.72  25-Feb-2014  pooka Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.71  20-Aug-2013  yamt - deal with softint_establish failure
- establish softint only when necessary
 1.70  28-Jan-2013  yamt branches: 1.70.2;
use cprng_fast instead of getmicrouptime to generate "random" mac address
because the latter often produces the same addresses for subsequent tap
instances.
 1.69  28-Jan-2013  yamt whitespace
 1.68  27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.67  02-Jun-2012  dsl branches: 1.67.2;
Add some pre-processor magic to verify that the type of the data item
passed to sysctl_createv() actually matches the declared type for
the item itself.
In the places where the caller specifies a function and a structure
address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
fallout. Most likely passing &char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.
 1.66  22-Nov-2010  christos branches: 1.66.8; 1.66.14; 1.66.18; 1.66.20;
PR/44131: Matthew Mondor: if_tap.c tap_dev_ioctl() not propagating error,
always returns 0.
 1.65  19-May-2010  christos Replace ether_nonstatic_aton with a
- better named one
- not suffering from buffer oveflow
- simpler
- handling different separators
- returning error codes for errors

Some ideas from one posted on tech-net by Jonathan A. Kollasch
 1.64  05-Apr-2010  joerg Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.63  19-Jan-2010  pooka branches: 1.63.2; 1.63.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.62  20-Dec-2009  dsl If a multithreaded app closes an fd while another thread is blocked in
read/write/accept, then the expectation is that the blocked thread will
exit and the close complete.
Since only one fd is affected, but many fd can refer to the same file,
the close code can only request the fs code unblock with ERESTART.
Fixed for pipes and sockets, ERESTART will only be generated after such
a close - so there should be no change for other programs.
Also rename fo_abort() to fo_restart() (this used to be fo_drain()).
Fixes PR/26567
 1.61  09-Dec-2009  dsl Rename fo_drain() to fo_abort(), 'drain' is used to mean 'wait for output
do drain' in many places, whereas fo_drain() was called in order to force
blocking read()/write() etc calls to return to userspace so that a close()
call from a different thread can complete.
In the sockets code comment out the broken code in the inner function,
it was being called from compat code.
 1.60  29-Nov-2009  plunky fix a potential leak on tap device close, purging the send queue
did not actually release the dequeued mbufs.

pointed out by Paul Forgey on tech-net
 1.59  15-Sep-2009  drochner fix undefined result of stat(), found by clang static analyzer
 1.58  23-Jul-2009  plunky Avoid a kernel assertion failure upstream by using FSTATE_NOTFOUND
rather than FSTATE_FOUND when setting the unit number directly.

config_attach_pseudo() will convert it to FSTATE_FOUND just after the
assertion.
 1.57  11-Apr-2009  christos Fix locking as Andy explained. Also fill in uid and gid like sys_pipe did.
 1.56  11-Apr-2009  christos Fix PR/37878 and PR/37550: Provide stat(2) for all devices and don't use
fbadop_stat.
 1.55  04-Apr-2009  ad Add fileops::fo_drain(), to be called from fd_close() when there is more
than one active reference to a file descriptor. It should dislodge threads
sleeping while holding a reference to the descriptor. Implemented only for
sockets but should be extended to pipes, fifos, etc.

Fixes the case of a multithreaded process doing something like the
following, which would have hung until the process got a signal.

thr0 accept(fd, ...)
thr1 close(fd)
 1.54  13-Mar-2009  plunky Deprecate the SIOCSIFPHYADDR ioctl and the sysctl node in favour
of the generic SIOCALIFADDR.

As suggested by cube.
 1.53  10-Mar-2009  plunky repair the SIOCSIFPHYADDR ioctl handler to be compatible with previous
versions which used a "struct sockaddr"
 1.52  01-Feb-2009  pooka branches: 1.52.2;
Drop splnet() *after* tsleep instead of before. Fixes a race condition
between sleep and wakeup. (tested on NetBSD 4.0)
 1.51  12-Nov-2008  ad Remove LKMs and switch to the module framework, pass 1.

Proposed on tech-kern@.
 1.50  07-Nov-2008  dyoung *** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
 1.49  03-Nov-2008  hans call pmf_device_deregister in detach functions. requested by jmcneill.
 1.48  02-Nov-2008  hans Add NULL pmf handlers. OK by cube.
 1.47  26-Aug-2008  rmind branches: 1.47.2; 1.47.4;
tap_attach/tap_detach: selinit/seldestroy the selinfo structure.
Should fix PR/39237.
 1.46  10-Jun-2008  cegger branches: 1.46.2;
device_private(device_lookup()) -> device_lookup_private()
ok cube@
 1.45  28-May-2008  dyoung branches: 1.45.2;
In tap_clone_destroy(), don't treat a pointer to the tap(4) softc
like it is a device_t.

In tap_clone_creator(), set cf_fstate to FSTATE_FOUND instead of
_NOTFOUND to avoid a panic in config_detach() on a DIAGNOSTIC
kernel. XXX I'm not sure that that is the right fix.

These changes should put a stop to the crash described in kern/38759.
 1.44  21-May-2008  ad Acquire kernel_lock in tap's fileops.
 1.43  29-Apr-2008  martin branches: 1.43.2;
Convert to new 2 clause license
 1.42  24-Apr-2008  ad branches: 1.42.2;
Network protocol interrupts can now block on locks, so merge the globals
proclist_mutex and proclist_lock into a single adaptive mutex (proc_lock).
Implications:

- Inspecting process state requires thread context, so signals can no longer
be sent from a hardware interrupt handler. Signal activity must be
deferred to a soft interrupt or kthread.

- As the proc state locking is simplified, it's now safe to take exit()
and wait() out from under kernel_lock.

- The system spends less time at IPL_SCHED, and there is less lock activity.
 1.41  21-Mar-2008  ad branches: 1.41.2;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
 1.40  04-Mar-2008  cube Split device_t/softc, and other related cosmetic changes.
 1.39  01-Mar-2008  rmind Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>
 1.38  20-Feb-2008  matt branches: 1.38.2; 1.38.6;
s/u_\(int[0-9]*_t\)/u\1/g
(change u_int*_t to uint*_t)
 1.37  04-Jan-2008  ad Start detangling lock.h from intr.h. This is likely to cause short term
breakage, but the mess of dependencies has been regularly breaking the
build recently anyhow.
 1.36  20-Dec-2007  dyoung Constify struct ifnet->if_sadl and every use throughout the tree.
Add if_set_sadl() that both sets the link-layer address length and
replaces the current link-layer address with a new one, and use it
throughout the tree.
 1.35  05-Dec-2007  pooka branches: 1.35.4;
Do not "return 1" from kqfilter for errors. That value is passed
directly to the userland caller and results in a mysterious EPERM.
Instead, return EINVAL or something else sensible depending on the
case.
 1.34  05-Dec-2007  ad lockmgr -> mutex
 1.33  10-Sep-2007  cube branches: 1.33.6; 1.33.8;
Remove 3rd clause and my name from all the licences which were only in my
name.
 1.32  30-Aug-2007  dyoung Use malloc(9) for sockaddrs instead of pool(9), and remove dom_sa_pool
and dom_sa_len members from struct domain. Pools of fixed-size
objects are too rigid for sockaddr_dls, whose size can vary over
a wide range.

Return sockaddr_dl to its "historical" size. Now that I'm using
malloc(9) instead of pool(9) to allocate sockaddr_dl, I can create
a sockaddr_dl of any size in the kernel, so expanding sockaddr_dl
is useless.

Avoid using sizeof(struct sockaddr_dl) in the kernel.

Introduce sockaddr_dl_alloc() for allocating & initializing an
arbitrary sockaddr_dl on the heap.

Add an argument, the sockaddr length, to sockaddr_alloc(),
sockaddr_copy(), and sockaddr_dl_setaddr().

Constify: LLADDR() -> CLLADDR().

Where the kernel overwrites LLADDR(), use sockaddr_dl_setaddr(),
instead. Used properly, sockaddr_dl_setaddr() will not overrun
the end of the sockaddr.
 1.31  26-Aug-2007  dyoung branches: 1.31.2;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).

Use sockaddr_dl_setaddr() in a few places.
 1.30  30-May-2007  christos branches: 1.30.2; 1.30.6;
Move the nasty ifdefs in one place. Requested by ad and dyoung.
 1.29  29-May-2007  christos Add a sockaddr_storage member to "struct ifreq" maintaining backwards
compatibility with the older ioctls. This avoids stack smashing and
abuse of "struct sockaddr" when ioctls placed "struct sockaddr_foo's" that
were longer than "struct sockaddr".
XXX: Some of the emulations might be broken; I tried to add code for
them but I did not test them.
 1.28  17-May-2007  christos return POLLERR instead of ENXIO since we are expecting an revents mask not
an errno.
 1.27  09-Mar-2007  drochner branches: 1.27.2; 1.27.4;
don't use DVUNIT_ANY as unit number to attach pseudo devices,
use FSTATE_STAR and cf_unit=0 like normal devices.
Thanks to Arnaud Degroote for the bug report and testing.
 1.26  04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.25  26-Feb-2007  cube Remove unnecessary output and reduce verbosity in dmesg(8) output. That
makes the output consistent with etherip(4).

Suggested by Nino Dehne on current-users@.
 1.24  24-Nov-2006  rpaulo branches: 1.24.2; 1.24.4;
The change I committed to etherip was wrong. ether_snprintf doesn't make
sense when chaning the MAC address of the virtual interface as pointed
out by Hans himself.
So, introduce ether_nonstatic_aton() and make etherip(4) and tap(4) use it.
 1.23  16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.22  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.21  01-Sep-2006  cube branches: 1.21.2; 1.21.4;
Add a note about the use of CTL_CREATE in sysctl_createv, otherwise the
code can be confusing.
 1.20  30-Aug-2006  christos fix initializers.
 1.19  23-Jul-2006  ad Use the LWP cached credentials where sane.
 1.18  07-Jun-2006  kardel merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
time.tv_sec -> time_second
- struct timeval mono_time is gone
mono_time.tv_sec -> time_uptime
- access to time via
{get,}{micro,nano,bin}time()
get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html
 1.17  14-May-2006  elad branches: 1.17.2;
integrate kauth.
 1.16  29-Mar-2006  thorpej Use device_cfdata().
 1.15  28-Mar-2006  thorpej Use device_unit().
 1.14  16-Mar-2006  christos branches: 1.14.2;
Add a new function called ether_snprintf() which takes an external buffer
and a length. The buffer should be 3 * addrlen.
Remove local tap_ether_sprintf(), and use ether_snprintf() instead.
 1.13  24-Feb-2006  pooka branches: 1.13.2; 1.13.4;
comment police: p_dupfd is now known as l_dupfd and lives in struct lwp
 1.12  01-Feb-2006  cube branches: 1.12.2;
Properly dispose of cfdata memory when unloading the tap(4) LKM.
 1.11  11-Dec-2005  christos branches: 1.11.2; 1.11.4;
merge ktrace-lwp.
 1.10  20-Jun-2005  atatat branches: 1.10.2;
Change the rest of the sysctl subsystem to use const consistently.
The __UNCONST macro is now used only where necessary and the RW macros
are gone. Most of the changes here are consumers of the
sysctl_createv(9) interface that now takes a pair of const pointers
which used not to be.
 1.9  10-Jun-2005  bouyer call (ifp->if_input) at splnet(). ifp->if_input points to ether_input()
which doesn't raise the IPL itself in all cases.
Should also fix PR 29546 (the pkgsrc kernel module needs to be updated).
 1.8  17-May-2005  christos Yes, it was a cool trick >20 years ago to use "0123456789abcdef"[a] to
implement, xtoa(), but I think defining the samestring 50 times is a bit
too much. Defined HEXDIGITS and hexdigits in subr_prf.c and use it...
 1.7  24-Mar-2005  cube Set bit 0x2 of the first byte of the generated MAC address, to indicate it
is a locally administered address. Pointed out by Ignatios Souvatzis.
 1.6  26-Feb-2005  perry branches: 1.6.2;
nuke trailing whitespace
 1.5  12-Feb-2005  christos pass the flag to fdclone.
 1.4  25-Jan-2005  ragge branches: 1.4.2;
Do not cast simple_lock() to (void). It may be a do { } while() macro,
and then compilation fails. Found by H�vard Eidnes.
 1.3  22-Jan-2005  cube s/PF_LINK/AF_LINK/ because that way it makes sense.
 1.2  19-Jan-2005  cube Make this LKM-friendly by using _KERNEL_OPT and having a prototype for the
sysctl setup function.
 1.1  08-Jan-2005  cube branches: 1.1.2; 1.1.4;
Addition of tap(4).

NAME
tap - virtual Ethernet device

SYNOPSIS
pseudo-device tap

DESCRIPTION
The tap driver allows the creation and use of virtual Ethernet devices.
Those interfaces appear just as any real Ethernet NIC to the kernel, but
can also be accessed by userland through a character device node in order
to read frames being sent by the system or to inject frames.

In that respect it is very similar to what tun(4) provides, but the added
Ethernet layer allows easy integration with machine emulators or virtual
Ethernet networks through the use of bridge(4) with tunneling.

``Qui tacet consentire videtur.''
 1.1.4.8  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.4.7  01-Apr-2005  skrll Sync with HEAD.
 1.1.4.6  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.4.5  15-Feb-2005  skrll Sync with HEAD.
 1.1.4.4  04-Feb-2005  skrll Sync with HEAD.
 1.1.4.3  24-Jan-2005  skrll Sync with HEAD.
 1.1.4.2  17-Jan-2005  skrll Sync with HEAD.
 1.1.4.1  08-Jan-2005  skrll file if_tap.c was added on branch ktrace-lwp on 2005-01-17 19:32:38 +0000
 1.1.2.1  29-Apr-2005  kent sync with -current
 1.4.2.3  26-Mar-2005  yamt sync with head.
 1.4.2.2  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.4.2.1  25-Jan-2005  yamt file if_tap.c was added on branch yamt-km on 2005-03-19 08:36:31 +0000
 1.6.2.2  21-Jan-2006  snj Pull up following revision(s) (requested by cube in ticket #1113):
sys/net/if_tap.c: revision 1.7
Set bit 0x2 of the first byte of the generated MAC address, to indicate it
is a locally administered address. Pointed out by Ignatios Souvatzis.
 1.6.2.1  10-Jun-2005  tron Pull up revision 1.9 (requested by bouyer in ticket #438):
call (ifp->if_input) at splnet(). ifp->if_input points to ether_input()
which doesn't raise the IPL itself in all cases.
Should also fix PR 29546 (the pkgsrc kernel module needs to be updated).
 1.10.2.9  24-Mar-2008  yamt sync with head.
 1.10.2.8  17-Mar-2008  yamt sync with head.
 1.10.2.7  27-Feb-2008  yamt sync with head.
 1.10.2.6  21-Jan-2008  yamt sync with head
 1.10.2.5  07-Dec-2007  yamt sync with head
 1.10.2.4  27-Oct-2007  yamt sync with head.
 1.10.2.3  03-Sep-2007  yamt sync with head.
 1.10.2.2  30-Dec-2006  yamt sync with head.
 1.10.2.1  21-Jun-2006  yamt sync with head.
 1.11.4.1  09-Sep-2006  rpaulo sync with head
 1.11.2.2  01-Mar-2006  yamt sync with head.
 1.11.2.1  01-Feb-2006  yamt sync with head.
 1.12.2.4  01-Jun-2006  kardel Sync with head.
 1.12.2.3  22-Apr-2006  simonb Fix sync-with-trunc botch.
 1.12.2.2  22-Apr-2006  simonb Sync with head.
 1.12.2.1  04-Feb-2006  simonb Adapt for timecounters: mostly use get*time(), use bintime's for timeout
calculations and use "time_second" instead of "time.tv_sec".
 1.13.4.3  06-May-2006  christos - Move kauth_cred_t declaration to <sys/types.h>
- Cleanup struct ucred; forward declarations that are unused.
- Don't include <sys/kauth.h> in any header, but include it in the c files
that need it.

Approved by core.
 1.13.4.2  19-Apr-2006  elad sync with head.
 1.13.4.1  08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.13.2.5  03-Sep-2006  yamt sync with head.
 1.13.2.4  11-Aug-2006  yamt sync with head
 1.13.2.3  26-Jun-2006  yamt sync with head.
 1.13.2.2  24-May-2006  yamt sync with head.
 1.13.2.1  01-Apr-2006  yamt sync with head.
 1.14.2.2  24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.14.2.1  31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.17.2.1  19-Jun-2006  chap Sync with head.
 1.21.4.2  10-Dec-2006  yamt sync with head.
 1.21.4.1  22-Oct-2006  yamt sync with head
 1.21.2.2  12-Jan-2007  ad Sync with head.
 1.21.2.1  18-Nov-2006  ad Sync with head.
 1.24.4.2  12-Mar-2007  rmind Sync with HEAD.
 1.24.4.1  27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.24.2.1  03-Dec-2009  sborrill Pull up the following revisions(s) (requested by plunky in ticket #1368):
sys/net/if_tap.c: revision 1.60

Fix a potential leak on tap device close; purging the send queue did not
actually release the dequeued mbufs.
 1.27.4.1  11-Jul-2007  mjf Sync with head.
 1.27.2.3  09-Oct-2007  ad Sync with head.
 1.27.2.2  09-Jun-2007  ad Sync with head.
 1.27.2.1  08-Jun-2007  ad Sync with head.
 1.30.6.3  09-Dec-2007  jmcneill Sync with HEAD.
 1.30.6.2  02-Oct-2007  joerg Sync with HEAD.
 1.30.6.1  03-Sep-2007  jmcneill Sync with HEAD.
 1.30.2.1  03-Sep-2007  skrll Sync with HEAD.
 1.31.2.3  23-Mar-2008  matt sync with HEAD
 1.31.2.2  09-Jan-2008  matt sync with HEAD
 1.31.2.1  06-Nov-2007  matt sync with HEAD
 1.33.8.2  26-Dec-2007  ad Sync with head.
 1.33.8.1  08-Dec-2007  ad Sync with head.
 1.33.6.3  18-Feb-2008  mjf Sync with HEAD.
 1.33.6.2  27-Dec-2007  mjf Sync with HEAD.
 1.33.6.1  08-Dec-2007  mjf Sync with HEAD.
 1.35.4.2  08-Jan-2008  bouyer Sync with HEAD
 1.35.4.1  02-Jan-2008  bouyer Sync with HEAD
 1.38.6.7  17-Jan-2009  mjf Sync with HEAD.
 1.38.6.6  28-Sep-2008  mjf Sync with HEAD.
 1.38.6.5  29-Jun-2008  mjf Sync with HEAD.
 1.38.6.4  02-Jun-2008  mjf Sync with HEAD.
 1.38.6.3  06-Apr-2008  mjf - after some discussion with agc@ i agreed it would be a good idea to move
device_unregister_* to device_deregister_* to be more like the pmf(9)
functions, especially since a lot of the time the function calls are next
to each other.

- add device_register_name() support for dk(4).
 1.38.6.2  05-Apr-2008  mjf - add "file-system DEVFS" and "pseudo-device devfsctl" to conf/std seeing
as these are always needed.

- convert many, many drivers over to the New Devfs World Order. For a
list of device drivers yet to be converted see,
http://www.netbsd.org/~mjf/devfs-todo.html.

- add a new device_unregister_all(device_t) function to remove all device
names associated with a device_t, which saves us having to construct
device names when the driver is detached.

- add a DEV_AUDIO type for devices.
 1.38.6.1  03-Apr-2008  mjf Sync with HEAD.
 1.38.2.1  24-Mar-2008  keiichi sync with head.
 1.41.2.3  17-Jun-2008  yamt sync with head.
 1.41.2.2  04-Jun-2008  yamt sync with head
 1.41.2.1  18-May-2008  yamt sync with head.
 1.42.2.6  11-Aug-2010  yamt sync with head.
 1.42.2.5  11-Mar-2010  yamt sync with head
 1.42.2.4  16-Sep-2009  yamt sync with head
 1.42.2.3  19-Aug-2009  yamt sync with head.
 1.42.2.2  04-May-2009  yamt sync with head.
 1.42.2.1  16-May-2008  yamt sync with head.
 1.43.2.2  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.43.2.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.45.2.1  18-Jun-2008  simonb Sync with head.
 1.46.2.2  13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.46.2.1  19-Oct-2008  haad Sync with HEAD.
 1.47.4.8  09-Dec-2010  riz Pull up following revision(s) (requested by christos in ticket #1492):
sys/net/if_tap.c: revision 1.66
PR/44131: Matthew Mondor: if_tap.c tap_dev_ioctl() not propagating error,
always returns 0.
 1.47.4.7  03-Dec-2009  sborrill Pull up the following revisions(s) (requested by plunky in ticket #1173):
sys/net/if_tap.c: revision 1.60

Fix a potential leak on tap device close; purging the send queue
did not actually release the dequeued mbufs.
 1.47.4.6  04-Apr-2009  snj branches: 1.47.4.6.4;
Pull up following revision(s) (requested by ad in ticket #661):
sys/arch/xen/xen/xenevt.c: revision 1.32
sys/compat/svr4/svr4_net.c: revision 1.56
sys/compat/svr4_32/svr4_32_net.c: revision 1.19
sys/dev/dmover/dmover_io.c: revision 1.32
sys/dev/putter/putter.c: revision 1.21
sys/kern/kern_descrip.c: revision 1.190
sys/kern/kern_drvctl.c: revision 1.23
sys/kern/kern_event.c: revision 1.64
sys/kern/sys_mqueue.c: revision 1.14
sys/kern/sys_pipe.c: revision 1.109
sys/kern/sys_socket.c: revision 1.59
sys/kern/uipc_syscalls.c: revision 1.136
sys/kern/vfs_vnops.c: revision 1.164
sys/kern/uipc_socket.c: revision 1.188
sys/net/bpf.c: revision 1.144
sys/net/if_tap.c: revision 1.55
sys/opencrypto/cryptodev.c: revision 1.47
sys/sys/file.h: revision 1.67
sys/sys/param.h: patch
sys/sys/socketvar.h: revision 1.119
Add fileops::fo_drain(), to be called from fd_close() when there is more
than one active reference to a file descriptor. It should dislodge threads
sleeping while holding a reference to the descriptor. Implemented only for
sockets but should be extended to pipes, fifos, etc.
Fixes the case of a multithreaded process doing something like the
following, which would have hung until the process got a signal.
thr0 accept(fd, ...)
thr1 close(fd)
 1.47.4.5  18-Mar-2009  snj Pull up following revision(s) (requested by plunky in ticket #575):
sys/net/if_tap.c: revision 1.54
Deprecate the SIOCSIFPHYADDR ioctl and the sysctl node in favour
of the generic SIOCALIFADDR.
As suggested by cube.
 1.47.4.4  18-Mar-2009  snj Pull up following revision(s) (requested by plunky in ticket #572):
sys/net/if_tap.c: revision 1.53
repair the SIOCSIFPHYADDR ioctl handler to be compatible with previous
versions which used a "struct sockaddr"
 1.47.4.3  06-Feb-2009  snj Pull up following revision(s) (requested by pooka in ticket #405):
sys/net/if_tap.c: revision 1.52
Drop splnet() *after* tsleep instead of before. Fixes a race condition
between sleep and wakeup. (tested on NetBSD 4.0)
 1.47.4.2  19-Nov-2008  snj Pull up following revision(s) (requested by hans in ticket #89):
sys/net/if_tap.c: revision 1.49
sys/net/if_etherip.c: revision 1.24
call pmf_device_deregister in detach functions. requested by jmcneill.
 1.47.4.1  19-Nov-2008  snj Pull up following revision(s) (requested by hans in ticket #89):
sys/net/if_tap.c: revision 1.48
sys/net/if_etherip.c: revision 1.23
Add NULL pmf handlers. OK by cube.
 1.47.4.6.4.1  21-Apr-2010  matt sync to netbsd-5
 1.47.2.3  28-Apr-2009  skrll Sync with HEAD.
 1.47.2.2  03-Mar-2009  skrll Sync with HEAD.
 1.47.2.1  19-Jan-2009  skrll Sync with HEAD.
 1.52.2.2  23-Jul-2009  jym Sync with HEAD.
 1.52.2.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.63.4.2  05-Mar-2011  rmind sync with head
 1.63.4.1  30-May-2010  rmind sync with head
 1.63.2.2  17-Aug-2010  uebayasi Sync with HEAD.
 1.63.2.1  30-Apr-2010  uebayasi Sync with HEAD.
 1.66.20.1  03-Jun-2014  msaitoh Pull up following revision(s) (requested by cube in ticket #1071):
sys/net/if_tap.c 1.76

Prevent a race between tap_dev_poll() and tap_start() by making sure the
call to selrecord() happens at splnet(). Fixes kern/47506 and kern/46199.
 1.66.18.1  03-Jun-2014  msaitoh Pull up following revision(s) (requested by cube in ticket #1071):
sys/net/if_tap.c 1.76

Prevent a race between tap_dev_poll() and tap_start() by making sure the
call to selrecord() happens at splnet(). Fixes kern/47506 and kern/46199.
 1.66.14.1  03-Jun-2014  msaitoh Pull up following revision(s) (requested by cube in ticket #1071):
sys/net/if_tap.c 1.76

Prevent a race between tap_dev_poll() and tap_start() by making sure the
call to selrecord() happens at splnet(). Fixes kern/47506 and kern/46199.
 1.66.8.2  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.66.8.1  30-Oct-2012  yamt sync with head
 1.67.2.4  03-Dec-2017  jdolecek update from HEAD
 1.67.2.3  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.67.2.2  25-Feb-2013  tls resync with head
 1.67.2.1  20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.70.2.2  18-May-2014  rmind sync with head
 1.70.2.1  28-Aug-2013  rmind sync with head
 1.74.2.1  10-Aug-2014  tls Rebase.
 1.80.2.7  28-Aug-2017  skrll Sync with HEAD
 1.80.2.6  05-Feb-2017  skrll Sync with HEAD
 1.80.2.5  05-Oct-2016  skrll Sync with HEAD
 1.80.2.4  09-Jul-2016  skrll Sync with HEAD
 1.80.2.3  19-Mar-2016  skrll Sync with HEAD
 1.80.2.2  22-Sep-2015  skrll Sync with HEAD
 1.80.2.1  06-Apr-2015  skrll Sync with HEAD
 1.84.2.6  20-Mar-2017  pgoyette Sync with HEAD
 1.84.2.5  07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.84.2.4  04-Nov-2016  pgoyette Sync with HEAD
 1.84.2.3  26-Jul-2016  pgoyette Rename LOCALCOUNT_INITIALIZER to DEVSW_MODULE_INIT. This better describes
what we're doing, and why.
 1.84.2.2  19-Jul-2016  pgoyette Instead of repeatedly typing the conditional initialization of the
.d_localcount members in the various {b,c}devsw, define an initializer
macro and use it. This also removes the need for defining new symbols
for each 'struct localcount'.

As suggested by riastradh@
 1.84.2.1  18-Jul-2016  pgoyette Rump drivers are always installed via devsw_attach() so we need to
always allocate a 'struct localcount' for these drivers whenever they
are built as modules.
 1.94.2.1  21-Apr-2017  bouyer Sync with HEAD
 1.99.6.2  10-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #427):
sys/arch/amiga/dev/if_bah_zbus.c: 1.17
sys/arch/arm/broadcom/bcm53xx_eth.c: 1.30
sys/arch/powerpc/booke/dev/pq3etsec.c: 1.32
sys/arch/usermode/dev/if_veth.c: 1.9
sys/dev/ic/an.c: 1.66
sys/dev/ic/athn.c: 1.17
sys/dev/ic/atw.c: 1.162
sys/dev/ic/bwi.c: 1.33
sys/dev/ic/dwc_gmac.c: 1.41-1.42
sys/dev/ic/malo.c: 1.10
sys/dev/ic/rt2560.c: 1.31
sys/dev/ic/rt2661.c: 1.36
sys/dev/ic/rt2860.c: 1.29
sys/dev/ic/rtw.c: 1.127
sys/dev/ic/rtwvar.h: 1.46
sys/dev/ic/smc90cx6.c: 1.71
sys/dev/ic/smc90cx6var.h: 1.12
sys/dev/ic/wi.c: 1.244
sys/dev/pci/if_ipw.c: 1.66
sys/dev/pci/if_iwi.c: 1.104
sys/dev/pci/if_iwm.c: 1.76
sys/dev/pci/if_iwn.c: 1.86
sys/dev/pci/if_rtwn.c: 1.13
sys/dev/pci/if_wm.c: 1.541
sys/dev/pci/if_wpi.c: 1.79
sys/dev/pci/ixgbe/ixgbe.c: 1.106
sys/dev/pci/ixgbe/ixv.c: 1.73 via patch
sys/dev/pcmcia/if_malo_pcmcia.c: 1.15
sys/dev/scsipi/if_se.c: 1.95
sys/dev/usb/if_upl.c: 1.60
sys/net/if.c: 1.396
sys/net/if.h: 1.241
sys/net/if_arc.h: 1.23
sys/net/if_arcsubr.c: 1.78
sys/net/if_bridge.c: 1.136-1.137
sys/net/if_etherip.c: 1.39
sys/net/if_faith.c: 1.56
sys/net/if_gif.c: 1.131
sys/net/if_loop.c: 1.96
sys/net/if_mpls.c: 1.30
sys/net/if_pppoe.c: 1.129
sys/net/if_srt.c: 1.27
sys/net/if_stf.c: 1.102
sys/net/if_tap.c: 1.100
sys/net/if_vlan.c: 1.105
sys/netinet/ip_carp.c: 1.91
sys/rump/net/lib/libshmif/if_shmem.c: 1.73-1.74
sys/rump/net/lib/libvirtif/if_virt.c: 1.55-1.56
if_initalize() and if_attach() failed when resource allocation failed
(e.g. allocating softint). Without this change, it panics. It's bad because
resource shortage really occured when a lot of pseudo interface is created.
To avoid this problem, don't panic and change return value of if_initialize()
and if_attach() to int. Caller fanction will be recover from error cleanly by
checking the return value.
Return if bah_attach_subr() failed.
If if_attach() failed in the attach function, return.
- If if_initialize() failed in the attach function, free resources and return.
- Add some missing frees in bridge_clone_destroy().
- KNF
If error occured in bcmeth_ccb_attach(), free resources and return.
If error occured in pq3etsec_attach(), free resources and return.
If error occured in the attach function, free resources and return.
- If if_initialize() failed in athn_attach(), free resources and return.
- Add missing pmf_event_deregister() in athn_detach().
- Free resources correctly on some errors in atw_attach().
- Use apint*() insread of printf() in the attach function.
If if_initialize() failed in the attach function, return.
- If if_initialize() failed in the attach function, free resources and return.
- Add missing dwc_gmac_free_dma_rings() and mutex_destroy() when attach
failed.
- If if_initialize() failed in the attach function, free resources and return.
- ifp is always not NULL in iwi_detach(). Check correctly with ifp->if_softc.
- If if_initialize() failed in the attach function, free resources and return.
- Fix error path in the attach function correctly.
If if_initialize() failed in the attach function, free resources and return.
If if_attach() failed in the attach function, free resources and return.
- If if_initialize() failed in the attach function, free resources and return.
- KNF
- If if_attach() failed in the attach function, free resources and return.
- KNF
Fix compile error.
Fix compile error.
We don't need '&mii', but just 'mii' for mii_detach().
Don't free sc_rthash twice
 1.99.6.1  08-Nov-2017  snj Pull up following revision(s) (requested by ozaki-r in ticket #349):
sys/net/if_l2tp.c: revision 1.14
sys/net/if_tap.c: revision 1.101
sys/net/if_tun.c: revision 1.141
sys/net/if_vlan.c: revision 1.106
Set IFEF_NO_LINK_STATE_CHANGE flag to pseudo devices that don't use
if_link_state_change
 1.99.4.3  17-May-2017  pgoyette Actually return the retrun value that we computed.
 1.99.4.2  17-May-2017  pgoyette At suggestion of chuq@, modify config_attach_pseudo() to return with a
reference held on the device.

Adapt callers to expect the reference to exist, and to ensure that the
reference is released.
 1.99.4.1  27-Apr-2017  pgoyette Restore all work from the former pgoyette-localcount branch (which is
now abandoned doe to cvs merge botch).

The branch now builds, and installs via anita. There are still some
problems (cgd is non-functional and all atf tests time-out) but they
will get resolved soon.
 1.105.2.2  06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.105.2.1  28-Jul-2018  pgoyette Sync with HEAD
 1.106.2.3  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.106.2.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.106.2.1  10-Jun-2019  christos Sync with HEAD
 1.113.2.1  01-Nov-2019  martin Pull up following revision(s) (requested by knakahara in ticket #387):

sys/net/if_gre.c: revision 1.176
sys/net/if_l2tp.c: revision 1.40
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.56
sys/net/if_tap.c: revision 1.114

Fix missing kpreempt_disable() before softint_schedule() like if_vmx.c:r1.51.
 1.115.2.1  29-Feb-2020  ad Sync with head.
 1.120.2.1  03-Jan-2021  thorpej Sync w/ HEAD.
 1.121.4.1  17-Jun-2021  thorpej Sync w/ HEAD.
 1.127.4.3  12-Sep-2024  martin Pull up following revision(s) (requested by rin in ticket #852):

sys/net/if_tap.c: revision 1.134

if_tap: Explicitly include "opt_net_mpsafe.h", NFC
because it was included via <net/if.h> anyway.
 1.127.4.2  11-Sep-2024  martin Pull up following revision(s) (requested by rin in ticket #825):

sys/net/if_tap.c: revision 1.129
sys/net/if_tap.c: revision 1.130
sys/net/if_tap.c: revision 1.131
sys/net/if_tap.c: revision 1.132

tap(4): Prune dead branches around tap_dev_close.
No functional change intended.
PR kern/58166

tap(4): Prune dead branches around tap_dev_destroyer.
No functional change intended.
PR kern/58166

tap(4): Use DETACH_FORCE with config_detach.
It doesn't make a difference here, because tap_detach never fails,
but let's make it more obvious at the call site that failure is
forbidden here.

No functional change intended.
PR kern/58166

tap(4): Just use mutex_enter.
PR kern/58167
 1.127.4.1  06-Jan-2023  martin Pull up following revision(s) (requested by ozaki-r in ticket #38):

sys/net/if_tap.c: revision 1.128

tap: link up an interface cloned from /dev/tap

Fix PR 57155 (partially)

RSS XML Feed