summaryrefslogtreecommitdiffstats
path: root/sys/net/if_loop.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* deprecate interface input handler lists, just use one input function.dlg2020-07-221-8/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | the interface input handler lists were originally set up to help us during the intial mpsafe network stack work. at the time not all the virtual ethernet interfaces (vlan, svlan, bridge, trunk, etc) were mpsafe, so we wanted a way to avoid them by default, and only take the kernel lock hit when they were specifically enabled on the interface. since then, they have been fixed up to be mpsafe. i could leave the list in place, but it has some semantic problems. because virtual interfaces filter packets based on the order they were attached to the parent interface, you can get packets taken away in surprising ways, especially when you reboot and netstart does something different to what you did by hand. by hardcoding the order that things like vlan and bridge get to look at packets, we can document the behaviour and get consistency. it also means we can get rid of a use of SRPs which were difficult to replace with SMRs. the interface input handler list is an SRPL, which we would like to deprecate. it turns out that you can sleep during stack processing, which you're not supposed to do with SRPs or SMRs, but SRPs are a lot more forgiving and it worked. lastly, it turns out that this code is faster than the input list handling, so lots of winning all around. special thanks to hrvoje popovski and aaron bieber for testing. this has been in snaps as part of a larger diff for over a week.
* In loop_clone_destroy() reset the rdomain with rtable_l2set() afterclaudio2020-01-081-2/+6
| | | | | | the if_detach() call. In if_detach() various route messages are generated and during that time the rtable_l2() mapping needs to stay. OK kn@
* When we needed the kernel lock for local IP packet delivery, mpi@bluhm2019-08-061-5/+5
| | | | | | | | | | | introduced a queue to grab the lock for multiple packets. Now we have only netlock for both IP and protocol input. So the queue is not necessary anymore. It just switches CPU and decreases performance. So remove the inet and inet6 ip queue for local packets. To get TCP running on loopback, we have to queue once between TCP input and output of the two sockets. So use the loopback queue in looutput() unconditionally. OK visa@
* allow the automatically created loopback interfaces in rdomains to behenning2018-09-091-3/+22
| | | | | | | | deleted if the rdomain doesn't contain any other interface. turn the rdomain back into an ordinary, empty rtable in that case. with this and the previous commits one can get rid of rdomains again without rebooting, which wasn't possible any more for some time ok bluhm, input mpi
* Revert all the bits of the autocreate 127.0.0.1 on lo(4) creation for now.claudio2018-03-021-14/+1
| | | | This needs to go back to the drawing board.
* Similar to the IPv6 case create 127.0.0.1/8 on lo(4) interfaces which actclaudio2018-02-101-1/+14
| | | | | | | as loopback interfaces for each rdomain (including lo0). This is done when the interface is brought up. This is now also done by default (either on attach of lo0 or when creating the rdomain). OK mpi@
* Creating a cloned interface could return ENOMEM due to temporarybluhm2018-01-091-6/+2
| | | | | | memory shortage. As it is invoked from a system call, it should not fail and wait instead. OK visa@ mpi@
* add ifiqueues for mp safety and nics with multiple rx rings.dlg2017-12-151-7/+2
| | | | | | | | | | | | | | | | | | | | | | | | currently there is a single mbuf_queue per interface, which all rings on a nic shove packets onto. while the list inside this queue is protected by a mutex, the counters around it (ie, ipackets, ibytes, idrops) are not. this means updates can be lost, and reading the statistics is also inconsistent. having a single queue means that busy rx rings can dominate and then starve the others. ifiqueue structs are like ifqueue structs. they provide per ring queues, and independent counters for each ring. when ifdata is read for userland, these counters are aggregated. having a queue per ring now allows for per ring backpressure to be applied. MCLGETI will have it's day again. right now we assume every interface wants an input queue and unconditionally provide one. individual interfaces can opt into more. im not completely happy about the shape of this atm, but shuffling it around more makes the diff bigger. ok visa@
* - add one more softnet taskqsashan2017-10-311-2/+2
| | | | | | | NOTE: code still runs with single softnet task. change definition of SOFTNET_TASKS in net/if.c, if you want to have more than one softnet task OK mpi@, OK phessler@
* There was a possible stack overrun in the network since we hadbluhm2017-10-191-3/+30
| | | | | | | | | | | | | | | removed some queueing. lo(4) output called the ip input routines without a queue. So if a packet looped through the kernel, the kernel stack filled up. Use M_LOOP to find recursive calls to looutput(). This flag is set when a packet goes through the loopback interface. Avoid an additional queueing if the packet goes to lo(4) only once. As there may be gif(4), bridge(4), pair(4), ipsec(4), rdomain(4), ... setups that legitimately pass lo(4) more than once, use the interface input queue for these cases. Packets in the queue run through ip forward. There the TTL is decremented and the packet is finally processed or dropped. found by markus@; OK mpi@ sashan@
* Use the rt_rmx defines that hide the struct rt_kmetrics indirection.bluhm2017-04-191-3/+3
| | | | | No binary change. OK mpi@
* A space here, a space there. Soon we're talking real whitespacekrw2017-01-241-11/+11
| | | | rectification.
* Flag pseudo-interfaces as such in order to call add_net_randomness()mpi2017-01-231-1/+2
| | | | | | | | | only once per packet. Fix a regression introduced when if_input() started to be called by every pseudo-driver. ok claudio@, dlg@
* Do not return an error code for SIOCSIFFLAGS.mpi2017-01-191-1/+3
| | | | | | | This synchronize lo(4) with other pseudo-driver and fix a regression introduced by the refactoring of the UP/DOWN logic in if.c ok dlg@, claudio@
* Automatically create a default lo(4) interface per rdomain.mpi2016-11-141-3/+4
| | | | | | | | | | | | | | | | | | In order to stop abusing lo0 for all rdomains, a new loopback interface will be created every time a rdomain is created. The unit number will be the same as the rdomain, i.e. lo1 will be attached to rdomain 1. If this loopback interface is already in use it wont be possible to create the corresponding rdomain. In order to know which lo(4) interface is attached to a rdomain, its index is stored in the rtable/rdomain map. This is a long overdue since the introduction of rtable/rdomain. It also fixes a recent regression due to resetting the rdomain of an incoming packet reported by semarie@, Andreas Bartelt and Nils Frohberg. ok claudio@
* We're always ready! So send IFQ_SET_READY() to the bitbucket.mpi2016-04-131-2/+1
|
* remove old lint annotationstedu2015-12-051-4/+1
|
* Keep lo(4) definitions inside if_loop.cmpi2015-11-271-1/+7
|
* Store the index of the lo0 interface instead of a pointer to itsmpi2015-11-111-4/+4
| | | | | | | | descriptor. Allow to get rid of two if_ref() in the output paths. ok dlg@
* Introduce if_rtrequest() the successor of ifa_rtrequest().mpi2015-10-251-7/+3
| | | | | | | | | 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@
* Introduce if_input_local() a function to feed local traffic back tompi2015-09-121-46/+2
| | | | | | | | | | the protocol queues. It basically does what looutput() was doing but having a generic function will allow us to get rid of the loopback hack overwwritting the rt_ifp field of RTF_LOCAL routes. ok mikeb@, dlg@, claudio@
* Don't use mpls_input() as input handler anymore and instead call itrzalamena2015-07-291-11/+4
| | | | | | directly. Also protect non mp-safe functions while at it. ok mpi@.
* Put the mbuf_list inside "#ifdef MPLS".mpi2015-07-211-1/+3
| | | | reported by rpe@
* Remove splassert(IPL_NET) from if_input().mpi2015-07-201-5/+1
| | | | | | | | | | | 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@
* Kill NETISR_MPLS, from now on we will use interface input handlers to dealrzalamena2015-07-201-3/+14
| | | | | | with MPLS packets. ok mpi@, claudio@
* Store a unique ID, an interface index, rather than a pointer to thempi2015-06-161-2/+2
| | | | | | | | | | | | | | | 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@
* replace the use of ifqueues for most input queues serviced by netisrdlg2015-04-101-15/+6
| | | | | | | | | | | | | | | | | 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@
* Remove some includes include-what-you-use claims don'tjsg2015-03-141-2/+1
| | | | | | | have any direct symbols used. Tested for indirect use by compiling amd64/i386/sparc64 kernels. ok tedu@ deraadt@
* Do not overwrite user-specified MTU.mpi2015-01-271-2/+2
| | | | | | Allow to use different size than the default of 32K. ok henning@, stsp@, florian@, benno@ as part of a larger diff.
* unifdef INET in net code as a precursor to removing the pretend option.tedu2014-12-191-8/+1
| | | | | long live the one true internet. ok henning mikeb
* Explicitly include <net/if_var.h> instead of pulling it in <net/if.h>.mpi2014-12-051-1/+2
| | | | ok mikeb@, krw@, bluhm@, tedu@
* length argument for some free() calls; ok dougderaadt2014-11-231-2/+2
|
* Document that lo0 must be present on your system by panic(9)ing if wempi2014-10-141-2/+4
| | | | | | cannot create it. Suggested by and ok claudio@
* Do not protect the SIOCSIFADDR call by splnet(). Drivers alreadympi2014-10-071-4/+2
| | | | | | | | | | | | raise it inside their ioctl handler (except for carp(4), what else?). In general, global structures manipulated in the softnet codepath only require a splsoftnet() protection when they are modified in process (ioctl) context. Also put some IPL_SOFNET asserts in functions accessing global structures. Previous version diff ok mikeb@, with inputs from and ok bluhm@
* Fewer <netinet/in_systm.h> !mpi2014-07-221-2/+1
|
* add a size argument to free. will be used soon, but for now default to 0.tedu2014-07-121-2/+2
| | | | after discussions with beck deraadt kettenis.
* There is no reason why one needs to have a lo(4) MTU that is arch specific.claudio2014-05-141-6/+2
| | | | | | | Also making the size 32k + some extra is not very helpful since we don't do something like zerocopy or sendfile. Just go back to 32768 and we can bikeshed over the right value later on once we have features that benefit from it. OK mpi@
* /*henning2014-04-191-94/+1
| | | | | | | | * altq for loop is just for debugging. * only used when called for loop interface (not for * a simplex interface). */ bye bye!
* Remove the number of in6_var.h inclusions by moving some functions andmpi2013-10-241-2/+1
| | | | | | global variables to in6.h. ok deraadt@
* Remove the number of in_var.h inclusions by moving some functions andmpi2013-10-231-2/+1
| | | | | | global variables to in.h. ok mikeb@, deraadt@
* Uniformize drivers doing nothing with their multicast filters to makempi2013-10-191-21/+1
| | | | | | them ignore the SIOC{ADD,DEL}MULTI ioctls. ok reyk@, claudio@
* Remove unused argument from *rtrequest()mpi2013-08-281-2/+2
| | | | ok krw@, mikeb@
* do not include machine/cpu.h from a .c file; it is the responsibility ofderaadt2013-03-281-2/+1
| | | | | .h files to pull it in, if needed ok tedu
* Switch to ANSI C prototypes. Diff by somebody else which I no longer remember.claudio2013-03-101-24/+9
| | | | No binary change.
* Use DLT_LOOP for all tunneling interfaces.yasuoka2012-04-141-3/+2
| | | | | | | | Byte order adjustment for bpf was hidden behind bpf_mtap_af() and sizeof(u_int32_t) is used for length of the bpf header. tested by sebastia and mxb at alumni.chalmers.se. ok claudio
* begone, fucking rotten appletalk shit. ok roomhenning2011-07-091-19/+1
|
* make sure RTM_IFINFO is sent when lo(4) handles SIOCSIFADDR; without thissthen2011-07-041-3/+7
| | | | | ospfd doesn't notice an interface added at runtime unless you ifconfig down+up. ok phessler@ claudio@
* Add MPLS support to loopback.norby2008-05-071-1/+17
| | | | | | Makes it possible to do evil tricks locally. ok claudio@
* return with ENOTTY instead of EINVAL for unknown ioctl requests.brad2007-12-201-2/+2
| | | | ok claudio@ krw@ jason@ dlg@
* malloc sweep:henning2007-09-151-3/+2
| | | | | | | -remove useless casts -MALLOC/FREE -> malloc/free -use M_ZERO where appropriate instead of seperate bzero feedback & ok krw, hshoexer