summaryrefslogtreecommitdiffstats
path: root/sys/net/if.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* use struct in_addr to represent an address.dlg2018-02-091-1/+9
|
* add SIOCSETKALIVE to the list of ioctls that need root and NET_LOCKdlg2018-02-071-1/+2
|
* have carp use standard detach hooks instead of getting special handlingdlg2018-01-121-6/+1
| | | | | | | | | | | | | if_deactivate looked for carp parent interfaces and called carp_ifdetach to have children interfaces unplug themselves. this diff has the carp interfaces register detach hooks on the parent instead. the effect is the same, but using the standard every other interface uses. while im here i shuffle the order the hooks carp_set_ifp are estabilshed so it will fail if they arent allocated. ok visa@ mpi@
* get rid of struct carp_if by moving the srpl into struct ifnet if_carp.dlg2018-01-101-2/+2
| | | | | | | | | | | | | currently carp uses a struct carp_if to hold an srp list head, which is accessed by both if_carp in struct ifnet, and via the if input handlers list. this gets rid of some indirection by making if_carp itself the list head, rather than a pointer to the list head via a struct carp_if. it also makes accessing the list consistent by only using if_carp to get to it. ok mpi@
* Stop grabing the KERNEL_LOCK() for running protocol input routines.mpi2018-01-091-10/+29
| | | | | | | | | | | | The NET_LOCK() is already held in this thread and is now enough. People interested in ARP/bridge(4)/switch(4)/pipex(4)/pppoe(4) performances can now push the KERNEL_LOCK() without depending on other subsystems/drivers. Tested by Hrvoje Popovski. ok bluhm@, visa@
* make mpls_input take a struct ifnet *ifp argument.dlg2018-01-091-2/+2
| | | | | | | | | | | this makes it like all our other protocol family input functions. mpls_input always looks up the interface the mbuf was received on, but it's always called by code that already has a reference to that interface anyway. the result of this is a few less if_get/if_put calls. ok mpi@ bluhm@ visa@ claudio@
* Include timeout & tasks in 'struct ifnet' instead of always allocatingmpi2018-01-041-20/+10
| | | | | | them as M_TEMP. ok visa@
* Move the NET_LOCK() inside the switch and start documenting which fieldmpi2018-01-021-21/+36
| | | | | | is protected by which lock. ok bluhm@, visa@
* Make the functions which link the pf state keys to mbufs, inpcbs,bluhm2017-12-291-2/+2
| | | | | or other states more consistent. OK visa@ sashan@ on a previous version
* add ifiqueues for mp safety and nics with multiple rx rings.dlg2017-12-151-66/+71
| | | | | | | | | | | | | | | | | | | | | | | | 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@
* Do not fail if an interface is DOWN when calling ifpromisc().mpi2017-11-201-16/+17
| | | | | | | | As soon as the interface will be brough UP, its device driver will recognize it has the IFF_PROMISC flag and will configure its filters accordingly. ok visa@
* add if_rxr_livelocked so rxr users can request backpressure themselves.dlg2017-11-171-1/+14
| | | | | | | | | | | | | right now the rx ring moderation code makes a decision globally that a machine is livelocked, and uses that to apply backpressure on all the rx rings. we're moving toward having the network stack run on multiple cpus, and fed from multiple rx rings. if_rxr_livelocked lets a driver apply backpressure explicitely if something tells it that whatever is consuming previous packets cannot keep up. while here expose the current ring watermark with if_rxr_cwm. tweaks and ok visa@
* Push the NET_LOCK into ifioctl() and use the NET_RLOCK in ifioctl_get().tb2017-11-141-9/+39
| | | | | | In particular, this allows SIOCGIF* requests to run in parallel. lots of help & ok mpi, ok visa, sashan
* move the adding of an ifqs counters in if_getdata to ifq.cdlg2017-11-141-22/+6
| | | | | | this keeps the knowledge of ifq locking in ifq.c ok visa@
* Only use a single taskq to process incoming network packets as soon asmpi2017-11-121-8/+15
| | | | | | | | | | IPsec is enabled. This is currently a no-op since we still use a single taskq. But it will allows us to experiment with multiple forwarding threads and the PF_LOCK() without having to fix IPsec at the same time. ok sashan@, visa@
* Introduce a reader version of the NET_LOCK().mpi2017-11-101-3/+3
| | | | | | | | This will be used to first allow read-only ioctl(2) to be executed while the softnet taskq is running. Then it will allows us to execute multiple softnet taskq in parallel. Tested by Hrvoje Popovski, ok kettenis@, sashan@, visa@, tb@
* The cmd argument of ifconf() has been unused since COMPAT_LINUX wastb2017-11-091-3/+4
| | | | | | | purged. Remove it and move the prototype to if.c since ifconf() is not used outside of this file. ok mpi
* Move the ioctls that only need a read lock from ifioctl into a newtb2017-11-041-71/+115
| | | | | | function ifioctl_get(). This simplifies an upcoming diff. suggested by & ok mpi, input & ok florian
* Stop calling ifp->if_ioctl() inside in{,6}_ioctl().mpi2017-11-041-25/+17
| | | | | | | | | Instead return EOPNOTSUPP and call it from ifioctl(). This will help getting per-driver ioctl routines outside of need the NET_LOCK(). While here always return ENXIO when ``ifp'' is NULL. ok visa@, florian@
* - add one more softnet taskqsashan2017-10-311-11/+27
| | | | | | | 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@
* Stop grabbing the KERNEL_LOCK() in network tasks when `ipsec_in_use'mpi2017-10-261-25/+1
| | | | | | | | | is set. Accesses to IPsec global data structure are now serialized by the NET_LOCK(). Tested by many, ok visa@, bluhm@
* Remove kernel support for the following ioctl(2)s, deprecated since 2001:mpi2017-10-161-7/+1
| | | | | | | | | | | - SIOCSIFPHYADDR - SIOCSIFPHYADDR_IN6 - SIOCGIFPSRCADDR - SIOCGIFPSRCADDR_IN6 - SIOCGIFPDSTADDR - SIOCGIFPDSTADDR_IN6 ok bluhm@
* Multiple tweaks:mpi2017-10-161-34/+33
| | | | | | | | | | | | - Assert that all drivers declare a if_ioctl function pointer and stop checking it against NULL. - Do not use return statements in ifioctl() where a lock is needed. - Call if_setlladdr() only if the underlying driver did not report an error. ok bluhm@
* Change most of the returns into breaks. This will let us release a lock.mpi2017-10-161-29/+29
| | | | | | While here add error checks for SIOC{A,D}IFGROUP. ok sashan@, bluhm@, visa@
* Move sysctl_mq() where it can safely mess with mbuf queue internals.mpi2017-10-121-34/+1
| | | | ok visa@, bluhm@, deraadt@
* Fix a singed vs unsigned comparison resulting in an overflow of thempi2017-10-121-2/+2
| | | | | | | | | | | | | | | | | | routing socket. When clang became the default compiler, `if_flags' from `struct ifnet' was changed from "short" to "unsigned short", to silence a warning. Sadly the copy of these flags on the stack was still a "short" which made the flags comparison always true, which in turn made ifioctl() generates a RTM_INFO message for many ioctl(2). Since my last commit, the flag comparison is done for every ioctl(2). This made the kernel generate at least one routing message per ioctl, resulting in a lot of RTM_DESYNC. RTM_DESYNC problem reported by krw@ thanks to dhclient(8)'s noisiness! ok krw@, patrick@
* ifioctl() cleanups.mpi2017-10-111-27/+17
| | | | | | | Only one semantic chance for SIOCSIFXFLAGS, rtm_ifchg() is now only called when the flags changed, not always. ok bluhm@, visa@
* Reduces the scope of the NET_LOCK() in sysctl(2) path.mpi2017-10-091-3/+13
| | | | | | Exposes per-CPU counters to real parrallelism. ok visa@, bluhm@, jca@
* Prevent a race against ipsec_in_use.mpi2017-08-221-14/+17
| | | | | | Problem reported and fix tested by Hrvoje Popovski. ok bluhm@, visa@
* Use the NET_LOCK() macro instead of handrolling it.mpi2017-08-121-5/+5
| | | | Tested by Hrvoje Popovski.
* Remove NET_LOCK()'s argument.mpi2017-08-111-32/+23
| | | | Tested by Hrvoje Popovski, ok bluhm@
* The socket field so_proto can never be NULL. Remove the checks.bluhm2017-08-101-3/+1
| | | | OK mpi@ visa@
* When we disable INET6 on an interface that also removes the autoconf6florian2017-08-041-4/+9
| | | | | | | flag. Notify userland about this via the route socket, otherwise slaacd gets confused about the state the interface is in. OK on a previous version sthen input & OK bluhm
* rt_if_track() is needed even on ramdisk kernels, because of MPATHderaadt2017-08-011-3/+1
| | | | ok mpi
* Reduce NET_LOCK() contention by moving the linktstate and watchdogmpi2017-07-241-5/+9
| | | | | | tasks from `systq' to `softnettq'. ok kettenis@, visa@
* Purging is at last at hand. Day of Doom is here. All that is evilflorian2017-07-111-11/+1
| | | | | | | | | shall all be cleansed. Remove sending of router solicitations and processing of router advertisements from the kernel. It's handled by slaacd(8) these days. Input & OK bluhm@, mpi@
* Resetting the mbuf header in if_input_local() was stripping off thebluhm2017-06-231-1/+2
| | | | | | M_LOOP flag. This broke IPv6 multicast. Always set M_LOOP when going through if_input_local() and adjust the flag's comment. report rzalamena@; OK mpi@
* Move IPv4 & IPv6 incoming/forwarding path, PIPEX ppp processing andmpi2017-05-311-2/+36
| | | | | | | | | | | | | | | | | | | | | IPv4 & IPv6 dispatch functions outside the KERNEL_LOCK(). We currently rely on the NET_LOCK() serializing access to most global data structures for that. IP input queues are no longer used in the forwarding case. They still exist as boundary between the network and transport layers because TCP/UDP & friends still need the KERNEL_LOCK(). Since we do not want to grab the NET_LOCK() for every packet, the softnet thread will do it once before processing a batch. That means the L2 processing path, which is currently running without lock, will now run with the NET_LOCK(). IPsec isn't ready to run without KERNEL_LOCK(), so the softnet thread will grab the KERNEL_LOCK() as soon as ``ipsec_in_use'' is set. Tested by Hrvoje Popovski. ok visa@, bluhm@, henning@
* Introduce ipv{4,6}_input(), two wrappers around IP queues.mpi2017-05-301-14/+7
| | | | | | | This will help transitionning to an un-KERNEL_LOCK()ed IP forwarding path. Disucssed with bluhm@, ok claudio@
* Clear the internal table used by if_get(9) and sleep until allmpi2017-05-301-3/+3
| | | | | | | | | | | | remaining ifp references are released *without* the NET_LOCK(). It's safe to do so because the KERNEL_LOCK() serializes accesses to ``if_map''. More importantly this fix possible deadlocks between if_get() and the NET_LOCK(). It is now possible to call them in whatever order. ok visa@, dlg@
* Do not try to grab the NET_LOCK() while holding an ifp reference.mpi2017-05-291-7/+6
| | | | | | Fix a deadlock with a thread trying to detach the corresponding interface. ok sashan@, bluhm@
* Remove all splnet/splx from pipex(4) and pppx(4) and replace some ofyasuoka2017-05-281-1/+5
| | | | | | | them by NET_LOCK/NET_UNLOCK. Also make the timeout for pipex_timer run with a thread context and replace pipex softintr by NETISR_PIPEX. ok mpi
* Leaving IP multicast group requires the NET_LOCK().mpi2017-05-281-5/+3
| | | | | | Grab the lock before calling carpdetach(). ok bluhm@
* Replace remaining splsoftassert(IPL_SOFTNET) by NET_ASSERT_LOCKED().mpi2017-05-161-6/+6
| | | | ok visa@
* Enable the NET_LOCK(), take 3.mpi2017-05-151-1/+13
| | | | | | Recursions are still marked as XXXSMP. ok deraadt@, bluhm@
* pfctlinput(PRC_IFDOWN, ...) has no effect on OpenBSD so remove it.mpi2017-05-091-6/+1
| | | | ok bluhm@
* Introduce sstosa() for converting sockaddr_storage with a type safebluhm2017-05-041-2/+2
| | | | | | | inline function instead of casting it to sockaddr. While there, use inline instead of __inline for all these conversions. Some struct sockaddr casts can be avoided completely. OK dhill@ mpi@
* Avoid some false positives with cppcheck. No binary change.bluhm2017-04-141-2/+3
| | | | OK jsg@
* Replace an expensive microtime call with a getmicrotime for if_lastchangemikeb2017-03-221-4/+4
| | | | | | reducing its resolution to 10ms. ok florian, mpi
* Revert the NET_LOCK() and bring back pf's contention lock for release.mpi2017-03-171-13/+1
| | | | | | | | | For the moment the NET_LOCK() is always taken by threads running under KERNEL_LOCK(). That means it doesn't buy us anything except a possible deadlock that we did not spot. So make sure this doesn't happen, we'll have plenty of time in the next release cycle to stress test it. ok visa@