summaryrefslogtreecommitdiff
path: root/sys/net/if.c
AgeCommit message (Collapse)Author
2018-02-10Implement RFC 7217: "A Method for Generating Semantically OpaqueFlorian Obser
Interface Identifiers with IPv6 Stateless Address Autoconfiguration." "An IPv6 address configured using this method is stable within each subnet, but the corresponding Interface Identifier changes when the host moves from one network to another. This method is meant to be an alternative to generating Interface Identifiers based on hardware addresses." OK naddy, sthen
2018-02-10Similar to the IPv6 case create 127.0.0.1/8 on lo(4) interfaces which actClaudio Jeker
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@
2018-02-09oh carp - i didnt mean to commit theseDavid Gwynne
2018-02-09use struct in_addr to represent an address.David Gwynne
2018-02-07add SIOCSETKALIVE to the list of ioctls that need root and NET_LOCKDavid Gwynne
2018-01-12have carp use standard detach hooks instead of getting special handlingDavid Gwynne
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@
2018-01-10get rid of struct carp_if by moving the srpl into struct ifnet if_carp.David Gwynne
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@
2018-01-09Stop grabing the KERNEL_LOCK() for running protocol input routines.Martin Pieuchot
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@
2018-01-09make mpls_input take a struct ifnet *ifp argument.David Gwynne
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@
2018-01-04Include timeout & tasks in 'struct ifnet' instead of always allocatingMartin Pieuchot
them as M_TEMP. ok visa@
2018-01-02Move the NET_LOCK() inside the switch and start documenting which fieldMartin Pieuchot
is protected by which lock. ok bluhm@, visa@
2017-12-29Make the functions which link the pf state keys to mbufs, inpcbs,Alexander Bluhm
or other states more consistent. OK visa@ sashan@ on a previous version
2017-12-15add ifiqueues for mp safety and nics with multiple rx rings.David Gwynne
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@
2017-11-20Do not fail if an interface is DOWN when calling ifpromisc().Martin Pieuchot
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@
2017-11-17add if_rxr_livelocked so rxr users can request backpressure themselves.David Gwynne
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@
2017-11-14Push the NET_LOCK into ifioctl() and use the NET_RLOCK in ifioctl_get().Theo Buehler
In particular, this allows SIOCGIF* requests to run in parallel. lots of help & ok mpi, ok visa, sashan
2017-11-14move the adding of an ifqs counters in if_getdata to ifq.cDavid Gwynne
this keeps the knowledge of ifq locking in ifq.c ok visa@
2017-11-12Only use a single taskq to process incoming network packets as soon asMartin Pieuchot
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@
2017-11-10Introduce a reader version of the NET_LOCK().Martin Pieuchot
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@
2017-11-09The cmd argument of ifconf() has been unused since COMPAT_LINUX wasTheo Buehler
purged. Remove it and move the prototype to if.c since ifconf() is not used outside of this file. ok mpi
2017-11-04Move the ioctls that only need a read lock from ifioctl into a newTheo Buehler
function ifioctl_get(). This simplifies an upcoming diff. suggested by & ok mpi, input & ok florian
2017-11-04Stop calling ifp->if_ioctl() inside in{,6}_ioctl().Martin Pieuchot
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@
2017-10-31- add one more softnet taskqAlexandr Nedvedicky
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@
2017-10-26Stop grabbing the KERNEL_LOCK() in network tasks when `ipsec_in_use'Martin Pieuchot
is set. Accesses to IPsec global data structure are now serialized by the NET_LOCK(). Tested by many, ok visa@, bluhm@
2017-10-16Remove kernel support for the following ioctl(2)s, deprecated since 2001:Martin Pieuchot
- SIOCSIFPHYADDR - SIOCSIFPHYADDR_IN6 - SIOCGIFPSRCADDR - SIOCGIFPSRCADDR_IN6 - SIOCGIFPDSTADDR - SIOCGIFPDSTADDR_IN6 ok bluhm@
2017-10-16Multiple tweaks:Martin Pieuchot
- 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@
2017-10-16Change most of the returns into breaks. This will let us release a lock.Martin Pieuchot
While here add error checks for SIOC{A,D}IFGROUP. ok sashan@, bluhm@, visa@
2017-10-12Move sysctl_mq() where it can safely mess with mbuf queue internals.Martin Pieuchot
ok visa@, bluhm@, deraadt@
2017-10-12Fix a singed vs unsigned comparison resulting in an overflow of theMartin Pieuchot
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@
2017-10-11ifioctl() cleanups.Martin Pieuchot
Only one semantic chance for SIOCSIFXFLAGS, rtm_ifchg() is now only called when the flags changed, not always. ok bluhm@, visa@
2017-10-09Reduces the scope of the NET_LOCK() in sysctl(2) path.Martin Pieuchot
Exposes per-CPU counters to real parrallelism. ok visa@, bluhm@, jca@
2017-08-22Prevent a race against ipsec_in_use.Martin Pieuchot
Problem reported and fix tested by Hrvoje Popovski. ok bluhm@, visa@
2017-08-12Use the NET_LOCK() macro instead of handrolling it.Martin Pieuchot
Tested by Hrvoje Popovski.
2017-08-11Remove NET_LOCK()'s argument.Martin Pieuchot
Tested by Hrvoje Popovski, ok bluhm@
2017-08-10The socket field so_proto can never be NULL. Remove the checks.Alexander Bluhm
OK mpi@ visa@
2017-08-04When we disable INET6 on an interface that also removes the autoconf6Florian Obser
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
2017-08-01rt_if_track() is needed even on ramdisk kernels, because of MPATHTheo de Raadt
ok mpi
2017-07-24Reduce NET_LOCK() contention by moving the linktstate and watchdogMartin Pieuchot
tasks from `systq' to `softnettq'. ok kettenis@, visa@
2017-07-11Purging is at last at hand. Day of Doom is here. All that is evilFlorian Obser
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@
2017-06-23Resetting the mbuf header in if_input_local() was stripping off theAlexander Bluhm
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@
2017-05-31Move IPv4 & IPv6 incoming/forwarding path, PIPEX ppp processing andMartin Pieuchot
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@
2017-05-30Introduce ipv{4,6}_input(), two wrappers around IP queues.Martin Pieuchot
This will help transitionning to an un-KERNEL_LOCK()ed IP forwarding path. Disucssed with bluhm@, ok claudio@
2017-05-30Clear the internal table used by if_get(9) and sleep until allMartin Pieuchot
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@
2017-05-29Do not try to grab the NET_LOCK() while holding an ifp reference.Martin Pieuchot
Fix a deadlock with a thread trying to detach the corresponding interface. ok sashan@, bluhm@
2017-05-28Remove all splnet/splx from pipex(4) and pppx(4) and replace some ofYASUOKA Masahiko
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
2017-05-28Leaving IP multicast group requires the NET_LOCK().Martin Pieuchot
Grab the lock before calling carpdetach(). ok bluhm@
2017-05-16Replace remaining splsoftassert(IPL_SOFTNET) by NET_ASSERT_LOCKED().Martin Pieuchot
ok visa@
2017-05-15Enable the NET_LOCK(), take 3.Martin Pieuchot
Recursions are still marked as XXXSMP. ok deraadt@, bluhm@
2017-05-09pfctlinput(PRC_IFDOWN, ...) has no effect on OpenBSD so remove it.Martin Pieuchot
ok bluhm@
2017-05-04Introduce sstosa() for converting sockaddr_storage with a type safeAlexander Bluhm
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@