summaryrefslogtreecommitdiff
path: root/sys/netinet
Commit message (Collapse)AuthorAgeFilesLines
* MFstable/11 334801Michael Tuexen2018-06-072-3/+2
| | | | | | | | | | | | | | | | | | | | Improve compliance with RFC 4895 and RFC 6458. Silently dicard SCTP chunks which have been requested to be authenticated but are received unauthenticated no matter if support for SCTP authentication has been negotiated. This improves compliance with RFC 4895. When the application uses the SCTP_AUTH_CHUNK socket option to request a chunk to be received in an authenticated way, enable the SCTP authentication extension for the end-point. This improves compliance with RFC 6458. Discussed with: Peter Lei Approved by: re (marius@) Notes: svn path=/releng/11.2/; revision=334802
* MFstable/11 334732:Michael Tuexen2018-06-062-0/+4
| | | | | | | | | | | | | | Don't overflow a buffer if we receive an INIT or INIT-ACK chunk without a RANDOM parameter but with a CHUNKS or HMAC-ALGO parameter. Please note that sending this combination violates the specification. Thanks to Ronald E. Crane for reporting the issue for the userland stack. Approved by: re (gjb@) Notes: svn path=/releng/11.2/; revision=334743
* MFstable/11 334731Michael Tuexen2018-06-061-2/+8
| | | | | | | | | | | | | Limit the retransmission timer for SYN-ACKs by TCPTV_REXMTMAX. Use the same logic to handle the SYN-ACK retransmission when sent from the syn cache code as when sent from the main code. Approved by: re (gjb@) Sponsored by: Netflix, Inc. Notes: svn path=/releng/11.2/; revision=334740
* MFstable/11 r334730Michael Tuexen2018-06-061-1/+20
| | | | | | | | | | | | | | Ensure net.inet.tcp.syncache.rexmtlimit is limited by TCP_MAXRXTSHIFT. If the sysctl variable is set to a value larger than TCP_MAXRXTSHIFT+1, the array tcp_syn_backoff[] is accessed out of bounds. Discussed with: jtl@ Approved by: re (gjb) Sponsored by: Netflix, Inc. Notes: svn path=/releng/11.2/; revision=334737
* MFstable/11 r334728:Michael Tuexen2018-06-061-1/+3
| | | | | | | | | | Ensure we are not dereferencing a NULL pointer. CID: 1385266 Approved by: re (marius@) Notes: svn path=/releng/11.2/; revision=334734
* MFC r333382:Michael Tuexen2018-05-311-0/+14
| | | | | | | | | | | | | | | | | When reporting ERROR or ABORT chunks, don't use more data that is guaranteed to be contigous. Thanks to Felix Weinrank for finding and reporting this bug by fuzzing the usrsctp stack. MFC r333386: Fix two typos reported by N. J. Mann, which were introduced in https://svnweb.freebsd.org/changeset/base/333382 by me. Approved by: re@ (marius) Notes: svn path=/stable/11/; revision=334441
* MFC r333244:Andrey V. Elsukov2018-05-151-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | Immediately propagate EACCES error code to application from tcp_output. In r309610 and r315514 the behavior of handling EACCES was changed, and tcp_output() now returns zero when EACCES happens. The reason of this change was a hesitation that applications that use TCP-MD5 will be affected by changes in project/ipsec. TCP-MD5 code returns EACCES when security assocition for given connection is not configured. But the same error code can return pfil(9), and this change has affected connections blocked by pfil(9). E.g. application doesn't return immediately when SYN segment is blocked, instead it waits when several tries will be failed. Actually, for TCP-MD5 application it doesn't matter will it get EACCES after first SYN, or after several tries. Security associtions must be configured before initiating TCP connection. I left the EACCES in the switch() to show that it has special handling. Reported by: Andreas Longwitz <longwitz at incore dot de> Approved by: re (marius) Notes: svn path=/stable/11/; revision=333627
* MFC r331745 (by np):Jonathan T. Looney2018-04-231-2/+2
| | | | | | | | | | | | Fix RSS build (broken in r331309). Sponsored by: Chelsio Communications PR: 227691 Pointy-hat to: jtl Notes: svn path=/stable/11/; revision=332889
* MFC r319214:Jonathan T. Looney2018-04-201-7/+5
| | | | | | | | | | | | | | Enforce the limit on ICMP messages before doing work to formulate the response. Delete an unneeded rate limit for UDP under IPv6. Because ICMP6 messages have their own rate limit, it is unnecessary to apply a second rate limit to UDP messages. Sponsored by: Netflix, Inc. Notes: svn path=/stable/11/; revision=332840
* MFC r307083:Jonathan T. Looney2018-04-201-3/+3
| | | | | | | | | | | | | | | | | Currently, when tcp_input() receives a packet on a session that matches a TCPCB, it checks (so->so_options & SO_ACCEPTCONN) to determine whether or not the socket is a listening socket. However, this causes the code to access a different cacheline. If we first check if the socket is in the LISTEN state, we can avoid accessing so->so_options when processing packets received for ESTABLISHED sessions. If INVARIANTS is defined, the code still needs to access both variables to check that so->so_options is consistent with the state. Sponsored by: Netflix, Inc. Notes: svn path=/stable/11/; revision=332829
* MFC r306768:Jonathan T. Looney2018-04-201-3/+4
| | | | | | | | If the new window size is less than the old window size, skip the calculations to check if we should advertise a larger window. Notes: svn path=/stable/11/; revision=332828
* MFC r331309:Jonathan T. Looney2018-04-201-22/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the INP lock is uncontested, avoid taking a reference and jumping through the lock-switching hoops. A few of the INP lookup operations that lock INPs after the lookup do so using this mechanism (to maintain lock ordering): 1. Lock lookup structure. 2. Find INP. 3. Acquire reference on INP. 4. Drop lock on lookup structure. 5. Acquire INP lock. 6. Drop reference on INP. This change provides a slightly shorter path for cases where the INP lock is uncontested: 1. Lock lookup structure. 2. Find INP. 3. Try to acquire the INP lock. 4. If successful, drop lock on lookup structure. Of course, if the INP lock is contested, the functions will need to revert to the previous way of switching locks safely. This saves a few atomic operations when the INP lock is uncontested. Sponsored by: Netflix, Inc. Notes: svn path=/stable/11/; revision=332821
* MFC r331926:Jonathan T. Looney2018-04-201-4/+4
| | | | | | | | | | | | | | r330675 introduced an extra window check in the LRO code to ensure it captured and reported the highest window advertisement with the same SEQ/ACK. However, the window comparison uses modulo 2**16 math, rather than directly comparing the absolute values. Because windows use absolute values and not modulo 2**16 math (i.e. they don't wrap), we need to compare the absolute values. Sponsored by: Netflix, Inc. Notes: svn path=/stable/11/; revision=332818
* MFC r332120:Jonathan T. Looney2018-04-201-1/+4
| | | | | | | | | | | | | | | | | If a user closes the socket before we call tcp_usr_abort(), then tcp_drop() may unlock the INP. Currently, tcp_usr_abort() does not check for this case, which results in a panic while trying to unlock the already-unlocked INP (not to mention, a use-after-free violation). Make tcp_usr_abort() check the return value of tcp_drop(). In the case where tcp_drop() returns NULL, tcp_usr_abort() can skip further steps to abort the connection and simply unlock the INP_INFO lock prior to returning. Sponsored by: Netflix, Inc. Notes: svn path=/stable/11/; revision=332817
* MFC r332273:Michael Tuexen2018-04-161-1/+1
| | | | | | | | Fix a logical inversion bug. Thanks to Irene Ruengeler for finding and reporting this bug. Notes: svn path=/stable/11/; revision=332636
* MFC r332271:Michael Tuexen2018-04-161-15/+3
| | | | | | | Small cleanup, no functional change. Notes: svn path=/stable/11/; revision=332635
* MFC r332269:Michael Tuexen2018-04-161-1/+1
| | | | | | | | | Fix a signed/unsigned warning showing up for the userland stack on some platforms. Thanks to Felix Weinrank for reporting the issue. Notes: svn path=/stable/11/; revision=332634
* MFC r331436:Kristof Provost2018-04-153-5/+5
| | | | | | | | | | | | | | | | | | netpfil: Introduce PFIL_FWD flag Forwarded packets passed through PFIL_OUT, which made it difficult for firewalls to figure out if they were forwarding or producing packets. This in turn is an issue for pf for IPv6 fragment handling: it needs to call ip6_output() or ip6_forward() to handle the fragments. Figuring out which was difficult (and until now, incorrect). Having pfil distinguish the two removes an ugly piece of code from pf. Introduce a new variant of the netpfil callbacks with a flags variable, which has PFIL_FWD set for forwarded packets. This allows pf to reliably work out if a packet is forwarded. Notes: svn path=/stable/11/; revision=332513
* MFC r328988,r328989:Andrey V. Elsukov2018-04-111-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rework ipfw dynamic states implementation to be lockless on fast path. o added struct ipfw_dyn_info that keeps all needed for ipfw_chk and for dynamic states implementation information; o added DYN_LOOKUP_NEEDED() macro that can be used to determine the need of new lookup of dynamic states; o ipfw_dyn_rule now becomes obsolete. Currently it used to pass information from kernel to userland only. o IPv4 and IPv6 states now described by different structures dyn_ipv4_state and dyn_ipv6_state; o IPv6 scope zones support is added; o ipfw(4) now depends from Concurrency Kit; o states are linked with "entry" field using CK_SLIST. This allows lockless lookup and protected by mutex modifications. o the "expired" SLIST field is used for states expiring. o struct dyn_data is used to keep generic information for both IPv4 and IPv6; o struct dyn_parent is used to keep O_LIMIT_PARENT information; o IPv4 and IPv6 states are stored in different hash tables; o O_LIMIT_PARENT states now are kept separately from O_LIMIT and O_KEEP_STATE states; o per-cpu dyn_hp pointers are used to implement hazard pointers and they prevent freeing states that are locklessly used by lookup threads; o mutexes to protect modification of lists in hash tables now kept in separate arrays. 65535 limit to maximum number of hash buckets now removed. o Separate lookup and install functions added for IPv4 and IPv6 states and for parent states. o By default now is used Jenkinks hash function. Obtained from: Yandex LLC Sponsored by: Yandex LLC Differential Revision: https://reviews.freebsd.org/D12685 Notes: svn path=/stable/11/; revision=332401
* MFC r331797:Brooks Davis2018-04-081-3/+5
| | | | | | | | | | | | | | | Use an accessor function to access ifr_data. This fixes 32-bit compat (no ioctl command defintions are required as struct ifreq is the same size). Reviewed by: kib Obtained from: CheriBSD Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D14900 Notes: svn path=/stable/11/; revision=332288
* MFC r327203:Michael Tuexen2018-04-081-1/+1
| | | | | | | | | | | Allow the first (and second) argument of sn_calloc() be a sum. This fixes a bug reported in https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=224103 PR: 224103 Notes: svn path=/stable/11/; revision=332276
* MFC r327214:Michael Tuexen2018-04-071-296/+295
| | | | | | | Whitespace changes. Notes: svn path=/stable/11/; revision=332257
* MFC r327209:Michael Tuexen2018-04-071-14/+15
| | | | | | | Clarify that there is no break missing. While there, cleanup whitespaces. Notes: svn path=/stable/11/; revision=332256
* Clarify that the break is not missing.Michael Tuexen2018-04-071-0/+1
| | | | | | | CID: 1008198 Notes: svn path=/stable/11/; revision=332255
* MFC r327205:Michael Tuexen2018-04-071-6/+6
| | | | | | | | | Fix an assignment. While there, do some whitespace cleanups. CID: 1008936 Notes: svn path=/stable/11/; revision=332254
* MFC r331061:Michael Tuexen2018-04-071-0/+2
| | | | | | | | | | | | | | | | | | | Set the inp_vflag consistently for accepted TCP/IPv6 connections when net.inet6.ip6.v6only=0. Without this patch, the inp_vflag would have INP_IPV4 and the INP_IPV6 flags for accepted TCP/IPv6 connections if the sysctl variable net.inet6.ip6.v6only is 0. This resulted in netstat to report the source and destination addresses as IPv4 addresses, even they are IPv6 addresses. PR: 226421 Reviewed by: bz, hiren, kib Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D13514 Notes: svn path=/stable/11/; revision=332238
* MFC r328478:Michael Tuexen2018-04-071-0/+2
| | | | | | | | Add constant for the PAD chunk as defined in RFC 4820. This will be used by traceroute and traceroute6 soon. Notes: svn path=/stable/11/; revision=332236
* MFC r328477:Michael Tuexen2018-04-071-21/+10
| | | | | | | | Update references in comments, since the IDs have become an RFC long time ago. Also cleanup whitespaces. No functional change. Notes: svn path=/stable/11/; revision=332235
* MFC r328066:Michael Tuexen2018-04-071-14/+14
| | | | | | | | | | | | | | | | Fix a bug related to fast retransmissions. When processing a SACK advancing the cumtsn-ack in fast recovery, increment the miss-indications for all TSN's reported as missing. Thanks to Fabian Ising for finding the bug and to Timo Voelker for provinding a fix. This fix moves also CMT related initialisation of some variables to a more appropriate place. Notes: svn path=/stable/11/; revision=332234
* MFC r328028:Michael Tuexen2018-04-071-5/+15
| | | | | | | | Don't provide a (meaningless) cmsg when proving a notification in a recvmsg() call. Notes: svn path=/stable/11/; revision=332232
* MFC r326233:Michael Tuexen2018-04-073-46/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add to ipfw support for sending an SCTP packet containing an ABORT chunk. This is similar to the TCP case. where a TCP RST segment can be sent. There is one limitation: When sending an ABORT in response to an incoming packet, it should be tested if there is no ABORT chunk in the received packet. Currently, it is only checked if the first chunk is an ABORT chunk to avoid parsing the whole packet, which could result in a DOS attack. Thanks to Timo Voelker for helping me to test this patch. MFC r327200: When adding support for sending SCTP packets containing an ABORT chunk to ipfw in https://svnweb.freebsd.org/changeset/base/326233, a dependency on the SCTP stack was added to ipfw by accident. This was noted by Kevel Bowling in https://reviews.freebsd.org/D13594 where also a solution was suggested. This patch is based on Kevin's suggestion, but implements the required SCTP checksum computation without any dependency on other SCTP sources. While there, do some cleanups and improve comments. Thanks to Kevin Kevin Bowling for reporting the issue and suggesting a fix. Notes: svn path=/stable/11/; revision=332229
* MFC r326829:Michael Tuexen2018-04-072-15/+13
| | | | | | | Cleaup, no functional change. Notes: svn path=/stable/11/; revision=332228
* MFC r326672:Michael Tuexen2018-04-077-60/+2
| | | | | | | | | | | | | Retire SCTP_WITH_NO_CSUM option. This option was used in the early days to allow performance measurements extrapolating the use of SCTP checksum offloading. Since this feature is now available, get rid of this option. This also un-breaks the LINT kernel. Thanks to markj@ for making me aware of the problem. Notes: svn path=/stable/11/; revision=332227
* MFC r325864:Michael Tuexen2018-04-071-58/+74
| | | | | | | | | | Fix the handling of ERROR chunks which a lot of error causes. While there, clean up the code. Thanks to Felix Weinrank who found the bug by using fuzz-testing the SCTP userland stack. Notes: svn path=/stable/11/; revision=332226
* MFC r325788:Michael Tuexen2018-04-071-52/+24
| | | | | | | Simply the code and use the full buffer for contigous chunk representation. Notes: svn path=/stable/11/; revision=332225
* MFC r325746:Michael Tuexen2018-04-071-240/+110
| | | | | | | | | Cleanup the handling of control chunks. While there fix some minor bug related to clearing the assoc retransmit counter and the dup TSN handling of NR-SACK chunks. Notes: svn path=/stable/11/; revision=332224
* MFC r325434:Michael Tuexen2018-04-071-17/+24
| | | | | | | | | | Fix an accounting bug where data was counted twice if on the read queue and on the ordered or unordered queue. While there, improve the checking in INVARIANTs when computing the a_rwnd. Notes: svn path=/stable/11/; revision=332223
* MFC r325370:Michael Tuexen2018-04-076-21/+74
| | | | | | | | Allow the setting of the MTU for future paths using an SCTP socket option. This functionality was missing. Notes: svn path=/stable/11/; revision=332222
* MFC r325284:Michael Tuexen2018-04-071-1/+1
| | | | | | | Fix the reporting of the MTU for SCTP sockets when using IPv6. Notes: svn path=/stable/11/; revision=332221
* MFC r325046:Michael Tuexen2018-04-071-17/+22
| | | | | | | | | | | Fix parsing error when processing cmsg in SCTP send calls. The bug is related to a signed/unsigned mismatch. This should most likely fix the issue in sctp_sosend reported by Dmitry Vyukov on the freebsd-hackers mailing list and found by running syzkaller. Notes: svn path=/stable/11/; revision=332220
* MFC r324971:Michael Tuexen2018-04-071-3/+3
| | | | | | | | Fix a bug reported by Felix Weinrank using the libfuzzer on the userland stack. Notes: svn path=/stable/11/; revision=332218
* MFC r324958:Michael Tuexen2018-04-071-11/+18
| | | | | | | | | Fix a bug in handling special ABORT chunks. Thanks to Felix Weinrank for finding this issue using libfuzzer with the userland stack. Notes: svn path=/stable/11/; revision=332217
* MFC r324954:Michael Tuexen2018-04-071-3/+0
| | | | | | | | Fix a locking issue found by running AFL on the userland stack. Thanks to Felix Weinrank for reporting the issue. Notes: svn path=/stable/11/; revision=332216
* MFC r324730:Michael Tuexen2018-04-071-4/+5
| | | | | | | Fix a signed/unsigned warning. Notes: svn path=/stable/11/; revision=332215
* MFC r324729:Michael Tuexen2018-04-071-4/+25
| | | | | | | | | | Abort an SCTP association, when a DATA chunk is followed by an unknown chunk with a length smaller than the minimum length. Thanks to Felix Weinrank for making me aware of the problem. Notes: svn path=/stable/11/; revision=332214
* MFC r324638:Michael Tuexen2018-04-071-114/+57
| | | | | | | | | | | | | | | | | | | | | | | Fix the handling of parital and too short chunks. Ensure that the current behaviour is consistent: stop processing of the chunk, but finish the processing of the previous chunks. This behaviour might be changed in a later commit to ABORT the assoication due to a protocol violation, but changing this is a separate issue. MFC r324725 Fix a bug introduced in r324638. Thanks to Felix Weinrank for making me aware of this. MFC r324726: Revert change which got in accidently. Notes: svn path=/stable/11/; revision=332213
* MFC r324615:Michael Tuexen2018-04-076-30/+20
| | | | | | | | | | Code cleanup, not functional change. This avoids taking a pointer of a packed structure which allows simpler compilation of the userland stack. Notes: svn path=/stable/11/; revision=332212
* MFC r324317:Michael Tuexen2018-04-071-0/+1
| | | | | | | | Ensure that the accept ABORT chunks with the T-bit set only the a non-zero matching peer tag is provided. Notes: svn path=/stable/11/; revision=332211
* MFC r324056:Michael Tuexen2018-04-072-36/+0
| | | | | | | Remove unused function. Notes: svn path=/stable/11/; revision=332204
* MFC r323904:Michael Tuexen2018-04-071-0/+10
| | | | | | | | Add missing locking. Found by Coverity while scanning the usrsctp library. Notes: svn path=/stable/11/; revision=332203