summaryrefslogtreecommitdiff
path: root/sys/net/if_tun.c
AgeCommit message (Collapse)Author
2016-04-13We're always ready! So send IFQ_SET_READY() to the bitbucket.Martin Pieuchot
2016-03-01Set IFF_MULTICAST flag on tun(4) interfaces so IPv6 addresses can be assigned.Stefan Sperling
ok millert@ mpi@
2016-01-31Convert to ulmin and uiomove to prevent integer truncations.Stefan Kempf
Reviewed by Martin Natano.
2016-01-07Make open(O_NONBLOCK) of tun, tap, and bpf behave like open+ioctl(FIONBIO)Philip Guenther
problem noted by yasuoka@ ok yasuoka@ millert@
2015-12-05Make pppx pass packets with npppd through the device. This makes pppx workYASUOKA Masahiko
without pipex.enable=1. Also fix tun(4) not to pass the packets to pipex when pipex.enable=0. "go for it" dlg
2015-11-20Prefer if_get() over if_ref() when checking if the interface has beenMartin Pieuchot
destroyed during our sleep. No objection from the slackers.
2015-11-20dont needlessly clear IFF_OACTIVE.David Gwynne
only a driver sets or clears OACTIVE. clearing it without setting it is a waste of time.
2015-11-20if we deq m0, we should probably send it to bpf, not m.David Gwynne
found by and ok jsg@
2015-11-20shuffle struct ifqueue so in flight mbufs are protected by a mutex.David Gwynne
the code is refactored so the IFQ macros call newly implemented ifq functions. the ifq code is split so each discipline (priq and hfsc in our case) is an opaque set of operations that the common ifq code can call. the common code does the locking, accounting (ifq_len manipulation), and freeing of the mbuf if the disciplines enqueue function rejects it. theyre kind of like bufqs in the block layer with their fifo and nscan disciplines. the new api also supports atomic switching of disciplines at runtime. the hfsc setup in pf_ioctl.c has been tweaked to build a complete hfsc_if structure which it attaches to the send queue in a single operation, rather than attaching to the interface up front and building up a list of queues. the send queue is now mutexed, which raises the expectation that packets can be enqueued or purged on one cpu while another cpu is dequeueing them in a driver for transmission. a lot of drivers use IFQ_POLL to peek at an mbuf and attempt to fit it on the ring before committing to it with a later IFQ_DEQUEUE operation. if the mbuf gets freed in between the POLL and DEQUEUE operations, fireworks will ensue. to avoid this, the ifq api introduces ifq_deq_begin, ifq_deq_rollback, and ifq_deq_commit. ifq_deq_begin allows a driver to take the ifq mutex and get a reference to the mbuf they wish to try and tx. if there's space, they can ifq_deq_commit it to remove the mbuf and release the mutex. if there's no space, ifq_deq_rollback simply releases the mutex. this api was developed to make updating the drivers using IFQ_POLL easy, instead of having to do significant semantic changes to avoid POLL that we cannot test on all the hardware. the common code has been tested pretty hard, and all the driver modifications are straightforward except for de(4). if that breaks it can be dealt with later. ok mpi@ jmatthew@
2015-10-25arp_ifinit() is no longer required.Martin Pieuchot
2015-10-25Introduce if_rtrequest() the successor of ifa_rtrequest().Martin Pieuchot
L2 resolution depends on the protocol (encoded in the route entry) and an ``ifp''. Not having to care about an ``ifa'' makes our life easier in our MP effort. Fewer dependencies between data structures implies fewer headaches. Discussed with bluhm@, ok claudio@
2015-10-24lookup tap devices in tapkqfilter, not tun devices.David Gwynne
libevent likes this more.
2015-10-23Split up tun(4) into tun(4) & tap(4). Killing the link0 magic to switchClaudio Jeker
between modes. The two drivers still share most of the code but the mode switcher is gone. OK dlg@ mpi@
2015-09-10dont leak an ifp reference if tun isnt ready to read.David Gwynne
found by jsg@
2015-09-09if_put after if_get.David Gwynne
this is a bit funky cos we give up the ref while sleeping in tunread, and have to get a new ref on wakeup. ok claudio@
2015-09-01Replace sockaddr casts with the proper satosin(), ... calls.Alexander Bluhm
From David Hill; OK mpi@; tested kspillner@; tweaks bluhm@
2015-08-28Fix compiling a kernel without NBPFILTER > 0.Reyk Floeter
OK mikeb@
2015-07-20Remove splassert(IPL_NET) from if_input().Martin Pieuchot
if_input() has been designed to be able to safely handle a batch of packets from physical drivers to the network stack. Most of these drivers have an interrupt routine executed at IPL_NET and the check made sense during the conversion. However we also want to re-enqueue packets with if_input() from the network stack currently running at IPL_SOFTNET. ok claudio@
2015-07-15m_freem() can handle NULL, do not check for this condition beforehands.Theo de Raadt
ok stsp mpi
2015-07-08MFREE(9) is dead, long live m_freem(9)!Martin Pieuchot
ok bluhm@, claudio@, dlg@
2015-06-30Rename if_output() into if_enqueue() to avoid confusion with commentsMartin Pieuchot
talking about (*ifp->if_output)(). ok claudio@, dlg@
2015-06-24Increment if_ipackets in if_input().Martin Pieuchot
Note that pseudo-drivers not using if_input() are not affected by this conversion. ok mikeb@, kettenis@, claudio@, dlg@
2015-06-16Store a unique ID, an interface index, rather than a pointer to theMartin Pieuchot
receiving interface in the packet header of every mbuf. The interface pointer should now be retrieved when necessary with if_get(). If a NULL pointer is returned by if_get(), the interface has probably been destroy/removed and the mbuf should be freed. Such mechanism will simplify garbage collection of mbufs and limit problems with dangling ifp pointers. Tested by jmatthew@ and krw@, discussed with many. ok mikeb@, bluhm@, dlg@
2015-06-01Convert tun(4) to if_input().Martin Pieuchot
Tested by Norman Golisz and <mxb AT alumni DOT chalmers DOT se>, thanks! ok bluhm@
2015-05-26move add_net_randomness from ether_input to the if_input task.David Gwynne
change it from feeding the ethertype of the packet (which is almost certainly an ip packet or vlan packet, so not that variable) to the number of packets about to be processed. ok deraadt@ mpi@
2015-05-20Do not increment if_opackets in if_output(). It might make sense to doMartin Pieuchot
that later but all drivers should be adapated. Should fix a double output packet accounting, reported by Hrvoje Popovski.
2015-05-19splx should also be called in the error case, fix a regressionMartin Pieuchot
introduced during the if_output() conversion. Found by jsg@
2015-05-15Remove useless comments mentioning ether_output().Martin Pieuchot
2015-05-15Introduce if_output(), a function do to the last steps before enqueuingMartin Pieuchot
a packet on the sending queue of an interface. Tested by many, thanks a lot! ok dlg@, claudio@
2015-04-30Do not free & reallocate a new chunk of memory for the interfaceMartin Pieuchot
descriptor during SIOCSIFFLAGS. This prevent a use after free, triggered by the pool/malloc damage finder being currently cooked by dlg@ and deraadt@. ok deraadt@
2015-04-29Use if_get() after every tsleep(), in case the bottom half of the driverTheo de Raadt
has destroyed or damaged the interface clone. with mpi
2015-04-15Fix a typo introduced in the niq_enqueue() conversion.Martin Pieuchot
Should fix a panic reported by many on bugs@ and misc@. ok dlg@
2015-04-10replace the use of ifqueues for most input queues serviced by netisrDavid Gwynne
with niqueues. this change is so big because there's a lot of code that takes pointers to different input queues (eg, ether_input picks between ipv4, ipv6, pppoe, arp, and mpls input queues) and falls through to code to enqueue packets against the pointer. if i changed only one of the input queues id have to add sepearate code paths, one for ifqueues and one for niqueues in each of these places by flipping all these input queues at once i can keep the currently common code common. testing by mpi@ sthen@ and rafael zalamena ok mpi@ sthen@ claudio@ henning@
2015-04-01Kill useless comments talking about ether_input().Martin Pieuchot
2015-03-18remove the congestion handling from struct ifqueue.David Gwynne
its only used for the ip and ip6 network stack input queues, so it seems unfair that every instance of ifqueue has to carry a pointer around for this specific use case. this moves the congestion marker to a kernel global. if we detect that we're congested, we assume the whole system is busy and punish all input queues. marking a system as congested is done by setting the global to the current value of ticks. as the system moves away from that value, it moves away from being congested until the comparison fails. written at s2k15 ok henning@ beck@ bluhm@ claudio@
2015-03-14Remove some includes include-what-you-use claims don'tJonathan Gray
have any direct symbols used. Tested for indirect use by compiling amd64/i386/sparc64 kernels. ok tedu@ deraadt@
2015-02-10First step towards making uiomove() take a size_t size argument:Miod Vallat
- rename uiomove() to uiomovei() and update all its users. - introduce uiomove(), which is similar to uiomovei() but with a size_t. - rewrite uiomovei() as an uiomove() wrapper. ok kettenis@
2015-01-21Delete option COMPAT_43: support for pre-sa_len binaries has been obsoletePhilip Guenther
for a couple decades. Keep the OSIOCGIFCONF ioctl to support COMPAT_LINUX but move the rest of the Linux-specific ioctl() handling into linux_socket.c This lets struct osockaddr finally move from sys/socket.h to protocols/talkd.h ok krw@ deraadt@ mpi@
2014-12-19unifdef INET in net code as a precursor to removing the pretend option.Ted Unangst
long live the one true internet. ok henning mikeb
2014-10-21tun(4) has a pipex session which is used for multicast internally, itYASUOKA Masahiko
wasn't freeed when the interface is destroyed. Free it properly. ok dlg
2014-09-08remove uneeded route.h includesJonathan Gray
ok miod@ mpi@
2014-07-22Fewer <netinet/in_systm.h> !Martin Pieuchot
2014-07-12add a size argument to free. will be used soon, but for now default to 0.Ted Unangst
after discussions with beck deraadt kettenis.
2014-05-05Use a custom ifa_rtrequest function for point-to-point interfacesMartin Pieuchot
instead of relying on hacks in nd6_rtrequest() to add a route to loopback for each address configured on such interfaces. While here document that abusing lo0 for local traffic is not safe for interfaces in a non-default rdomain. Tested by claudio@, jca@ and sthen@, ok sthen@
2014-04-22Remove some altq tentacles.Martin Pieuchot
ok pelikan@, henning@
2014-04-18reaching into altq outside #ifdef ALTQ is bad, mmkay? ok claudioHenning Brauer
2014-04-14"struct pkthdr" holds a routing table ID, not a routing domain one.Martin Pieuchot
Avoid the confusion by using an appropriate name for the variable. Note that since routing domain IDs are a subset of the set of routing table IDs, the following idiom is correct: rtableid = rdomain But to get the routing domain ID corresponding to a given routing table ID, you must call rtable_l2(9). claudio@ likes it, ok mikeb@
2014-03-30Eliminates struct pcred by moving the real and saved ugids intoPhilip Guenther
struct ucred; struct process then directly links to the ucred Based on a discussion at c2k10 or so before noting that FreeBSD and NetBSD did this too. ok matthew@
2013-10-24Remove the number of in6_var.h inclusions by moving some functions andMartin Pieuchot
global variables to in6.h. ok deraadt@
2013-10-23Remove the number of in_var.h inclusions by moving some functions andMartin Pieuchot
global variables to in.h. ok mikeb@, deraadt@