summaryrefslogtreecommitdiff
path: root/sys/netinet
AgeCommit message (Collapse)Author
2017-06-26Convert ip_input() to a pr_input style function. Goal is to processAlexander Bluhm
IPsec packets without additional enqueueing. OK mpi@
2017-06-26Assert that the corresponding socket is locked when manipulating socketMartin Pieuchot
buffers. This is one step towards unlocking TCP input path. Note that all the functions asserting for the socket lock are not necessarilly MP-safe. All the fields of 'struct socket' aren't protected. Introduce a new kernel-only kqueue hint, NOTE_SUBMIT, to be able to tell when a filter needs to lock the underlying data structures. Logic and name taken from NetBSD. Tested by Hrvoje Popovski. ok claudio@, bluhm@, mikeb@
2017-06-26Split a part of tdb_delete() into tdb_unlink() so that we can removePatrick Wildt
a TDB from the hash table without actually free()ing it. That way we can modify the TDB and then put it back in using puttdb(). ok claudio@
2017-06-22Fix the remaining ';;'s in sys/Tom Cosgrove
2017-06-20Do not use the interface pointer after if_put(). Rename ipip_input_gif()Alexander Bluhm
to ipip_input_if() and always pass the ifp. Only dump the packet to bpf if we are called with a gif(4) interface. OK mpi@
2017-06-19When dealing with mbuf pointers passed down as function parameters,Alexander Bluhm
bugs could easily result in use-after-free or double free. Introduce m_freemp() which automatically resets the pointer before freeing it. So we have less dangling pointers in the kernel. OK krw@ mpi@ claudio@
2017-06-19The IP multicast forward functions return an errno, call the variableAlexander Bluhm
error. Make the ip_mforward() return value consistent. Simplify the caller logic in ipv6_input() like in IPv4. OK mpi@
2017-06-11Use a common 'goto bad' style and set mp to NULL after freeing itAlexander Bluhm
in ipip_input_gif(). This prevents a use-after-free if there is a bug in the IP input functions. OK mpi@
2017-06-09Replace rtrequest(RTM_DELETE...) rtrequest_delete() and do not evenMartin Pieuchot
try to remove a route from the table if it is and invalid cache. This is a step towards decoupling code dealing with userland and kernel inserted routes. ok bluhm@
2017-06-07Grab the KERNEL_LOCK() around rtm*() functions. Routing sockets globalsMartin Pieuchot
aren't protected by the NET_LOCK(). While here change lock assertions in rt_{set,put}gwroute(), the NET_LOCK() is enough. Tested by Hrvoje Popovski. ok jmatthew@, claudio@
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-30add sizes to free() callsTheo de Raadt
2017-05-30Carp balancing ip does not work since there is a mac filter infriehm
ether_input(). Now we use mbuf tags instead of modifying the MAC address. ok mpi@
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-29Per-interface list of addresses, both multicast and unicast, areMartin Pieuchot
currently protected by the NET_LOCK(). They are not accessed in the hot path, so protecting them with a mutex could be an option. However since we're now going to run with a NET_LOCK() for some time, assert that it is held. IPsec is not yet ready to run without KERNEL_LOCK(), so assert it is held, even in the forwarding path. Tested by sthen@, ok visa@, claudio@, bluhm@
2017-05-28Call bpf_mtap_af() a bit earlier in ipip_input(). This preparesAlexander Bluhm
upcoming diffs, no functional change. OK mpi@
2017-05-28Leaving IP multicast group requires the NET_LOCK().Martin Pieuchot
Grab the lock before calling carpdetach(). ok bluhm@
2017-05-28clang warns on unused labels. Place a recently introduced label underJonathan Gray
ifdef IPSEC to fix the clang build when IPSEC is not defined. ok deraadt@ bluhm@
2017-05-28Rename ip_local() to ip_deliver() and give it the same parametersAlexander Bluhm
as the pr_input functions. Add an assert that IPv4 delivery ends in IP proto done to assure that IPv4 protocol functions work like IPv6. OK mpi@
2017-05-27Fix the carp mode 'balancing ip-stealth'. Set the link state UPAlexander Bluhm
if at least one vhid is in state MASTER. from Florian Riehm; OK florian@
2017-05-26In IPIP input rename the variable ipo to ip as it is used for innerAlexander Bluhm
and outer header. Reset values depending on the the mbuf when the mbuf is adjusted. Check the length of the inner IP header with the correct size in case of IPv6. Check the IPv4 header size including IP options. For the IPIP statistics the inner header length has to be subtracted from the packet size as the outer header has already been stripped off. OK mpi@
2017-05-26Instead of looking at the IP version of the header, use the outerAlexander Bluhm
address family passed to ipip_input(). OK mpi@
2017-05-22Move IPsec forward and local policy check functions to ipsec_input.cAlexander Bluhm
and give them better names. input and OK mikeb@
2017-05-22Use the IPsec policy check from IPv4 also when doing local deliveryAlexander Bluhm
in ip6_local() to our IPv6 stack. OK mikeb@
2017-05-22Fix a mbuf leak when reflecting an ICMP packet with IP options.Alexander Bluhm
Free the options in icmp_input_if() after a successful call to icmp_reflect(). bug report and analysis by Hendrik Gerlach OK krw@ claudio@ phessler@
2017-05-18Merge the content of <netinet/tcpip.h> and <netinet6/tcpipv6.h> inMartin Pieuchot
<netinet/tcp_debug.h>. The IPv6 variant was always included and the IPv4 version is not present on all systems. Most of the offending ports are already fixed, thanks to sthen@!
2017-05-18The function name ip4_input() is confusing as it also handles IPv6Alexander Bluhm
packets. This is the IP in IP protocol input function, so call it ipip_input(). Rename the existing ipip_input() to ipip_input_gif() as it is the input function used by the gif interface. Pass the address family to make it consistent with pr_input. Use __func__ in debug print and panic messages. Move all ipip prototypes to the ip_ipip.h header file. OK dhill@ mpi@
2017-05-17The large and nested GIF #ifdef in protosw made it hard to figureAlexander Bluhm
out what is going on. There were also some inconsistencies that seem to be oversights. Use more specific the #ifdefs. OK mpi@
2017-05-16Sync three changes that were caught by IPv6 multicast routing review:Rafael Zalamena
* use a variable to allow disabling debugs on run-time * fix a potential memory leak on copyout() failure * don't just blindly use the first address provided by ifalist ok bluhm@
2017-05-16Make return values more meaningful by using errno instead of -1 or 1.Rafael Zalamena
ok bluhm@
2017-05-16Replace remaining splsoftassert(IPL_SOFTNET) by NET_ASSERT_LOCKED().Martin Pieuchot
ok visa@
2017-05-16Let malloc() block when the caller of the add route function isRafael Zalamena
setsockopt(), otherwise use non-blocking malloc() for network stack calls. ok bluhm@
2017-05-16Call rtfree() after each use of routes and make sure the route is validRafael Zalamena
when finding one. Since rtfree() is being called and rt_llinfo being removed, add checks everywhere to make sure we are using a route that is not being removed. ok bluhm@
2017-05-13Do not check for mapped addresses in tcp_usrreq(PRU_CONNECT),Alexander Bluhm
this is done in in6_pcbconnect(). OK mpi@
2017-05-12IPsec packets were passed through ip_input() a second time afterAlexander Bluhm
they have been decrypted. That means that all the IP header fields were checked twice. Also fragment reassembly was tried twice. At pf incoming packets in tunnel mode appeared twice on the enc0 interface, once as IP-in-IP and once as the inner packet. In the outgoing path pf only sees the inner packet. Asymmetry is bad for stateful filtering. IPv6 shows that IPsec works without that. After decrypting immediately continue with local delivery. In tunnel mode the IP-in-IP protocol functions pass the inner header to ip6_input(). In transport mode only pf_test() has to be called for the enc0 device. Introduce ip_local() to avoid needless processing and cleaner pf behavior in IPv4 IPsec. OK mikeb@
2017-05-12Use the common switch(af) construct for address family specificAlexander Bluhm
code in tcp_usrreq(PRU_CONNECT). Do not access sockaddr_in before checking the address family. Return EAFNOSUPPORT error in the default case. OK mikeb@
2017-05-12Instead of printing a debug message at the end of processing, panicAlexander Bluhm
early if the IPsec security protocol is unknown. ipsec_common_input() and ipsec_common_input_cb() can only be called with the IP protocols ESP, AH, or IPComp. Everything else is a programming mistake. OK claudio@
2017-05-12Use the IPsec policy check from ipv4_input() also when forwardingAlexander Bluhm
in ip6_input(). While there avoid an ugly #ifdef in ipv4_input(). OK mikeb@
2017-05-11IPv6 IPsec transport mode did not work if pf is enabled. TheAlexander Bluhm
decrypted packets in the input path were not checked with pf. So with stateful filtering on enc0, direction aware protocols like ping or TCP did not pass. Add an explicit pf_test() in ipsec_common_input_cb() for IPv6 transport mode to fix this. OK mikeb@
2017-05-11Fix white spaces and wrap long line. No binary change.Alexander Bluhm
2017-05-09Remove rip_output() and rip6_output() from inetsw and inet6sw. TheAlexander Bluhm
rip_output() function is never called via the pr_output pointer. rip_usrreq(PRU_SEND) calls rip_output() directly. raw_usrreq() is never called from inetsw. Situation in inet and inet6 is analog. OK claudio@ mikeb@
2017-05-09Convert diagnostic panic to compile time assert in tcp6_ctlinput().Alexander Bluhm
No binary change. OK mpi@
2017-05-06Checking for IPv4 mapped addreses and dropping the packet is doneAlexander Bluhm
in ip6_input(). Do not check that again in the protocol input functions. OK mpi@
2017-05-06Convert the xformsw definition to C99 style initializer. Also fixAlexander Bluhm
the function declaration of ipe4_input() and avoid a wrong cast. OK mikeb@ dhill@
2017-05-05Expand SA_LEN(), there is no benefit for using the macro in theAlexander Bluhm
kernel. It was only used in IPsec sources. No binary change OK deraadt@
2017-05-04If m is not a continuous mbuf cluster, m_pullup() in pr_input mayAlexander Bluhm
change the pointer. Then *mp keeps the invalid pointer and it might be used. Fix the potential use after free and also reset *mp in other places to have less dangling pointers to freed mbufs. OK mpi@ mikeb@
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@
2017-05-03Back out rev 1.185 (which made the code match the comment) andTodd C. Miller
adjust the comment to match reality (or at least rfc7323) instead. This brings us back in line with the behavior of Net and Free. From Lauri Tirkkonen. OK bluhm@
2017-05-02Switch OCF and IPsec over to the new AESMike Belopuhov
ok djm
2017-04-19Use the rt_rmx defines that hide the struct rt_kmetrics indirection.Alexander Bluhm
No binary change. OK mpi@