aboutsummaryrefslogtreecommitdiff
path: root/sys/netinet/sctp_pcb.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Mark the socket as disconnected when freeing the association the firstMichael Tuexen2020-02-121-25/+25
| | | | | | | | | | time. This issue was found by running syzkaller. MFC after: 1 week Notes: svn path=/head/; revision=357829
* Revert https://svnweb.freebsd.org/changeset/base/357761Michael Tuexen2020-02-111-2/+2
| | | | | | | This was suggested by cem@ Notes: svn path=/head/; revision=357775
* Don't start an SCTP timer using a net, which has been removed.Michael Tuexen2020-02-111-0/+1
| | | | | | | | Submitted by: Taylor Brandstetter MFC after: 1 week Notes: svn path=/head/; revision=357768
* Use an int instead of a bool variable, since bool is not supportedMichael Tuexen2020-02-111-2/+2
| | | | | | | on all platforms the stack is running on in userland. Notes: svn path=/head/; revision=357761
* Stop the PMTU and HB timer when removing a net, not when freeing it.Michael Tuexen2020-02-091-1/+7
| | | | | | | | Submitted by: Taylor Brandstetter MFC after: 1 week Notes: svn path=/head/; revision=357708
* Cleanup timer handling.Michael Tuexen2020-02-091-45/+6
| | | | | | | | Submitted by: Taylor Brandstetter MFC after: 1 week Notes: svn path=/head/; revision=357705
* Remove unused timer.Michael Tuexen2020-02-041-5/+0
| | | | | | | Submitted by: Taylor Brandstetter Notes: svn path=/head/; revision=357501
* Return -1 consistently if an error occurs.Michael Tuexen2020-01-051-1/+1
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=356377
* Improve input validation for some parameters having a too smallMichael Tuexen2019-12-201-1/+4
| | | | | | | | | | | | reported length. Thanks to Natalie Silvanovich from Google for finding one of these issues in the SCTP userland stack and reporting it. MFC after: 1 week Notes: svn path=/head/; revision=355931
* Move SCTP DTrace probe definitions into a .c file.Mark Johnston2019-10-131-1/+0
| | | | | | | | | | | | | Previously they were defined in a header which was included exactly once. Change this to follow the usual practice of putting definitions in C files. No functional change intended. Discussed with: tuexen MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=353477
* Improve function definition.Michael Tuexen2019-08-311-1/+1
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=351641
* Improve consistency. No functional change.Michael Tuexen2019-08-051-3/+4
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=350588
* IPv6 cleanup: kernelBjoern A. Zeeb2019-08-021-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Finish what was started a few years ago and harmonize IPv6 and IPv4 kernel names. We are down to very few places now that it is feasible to do the change for everything remaining with causing too much disturbance. Remove "aliases" for IPv6 names which confusingly could indicate that we are talking about a different data structure or field or have two fields, one for each address family. Try to follow common conventions used in FreeBSD. * Rename sin6p to sin6 as that is how it is spelt in most places. * Remove "aliases" (#defines) for: - in6pcb which really is an inpcb and nothing separate - sotoin6pcb which is sotoinpcb (as per above) - in6p_sp which is inp_sp - in6p_flowinfo which is inp_flow * Try to use ia6 for in6_addr rather than in6p. * With all these gone also rename the in6p variables to inp as that is what we call it in most of the network stack including parts of netinet6. The reasons behind this cleanup are that we try to further unify netinet and netinet6 code where possible and that people will less ignore one or the other protocol family when doing code changes as they may not have spotted places due to different names for the same thing. No functional changes. Discussed with: tuexen (SCTP changes) MFC after: 3 months Sponsored by: Netflix Notes: svn path=/head/; revision=350531
* Fix socket state handling when freeing an SCTP endpoint.Michael Tuexen2019-07-151-6/+5
| | | | | | | | | This issue was found by runing syzkaller. MFC after: 1 week Notes: svn path=/head/; revision=349998
* When calling sctp_initialize_auth_params(), the inp must have atMichael Tuexen2019-07-141-2/+5
| | | | | | | | | | | least a read lock. To avoid more complex locking dances, just call it in sctp_aloc_assoc() when the write lock is still held. Reported by: syzbot+08a486f7e6966f1c3cfb@syzkaller.appspotmail.com MFC after: 1 week Notes: svn path=/head/; revision=349986
* Improve locking when tearing down an SCTP association.Michael Tuexen2019-03-251-1/+3
| | | | | | | | | | This is joint work with rrs@ and the issue was found by syzkaller. MFC after: 1 week Notes: svn path=/head/; revision=345504
* Allocate an assocition id and register the stcb with holding the lock.Michael Tuexen2019-03-031-7/+2
| | | | | | | | | | | | This avoids a race where stcbs can be found, which are not completely initialized. This was found by running syzkaller. MFC after: 3 days Notes: svn path=/head/; revision=344742
* Refactor the SHUTDOWN_PENDING state handling.Michael Tuexen2018-08-211-1/+0
| | | | | | | | | | | | This is not a functional change but a preperation for the upcoming DTrace support. It is necessary to change the state in one logical operation, even if it involves clearing the sub state SHUTDOWN_PENDING. MFC after: 1 month Notes: svn path=/head/; revision=338134
* Use the stacb instead of the asoc in state macros.Michael Tuexen2018-08-131-25/+25
| | | | | | | | This is not a functional change. Just a preparation for upcoming dtrace state change provider support. Notes: svn path=/head/; revision=337708
* Use consistently the macors to modify the assoc state.Michael Tuexen2018-08-131-10/+10
| | | | | | | No functional change. Notes: svn path=/head/; revision=337706
* Whitespace changes due to changes in ident.Michael Tuexen2018-07-191-0/+16
| | | | Notes: svn path=/head/; revision=336511
* Revert https://svnweb.freebsd.org/changeset/base/336503Michael Tuexen2018-07-191-36/+21
| | | | | | | since I also ran the export script with different parameters. Notes: svn path=/head/; revision=336508
* Whitespace changes due to change if ident.Michael Tuexen2018-07-191-21/+36
| | | | Notes: svn path=/head/; revision=336503
* Don't overflow a buffer if we receive an INIT or INIT-ACK chunkMichael Tuexen2018-06-021-0/+2
| | | | | | | | | | | | | without a RANDOM parameter but with a CHUNKS or HMAC-ALGO parameter. Please note that sending this combination violates the specification. Thnanks to Ronald E. Crane for reporting the issue for the userland stack. MFC after: 3 days Notes: svn path=/head/; revision=334532
* sys: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-201-0/+2
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 3-Clause license. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point. Notes: svn path=/head/; revision=326023
* Allow the setting of the MTU for future paths using an SCTP socket option.Michael Tuexen2017-11-031-10/+55
| | | | | | | | | This functionality was missing. MFC after: 1 week Notes: svn path=/head/; revision=325370
* Add missing socket lock.Michael Tuexen2017-09-221-0/+2
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=323902
* Protect the address workqueue timer by a mutex.Michael Tuexen2017-09-201-4/+2
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=323833
* Silence a Coverity warning from scanning the usrsctp library.Michael Tuexen2017-09-091-2/+2
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=323374
* Use memset/memcpy instead of bzero/bcopy.Michael Tuexen2017-07-191-14/+14
| | | | | | | | | | Just use one variant instead of both. Use the memset/memcpy ones since they cause less problems in crossplatform deployment. MFC after: 1 week Notes: svn path=/head/; revision=321204
* Fix the accounting and add code to detect errors in accounting.Michael Tuexen2017-07-191-52/+88
| | | | | | | | Joint work with rrs@ MFC after: 1 week Notes: svn path=/head/; revision=321197
* Handle sctp_get_next_param() in a consistent way.Michael Tuexen2017-06-231-21/+24
| | | | | | | | | | This addresses an issue found by Felix Weinrank using libfuzz. While there, use also consistent nameing. MFC after: 3 days Notes: svn path=/head/; revision=320300
* The desired lock here is socket buffer, not socket.Gleb Smirnoff2017-06-081-1/+1
| | | | | | | Right now they match, but won't in future. Notes: svn path=/head/; revision=319686
* Use the SCTP_PCB_FLAGS_ACCEPTING flags to check for listeners.Michael Tuexen2017-05-261-2/+2
| | | | | | | | | | While there, use a macro for checking the listen state to allow for easier changes if required. This done to help glebius@ with his listen changes. Notes: svn path=/head/; revision=318958
* Allow SCTP to use the hostcache.Michael Tuexen2017-04-291-16/+8
| | | | | | | | | | | This patch allows the MTU stored in the hostcache to be used as an initial value for SCTP paths. When an ICMP PTB message is received, store the MTU in the hostcache. MFC after: 1 week Notes: svn path=/head/; revision=317597
* Remove IPsec related PCB code from SCTP.Andrey V. Elsukov2017-02-131-18/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The inpcb structure has inp_sp pointer that is initialized by ipsec_init_pcbpolicy() function. This pointer keeps strorage for IPsec security policies associated with a specific socket. An application can use IP_IPSEC_POLICY and IPV6_IPSEC_POLICY socket options to configure these security policies. Then ip[6]_output() uses inpcb pointer to specify that an outgoing packet is associated with some socket. And IPSEC_OUTPUT() method can use a security policy stored in the inp_sp. For inbound packet the protocol-specific input routine uses IPSEC_CHECK_POLICY() method to check that a packet conforms to inbound security policy configured in the inpcb. SCTP protocol doesn't specify inpcb for ip[6]_output() when it sends packets. Thus IPSEC_OUTPUT() method does not consider such packets as associated with some socket and can not apply security policies from inpcb, even if they are configured. Since IPSEC_CHECK_POLICY() method is called from protocol-specific input routine, it can specify inpcb pointer and associated with socket inbound policy will be checked. But there are two problems: 1. Such check is asymmetric, becasue we can not apply security policy from inpcb for outgoing packet. 2. IPSEC_CHECK_POLICY() expects that caller holds INPCB lock and access to inp_sp is protected. But for SCTP this is not correct, becasue SCTP uses own locks to protect inpcb. To fix these problems remove IPsec related PCB code from SCTP. This imply that IP_IPSEC_POLICY and IPV6_IPSEC_POLICY socket options will be not applicable to SCTP sockets. To be able correctly check inbound security policies for SCTP, mark its protocol header with the PR_LASTHDR flag. Reported by: tuexen Reviewed by: tuexen Differential Revision: https://reviews.freebsd.org/D9538 Notes: svn path=/head/; revision=313697
* Merge projects/ipsec into head/.Andrey V. Elsukov2017-02-061-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Small summary ------------- o Almost all IPsec releated code was moved into sys/netipsec. o New kernel modules added: ipsec.ko and tcpmd5.ko. New kernel option IPSEC_SUPPORT added. It enables support for loading and unloading of ipsec.ko and tcpmd5.ko kernel modules. o IPSEC_NAT_T option was removed. Now NAT-T support is enabled by default. The UDP_ENCAP_ESPINUDP_NON_IKE encapsulation type support was removed. Added TCP/UDP checksum handling for inbound packets that were decapsulated by transport mode SAs. setkey(8) modified to show run-time NAT-T configuration of SA. o New network pseudo interface if_ipsec(4) added. For now it is build as part of ipsec.ko module (or with IPSEC kernel). It implements IPsec virtual tunnels to create route-based VPNs. o The network stack now invokes IPsec functions using special methods. The only one header file <netipsec/ipsec_support.h> should be included to declare all the needed things to work with IPsec. o All IPsec protocols handlers (ESP/AH/IPCOMP protosw) were removed. Now these protocols are handled directly via IPsec methods. o TCP_SIGNATURE support was reworked to be more close to RFC. o PF_KEY SADB was reworked: - now all security associations stored in the single SPI namespace, and all SAs MUST have unique SPI. - several hash tables added to speed up lookups in SADB. - SADB now uses rmlock to protect access, and concurrent threads can do SA lookups in the same time. - many PF_KEY message handlers were reworked to reflect changes in SADB. - SADB_UPDATE message was extended to support new PF_KEY headers: SADB_X_EXT_NEW_ADDRESS_SRC and SADB_X_EXT_NEW_ADDRESS_DST. They can be used by IKE daemon to change SA addresses. o ipsecrequest and secpolicy structures were cardinally changed to avoid locking protection for ipsecrequest. Now we support only limited number (4) of bundled SAs, but they are supported for both INET and INET6. o INPCB security policy cache was introduced. Each PCB now caches used security policies to avoid SP lookup for each packet. o For inbound security policies added the mode, when the kernel does check for full history of applied IPsec transforms. o References counting rules for security policies and security associations were changed. The proper SA locking added into xform code. o xform code was also changed. Now it is possible to unregister xforms. tdb_xxx structures were changed and renamed to reflect changes in SADB/SPDB, and changed rules for locking and refcounting. Reviewed by: gnn, wblock Obtained from: Yandex LLC Relnotes: yes Sponsored by: Yandex LLC Differential Revision: https://reviews.freebsd.org/D9352 Notes: svn path=/head/; revision=313330
* Whitespace changes.Michael Tuexen2016-12-261-45/+73
| | | | | | | | | | The toolchain for processing the sources has been updated. No functional change. MFC after: 3 days Notes: svn path=/head/; revision=310590
* Cleanup the names of SSN, SID, TSN, FSN, PPID and MID.Michael Tuexen2016-12-071-9/+9
| | | | | | | | | | | | This made a couple of bugs visible in handling SSN wrap-arounds when using DATA chunks. Now bulk transfer seems to work fine... This fixes the issue reported in https://github.com/sctplab/usrsctp/issues/111 MFC after: 1 week Notes: svn path=/head/; revision=309682
* Mark the socket as un-writable when it is 1-to-1 and the SCTP associationMichael Tuexen2016-10-131-0/+1
| | | | | | | | | is freed. MFC after: 1 month Notes: svn path=/head/; revision=307217
* Whitespace changes.Michael Tuexen2016-10-131-90/+38
| | | | | | | MFC after: 1 month Notes: svn path=/head/; revision=307216
* Remove stream queue entry consistently from wheel.Michael Tuexen2016-08-071-3/+2
| | | | | | | | | While there, improve the handling of drain. MFC after: 3 days Notes: svn path=/head/; revision=303813
* Fix various bugs in relation to the I-DATA chunk supportMichael Tuexen2016-08-061-14/+28
| | | | | | | | | This is joint work with rrs. MFC after: 3 days Notes: svn path=/head/; revision=303792
* net: Use M_HASHTYPE_OPAQUE_HASH if the mbuf flowid has hash propertiesSepherosa Ziehau2016-06-071-1/+1
| | | | | | | | | Reviewed by: hps, erj, tuexen Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6688 Notes: svn path=/head/; revision=301538
* netinet/sctp*: minor spelling fixes in comments.Pedro F. Giffuni2016-05-021-3/+3
| | | | | | | | | No functional change. Reviewed by: tuexen Notes: svn path=/head/; revision=298942
* When a client uses UDP encapsulation and lists IP addresses in the INITMichael Tuexen2016-05-011-8/+8
| | | | | | | | | | | chunk, enable UDP encapsulation for all those addresses. This helps clients using a userland stack to support multihoming if they are not behind a NAT. MFC after: 1 week Notes: svn path=/head/; revision=298902
* Add the UDP encaps port as a parameter to sctp_add_remote_addr().Michael Tuexen2016-04-301-7/+7
| | | | | | | | | | | | This is currently only a code change without any functional change. But this allows to set the remote encapsulation port in a more detailed way, which will be provided in a follow-up commit. MFC after: 1 week Notes: svn path=/head/; revision=298847
* This is work done by Michael Tuexen and myself at the IETF. ThisRandall Stewart2016-04-071-55/+102
| | | | | | | | | | | | adds the new I-Data (Interleaved Data) message. This allows a user to be able to have complete freedom from Head Of Line blocking that was previously there due to the in-ability to send multiple large messages without the TSN's being in sequence. The code as been tested with Michaels various packet drill scripts as well as inter-networking between the IETF's location in Argentina and Germany. Notes: svn path=/head/; revision=297662
* Restrict local addresses until they are acked by the peer.Michael Tuexen2016-03-281-0/+4
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=297361
* Use the SCTP level pointer, not the interface level.Michael Tuexen2016-02-191-3/+2
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=295805