From d6f2d959a0f498797bf3e7ac27d6da3afc64d148 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Fri, 14 Jan 2022 22:34:50 +0400 Subject: [PATCH] Update webrtc --- submodules/TgVoipWebrtc/BUILD | 1 + submodules/TgVoipWebrtc/tgcalls | 2 +- third-party/webrtc/BUILD | 65 +- .../usrsctp/usrsctplib/CMakeLists.txt | 16 +- .../third_party/usrsctp/usrsctplib/Manual.md | 7 +- .../third_party/usrsctp/usrsctplib/Manual.tex | 19 +- .../third_party/usrsctp/usrsctplib/README.md | 4 +- .../usrsctplib/cmake/FindMbedTLS.cmake | 38 + .../usrsctp/usrsctplib/configure.ac | 14 +- .../usrsctp/usrsctplib/fuzzer/CMakeLists.txt | 108 - ...z-testcase-fuzzer_connect-5204536192401408 | Bin 5728 -> 0 bytes ...z-testcase-fuzzer_connect-5634380847906816 | Bin 944 -> 0 bytes ...z-testcase-fuzzer_connect-5645105154752512 | Bin 92 -> 0 bytes ...z-testcase-fuzzer_connect-5649242005176320 | Bin 85 -> 0 bytes ...z-testcase-fuzzer_connect-5649768725872640 | Bin 62779 -> 0 bytes ...z-testcase-fuzzer_connect-5676652788449280 | Bin 255 -> 0 bytes ...z-testcase-fuzzer_connect-5688015225094144 | Bin 4148 -> 0 bytes ...z-testcase-fuzzer_connect-5722044720742400 | Bin 4409 -> 0 bytes ...z-testcase-fuzzer_connect-5734997805236224 | Bin 65532 -> 0 bytes ...z-testcase-fuzzer_connect-5736809862004736 | Bin 5139 -> 0 bytes ...z-testcase-fuzzer_connect-5741506257747968 | Bin 5287 -> 0 bytes ...z-testcase-fuzzer_connect-5759310927233024 | Bin 3255 -> 0 bytes ...stcase-fuzzer_unconnected-5767885871382528 | Bin 1024642 -> 0 bytes ...-minimized-fuzzer_connect-5631709814456320 | Bin 242 -> 0 bytes ...-minimized-fuzzer_connect-5638658568224768 | Bin 35209 -> 0 bytes ...-minimized-fuzzer_connect-5675883720867840 | Bin 1284 -> 0 bytes ...-minimized-fuzzer_connect-5764087333519360 | Bin 1271 -> 0 bytes ...imized-fuzzer_unconnected-5639391992610816 | Bin 1020106 -> 0 bytes ...h-0a63175dc6b51474dc08197431ec36d11db5e77b | Bin 291 -> 0 bytes ...h-27ffd53d682a7908bf7569e32d904f049066b5d6 | Bin 444 -> 0 bytes .../fuzzer/CORPUS_CONNECT/data-1.bin | Bin 16 -> 0 bytes .../fuzzer/CORPUS_CONNECT/init-ack-1.bin | Bin 444 -> 0 bytes ...k-00bd871f5ce0596083fe8642c803c97f424b0c70 | Bin 1068 -> 0 bytes .../fuzzer/CORPUS_CONNECT/rtcweb-000000 | Bin 101 -> 0 bytes .../fuzzer/CORPUS_CONNECT/rtcweb-000001 | Bin 421 -> 0 bytes .../fuzzer/CORPUS_CONNECT/rtcweb-000002 | Bin 329 -> 0 bytes .../fuzzer/CORPUS_CONNECT/rtcweb-000003 | Bin 5 -> 0 bytes .../fuzzer/CORPUS_CONNECT/rtcweb-000004 | Bin 25 -> 0 bytes .../fuzzer/CORPUS_CONNECT/rtcweb-000005 | Bin 17 -> 0 bytes .../fuzzer/CORPUS_CONNECT/rtcweb-000006 | Bin 25 -> 0 bytes .../fuzzer/CORPUS_CONNECT/rtcweb-000007 | Bin 17 -> 0 bytes .../fuzzer/CORPUS_CONNECT/rtcweb-000008 | Bin 21 -> 0 bytes .../fuzzer/CORPUS_CONNECT/rtcweb-000009 | Bin 17 -> 0 bytes .../fuzzer/CORPUS_CONNECT/rtcweb-000010 | Bin 33 -> 0 bytes .../fuzzer/CORPUS_CONNECT/rtcweb-000011 | Bin 17 -> 0 bytes .../fuzzer/CORPUS_CONNECT/rtcweb-000012 | Bin 25 -> 0 bytes .../fuzzer/CORPUS_CONNECT/rtcweb-000013 | Bin 17 -> 0 bytes .../fuzzer/CORPUS_CONNECT/rtcweb-000014 | Bin 25 -> 0 bytes .../fuzzer/CORPUS_CONNECT/rtcweb-000015 | Bin 17 -> 0 bytes .../fuzzer/CORPUS_CONNECT/rtcweb-000016 | Bin 25 -> 0 bytes .../fuzzer/CORPUS_CONNECT/rtcweb-000017 | Bin 41 -> 0 bytes .../fuzzer/CORPUS_CONNECT/rtcweb-000018 | Bin 37 -> 0 bytes .../fuzzer/CORPUS_CONNECT/rtcweb-000019 | Bin 17 -> 0 bytes .../fuzzer/CORPUS_CONNECT/rtcweb-000020 | Bin 33 -> 0 bytes .../fuzzer/CORPUS_CONNECT/rtcweb-000021 | Bin 17 -> 0 bytes .../fuzzer/CORPUS_CONNECT/rtcweb-000022 | Bin 25 -> 0 bytes .../fuzzer/CORPUS_CONNECT/rtcweb-000023 | Bin 17 -> 0 bytes .../fuzzer/CORPUS_CONNECT/rtcweb-000024 | Bin 25 -> 0 bytes .../fuzzer/CORPUS_CONNECT/rtcweb-000025 | Bin 17 -> 0 bytes .../fuzzer/CORPUS_CONNECT/rtcweb-000026 | Bin 15 -> 0 bytes .../fuzzer/CORPUS_CONNECT/rtcweb-000027 | Bin 5 -> 0 bytes .../fuzzer/CORPUS_CONNECT/rtcweb-000028 | Bin 15 -> 0 bytes .../fuzzer/CORPUS_CONNECT/shutdown-1.bin | Bin 8 -> 0 bytes .../fuzzer/CORPUS_CONNECT/shutdown-ack-1.bin | Bin 4 -> 0 bytes .../CORPUS_CONNECT/shutdown-complete-1.bin | Bin 4 -> 0 bytes ...t-00b96dd43f1251438bb44daa0a5a24ae4df5bce5 | Bin 995 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000000 | Bin 129 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000001 | Bin 505 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000002 | Bin 385 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000003 | Bin 15 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000004 | Bin 45 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000005 | Bin 45 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000006 | Bin 45 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000007 | Bin 1041 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000008 | Bin 1041 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000009 | Bin 1041 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000010 | Bin 1041 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000011 | Bin 1041 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000012 | Bin 45 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000013 | Bin 17 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000014 | Bin 17 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000015 | Bin 17 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000016 | Bin 17 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000017 | Bin 9 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000018 | Bin 15 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000019 | Bin 5 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000020 | Bin 137 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000021 | Bin 529 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000022 | Bin 401 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000023 | Bin 15 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000024 | Bin 45 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000025 | Bin 45 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000026 | Bin 45 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000027 | Bin 1145 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000028 | Bin 1361 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000029 | Bin 929 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000030 | Bin 45 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000031 | Bin 1361 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000032 | Bin 17 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000033 | Bin 929 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000034 | Bin 17 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000035 | Bin 17 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000036 | Bin 17 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000037 | Bin 9 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000038 | Bin 15 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000039 | Bin 5 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000040 | Bin 137 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000041 | Bin 529 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000042 | Bin 401 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000043 | Bin 15 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000044 | Bin 45 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000045 | Bin 45 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000046 | Bin 45 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000047 | Bin 1205 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000048 | Bin 1381 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000049 | Bin 45 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000050 | Bin 1029 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000051 | Bin 1205 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000052 | Bin 17 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000053 | Bin 1205 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000054 | Bin 17 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000055 | Bin 17 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000056 | Bin 9 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000057 | Bin 15 -> 0 bytes .../fuzzer/CORPUS_CONNECT/tsctp-000058 | Bin 5 -> 0 bytes .../fuzzer/CORPUS_LISTEN/init-1.bin | Bin 108 -> 0 bytes .../usrsctp/usrsctplib/fuzzer/build-fuzzer.sh | 47 - .../usrsctp/usrsctplib/fuzzer/check-input.sh | 56 - .../usrsctp/usrsctplib/fuzzer/crashtest.py | 44 - .../usrsctplib/fuzzer/fuzzer_connect.c | 478 ---- .../usrsctplib/fuzzer/fuzzer_connect_multi.sh | 22 - .../usrsctp/usrsctplib/fuzzer/fuzzer_listen.c | 170 -- .../usrsctplib/fuzzer/fuzzer_listen.sh | 5 - .../usrsctp/usrsctplib/fuzzer/pcap2corpus.c | 247 -- .../usrsctp/usrsctplib/meson.build | 50 +- .../usrsctplib/programs/CMakeLists.txt | 16 +- .../usrsctp/usrsctplib/programs/Makefile.am | 4 - .../usrsctplib/programs/Makefile.nmake | 13 +- .../programs/chargen_server_upcall.c | 12 +- .../usrsctplib/programs/client_upcall.c | 3 +- .../usrsctplib/programs/daytime_server.c | 16 +- .../programs/daytime_server_upcall.c | 14 +- .../usrsctplib/programs/discard_server.c | 12 +- .../programs/discard_server_upcall.c | 10 +- .../usrsctp/usrsctplib/programs/echo_server.c | 12 +- .../usrsctplib/programs/echo_server_upcall.c | 10 +- .../usrsctp/usrsctplib/programs/ekr_client.c | 28 +- .../usrsctp/usrsctplib/programs/ekr_loop.c | 212 +- .../usrsctplib/programs/ekr_loop_offload.c | 557 ---- .../usrsctplib/programs/ekr_loop_upcall.c | 293 ++- .../usrsctp/usrsctplib/programs/ekr_peer.c | 26 +- .../usrsctp/usrsctplib/programs/ekr_server.c | 49 +- .../usrsctp/usrsctplib/programs/http_client.c | 12 +- .../usrsctplib/programs/http_client_upcall.c | 25 +- .../usrsctp/usrsctplib/programs/meson.build | 1 - .../usrsctplib/programs/programs_helper.c | 299 ++- .../usrsctplib/programs/programs_helper.h | 19 +- .../usrsctp/usrsctplib/programs/rtcweb.c | 19 +- .../usrsctp/usrsctplib/programs/st_client.c | 70 +- .../usrsctp/usrsctplib/programs/tsctp.c | 229 +- .../usrsctplib/programs/tsctp_upcall.c | 38 +- .../usrsctp/usrsctplib/usrsctp.pc.in | 1 + .../usrsctplib/usrsctplib/CMakeLists.txt | 102 +- .../usrsctp/usrsctplib/usrsctplib/Makefile.am | 2 +- .../usrsctplib/usrsctplib/Makefile.nmake | 2 +- .../usrsctplib/usrsctplib/netinet/sctp.h | 22 +- .../usrsctplib/netinet/sctp_asconf.c | 283 +- .../usrsctplib/netinet/sctp_asconf.h | 12 +- .../usrsctplib/usrsctplib/netinet/sctp_auth.c | 35 +- .../usrsctplib/usrsctplib/netinet/sctp_auth.h | 7 +- .../usrsctplib/netinet/sctp_bsd_addr.c | 92 +- .../usrsctplib/netinet/sctp_bsd_addr.h | 9 +- .../usrsctplib/netinet/sctp_callout.c | 36 +- .../usrsctplib/netinet/sctp_callout.h | 18 +- .../usrsctplib/netinet/sctp_cc_functions.c | 209 +- .../usrsctplib/netinet/sctp_constants.h | 88 +- .../usrsctplib/netinet/sctp_crc32.c | 27 +- .../usrsctplib/netinet/sctp_crc32.h | 8 +- .../usrsctplib/netinet/sctp_header.h | 76 +- .../usrsctplib/netinet/sctp_indata.c | 509 ++-- .../usrsctplib/netinet/sctp_indata.h | 30 +- .../usrsctplib/netinet/sctp_input.c | 1587 ++++++------ .../usrsctplib/netinet/sctp_input.h | 12 +- .../usrsctplib/netinet/sctp_lock_userspace.h | 24 +- .../usrsctplib/usrsctplib/netinet/sctp_os.h | 17 +- .../usrsctplib/netinet/sctp_os_userspace.h | 172 +- .../usrsctplib/netinet/sctp_output.c | 1337 +++++----- .../usrsctplib/netinet/sctp_output.h | 115 +- .../usrsctplib/usrsctplib/netinet/sctp_pcb.c | 1398 +++++----- .../usrsctplib/usrsctplib/netinet/sctp_pcb.h | 194 +- .../usrsctplib/netinet/sctp_peeloff.c | 44 +- .../usrsctplib/netinet/sctp_peeloff.h | 6 +- .../usrsctplib/netinet/sctp_process_lock.h | 206 +- .../usrsctplib/usrsctplib/netinet/sctp_sha1.c | 22 +- .../usrsctplib/usrsctplib/netinet/sctp_sha1.h | 17 +- .../usrsctplib/netinet/sctp_ss_functions.c | 513 ++-- .../usrsctplib/netinet/sctp_structs.h | 132 +- .../usrsctplib/netinet/sctp_sysctl.c | 203 +- .../usrsctplib/netinet/sctp_sysctl.h | 33 +- .../usrsctplib/netinet/sctp_timer.c | 228 +- .../usrsctplib/netinet/sctp_timer.h | 22 +- .../usrsctplib/usrsctplib/netinet/sctp_uio.h | 160 +- .../usrsctplib/netinet/sctp_userspace.c | 164 +- .../usrsctplib/netinet/sctp_usrreq.c | 1405 +++++----- .../usrsctplib/usrsctplib/netinet/sctp_var.h | 112 +- .../usrsctplib/usrsctplib/netinet/sctputil.c | 2292 ++++++++++------- .../usrsctplib/usrsctplib/netinet/sctputil.h | 91 +- .../usrsctplib/netinet6/sctp6_usrreq.c | 412 ++- .../usrsctplib/netinet6/sctp6_var.h | 22 +- .../usrsctplib/usrsctplib/user_atomic.h | 8 +- .../usrsctplib/usrsctplib/user_environment.c | 343 ++- .../usrsctplib/usrsctplib/user_environment.h | 20 +- .../usrsctplib/usrsctplib/user_inpcb.h | 18 +- .../usrsctplib/usrsctplib/user_ip6_var.h | 22 +- .../usrsctplib/usrsctplib/user_ip_icmp.h | 24 +- .../usrsctplib/usrsctplib/user_malloc.h | 67 +- .../usrsctp/usrsctplib/usrsctplib/user_mbuf.c | 54 +- .../usrsctp/usrsctplib/usrsctplib/user_mbuf.h | 61 +- .../usrsctplib/usrsctplib/user_queue.h | 6 +- .../usrsctplib/usrsctplib/user_recv_thread.c | 242 +- .../usrsctplib/usrsctplib/user_route.h | 2 +- .../usrsctplib/usrsctplib/user_socket.c | 455 +--- .../usrsctplib/usrsctplib/user_socketvar.h | 361 +-- .../usrsctp/usrsctplib/usrsctplib/user_uma.h | 4 +- .../usrsctp/usrsctplib/usrsctplib/usrsctp.h | 36 +- third-party/webrtc/webrtc | 2 +- 226 files changed, 7846 insertions(+), 9779 deletions(-) create mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/cmake/FindMbedTLS.cmake delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CMakeLists.txt delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5204536192401408 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5634380847906816 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5645105154752512 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5649242005176320 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5649768725872640 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5676652788449280 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5688015225094144 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5722044720742400 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5734997805236224 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5736809862004736 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5741506257747968 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5759310927233024 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_unconnected-5767885871382528 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5631709814456320 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5638658568224768 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5675883720867840 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5764087333519360 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_unconnected-5639391992610816 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/crash-0a63175dc6b51474dc08197431ec36d11db5e77b delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/crash-27ffd53d682a7908bf7569e32d904f049066b5d6 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/data-1.bin delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/init-ack-1.bin delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/leak-00bd871f5ce0596083fe8642c803c97f424b0c70 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000000 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000001 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000002 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000003 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000004 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000005 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000006 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000007 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000008 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000009 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000010 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000011 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000012 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000013 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000014 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000015 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000016 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000017 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000018 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000019 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000020 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000021 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000022 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000023 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000024 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000025 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000026 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000027 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000028 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/shutdown-1.bin delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/shutdown-ack-1.bin delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/shutdown-complete-1.bin delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/timeout-00b96dd43f1251438bb44daa0a5a24ae4df5bce5 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000000 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000001 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000002 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000003 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000004 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000005 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000006 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000007 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000008 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000009 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000010 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000011 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000012 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000013 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000014 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000015 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000016 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000017 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000018 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000019 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000020 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000021 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000022 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000023 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000024 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000025 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000026 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000027 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000028 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000029 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000030 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000031 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000032 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000033 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000034 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000035 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000036 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000037 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000038 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000039 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000040 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000041 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000042 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000043 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000044 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000045 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000046 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000047 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000048 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000049 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000050 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000051 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000052 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000053 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000054 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000055 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000056 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000057 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000058 delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_LISTEN/init-1.bin delete mode 100755 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/build-fuzzer.sh delete mode 100755 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/check-input.sh delete mode 100755 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/crashtest.py delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/fuzzer_connect.c delete mode 100755 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/fuzzer_connect_multi.sh delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/fuzzer_listen.c delete mode 100755 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/fuzzer_listen.sh delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/pcap2corpus.c delete mode 100644 third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/ekr_loop_offload.c diff --git a/submodules/TgVoipWebrtc/BUILD b/submodules/TgVoipWebrtc/BUILD index f506c64290..108b937aca 100644 --- a/submodules/TgVoipWebrtc/BUILD +++ b/submodules/TgVoipWebrtc/BUILD @@ -55,6 +55,7 @@ objc_library( "-DRTC_ENABLE_VP9", "-DTGVOIP_NAMESPACE=tgvoip_webrtc", "-std=c++14", + "-DWEBRTC_DISABLE_H265", ], includes = [ "PublicHeaders", diff --git a/submodules/TgVoipWebrtc/tgcalls b/submodules/TgVoipWebrtc/tgcalls index 4885177034..731818cea9 160000 --- a/submodules/TgVoipWebrtc/tgcalls +++ b/submodules/TgVoipWebrtc/tgcalls @@ -1 +1 @@ -Subproject commit 48851770349761f89c969e1c9cde34b7fae5cf67 +Subproject commit 731818cea9bce6eb7f4ee36f28d62f2ee03bd2b7 diff --git a/third-party/webrtc/BUILD b/third-party/webrtc/BUILD index acb81a0030..cf693a3b29 100644 --- a/third-party/webrtc/BUILD +++ b/third-party/webrtc/BUILD @@ -10,9 +10,9 @@ config_setting( optimization_flags = select({ ":debug_build": [ - #"-O2", + "-O2", #"-DNDEBUG", - "-DRTC_DCHECK_IS_ON", + #"-DRTC_DCHECK_IS_ON", ], "//conditions:default": ["-DNDEBUG"], }) @@ -749,7 +749,6 @@ webrtc_sources = [ "pc/webrtc_session_description_factory.cc", "media/base/adapted_video_track_source.cc", "media/base/codec.cc", - "media/base/h264_profile_level_id.cc", "media/base/media_channel.cc", "media/base/media_constants.cc", "media/base/media_engine.cc", @@ -1072,23 +1071,18 @@ webrtc_sources = [ "modules/audio_processing/agc/legacy/digital_agc.cc", "modules/audio_processing/agc/loudness_histogram.cc", "modules/audio_processing/agc/utility.cc", - "modules/audio_processing/agc2/adaptive_agc.cc", "modules/audio_processing/agc2/adaptive_digital_gain_applier.cc", "modules/audio_processing/agc2/adaptive_mode_level_estimator.cc", "modules/audio_processing/agc2/agc2_testing_common.cc", "modules/audio_processing/agc2/biquad_filter.cc", "modules/audio_processing/agc2/compute_interpolated_gain_curve.cc", - "modules/audio_processing/agc2/down_sampler.cc", "modules/audio_processing/agc2/fixed_digital_level_estimator.cc", "modules/audio_processing/agc2/gain_applier.cc", "modules/audio_processing/agc2/interpolated_gain_curve.cc", "modules/audio_processing/agc2/limiter.cc", "modules/audio_processing/agc2/limiter_db_gain_curve.cc", "modules/audio_processing/agc2/noise_level_estimator.cc", - "modules/audio_processing/agc2/noise_spectrum_estimator.cc", "modules/audio_processing/agc2/saturation_protector.cc", - "modules/audio_processing/agc2/signal_classifier.cc", - "modules/audio_processing/agc2/vad_with_level.cc", "modules/audio_processing/agc2/vector_float_frame.cc", "modules/audio_processing/agc2/rnn_vad/auto_correlation.cc", "modules/audio_processing/agc2/rnn_vad/features_extraction.cc", @@ -1115,8 +1109,6 @@ webrtc_sources = [ "modules/audio_processing/include/audio_frame_proxies.cc", "modules/audio_processing/include/audio_processing.cc", "modules/audio_processing/include/audio_processing_statistics.cc", - "modules/audio_processing/include/config.cc", - "modules/audio_processing/level_estimator.cc", "modules/audio_processing/logging/apm_data_dumper.cc", "modules/audio_processing/ns/fast_math.cc", "modules/audio_processing/ns/histograms.cc", @@ -1322,7 +1314,6 @@ webrtc_sources = [ "modules/video_coding/unique_timestamp_counter.cc", "modules/video_coding/utility/decoded_frames_history.cc", "modules/video_coding/utility/frame_dropper.cc", - "modules/video_coding/utility/framerate_controller.cc", "modules/video_coding/utility/ivf_file_reader.cc", "modules/video_coding/utility/ivf_file_writer.cc", "modules/video_coding/utility/quality_scaler.cc", @@ -1780,7 +1771,6 @@ webrtc_sources = [ "logging/rtc_event_log/rtc_event_log_impl.h", "logging/rtc_event_log/rtc_stream_config.h", "media/base/codec.h", - "media/base/h264_profile_level_id.h", "media/base/media_channel.h", "media/base/media_constants.h", "media/base/media_engine.h", @@ -1792,7 +1782,6 @@ webrtc_sources = [ "media/base/video_broadcaster.h", "media/base/video_common.h", "media/base/video_source_base.h", - "media/base/vp9_profile.h", "media/engine/adm_helpers.h", "media/engine/encoder_simulcast_proxy.h", "media/engine/internal_decoder_factory.h", @@ -1997,21 +1986,18 @@ webrtc_sources = [ "modules/audio_processing/agc/legacy/digital_agc.h", "modules/audio_processing/agc/loudness_histogram.h", "modules/audio_processing/agc/utility.h", - "modules/audio_processing/agc2/adaptive_agc.h", "modules/audio_processing/agc2/adaptive_digital_gain_applier.h", "modules/audio_processing/agc2/adaptive_mode_level_estimator.h", "modules/audio_processing/agc2/agc2_common.h", "modules/audio_processing/agc2/agc2_testing_common.h", "modules/audio_processing/agc2/biquad_filter.h", "modules/audio_processing/agc2/compute_interpolated_gain_curve.h", - "modules/audio_processing/agc2/down_sampler.h", "modules/audio_processing/agc2/fixed_digital_level_estimator.h", "modules/audio_processing/agc2/gain_applier.h", "modules/audio_processing/agc2/interpolated_gain_curve.h", "modules/audio_processing/agc2/limiter.h", "modules/audio_processing/agc2/limiter_db_gain_curve.h", "modules/audio_processing/agc2/noise_level_estimator.h", - "modules/audio_processing/agc2/noise_spectrum_estimator.h", "modules/audio_processing/agc2/rnn_vad/auto_correlation.h", "modules/audio_processing/agc2/rnn_vad/common.h", "modules/audio_processing/agc2/rnn_vad/features_extraction.h", @@ -2022,8 +2008,6 @@ webrtc_sources = [ "modules/audio_processing/agc2/rnn_vad/spectral_features.h", "modules/audio_processing/agc2/rnn_vad/spectral_features_internal.h", "modules/audio_processing/agc2/saturation_protector.h", - "modules/audio_processing/agc2/signal_classifier.h", - "modules/audio_processing/agc2/vad_with_level.h", "modules/audio_processing/agc2/vector_float_frame.h", "modules/audio_processing/audio_buffer.h", "modules/audio_processing/audio_processing_impl.h", @@ -2039,8 +2023,6 @@ webrtc_sources = [ "modules/audio_processing/include/audio_frame_proxies.h", "modules/audio_processing/include/audio_processing.h", "modules/audio_processing/include/audio_processing_statistics.h", - "modules/audio_processing/include/config.h", - "modules/audio_processing/level_estimator.h", "modules/audio_processing/logging/apm_data_dumper.h", "modules/audio_processing/ns/fast_math.h", "modules/audio_processing/ns/histograms.h", @@ -2265,7 +2247,6 @@ webrtc_sources = [ "modules/video_coding/unique_timestamp_counter.h", "modules/video_coding/utility/decoded_frames_history.h", "modules/video_coding/utility/frame_dropper.h", - "modules/video_coding/utility/framerate_controller.h", "modules/video_coding/utility/ivf_file_reader.h", "modules/video_coding/utility/ivf_file_writer.h", "modules/video_coding/utility/quality_scaler.h", @@ -2926,27 +2907,23 @@ webrtc_sources = [ "modules/audio_processing/agc/clipping_predictor_evaluator.cc", "modules/audio_processing/agc/clipping_predictor_level_buffer.h", "modules/audio_processing/agc/clipping_predictor_level_buffer.cc", - "modules/rtp_rtcp/source/rtp_format_h265.cc", - "modules/rtp_rtcp/source/video_rtp_depacketizer_h265.cc", - "modules/video_coding/h265_vps_sps_pps_tracker.cc", - "common_video/h265/h265_bitstream_parser.cc", - "common_video/h265/h265_common.cc", - "common_video/h265/h265_pps_parser.cc", - "common_video/h265/h265_sps_parser.cc", - "common_video/h265/h265_vps_parser.cc", - "common_video/h265/h265_bitstream_parser.h", - "common_video/h265/h265_common.h", - "common_video/h265/h265_pps_parser.h", - "modules/rtp_rtcp/source/video_rtp_depacketizer_h265.h", - "modules/video_coding/h265_vps_sps_pps_tracker.h", - "common_video/h265/h265_sps_parser.h", - "common_video/h265/h265_vps_parser.h", - "modules/rtp_rtcp/source/rtp_format_h265.h", - "modules/video_coding/codecs/h265/include/h265_globals.h", "media/sctp/sctp_transport_factory.h", "media/sctp/sctp_transport_factory.cc", "media/sctp/usrsctp_transport.h", "media/sctp/usrsctp_transport.cc", + "rtc_base/bitstream_reader.cc", + "modules/audio_coding/neteq/reorder_optimizer.cc", + "modules/audio_coding/neteq/underrun_optimizer.cc", + "common_video/framerate_controller.cc", + "modules/audio_processing/agc/analog_gain_stats_reporter.cc", + "modules/audio_coding/neteq/relative_arrival_delay_tracker.cc", + "modules/audio_processing/agc2/vad_wrapper.cc", + "modules/audio_processing/agc2/adaptive_digital_gain_controller.cc", + "modules/video_coding/utility/framerate_controller_deprecated.cc", + "video/adaptation/bandwidth_quality_scaler_resource.cc", + "api/wrapping_async_dns_resolver.cc", + "modules/video_coding/utility/bandwidth_quality_scaler.cc", + "rtc_base/experiments/bandwidth_quality_scaler_settings.cc", ] ios_objc_sources = [ @@ -2972,15 +2949,6 @@ ios_objc_sources = [ "objc/components/video_codec/RTCVideoEncoderFactoryH264.m", "objc/components/video_codec/RTCVideoDecoderFactoryH264.h", "objc/components/video_codec/RTCVideoDecoderFactoryH264.m", - "objc/components/video_codec/RTCCodecSpecificInfoH265.h", - "objc/components/video_codec/RTCCodecSpecificInfoH265.mm", - "objc/components/video_codec/RTCH265ProfileLevelId.h", - "objc/components/video_codec/RTCH265ProfileLevelId.mm", - "objc/components/video_codec/RTCVideoDecoderH265.h", - "objc/components/video_codec/RTCVideoDecoderH265.mm", - "objc/components/video_codec/RTCVideoEncoderH265.h", - "objc/components/video_codec/RTCVideoEncoderH265.mm", - "objc/components/video_codec/RTCCodecSpecificInfoH265+Private.h", ] ios_sources = [ @@ -3290,6 +3258,9 @@ common_flags = [ "-DWEBRTC_ENABLE_PROTOBUF=0", "-DWEBRTC_ENABLE_AVX2", "-DWEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=0", + "-Wno-shorten-64-to-32", + "-Wno-macro-redefined", + "-D__APPLE__", ] arm_specific_flags = [ diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/CMakeLists.txt b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/CMakeLists.txt index ba3b594eef..3fc4ec6ac2 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/CMakeLists.txt +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/CMakeLists.txt @@ -38,6 +38,8 @@ if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "DEBUG") endif () +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) + include(CheckStructHasMember) include(CheckIncludeFile) include(CheckIncludeFiles) @@ -69,7 +71,7 @@ endif () option(sctp_werror "Treat warning as error" 1) -option(sctp_link_programs_static "Link example programs static" 0) +option(sctp_build_shared_lib "Build USRSCTP as shared library" 0) option(sctp_build_programs "Build example programs" 1) @@ -83,12 +85,6 @@ if (sctp_sanitizer_address AND sctp_sanitizer_memory) message(FATAL_ERROR "Can not compile with both sanitizer options") endif () -if (sctp_link_programs_static OR WIN32) - set(programs_link_library "usrsctp-static") -else () - set(programs_link_library "usrsctp") -endif () - ################################################# # CHECK FOR TYPES AND FUNCTIONS @@ -114,6 +110,11 @@ if (have_netinet_ip_icmp_h) add_definitions(-DHAVE_NETINET_IP_ICMP_H) endif () +check_include_files("sys/types.h;sys/socket.h;net/route.h" have_net_route_h) +if (have_net_route_h) + add_definitions(-DHAVE_NET_ROUTE_H) +endif () + check_include_files("stdatomic.h" have_stdatomic_h) if (have_stdatomic_h) add_definitions(-DHAVE_STDATOMIC_H) @@ -259,6 +260,7 @@ elseif (CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID MATCHES "Appl endif () if (sctp_build_fuzzer) + set(CMAKE_BUILD_TYPE "RelWithDebInfo") add_definitions(-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=fuzzer-no-link") endif () diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/Manual.md b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/Manual.md index e52fad748a..12dcf73352 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/Manual.md +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/Manual.md @@ -7,7 +7,7 @@ Like TCP, SCTP provides reliable, connection oriented data delivery with congest In this manual the socket API for the SCTP User-land implementation will be described. It is based on [RFC 6458](https://tools.ietf.org/html/rfc6458). The main focus of this document is on pointing out the differences to the SCTP Sockets API. For all aspects of the sockets API that are not mentioned in this document, please refer to [RFC 6458](https://tools.ietf.org/html/rfc6458). Questions about SCTP itself can hopefully be answered by [RFC 4960](https://tools.ietf.org/html/rfc4960). ## Getting Started -The user-land stack has been tested on FreeBSD 10.0, Ubuntu 11.10, Windows 7, Mac OS X 10.6, and Mac OS X 10.7. The current version of the user-land stack is provided on [github](https://github.com/sctplab/usrsctp). Download the tarball and untar it in a folder of your choice. The tarball contains all the sources to build the libusrsctp, which has to be linked to the object file of an example program. In addition there are two applications in the folder `programs` that can be built and run. +The user-land stack has been tested on FreeBSD 10.0, OpenBSD 7.0, Ubuntu 11.10, Windows 7, Mac OS X 10.6, and Mac OS X 10.7. The current version of the user-land stack is provided on [github](https://github.com/sctplab/usrsctp). Download the tarball and untar it in a folder of your choice. The tarball contains all the sources to build the libusrsctp, which has to be linked to the object file of an example program. In addition there are two applications in the folder `programs` that can be built and run. ### Building the Library and the Applications #### Unix-like Operating Systems @@ -128,7 +128,8 @@ usrsctp_socket(int domain, int flags, void *ulp_info), int (*send_cb)(struct socket *sock, - uint32_t sb_free), + uint32_t sb_free, + void *ulp_info), uint32_t sb_threshold, void *ulp_info) ``` @@ -363,7 +364,7 @@ SCTP_RECVRCVINFO | int | r/w SCTP_RECVNXTINFO | int | r/w SCTP_DEFAULT_SNDINFO | struct sctp_sndinfo | r/w SCTP_DEFAULT_PRINFO | struct sctp_default_prinfo | r/w -SCTP_REMOTE_UDP_ENCAPS_PORT | int | r/w +SCTP_REMOTE_UDP_ENCAPS_PORT | struct sctp_udpencaps | r/w SCTP_ENABLE_STREAM_RESET | struct sctp_assoc_value | r/w SCTP_STATUS | struct sctp_status | r SCTP_GET_PEER_ADDR_INFO | struct sctp_paddrinfo | r diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/Manual.tex b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/Manual.tex index 7ec1e1f53b..32711ee974 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/Manual.tex +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/Manual.tex @@ -205,7 +205,8 @@ usrsctp_socket(int domain, int flags, void *ulp_info), int (*send_cb)(struct socket *sock, - uint32_t sb_free), + uint32_t sb_free, + void *ulp_info), uint32_t sb_threshold, void *ulp_info). \end{verbatim} @@ -970,7 +971,7 @@ SCTP\_DEBUG has to be set as a compile flag. #include #include #include -#if !defined(__Userspace_os_Windows) +#if !defined(_WIN32) #include #include #include @@ -1098,7 +1099,7 @@ main(int argc, char *argv[]) } while (1) { if (use_cb) { -#if defined (__Userspace_os_Windows) +#if defined(_WIN32) Sleep(1*1000); #else sleep(1); @@ -1133,7 +1134,7 @@ main(int argc, char *argv[]) } usrsctp_close(sock); while (usrsctp_finish() != 0) { -#if defined (__Userspace_os_Windows) +#if defined(_WIN32) Sleep(1000); #else sleep(1); @@ -1183,11 +1184,11 @@ main(int argc, char *argv[]) #include #include #include -#if !defined(__Userspace_os_Windows) +#if !defined(_WIN32) #include #endif #include -#if !defined(__Userspace_os_Windows) +#if !defined(_WIN32) #include #include #include @@ -1242,7 +1243,7 @@ main(int argc, char *argv[]) } memset((void *)&addr4, 0, sizeof(struct sockaddr_in)); memset((void *)&addr6, 0, sizeof(struct sockaddr_in6)); -#if !defined(__Userspace_os_Linux) && !defined(__Userspace_os_Windows) +#if !defined(__linux__) && !defined(_WIN32) addr4.sin_len = sizeof(struct sockaddr_in); addr6.sin6_len = sizeof(struct sockaddr_in6); #endif @@ -1271,14 +1272,14 @@ main(int argc, char *argv[]) usrsctp_shutdown(sock, SHUT_WR); } while (!done) { -#if defined (__Userspace_os_Windows) +#if defined(_WIN32) Sleep(1*1000); #else sleep(1); #endif } while (usrsctp_finish() != 0) { -#if defined (__Userspace_os_Windows) +#if defined(_WIN32) Sleep(1000); #else sleep(1); diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/README.md b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/README.md index 1eea55eb25..3d5ba38f35 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/README.md +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/README.md @@ -1,7 +1,9 @@ # usrsctp [![Coverity Scan Build Status](https://scan.coverity.com/projects/13430/badge.svg)](https://scan.coverity.com/projects/usrsctp) -This is a userland SCTP stack supporting FreeBSD, Linux, Mac OS X and Windows. +![GitHub Actions Build Status (CMake-based build only)](https://github.com/sctplab/usrsctp/workflows/Build%20with%20CMake/badge.svg) + +This is a userland SCTP stack supporting FreeBSD, OpenBSD, Linux, Mac OS X and Windows. See [manual](Manual.md) for more information. diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/cmake/FindMbedTLS.cmake b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/cmake/FindMbedTLS.cmake new file mode 100644 index 0000000000..b3ed046b69 --- /dev/null +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/cmake/FindMbedTLS.cmake @@ -0,0 +1,38 @@ +find_path(MBEDTLS_INCLUDE_DIRS mbedtls/ssl.h) + +find_library(MBEDTLS_LIBRARY mbedtls) +find_library(MBEDX509_LIBRARY mbedx509) +find_library(MBEDCRYPTO_LIBRARY mbedcrypto) + +set(MBEDTLS_LIBRARIES "${MBEDTLS_LIBRARY}" "${MBEDX509_LIBRARY}" "${MBEDCRYPTO_LIBRARY}") + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(MbedTLS DEFAULT_MSG + MBEDTLS_LIBRARY MBEDTLS_INCLUDE_DIRS MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY) + +mark_as_advanced(MBEDTLS_INCLUDE_DIRS MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY) + +if(NOT TARGET MbedTLS) + message("in mbedtls ${MBEDTLS_LIBRARY}") + add_library(MbedTLS UNKNOWN IMPORTED) + set_target_properties(MbedTLS PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${MBEDTLS_INCLUDE_DIRS}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${MBEDTLS_LIBRARY}") +endif() + +if(NOT TARGET MbedCrypto) + add_library(MbedCrypto UNKNOWN IMPORTED) + set_target_properties(MbedCrypto PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${MBEDTLS_INCLUDE_DIRS}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${MBEDCRYPTO_LIBRARY}") +endif() + +if(NOT TARGET MbedX509) + add_library(MbedX509 UNKNOWN IMPORTED) + set_target_properties(MbedX509 PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${MBEDTLS_INCLUDE_DIRS}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${MBEDX509_LIBRARY}") +endif() diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/configure.ac b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/configure.ac index e24c37cb74..cdcd483571 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/configure.ac +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/configure.ac @@ -28,7 +28,7 @@ dnl OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF dnl SUCH DAMAGE. dnl -AC_INIT([libusrsctp], [0.9.3.0]) +AC_INIT([libusrsctp], [0.9.5.0]) AM_INIT_AUTOMAKE([foreign]) AC_PROG_CC @@ -46,11 +46,9 @@ APPCFLAGS="" case $host_os in darwin*) CFLAGS="$CFLAGS -std=c99 -Wno-deprecated-declarations -D__APPLE_USE_RFC_2292" - LIBCFLAGS="$LIBCFLAGS -U__APPLE__ -D__Userspace_os_Darwin" ;; dragonfly*) CFLAGS="$CFLAGS -std=c99 -pthread" - LIBCFLAGS="$LIBCFLAGS -U__DragonFly__ -D__Userspace_os_DragonFly" ;; freebsd*) CFLAGS="$CFLAGS -std=c99 -pthread" @@ -58,19 +56,15 @@ freebsd*) CFLAGS="$CFLAGS -Wno-unknown-warning-option" LDFLAGS="$LDFLAGS -Qunused-arguments" fi - LIBCFLAGS="$LIBCFLAGS -U__FreeBSD__ -D__Userspace_os_FreeBSD" ;; linux*) CFLAGS="$CFLAGS -std=c99 -pthread -D_GNU_SOURCE -Wno-address-of-packed-member" - LIBCFLAGS="$LIBCFLAGS -D__Userspace_os_Linux" ;; netbsd*) CFLAGS="$CFLAGS -std=c99 -pthread" - LIBCFLAGS="$LIBCFLAGS -U__NetBSD__ -D__Userspace_os_NetBSD" ;; openbsd*) CFLAGS="$CFLAGS -std=c99 -pthread" - LIBCFLAGS="$LIBCFLAGS -U__OpenBSD__ -D__Userspace_os_OpenBSD" ;; solaris*) CFLAGS="$CFLAGS -D_XPG4_2" @@ -149,6 +143,12 @@ AC_CHECK_HEADERS(sys/queue.h) AC_CHECK_HEADERS(linux/if_addr.h, [], [], [#include ]) AC_CHECK_HEADERS(linux/rtnetlink.h, [], [], [#include ]) AC_CHECK_HEADERS(netinet/ip_icmp.h, [], [], [#include ]) +AC_CHECK_HEADERS(net/route.h, [], [], + [#ifdef HAVE_SYS_TYPES_H + #include + #endif + #include ]) + AC_CHECK_MEMBER(struct sockaddr.sa_len, AC_DEFINE(HAVE_SA_LEN, 1, [Define this if your stack has sa_len in sockaddr struct.]),, diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CMakeLists.txt b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CMakeLists.txt deleted file mode 100644 index d60eb5dc87..0000000000 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CMakeLists.txt +++ /dev/null @@ -1,108 +0,0 @@ -# -# Copyright (C) 2015-2019 Felix Weinrank -# -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. Neither the name of the project nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# - -#project(usrsctp-fuzzer C) - -################################################# -# INCLUDE MODULES -################################################# - -include(CheckIncludeFile) - - -################################################# -# CHECK INCLUDES -################################################# - -include_directories(${CMAKE_SOURCE_DIR}/usrsctplib) - - -################################################# -# OS DEPENDENT -################################################# - -if (CMAKE_SYSTEM_NAME MATCHES "Linux") - add_definitions(-D_GNU_SOURCE) -endif () - -if (CMAKE_SYSTEM_NAME MATCHES "Darwin") - add_definitions(-D__APPLE_USE_RFC_2292) -endif () - -################################################# -# COMPILER FLAGS -################################################# - -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-gnu-zero-variadic-macro-arguments -Wno-unused-variable") -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=fuzzer") - - -################################################# -# PROGRAMS -################################################# - -# FUZZING_STAGE LEVELS -# 0 - MULTI - based on input -# 1 - COOKIE_WAIT -# 2 - COOKIE_ECHO -# 3 - ESTABLISHED -# 4 - DATA SENT -# 5 - DATA RECEIVED - -add_executable(fuzzer_listen fuzzer_listen.c ../programs/programs_helper.c) -target_link_libraries(fuzzer_listen usrsctp-static) - -add_executable(fuzzer_connect_multi fuzzer_connect.c ../programs/programs_helper.c) -target_compile_definitions(fuzzer_connect_multi PRIVATE FUZZING_STAGE=0) -target_link_libraries(fuzzer_connect_multi usrsctp-static) - -add_executable(fuzzer_connect_multi_verbose fuzzer_connect.c ../programs/programs_helper.c) -target_compile_definitions(fuzzer_connect_multi_verbose PRIVATE FUZZING_STAGE=0 FUZZ_VERBOSE) -target_link_libraries(fuzzer_connect_multi_verbose usrsctp-static) - -# add_executable(fuzzer_connect_cookie_wait fuzzer_connect.c) -# target_compile_definitions(fuzzer_connect_cookie_wait PRIVATE FUZZING_STAGE=1) -# target_link_libraries(fuzzer_connect_cookie_wait usrsctp-static) - -# add_executable(fuzzer_connect_cookie_echoed fuzzer_connect.c) -# target_compile_definitions(fuzzer_connect_cookie_echoed PRIVATE FUZZING_STAGE=2) -# target_link_libraries(fuzzer_connect_cookie_echoed usrsctp-static) - -# add_executable(fuzzer_connect_established fuzzer_connect.c) -# target_compile_definitions(fuzzer_connect_established PRIVATE FUZZING_STAGE=3) -# target_link_libraries(fuzzer_connect_established usrsctp-static) - -# add_executable(fuzzer_connect_data_sent fuzzer_connect.c) -# target_compile_definitions(fuzzer_connect_data_sent PRIVATE FUZZING_STAGE=4) -# target_link_libraries(fuzzer_connect_data_sent usrsctp-static) - -# add_executable(fuzzer_connect_data_received fuzzer_connect.c) -# target_compile_definitions(fuzzer_connect_data_received PRIVATE FUZZING_STAGE=5) -# target_link_libraries(fuzzer_connect_data_received usrsctp-static) diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5204536192401408 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5204536192401408 deleted file mode 100644 index d2ceb962fa2f082b5683951c70e37c969c71a062..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5728 zcmeHL&1(}u6#s2!2&-#p&?soBjTEuHD6}Yrp8N~+u6q^#0TC56htg|^ww{Wo;I;JV zO|PDE@T{Kn(1LiW4OpM=&CWLanWT+LiR{4Uy`7nzyszJTZ+B+u59R?l_y!QsUh{1e z(_gM{f4n<8cViCaiQg}HdSmOu*)mjPecGwwG#cwGl}GO#xNlaRC?&LL9wk(E$l*i% z`lU}q%$TDm4b$yM2a7c(EK|+M1ef+$v;`xY7aRs<#&@Nv)m@r;W*%GO*$cwy18CjE z!!|Kpg)8!tVxE_t=;pzlHs9BH!IRBQ&jr+M){)J8i2IYo9<7u;e)M4vjfg$09Ynxj z_#5qV$O{#5M1(6z5kft1<~%T|y)~HYtEJjfZ|$?vHBl&2kv24G4?3h`4b3hz9yF3B z?QrqPqj!8;vyQca}3D(Iqa}T^zEhxS&4b;&H^)$Bc_KPLgpUE>7ZP zA}cNyQmWgDcwF#dV*^yl6Fv0LQ#zdAVIKv2pZ2jh7wG2TMpG$;9EJkV^+1k6OypdB zm4)N~Th$pUWM)`-HMB=)p>8yWo7>mwzS$hht2y|ID@5~+8gM2Xxc zwJ2laL_1>XyRR}P5Bl}Wex!^g+>mSe?AL?wFJpu0UzD-d$-N$#*S(@`jeZUocH1`o lcpt27FYx})@m{p8_H#hdwwk`?e{5S#^TeIG{k*yf`~^~ml>ZwRv=VKW8`ri&HCV21E;SO66M&j51egb9jZ5|wCxXhyPM8Y%+xK13U; z1~3m8F#oX#BMUj<1#p#M%b?*e3l4u{xcv=afA2&0y#QSEgbAKdfFy*>WMFs*bSW@& O(UU7qzS4gNpd0{%Gl2;J diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5645105154752512 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5645105154752512 deleted file mode 100644 index 0428a9dc927f5be621a4deb1f164759f6179b075..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 92 zcmey*|Bpd~fq{XMA+CqZfq_9J*1FZu;69(BVSv1${`FV}29^c}AmBeJ#9+)kaf&pf l0s|Mr#3|N{hYm0@NP(n)fMec){}&io88|pUeN*`c0|52N98drN diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5649242005176320 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5649242005176320 deleted file mode 100644 index c6491cca31258199d68f33da62d96b4c5f245131..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 85 zcmZSJ|HPodz`(%B@Qi`s_mlq|K_Suq4es;l8U)B2>T5FyF#M_i|NsBg_XmX-6qqMY ik!Dn2;DQJoU}WH!cj3PV0~><~&;$m9`#{AY1_J;C&>XD* diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5649768725872640 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5649768725872640 deleted file mode 100644 index 882b8a066e9ed047ec658b85cdaeb3614d88ff6c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 62779 zcmeI*&1%#@902ftKd@W7;<8eTRI#=fy(oAU55?k9e1U=|5BdlqLa{dw3Kax<5sFv! z1*$?%g0G<9LGa+Ef?m3=lkAFCx6qdDy2<_qLX+%dG9SMro5^fb8IKq>sRITWV1NMz z7+`<_1{h#~0R~EA;QHc|#YmwD_xty_D?~dL!IC@{;iy9z z#-bXtRK77w+uL-ZgZr|VS^2gbP#@}pfub8Q7M0nBlRF@1ezyJdbFu(u< z3^2d|0}L?000Rs#zyJdbFu(u<3@}h|0~0f?@d?@AeEw#>T#XkodUh(_rDyT^{P@)G zc-iy$zvE`{+i~*vX?g3*pWE!5?#ZJ+;!H#g#ixj7v-xf9*;-70IQR1HwNrEF=b|>e zbvLbk^!#pm{M>3as@WZMnxCz%Ms+jmGD_ilGqTTT@2^IswLV{d zvl&qtPTeZ0Unl?k-|a8v>p!Nnc1rivMxJikS3Av0RI)y(_Hx(rl=9J7U%&MJ>(i`! zt$cSZ>ki#TS-)H7zPDE2+;$){DRwrcI?AW^{N+5vSS&5Z@uTbfs(kTC)bq}{8_S<>U%i#yi%^UDP&CrVhnF5it(k4x?Xc2Lu-?29l^BWUuTsS1 F*iTuOruYB= diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5676652788449280 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5676652788449280 deleted file mode 100644 index fc85d8b818ae3c800f0b8f1ac0ac4800823d69ee..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 255 zcmZqR|Hq)gz`(%B5ZA-yz`!69Yu##Sc%RSEFhJf=|9UI~14{z~5bz%qVlZZ&I7OOK zfq{!*;uLGf(gTbPZ1XPszreuGz`+R<;Q))U0!0{~f=u-TX$FH>E@p0}Bffb25UlI>QDA4gsEyqpxh$>EN(M& diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5688015225094144 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5688015225094144 deleted file mode 100644 index 918270eb29d758a09a9c776b0be7f14691108546..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4148 zcmeHKJ4*vW5T5e}iJoH6C`O4!f?%bErG<^9pg%x+D?1UfFojsyNWcd+R>8(X?6lL? z%3lzzv``S6U?6dw+0C7IdzVY%3xylF%SOgH}j9(l@j!uiF5j z(#aAdTe8v?h>4T6@d|L^8Y)pjqFG!p zkR7Uti&fWAe-an|_|S0?Cp+}`Xwh&{-JWByS7;U&C|Z5UprfX_I>?ZSAjsQz!%-DC zn-~xxsUOZ4ULVvL>9|h<08rzzB(fFMT(A;+!X+V zZ^{=`O&X{pe<5E4_~5suPJ)lX{r7F25;mZy=_>M>4>)(#$l+m~%Fjg{$M?eid4a2S zRH;KcIB(=-0z0_y$a5o5m-Pz4r6KAl?Fz4Tl)Cf6$A-E9XblcB6%_aLodGGv>ANy4Nsf38`@t1rD Dc%-8Y diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5722044720742400 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5722044720742400 deleted file mode 100644 index 79fd18eeb676d6d7837e8b3b562f78a500ca1315..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4409 zcmeHK&ubGw6#lmRh#M10sHv!>8YxOo3hJ#F1@WrjKjG1fh=_EB(0d^sl^%ju=}`|- zuU@QIvFb@d1ubGRU^~8<&2(R9ce+j5N|8L+yf;7d=FKTtwezHd z@egMgUR^&qd2SN*kv}tB{qX6_(K^Dp_IS|5LCm$M8@Cq&M31KfsTG#g6iR4(}l%h%Iy1)V!fc;g>*rRDj=(MG>Es(?40q`jl;3Nr5G0{99+m){05%M zvat;$`o~3>;^LwY7k9)~4~UEG`EYSj=T*4pV{FpQCDe;7NDIAebRdZk|2k~Mxg1kQ zdij?d0Y8&)`T31o_krWN!aY1KN4bBOpG=(O^&|$wRJK-Xf__iQ)JNK!p~M?`NiRKG z-sJO}mhC@cmZIM|HW8tS^rJ1r@-OWXwSMHkao(yG&S#T(MtOLVoDuBYOl`?wKj$Aj z(ooE0YcXbc6QsfZM>j$GhoMUCfh^P-3XH7=UbGk6ZJkfMqOoo_8DMaZ8BqQOF>h1o diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5734997805236224 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5734997805236224 deleted file mode 100644 index 74c273e75a2bcbfd1206343a4aeca1ce92155aaf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 65532 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 diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5736809862004736 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5736809862004736 deleted file mode 100644 index f5ef7a7b6e860b6982e251fea4d60d2aa3461e72..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5139 zcmeHLO=uHA6#h25Z4yn|BE_~uZ9&i?8p*l6c=DKlmq-m%uL`12DN;1If`>w|Jz0uq zF&Dw@t;bY*Q4lO1^j3esgC|?530k|pnPw)lKgs5&77AGiZ)f(+n{U4NGmjvgMHHO~ zzw8E#t|*FA$~YW7mEBUtT~WPo0wF#36xkW{>p2TR2^hF^=X8NyEh`i0Lu7ozG7P+Z z965@}#(0NC&v5q+hDk%iH>PI&T70&M*m`{FO=|Guc{aa&pQh(ttQ_fqo|}znLpX%o z?Ci)$?*y3+EsSUrh0e0na7=q=4HNF(oi&r5RI->%Ca=C$bi8!mGhI?7b(=1?SMQ!$ zc~54`TnKsKY6Sap!cGsvb4#ADDt4*s;G$ma#8-~vHsxM6E|<+l@Fa_7iqTn%%h6Bs z8S*>o^P|ad^>bgVxE?HX&_7JmGY+cqt;Rz`J{ECBcw$~L*9cFkq}k!mQ(gRML}X_E z@C9On`HzL(g38mHFHgP91Ufu#o8qa3++==paImL!#3#=T zr7n5p*+e-6glB>9tcz&P41O+fdi>=nLS7j@n%B-XnUiPT`?gN7bV zTBSVYiIGQ8O65JxzSEdXKRxl?zJ9Xm`gn~!fld`u1;bp7)#H}>!DGvzaq zKf>z%F1V?EX6Xm%3$ZSbJ~1b`xN)<#@5EXm=?rVT?>*FS8V&iLo!`zu$;BmWVgJ*k z7V_<%bch3%k8QjapE2jP$_I>c&2q-166;F7w3d%zk5yg=-L~c`b<8*S_aScohALdQ z%5&BA9y|-ag%owlIp*_Xy^w-ql4&s~B+WHlw}cHL)qT{v&pz+=u~;8>+?C~eF3zab zNUs`ukKbwPUc#uxgtmT`HXSF$VfGDxCms4GO3Ta9( l*biX`8x(p?*_w7WF|F-Y#-BC}D!DwKNCJ0<5CD#27%Q6#j;t#A|y)oMNm1huTV-1cXXVCUR(w-U6xA-%a=s3%_ZG0Zf@3dz>N|k_YdHG_oc;nGx@s*>+ z=e{okvI5fN<`FD88&{qZd8Dv$Wm&A%1l(#vH82J@DTomjc#p7M!*1&Qr^u)_yfp~? z1@!A9E3nHUk@rA`tPZdJIdIEU|6C)xQOiCFylV)F(~9I)Unpz~Oz9zUqEwY~<&V$E zUqVJpIkz)TiRN)l%U=79FQ~->Ej?8zY$q_4KUd40%Ncq?|EtH3`#rcoktk>PwT9Mr z-4IY;oy;ShPp0#b4u86}KU!oSS1tBi>4PPQ*H<-WIfP|@K#cZ_Jsq>KOH~`21$^<% z#|$~TO$fcr{$i~U5=#bi+xBj#E>m1&8cq;^dDJ(MaW+(zRwvp1sR1;RtRUH(Z8n=f zLqCs0Ayv1$W{3w&G%DwNpj{!i)@H>_j$q4&hw_b1JJKkUXawF&jRdfgZV zvvWP;1Kd|rCRqwWOK>?(_c9V^^>X3q0B_}eA~Z_Vo5~-~^n$Oaji|?dDE+8*a3mzA zKVL+hkhq6YhuToxebhlnovxhy)wg)=)O(@JUPoW-sM~r&D@i&HZ%d6m{h?B2FUM!i z-!}Z@)_dQTF1RkdD!dsrrXmIG@>1w`o_j9n2dUD{<%UxyC$ zA=Ax{M}JjwIXTJ7ZDj?ycUG8l5|EyL!J9_JrmqIQ+c?Tg<8k)%d2WkT5h_xdx9*_U z|3#Hsf8J27Eml=Qda-T4YPEC6(Un**Ccq9ZfoXBfxtTcx6 EFKUSLDF6Tf diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5759310927233024 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5759310927233024 deleted file mode 100644 index bbe106608fea8e5ae067dff33df74c9cab7e850b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3255 zcmd^BOK2295Pg##lZlyRSIlZiR5oiOit&^91r>HqDxxQ^9>joxpMxkOYTQBbB*w!6xynqo}HO>6BYa*7R+>YRdscB{knH-DQUnx zg04Gx=&ZWy&Vidj^Kf}>&j{nKz;JnGPi7*(amHC?F@2n6Rt7Rx70E>MJ@ZG(!)9$D z-)(fRzBh6^(nTYp#lp7;15!`V$M~>(|1$EzKSAqh|2ExpeEn&KPC4VTTOF`2+&G1_$jl>|I`WPd z8(Yc7T&6%;BP*9e%|_gc;?NZa<5|JYPfh0tV+O5%2RIbs+dS6EJa#-AcGC}hB4Pv^ zN1N=?S+tHmt!DxQL1eVfJuAU&1Z>*w@q5C});U-3Kx|BlIk~fjzcXQ)@aC7?iXK^O zbQ(SD_&Btem(+{8?zr>5aUEI80geSwk1Z!s5TP7LNPPRzJGX;H!wd}gDdIO&qEjn_ z6rHb7BZF2{GKf-7Ob?HqjLQFg^x-n4r*)BfAFxRkFH!)q90f|^79JVWRIdic4V$ME zLJLX|i)i9l4=Z|zY%?jQ>C#^UG9%5V*7K+J7p*_>lwkwx1~PK{;e2YGlH~C~KJdpw zEA&TJLbdAu5LQ=MZKfihBq1#ESa;z( z-p3Vhje+XRU91?#*6XGV^hPwfd#aXtxsuyD70jB7`5j)=R>Bsuyj(E z)JC+ILn6qp)YBTQf0o3a{8KQ6lN3X<{D0_|52ZYQrA(T_RNrB%2x^^cy1Lfm brL#GD^_v&{?|t?E#DhP43dT-EEeu})GmJr! diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_unconnected-5767885871382528 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_unconnected-5767885871382528 deleted file mode 100644 index a082503f231c7fea8e13bb042aac29c2a512551f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1024642 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࿺ z;}aY)0N)!@S%Ft+n~0-AjF)yi;Fbq)ROEuYvY-sNFBBA%;hu^AZDRB0tzZ8hj&Z_i z_>PBuVVM~y$@iA%Kl!DuYE2e9-w z5LF{kP_RICFDcV71p}2+~Fo{Y$SU>W@rF3Srz>|0mZJ2U{sQdF|bKuQCSsj!<8iChU zL8qwv8SDKtC6=9}#ZC!!q$C3ocr8(zwkMjfz0%#19;Yf^ZS{^?A9$Yorz$M7y;Xvc z*#?qz5d9E*kOTG2X=kj!hKY*LBn}RSE=1#p8UH7`WK2HkOWqr=+?;ki}VGUyo z6^BFu@OT#PDWChBrQT}SYFzHC{&r#DuVp^ez+IoEWz}UqF%?vb$voVZRl7yk-RA8-^l0d zk(iq|Z~j$Hzy)Unt_V2z$>jSR8{cSb)WqfAe+4c`VO*kA*q&%YqjYFDIYNLCAOx}z z0qI*9?PPgQI`SQx39cp+jL3W&@-p4o+hk={ni8{!6D~ZA*O2LWfER~_jJ;vFX{u!M zk5IAB0eZYcVUh}l9l{(L);0B-4u>j@)LF7_8zs46>aDKi>kvm zggtMBP2@)6p=8Y=X9wS*2f6%b8oz{-={-336(ffpW_;&9-`UnhbizyGg$MF2Y4o@xJ&8DAAU!e!jyGw*jhE;h_oH?y+dLc!GjUp^^MB zh4{li{}jGQEcjkLu460TK)5NcbMQ|h`Em0f?g`|E%b!*{-@yIl{PVe(Ux;MF^FZrG z9rB(;aXVZX#awBB;+;7NxF7lzYyfu|`{o-NQOzbgzU@%GHBqi;FMb+J3%mje7LtGU zNd!nfUvdG4i4M(_K;iac-r@#7;2Zo@+Z%B|puBf7T%nklw=>!Ct(WCkKpFV#4zN7m()Uld<6Be(ks`3sW zUO$>am3K~M)h{mCaVp;30*i{a;8&>@6)nbtKLQAzDs)~q)GR7;>^`;-M!Qhr!hKag zS-jZk-0zee?=aAJOVxML6FAe?tqRz#@#E{ThpVe9Dq;*(%z>k;0;7F(05{$A)6u~5 z%3H*Wi}@tdXtq&ukW*aTxftE9;vvPwy^1fMz)SWOfTX$1$EOrf^IekW&S>sUH;udn zmc_Poan;eqzHY6U$HJn0%YFO4+*fs8Cp>)Q4M5%KPDhVUm@r{@J;GGC91FK^N7eYB z7IY3E%_lFa1L0AP8$VhU9*yV@uZL4}Aa~!s4x!4bi#MNj^s^XUAn!zdyvFhS5ctPG zbT+#Le}o2CBR)iAch}^}Z@FtQ7%Jfmeu4VK%f(LkZFG$Pyv??<1pt5F_#S`Wyu-8P zogBJz!`VYaLkT~~>}pi5BS#!`ZHJNuF3K~^L328G4CWMF zM)?jh*YG@_l$`(eD^fr2-O_&XHxyXaSNtg8|M6bz*Cm%Y$xII1azDIl7lU;c$k5e3Ji_Rww<}Ou&`LmmqKm(p(mmjbDoelh1KVk%mkKzaO z!=h?GJMMA~t8uw%8sQieu<(4P^nk{vb(G`J?%8bi?Acs|XCgkz!(sp}|B-Lxr+mZ$ zI6eaHakv^9Iu$&D1_KUYaRkDLn&I)M7^aLx!`FsR!gd%^fKm;ea0tTF7BJw}K8%0I z8wy6Uq8%8AQc5h3WCe{%sbx6eDaHy$Jk=E=VJ`RLm0JL(8 ztC&P`ax*Y7>T{f>eHG*7-Oigv6tS@!SLvNx8~`6<+xhU_u%40&6b*3<0rvno%98m!WYiJk(jvZo~kft@T6+;&>Ihv2hJ2Cz^96Q8G`xbUA$8kmp zTN8JPt<+EOTbUXP(?kLB2d5t}fegGD;^O_3Mo(1DX#$*VL_xtM%&%m=y77pWz{!W| zH7pDhAs&A;xoB^C;cX4LO9H$rED3~JYSO9MZ$YVPD!LYcgtv%oQjZG!x>&^3$j_-r zNZ1!9q}VHtkPw!;Mah8vlG9=@-t|<4t&%!+#^kPBi4q@K$_>Br(r?+qNv3}0$dxAw zM!3X#EKvbsxJB=Ht3cK(tOjJDIv>$5a#{W{8Mzp3-bhbadJZ7nqACoXKvIE0-t-_~ zZF_2ZY@uB2AV6n`?4T7ToAw>osXopSRibtbu=*J-IzwcylIRSP30`!D$OITm!E}bm z5=@qa=nRo1nBoc18KQUyB_EGRHIi3iM}ws^M1~6SFinabogs>xA@b81qU717p1mSJ zA&?yi=;vwEcb^^jkdC7#-H8^?jCt2w95}jV6(@S)ENjhgmrZ&=aMW>fcwtG=9 zAwUQa0w*d0bb9H;saa({fle=l_lnc$B|5!Cru5JE2ZKO95d&w5#Iwo8)AD4K1r#j61I;1+HI*Qkh)$zm^;)|LO z@%+RW;!8Y^sN;z*(R?9HqA}r|AzTO-b>9)sPkbT1#N&uMp7=t1QS%|5pZG$2iN_Ij zJn@D2qUJ+9Kk|R4-x&zo(+0w{Lj0@|D;SGZhr4ElTYx&M-zg}vl|N&>pJuFODKHF%r9er>sIc;_SVLpC8-`|ZptVoUzZ}O| z(-K2Ug%Ev;UIhku(}MtgiatF!r#=_@6n#>d(x>Q?f=`>6K1Hv^BUN|wDS8tm=~MJ3 zz*q{VPtjX~$&wI#irx}T@r3A8^zjf%KAt{Bufi}C3b9Z~70|BUH>KQhBD!p;x1RZ2 zp3d+GaPQ57|!WzcJPs;P3JpSK?dOQpFl+XRm zQg5|u^#p+GZx;ssTINFy-1S*XpQ2CcB$Wg!{SpEv5CS_+pt7`YQAYFSFI?o^>Zri= z`(@aTI|{ct$^a(f!Y-}>N7jFH3JNe-{KF_*+{LwD9#GH=CQhVp^CFCeDf>2W`*Ols z?)0gCOW%-BR){{;ZwW!OZ`)@~IR8|Cx{X;=+y9CBm2cfV0}fu<`@aWoyKnUTA7Axp z-KH@ee>HQ@lrFtOOV(X~UWb*zrypH-<%_pWSn&SKXTN#pq4HmD=<%Hu4UZLE_uX@w zm)!i`T?vvk5Z+E-?hh08d zwdp{?#)+do`{vV2KD^aEX5jkwuV2*nnO}CEy5oZ74|Qm{W#Yivr=I!c(_6YddHRGE zEoWWb`PM(p|4Z@ExjA$4*WBrUckUN2e)-XD-JiJlu|eld-@1Ev#TTQy)f_mzdRT6c zrMcrixZuNo9QmMO%k!5{edfc>(r{8(czvifvX_LMJsd7ppz_**Z({M6g7?LT<3`rf?V zCFc~rT)yt*y1QJ%pzVE^m15=jYGf_uvN)UzYQP_u2zLocQGQtAuZU^$Gl^YsHAkh4Wtf`K+I<-m&`r zXZCKY|FH7QC$AXr<^C5o++5qU>&`=-F-2SUuUR(!&EU8nti0-fXEg6A9P#h3HosEw z!0;)%pYHYNeU~4d*W;1*M?En8&jTM{a`$H!m4rsRYDV98^QggxC$ISS?rHn~H*MFP zt0tDO>$Bw5L3a(`@XOt=S6ndY=c^v+dh6`JJd~eb-TAK&M={2A-T z?|aonjC(LOE}}4=&vYxAlJIlIlhxObPH#OQy43B(QS4%Ncj@BCSRS}Kba*zaixnAKr(ZMbPRWc8wnfn>0y_npKv zWkjl`(~(&jVTr~Foa=3Ow=UHd47)US8tr_@k!0Hs0edyRz@B*KOLuGw6LG!}diTdTUemc8UF9^hV%rS*Bo91#puI{Di=5cIF||e;O2hiUJm2o{I3+l z`M&^;8u1@vB^vFSd1JUD{Z_=*Z4qxA-;y}-HlraYW`f3;u@sp_2t1!fwi=syBvi*d zH>_oWW^c~k=GutRjS;Wn;~(o*{F!)tFB6SQ%%&@Xyca6J5a{dzoJ@5Cg2IIZkQa$3B2 z&lX<7hu%5?T5I!N3={jkkBBGp#Z&cM8#1sK8=+*=(b8B{kW3){PhBBtz=D=YHeaJa&kunmTFk8Xp8`r<1p`hsC1O| zM-P@WYzAhBrGm+B$H$J=`dpy`uFVJEHFA7s=nbymrr;)a)VtxaN2qh*%2aXcM%`jCe4;&e0kg`C#9KIuEIonfoq8v3+O1*5EGUxxX5|ruJwmnM1 z_mW2;&?_oL3`l!lWo(8nbaoayXB^v~h!fww(XX~i_L?%|{7{=@LP}3E1Zw}CbCQ*q z7q?C+bB*Fj-*v`4k~7LtFbZTwf#zXO^QbJ1IX8K`Z%JN-q+zCIMZdEwsS#vhZfb&4 zeA7{MDOMU^UAOom*&uO4HW+E!#+z)Xn2lS|)Xu(ws1(x1wq@LfnrmxIYiqBpt&Nh3 z6EHDOym9oS#=%xXJzzyjE92DOru{CocDp-?OiL3eauV64H0jj<4+FH~8(s*ywE7Q5 z-3Od-CVVZ%|5hE3GmOzr`frmBexpS#hu~ys(yl&>YbbVgKN&lkViQ2X87GbA^)rqv zMN0_qP1*;V^Fo9NArKRR`(wtYFtT|=b2IE(n?j8Ss;*PcZiKYhpHmiI zxE~elo>NrJM}JNzY?g+VhjAA$16EX&9&6H4qcf!1?PPj$E-GNPKe`LMz!$XlbkE(<6Tf+tXO=Kz)ORRk}!8Z|bjO9o~g)46; z${S3V)~fKEjQC=sRo|tx5~H0FH4xF-M|lxaz4$0$Xl&MF!hwjq{25{ph+h?m8R9G=r@UoG>P9jofs8eV zBhadXqoJbORMe?Tt>)!d;fO6fm&eDGIHNS%v~%X5&H0aPqkz7RC_rONx?60Ys*dmA z)$AVWi8BNS<0A){6T6cmtm8UpK@a%E3;OB+@M!nio}0GCdxV|L@y9Ol*4K<$I#1e_ z;6U6ELp;&s#=UzmiJ*&cL-z(nt6e%klE0r5lfhKcD1OF)R=ZLF zWgHc>+9j`c>EA=N?-7~-KOZ4QIq^Ym^b;j%J%CobVzHN2yJDe}Se!FXGFt7515k`; zTJ?$n4n;)}pjEHPOCb3Ofi^)P(%jn6_iCHy);xsi#6z24eDW!!6A$UGb2{;07jc>c zwu@L?d71-`3sDRKngf=>p*dg)2s-f)qqR^}>JhljSS3x48sm~os54Gt&3joKS&G&o zK$D|dJmTK*??atTE;qr#^3}E${97k3yRD13vUSp~COD2UpTV_oK~4?eP8`vF#>TQ5 zX+t94-8sjClM;r11^iIT8^M+!{{S!#4Bvb1*uAo`DChy-ia!@?qeM|@(eIbwVBj2# zfA|rvLQLQNl4IOnS3T~(;$KY0F!8ahYH*EsLO`qb5`{b z(?8fyEGiF8SfRjGp|1N}KgEY?)2kNCh4uofdUKJ_X3<2>tP{Y5zgQiHwfga#S@gqT+qe2&8 znsHdV<~(s2fgB(QltEnqx%x)N^6^4F@IWxFj~nF|8-GL0?bd!B6pc>B)?r zRdox{_7izLsNz}poPfN) zE^+|M zo<}HjusPs-4!aIzz=p{>gLss$p8#XwlNyJxZ5@asTLcD%_zMYl!Jvapz<7Sp;cLcLZj*wO{k8T^r92fdw{$cwr9)N&&kt$x^O;IV`8RB= zy7QTu&R8!W;O8@?ZYlie;N4QBv*ulzX}8Pc47c_~0|{^OU~K(j(8- zBiQf(j6?{dsOm+P6N%cLzk7uB9ixv<^14vuwMRKqd0JKMDUX{BrD~PdBYlrY)%Qkv zTo{G}HN{SCxeVpg{c54_Q?upBqazHeN#)2NNiqaEK<8xDjVJcGV>_>iX?-aSe+Ua7 zYe~PCMTQ<`2TxPN8Ff!J6yKipYcg&GxF zRcX?v?o@S@mKGf$O;r9Wd(+R6_!K^YD57q?Hcq}PBdO13b_6mGf1YlMRFku(;AC8+-Qo>|2 zbTSTsld`UiP{@kPytcz)sw@g*Kd)bYd@;)|LOvHZjp;z}%j=;Mel#1}m$V%-y8 zh%d4Dp^qcJ5MT71h;>hVA-=@ohdz$@LVVG4BGx_eh4>PSANn}r3-LwIiCFi<7vf7S ze(2+fFT@u;Ct}?bUx+WU_@R#@z7SvZoQQQ#d?CKX;)gzt_(FWqb0XF~@g-CEQe=84 zoa!i3>d4p*-oB`gjIkkH2$xvTAAKD0rTzMn_QIa>HSQzyZ6n!x!kKVRmP1DAiC4rc zBVHsMM!X_kCCeeB^u#OTl@TwJ4QoeU`I5Cgk@W3YUemdRd zV2lMb+5Ib)aj7zW*|LzF&Bw8_vm5t}-2^t|7uk@FBl>=v_&Cv_J!>~MH#e_*_ub}D z=I0Lc`#^n&*yj8!q;d*6S!GmJI#b(Fkm}Tyaf7QHWUi6kYUMVY5H@l$dtu>SFdS< z81T71*zP?a7uiii^7aro#hy4x69PH})&+yF>4IY4mPMksN4)9w)!6P@RNB)hpVWdVG;DQvC*lZNtGRR_^Z`VP&a`Z8Cectd!yfHG36SMq0)&aO5|F z)M_lYjBv|o!xk243&;t@YJL?hmHG|rFnG7Y+j>hYmPl@+Vu!*z5c5u=Gw@EtbtJd( zbyX)JLBZQygooH4gus1h&{Z?R35DD*47x5bs|lFs7iR5cbvU2=H4oo8b5>~dK3Qhw zA40Ospq(2JG=Ug?XwY>tJw|#4!GyRnf=S+@O=8}?O!8K2{bXWDu_F`8BV&j52UQp$ zzH01P2;n`@w9zdHvsCt9mq2|Skm_JBracV@0A_U=!PBfR4e(6F9#gK2mARFg@*5CX_Yvn8y*yZSI7-L?d8pvRp&EB*`I!?hAn>1Y4CQ*Tql{IH z`HlH%lBiTp&o4W9B9;56%CGUl;}Iumycx6RBgUShy1|2YKu5-0WBdM|=L&+8Z4e`r zpTYjYDCviNqS{T&C#hf1o3SbYv{0jut&kj+_zgDH52u1K1E$QFAtmYqxmdinp-fS( zyJ9YqyNq=aN3?9Dmm}5S!~t$TV1DIpFO)yVCi&n-aJw9fy9&o)pdUojxv~#s$Nf3{ zhdVLsvQlY~tf&Ok=!a6BePhwUA@DY1kFVe+VIpHd^{+MtSlvo)1s^VUF$yJkkHlSXcIsK8r>EHPE6|U9 zT{$L?^q-HLb)YEh8ruyy%y#$qmi4_5)Z?hE83(3*Y!E#T43E*H#v6xm?42>=jT$~i z`nhaRoOcrWUB!<5G}bbH$BX@*(ti95nZDPghRl$SASk|XkBY*0s0<)xR{R83f%TraWN+ji30QEDbrly<6`FrtB-YJx8{ z4??AHG@1bBedEqSd;-{@ZxknhEz}VW>|zhHHJlIEY2p*=mL{Ov@7bM#f!(3DddZ=_ zF1ub55*-Jc^>xx>SGM$Z#_Mw@|G$?lye4*5%>^FPzwfv zVZlPwF@|fM@8!v*h1rmR;JOau=8A=ABy_-C8hQA~H(NO6D{i`w!i1b-SO_^jBB#jX z28?i8u1gB%x^TaWdWKrH`m4;qMkXS}K_H)OiMwLWU!n~LEnWffD7_8`?$XW(t_z$( zVesnw>oCZT^(OSbm}3@l3%ERu3wIJZMssoqU7;D==z&xClF`{+p|o$n?FLWqClGk% zHNbViNB5t13=XjK2D7>s*9;A!0#DF~TN)q$|9t6*&>?pdYijyO==E0$8LlQ?14F?t z422qRsTcRCoXraPnyY|S$FJy?;ve`bA;>VUsfj0U3cbz>`SgA;=QrTGSAc#^O+%$9 z)QcM68e9*S^a`lART$C(nbV4^tm5&{P-va-Fl%mpsCki#xf;9Sp-{Av?G7(OqP?C>)bqC5A2h=YnhiD9e< z_<%XlA6<@Vv5RO2x>IH7*lz@ugFAih71$4k2vCvBG5gvO&dRoclOckgaF<1FI2|bP zES$}IG;_D2)$P9qkTj^Q*D=HopaR*_D}YIaoKDEHv3YUm1yJlhOe~vUwK>%3*dSF|FK>$C(wk|2slm=0NVofO{ zrKy4GP9HAY@5Kf_LYN)myNnrBie_Nvlf!M59G-8KI$}7E`NhH64Br|X_$G?00wM0I z>rt%S$k#x;lKV9!Hvk7WPt>1|RUOEIPp@wb{XGES3czrDh)XUiR}_esDSj*pT@>6% zE6fOMcO8TNdE%xG9Sta-6$ zE~BE=1G0H!NX3Evz(3Pt;hRaRkfHBAInshP;Y>KEqP^;M5UocKa~G2(?;81aSpV#W=l zaN-N`#fTSXVZ;~Wiy1eJ!ig`$7b9Mng%MwfFJ{~@3eP6KWRk5$SXv3oq%x2#)K^&H ztRh2vA-*VFuyQ575MQkDM3EuB5MLB7Sh*5kh%Z)nqR0?mh%X8ktXzpN#1|_(QDlfO z#21ANR<6Vs;)@lYC^Ezs;)}usD_7zR@x=;H6dB?R@kQZ+mFr2y7d*Xd%nyC|NrsE% zbFqYrF@Fdb!bRVQ#JVTG5MN^PLmx+cA-?E25$m4#LVStE4}Bc*h4`Z9M67$_3-Kiu zKlE|L7vhVa6S3}zFT|Hv{Lse{Ux+VyPQhVA-=@ohdz$@LVVG4BGx_e zh4>PSANn}r3-LwIiCFi<7vf7Se(2+fFT@u;Ct}?bUx+WU_@R#@z7SvZoQQQ#d^tJ! z(!t_cMm=|kFDEBo^gOV7PkbT1Smg?rBfbz{h%d$*AY2F+I~=ehOZ~1fw+I))C0pB3 zJiCe8#O-(-QO6Tsh%ahB#Pbthh%fOtqK+rN*y4-j@6o9-PS#I#6kSJzNi-&$XM_vk zVyC|$z7SuCFUA}oTnHCC9Izux{jM>$2p7VI+L18_2p7V|4hQVWQon1=Ey9Ixp>|}< z0m6lFvBLp7vefSybBk~xT&NuxbAWImT+T zt}(X=7sAD?9kmxXC|_evn$=UH;e<2coG5oEsBH1wF74a%r4jH8_nr3B5YF~7 zGvaH!Fv6K|j>nNi;)z$pt3-HXmPU&vu}h1G8EVnt(IM6}ok)mRoIPcr6&!4rSr~L( zU{+HN3x?q5f-q|@tAj%HyQOg8;cht`f?un`59`Bs&YTq*y-!X%^ADi|qW{pK>t=#8 zp3WF)PxFAOJs}U;DW>fe$yc^{(9Vqqn!@&fGBE_QJy#`Qk49&>Tppux4T1@nZ)_O} zXR%yC$xcxoF-P1qc`5j->`wyEy_i;uXV^|n9VvBZRi5Ll7d1z!-t|qk>v65DW_zqM9*W>wGUyE$$s+QdDBc}Xc z^`yq@fBIEfed~L_`fBvtzwdeJ_OUl!`PqXXUHtw<-?@JAU2pgPVC2XDfVI_qW>tTC z>7OpRs>eCM?|98?foE<-=ka)cJt|N(Xu`rlm;U(DOD|o-oT zZ+Y#P^(1LWi2;)cdDLl$Na?|ya3-A9?JiY*;+2+Hjsza2R_cOq*5YghvqWSFXTn*_ zo5GZwHzZyWue7{M4Iad+)ZiGeZZZ?+wfEysVmaK>+K_hXq^=C-SEDsS6itL7=; zOgO9gkSag%ig=YOE~)hpuZUM_KBUS|ydqwuic4xe#4F;Jnh&Y+6R*<4E2H{qFYL({ z>vc|bWQ-NzLbw?9BW7X57vhTCr=3}g%S z6;?Q_$PizMFA5i|T!}Bl7b`qbWQZ@s7ljK}uEZDOixr+IGQ=0+i^2sfSK5G5xDVqslTPDRExa+U3a zi*nH(I6(5pVHX$`b)4d|4y&*LU4*o{AZgM)@7udQv)wb@^Ul8euHNr!qnWp-XQt=r zPxrj9^uD`z!HbU*T?a3C(H4A`ZRW-Mhpo0*F5W+zhFq9meC8Eh2QPTh7JQa?!HbU* zT?a3C(H4A`c)^R06I}-{c+nPomUzL7j}u)7FL==we3p2@i;ojs2QPTh7JQa?!HbU* zT?a3C(H4r9Siwq>5pz3U@M3x>TE`1sij0`s@q!oAL(w{3@KR*N+>RH#m>!DO@q(8k zBj$Fz;KlS%w2l|N6d5tM;{`9KhoW`7;HAijxg9TfF+CKm;{`88M$GMa!HemkXdN$j zDKcVi#|vIe4@K*E!Ap@5b30z}VtOcA#|vJHjF{W;()wP^{<5vphppd-^bvhz8@sMD zyx_%U!&Z(Lyx3g0%J4GX3z+gi z99-eb^ib70u5eYACG$AA!jvSBO73tnt4TxEE{i_3T zS>gpRK2CHUyx>J!@LA#oFFsCm9lYR0Tku)p1us5MbRE3lMO*M$wwV{7i)7RlKxHJ5*k@g)vk#Zp`g?!HemkXdN$j zDKcVi#|vIe4@K*EX#p=i_BQCgqmS(QkPEr!G2*kt3toJj=sI}8i?-mi#0y@0oaj1u z!Hc%wv&0Kte4OYyc)^Rd;IqUFUVNPBI(Wg0w&1hG3toJj=sI}8i?-mi#0y?rPG-vn z=e3)3^;6k$awg}pcJlVa6|VApl--6aT$Qzxw;!%>mFJ`Ewl;LNuxwV1?AL}lm-@L_ zjbyC$C1>WzMh)5a#}%$@E=rZ1HkBo=rm`rNrRUFIB3j)Rng1oJp4zAf6eq6 zPNl>@^3g4q`Q#9M&C%e-;n9ODX+bBPpE#E&f zIYsXh-h+D9wr=v>!+KI4wK z_UP!B_r7>QbPn|QjtTj=XNeH=wIa&fG4PlxE-BZfQGWV)t4fkvZKljfzy zq`B;Z>yv{F&+8RyqAszzPplL-M9DpG|HyY!_b|V?*nXbm#yZ)S13Tp<=>OuaqD!r- zOB#tqr#M|*=d`O;o74t*rRuSEK>iWO199@K_Q%qn^p2hN#{8a(cgS1pZt?5r;jaie zl`lK9meafsh^r$tk49$2;ql3eeey6@tD|o3RlC=2m=lqR##`a>O45j5HQE%FU!%te z+yAbx>h9XTk1X2R@zUP+zj^MyXI3oO{GFYvc3*zO&{OyB+i=&npZMW(i;rLT?&HTl z|J%MTXKvfR_2wU}TeS0?2cO#er4tXm@5WDm_1P00i?7^r--n~sX^J~t&b=Q}lU-pYNzx=*FIfB?eNmUO*;mMJ~cEn^kn=k`Pls6s_2$z)v9=B^i987kM8=J=ke+_4dbkm zz$uqN`mO4WytVWE_)*chgWpne-clbgCg<=mQDoP)ot$SZ=NUV2?tr30o0B^^le29? zZL|zmxN6jpZGT+h%I2ccvT#>@xvyV*+Y^4?YWkn^R+D2#7a1wDJ>S*wqn^h+ zyyJmw!Sh)Dxo57wIq%G6YkDDPayC6wwT>%XRb|OM4z6%zdZ=n0SGcOml6f3l;mY(- z)jFN$qFg3VCMMoH zT1^JFyk;?%X+Qs+w%GfbT*$>Xc3ow7!Hdg=tsF0SvAJ-S;RP=)8@6)1;Kk;`RfZS5 zxNO+U@q!nd3s)Il@Zz#zE5{37Y%W}7c)^RyhOHbgc(J)~mEi?1E*rM;+4919?M`id z)JPdQlXD|}T>Ih*S1uckl;a9ljreixiz{5YY&24itERbH*hoK>-IxAtTK`V_%xBp? z3)zqUrGG=b_}0Z0u6(V8)Wa37LcI9aoh?_s?bG!tY3Ixks-$W1E6n;*eV3d!JTu>H z&3fca&ZdW|)^UZasw|nuX#-cyfn$cM*4rT1)Qb?Vw>i$pnVhq8O%=~^g{vwYWsiZY zR&~{vx_@W;&G$L|+p7IrO}psdYH}XUR-5(!Hdg=tsF0SvAJ-S;RP=)8@6)1;Kk;`RfZS5xNO+U@q!nd z3s)Il@Zz#zE5{37Y%W}7c)^RyhOHbgc(J)~l@)m@+U`1TE0wp>HP9BuXUN#V3tsSI zH$X1r5@H~vF7vM47P*iM^J-pxrFLnduLM|Z&Lh3T_+HH{wxiF6G2FQh6 zLJWk|W!|;hA{TOD9N7(!3%P_C2&v1wYqv!%T5lyUbE&PZlpAef%omLvb30z}VtOcA#|vJHjF{W;(%N3=pVsalHJ0cj z`pBG9i`Maimz0sno`K3p&J zjBOk=T81lJHEPJVKdx|PbJ1uSu5i_;A>01A!j;WMqh+|lRilP%`{N2%HW!VSHQQCX z7n^-{oz~nxufCGd<=nsWDM26k=$6ZTu0Qyiqrr{CqX$>U;}hZwQ8aoWzF+jo_3m1^ zQ03kAaxwn4QGPUAzJFwNV%?kdeMcUfIFzg(8QeG`x{8jOv+p@Q!r7jQ9@)-h-}9%= zTW|B={#OqjoNWJVw@-+Ad)Aj|PwJSH*VSXYu0gR$o;SZvE$8IA#%t|N>dVY!ZmDzW z{EhZEkmmupZ#vJ(cBcAB_nmKjm2<|!kp}jy_o~;@8o`UlDRDUv_3Kr+FU`S4V0djm(O}N8R45cCXzqCn6Dz zx5DFTe^W1&UtXQ!5J3CkHzWj!vr|#Xi z;jV8#@x$j9AHVM1$B%#hw|!gA+_rt|%|BSTXy-c*KDGBtCmwp=ji3JNvnM(hU%BPJ z6?g2p^`^I$j-7nz8*i<9_=$c(`F-)iiVH_q z93Fc7s`Vebr|cKw{|6e{cE;8oHx9$vKjh3Cuef@aS~dm ziLRQ{f!P3>c!8Pv+1F#bzI@9Dof^Z zaD^+=Lsjdz!c|q4%;Vq+SEh%m)^XJwSGN9|t?X%wf1lGw_N>T-Tx|1*s|+uAaoMny z;{`7^7p^kA;KgObR*o0E*j%{E@PZeY4O=;0@M3e}D#Ht2TsCawc)^R!g{urNcyZaV zmCq$Ft<+XqmOf>zbPcqHxx&Y+u7el6XbV0|yx_&hiLQeeyl4wPOT6I4$BC|k7rbZ- zK1;md#m9-RgBQGL3qDJ{;Kj#@u7el6XbV0|yx_&hiLQeeyl4wP%Qo{Oe-yIaN4C7p za`FDzG~{CULoVc!okQ}T;{`8yKC;{Jf|sm`yyu3Oua$dTAj<963VVG_A8VxxEg+p&EX!(SMsg=&1@}^Kv%&& z|FK{@o2Mu6!l7dmhmM^#F?|aqBw!@)?~U~tT|M^7v18&NUYOByd~M_W`n_u-4-%N$ z3EU={(*Ai%Yrj-d4xF{)i|6&9r$&(c70AbGFD#GB-y#`{xWB(St!c_77oB8ZT#w|W zh@z$9nm@Woh-)smNPJdY_;;6zC7&6V?{DNUEbWa{`5#^McNczETq4AhE*YCD{}=W0 zr2ZxK`f8uPC;RV@EAwgv3&eg{&%5T(T|TuYd$Nko&P8DcZ)s{eYi_J^1J`+vqE&A5#Jqu zJ3c@81*7_%$M3#df8TJG`u)3KiIXc%zcZ2VL`3HXmBh4i{SHOHgE{Nu?@qpxk%v=H z&BLE{@?yEUYw9p!>Zlhc_2nBO$x&%k7|(0F{6iV)6KlAhD5;Mf6O%k?g{O|KS{=?G4Z|onfOm@cbw(olk%1$;x0Lz z{8PN(MR7u|h=s{QuF2n)en5y9mh9bEbPH?e?eAUJJGOG|PadiL{^jI%ZO7s?F~3`g z%f%f;H)SL9X6#>Oo|ky~Z%gcB-DSjDYAgItw!-4F`2ONLjn`O^JQ_bv;1SLZtly&5 z|DZ+N)mXFsFnsrk^dtNL)ApE9e?vI&-_&E`*cDe?aK#ljUU9{=S_K8S7i_n0{&Rb= zPiaqye^}`9Iq(eDnRwy1^RHex;jn2c0shr%>P;YPBrqchObxdgT>HxzIdasbV0Dn1}&ZF?zyf%Aul)PT`uWcvfe=jEg?Dpc+W9f^vPc@0-a?9)D7ID?Ql|p_J zCwaUcZ-`e;{zIVH>hY-UIQeJPA;kX}KQaES{Gg92oP6H%$8Y@gp8oM3vGBkD#d+yX zN!8jv`u#i68H=t@%Kyaa@?)ApEWYkN)!zAI^7B`6p~{lyXUIczsk-ui>3U+mDmCiK z4;#HFI#t<;Se%ixbnTBt?Sn|7SG@N*StgIUR{oh3nq{(HvIBp(5_m*?O8NBRk1iJH zis+*A{@@+eJ?Y1^L7n$GqTLNVgt#RBoVfbvN8+*nuy5K~Ckt+yTx)#gmfz_eJ95Wu z|Gal>{K)tcaiV*EcNCqr{2i6R{N?xG-z^{Fual2?%aUlX_;9cIgy@>zcX#x@{qd(x z^d*`l?D-;^FO~jzw}`uA(Y-7kVcxUaK`+f7w6=@f_`#${P9zN-|DE0s9_fB}rHHkyonQKDE?YnaiV7n`>*eORayMVV*oe z!=K?lJudtdfBuK*?Vrew&97M0T!wv&Uw*qM;6{|XIjN}RxL$k1YI&bEZerQv$!gQi zkt*wp)S=|D?wx;=ys1vzEM?(Bee>;}ep5ZEZ>mPUWPf#|tsT?2nai@%jhlJ;<|~gd z)kd%O2%*0YbiVm@Ao-o3zf3?L6T`{Zfu8waXUnG4z7F(fs!{4IL8-3_T_yMVth~Bo zrzI~VWEJ`Ni>XJg!1m{bf0z0ik-Y28m)CE7QR2>}+>0D%Kgl*YU;Lc+x!Rri<8q>p z#98mEPh=;3KEE@b*C~55dC@f0=jO3gUD-$VPjA<~otFJlRQfAYU;Lu_-lzI+yCnKn z+<7$a+;vbLCiB`$)>!-Fg=rG%bkkpt{aBWz>#2^ZWEhx3$hb^({Ix~ji7>Xuliw4V z`e_pRH?I8!U&8wP4&z3YoGJS}J9PzpAxGV?^o=h0f|C9UgucyXk3Ouv1~H@eg?HpD z%76TS|N4`0{PD}iqyPN-Upwuha}>@G*B+`%T;GqJniu4)a`J0}YLEJ3puaW<#PTH~ z5}gA}-V>t#k4IvIcx`28wC_ccyuy_; z&pq;sh!@E;{%;)Z?TzL~-+cSom(@^FZ%EW*e7rN>B)6+CI=mgnf4#3(+~}Wv@2T`% zL7uG{!%I)dX7K7un(F(RdZPTVad*`ZPw}V zpX4!1y%#KX3zj!N`<$oeGOt@+&@I?{1C|gbQ#58#{f)%*Cx3qv{q2JEHx%XeoSCf3 zZ>uIRrH(sZN?oBxPwnUN7<2E`j4Ljm`dX{{K3n08sf_6y_?m2zsqHS(IT@0pbLu}N z$=WHyd{5RymjAuukhh3UeN#C3gRtant>O1&Q!hPSUp%eEj5(rzU%q?J;#D`1+JvEB z{N&9T_4((ygdZbwfj?v!c8!0Ay3K20!Z@@R-^((Kk z%YE_mHwp8SpX4(6CZR(t=^Wd%xmVn)e~8N`lE1N8D1V5{vf7)6+TYkry{Q;hZxYHj zX>RS;85uvQQ~q_9{fC^+L^WymuP%?T##L+*9OIOPer&J=@)l1HnaNbID&(Ha|{4|DFKOf%lz_#Fa<)7Q@ zyus&G*TZ>dE?d(JIg_*Lp{jLU;i@W2=5cUUiK}7x+ED-J@#=xpD@ncZl@K|TvpL&U zwT>%XRb|OM4z8Nx%FJA^&sO&O{N|Fj*d34yxtQamXdN$jDKcVi#|vIe4@K*E!Ap)2 zdpJ2e6#j)qnSDWO?+0=rmyq$)N?wZE-AZkxEsV1wujY2V;KlS%wB8giGxEx;=*rCP zO}R>sf4Wp{qAiS2(`L~+Uhq<6#N3V-yqF$}*71UuA|vK@yx_(3P_&L0yc8KRx8nsb zriY?+yx^tCh~ADBtY`~9OT6I4$BC|k7rbZ-K1;md#m9-RgBQGL3qDJ{;Kj#@u7el6 zXbV0|yx_&hiLQeeyl4wPOT6I4$BC|k7rbZ-K1;md#m9-RgBQGL3qDJ{;Kj#@u7el6 zXbV0|yx_&hiLQeeyl4wPOT6I4$BC|k7rbZ-K1;l`zL%nYqz_xa59uTNsAwFU+wp=I z(?iiZUhq<6#N3XT>0ZcWdM3&YxsZ!FcNDGT1usQL%2m#m4r=XhzJmoq$nw@S9Z=%eQKQ8s(u=kyVM39W-GT!os+ ztDjC2UFkgXl1pz(Kl4Azsg(FfKDy;HpB#d(IU3wJJbG|tJU$`55JjU0;`>FPT<@-x z3sv4-FBju)8|6o{<@-lQC)T}L-*@D(i9^Zyk-?24qO0hbIs2Z|Bb@D-=#lMA_C0^< zy!AE@?tk^r!O8Z&cKd{=w`YBc_N0zEd0joW>lzfB^bS2<@q9BE+RdY>AZG{cgzjiu@1-7z+2s(;fywSP4) z)#rgm`)K7Ho$K1qXWS9j9v%Ji-WLyu&Vl~kF(DuKED=I}hG%vE-RCV?E{=8X=@6ZJ z#BisYOxM&W&}ejO(!A7|G?!g)eR7cDdA(vy)FoE;iIw7pD7okDANg+T9_BX}+s~8S zSSQ!6ado8T(a5YgJU&^mPafuKb=2*>YWLa=b0QMa zcq=?!NgDC1Mw_DYYxEdl``;B--Ceu)kwrT@UfTQqH_zSo%!&n@zq51I?#pi&dg|VN z8}9n{6F+=z@$u{4ef;?6f7`d^%x&AZ-u#1gi*~;A;8T0QbmF1+-T3LRK6|2L@s(Td zTXDypTW@-6>DbAazVX(&hrjomA8p=n+l{Y({pD+ae$Cmp?)vic%YL!um){pJthjJ= z#o?jHuUh}1OCDWt^V7pm+$kSDJv|St9bP)PX~*Eur-p`xo{YaGADbUs72Oi8S{3h% zzUf!%(Op0DJYKz~VVqSGIOP)Xe;cdc_65JSEBWJ5^!fCX^M?18&Mss*cXK{2M`w6O zbN70~uT|yK2G?6Im@;_GecB+{)b|y*-sU(XXL2^@nX1-{Ty>VXnfkP?=)6A1@T=qV zYCUbMd2QpoetnqEsnLDt-=aMGQup|>d6RQd&ed!u=W22+a!$^zkn{1QMg3IYet5?N z+k)pY`nVPPc;?zb|IS>t=C~whayC6wwT>%XRb|OM4z6%zdZ=n0SGcOml6f3l;mY(- z)%t9?vbCSK*o~75x!A^ws|+uAaoMny;{`7^7p^kA;KgObR*o0E*j%{E@PZeY4O=;0 z@M3e}D#Ht2TsCawc)^R!g{urNcyZaVmE#33HW#k4A}>YTUB_*u@>aSA+QRq@85?-P z3tsF7$c0=&420BW-nH8z7jj`7*$t2jxr7)9smr`;w?!`G!Z@-UAQy58F%VLhdDm`> zT*!rSWH&%AT*!rSWH&%AMSk=+2fkV}Yxkh;vfc3b2^E{r3)0dgUi5Cb7~nRo5B$c0?y z>NqNDH@2}|WW?N#7rdAriq`Rhmm(wPcD&%l^iZ_kDqdQp9V#!{!Wb$VH|BP{;KlS% zw2l|N6d5tM;{`9KhoW`7;HAijxg9TfF+CKm;{`88M$GMa!HemkXdN$jDKcVi#|vIe z4@K*E!Ap@5b30z}VtOcA#|vJHjF{W;f)~?6(K=r6Qe?#3ju*U`9*WlSf|nvA=Jwh0 z!g=jZ&AzE(ot(+J3P;&v;0jk+6IDFN6|SmqlsyKnaFsPt#dBOW&DFvx`YZGp^l#Jp zHwx{WD(cg}^luf8vd6#`uCgYoc#bPvRpBUmjM;LPZAa1bO4>Oygeqy8{0ehX1ljGJ zH$1a!hCa{9nVfx`gx0|ou0qZD)Ncb<&4H5*yA6U(y$IoYo8yd}$vHdMRPh{FxT?ZY z_87QoRabqf`**hAe4o?5t=hlUw2S_&CdZ=jM9yZ;$B!1}Ro{Mi#{=7f=P|N2v!1zi za-O+t&GA9b+gi99-eb^ib70u5eYACG$AA!jvSBO73tnt4TxEE{i_3TS>gpRK2CHUyx>J!@LA#oFFsCm9lYR0Tku)p1us5M zbRE3lMO*M$wwV{7i)7RlKxH zJ5*k@g)vk#Zp`g?!HemkXdN$jDKcVi#|vIe4@K*EX#p=i_BQCgqmS(QkPEr!G2*kt z3toJj=sI}8i?-mi#0y@0oaj1u!Hc%wv&0Kte4OYyc)^Rd;IqUFUVNPBI(Wg0w&1hG z3toJj=sI}8i?-mi#0y?rPG-vn=e3)3^;6k$awg}pcJlVa6|VApl--6aT$Qzxw;!%> zmFJ`Ewl;LNuxwV1?AL}lm-@L_jbyC$C1>WzMh)5a#}%$@E*dSv6|NdJWZS>pT-h?n zD{HrWxL)R&yzx+W8?JCw)=u7jxWZMQkFwivg{!i5^7g|OuJU}8-G(b%m9>+%AFgnf z=cDYlX1hxFVzbY#Q=0qd)mIX_ocmWkCFmm`-Ex`F^#@;bG`Mki^x(>Pd_sI7ibfB_ z_lrKc-d!sfs=T{iF2>(B%8zEt_m7NDtb4P*@5o~lhm!RpgBwRgSJ5$Z_C2RZINLMP zBiotmd;ZjU>uny~|LUQGlkI=)_6bpM&-xPWNgZ?Yx_WHaH7GX8^XAv7<(ypCc&(jD zeVMt;Ep;xPztR2%@;o5-P3Jk;&Qu@izVofGa?W@-(!jp;J~c9Fh9zYiOVh`@V{Fb; z|E7Iv|7u>U&jXG2(aJeG*R`L|xFfDTI{M|kFCGw`1O2^YLO$+UB82=5&+7iW&s(xw z9P8ZEAv*Vn;Z8M~uBlI;(dg8qd8sjJF1z6RPXF_ky&wge6nJnJj~VVsM~wh z?zJ1{L?oi|R(QOUG~!o{Hbv#v=rO|fzbmY|yLRs*i*|OrwD_hXXmQj zm)|h-)V=#Q-1Y4ze)!ztyGwr|Us+qQ4L`3LJ3?R@9Kr}lp7#6$19@zY;@ z_C&|xE4SRY;*LGH-t^Yev6C--wf;kwJi6fKr-z@oQ$BindLCLkymWBWj=`Z%4Gj%F8GlPYHb1y3 zx+Pk*D&84=)34T}yME?*yn0Q;IIARZ$|W%M*3Rc`ovIW3)~@8Qf6cas^M?0THbbB1 zs|+uAaoMny;{`7^7iG)vgr^WYc)<%^>;}k%TtW_N0Eq^oY??us_r$@G31tzCTvKT=eh9|7QF}xlEo+OuTornhb1t&0;Roe*QacvG+5%kc(~Xy2|i^ z7ncoNIbQH$bKxq(3tn6{Y~^^ti_L|r3@>?!dk$x(>Fa6uJ{+;%j&$4|MvLF3R|Au(+t&1yM`C197hbvr#c=4?} zTdsWDr|VVH&Y2-pNz>$4nDwRlE;(;_X1>{)^~jl=O%GMA;|f<*Su&5)2CkX|#|%}i zw?VL}7a?44bDWVgIcMjZDxTvCS5-L59s^gc>Z&hw|IYTC?{oUMRr|M^cG17pe~X$;Rar8RgDYH_9;#Z$ z6|SnXWF7}sxH3Idwcc*7Y`M)=2DHV0Ow&j9tjL92Z1ae#3@>s|+uAaoMny&m}Ld)K*)T zK4qJru3CikDVthsuk#Fouf8jkz5!criT`t>XnRMMli+c)^S5 zp=cd1E#Rfc-Ui)w^pQOuav>KzMtqid!HbU*T?a3C(H4A`c)^R06I}-{c+nPomUzL7 zj}u)7FL==we3p2@i;ojs2QPTh7JQa?!HbU*T?a3C(H4A`c)^Ry$!yu+ymphWekxl| z&g5LyPTqdF!d0G+vfFTltFm_T_QMsf@_dxt)`qSYmd&b>{n{|+Qa=}~k&M;8(ddEre$gk_yKCh_m3P<6#rWGs`O$3o{*lp%b#K=9 z9eHfxP_lkxaN~&RDmrG)zUTA^XL}}kWIL06&!0MPz0HIBUp;hivi+~!J|XJuSzn?( zsbfxFSC8$w2E`_M-uybXoRjMsueCF&FEf|9rOu`EH`?Doo(JT<={zUfnd&3mcfR#i z&KVC!8rZkqr$#2tu%v8bY5I6~jLn(q-?UHdU(HMPd7#lgS~*AOy7u!Kcf_?vN58!H z#RH;qpucxa$j3cPgpi-%S>1p4c}tdyW1V|CMCTqc+^HthHT4NJ8l9RnFEu93WfxqZ z9AtQ2uUHdxiPe2#rMMwV?s@x1zMHy-`OU@l^CUOc$+jHWDKA0)7jG3^YF%B@NGv+V z>FPSCU9H-rHpnYgkF^8xk2oHPlV`O*mj0x7?5sED_guU~-ePx)Uq=srMaZdq*_pMR z=6yh19jSRVGAj;`Pgd-chq+oEb$hScy>`Q#h(t8r3XfNkM*OPLrl|ZHJx196cZF4V z*Y15}(aw&S_P+nkbN4;7V!`I`>|C|`@*9Spx_94(yT1Lz51(6n{JM7^KmPgO_H8+H z+xD$D|6tvso$oyO)ZQXBc@dM;F}u^zajR%12L6 z&qHg6mkw^)F*x+8p`oEC<8R5w<_A|rw?wN}#XF;K`qg@L*UvnUSFdRpXO#p_xdf)( z+WEY#Q+0yh+LiqEui5r+-tfN4X6W;roXOe8NobuWx@t}bW&>#A1*X0?zeh*tFjrZ{m7Y|8}Z}Xw>4cIKk904ru^`Z z2et*zW3743Gv}M@ow;mHkK|0wriZH5afPd@ESbl_6|PJVRjuO+S5;XukAo{*nI5WI z$5nG&+4^g?vZpQneNG?QvmzIAvCSi{GQ8l$Wy4mE7rfY9xXSQ?7ncoNIbQH$bKxq( z3tn6{Y~^^ti_L|r3@>^8jMC2Jz@IbQIR=OeofFL=qC$a{_# zyyW@FZo>;+vL^DL<7K)RGMS!Q6M4_^f|ooW*==~iOV&i* zbG+as&qsC}UhtANk@p-gc**mT-G&#uWKHBf#|vKad}O!b1ut0>dC&2JmpmWYZLQ=b z+qUfUR%$D4VVq@s<~_#?Uh;fox8VgZSrd8B@q(8;ALcf!V8!%Mw2l|N6d5tM;{`9K zhoW`7;HAijxg9TfF+CKm;{`88M$GMa!HemkXdN$jDKcVi#|vIe4@K*E!Ap@5b30z} zVtS}*9ap#tv4j`A;Kgo$Tv{`iGdzE1Ubg?3>+JnWF65FOD|yfHf|ooW*==~iOV&i* zbG+as&qsC}UhtANk@p-gt?wnT|I{}6u=V?JuJ%!6dGtoTV-DKUzCJrU*M-IsS&gl_qza#1xU7~OD7zgDs z)Ul({1L@<`&Us{Ty{fN{bF_Q+#*rS|zJp@Zp@a4MA9K{v$Cu|CAKd?{uCK1?F?Aiu z^(E!HJ#S9jE+$?Zmu;3A__aCz+U2>1N3+*kJ8vd8YkOY1z1|P?Or|o_Ijd~zIUDD? zXfoSU=Q6HcX4pF>)(X)(t{$RSy!W{?h(pcimY?* z{F}}g7o8Wy?}<*8vMgM9-FtFhF<<=`%jfguf7|78-ikYq#+|z^x1VqAj~AxfuzZP- zCmHA$B3bJkP)~(eA?MNo^34|`@LPK)Km$j9+3pP7GF z1&=)gUs8|l@{m_vdD<&trHGS{2y1 z)aNigwif)Mx^5v({^|3}w?K_Q0y%oC?b zGb%A~0pa;6){LeH7#RfSUHGrZpvJ(#@c(})i2ok~ynx~tnpqh*>IE1|4=^zZlpbJl sU|<9Dn-1U>*8|xI1f-h7hGsrH1JFtA{~6eg7=Q$b!vQ1?FxCGD08H#ixBvhE diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5638658568224768 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5638658568224768 deleted file mode 100644 index b7687888d7ab9476f99b440efa060efdf9bcaca2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 35209 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 A00000 diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5764087333519360 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5764087333519360 deleted file mode 100644 index 6196fd6f6525e419f96453dcb849668b8438b9dc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1271 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�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%0D$ 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 diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/init-ack-1.bin b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/init-ack-1.bin deleted file mode 100644 index 89abce3ee75397075dca386bf7df1a3c23765a0c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 444 zcmZQ#VBC{=sB{Yh69WSS7YD<<3yOaZurY7|c?=B<3@itLxPgO#^8o+Bh9;006N8Gw ztF}w!UrnnoOugc|OIU0ArY|;L;{D-UPx3y|O)+mRZD3(wV_*cTWoBS&I0)3l&KTkC z=B`B2LtB;{+$g?3=9knObjXxuiCQ8znWEFn0m!^m$26KO_@U5ri&HCV21GU*#ePM#G(Xd5+eME zR{UE)Jb)B7XiQjEfMpv5y>KnVgL~`@M%eSIdG&=WyS}&zYuRj?4l{BKjIm@1EZo2` z0Oi;KbE*k*EQn_UOvqB8ObiqPf+=PU|NjGNCLk7A<8aP^VSYYKJ5Y>q-j*!@l$XzA diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000000 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000000 deleted file mode 100644 index fd2da797fc8ab5f0c88ad5ccb4063aafb945a984..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 101 zcmZQzWMD|rFgnh{AX9jpf%X4?|J5&J8W9sIuCoi;)WE{P!NAPG*uc!d)^HH0iHCuWft7&) E081Gi%m4rY diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000001 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000001 deleted file mode 100644 index 45b146bf4a144cda031633a802df596b61ea4876..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 421 zcmZQzVqjeInd!j>2ARU+46OhEi%z{{+Q7iTasY@MI2bq&@E>ewVqjosU}8`yX7-!$ z;oi-sbssamYdV#yjwmL6Hd$tJIAw{Zztff{Rt+o+91P41j19~TYz+s2n%EgVyd8aA zb)AA;6b$tYfg%jNHnAXz;pS;}FrDxUOo0iO<3<`Fw_G_{8H^BRU|nvmSs9EF zWnf?ha)4q%=wcxL?&HE8j7Sndc9MqCaTW%d!s86A|Nr~1ei_riz`$|t;J1OOuO0*e3u diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000009 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000009 deleted file mode 100644 index 5b06d525544bbd68fc1c67bc959a66ae2d8f6c2c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17 XcmZQzW?&HTU;Q$cL8kCH0}ucJAIbx$ diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000010 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000010 deleted file mode 100644 index 31c5831136689d089037cad11e0eccd94b5a6cc5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 33 ocmZQzU}li>U;Q$UfsuiUfq}u;t+c8tGcR37p)xhGSdoDN0CgV+r2qf` diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000011 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000011 deleted file mode 100644 index d43bd7ddbcfd23865d72bf4d543ba0fcce4f7f70..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17 XcmZQzW?&HTU;Q$UL8kCH0}ucJAJYS= diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000012 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000012 deleted file mode 100644 index adea816bb7703475eb8815887ca0ed2920c993b7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 25 fcmZQ*Vqg$s;AIfIE!hH> diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000017 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000017 deleted file mode 100644 index 5c32e8fd553c5bc86119feb11b88c911aa3f1d37..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 41 mcmZQzW?&HTU;Q$kL8kCH0|+oPh>1?UWX8Y<<{5!0AOQfH$OWnZ diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000018 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000018 deleted file mode 100644 index cad34eb596975bf704912fb1548a6d6199849ccf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 37 ncmZQzW?&EyoqEZPL8kCH0|+oP2>P#nnZUpZgbWNuOh5tvdgcYE diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000019 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000019 deleted file mode 100644 index 47925c52910bc01a96098ff75893f051197226c1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17 XcmZQzW?&HTU;Q$HL8kCH0}ucJALRq9 diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000020 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000020 deleted file mode 100644 index c01b3cb230950afd93f7c003c095a2c479e4caa8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 33 kcmZQzU}uo^U;Q$Xfsp|Oj6D)_a`F}2N~@|;ixhzZ0CLXL28{xm diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/shutdown-ack-1.bin b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/shutdown-ack-1.bin deleted file mode 100644 index 307a4f9d3c80596c11aac856f392a9e0fffe950b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4 Lcmd;JU|<0N04M+r diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/shutdown-complete-1.bin b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/shutdown-complete-1.bin deleted file mode 100644 index d1e11efca0b43934dc1555e35064abfbab965c81..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4 Lcmd;MU|<0N06+i} diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/timeout-00b96dd43f1251438bb44daa0a5a24ae4df5bce5 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/timeout-00b96dd43f1251438bb44daa0a5a24ae4df5bce5 deleted file mode 100644 index 0a8a27101ab64e294816ed23416b846d262bcf8f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 995 zcmZo?V&Ir}LGdd)0~UHM!-IS542C;)FmN8=-`UW_z`)SJ#GvBvsx7Pht6BAhsaITg z32RN?^u@+Yygz*FN!};ADOIhdO$>|-3{ngY%oFET0kuE?6Oa;E<6s2lK{K6yi+2Ijvp z7jT*b3}S}ZhR;i(2BVpWun?pU381ONa2HkWMRK1Rss7yn3O9R*`@nuh@&u4cYkxRC xGi7i{1X={L8wt?bUWkW*7J~hZh+mxHhfo5Hy1qUJ28ap3ewVgM>)Vo-T=Zr7bP zO^rJrOv%mE3>2)IZ?tpz3ublhIqzOyeavoA+rYxW!NAPG*uc!d)^HH0i3iAMWncqB Z5iO=;3mill1c9O;&G7ywPfCd>c; diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000001 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000001 deleted file mode 100644 index 2db572e9e4c410b35f34197a7024e994ada7bd40..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 505 zcmZQzVqpBSjsMXx2ARU+42=K(*H!KO-@w4YasY@MI2bq&@E>ewVqjosU}8{N+5adj zuxXVa%T~M6wxlrO@2YB&pB5Th*XjI;>vHBl*TBNS!NAPG*uc!d)^HH0iH$)-i|N<` z2T=w=AP)qZ7+4uNuAHn4Vqj-%@OJcd)pZJXQ83gq1WB?O$ATyZHw#uUo$v}wfr%Yg z^h`nS1nLb&h%x|;V_*QAha?Em&A_l`fp8}yBSHemY%tZkvIFMVBeUQBY{22yH|KWU zS<}?G^TCwdOwB;Ss`*Acr@vrU=brQK_0`Ah7PT0Dy&R#X$Tu3xqov84)r-W`n8Tl^qN+g~u5f|NlQS`|ZyLptT2pxPgO#^8o+B zh9;o$1||lTH|KWUS<}?G^TCwdOwB;Ss`*Acr@vrU=brQK_0`Ah7PSp53>*y1Ku<6; zur(Y6YT^O%SsB=XP(+LA*a8Pp20@@G2s8u5IY91aVqp9M@&nBNx~iT38*tdavj0(5 zVACo;maTTBZAoFm-&NHlKP@!2uG9Gw*X7KA4#R#-dz+y42L15wdUUgrk;`O#$%T)n L%5-1Nxn2YSc++PF diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000003 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000003 deleted file mode 100644 index 737a802318a25ef61a2c985299e207d526383886..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 15 OcmZSJW?*1pfCB&k)c_Cx diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000004 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000004 deleted file mode 100644 index 840eedf30e5e61a385f0deb6bbf4834a296d5cb5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 45 wcmZQzVPMc|lIEXR`GC)8R0J{(fH~;_u diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000005 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000005 deleted file mode 100644 index e540d44eb18c8633e27ed44e6215f3206a20ed4e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 45 wcmZQzVPMcF^**jwqRw55`OG7p(w&sMuvewi|N<`2T=w=1_)>d0H1OPQUCw| diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000006 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000006 deleted file mode 100644 index 00019dc491cb3f43f36de21e6a1fbbe3e4a0cf0b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 45 wcmZQzWnj=@U}Vr>F^**jwqRw55`OG7p(w&sMuvewi|N<`2T=w=1_)>d0H2-*Qvd(} diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000007 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000007 deleted file mode 100644 index c7f499d34e6ec4ad1ee455454ac8553583c13e5b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1041 ecmZQzU}h0GGW+dM1_)4h90j8xFd70QHUt3FlLwOk diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000008 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000008 deleted file mode 100644 index 94d5c0bd0024fe4b3d1db13497c8580ee40f4525..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1041 hcmZQzU}h0GGW+c>1_lO3AXaxA1*0J_8UiCW1OVKj2bBN- diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000009 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000009 deleted file mode 100644 index 4d49f378e3faa97698845c689f26c699bc343acc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1041 hcmZQzU}h0GGW+ds1_lNuAXaxA1*0J_8UiCW1OVi(2bTZ< diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000010 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000010 deleted file mode 100644 index 2829bb6aea87d49f086e394ee0d5e1d68a9752d4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1041 hcmZQz;ARmxGW+cx1_lOZAXaxA1*0J_8UiCW1ON?02cZA} diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000011 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000011 deleted file mode 100644 index a39993144b1947a8b42d06e9e32f6d8ebd24dc32..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1041 hcmZQz;ARmxGW+dc1_lNeAXaxA1*0J_8UiCW1OOFM2crN0 diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000012 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000012 deleted file mode 100644 index c81a1768b4a4af5e75782515efc4327fe8207c8f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 45 wcmZQzWnj=@U}Vs^XcWsJ=EuU&K8=${aLvXeGBOMdT1>|lIEXR`GC)8R0J}U0IRF3v diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000013 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000013 deleted file mode 100644 index 9457b75de69c5991afb9c7f6fde68abe4bc20806..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17 XcmZQzW?&FFGW+dM2AQ1W3_t(?DjWo; diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000014 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000014 deleted file mode 100644 index 777f11b5a51ff3c3933efe3fd320228e3fab033c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17 XcmZQzW?&FFGW+ds2ATBZ3_t(?Di8#v diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000015 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000015 deleted file mode 100644 index e749a26e054d0aa86edf076878e7c75003d1b56c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17 XcmZQzW?&FFGW+cx2AQ1W3_t(?DmMhH diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000016 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000016 deleted file mode 100644 index ed8f9fc0a63ec59ab223aeb79f8eeebb2e4c0bcd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17 XcmZQzW?&FFGW+dc2AQ1W3_t(?DnJCR diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000017 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000017 deleted file mode 100644 index 1b15ab1999b63355d27a40ba3cb877f314751b4a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9 QcmZQzXJFu{tJ?Vw00ut-zW@LL diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000018 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000018 deleted file mode 100644 index 634f886604efc805206886f0caa72521d2b1266c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 15 OcmZSJU|?WjfCB&ks{joE diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000019 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000019 deleted file mode 100644 index 9f51d75c3e753b58db25b76bd0ee98574af7beeb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5 McmZSJV_;wb002P%6951J diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000020 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000020 deleted file mode 100644 index 69d60102b3da59cfd8291acd6b54e099cbe75c26..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 137 zcmZQzWMJqx^`NeYL8kCH1LOby=XfTrJix}l!N9KmIK+Rjp~-=v zfr&xo{zda<^hHQE70edes6~Q eJ$RtQ-gME@ucaT3IE%OD)|}$ykv%fy(k1{H4T=r` diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000022 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000022 deleted file mode 100644 index 22317e0ca159fc9a9f31c8fc5a4c7f162bbbd23c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 401 zcmZSJVql!$?da>O>lEywV5n!v00f4{u^@_JmJt`2PIv{Tz(h~ogHxt6(p#>atPDno zGBB_LIY6->bTJVB(L~`+Mn;4TklAtSL0u1nOyO|`#{d7%@l0HKfQ^BJfr0%<0|Nug z0U&PRVBkJ*i2q$ETaQ$jC4-XfYjI;2_E%$N&LN0P4{Rxc~qF diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000025 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000025 deleted file mode 100644 index 9afda34a7fd34b92f95a941541e6ef3cb87c1520..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 45 wcmZQzVPMc&DMWyHmB&p_g`yV0y)GBOMdT1>|lIEXR`GC)8x0K&-#ssI20 diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000026 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000026 deleted file mode 100644 index 85ddaf14b49649aa3e08a599ead653a0178e2463..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 45 wcmZQzWnj=@U}VrRG>&DMWyHmB&p_g`yV0y)GBOMdT1>|lIEXR`GC)8x0K)YMs{jB1 diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000027 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000027 deleted file mode 100644 index ce9027d9aa31d8fe58d80bcb17f10f3b7802f734..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1145 zcmZQ@U}Ly(j%VUZ1_V%d90tIF1?;a?2yZbk4g+sFLjAQG$zM#v$X{!a{KY(s{IwRz WUo6AIU#tucz;a_9lD}9<@fQGqEf(Ma diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000028 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000028 deleted file mode 100644 index be15835731725627900eb479edb188aaa663a05b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1361 zcmZQ@U}Ly(j%VU}1_)pTQtFPw064IK{j~wfUyQ@RTaHkFZA9`H(=hVaCM16`4$ETaQ$jC4-XfYjI;2_E%$N&LN0P6h-x&QzG diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000031 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000031 deleted file mode 100644 index bb605880b38d74716c1f6a715a856a5ce1a5e7f7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1361 zcmZQ@;A6OPj%VU-1_)pVQtFPw066e~{j~?lUyQ@RTaHkF?M3nz(=hVaJ|urJ4r8jS+B diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000036 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000036 deleted file mode 100644 index cdd9e2b5c30e024ce796095f6cc13f7099a1490e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17 XcmZQzW?&FF$20L5gG}&o1|R?c9(DtJ diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000037 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000037 deleted file mode 100644 index e9db8bb4e789e17abde44c4f0d919b23b8fb2559..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9 QcmZQzXJFt6tzXOn00e{qivR!s diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000038 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000038 deleted file mode 100644 index 634f886604efc805206886f0caa72521d2b1266c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 15 OcmZSJU|?WjfCB&ks{joE diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000039 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000039 deleted file mode 100644 index 9f51d75c3e753b58db25b76bd0ee98574af7beeb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5 McmZSJV_;wb002P%6951J diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000040 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000040 deleted file mode 100644 index 2e9f0c11aed33b3d140f4a157304739e5085e39f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 137 zcmZQzWMJrs^?ml7L8kCH1LOby2gF!y4zMwBFfgzmX<%SrIRL~B91PqC4)GssXmVg^ zU}8}D%DsaB)rPlO@t;&*C$lf$zj5m?w^@CoPM81DgAFs)1RGd@`k5IR8<-i`85#~U hFz^8RtPE^GD5Ax5Y=MI)gCGM0Gy}ysuAHn41^|>vCW`<7 diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000041 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000041 deleted file mode 100644 index 25d1d45bf99c9c50aafffa08d9743577e449d759..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 529 zcmZQzVqg;Z7KmIK+Rjp~-=v zfr&w7#fkNW+sofOAL`wrw#Hj9Xt9gY=EKhgcvwE|ox0W4B)5SDsGpgEv4NR^ouT0% z0|Og_h!)ea1rDMNf(#JQ#K6kHaph!X5Cc2o1aC)QS6!!I7X?E-Ly)wmaV%KXj#M5n zo$v}wfr;nOd}BfG1?mk(h%x|;V_*QAha?CR0|8?O;Z8O>lEywV5n!v00f@Ku^@_JM=B4PPIv{Tz{K-szOf(UPPSb+Ss9EF zWnf?ha)4q%=wcwgF@ta?BO^iv$n1#qefFF|rtmle?Yy@LPMhPPSqpHyEbvoGMkaqBO)S$(5Um;cd&4KvjQ z8(4t)nHd-xm>Jj^8V)ir@BsO&3~WFsqQ!J4x$W#3=q%+0LttLx&QzG diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000045 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000045 deleted file mode 100644 index 702654ceff42c25bf515a31e30ce30e3a68634b3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 45 wcmZQzVPMc&E1k;=o+=eBvm9xIkpGBOMdT1>|lIEXR`GC)8x0L}9V>Hq)$ diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000046 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000046 deleted file mode 100644 index 768a67182c5622b409c7235e70afbfa2c95d5553..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 45 wcmZQzWnj=@U}VtnG>&E1k;=o+=eBvm9xIkpGBOMdT1>|lIEXR`GC)8x0L~u>>i_@% diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000047 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000047 deleted file mode 100644 index 66de2ee5546d3b09825b9513104e8282b3d6a2b0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1205 zcmZSJXJF7^U|?W&Y&auQ)A+!#p{vS0f@PlWR-ac~A4EFm&3$<8;yU@lEe>o98xDxE z+5pwUfV$%#1`aG>_u9f73#1tbv2z`v?zKa5FVhfkuRW4`nTLRT9gy71G6dY~h~!?@ ULG4~vh8$q|;DqE}Hd?tC01q7^hX4Qo diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000048 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000048 deleted file mode 100644 index 6d54d1a8837647a48c15000361c71975ff1cee83..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1381 zcmZSJXJF7^U|?Xjc`Z8EW4F@b8}?6RJ=w0=9$X;x`rA~UvcF}DuR0%?{&!$w*l<9M z)fuQ31Q>x>-Ej~D2Ntk4x$W#3=q%+0LvH%y8r+H diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000050 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000050 deleted file mode 100644 index 248cc34bc3ac1b3d2e1f4976230564ba54fff454..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1029 zcmZSJXJF7^U|?XrnX`V{y%w#YsImdIRunPYa#As8pO_Zgu2%k$-T@&z`cG*?qwMQ?)67fQ1G->tTv3xCCVTXEM5cS!4Om=~Y=WXA#hFAi)B8xDxE z1_ITB05cG)I}T#tzyfw}5ZJX4_c9J*=Q={&8;s;$rXk?o5G4094*~avBDt4k2)H*4 X$-S(D+P$m{Il%HE9Lc?Gv~n*1Srj8v diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000052 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000052 deleted file mode 100644 index df60fbebe106a292a4d9a73435651a863a5d4908..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17 WcmZQzW?&FFAjay%Ad_^Q0SEvTdIEL; diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000053 b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000053 deleted file mode 100644 index 2463c07b4b0ae793cd5ece8af5235c07e5b81cc0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1205 zcmZSJXJF7^U|?YGlH}hMIjQ63W2x`V5)uw?Bf6`1@lRNMf59YX&W+m@_B-$~Y&ams z8Ua)b0xUqR?l_2n0}t4}kzm(C+{-wKo$Cm7ZxoVynTCLSqmkUpJOtbugXCV8A>iIv XB=@ooYWMOo$L;sNqm85jVux)j0y diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/build-fuzzer.sh b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/build-fuzzer.sh deleted file mode 100755 index e6cb6bc714..0000000000 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/build-fuzzer.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env bash -set -e - -NPROC=1 - -# OS detection -if [ "$(uname)" = "Linux" ]; then - NPROC=$(nproc) - CC=clang-9 -elif [ "$(uname)" = "Darwin" ]; then - NPROC=$(sysctl -n hw.ncpu) - CC=/usr/local/opt/llvm/bin/clang -elif [ "$(uname)" = "FreeBSD" ]; then - NPROC=$(sysctl -n hw.ncpu) - CC=clang-devel -else - echo "Error: $(uname) not supported, sorry!" - exit 1 -fi - -# Check if we have a compiler -if ! [ -x "$(command -v $CC)" ]; then - echo "Error: $CC is not installed!" >&2 - exit 1 -fi - -echo "OS :" $(uname) -echo "CC :" $CC -echo "NP :" $NPROC - -# Go to script directory -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -cd "$SCRIPT_DIR" -cd ".." - -pwd - -# Find and then delete all files under current directory (.) that: -# 1. contains "cmake" (case-&insensitive) in its path (wholename) -# 2. name is not CMakeLists.txt -find . -iwholename '*cmake*' -not -name CMakeLists.txt -delete - -# Build with ASAN / MSAN -cmake -Dsctp_build_fuzzer=1 -Dsctp_build_programs=0 -Dsctp_invariants=1 -Dsctp_sanitizer_address=1 -DCMAKE_LINKER="$CC" -DCMAKE_C_COMPILER="$CC" -DCMAKE_BUILD_TYPE=Debug . -#cmake -Dsctp_build_fuzzer=1 -Dsctp_build_programs=0 -Dsctp_invariants=1 -Dsctp_sanitizer_memory=1 -DCMAKE_LINKER="$CC" -DCMAKE_C_COMPILER="$CC" -DCMAKE_BUILD_TYPE=RelWithDebInfo . - -make -j"$NPROC" diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/check-input.sh b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/check-input.sh deleted file mode 100755 index 31f117a0f5..0000000000 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/check-input.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env bash - -# -# usage: check-input.sh input_data -# - -set -e # stop on error -set -u # uinitialized variables -> error! - -#make - -C_RED='\033[0;31m' # RED -C_GRN='\033[0;32m' # RED -C_NOC='\033[0m' # No Color - -echo "Fuzzer Input: $1" -echo "########## Beginning Fuzzer Chain" -echo "" - -set +e -./fuzzer_connect_multi_verbose -timeout=30 $1 > $1.log 2>&1 -FUZZER_RETVAL=$? -set -e - -echo "Fuzzer returncode: $FUZZER_RETVAL" - -if [ "$FUZZER_RETVAL" -eq "0" ]; then - echo -e "$C_RED" - echo "$1 - NOT REPRODUCABLE" - echo -e "$C_NOC" -elif [ "$FUZZER_RETVAL" -eq "77" ]; then - echo -e "$C_GRN" - echo "$1 - REPRODUCABLE" - echo -e "$C_NOC" -else - echo "Unexpected return code: $FUZZER_RETVAL - handle with care..!" - #exit -fi - -grep "# SCTP_PACKET" $1.log > $1.pcap-log -text2pcap -n -l 248 -D -t "%H:%M:%S." $1.pcap-log $1.pcapng -rm $1.pcap-log - -echo "" -echo "LOG: $1.log" -echo "PCAP: $1.pcapng" -echo "" - -# Open Wireshark if we have an X session -#if [ -z ${DISPLAY+x} ]; then - #echo "\$DISPLAY unset, skipping wireshark" -#else - #wireshark $1.pcapng -#fi - -exit $FUZZER_RETVAL diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/crashtest.py b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/crashtest.py deleted file mode 100755 index ce51e0af06..0000000000 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/crashtest.py +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env python3 -import glob -import subprocess -import os -import re - -reportdir = "reports/" -fuzzer = "./fuzzer_connect_multi" - -class bcolors: - HEADER = '\033[95m' - OKBLUE = '\033[94m' - OKGREEN = '\033[92m' - WARNING = '\033[93m' - FAIL = '\033[91m' - ENDC = '\033[0m' - BOLD = '\033[1m' - UNDERLINE = '\033[4m' - - -print("Testing crashfiles") - -FNULL = open(os.devnull, "w") -crashfiles = [] -crashfiles.extend(glob.glob("*")) -pattern = re.compile("^(leak-|timeout-|crash-)\w+$") - -filecounter = 1 - -FNULL = open(os.devnull, 'w') - -for filename in crashfiles: - - if not pattern.match(filename): - continue - - fuzzer_retval = subprocess.call(["./check-input.sh", filename, "batchmode"], stdout=FNULL, stderr=subprocess.STDOUT) - - if fuzzer_retval == 0: - print(bcolors.FAIL, "[", filecounter, "]", filename,"- not reproducable", bcolors.ENDC) - else: - print(bcolors.OKGREEN, "[", filecounter, "]", filename, "- reproducable", bcolors.ENDC) - - filecounter = filecounter + 1 diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/fuzzer_connect.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/fuzzer_connect.c deleted file mode 100644 index 79505db6e4..0000000000 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/fuzzer_connect.c +++ /dev/null @@ -1,478 +0,0 @@ -/* - * Copyright (C) 2017-2019 Felix Weinrank - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include "../programs/programs_helper.h" - -//#define FUZZ_VERBOSE -#define FUZZ_INTERLEAVING -//#define FUZZ_EXPLICIT_EOR -#define FUZZ_STREAM_RESET -#define FUZZ_DISABLE_LINGER - -#define BUFFER_SIZE 4096 -#define COMMON_HEADER_SIZE 12 - -static uint32_t assoc_vtag = 0; - -#ifdef FUZZ_VERBOSE -#define fuzzer_printf(...) \ - do { \ - fprintf(stderr, "[P]"); \ - debug_printf_runtime(); \ - fprintf(stderr, __VA_ARGS__); \ - } while (0) -#else -#define fuzzer_printf(...) -#endif - -static void -dump_packet(const void *buffer, size_t bufferlen, int inout) { -#ifdef FUZZ_VERBOSE - static char *dump_buf; - if ((dump_buf = usrsctp_dumppacket(buffer, bufferlen, inout)) != NULL) { - fprintf(stderr, "%s", dump_buf); - usrsctp_freedumpbuffer(dump_buf); - } -#endif // FUZZ_VERBOSE -} - -static int -conn_output(void *addr, void *buf, size_t length, uint8_t tos, uint8_t set_df) -{ - struct sctp_init_chunk *init_chunk; - const char *init_chunk_first_bytes = "\x13\x88\x13\x89\x00\x00\x00\x00\x00\x00\x00\x00\x01"; - // Looking for the outgoing VTAG. - // length >= (COMMON_HEADER_SIZE + 16 (min size of INIT)) - // If the common header has no VTAG (all zero), we're assuming it carries an INIT - if ((length >= (COMMON_HEADER_SIZE + 16)) && (memcmp(buf, init_chunk_first_bytes, COMMON_HEADER_SIZE) == 0)) { - init_chunk = (struct sctp_init_chunk*) ((char *)buf + sizeof(struct sctp_common_header)); - fuzzer_printf("Found outgoing INIT, extracting VTAG : %u\n", init_chunk->initiate_tag); - assoc_vtag = init_chunk->initiate_tag; - } - - dump_packet(buf, length, SCTP_DUMP_OUTBOUND); - return (0); -} - - -static void -handle_upcall(struct socket *sock, void *arg, int flgs) -{ - fuzzer_printf("handle_upcall()\n"); - int events = usrsctp_get_events(sock); - - while (events & SCTP_EVENT_READ) { - struct sctp_recvv_rn rn; - ssize_t n; - struct sockaddr_in addr; - char *buf = calloc(1, BUFFER_SIZE); - int flags = 0; - socklen_t len = (socklen_t)sizeof(struct sockaddr_in); - unsigned int infotype = 0; - socklen_t infolen = sizeof(struct sctp_recvv_rn); - memset(&rn, 0, sizeof(struct sctp_recvv_rn)); - n = usrsctp_recvv(sock, buf, BUFFER_SIZE, (struct sockaddr *) &addr, &len, (void *)&rn, &infolen, &infotype, &flags); - fuzzer_printf("usrsctp_recvv() - returned %zd\n", n); - - if (flags & MSG_NOTIFICATION) { - fuzzer_printf("NOTIFICATION received\n"); -#ifdef FUZZ_VERBOSE - handle_notification((union sctp_notification *)buf, n); -#endif // FUZZ_VERBOSE - } else { - fuzzer_printf("DATA received\n"); - } - - free(buf); - - if (n <= 0) { - break; - } - - events = usrsctp_get_events(sock); - } -} - - -int -initialize_fuzzer(void) { -#ifdef FUZZ_VERBOSE - usrsctp_init(0, conn_output, debug_printf_stack); -#else // FUZZ_VERBOSE - usrsctp_init(0, conn_output, NULL); -#endif // FUZZ_VERBOSE - - usrsctp_enable_crc32c_offload(); - -#ifdef SCTP_DEBUG - usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_ALL); -#endif // SCTP_DEBUG - - usrsctp_register_address((void *)1); - - fuzzer_printf("usrsctp initialized\n"); - return (1); -} - - -int -LLVMFuzzerTestOneInput(const uint8_t* data, size_t data_size) -{ - static int initialized; - char *fuzz_packet_buffer; - struct sockaddr_in6 bind6; - struct sockaddr_conn sconn; - struct socket *socket_client; - struct linger so_linger; - struct sctp_event event; - unsigned long i; - struct sctp_common_header* common_header; - uint16_t event_types[] = { - SCTP_ASSOC_CHANGE, - SCTP_PEER_ADDR_CHANGE, - SCTP_REMOTE_ERROR, - SCTP_SEND_FAILED, - SCTP_SHUTDOWN_EVENT, - SCTP_ADAPTATION_INDICATION, - SCTP_PARTIAL_DELIVERY_EVENT, - SCTP_AUTHENTICATION_EVENT, - SCTP_STREAM_RESET_EVENT, - SCTP_SENDER_DRY_EVENT, - SCTP_ASSOC_RESET_EVENT, - SCTP_STREAM_CHANGE_EVENT, - SCTP_SEND_FAILED_EVENT - }; - int enable; - int result; - struct sctp_initmsg initmsg; -#if defined(FUZZ_STREAM_RESET) || defined(FUZZ_INTERLEAVING) - struct sctp_assoc_value assoc_val; -#endif // defined(FUZZ_STREAM_RESET) || defined(FUZZ_INTERLEAVING) - - // WITH COMMON HEADER! - char fuzz_init_ack[] = "\x13\x89\x13\x88\x54\xc2\x7c\x46\x00\x00\x00\x00\x02\x00\x01\xf8" \ - "\xc7\xa1\xb0\x4d\x00\x1c\x71\xc7\x00\x0a\xff\xff\x03\x91\x94\x1b" \ - "\x80\x00\x00\x04\xc0\x00\x00\x04\x80\x08\x00\x09\xc0\x0f\xc1\x80" \ - "\x82\x00\x00\x00\x80\x02\x00\x24\x61\x6c\x7e\x52\x2a\xdb\xe0\xa2" \ - "\xaa\x78\x25\x1e\x12\xc5\x01\x9e\x4c\x60\x16\xdf\x01\x6d\xa1\xd5" \ - "\xcd\xbe\xa7\x5d\xa2\x73\xf4\x1b\x80\x04\x00\x08\x00\x03\x00\x01" \ - "\x80\x03\x00\x07\x00\x80\xc1\x00\x00\x06\x00\x14\x2a\x02\xc6\xa0" \ - "\x40\x15\x00\x11\x00\x00\x00\x00\x00\x00\x00\x83\x00\x05\x00\x08" \ - "\xd4\xc9\x79\x53\x00\x07\x01\x80\x4b\x41\x4d\x45\x2d\x42\x53\x44" \ - "\x20\x31\x2e\x31\x00\x00\x00\x00\x64\x11\x49\x00\x00\x00\x00\x00" \ - "\xac\xde\x0c\x00\x00\x00\x00\x00\x60\xea\x00\x00\x00\x00\x00\x00" \ - "\x00\x00\x00\x00\xb2\xd4\x38\x45\xc7\xa1\xb0\x4d\xd4\xc9\x79\x52" \ - "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05\x00\x00\x00" \ - "\xd4\xc9\x79\x53\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \ - "\x05\x00\x00\x00\x00\x00\x00\x00\xd9\x05\x13\x89\x01\x01\x00\x00" \ - "\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x80\x45\x38\xd4\xb2" \ - "\x00\x1c\x71\xc7\x00\x01\xff\xff\xac\x40\x9b\x94\x80\x00\x00\x04" \ - "\xc0\x00\x00\x04\x80\x08\x00\x09\xc0\x0f\xc1\x80\x82\x00\x00\x00" \ - "\x80\x02\x00\x24\xc8\x24\x46\x8c\x7e\x88\x2e\xb7\x88\x8b\xdd\xa1" \ - "\x55\x8b\xb4\xc0\x26\xe3\x21\xbb\xb0\x66\xfd\xb2\xd4\xde\xf9\x77" \ - "\x4f\xe4\x7c\xbf\x80\x04\x00\x08\x00\x03\x00\x01\x80\x03\x00\x07" \ - "\x00\x80\xc1\x00\x00\x0c\x00\x08\x00\x05\x00\x06\x00\x06\x00\x14" \ - "\x2a\x02\xc6\xa0\x40\x15\x00\x11\x00\x00\x00\x00\x00\x00\x00\x82" \ - "\x00\x05\x00\x08\xd4\xc9\x79\x52\x02\x00\x01\xf8\xc7\xa1\xb0\x4d" \ - "\x00\x1c\x71\xc7\x00\x01\xff\xff\x03\x91\x94\x1b\x80\x00\x00\x04" \ - "\xc0\x00\x00\x04\x80\x08\x00\x09\xc0\x0f\xc1\x80\x82\x00\x00\x00" \ - "\x80\x02\x00\x24\x61\x6c\x7e\x52\x2a\xdb\xe0\xa2\xaa\x78\x25\x1e" \ - "\x12\xc5\x01\x9e\x4c\x60\x16\xdf\x01\x6d\xa1\xd5\xcd\xbe\xa7\x5d" \ - "\xa2\x73\xf4\x1b\x80\x04\x00\x08\x00\x03\x00\x01\x80\x03\x00\x07" \ - "\x00\x80\xc1\x00\x00\x06\x00\x14\x2a\x02\xc6\xa0\x40\x15\x00\x11" \ - "\x00\x00\x00\x00\x00\x00\x00\x83\x00\x05\x00\x08\xd4\xc9\x79\x53" \ - "\x64\x30\x8a\xb9\x7c\xe5\x93\x69\x52\xa9\xc8\xd5\xa1\x1b\x7d\xef" \ - "\xea\xfa\x23\x32"; - - // WITH COMMON HEADER! - char fuzz_cookie_ack[] = "\x13\x89\x13\x88\x54\xc2\x7c\x46\x00\x00\x00\x00\x0b\x00\x00\x04"; - - // WITH COMMON HEADER! - char fuzz_abort[] = "\x13\x89\x13\x88\x54\xc2\x7c\x46\x00\x00\x00\x00\x06\x00\x00\x08\x00\x0c\x00\x04"; - - // WITH COMMON HEADER! - char fuzz_i_data[] = "\x13\x89\x13\x88\x54\xc2\x7c\x46\x00\x00\x00\x00" \ - "\x00\x1b\x04\x42\xa3\x58\x90\xe2\xba\x9e\x8c\xfc\x08\x00\x45\x02" \ - "\x04\x34\x00\x00\x40\x00\x40\x84\x9a\x0b\xd4\xc9\x79\x52\xd4\xc9" \ - "\x79\x53\x65\x75\x13\x89\x11\x97\x93\x37\x26\x6c\xb7\x65\x40\x02" \ - "\x04\x14\x96\xff\xad\xc1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \ - "\x00\x27\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \ - "\x41\x41"; - - char fuzz_common_header[] = "\x13\x89\x13\x88\x54\xc2\x7c\x46\x00\x00\x00\x00"; - - fuzzer_printf("LLVMFuzzerTestOneInput()\n"); - - if (!initialized) { - initialized = initialize_fuzzer(); - } - - if (data_size < 5 || data_size > 65535) { - // Skip too small and too large packets - fuzzer_printf("data_size %zu makes no sense, skipping\n", data_size); - return (0); - } - - socket_client = usrsctp_socket(AF_CONN, SOCK_STREAM, IPPROTO_SCTP, NULL, NULL, 0, 0); - assert(socket_client != NULL); - - usrsctp_set_non_blocking(socket_client, 1); - - // all max! - memset(&initmsg, 1, sizeof(struct sctp_initmsg)); - result = usrsctp_setsockopt(socket_client, IPPROTO_SCTP, SCTP_INITMSG, &initmsg, sizeof(struct sctp_initmsg)); - assert(result == 0); - - so_linger.l_onoff = 1; - so_linger.l_linger = 0; - result = usrsctp_setsockopt(socket_client, SOL_SOCKET, SO_LINGER, &so_linger, sizeof(struct linger)); - assert(result == 0); - - memset(&event, 0, sizeof(event)); - event.se_assoc_id = SCTP_ALL_ASSOC; - event.se_on = 1; - for (i = 0; i < (sizeof(event_types) / sizeof(uint16_t)); i++) { - event.se_type = event_types[i]; - result = usrsctp_setsockopt(socket_client, IPPROTO_SCTP, SCTP_EVENT, &event, sizeof(event)); - assert(result == 0); - } - - enable = 1; - result = usrsctp_setsockopt(socket_client, IPPROTO_SCTP, SCTP_RECVRCVINFO, &enable, sizeof(enable)); - assert(result == 0); - - enable = 1; - result = usrsctp_setsockopt(socket_client, IPPROTO_SCTP, SCTP_RECVNXTINFO, &enable, sizeof(enable)); - assert(result == 0); - -#if defined(FUZZ_EXPLICIT_EOR) - enable = 1; - result = usrsctp_setsockopt(socket_client, IPPROTO_SCTP, SCTP_EXPLICIT_EOR, &enable, sizeof(enable)); - assert(result == 0); -#endif // defined(FUZZ_EXPLICIT_EOR) - -#if defined(FUZZ_STREAM_RESET) - assoc_val.assoc_id = SCTP_ALL_ASSOC; - assoc_val.assoc_value = SCTP_ENABLE_RESET_STREAM_REQ | SCTP_ENABLE_RESET_ASSOC_REQ | SCTP_ENABLE_CHANGE_ASSOC_REQ; - result = usrsctp_setsockopt(socket_client, IPPROTO_SCTP, SCTP_ENABLE_STREAM_RESET, &assoc_val, sizeof(struct sctp_assoc_value)); - assert(result == 0); -#endif // defined(FUZZ_STREAM_RESET) - -#if defined(FUZZ_INTERLEAVING) -#if !defined(SCTP_INTERLEAVING_SUPPORTED) -#define SCTP_INTERLEAVING_SUPPORTED 0x00001206 -#endif // !defined(SCTP_INTERLEAVING_SUPPORTED) - enable = 2; - result = usrsctp_setsockopt(socket_client, IPPROTO_SCTP, SCTP_FRAGMENT_INTERLEAVE, &enable, sizeof(enable)); - assert(result == 0); - - memset(&assoc_val, 0, sizeof(assoc_val)); - assoc_val.assoc_value = 1; - result = usrsctp_setsockopt(socket_client, IPPROTO_SCTP, SCTP_INTERLEAVING_SUPPORTED, &assoc_val, sizeof(assoc_val)); - assert(result == 0); -#endif // defined(FUZZ_INTERLEAVING) - - memset((void *)&bind6, 0, sizeof(struct sockaddr_in6)); -#ifdef HAVE_SIN_LEN - bind6.sin6_len = sizeof(struct sockaddr_in6); -#endif // HAVE_SIN_LEN - bind6.sin6_family = AF_INET6; - bind6.sin6_port = htons(5000); - bind6.sin6_addr = in6addr_any; - - result = usrsctp_bind(socket_client, (struct sockaddr *)&bind6, sizeof(bind6)); - assert(result == 0); - - usrsctp_set_upcall(socket_client, handle_upcall, NULL); - - memset(&sconn, 0, sizeof(struct sockaddr_conn)); - sconn.sconn_family = AF_CONN; -#ifdef HAVE_SCONN_LEN - sconn.sconn_len = sizeof(struct sockaddr_conn); -#endif // HAVE_SCONN_LEN - sconn.sconn_port = htons(5001); - sconn.sconn_addr = (void *)1; - - fuzzer_printf("Calling usrsctp_connect()\n"); - result = usrsctp_connect(socket_client, (struct sockaddr *)&sconn, sizeof(struct sockaddr_conn)); - assert(result == 0 || errno == EINPROGRESS); - - if (data[0] & (1 << 0)) { - fuzzer_printf("Injecting INIT-ACK\n"); - - common_header = (struct sctp_common_header*) fuzz_init_ack; - common_header->verification_tag = assoc_vtag; - - dump_packet(fuzz_init_ack, 516, SCTP_DUMP_INBOUND); - usrsctp_conninput((void *)1, fuzz_init_ack, 516, 0); - } - - if (data[0] & (1 << 1)) { - fuzzer_printf("Injecting COOKIE-ACK\n"); - - common_header = (struct sctp_common_header*) fuzz_cookie_ack; - common_header->verification_tag = assoc_vtag; - - dump_packet(fuzz_cookie_ack, 16, SCTP_DUMP_INBOUND); - usrsctp_conninput((void *)1, fuzz_cookie_ack, 16, 0); - } - - // Required: INIT-ACK and COOKIE-ACK - if (data[0] & (1 << 0) && - data[0] & (1 << 1) && - data[0] & (1 << 2)) { - const char *sendbuffer = "Geologie ist keine richtige Wissenschaft!"; - fuzzer_printf("Calling usrsctp_sendv()\n"); - usrsctp_sendv(socket_client, sendbuffer, strlen(sendbuffer), NULL, 0, NULL, 0, SCTP_SENDV_NOINFO, 0); - } - - // Required: INIT-ACK and COOKIE-ACK - if (data[0] & (1 << 0) && - data[0] & (1 << 1) && - data[0] & (1 << 3)) { - fuzzer_printf("Injecting I-DATA\n"); - - common_header = (struct sctp_common_header*) fuzz_i_data; - common_header->verification_tag = assoc_vtag; - - dump_packet(fuzz_i_data, 1102, SCTP_DUMP_INBOUND); - usrsctp_conninput((void *)1, fuzz_i_data, 1102, 0); - } - - // Required: INIT-ACK and COOKIE-ACK - if (data[0] & (1 << 0) && - data[0] & (1 << 1) && - data[0] & (1 << 4)) { - fuzzer_printf("Sending Stream Reset for all streams\n"); - - struct sctp_reset_streams srs; - memset(&srs, 0, sizeof(struct sctp_reset_streams)); - srs.srs_flags = SCTP_STREAM_RESET_INCOMING | SCTP_STREAM_RESET_OUTGOING; - result = usrsctp_setsockopt(socket_client, IPPROTO_SCTP, SCTP_RESET_STREAMS, &srs, sizeof(struct sctp_reset_streams)); - assert(result == 0); - } - - fuzz_packet_buffer = malloc(data_size - 1 + COMMON_HEADER_SIZE); - memcpy(fuzz_packet_buffer, fuzz_common_header, COMMON_HEADER_SIZE); // common header - memcpy(fuzz_packet_buffer + COMMON_HEADER_SIZE, data + 1, data_size - 1); - - common_header = (struct sctp_common_header*) fuzz_packet_buffer; - common_header->verification_tag = assoc_vtag; - - fuzzer_printf("Injecting FUZZER-Packet\n"); - dump_packet(fuzz_packet_buffer, data_size - 1 + COMMON_HEADER_SIZE, SCTP_DUMP_INBOUND); - usrsctp_conninput((void *)1, fuzz_packet_buffer, data_size - 1 + COMMON_HEADER_SIZE, 0); - - free(fuzz_packet_buffer); - - fuzzer_printf("Calling usrsctp_close()\n"); - usrsctp_close(socket_client); -#if 0 - fuzzer_printf("Calling usrsctp_finish()\n"); - while (usrsctp_finish() != 0) { - } - fuzzer_printf("Done!\n"); -#endif - - return (0); -} - - - diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/fuzzer_connect_multi.sh b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/fuzzer_connect_multi.sh deleted file mode 100755 index 4e2f92011a..0000000000 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/fuzzer_connect_multi.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash - -export ASAN_OPTIONS=abort_on_error=1:disable_core=0:unmap_shadow_on_exit=1:disable_coredump=0:detect_leaks=1 -ulimit -c unlimited -mkdir -p CORPUS_CONNECT - -NPROC=1 - -if [[ "$OSTYPE" == "linux-gnu" ]]; then - NPROC=$(nproc) -elif [[ "$OSTYPE" == "darwin"* ]]; then - NPROC=$(sysctl -n hw.ncpu) -elif [[ "$OSTYPE" == "freebsd"* ]]; then - NPROC=$(sysctl -n hw.ncpu) -else - exit 1 -fi - -echo "$NPROC" - - -./fuzzer_connect_multi -jobs=64 -timeout=10 -max_len=32000 CORPUS_CONNECT diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/fuzzer_listen.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/fuzzer_listen.c deleted file mode 100644 index e6e873c06e..0000000000 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/fuzzer_listen.c +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (C) 2017-2019 Felix Weinrank - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "../programs/programs_helper.h" - -#define FUZZ_FAST 1 - -#ifdef FUZZ_VERBOSE -#define fuzzer_printf(...) \ - do { \ - fprintf(stderr, "[P]"); \ - debug_printf_runtime(); \ - fprintf(stderr, __VA_ARGS__); \ - } while (0) -#else -#define fuzzer_printf(...) -#endif - -struct sockaddr_conn sconn; -struct socket *s_l; - -static int -conn_output(void *addr, void *buf, size_t length, uint8_t tos, uint8_t set_df) -{ -#if 0 - char *dump_buf; - if ((dump_buf = usrsctp_dumppacket(buf, length, SCTP_DUMP_OUTBOUND)) != NULL) { - fprintf(stderr, "%s", dump_buf); - usrsctp_freedumpbuffer(dump_buf); - } -#endif - return (0); -} - -static void -handle_upcall(struct socket *sock, void *arg, int flgs) -{ - fuzzer_printf("Listening socket established, implement logic!\n"); - exit(EXIT_FAILURE); -} - -int -init_fuzzer(void) { - static uint8_t initialized = 0; - struct sctp_event event; - uint16_t event_types[] = { - SCTP_ASSOC_CHANGE, - SCTP_PEER_ADDR_CHANGE, - SCTP_SEND_FAILED_EVENT, - SCTP_REMOTE_ERROR, - SCTP_SHUTDOWN_EVENT, - SCTP_ADAPTATION_INDICATION, - SCTP_PARTIAL_DELIVERY_EVENT}; - unsigned long i; - -#if defined(FUZZ_FAST) - if (initialized) { - return 0; - } -#endif - -#ifdef FUZZ_VERBOSE - usrsctp_init(0, conn_output, debug_printf_stack); -#else - usrsctp_init(0, conn_output, NULL); -#endif - - usrsctp_enable_crc32c_offload(); - -#ifdef SCTP_DEBUG - usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_ALL); -#endif - usrsctp_register_address((void *)1); - - if ((s_l = usrsctp_socket(AF_CONN, SOCK_STREAM, IPPROTO_SCTP, NULL, NULL, 0, 0)) == NULL) { - perror("usrsctp_socket"); - exit(EXIT_FAILURE); - } - usrsctp_set_non_blocking(s_l, 1); - - /* Bind the server side. */ - memset(&sconn, 0, sizeof(struct sockaddr_conn)); - sconn.sconn_family = AF_CONN; -#ifdef HAVE_SCONN_LEN - sconn.sconn_len = sizeof(struct sockaddr_conn); -#endif - sconn.sconn_port = htons(5001); - sconn.sconn_addr = (void *)1; - if (usrsctp_bind(s_l, (struct sockaddr *)&sconn, sizeof(struct sockaddr_conn)) < 0) { - perror("usrsctp_bind"); - exit(EXIT_FAILURE); - } - - memset(&event, 0, sizeof(event)); - event.se_assoc_id = SCTP_FUTURE_ASSOC; - event.se_on = 1; - for (i = 0; i < sizeof(event_types)/sizeof(uint16_t); i++) { - event.se_type = event_types[i]; - if (usrsctp_setsockopt(s_l, IPPROTO_SCTP, SCTP_EVENT, &event, sizeof(event)) < 0) { - perror("setsockopt SCTP_EVENT s_l"); - exit(EXIT_FAILURE); - } - } - - /* Make server side passive... */ - if (usrsctp_listen(s_l, 1) < 0) { - perror("usrsctp_listen"); - exit(EXIT_FAILURE); - } - - usrsctp_set_upcall(s_l, handle_upcall, NULL); - - initialized = 1; - - return (0); -} - -int -LLVMFuzzerTestOneInput(const uint8_t* data, size_t data_size) -{ - init_fuzzer(); - - if (data_size < 8 || data_size > 65535) { - // Skip too small and too large packets - return (0); - } - usrsctp_conninput((void *)1, data, data_size, 0); - -#if !defined(FUZZ_FAST) - usrsctp_close(s_l); - while (usrsctp_finish() != 0) { - //sleep(1); - } -#endif - - return (0); -} - - diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/fuzzer_listen.sh b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/fuzzer_listen.sh deleted file mode 100755 index 4a70dec2e3..0000000000 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/fuzzer_listen.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -export ASAN_OPTIONS=abort_on_error=1:disable_core=0:unmap_shadow_on_exit=1:disable_coredump=0 -ulimit -c unlimited -mkdir -p CORPUS_LISTEN -./fuzzer_listen -jobs=32 -timeout=10 -max_len=4086 CORPUS_LISTEN diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/pcap2corpus.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/pcap2corpus.c deleted file mode 100644 index ba178d2442..0000000000 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/fuzzer/pcap2corpus.c +++ /dev/null @@ -1,247 +0,0 @@ -/*- - * Copyright (c) 2017 Michael Tuexen - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -/* - * Compile: cc -Wall -Werror -pedantic pcap2corpus.c -lpcap -o pcap2corpus - * - * Usage: pcap2corpus infile outfile_prefix [expression] - * if no expression, a pcap filter, is provided, sctp is used. - */ -#define _GNU_SOURCE -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static unsigned long nr_read = 0; -static unsigned long nr_decaps = 0; - -#define PRE_PADDING 1 - -struct args { - struct bpf_program bpf_prog; - char *filename_prefix; - int (*is_ipv4)(const void *); - int (*is_ipv6)(const void *); - int linktype; - unsigned int offset; -}; - -/* - * SCTP protocol - RFC4960. - */ -struct sctphdr { - uint16_t src_port; /* source port */ - uint16_t dest_port; /* destination port */ - uint32_t v_tag; /* verification tag of packet */ - uint32_t checksum; /* CRC32C checksum */ - /* chunks follow... */ -} __attribute__((packed)); - -static int -loopback_is_ipv4(const void *bytes) -{ - uint32_t family; - - family = *(const uint32_t *)bytes; - return (family == 2); -} - -static int -loopback_is_ipv6(const void *bytes) -{ - uint32_t family; - - family = *(const uint32_t *)bytes; - return (family == 24 || family == 28 || family == 30); -} - -static int -ethernet_is_ipv4(const void *bytes) -{ - const struct ether_header *ether_hdr; - - ether_hdr = (const struct ether_header *)bytes; - return (ntohs(ether_hdr->ether_type) == ETHERTYPE_IP); -} - -static int -ethernet_is_ipv6(const void *bytes) -{ - const struct ether_header *ether_hdr; - - ether_hdr = (const struct ether_header *)bytes; - return (ntohs(ether_hdr->ether_type) == ETHERTYPE_IPV6); -} - -static void -packet_handler(u_char *user, const struct pcap_pkthdr *pkthdr, const u_char *bytes_in) -{ - struct args *args; - const u_char *bytes_out; - FILE *file; - char *filename; - const struct ip *ip4_hdr_in; - const struct ip6_hdr *ip6_hdr_in; - size_t offset, length; - int null = 0; - - args = (struct args *)(void *)user; - bytes_out = NULL; - if (pcap_offline_filter(&args->bpf_prog, pkthdr, bytes_in) == 0) { - goto out; - } - if (pkthdr->caplen < args->offset) { - goto out; - } - if (args->is_ipv4(bytes_in)) { - offset = args->offset + sizeof(struct ip) + sizeof(struct sctphdr); - if (pkthdr->caplen < offset) { - goto out; - } - ip4_hdr_in = (const struct ip *)(const void *)(bytes_in + args->offset); - if (ip4_hdr_in->ip_p == IPPROTO_SCTP) { - unsigned int ip4_hdr_len; - - ip4_hdr_len = ip4_hdr_in->ip_hl << 2; - offset = args->offset + ip4_hdr_len + sizeof(struct sctphdr); - if (pkthdr->caplen < offset) { - goto out; - } - bytes_out = bytes_in + offset; - length = pkthdr->caplen - offset; - } - } - if (args->is_ipv6(bytes_in)) { - offset = args->offset + sizeof(struct ip6_hdr) + sizeof(struct sctphdr); - if (pkthdr->caplen < offset) { - goto out; - } - ip6_hdr_in = (const struct ip6_hdr *)(bytes_in + args->offset); - if (ip6_hdr_in->ip6_nxt == IPPROTO_SCTP) { - bytes_out = bytes_in + offset; - length = pkthdr->caplen - offset; - } - } -out: - nr_read++; - if (bytes_out != NULL) { - asprintf(&filename, "%s-%06lu", args->filename_prefix, nr_decaps); - file = fopen(filename, "w"); - fwrite(&null, 1, PRE_PADDING, file); - fwrite(bytes_out, length, 1, file); - fclose(file); - free(filename); - nr_decaps++; - } -} - -static char * -get_filter(int argc, char *argv[]) -{ - char *result, *c; - size_t len; - int i; - - if (argc == 3) { - asprintf(&result, "%s", "sctp"); - } else { - len = 0; - for (i = 3; i < argc; i++) { - len += strlen(argv[i]) + 1; - } - len -= 1; - result = malloc(len); - c = result; - for (i = 3; i < argc; i++) { - size_t arg_len; - - arg_len = strlen(argv[i]); - memcpy(c, argv[i], arg_len); - c += arg_len; - if (i < argc - 1) { - *c++ = ' '; - } - } - } - return (result); -} - -int -main(int argc, char *argv[]) -{ - char errbuf[PCAP_ERRBUF_SIZE]; - pcap_t *pcap_reader; - char *filter; - struct args args; - - if (argc < 3) { - fprintf(stderr, "Usage: %s infile outfile_prefix [expression]\n", argv[0]); - return (-1); - } - args.filename_prefix = argv[2]; - pcap_reader = pcap_open_offline(argv[1], errbuf); - if (pcap_reader == NULL) { - fprintf(stderr, "Can't open input file %s: %s\n", argv[1], errbuf); - return (-1); - } - args.linktype = pcap_datalink(pcap_reader); - switch (args.linktype) { - case DLT_NULL: - args.is_ipv4 = loopback_is_ipv4; - args.is_ipv6 = loopback_is_ipv6; - args.offset = sizeof(uint32_t); - break; - case DLT_EN10MB: - args.is_ipv4 = ethernet_is_ipv4; - args.is_ipv6 = ethernet_is_ipv6; - args.offset = sizeof(struct ether_header); - break; - default: - fprintf(stderr, "Datalink type %d not supported\n", args.linktype); - pcap_close(pcap_reader); - return (-1); - } - filter = get_filter(argc, argv); - if (pcap_compile(pcap_reader, &args.bpf_prog, filter, 0, PCAP_NETMASK_UNKNOWN) < 0) { - fprintf(stderr, "Can't compile filter %s: %s\n", filter, pcap_geterr(pcap_reader)); - free(filter); - pcap_close(pcap_reader); - return (-1); - } - free(filter); - pcap_dispatch(pcap_reader, 0, packet_handler, (u_char *)&args); - pcap_close(pcap_reader); - fprintf(stderr, "%lu packets processed\n", nr_read); - fprintf(stderr, "%lu packets decapsulated\n", nr_decaps); - return (0); -} diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/meson.build b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/meson.build index 28a1490d7c..a1d68c134c 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/meson.build +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/meson.build @@ -1,9 +1,17 @@ # Project definition project('usrsctplib', 'c', - version: '1.0.0', - default_options: ['c_std=c99'], + version: '0.9.5.0', + default_options: [ + 'c_std=c99', + 'warning_level=2', + ], meson_version: '>=0.49.0') +# Shared library API and ABI versions +# Notice: shared library version must be in X.Y.Z format only +soversion_full = '2.0.0' +soversion_short = '2' + # Set compiler warning flags compiler = meson.get_compiler('c') if compiler.get_argument_syntax() == 'msvc' @@ -22,8 +30,6 @@ if compiler.get_argument_syntax() == 'msvc' else compiler_args = compiler.get_supported_arguments([ '-pedantic', - '-Wall', - '-Wextra', '-Wfloat-equal', '-Wshadow', '-Wpointer-arith', @@ -58,41 +64,20 @@ add_project_arguments([ system = host_machine.system() if system in ['linux', 'android'] add_project_arguments([ - '-D__Userspace_os_Linux', '-D_GNU_SOURCE', ], language: 'c') elif system == 'freebsd' - add_project_arguments([ - '-D__Userspace_os_FreeBSD', - '-U__FreeBSD__', - ] + compiler.get_supported_arguments([ - '-Wno-address-of-packed-member', - ]), language: 'c') + add_project_arguments(compiler.get_supported_arguments([ + '-Wno-address-of-packed-member', + ]), language: 'c') elif system in ['darwin', 'ios'] add_project_arguments([ - '-D__Userspace_os_Darwin', '-D__APPLE_USE_RFC_2292', ] + compiler.get_supported_arguments([ '-Wno-address-of-packed-member', '-Wno-deprecated-declarations', ]), language: 'c') -elif system == 'dragonfly' - add_project_arguments([ - '-D__Userspace_os_DragonFly', - '-U__DragonFly__', - ], language: 'c') -elif system == 'netbsd' - add_project_arguments([ - '-D__Userspace_os_NetBSD', - '-U__NetBSD__', - ], language: 'c') -elif system == 'openbsd' - add_project_arguments([ - '-D__Userspace_os_OpenBSD', - '-U__OpenBSD__', - ], language: 'c') elif system == 'windows' - add_project_arguments('-D__Userspace_os_Windows', language: 'c') dependencies += compiler.find_library('ws2_32', required: true) dependencies += compiler.find_library('iphlpapi', required: true) if compiler.get_id() == 'gcc' @@ -130,6 +115,11 @@ if have_sys_types and have_netinet_in and have_netinet_ip and have_netinet_ip_ic add_project_arguments('-DHAVE_NETINET_IP_ICMP_H', language: 'c') endif +# Feature: net/route +if compiler.has_header('net/route.h') + add_project_arguments('-DHAVE_NET_ROUTE_H', language: 'c') +endif + # Feature: stdatomic if compiler.has_header('stdatomic.h') add_project_arguments('-DHAVE_STDATOMIC_H', language: 'c') @@ -207,8 +197,8 @@ else dependencies: dependencies, include_directories: include_dirs, install: true, - version: meson.project_version(), - c_args: '-U__APPLE__') + version: soversion_full, + soversion: soversion_short) endif # Declare dependency diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/CMakeLists.txt b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/CMakeLists.txt index d9b89d8238..8b740a2b9f 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/CMakeLists.txt +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/CMakeLists.txt @@ -1,6 +1,6 @@ # # Copyright (C) 2015-2015 Oleg Alexeenkov -# Copyright (C) 2015-2019 Felix Weinrank +# Copyright (C) 2015-2020 Felix Weinrank # # All rights reserved. # @@ -52,7 +52,7 @@ if (CMAKE_SYSTEM_NAME MATCHES "Linux") add_definitions(-D_GNU_SOURCE) endif () -if (CMAKE_SYSTEM_NAME MATCHES "Darwin") +if (CMAKE_SYSTEM_NAME MATCHES "Darwin" OR CMAKE_SYSTEM_NAME MATCHES "iOS") add_definitions(-D__APPLE_USE_RFC_2292) endif () @@ -93,7 +93,6 @@ list(APPEND check_programs echo_server_upcall.c ekr_client.c ekr_loop.c - ekr_loop_offload.c ekr_loop_upcall.c ekr_peer.c ekr_server.c @@ -117,7 +116,16 @@ foreach (source_file ${check_programs}) target_link_libraries( ${source_file_we} - ${programs_link_library} + "usrsctp" ${CMAKE_THREAD_LIBS_INIT} ) + + if (APPLE) + set_target_properties( + ${source_file_we} + PROPERTIES + XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER + com.github.sctplab.usrsctp.${source_file_we} + ) + endif() endforeach () diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/Makefile.am b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/Makefile.am index 794c32e194..51501b5fd8 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/Makefile.am +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/Makefile.am @@ -47,7 +47,6 @@ EXTRA_DIST = \ ekr_client.c \ ekr_server.c \ ekr_loop.c \ - ekr_loop_offload.c \ ekr_loop_upcall.c \ ekr_peer.c \ test_libmgmt.c \ @@ -72,7 +71,6 @@ noinst_PROGRAMS = \ ekr_client \ ekr_server \ ekr_loop \ - ekr_loop_offload \ ekr_loop_upcall \ ekr_peer \ test_libmgmt \ @@ -114,8 +112,6 @@ ekr_peer_SOURCES = programs_helper.c ekr_peer.c ekr_peer_LDADD = ../usrsctplib/libusrsctp.la ekr_loop_SOURCES = programs_helper.c ekr_loop.c ekr_loop_LDADD = ../usrsctplib/libusrsctp.la -ekr_loop_offload_SOURCES = programs_helper.c ekr_loop_offload.c -ekr_loop_offload_LDADD = ../usrsctplib/libusrsctp.la ekr_loop_upcall_SOURCES = programs_helper.c ekr_loop_upcall.c ekr_loop_upcall_LDADD = ../usrsctplib/libusrsctp.la http_client_SOURCES = programs_helper.c http_client.c diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/Makefile.nmake b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/Makefile.nmake index 24e9695ecf..aacfc74e5f 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/Makefile.nmake +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/Makefile.nmake @@ -53,7 +53,6 @@ all: \ ekr_server \ ekr_peer \ ekr_loop \ - ekr_loop_offload \ ekr_loop_upcall \ test_libmgmt \ http_client \ @@ -119,10 +118,6 @@ ekr_loop: $(CC) $(CFLAGS) $(CVARSDLL) -c ekr_loop.c link -out:ekr_loop.exe ekr_loop.obj programs_helper.obj $(LINKFLAGS) -ekr_loop_offload: - $(CC) $(CFLAGS) $(CVARSDLL) -c ekr_loop_offload.c - link -out:ekr_loop_offload.exe ekr_loop_offload.obj programs_helper.obj $(LINKFLAGS) - ekr_loop_upcall: $(CC) $(CFLAGS) $(CVARSDLL) -c ekr_loop_upcall.c link -out:ekr_loop_upcall.exe ekr_loop_upcall.obj programs_helper.obj $(LINKFLAGS) @@ -139,9 +134,9 @@ http_client_upcall: $(CC) $(CFLAGS) $(CVARSDLL) -c http_client_upcall.c link -out:http_client_upcall.exe http_client_upcall.obj programs_helper.obj $(LINKFLAGS) -st_client: - $(CC) $(CFLAGS) $(CVARSDLL) -c st_client.c - link -out:st_client.exe st_client.obj programs_helper.obj $(LINKFLAGS) +st_client: + $(CC) $(CFLAGS) $(CVARSDLL) -c st_client.c + link -out:st_client.exe st_client.obj programs_helper.obj $(LINKFLAGS) clean: del /F client.exe @@ -172,8 +167,6 @@ clean: del /F ekr_peer.obj del /F ekr_loop.exe del /F ekr_loop.obj - del /F ekr_loop_offload.exe - del /F ekr_loop_offload.obj del /F ekr_loop_upcall.exe del /F ekr_loop_upcall.obj del /F test_libmgmt.exe diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/chargen_server_upcall.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/chargen_server_upcall.c index 263bd206c7..152d405914 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/chargen_server_upcall.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/chargen_server_upcall.c @@ -41,10 +41,10 @@ #include #include #ifndef _WIN32 +#include #include #include -#include -#include +#include #include #include #endif @@ -217,14 +217,6 @@ main(int argc, char *argv[]) Sleep(1*1000); #else sleep(1); -#endif - } - usrsctp_close(listening_socket); - while (usrsctp_finish() != 0) { -#ifdef _WIN32 - Sleep(1000); -#else - sleep(1); #endif } return (0); diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/client_upcall.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/client_upcall.c index 9d55a385a6..e29d8fa224 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/client_upcall.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/client_upcall.c @@ -72,7 +72,7 @@ int inputAvailable(void) tv.tv_usec = 0; FD_ZERO(&fds); #if defined(_WIN32) && !defined(__MINGW32__) - FD_SET(_fileno(stdin), &fds); + FD_SET((SOCKET)_fileno(stdin), &fds); select(_fileno(stdin) + 1, &fds, NULL, NULL, &tv); #else FD_SET(STDIN_FILENO, &fds); @@ -308,7 +308,6 @@ main(int argc, char *argv[]) while (!done && !input_done) { if (inputAvailable()) { if (fgets(buffer, sizeof(buffer), stdin) != NULL) { - buffer[strlen(buffer)] = '\0'; usrsctp_sendv(sock, buffer, strlen(buffer), NULL, 0, NULL, 0, SCTP_SENDV_NOINFO, 0); } else { if (usrsctp_shutdown(sock, SHUT_WR) < 0) { diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/daytime_server.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/daytime_server.c index 3e03dc1fbf..c3b157a503 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/daytime_server.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/daytime_server.c @@ -30,7 +30,7 @@ /* * Usage: daytime_server [local_encaps_port] [remote_encaps_port] - * + * * Example * Server: $ ./daytime_server 11111 22222 * Client: $ ./client 127.0.0.1 13 0 22222 11111 @@ -111,10 +111,12 @@ main(int argc, char *argv[]) } time(&now); #ifdef _WIN32 - _snprintf(buffer, sizeof(buffer), "%s", ctime(&now)); + if (_snprintf(buffer, sizeof(buffer), "%s", ctime(&now)) < 0) { #else - snprintf(buffer, sizeof(buffer), "%s", ctime(&now)); + if (snprintf(buffer, sizeof(buffer), "%s", ctime(&now)) < 0) { #endif + buffer[0] = '\0'; + } sndinfo.snd_sid = 0; sndinfo.snd_flags = 0; sndinfo.snd_ppid = htonl(DAYTIME_PPID); @@ -126,13 +128,5 @@ main(int argc, char *argv[]) } usrsctp_close(conn_sock); } - usrsctp_close(sock); - while (usrsctp_finish() != 0) { -#ifdef _WIN32 - Sleep(SLEEP * 1000); -#else - sleep(SLEEP); -#endif - } return (0); } diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/daytime_server_upcall.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/daytime_server_upcall.c index b85cb25677..3d83963cff 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/daytime_server_upcall.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/daytime_server_upcall.c @@ -69,10 +69,12 @@ handle_accept(struct socket *sock, void *data, int flags) } time(&now); #ifdef _WIN32 - _snprintf(buffer, sizeof(buffer), "%s", ctime(&now)); + if (_snprintf(buffer, sizeof(buffer), "%s", ctime(&now)) < 0) { #else - snprintf(buffer, sizeof(buffer), "%s", ctime(&now)); + if (snprintf(buffer, sizeof(buffer), "%s", ctime(&now)) < 0) { #endif + buffer[0] = '\0'; + } sndinfo.snd_sid = 0; sndinfo.snd_flags = 0; sndinfo.snd_ppid = htonl(DAYTIME_PPID); @@ -134,14 +136,6 @@ main(int argc, char *argv[]) Sleep(1*1000); #else sleep(1); -#endif - } - usrsctp_close(sock); - while (usrsctp_finish() != 0) { -#ifdef _WIN32 - Sleep(1000); -#else - sleep(1); #endif } return (0); diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/discard_server.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/discard_server.c index e469b363e3..f8c2a721f2 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/discard_server.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/discard_server.c @@ -86,15 +86,17 @@ receive_cb(struct socket *sock, union sctp_sockstore addr, void *data, #endif case AF_CONN: #ifdef _WIN32 - _snprintf(namebuf, INET6_ADDRSTRLEN, "%p", addr.sconn.sconn_addr); + if (_snprintf(namebuf, INET6_ADDRSTRLEN, "%p", addr.sconn.sconn_addr) < 0) { #else - snprintf(namebuf, INET6_ADDRSTRLEN, "%p", addr.sconn.sconn_addr); + if (snprintf(namebuf, INET6_ADDRSTRLEN, "%p", addr.sconn.sconn_addr) < 0) { #endif + namebuf[0] = '\0'; + } name = namebuf; port = ntohs(addr.sconn.sconn_port); break; default: - name = NULL; + name = "???"; port = 0; break; } @@ -105,7 +107,7 @@ receive_cb(struct socket *sock, union sctp_sockstore addr, void *data, rcv.rcv_sid, rcv.rcv_ssn, rcv.rcv_tsn, - ntohl(rcv.rcv_ppid), + (uint32_t)ntohl(rcv.rcv_ppid), rcv.rcv_context); } free(data); @@ -219,7 +221,7 @@ main(int argc, char *argv[]) rcv_info.rcv_sid, rcv_info.rcv_ssn, rcv_info.rcv_tsn, - ntohl(rcv_info.rcv_ppid), + (uint32_t)ntohl(rcv_info.rcv_ppid), rcv_info.rcv_context, (flags & MSG_EOR) ? 1 : 0); } else { diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/discard_server_upcall.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/discard_server_upcall.c index 881bf0d94e..31d84b3877 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/discard_server_upcall.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/discard_server_upcall.c @@ -128,7 +128,7 @@ handle_upcall(struct socket *sock, void *data, int flgs) rn.recvv_rcvinfo.rcv_sid, rn.recvv_rcvinfo.rcv_ssn, rn.recvv_rcvinfo.rcv_tsn, - ntohl(rn.recvv_rcvinfo.rcv_ppid), + (uint32_t)ntohl(rn.recvv_rcvinfo.rcv_ppid), rn.recvv_rcvinfo.rcv_context); } } @@ -220,14 +220,6 @@ main(int argc, char *argv[]) Sleep(1*1000); #else sleep(1); -#endif - } - usrsctp_close(sock); - while (usrsctp_finish() != 0) { -#ifdef _WIN32 - Sleep(1000); -#else - sleep(1); #endif } return (0); diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/echo_server.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/echo_server.c index f59a99c807..9351447a38 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/echo_server.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/echo_server.c @@ -86,15 +86,17 @@ receive_cb(struct socket *sock, union sctp_sockstore addr, void *data, #endif case AF_CONN: #ifdef _WIN32 - _snprintf(namebuf, INET6_ADDRSTRLEN, "%p", addr.sconn.sconn_addr); + if (_snprintf(namebuf, INET6_ADDRSTRLEN, "%p", addr.sconn.sconn_addr) < 0) { #else - snprintf(namebuf, INET6_ADDRSTRLEN, "%p", addr.sconn.sconn_addr); + if (snprintf(namebuf, INET6_ADDRSTRLEN, "%p", addr.sconn.sconn_addr) < 0) { #endif + namebuf[0] = '\0'; + } name = namebuf; port = ntohs(addr.sconn.sconn_port); break; default: - name = NULL; + name = "???"; port = 0; break; } @@ -105,7 +107,7 @@ receive_cb(struct socket *sock, union sctp_sockstore addr, void *data, rcv.rcv_sid, rcv.rcv_ssn, rcv.rcv_tsn, - ntohl(rcv.rcv_ppid), + (uint32_t)ntohl(rcv.rcv_ppid), rcv.rcv_context); if (flags & MSG_EOR) { struct sctp_sndinfo snd_info; @@ -234,7 +236,7 @@ main(int argc, char *argv[]) rcv_info.rcv_sid, rcv_info.rcv_ssn, rcv_info.rcv_tsn, - ntohl(rcv_info.rcv_ppid), + (uint32_t)ntohl(rcv_info.rcv_ppid), rcv_info.rcv_context, (flags & MSG_EOR) ? 1 : 0); if (flags & MSG_EOR) { diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/echo_server_upcall.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/echo_server_upcall.c index 8ecdfe4c93..0734378516 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/echo_server_upcall.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/echo_server_upcall.c @@ -130,7 +130,7 @@ handle_upcall(struct socket *sock, void *data, int flgs) rn.recvv_rcvinfo.rcv_sid, rn.recvv_rcvinfo.rcv_ssn, rn.recvv_rcvinfo.rcv_tsn, - ntohl(rn.recvv_rcvinfo.rcv_ppid), + (uint32_t)ntohl(rn.recvv_rcvinfo.rcv_ppid), rn.recvv_rcvinfo.rcv_context); if (flags & MSG_EOR) { struct sctp_sndinfo snd_info; @@ -237,14 +237,6 @@ main(int argc, char *argv[]) Sleep(1*1000); #else sleep(1); -#endif - } - usrsctp_close(sock); - while (usrsctp_finish() != 0) { -#ifdef _WIN32 - Sleep(1000); -#else - sleep(1); #endif } return (0); diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/ekr_client.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/ekr_client.c index 6aa045dc5a..50e553edeb 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/ekr_client.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/ekr_client.c @@ -142,7 +142,7 @@ receive_cb(struct socket *sock, union sctp_sockstore addr, void *data, rcv.rcv_sid, rcv.rcv_ssn, rcv.rcv_tsn, - ntohl(rcv.rcv_ppid), + (uint32_t)ntohl(rcv.rcv_ppid), rcv.rcv_context); } free(data); @@ -161,7 +161,7 @@ main(int argc, char *argv[]) #ifdef _WIN32 SOCKET fd; #else - int fd; + int fd, rc; #endif struct socket *s; #ifdef _WIN32 @@ -176,13 +176,13 @@ main(int argc, char *argv[]) #endif if (argc < 4) { - printf("error: this program requires 4 arguments!\n"); + fprintf(stderr, "error: this program requires 4 arguments!\n"); exit(EXIT_FAILURE); } #ifdef _WIN32 if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0) { - printf("WSAStartup failed\n"); + fprintf(stderr, "WSAStartup failed\n"); exit (EXIT_FAILURE); } #endif @@ -190,7 +190,7 @@ main(int argc, char *argv[]) /* set up a connected UDP socket */ #ifdef _WIN32 if ((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) { - printf("socket() failed with error: %d\n", WSAGetLastError()); + fprintf(stderr, "socket() failed with error: %d\n", WSAGetLastError()); exit(EXIT_FAILURE); } #else @@ -206,12 +206,12 @@ main(int argc, char *argv[]) #endif sin.sin_port = htons(atoi(argv[2])); if (!inet_pton(AF_INET, argv[1], &sin.sin_addr.s_addr)){ - printf("error: invalid address\n"); + fprintf(stderr, "error: invalid address\n"); exit(EXIT_FAILURE); } #ifdef _WIN32 if (bind(fd, (struct sockaddr *)&sin, sizeof(struct sockaddr_in)) == SOCKET_ERROR) { - printf("bind() failed with error: %d\n", WSAGetLastError()); + fprintf(stderr, "bind() failed with error: %d\n", WSAGetLastError()); exit(EXIT_FAILURE); } #else @@ -232,7 +232,7 @@ main(int argc, char *argv[]) } #ifdef _WIN32 if (connect(fd, (struct sockaddr *)&sin, sizeof(struct sockaddr_in)) == SOCKET_ERROR) { - printf("connect() failed with error: %d\n", WSAGetLastError()); + fprintf(stderr, "connect() failed with error: %d\n", WSAGetLastError()); exit(EXIT_FAILURE); } #else @@ -247,9 +247,15 @@ main(int argc, char *argv[]) usrsctp_sysctl_set_sctp_ecn_enable(0); usrsctp_register_address((void *)&fd); #ifdef _WIN32 - tid = CreateThread(NULL, 0, &handle_packets, (void *)&fd, 0, NULL); + if ((tid = CreateThread(NULL, 0, &handle_packets, (void *)&fd, 0, NULL)) == NULL) { + fprintf(stderr, "CreateThread() failed with error: %lu\n", GetLastError()); + exit(EXIT_FAILURE); + } #else - pthread_create(&tid, NULL, &handle_packets, (void *)&fd); + if ((rc = pthread_create(&tid, NULL, &handle_packets, (void *)&fd)) != 0) { + fprintf(stderr, "pthread_create: %s\n", strerror(rc)); + exit(EXIT_FAILURE); + } #endif if ((s = usrsctp_socket(AF_CONN, SOCK_STREAM, IPPROTO_SCTP, receive_cb, NULL, 0, &fd)) == NULL) { perror("usrsctp_socket"); @@ -299,7 +305,7 @@ main(int argc, char *argv[]) TerminateThread(tid, 0); WaitForSingleObject(tid, INFINITE); if (closesocket(fd) == SOCKET_ERROR) { - printf("closesocket() failed with error: %d\n", WSAGetLastError()); + fprintf(stderr, "closesocket() failed with error: %d\n", WSAGetLastError()); } WSACleanup(); #else diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/ekr_loop.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/ekr_loop.c index d198beda40..65fdb4a703 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/ekr_loop.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/ekr_loop.c @@ -28,6 +28,10 @@ * SUCH DAMAGE. */ +/* + * Usage: ekr_loop [client_port] [server_port] [crc32c offloading <0/1>] + */ + #ifdef _WIN32 #define _CRT_SECURE_NO_WARNINGS #endif @@ -55,6 +59,8 @@ #define DISCARD_PPID 39 #define NUMBER_OF_STEPS 10 +static uint8_t crc32c_offloading = 0; + #ifdef _WIN32 static DWORD WINAPI #else @@ -68,8 +74,10 @@ handle_packets(void *arg) int *fdp; #endif char *dump_buf; + struct sctp_common_header *hdr; ssize_t length; char buf[MAX_PACKET_SIZE]; + uint32_t received_crc32c, computed_crc32c; #ifdef _WIN32 fdp = (SOCKET *)arg; @@ -83,10 +91,29 @@ handle_packets(void *arg) length = recv(*fdp, buf, MAX_PACKET_SIZE, 0); if (length > 0) { if ((dump_buf = usrsctp_dumppacket(buf, (size_t)length, SCTP_DUMP_INBOUND)) != NULL) { - /* fprintf(stderr, "%s", dump_buf); */ + /* debug_printf_clean("%s", dump_buf); */ usrsctp_freedumpbuffer(dump_buf); } - usrsctp_conninput(fdp, buf, (size_t)length, 0); + + if (crc32c_offloading) { + if ((size_t)length >= sizeof(struct sctp_common_header)) { + hdr = (struct sctp_common_header *)buf; + received_crc32c = hdr->crc32c; + hdr->crc32c = htonl(0); + computed_crc32c = usrsctp_crc32c(buf, (size_t)length); + hdr->crc32c = received_crc32c; + if (received_crc32c == computed_crc32c) { + usrsctp_conninput(fdp, buf, (size_t)length, 0); + } else { + debug_printf("Wrong CRC32c: expected %08x received %08x\n", + ntohl(computed_crc32c), ntohl(received_crc32c)); + } + } else { + debug_printf("Packet too short: length %zd", length); + } + } else { + usrsctp_conninput(fdp, buf, (size_t)length, 0); + } } } #ifdef _WIN32 @@ -100,6 +127,7 @@ static int conn_output(void *addr, void *buf, size_t length, uint8_t tos, uint8_t set_df) { char *dump_buf; + struct sctp_common_header *hdr; #ifdef _WIN32 SOCKET *fdp; #else @@ -111,8 +139,13 @@ conn_output(void *addr, void *buf, size_t length, uint8_t tos, uint8_t set_df) #else fdp = (int *)addr; #endif + if (crc32c_offloading && length >= sizeof(struct sctp_common_header)) { + hdr = (struct sctp_common_header *)buf; + hdr->crc32c = usrsctp_crc32c(buf, (size_t)length); + } + if ((dump_buf = usrsctp_dumppacket(buf, length, SCTP_DUMP_OUTBOUND)) != NULL) { - /* fprintf(stderr, "%s", dump_buf); */ + /* debug_printf_clean("%s", dump_buf); */ usrsctp_freedumpbuffer(dump_buf); } #ifdef _WIN32 @@ -154,13 +187,16 @@ receive_cb(struct socket *sock, union sctp_sockstore addr, void *data, return (1); } -#if 0 static void print_addresses(struct socket *sock) { int i, n; struct sockaddr *addrs, *addr; +#if !defined(HAVE_SA_LEN) + int sa_len; +#endif + debug_printf("Addresses: "); n = usrsctp_getladdrs(sock, 0, &addrs); addr = addrs; for (i = 0; i < n; i++) { @@ -173,7 +209,10 @@ print_addresses(struct socket *sock) sin = (struct sockaddr_in *)addr; name = inet_ntop(AF_INET, &sin->sin_addr, buf, INET_ADDRSTRLEN); - debug_printf("%s:%d", name, ntohs(sin->sin_port)); + debug_printf_clean("%s:%d", name, ntohs(sin->sin_port)); +#if !defined(HAVE_SA_LEN) + sa_len = (int)sizeof(struct sockaddr_in); +#endif break; } case AF_INET6: @@ -184,7 +223,10 @@ print_addresses(struct socket *sock) sin6 = (struct sockaddr_in6 *)addr; name = inet_ntop(AF_INET6, &sin6->sin6_addr, buf, INET6_ADDRSTRLEN); - debug_printf("%s:%d", name, ntohs(sin6->sin6_port)); + debug_printf_clean("%s:%d", name, ntohs(sin6->sin6_port)); +#if !defined(HAVE_SA_LEN) + sa_len = (int)sizeof(struct sockaddr_in6); +#endif break; } case AF_CONN: @@ -192,22 +234,32 @@ print_addresses(struct socket *sock) struct sockaddr_conn *sconn; sconn = (struct sockaddr_conn *)addr; - debug_printf("%p:%d", sconn->sconn_addr, ntohs(sconn->sconn_port)); + debug_printf_clean("%p:%d", sconn->sconn_addr, ntohs(sconn->sconn_port)); +#if !defined(HAVE_SA_LEN) + sa_len = (int)sizeof(struct sockaddr_conn); +#endif break; } default: - debug_printf("Unknown family: %d", addr->sa_family); + debug_printf_clean("Unknown family: %d", addr->sa_family); +#if !defined(HAVE_SA_LEN) + sa_len = (int)sizeof(struct sockaddr); +#endif break; } +#if !defined(HAVE_SA_LEN) + addr = (struct sockaddr *)((char *)addr + sa_len); +#else addr = (struct sockaddr *)((caddr_t)addr + addr->sa_len); +#endif if (i != n - 1) { - debug_printf(","); + debug_printf_clean(","); } } if (n > 0) { usrsctp_freeladdrs(addrs); } - debug_printf("<->"); + debug_printf_clean("<->"); n = usrsctp_getpaddrs(sock, 0, &addrs); addr = addrs; for (i = 0; i < n; i++) { @@ -220,7 +272,10 @@ print_addresses(struct socket *sock) sin = (struct sockaddr_in *)addr; name = inet_ntop(AF_INET, &sin->sin_addr, buf, INET_ADDRSTRLEN); - debug_printf("%s:%d", name, ntohs(sin->sin_port)); + debug_printf_clean("%s:%d", name, ntohs(sin->sin_port)); +#if !defined(HAVE_SA_LEN) + sa_len = (int)sizeof(struct sockaddr_in); +#endif break; } case AF_INET6: @@ -231,7 +286,10 @@ print_addresses(struct socket *sock) sin6 = (struct sockaddr_in6 *)addr; name = inet_ntop(AF_INET6, &sin6->sin6_addr, buf, INET6_ADDRSTRLEN); - debug_printf("%s:%d", name, ntohs(sin6->sin6_port)); + debug_printf_clean("%s:%d", name, ntohs(sin6->sin6_port)); +#if !defined(HAVE_SA_LEN) + sa_len = (int)sizeof(struct sockaddr_in6); +#endif break; } case AF_CONN: @@ -239,34 +297,44 @@ print_addresses(struct socket *sock) struct sockaddr_conn *sconn; sconn = (struct sockaddr_conn *)addr; - debug_printf("%p:%d", sconn->sconn_addr, ntohs(sconn->sconn_port)); + debug_printf_clean("%p:%d", sconn->sconn_addr, ntohs(sconn->sconn_port)); +#if !defined(HAVE_SA_LEN) + sa_len = (int)sizeof(struct sockaddr_conn); +#endif break; } default: - debug_printf("Unknown family: %d", addr->sa_family); + debug_printf_clean("Unknown family: %d", addr->sa_family); +#if !defined(HAVE_SA_LEN) + sa_len = (int)sizeof(struct sockaddr); +#endif break; } +#if !defined(HAVE_SA_LEN) + addr = (struct sockaddr *)((char *)addr + sa_len); +#else addr = (struct sockaddr *)((caddr_t)addr + addr->sa_len); +#endif if (i != n - 1) { - debug_printf(","); + debug_printf_clean(","); } } if (n > 0) { usrsctp_freepaddrs(addrs); } - debug_printf("\n"); + debug_printf_clean("\n"); } -#endif int main(int argc, char *argv[]) { struct sockaddr_in sin_s, sin_c; struct sockaddr_conn sconn; + struct sctp_paddrparams paddrparams; #ifdef _WIN32 SOCKET fd_c, fd_s; #else - int fd_c, fd_s; + int fd_c, fd_s, rc; #endif struct socket *s_c, *s_s, *s_l; #ifdef _WIN32 @@ -274,7 +342,7 @@ main(int argc, char *argv[]) #else pthread_t tid_c, tid_s; #endif - int i, j, cur_buf_size, snd_buf_size, rcv_buf_size; + int i, j, cur_buf_size, snd_buf_size, rcv_buf_size, sendv_retries_left; socklen_t opt_len; struct sctp_sndinfo sndinfo; char *line; @@ -284,28 +352,45 @@ main(int argc, char *argv[]) uint16_t client_port = 9900; uint16_t server_port = 9901; - if (argc == 3) { + if (argc > 1) { client_port = atoi(argv[1]); + } + + if (argc > 2) { server_port = atoi(argv[2]); } - debug_printf("starting program\n"); + if (argc > 3) { + crc32c_offloading = atoi(argv[3]); + } + + debug_printf("Starting program\n"); + debug_printf("Config:\n\tClient Port:\t%d\n\tServer Port:\t%d\n\tCRC32C Calc:\t%s\n", client_port, server_port, crc32c_offloading ? "offloaded" : "NOT offloaded"); #ifdef _WIN32 if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0) { - printf("WSAStartup failed\n"); + debug_printf("WSAStartup failed\n"); exit (EXIT_FAILURE); } #endif usrsctp_init(0, conn_output, debug_printf_stack); + +#ifdef SCTP_DEBUG + usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_NONE); +#endif + + if (crc32c_offloading) { + usrsctp_enable_crc32c_offload(); + } + /* set up a connected UDP socket */ #ifdef _WIN32 if ((fd_c = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) { - printf("socket() failed with error: %d\n", WSAGetLastError()); + debug_printf("socket() failed with error: %d\n", WSAGetLastError()); exit(EXIT_FAILURE); } if ((fd_s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) { - printf("socket() failed with error: %d\n", WSAGetLastError()); + debug_printf("socket() failed with error: %d\n", WSAGetLastError()); exit(EXIT_FAILURE); } #else @@ -334,11 +419,11 @@ main(int argc, char *argv[]) sin_s.sin_addr.s_addr = htonl(INADDR_LOOPBACK); #ifdef _WIN32 if (bind(fd_c, (struct sockaddr *)&sin_c, sizeof(struct sockaddr_in)) == SOCKET_ERROR) { - printf("bind() failed with error: %d\n", WSAGetLastError()); + debug_printf("bind() failed with error: %d\n", WSAGetLastError()); exit(EXIT_FAILURE); } if (bind(fd_s, (struct sockaddr *)&sin_s, sizeof(struct sockaddr_in)) == SOCKET_ERROR) { - printf("bind() failed with error: %d\n", WSAGetLastError()); + debug_printf("bind() failed with error: %d\n", WSAGetLastError()); exit(EXIT_FAILURE); } #else @@ -371,22 +456,26 @@ main(int argc, char *argv[]) } #endif #ifdef _WIN32 - tid_c = CreateThread(NULL, 0, &handle_packets, (void *)&fd_c, 0, NULL); - tid_s = CreateThread(NULL, 0, &handle_packets, (void *)&fd_s, 0, NULL); + if ((tid_c = CreateThread(NULL, 0, &handle_packets, (void *)&fd_c, 0, NULL)) == NULL) { + debug_printf("CreateThread() failed with error: %d\n", GetLastError()); + exit(EXIT_FAILURE); + } + if ((tid_s = CreateThread(NULL, 0, &handle_packets, (void *)&fd_s, 0, NULL)) == NULL) { + debug_printf("CreateThread() failed with error: %d\n", GetLastError()); + exit(EXIT_FAILURE); + } #else - if (pthread_create(&tid_c, NULL, &handle_packets, (void *)&fd_c)) { - perror("pthread_create tid_c"); + if ((rc = pthread_create(&tid_c, NULL, &handle_packets, (void *)&fd_c)) != 0) { + debug_printf_clean("pthread_create tid_c: %s\n", strerror(rc)); exit(EXIT_FAILURE); } - if (pthread_create(&tid_s, NULL, &handle_packets, (void *)&fd_s)) { - perror("pthread_create tid_s"); + if ((rc = pthread_create(&tid_s, NULL, &handle_packets, (void *)&fd_s)) != 0) { + debug_printf_clean("pthread_create tid_s: %s\n", strerror(rc)); exit(EXIT_FAILURE); }; #endif -#ifdef SCTP_DEBUG - usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_NONE); -#endif + usrsctp_sysctl_set_sctp_ecn_enable(0); usrsctp_register_address((void *)&fd_c); usrsctp_register_address((void *)&fd_s); @@ -412,7 +501,18 @@ main(int argc, char *argv[]) perror("usrsctp_getsockopt"); exit(EXIT_FAILURE); } - debug_printf("to %d.\n", cur_buf_size); + debug_printf_clean("to %d.\n", cur_buf_size); + memset(&paddrparams, 0, sizeof(struct sctp_paddrparams)); + paddrparams.spp_address.ss_family = AF_CONN; +#ifdef HAVE_SCONN_LEN + paddrparams.spp_address.ss_len = sizeof(struct sockaddr_conn); +#endif + paddrparams.spp_flags = SPP_PMTUD_DISABLE; + paddrparams.spp_pathmtu = 9000; + if (usrsctp_setsockopt(s_c, IPPROTO_SCTP, SCTP_PEER_ADDR_PARAMS, &paddrparams, sizeof(struct sctp_paddrparams)) < 0) { + perror("usrsctp_setsockopt"); + exit(EXIT_FAILURE); + } if ((s_l = usrsctp_socket(AF_CONN, SOCK_STREAM, IPPROTO_SCTP, receive_cb, NULL, 0, &fd_s)) == NULL) { perror("usrsctp_socket"); exit(EXIT_FAILURE); @@ -435,7 +535,7 @@ main(int argc, char *argv[]) perror("usrsctp_getsockopt"); exit(EXIT_FAILURE); } - debug_printf("to %d.\n", cur_buf_size); + debug_printf_clean("to %d.\n", cur_buf_size); /* Bind the client side. */ memset(&sconn, 0, sizeof(struct sockaddr_conn)); sconn.sconn_family = AF_CONN; @@ -482,6 +582,8 @@ main(int argc, char *argv[]) exit(EXIT_FAILURE); } usrsctp_close(s_l); + print_addresses(s_s); + if ((line = malloc(LINE_LENGTH)) == NULL) { exit(EXIT_FAILURE); } @@ -492,37 +594,41 @@ main(int argc, char *argv[]) sndinfo.snd_assoc_id = 0; for (i = 0; i < NUMBER_OF_STEPS; i++) { - j = 0; if (i % 2) { sndinfo.snd_flags = SCTP_UNORDERED; } else { sndinfo.snd_flags = 0; } - /* Send a 1 MB message */ - debug_printf("usrscp_sendv - step %d - call %d flags %x\n", i, ++j, sndinfo.snd_flags); - if (usrsctp_sendv(s_c, line, LINE_LENGTH, NULL, 0, (void *)&sndinfo, - (socklen_t)sizeof(struct sctp_sndinfo), SCTP_SENDV_SNDINFO, 0) < 0) { - perror("usrsctp_sendv"); - exit(EXIT_FAILURE); - } - /* Send a 1 MB message */ - debug_printf("usrscp_sendv - step %d - call %d flags %x\n", i, ++j, sndinfo.snd_flags); - if (usrsctp_sendv(s_c, line, LINE_LENGTH, NULL, 0, (void *)&sndinfo, - (socklen_t)sizeof(struct sctp_sndinfo), SCTP_SENDV_SNDINFO, 0) < 0) { - perror("usrsctp_sendv"); - exit(EXIT_FAILURE); + for (j = 0; j < 2; j++) { + /* Send a 1 MB message */ + sendv_retries_left = 120; + debug_printf("usrscp_sendv - step %d - call %d flags %x\n", i, j + 1, sndinfo.snd_flags); + while (usrsctp_sendv(s_c, line, LINE_LENGTH, NULL, 0, (void *)&sndinfo, + (socklen_t)sizeof(struct sctp_sndinfo), SCTP_SENDV_SNDINFO, 0) < 0) { + debug_printf("usrsctp_sendv - errno: %d - %s\n", errno, strerror(errno)); + if (errno != EWOULDBLOCK || !sendv_retries_left) { + exit(EXIT_FAILURE); + } + sendv_retries_left--; +#ifdef _WIN32 + Sleep(1000); +#else + sleep(1); +#endif + } } debug_printf("Sending done, sleeping\n"); #ifdef _WIN32 - Sleep(10000); + Sleep(1000); #else - sleep(10); + sleep(1); #endif } free(line); usrsctp_shutdown(s_c, SHUT_WR); while (usrsctp_finish() != 0) { + debug_printf("Waiting for usrsctp_finish()\n"); #ifdef _WIN32 Sleep(1000); #else diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/ekr_loop_offload.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/ekr_loop_offload.c deleted file mode 100644 index 5184bef1d0..0000000000 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/ekr_loop_offload.c +++ /dev/null @@ -1,557 +0,0 @@ -/* - * Copyright (C) 2011-2013 Michael Tuexen - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifdef _WIN32 -#define _CRT_SECURE_NO_WARNINGS -#endif -#include -#include -#include -#include -#include -#ifndef _WIN32 -#include -#include -#include -#include -#include -#include -#else -#include -#include -#endif -#include -#include "programs_helper.h" - -#define MAX_PACKET_SIZE (1<<16) -#define LINE_LENGTH (1<<20) -#define DISCARD_PPID 39 - -#ifdef _WIN32 -static DWORD WINAPI -#else -static void * -#endif -handle_packets(void *arg) -{ -#ifdef _WIN32 - SOCKET *fdp; -#else - int *fdp; -#endif - char *dump_buffer; - struct sctp_common_header *hdr; - ssize_t length; - char buffer[MAX_PACKET_SIZE]; - uint32_t received_crc32c, computed_crc32c; - -#ifdef _WIN32 - fdp = (SOCKET *)arg; -#else - fdp = (int *)arg; -#endif - for (;;) { -#if defined(__NetBSD__) - pthread_testcancel(); -#endif - length = recv(*fdp, buffer, MAX_PACKET_SIZE, 0); - if (length > 0) { - if ((dump_buffer = usrsctp_dumppacket(buffer, (size_t)length, SCTP_DUMP_INBOUND)) != NULL) { - /* fprintf(stderr, "%s", dump_buffer); */ - usrsctp_freedumpbuffer(dump_buffer); - } - if ((size_t)length >= sizeof(struct sctp_common_header)) { - hdr = (struct sctp_common_header *)buffer; - received_crc32c = hdr->crc32c; - hdr->crc32c = htonl(0); - computed_crc32c = usrsctp_crc32c(buffer, (size_t)length); - hdr->crc32c = received_crc32c; - if (received_crc32c == computed_crc32c) { - usrsctp_conninput(fdp, buffer, (size_t)length, 0); - } else { - fprintf(stderr, "Wrong CRC32c: expected %08x received %08x\n", - ntohl(computed_crc32c), ntohl(received_crc32c)); - } - } else { - fprintf(stderr, "Packet too short: length %zu", (size_t)length); - } - } - } -#ifdef _WIN32 - return 0; -#else - return (NULL); -#endif -} - -static int -conn_output(void *addr, void *buffer, size_t length, uint8_t tos, uint8_t set_df) -{ - char *dump_buffer; - struct sctp_common_header *hdr; -#ifdef _WIN32 - SOCKET *fdp; -#else - int *fdp; -#endif - -#ifdef _WIN32 - fdp = (SOCKET *)addr; -#else - fdp = (int *)addr; -#endif - if (length >= sizeof(struct sctp_common_header)) { - hdr = (struct sctp_common_header *)buffer; - hdr->crc32c = usrsctp_crc32c(buffer, (size_t)length); - } - if ((dump_buffer = usrsctp_dumppacket(buffer, length, SCTP_DUMP_OUTBOUND)) != NULL) { - /* fprintf(stderr, "%s", dump_buffer); */ - usrsctp_freedumpbuffer(dump_buffer); - } -#ifdef _WIN32 - if (send(*fdp, buffer, (int)length, 0) == SOCKET_ERROR) { - return (WSAGetLastError()); -#else - if (send(*fdp, buffer, length, 0) < 0) { - return (errno); -#endif - } else { - return (0); - } -} - -static int -receive_cb(struct socket *sock, union sctp_sockstore addr, void *data, - size_t datalen, struct sctp_rcvinfo rcv, int flags, void *ulp_info) -{ - printf("Message %p received on sock = %p.\n", data, (void *)sock); - if (data) { - if ((flags & MSG_NOTIFICATION) == 0) { - printf("Message of length %d received via %p:%u on stream %u with SSN %u and TSN %u, PPID %u, context %u, flags %x.\n", - (int)datalen, - addr.sconn.sconn_addr, - ntohs(addr.sconn.sconn_port), - rcv.rcv_sid, - rcv.rcv_ssn, - rcv.rcv_tsn, - ntohl(rcv.rcv_ppid), - rcv.rcv_context, - flags); - } - free(data); - } else { - usrsctp_deregister_address(ulp_info); - usrsctp_close(sock); - } - return (1); -} - -#if 0 -static void -print_addresses(struct socket *sock) -{ - int i, n; - struct sockaddr *addrs, *addr; - - n = usrsctp_getladdrs(sock, 0, &addrs); - addr = addrs; - for (i = 0; i < n; i++) { - switch (addr->sa_family) { - case AF_INET: - { - struct sockaddr_in *sin; - char buf[INET_ADDRSTRLEN]; - const char *name; - - sin = (struct sockaddr_in *)addr; - name = inet_ntop(AF_INET, &sin->sin_addr, buf, INET_ADDRSTRLEN); - printf("%s:%d", name, ntohs(sin->sin_port)); - break; - } - case AF_INET6: - { - struct sockaddr_in6 *sin6; - char buf[INET6_ADDRSTRLEN]; - const char *name; - - sin6 = (struct sockaddr_in6 *)addr; - name = inet_ntop(AF_INET6, &sin6->sin6_addr, buf, INET6_ADDRSTRLEN); - printf("%s:%d", name, ntohs(sin6->sin6_port)); - break; - } - case AF_CONN: - { - struct sockaddr_conn *sconn; - - sconn = (struct sockaddr_conn *)addr; - printf("%p:%d", sconn->sconn_addr, ntohs(sconn->sconn_port)); - break; - } - default: - printf("Unknown family: %d", addr->sa_family); - break; - } - addr = (struct sockaddr *)((caddr_t)addr + addr->sa_len); - if (i != n - 1) { - printf(","); - } - } - if (n > 0) { - usrsctp_freeladdrs(addrs); - } - printf("<->"); - n = usrsctp_getpaddrs(sock, 0, &addrs); - addr = addrs; - for (i = 0; i < n; i++) { - switch (addr->sa_family) { - case AF_INET: - { - struct sockaddr_in *sin; - char buf[INET_ADDRSTRLEN]; - const char *name; - - sin = (struct sockaddr_in *)addr; - name = inet_ntop(AF_INET, &sin->sin_addr, buf, INET_ADDRSTRLEN); - printf("%s:%d", name, ntohs(sin->sin_port)); - break; - } - case AF_INET6: - { - struct sockaddr_in6 *sin6; - char buf[INET6_ADDRSTRLEN]; - const char *name; - - sin6 = (struct sockaddr_in6 *)addr; - name = inet_ntop(AF_INET6, &sin6->sin6_addr, buf, INET6_ADDRSTRLEN); - printf("%s:%d", name, ntohs(sin6->sin6_port)); - break; - } - case AF_CONN: - { - struct sockaddr_conn *sconn; - - sconn = (struct sockaddr_conn *)addr; - printf("%p:%d", sconn->sconn_addr, ntohs(sconn->sconn_port)); - break; - } - default: - printf("Unknown family: %d", addr->sa_family); - break; - } - addr = (struct sockaddr *)((caddr_t)addr + addr->sa_len); - if (i != n - 1) { - printf(","); - } - } - if (n > 0) { - usrsctp_freepaddrs(addrs); - } - printf("\n"); -} -#endif - -int -main(int argc, char *argv[]) -{ - struct sockaddr_in sin_s, sin_c; - struct sockaddr_conn sconn; -#ifdef _WIN32 - SOCKET fd_c, fd_s; -#else - int fd_c, fd_s; -#endif - struct socket *s_c, *s_s, *s_l; -#ifdef _WIN32 - HANDLE tid_c, tid_s; -#else - pthread_t tid_c, tid_s; -#endif - int cur_buf_size, snd_buf_size, rcv_buf_size; - socklen_t opt_len; - struct sctp_sndinfo sndinfo; - char *line; -#ifdef _WIN32 - WSADATA wsaData; -#endif - uint16_t client_port = 9900; - uint16_t server_port = 9901; - - if (argc == 3) { - client_port = atoi(argv[1]); - server_port = atoi(argv[2]); - } - -#ifdef _WIN32 - if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0) { - printf("WSAStartup failed\n"); - exit (EXIT_FAILURE); - } -#endif - usrsctp_init(0, conn_output, debug_printf_stack); - usrsctp_enable_crc32c_offload(); - /* set up a connected UDP socket */ -#ifdef _WIN32 - if ((fd_c = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) { - printf("socket() failed with error: %d\n", WSAGetLastError()); - exit(EXIT_FAILURE); - } - if ((fd_s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) { - printf("socket() failed with error: %d\n", WSAGetLastError()); - exit(EXIT_FAILURE); - } -#else - if ((fd_c = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { - perror("socket"); - exit(EXIT_FAILURE); - } - if ((fd_s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { - perror("socket"); - exit(EXIT_FAILURE); - } -#endif - memset(&sin_c, 0, sizeof(struct sockaddr_in)); - sin_c.sin_family = AF_INET; -#ifdef HAVE_SIN_LEN - sin_c.sin_len = sizeof(struct sockaddr_in); -#endif - sin_c.sin_port = htons(client_port); - sin_c.sin_addr.s_addr = htonl(INADDR_LOOPBACK); - memset(&sin_s, 0, sizeof(struct sockaddr_in)); - sin_s.sin_family = AF_INET; -#ifdef HAVE_SIN_LEN - sin_s.sin_len = sizeof(struct sockaddr_in); -#endif - sin_s.sin_port = htons(server_port); - sin_s.sin_addr.s_addr = htonl(INADDR_LOOPBACK); -#ifdef _WIN32 - if (bind(fd_c, (struct sockaddr *)&sin_c, sizeof(struct sockaddr_in)) == SOCKET_ERROR) { - printf("bind() failed with error: %d\n", WSAGetLastError()); - exit(EXIT_FAILURE); - } - if (bind(fd_s, (struct sockaddr *)&sin_s, sizeof(struct sockaddr_in)) == SOCKET_ERROR) { - printf("bind() failed with error: %d\n", WSAGetLastError()); - exit(EXIT_FAILURE); - } -#else - if (bind(fd_c, (struct sockaddr *)&sin_c, sizeof(struct sockaddr_in)) < 0) { - perror("bind"); - exit(EXIT_FAILURE); - } - if (bind(fd_s, (struct sockaddr *)&sin_s, sizeof(struct sockaddr_in)) < 0) { - perror("bind"); - exit(EXIT_FAILURE); - } -#endif -#ifdef _WIN32 - if (connect(fd_c, (struct sockaddr *)&sin_s, sizeof(struct sockaddr_in)) == SOCKET_ERROR) { - printf("connect() failed with error: %d\n", WSAGetLastError()); - exit(EXIT_FAILURE); - } - if (connect(fd_s, (struct sockaddr *)&sin_c, sizeof(struct sockaddr_in)) == SOCKET_ERROR) { - printf("connect() failed with error: %d\n", WSAGetLastError()); - exit(EXIT_FAILURE); - } -#else - if (connect(fd_c, (struct sockaddr *)&sin_s, sizeof(struct sockaddr_in)) < 0) { - perror("connect"); - exit(EXIT_FAILURE); - } - if (connect(fd_s, (struct sockaddr *)&sin_c, sizeof(struct sockaddr_in)) < 0) { - perror("connect"); - exit(EXIT_FAILURE); - } -#endif -#ifdef _WIN32 - tid_c = CreateThread(NULL, 0, &handle_packets, (void *)&fd_c, 0, NULL); - tid_s = CreateThread(NULL, 0, &handle_packets, (void *)&fd_s, 0, NULL); -#else - if (pthread_create(&tid_c, NULL, &handle_packets, (void *)&fd_c)) { - perror("pthread_create tid_c"); - exit(EXIT_FAILURE); - } - - if (pthread_create(&tid_s, NULL, &handle_packets, (void *)&fd_s)) { - perror("pthread_create tid_s"); - exit(EXIT_FAILURE); - }; -#endif -#ifdef SCTP_DEBUG - usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_ALL); -#endif - usrsctp_sysctl_set_sctp_ecn_enable(0); - usrsctp_register_address((void *)&fd_c); - usrsctp_register_address((void *)&fd_s); - if ((s_c = usrsctp_socket(AF_CONN, SOCK_STREAM, IPPROTO_SCTP, receive_cb, NULL, 0, &fd_c)) == NULL) { - perror("usrsctp_socket"); - exit(EXIT_FAILURE); - } - opt_len = (socklen_t)sizeof(int); - cur_buf_size = 0; - if (usrsctp_getsockopt(s_c, SOL_SOCKET, SO_SNDBUF, &cur_buf_size, &opt_len) < 0) { - perror("usrsctp_getsockopt"); - exit(EXIT_FAILURE); - } - printf("Change send socket buffer size from %d ", cur_buf_size); - snd_buf_size = 1<<20; /* 1 MB */ - if (usrsctp_setsockopt(s_c, SOL_SOCKET, SO_SNDBUF, &snd_buf_size, sizeof(int)) < 0) { - perror("usrsctp_setsockopt"); - exit(EXIT_FAILURE); - } - opt_len = (socklen_t)sizeof(int); - cur_buf_size = 0; - if (usrsctp_getsockopt(s_c, SOL_SOCKET, SO_SNDBUF, &cur_buf_size, &opt_len) < 0) { - perror("usrsctp_getsockopt"); - exit(EXIT_FAILURE); - } - printf("to %d.\n", cur_buf_size); - if ((s_l = usrsctp_socket(AF_CONN, SOCK_STREAM, IPPROTO_SCTP, receive_cb, NULL, 0, &fd_s)) == NULL) { - perror("usrsctp_socket"); - exit(EXIT_FAILURE); - } - opt_len = (socklen_t)sizeof(int); - cur_buf_size = 0; - if (usrsctp_getsockopt(s_l, SOL_SOCKET, SO_RCVBUF, &cur_buf_size, &opt_len) < 0) { - perror("usrsctp_getsockopt"); - exit(EXIT_FAILURE); - } - printf("Change receive socket buffer size from %d ", cur_buf_size); - rcv_buf_size = 1<<16; /* 64 KB */ - if (usrsctp_setsockopt(s_l, SOL_SOCKET, SO_RCVBUF, &rcv_buf_size, sizeof(int)) < 0) { - perror("usrsctp_setsockopt"); - exit(EXIT_FAILURE); - } - opt_len = (socklen_t)sizeof(int); - cur_buf_size = 0; - if (usrsctp_getsockopt(s_l, SOL_SOCKET, SO_RCVBUF, &cur_buf_size, &opt_len) < 0) { - perror("usrsctp_getsockopt"); - exit(EXIT_FAILURE); - } - printf("to %d.\n", cur_buf_size); - /* Bind the client side. */ - memset(&sconn, 0, sizeof(struct sockaddr_conn)); - sconn.sconn_family = AF_CONN; -#ifdef HAVE_SCONN_LEN - sconn.sconn_len = sizeof(struct sockaddr_conn); -#endif - sconn.sconn_port = htons(5001); - sconn.sconn_addr = &fd_c; - if (usrsctp_bind(s_c, (struct sockaddr *)&sconn, sizeof(struct sockaddr_conn)) < 0) { - perror("usrsctp_bind"); - exit(EXIT_FAILURE); - } - /* Bind the server side. */ - memset(&sconn, 0, sizeof(struct sockaddr_conn)); - sconn.sconn_family = AF_CONN; -#ifdef HAVE_SCONN_LEN - sconn.sconn_len = sizeof(struct sockaddr_conn); -#endif - sconn.sconn_port = htons(5001); - sconn.sconn_addr = &fd_s; - if (usrsctp_bind(s_l, (struct sockaddr *)&sconn, sizeof(struct sockaddr_conn)) < 0) { - perror("usrsctp_bind"); - exit(EXIT_FAILURE); - } - /* Make server side passive... */ - if (usrsctp_listen(s_l, 1) < 0) { - perror("usrsctp_listen"); - exit(EXIT_FAILURE); - } - /* Initiate the handshake */ - memset(&sconn, 0, sizeof(struct sockaddr_conn)); - sconn.sconn_family = AF_CONN; -#ifdef HAVE_SCONN_LEN - sconn.sconn_len = sizeof(struct sockaddr_conn); -#endif - sconn.sconn_port = htons(5001); - sconn.sconn_addr = &fd_c; - if (usrsctp_connect(s_c, (struct sockaddr *)&sconn, sizeof(struct sockaddr_conn)) < 0) { - perror("usrsctp_connect"); - exit(EXIT_FAILURE); - } - if ((s_s = usrsctp_accept(s_l, NULL, NULL)) == NULL) { - perror("usrsctp_accept"); - exit(EXIT_FAILURE); - } - usrsctp_close(s_l); - if ((line = malloc(LINE_LENGTH)) == NULL) { - exit(EXIT_FAILURE); - } - memset(line, 'A', LINE_LENGTH); - sndinfo.snd_sid = 1; - sndinfo.snd_flags = 0; - sndinfo.snd_ppid = htonl(DISCARD_PPID); - sndinfo.snd_context = 0; - sndinfo.snd_assoc_id = 0; - /* Send a 1 MB message */ - if (usrsctp_sendv(s_c, line, LINE_LENGTH, NULL, 0, (void *)&sndinfo, - (socklen_t)sizeof(struct sctp_sndinfo), SCTP_SENDV_SNDINFO, 0) < 0) { - perror("usrsctp_sendv"); - exit(EXIT_FAILURE); - } - free(line); - usrsctp_shutdown(s_c, SHUT_WR); - - while (usrsctp_finish() != 0) { -#ifdef _WIN32 - Sleep(1000); -#else - sleep(1); -#endif - } -#ifdef _WIN32 - TerminateThread(tid_c, 0); - WaitForSingleObject(tid_c, INFINITE); - TerminateThread(tid_s, 0); - WaitForSingleObject(tid_s, INFINITE); - if (closesocket(fd_c) == SOCKET_ERROR) { - printf("closesocket() failed with error: %d\n", WSAGetLastError()); - exit(EXIT_FAILURE); - } - if (closesocket(fd_s) == SOCKET_ERROR) { - printf("closesocket() failed with error: %d\n", WSAGetLastError()); - exit(EXIT_FAILURE); - } - WSACleanup(); -#else - pthread_cancel(tid_c); - pthread_join(tid_c, NULL); - pthread_cancel(tid_s); - pthread_join(tid_s, NULL); - if (close(fd_c) < 0) { - perror("close"); - exit(EXIT_FAILURE); - } - if (close(fd_s) < 0) { - perror("close"); - exit(EXIT_FAILURE); - } -#endif - return (0); -} diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/ekr_loop_upcall.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/ekr_loop_upcall.c index d225fee977..3db480a729 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/ekr_loop_upcall.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/ekr_loop_upcall.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2011-2013 Michael Tuexen - * Copyright (C) 2018-2018 Felix Weinrank + * Copyright (C) 2018-2020 Felix Weinrank * * All rights reserved. * @@ -29,6 +29,10 @@ * SUCH DAMAGE. */ +/* + * Usage: ekr_loop [client_port] [server_port] [crc32c offloading <0/1>] + */ + #ifdef _WIN32 #define _CRT_SECURE_NO_WARNINGS #endif @@ -54,7 +58,14 @@ #define MAX_PACKET_SIZE (1<<16) #define LINE_LENGTH (1<<20) #define DISCARD_PPID 39 -/* #define DUMP_PKTS_TO_FILE */ +#define NUMBER_OF_STEPS 10 + +static uint8_t crc32c_offloading = 0; + +struct upcall_meta { + uint8_t sender; + void* addr; +}; #ifdef _WIN32 static DWORD WINAPI @@ -69,8 +80,10 @@ handle_packets(void *arg) int *fdp; #endif char *dump_buf; + struct sctp_common_header *hdr; ssize_t length; char buf[MAX_PACKET_SIZE]; + uint32_t received_crc32c, computed_crc32c; #ifdef _WIN32 fdp = (SOCKET *)arg; @@ -84,10 +97,29 @@ handle_packets(void *arg) length = recv(*fdp, buf, MAX_PACKET_SIZE, 0); if (length > 0) { if ((dump_buf = usrsctp_dumppacket(buf, (size_t)length, SCTP_DUMP_INBOUND)) != NULL) { - /* fprintf(stderr, "%s", dump_buf); */ + //debug_printf_clean("%s\n", dump_buf); usrsctp_freedumpbuffer(dump_buf); } - usrsctp_conninput(fdp, buf, (size_t)length, 0); + + if (crc32c_offloading) { + if ((size_t)length >= sizeof(struct sctp_common_header)) { + hdr = (struct sctp_common_header *)buf; + received_crc32c = hdr->crc32c; + hdr->crc32c = htonl(0); + computed_crc32c = usrsctp_crc32c(buf, (size_t)length); + hdr->crc32c = received_crc32c; + if (received_crc32c == computed_crc32c) { + usrsctp_conninput(fdp, buf, (size_t)length, 0); + } else { + debug_printf("Wrong CRC32c: expected %08x received %08x\n", + ntohl(computed_crc32c), ntohl(received_crc32c)); + } + } else { + debug_printf("Packet too short: length %zd", length); + } + } else { + usrsctp_conninput(fdp, buf, (size_t)length, 0); + } } } #ifdef _WIN32 @@ -101,6 +133,7 @@ static int conn_output(void *addr, void *buf, size_t length, uint8_t tos, uint8_t set_df) { char *dump_buf; + struct sctp_common_header *hdr; #ifdef _WIN32 SOCKET *fdp; #else @@ -112,21 +145,15 @@ conn_output(void *addr, void *buf, size_t length, uint8_t tos, uint8_t set_df) #else fdp = (int *)addr; #endif - if ((dump_buf = usrsctp_dumppacket(buf, length, SCTP_DUMP_OUTBOUND)) != NULL) { - /* fprintf(stderr, "%s", dump_buf); */ - usrsctp_freedumpbuffer(dump_buf); + if (crc32c_offloading && length >= sizeof(struct sctp_common_header)) { + hdr = (struct sctp_common_header *)buf; + hdr->crc32c = usrsctp_crc32c(buf, (size_t)length); } -#ifdef DUMP_PKTS_TO_FILE - FILE *fp; - char fname[128]; - static int pktnum = 0; - snprintf(fname, sizeof(fname), "pkt-%d", pktnum++); - fp = fopen(fname, "wb"); - fwrite((char *)buf + 12, 1, length - 12, fp); - fclose(fp); -#endif - + if ((dump_buf = usrsctp_dumppacket(buf, length, SCTP_DUMP_OUTBOUND)) != NULL) { + //debug_printf_clean("%s\n", dump_buf); + usrsctp_freedumpbuffer(dump_buf); + } #ifdef _WIN32 if (send(*fdp, buf, (int)length, 0) == SOCKET_ERROR) { return (WSAGetLastError()); @@ -144,7 +171,9 @@ handle_upcall(struct socket *sock, void *data, int flgs) { char *buf; int events; + struct upcall_meta *meta; + meta = data; buf = malloc(MAX_PACKET_SIZE); while ((events = usrsctp_get_events(sock)) && (events & SCTP_EVENT_READ)) { @@ -162,9 +191,9 @@ handle_upcall(struct socket *sock, void *data, int flgs) break; } else if (n > 0) { if (flags & MSG_NOTIFICATION) { - printf("Notification of length %d received.\n", (int)n); + debug_printf("MSG RCV: Notification of length %d received.\n", (int)n); } else { - printf("Message of length %d received via %p:%u on stream %u with SSN %u and TSN %u, PPID %u, context %u, flags %x.\n", + debug_printf("MSG RCV: Data length %d, addr %p:%u, stream %u, SSN %u, TSN %u, PPID %u, context %u, %s%s.\n", (int)n, addr.sconn.sconn_addr, ntohs(addr.sconn.sconn_port), @@ -173,10 +202,12 @@ handle_upcall(struct socket *sock, void *data, int flgs) rn.recvv_rcvinfo.rcv_tsn, ntohl(rn.recvv_rcvinfo.rcv_ppid), rn.recvv_rcvinfo.rcv_context, - flags); + (rn.recvv_rcvinfo.rcv_flags & SCTP_UNORDERED) ? "unordered" : "ordered", + (flags & MSG_EOR) ? ", EOR" : ""); } } else { - usrsctp_deregister_address(data); + debug_printf("Connection closed!\n"); + usrsctp_deregister_address(meta->addr); usrsctp_close(sock); break; } @@ -186,13 +217,16 @@ handle_upcall(struct socket *sock, void *data, int flgs) return; } -#if 0 static void print_addresses(struct socket *sock) { int i, n; struct sockaddr *addrs, *addr; +#if !defined(HAVE_SA_LEN) + int sa_len; +#endif + debug_printf("Addresses: "); n = usrsctp_getladdrs(sock, 0, &addrs); addr = addrs; for (i = 0; i < n; i++) { @@ -205,7 +239,10 @@ print_addresses(struct socket *sock) sin = (struct sockaddr_in *)addr; name = inet_ntop(AF_INET, &sin->sin_addr, buf, INET_ADDRSTRLEN); - printf("%s:%d", name, ntohs(sin->sin_port)); + debug_printf_clean("%s:%d", name, ntohs(sin->sin_port)); +#if !defined(HAVE_SA_LEN) + sa_len = (int)sizeof(struct sockaddr_in); +#endif break; } case AF_INET6: @@ -216,7 +253,10 @@ print_addresses(struct socket *sock) sin6 = (struct sockaddr_in6 *)addr; name = inet_ntop(AF_INET6, &sin6->sin6_addr, buf, INET6_ADDRSTRLEN); - printf("%s:%d", name, ntohs(sin6->sin6_port)); + debug_printf_clean("%s:%d", name, ntohs(sin6->sin6_port)); +#if !defined(HAVE_SA_LEN) + sa_len = (int)sizeof(struct sockaddr_in6); +#endif break; } case AF_CONN: @@ -224,22 +264,32 @@ print_addresses(struct socket *sock) struct sockaddr_conn *sconn; sconn = (struct sockaddr_conn *)addr; - printf("%p:%d", sconn->sconn_addr, ntohs(sconn->sconn_port)); + debug_printf_clean("%p:%d", sconn->sconn_addr, ntohs(sconn->sconn_port)); +#if !defined(HAVE_SA_LEN) + sa_len = (int)sizeof(struct sockaddr_conn); +#endif break; } default: - printf("Unknown family: %d", addr->sa_family); + debug_printf_clean("Unknown family: %d", addr->sa_family); +#if !defined(HAVE_SA_LEN) + sa_len = (int)sizeof(struct sockaddr); +#endif break; } +#if !defined(HAVE_SA_LEN) + addr = (struct sockaddr *)((char *)addr + sa_len); +#else addr = (struct sockaddr *)((caddr_t)addr + addr->sa_len); +#endif if (i != n - 1) { - printf(","); + debug_printf_clean(","); } } if (n > 0) { usrsctp_freeladdrs(addrs); } - printf("<->"); + debug_printf_clean("<->"); n = usrsctp_getpaddrs(sock, 0, &addrs); addr = addrs; for (i = 0; i < n; i++) { @@ -252,7 +302,10 @@ print_addresses(struct socket *sock) sin = (struct sockaddr_in *)addr; name = inet_ntop(AF_INET, &sin->sin_addr, buf, INET_ADDRSTRLEN); - printf("%s:%d", name, ntohs(sin->sin_port)); + debug_printf_clean("%s:%d", name, ntohs(sin->sin_port)); +#if !defined(HAVE_SA_LEN) + sa_len = (int)sizeof(struct sockaddr_in); +#endif break; } case AF_INET6: @@ -263,7 +316,10 @@ print_addresses(struct socket *sock) sin6 = (struct sockaddr_in6 *)addr; name = inet_ntop(AF_INET6, &sin6->sin6_addr, buf, INET6_ADDRSTRLEN); - printf("%s:%d", name, ntohs(sin6->sin6_port)); + debug_printf_clean("%s:%d", name, ntohs(sin6->sin6_port)); +#if !defined(HAVE_SA_LEN) + sa_len = (int)sizeof(struct sockaddr_in6); +#endif break; } case AF_CONN: @@ -271,34 +327,44 @@ print_addresses(struct socket *sock) struct sockaddr_conn *sconn; sconn = (struct sockaddr_conn *)addr; - printf("%p:%d", sconn->sconn_addr, ntohs(sconn->sconn_port)); + debug_printf_clean("%p:%d", sconn->sconn_addr, ntohs(sconn->sconn_port)); +#if !defined(HAVE_SA_LEN) + sa_len = (int)sizeof(struct sockaddr_conn); +#endif break; } default: - printf("Unknown family: %d", addr->sa_family); + debug_printf_clean("Unknown family: %d", addr->sa_family); +#if !defined(HAVE_SA_LEN) + sa_len = (int)sizeof(struct sockaddr); +#endif break; } +#if !defined(HAVE_SA_LEN) + addr = (struct sockaddr *)((char *)addr + sa_len); +#else addr = (struct sockaddr *)((caddr_t)addr + addr->sa_len); +#endif if (i != n - 1) { - printf(","); + debug_printf_clean(","); } } if (n > 0) { usrsctp_freepaddrs(addrs); } - printf("\n"); + debug_printf_clean("\n"); } -#endif int main(int argc, char *argv[]) { struct sockaddr_in sin_s, sin_c; struct sockaddr_conn sconn; + struct sctp_paddrparams paddrparams; #ifdef _WIN32 SOCKET fd_c, fd_s; #else - int fd_c, fd_s; + int fd_c, fd_s, rc; #endif struct socket *s_c, *s_s, *s_l; #ifdef _WIN32 @@ -306,7 +372,7 @@ main(int argc, char *argv[]) #else pthread_t tid_c, tid_s; #endif - int cur_buf_size, snd_buf_size, rcv_buf_size, on; + int i, j, cur_buf_size, snd_buf_size, rcv_buf_size, sendv_retries_left, on; socklen_t opt_len; struct sctp_sndinfo sndinfo; char *line; @@ -316,26 +382,59 @@ main(int argc, char *argv[]) uint16_t client_port = 9900; uint16_t server_port = 9901; - if (argc == 3) { + + struct upcall_meta upcall_meta_client; + struct upcall_meta upcall_meta_server; + +#ifdef OUTPUT_TO_LOGFILE + FILE *logfile; + logfile = fopen("ekr_loop_upcall.log", "a+"); + if (logfile == NULL) { + debug_printf("Failed creating logfile\n"); + exit(EXIT_FAILURE); + } + debug_set_target(logfile); +#endif + + if (argc > 1) { client_port = atoi(argv[1]); + } + + if (argc > 2) { server_port = atoi(argv[2]); } + if (argc > 3) { + crc32c_offloading = atoi(argv[3]); + } + + debug_printf("Starting program\n"); + debug_printf("Config:\n\tClient Port:\t%d\n\tServer Port:\t%d\n\tCRC32C Calc:\t%s\n", client_port, server_port, crc32c_offloading ? "offloaded" : "NOT offloaded"); + #ifdef _WIN32 if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0) { - printf("WSAStartup failed\n"); + debug_printf("WSAStartup failed\n"); exit (EXIT_FAILURE); } #endif usrsctp_init(0, conn_output, debug_printf_stack); + +#ifdef SCTP_DEBUG + usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_NONE); +#endif // SCTP_DEBUG + + if (crc32c_offloading) { + usrsctp_enable_crc32c_offload(); + } + /* set up a connected UDP socket */ #ifdef _WIN32 if ((fd_c = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) { - printf("socket() failed with error: %d\n", WSAGetLastError()); + debug_printf("socket() failed with error: %d\n", WSAGetLastError()); exit(EXIT_FAILURE); } if ((fd_s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) { - printf("socket() failed with error: %d\n", WSAGetLastError()); + debug_printf("socket() failed with error: %d\n", WSAGetLastError()); exit(EXIT_FAILURE); } #else @@ -364,11 +463,11 @@ main(int argc, char *argv[]) sin_s.sin_addr.s_addr = htonl(INADDR_LOOPBACK); #ifdef _WIN32 if (bind(fd_c, (struct sockaddr *)&sin_c, sizeof(struct sockaddr_in)) == SOCKET_ERROR) { - printf("bind() failed with error: %d\n", WSAGetLastError()); + debug_printf("bind() failed with error: %d\n", WSAGetLastError()); exit(EXIT_FAILURE); } if (bind(fd_s, (struct sockaddr *)&sin_s, sizeof(struct sockaddr_in)) == SOCKET_ERROR) { - printf("bind() failed with error: %d\n", WSAGetLastError()); + debug_printf("bind() failed with error: %d\n", WSAGetLastError()); exit(EXIT_FAILURE); } #else @@ -383,11 +482,11 @@ main(int argc, char *argv[]) #endif #ifdef _WIN32 if (connect(fd_c, (struct sockaddr *)&sin_s, sizeof(struct sockaddr_in)) == SOCKET_ERROR) { - printf("connect() failed with error: %d\n", WSAGetLastError()); + debug_printf("connect() failed with error: %d\n", WSAGetLastError()); exit(EXIT_FAILURE); } if (connect(fd_s, (struct sockaddr *)&sin_c, sizeof(struct sockaddr_in)) == SOCKET_ERROR) { - printf("connect() failed with error: %d\n", WSAGetLastError()); + debug_printf("connect() failed with error: %d\n", WSAGetLastError()); exit(EXIT_FAILURE); } #else @@ -401,31 +500,37 @@ main(int argc, char *argv[]) } #endif #ifdef _WIN32 - tid_c = CreateThread(NULL, 0, &handle_packets, (void *)&fd_c, 0, NULL); - tid_s = CreateThread(NULL, 0, &handle_packets, (void *)&fd_s, 0, NULL); + if ((tid_c = CreateThread(NULL, 0, &handle_packets, (void *)&fd_c, 0, NULL)) == NULL) { + debug_printf("CreateThread() failed with error: %d\n", GetLastError()); + exit(EXIT_FAILURE); + } + if ((tid_s = CreateThread(NULL, 0, &handle_packets, (void *)&fd_s, 0, NULL)) == NULL) { + debug_printf("CreateThread() failed with error: %d\n", GetLastError()); + exit(EXIT_FAILURE); + } #else - if (pthread_create(&tid_c, NULL, &handle_packets, (void *)&fd_c)) { - perror("pthread_create tid_c"); + if ((rc = pthread_create(&tid_c, NULL, &handle_packets, (void *)&fd_c)) != 0) { + debug_printf("pthread_create tid_c: %s\n", strerror(rc)); exit(EXIT_FAILURE); } - if (pthread_create(&tid_s, NULL, &handle_packets, (void *)&fd_s)) { - perror("pthread_create tid_s"); + if ((rc = pthread_create(&tid_s, NULL, &handle_packets, (void *)&fd_s)) != 0) { + debug_printf("pthread_create tid_s: %s\n", strerror(rc)); exit(EXIT_FAILURE); }; #endif -#ifdef SCTP_DEBUG - usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_NONE); -#endif + usrsctp_sysctl_set_sctp_ecn_enable(0); usrsctp_register_address((void *)&fd_c); usrsctp_register_address((void *)&fd_s); - if ((s_c = usrsctp_socket(AF_CONN, SOCK_STREAM, IPPROTO_SCTP, NULL, NULL, 0, NULL)) == NULL) { perror("usrsctp_socket"); exit(EXIT_FAILURE); } - usrsctp_set_upcall(s_c, handle_upcall, &fd_c); + + upcall_meta_client.addr = &fd_c; + upcall_meta_client.sender = 1; + usrsctp_set_upcall(s_c, handle_upcall, &upcall_meta_client); opt_len = (socklen_t)sizeof(int); cur_buf_size = 0; @@ -433,7 +538,7 @@ main(int argc, char *argv[]) perror("usrsctp_getsockopt"); exit(EXIT_FAILURE); } - printf("Change send socket buffer size from %d ", cur_buf_size); + debug_printf("Change send socket buffer size from %d ", cur_buf_size); snd_buf_size = 1<<22; /* 4 MB */ if (usrsctp_setsockopt(s_c, SOL_SOCKET, SO_SNDBUF, &snd_buf_size, sizeof(int)) < 0) { perror("usrsctp_setsockopt"); @@ -445,19 +550,29 @@ main(int argc, char *argv[]) perror("usrsctp_getsockopt"); exit(EXIT_FAILURE); } - printf("to %d.\n", cur_buf_size); + debug_printf_clean("to %d.\n", cur_buf_size); + memset(&paddrparams, 0, sizeof(struct sctp_paddrparams)); + paddrparams.spp_address.ss_family = AF_CONN; +#ifdef HAVE_SCONN_LEN + paddrparams.spp_address.ss_len = sizeof(struct sockaddr_conn); +#endif + paddrparams.spp_flags = SPP_PMTUD_DISABLE; + paddrparams.spp_pathmtu = 9000; + if (usrsctp_setsockopt(s_c, IPPROTO_SCTP, SCTP_PEER_ADDR_PARAMS, &paddrparams, sizeof(struct sctp_paddrparams)) < 0) { + perror("usrsctp_setsockopt"); + exit(EXIT_FAILURE); + } if ((s_l = usrsctp_socket(AF_CONN, SOCK_STREAM, IPPROTO_SCTP, NULL, NULL, 0, NULL)) == NULL) { perror("usrsctp_socket"); exit(EXIT_FAILURE); } - opt_len = (socklen_t)sizeof(int); cur_buf_size = 0; if (usrsctp_getsockopt(s_l, SOL_SOCKET, SO_RCVBUF, &cur_buf_size, &opt_len) < 0) { perror("usrsctp_getsockopt"); exit(EXIT_FAILURE); } - printf("Change receive socket buffer size from %d ", cur_buf_size); + debug_printf("Change receive socket buffer size from %d ", cur_buf_size); rcv_buf_size = 1<<16; /* 64 KB */ if (usrsctp_setsockopt(s_l, SOL_SOCKET, SO_RCVBUF, &rcv_buf_size, sizeof(int)) < 0) { perror("usrsctp_setsockopt"); @@ -469,13 +584,14 @@ main(int argc, char *argv[]) perror("usrsctp_getsockopt"); exit(EXIT_FAILURE); } - printf("to %d.\n", cur_buf_size); + debug_printf_clean("to %d.\n", cur_buf_size); on = 1; if (usrsctp_setsockopt(s_l, IPPROTO_SCTP, SCTP_RECVRCVINFO, &on, sizeof(int)) < 0) { perror("usrsctp_setsockopt"); exit(EXIT_FAILURE); } + /* Bind the client side. */ memset(&sconn, 0, sizeof(struct sockaddr_conn)); sconn.sconn_family = AF_CONN; @@ -517,40 +633,63 @@ main(int argc, char *argv[]) perror("usrsctp_connect"); exit(EXIT_FAILURE); } - if ((s_s = usrsctp_accept(s_l, NULL, NULL)) == NULL) { perror("usrsctp_accept"); exit(EXIT_FAILURE); } - usrsctp_set_upcall(s_s, handle_upcall, &fd_s); + upcall_meta_server.addr = &fd_s; + upcall_meta_server.sender = 0; + usrsctp_set_upcall(s_s, handle_upcall, &upcall_meta_server); usrsctp_close(s_l); + print_addresses(s_s); + if ((line = malloc(LINE_LENGTH)) == NULL) { exit(EXIT_FAILURE); } memset(line, 'A', LINE_LENGTH); sndinfo.snd_sid = 1; - sndinfo.snd_flags = SCTP_UNORDERED; sndinfo.snd_ppid = htonl(DISCARD_PPID); sndinfo.snd_context = 0; sndinfo.snd_assoc_id = 0; - /* Send a 1 MB ordered message */ - if (usrsctp_sendv(s_c, line, LINE_LENGTH, NULL, 0, (void *)&sndinfo, - (socklen_t)sizeof(struct sctp_sndinfo), SCTP_SENDV_SNDINFO, 0) < 0) { - perror("usrsctp_sendv"); - exit(EXIT_FAILURE); - } - /* Send a 1 MB ordered message */ - if (usrsctp_sendv(s_c, line, LINE_LENGTH, NULL, 0, (void *)&sndinfo, - (socklen_t)sizeof(struct sctp_sndinfo), SCTP_SENDV_SNDINFO, 0) < 0) { - perror("usrsctp_sendv"); - exit(EXIT_FAILURE); + + for (i = 0; i < NUMBER_OF_STEPS; i++) { + if (i % 2) { + sndinfo.snd_flags = SCTP_UNORDERED; + } else { + sndinfo.snd_flags = 0; + } + for (j = 0; j < 2; j++) { + /* Send a 1 MB message */ + sendv_retries_left = 120; + debug_printf("usrscp_sendv - step %d - call %d flags %x\n", i, j + 1, sndinfo.snd_flags); + while (usrsctp_sendv(s_c, line, LINE_LENGTH, NULL, 0, (void *)&sndinfo, + (socklen_t)sizeof(struct sctp_sndinfo), SCTP_SENDV_SNDINFO, 0) < 0) { + debug_printf("usrsctp_sendv - errno: %d - %s\n", errno, strerror(errno)); + if (errno != EWOULDBLOCK || !sendv_retries_left) { + exit(EXIT_FAILURE); + } + sendv_retries_left--; +#ifdef _WIN32 + Sleep(1000); +#else + sleep(1); +#endif + } + } + debug_printf("Sending done, sleeping\n"); +#ifdef _WIN32 + Sleep(1000); +#else + sleep(1); +#endif } free(line); usrsctp_shutdown(s_c, SHUT_WR); while (usrsctp_finish() != 0) { + debug_printf("Waiting for usrsctp_finish()\n"); #ifdef _WIN32 Sleep(1000); #else @@ -563,11 +702,11 @@ main(int argc, char *argv[]) TerminateThread(tid_s, 0); WaitForSingleObject(tid_s, INFINITE); if (closesocket(fd_c) == SOCKET_ERROR) { - printf("closesocket() failed with error: %d\n", WSAGetLastError()); + debug_printf("closesocket() failed with error: %d\n", WSAGetLastError()); exit(EXIT_FAILURE); } if (closesocket(fd_s) == SOCKET_ERROR) { - printf("closesocket() failed with error: %d\n", WSAGetLastError()); + debug_printf("closesocket() failed with error: %d\n", WSAGetLastError()); exit(EXIT_FAILURE); } WSACleanup(); diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/ekr_peer.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/ekr_peer.c index f278d5bc75..6ed511333c 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/ekr_peer.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/ekr_peer.c @@ -132,7 +132,7 @@ receive_cb(struct socket *sock, union sctp_sockstore addr, void *data, rcv.rcv_sid, rcv.rcv_ssn, rcv.rcv_tsn, - ntohl(rcv.rcv_ppid), + (uint32_t)ntohl(rcv.rcv_ppid), rcv.rcv_context); } free(data); @@ -156,7 +156,7 @@ main(int argc, char *argv[]) #ifdef _WIN32 SOCKET fd; #else - int fd; + int fd, rc; #endif struct socket *s; #ifdef _WIN32 @@ -177,7 +177,7 @@ main(int argc, char *argv[]) #ifdef _WIN32 if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0) { - printf("WSAStartup failed\n"); + fprintf(stderr, "WSAStartup failed\n"); exit(EXIT_FAILURE); } #endif @@ -185,7 +185,7 @@ main(int argc, char *argv[]) /* set up a connected UDP socket */ #ifdef _WIN32 if ((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) { - printf("socket() failed with error: %d\n", WSAGetLastError()); + fprintf(stderr, "socket() failed with error: %d\n", WSAGetLastError()); exit(EXIT_FAILURE); } #else @@ -206,7 +206,7 @@ main(int argc, char *argv[]) } #ifdef _WIN32 if (bind(fd, (struct sockaddr *)&sin, sizeof(struct sockaddr_in)) == SOCKET_ERROR) { - printf("bind() failed with error: %d\n", WSAGetLastError()); + fprintf(stderr, "bind() failed with error: %d\n", WSAGetLastError()); exit(EXIT_FAILURE); } #else @@ -227,7 +227,7 @@ main(int argc, char *argv[]) } #ifdef _WIN32 if (connect(fd, (struct sockaddr *)&sin, sizeof(struct sockaddr_in)) == SOCKET_ERROR) { - printf("connect() failed with error: %d\n", WSAGetLastError()); + fprintf(stderr, "connect() failed with error: %d\n", WSAGetLastError()); exit(EXIT_FAILURE); } #else @@ -237,9 +237,15 @@ main(int argc, char *argv[]) } #endif #ifdef _WIN32 - tid = CreateThread(NULL, 0, &handle_packets, (void *)&fd, 0, NULL); + if ((tid = CreateThread(NULL, 0, &handle_packets, (void *)&fd, 0, NULL)) == NULL) { + fprintf(stderr, "CreateThread() failed with error: %lu\n", GetLastError()); + exit(EXIT_FAILURE); + } #else - pthread_create(&tid, NULL, &handle_packets, (void *)&fd); + if ((rc = pthread_create(&tid, NULL, &handle_packets, (void *)&fd)) != 0) { + fprintf(stderr, "pthread_create: %s\n", strerror(rc)); + exit(EXIT_FAILURE); + } #endif #ifdef SCTP_DEBUG usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_NONE); @@ -306,7 +312,7 @@ main(int argc, char *argv[]) sndinfo.snd_context = 0; sndinfo.snd_assoc_id = 0; if (usrsctp_sendv(s, line, strlen(line), NULL, 0, (void *)&sndinfo, - (socklen_t)sizeof(struct sctp_sndinfo), SCTP_SENDV_SNDINFO, 0) < 0) { + (socklen_t)sizeof(struct sctp_sndinfo), SCTP_SENDV_SNDINFO, 0) < 0) { perror("usrsctp_sendv"); } } @@ -321,7 +327,7 @@ main(int argc, char *argv[]) TerminateThread(tid, 0); WaitForSingleObject(tid, INFINITE); if (closesocket(fd) == SOCKET_ERROR) { - printf("closesocket() failed with error: %d\n", WSAGetLastError()); + fprintf(stderr, "closesocket() failed with error: %d\n", WSAGetLastError()); } WSACleanup(); #else diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/ekr_server.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/ekr_server.c index 2fdfcc2fcf..a9dd85edd7 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/ekr_server.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/ekr_server.c @@ -143,7 +143,7 @@ receive_cb(struct socket *s, union sctp_sockstore addr, void *data, rcv.rcv_sid, rcv.rcv_ssn, rcv.rcv_tsn, - ntohl(rcv.rcv_ppid), + (uint32_t)ntohl(rcv.rcv_ppid), rcv.rcv_context); } free(data); @@ -161,7 +161,7 @@ main(int argc, char *argv[]) #ifdef _WIN32 SOCKET fd; #else - int fd; + int fd, rc; #endif struct socket *s; #ifdef _WIN32 @@ -174,13 +174,13 @@ main(int argc, char *argv[]) #endif if (argc < 4) { - printf("error: this program requires 4 arguments!\n"); + fprintf(stderr, "error: this program requires 4 arguments!\n"); exit(EXIT_FAILURE); } #ifdef _WIN32 if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0) { - printf("WSAStartup failed\n"); + fprintf(stderr, "WSAStartup failed\n"); exit (EXIT_FAILURE); } #endif @@ -188,7 +188,7 @@ main(int argc, char *argv[]) /* set up a connected UDP socket */ #ifdef _WIN32 if ((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) { - printf("socket() failed with error: %d\n", WSAGetLastError()); + fprintf(stderr, "socket() failed with error: %d\n", WSAGetLastError()); exit(EXIT_FAILURE); } #else @@ -204,12 +204,12 @@ main(int argc, char *argv[]) #endif sin.sin_port = htons(atoi(argv[2])); if (!inet_pton(AF_INET, argv[1], &sin.sin_addr.s_addr)){ - printf("error: invalid address\n"); + fprintf(stderr, "error: invalid address\n"); exit(EXIT_FAILURE); } #ifdef _WIN32 if (bind(fd, (struct sockaddr *)&sin, sizeof(struct sockaddr_in)) == SOCKET_ERROR) { - printf("bind() failed with error: %d\n", WSAGetLastError()); + fprintf(stderr, "bind() failed with error: %d\n", WSAGetLastError()); exit(EXIT_FAILURE); } #else @@ -230,7 +230,7 @@ main(int argc, char *argv[]) } #ifdef _WIN32 if (connect(fd, (struct sockaddr *)&sin, sizeof(struct sockaddr_in)) == SOCKET_ERROR) { - printf("connect() failed with error: %d\n", WSAGetLastError()); + fprintf(stderr, "connect() failed with error: %d\n", WSAGetLastError()); exit(EXIT_FAILURE); } #else @@ -245,9 +245,15 @@ main(int argc, char *argv[]) usrsctp_sysctl_set_sctp_ecn_enable(0); usrsctp_register_address((void *)&fd); #ifdef _WIN32 - tid = CreateThread(NULL, 0, &handle_packets, (void *)&fd, 0, NULL); + if ((tid = CreateThread(NULL, 0, &handle_packets, (void *)&fd, 0, NULL)) == NULL) { + fprintf(stderr, "CreateThread() failed with error: %lu\n", GetLastError()); + exit(EXIT_FAILURE); + } #else - pthread_create(&tid, NULL, &handle_packets, (void *)&fd); + if ((rc = pthread_create(&tid, NULL, &handle_packets, (void *)&fd)) != 0) { + fprintf(stderr, "pthread_create: %s\n", strerror(rc)); + exit(EXIT_FAILURE); + } #endif if ((s = usrsctp_socket(AF_CONN, SOCK_STREAM, IPPROTO_SCTP, receive_cb, NULL, 0, NULL)) == NULL) { perror("usrsctp_socket"); @@ -270,28 +276,5 @@ main(int argc, char *argv[]) perror("usrsctp_accept"); } } - usrsctp_close(s); - usrsctp_deregister_address((void *)&fd); - while (usrsctp_finish() != 0) { -#ifdef _WIN32 - Sleep(SLEEP * 1000); -#else - sleep(SLEEP); -#endif - } -#ifdef _WIN32 - TerminateThread(tid, 0); - WaitForSingleObject(tid, INFINITE); - if (closesocket(fd) == SOCKET_ERROR) { - printf("closesocket() failed with error: %d\n", WSAGetLastError()); - } - WSACleanup(); -#else - pthread_cancel(tid); - pthread_join(tid, NULL); - if (close(fd) < 0) { - perror("close"); - } -#endif return (0); } diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/http_client.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/http_client.c index def038498a..03c92860a7 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/http_client.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/http_client.c @@ -256,16 +256,20 @@ main(int argc, char *argv[]) if (argc > 6) { #ifdef _WIN32 - _snprintf(request, sizeof(request), "%s %s %s", request_prefix, argv[6], request_postfix); + if (_snprintf(request, sizeof(request), "%s %s %s", request_prefix, argv[6], request_postfix) < 0) { #else - snprintf(request, sizeof(request), "%s %s %s", request_prefix, argv[6], request_postfix); + if (snprintf(request, sizeof(request), "%s %s %s", request_prefix, argv[6], request_postfix) < 0) { #endif + request[0] = '\0'; + } } else { #ifdef _WIN32 - _snprintf(request, sizeof(request), "%s %s %s", request_prefix, "/", request_postfix); + if (_snprintf(request, sizeof(request), "%s %s %s", request_prefix, "/", request_postfix) < 0) { #else - snprintf(request, sizeof(request), "%s %s %s", request_prefix, "/", request_postfix); + if (snprintf(request, sizeof(request), "%s %s %s", request_prefix, "/", request_postfix) < 0) { #endif + request[0] = '\0'; + } } printf("\nHTTP request:\n%s\n", request); diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/http_client_upcall.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/http_client_upcall.c index 5583b54c29..04221c2593 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/http_client_upcall.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/http_client_upcall.c @@ -78,7 +78,7 @@ typedef char* caddr_t; static void handle_upcall(struct socket *sock, void *arg, int flgs) { int events = usrsctp_get_events(sock); - ssize_t bytesSent = 0; + ssize_t bytesSent; char *buf; if ((events & SCTP_EVENT_READ) && !done) { @@ -93,7 +93,7 @@ static void handle_upcall(struct socket *sock, void *arg, int flgs) memset(&rn, 0, sizeof(struct sctp_recvv_rn)); n = usrsctp_recvv(sock, buf, BUFFERSIZE, (struct sockaddr *) &addr, &len, (void *)&rn, - &infolen, &infotype, &flags); + &infolen, &infotype, &flags); if (n < 0) { if (errno == ECONNREFUSED) { @@ -103,10 +103,10 @@ static void handle_upcall(struct socket *sock, void *arg, int flgs) } else { result = RETVAL_CATCHALL; } - perror("usrsctp_connect"); + perror("usrsctp_recvv"); } - if (n <= 0){ + if (n <= 0) { done = 1; usrsctp_close(sock); } else { @@ -132,7 +132,7 @@ static void handle_upcall(struct socket *sock, void *arg, int flgs) perror("usrsctp_sendv"); usrsctp_close(sock); } else { - printf("%d bytes sent\n", (int)bytesSent); + printf("%zd bytes sent\n", bytesSent); } } } @@ -276,16 +276,20 @@ main(int argc, char *argv[]) if (argc > 6) { #ifdef _WIN32 - _snprintf(request, sizeof(request), "%s %s %s", request_prefix, argv[6], request_postfix); + if (_snprintf(request, sizeof(request), "%s %s %s", request_prefix, argv[6], request_postfix) < 0) { #else - snprintf(request, sizeof(request), "%s %s %s", request_prefix, argv[6], request_postfix); + if (snprintf(request, sizeof(request), "%s %s %s", request_prefix, argv[6], request_postfix) < 0) { #endif + request[0] = '\0'; + } } else { #ifdef _WIN32 - _snprintf(request, sizeof(request), "%s %s %s", request_prefix, "/", request_postfix); + if (_snprintf(request, sizeof(request), "%s %s %s", request_prefix, "/", request_postfix) < 0) { #else - snprintf(request, sizeof(request), "%s %s %s", request_prefix, "/", request_postfix); + if (snprintf(request, sizeof(request), "%s %s %s", request_prefix, "/", request_postfix) < 0) { #endif + request[0] = '\0'; + } } printf("\nHTTP request:\n%s\n", request); @@ -305,9 +309,6 @@ main(int argc, char *argv[]) result = RETVAL_CATCHALL; } perror("usrsctp_connect"); - usrsctp_close(sock); - - goto out; } } diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/meson.build b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/meson.build index 9cbb0fb2e8..b629a44bcd 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/meson.build +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/meson.build @@ -15,7 +15,6 @@ programs = { 'echo_server_upcall': files('echo_server_upcall.c'), 'ekr_client': files('ekr_client.c'), 'ekr_loop': files('ekr_loop.c'), - 'ekr_loop_offload': files('ekr_loop_offload.c'), 'ekr_loop_upcall': files('ekr_loop_upcall.c'), 'ekr_peer': files('ekr_peer.c'), 'ekr_server': files('ekr_server.c'), diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/programs_helper.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/programs_helper.c index 49185c254b..661a5b5645 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/programs_helper.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/programs_helper.c @@ -1,3 +1,29 @@ +/*- + * Copyright (c) 2019 -2020 Felix Weinrank + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ #ifdef _WIN32 #define _CRT_SECURE_NO_WARNINGS @@ -19,24 +45,76 @@ #include "programs_helper.h" +#define DEFAULT_TARGET stdout; + +static FILE *debug_target = NULL; + #ifdef _WIN32 static void gettimeofday(struct timeval *tv, void *ignore) { - struct timeb tb; + FILETIME filetime; + ULARGE_INTEGER ularge; - ftime(&tb); - tv->tv_sec = (long)tb.time; - tv->tv_usec = (long)(tb.millitm) * 1000L; + GetSystemTimeAsFileTime(&filetime); + ularge.LowPart = filetime.dwLowDateTime; + ularge.HighPart = filetime.dwHighDateTime; + /* Change base from Jan 1 1601 00:00:00 to Jan 1 1970 00:00:00 */ +#if defined(__MINGW32__) + ularge.QuadPart -= 116444736000000000ULL; +#else + ularge.QuadPart -= 116444736000000000UI64; +#endif + /* + * ularge.QuadPart is now the number of 100-nanosecond intervals + * since Jan 1 1970 00:00:00. + */ +#if defined(__MINGW32__) + tv->tv_sec = (long)(ularge.QuadPart / 10000000ULL); + tv->tv_usec = (long)((ularge.QuadPart % 10000000ULL) / 10ULL); +#else + tv->tv_sec = (long)(ularge.QuadPart / 10000000UI64); + tv->tv_usec = (long)((ularge.QuadPart % 10000000UI64) / 10UI64); +#endif } #endif void -debug_printf_runtime(void) { +debug_set_target(FILE *fp) { + debug_target = fp; +} + +void +debug_printf_clean(const char *format, ...) { + char charbuf[1024]; + va_list ap; + + if (debug_target == NULL) { + debug_target = DEFAULT_TARGET; + } + + va_start(ap, format); + if (vsnprintf(charbuf, 1024, format, ap) < 0) { + charbuf[0] = '\0'; + } + va_end(ap); + + fprintf(debug_target, "%s", charbuf); + fflush(debug_target); +} + +void +debug_printf(const char *format, ...) { + va_list ap; + char charbuf[1024]; static struct timeval time_main; struct timeval time_now; struct timeval time_delta; + if (debug_target == NULL) { + debug_target = DEFAULT_TARGET; + } + if (time_main.tv_sec == 0 && time_main.tv_usec == 0) { gettimeofday(&time_main, NULL); } @@ -44,18 +122,44 @@ debug_printf_runtime(void) { gettimeofday(&time_now, NULL); timersub(&time_now, &time_main, &time_delta); - fprintf(stderr, "[%u.%03u] ", (unsigned int) time_delta.tv_sec, (unsigned int) time_delta.tv_usec / 1000); -} + va_start(ap, format); + if (vsnprintf(charbuf, 1024, format, ap) < 0) { + charbuf[0] = '\0'; + } + va_end(ap); + fprintf(debug_target, "[P][%u.%03u] %s", (unsigned int) time_delta.tv_sec, (unsigned int) time_delta.tv_usec / 1000, charbuf); + fflush(debug_target); +} void debug_printf_stack(const char *format, ...) { va_list ap; + char charbuf[1024]; + static struct timeval time_main; + struct timeval time_now; + struct timeval time_delta; + + if (debug_target == NULL) { + debug_target = DEFAULT_TARGET; + } + + if (time_main.tv_sec == 0 && time_main.tv_usec == 0) { + gettimeofday(&time_main, NULL); + } + + gettimeofday(&time_now, NULL); + timersub(&time_now, &time_main, &time_delta); va_start(ap, format); - vprintf(format, ap); + if (vsnprintf(charbuf, 1024, format, ap) < 0) { + charbuf[0] = '\0'; + } va_end(ap); + + fprintf(debug_target, "[S][%u.%03u] %s", (unsigned int) time_delta.tv_sec, (unsigned int) time_delta.tv_usec / 1000, charbuf); + fflush(debug_target); } static void @@ -63,63 +167,70 @@ handle_association_change_event(struct sctp_assoc_change *sac) { unsigned int i, n; - fprintf(stderr, "Association change "); + if (debug_target == NULL) { + debug_target = DEFAULT_TARGET; + } + + fprintf(debug_target, "Association change "); switch (sac->sac_state) { case SCTP_COMM_UP: - fprintf(stderr, "SCTP_COMM_UP"); + fprintf(debug_target, "SCTP_COMM_UP"); break; case SCTP_COMM_LOST: - fprintf(stderr, "SCTP_COMM_LOST"); + fprintf(debug_target, "SCTP_COMM_LOST"); break; case SCTP_RESTART: - fprintf(stderr, "SCTP_RESTART"); + fprintf(debug_target, "SCTP_RESTART"); break; case SCTP_SHUTDOWN_COMP: - fprintf(stderr, "SCTP_SHUTDOWN_COMP"); + fprintf(debug_target, "SCTP_SHUTDOWN_COMP"); break; case SCTP_CANT_STR_ASSOC: - fprintf(stderr, "SCTP_CANT_STR_ASSOC"); + fprintf(debug_target, "SCTP_CANT_STR_ASSOC"); break; default: - fprintf(stderr, "UNKNOWN"); + fprintf(debug_target, "UNKNOWN"); break; } - fprintf(stderr, ", streams (in/out) = (%u/%u)", + fprintf(debug_target, ", streams (in/out) = (%u/%u)", sac->sac_inbound_streams, sac->sac_outbound_streams); n = sac->sac_length - sizeof(struct sctp_assoc_change); if (((sac->sac_state == SCTP_COMM_UP) || (sac->sac_state == SCTP_RESTART)) && (n > 0)) { - fprintf(stderr, ", supports"); + fprintf(debug_target, ", supports"); for (i = 0; i < n; i++) { switch (sac->sac_info[i]) { case SCTP_ASSOC_SUPPORTS_PR: - fprintf(stderr, " PR"); + fprintf(debug_target, " PR"); break; case SCTP_ASSOC_SUPPORTS_AUTH: - fprintf(stderr, " AUTH"); + fprintf(debug_target, " AUTH"); break; case SCTP_ASSOC_SUPPORTS_ASCONF: - fprintf(stderr, " ASCONF"); + fprintf(debug_target, " ASCONF"); break; case SCTP_ASSOC_SUPPORTS_MULTIBUF: - fprintf(stderr, " MULTIBUF"); + fprintf(debug_target, " MULTIBUF"); break; case SCTP_ASSOC_SUPPORTS_RE_CONFIG: - fprintf(stderr, " RE-CONFIG"); + fprintf(debug_target, " RE-CONFIG"); + break; + case SCTP_ASSOC_SUPPORTS_INTERLEAVING: + fprintf(debug_target, " INTERLEAVING"); break; default: - fprintf(stderr, " UNKNOWN(0x%02x)", sac->sac_info[i]); + fprintf(debug_target, " UNKNOWN(0x%02x)", sac->sac_info[i]); break; } } } else if (((sac->sac_state == SCTP_COMM_LOST) || (sac->sac_state == SCTP_CANT_STR_ASSOC)) && (n > 0)) { - fprintf(stderr, ", ABORT ="); + fprintf(debug_target, ", ABORT ="); for (i = 0; i < n; i++) { - fprintf(stderr, " 0x%02x", sac->sac_info[i]); + fprintf(debug_target, " 0x%02x", sac->sac_info[i]); } } - fprintf(stderr, ".\n"); + fprintf(debug_target, ".\n"); return; } @@ -132,6 +243,10 @@ handle_peer_address_change_event(struct sctp_paddr_change *spc) struct sockaddr_in6 *sin6; struct sockaddr_conn *sconn; + if (debug_target == NULL) { + debug_target = DEFAULT_TARGET; + } + switch (spc->spc_aaddr.ss_family) { case AF_INET: sin = (struct sockaddr_in *)&spc->spc_aaddr; @@ -144,46 +259,50 @@ handle_peer_address_change_event(struct sctp_paddr_change *spc) case AF_CONN: sconn = (struct sockaddr_conn *)&spc->spc_aaddr; #ifdef _WIN32 - _snprintf(addr_buf, INET6_ADDRSTRLEN, "%p", sconn->sconn_addr); + if (_snprintf(addr_buf, INET6_ADDRSTRLEN, "%p", sconn->sconn_addr) < 0) { #else - snprintf(addr_buf, INET6_ADDRSTRLEN, "%p", sconn->sconn_addr); + if (snprintf(addr_buf, INET6_ADDRSTRLEN, "%p", sconn->sconn_addr) < 0) { #endif + addr_buf[0] = '\0'; + } addr = addr_buf; break; default: #ifdef _WIN32 - _snprintf(addr_buf, INET6_ADDRSTRLEN, "Unknown family %d", spc->spc_aaddr.ss_family); + if (_snprintf(addr_buf, INET6_ADDRSTRLEN, "Unknown family %d", spc->spc_aaddr.ss_family) < 0) { #else - snprintf(addr_buf, INET6_ADDRSTRLEN, "Unknown family %d", spc->spc_aaddr.ss_family); + if (snprintf(addr_buf, INET6_ADDRSTRLEN, "Unknown family %d", spc->spc_aaddr.ss_family) < 0) { #endif + addr_buf[0] = '\0'; + } addr = addr_buf; break; } - fprintf(stderr, "Peer address %s is now ", addr); + fprintf(debug_target, "Peer address %s is now ", addr); switch (spc->spc_state) { case SCTP_ADDR_AVAILABLE: - fprintf(stderr, "SCTP_ADDR_AVAILABLE"); + fprintf(debug_target, "SCTP_ADDR_AVAILABLE"); break; case SCTP_ADDR_UNREACHABLE: - fprintf(stderr, "SCTP_ADDR_UNREACHABLE"); + fprintf(debug_target, "SCTP_ADDR_UNREACHABLE"); break; case SCTP_ADDR_REMOVED: - fprintf(stderr, "SCTP_ADDR_REMOVED"); + fprintf(debug_target, "SCTP_ADDR_REMOVED"); break; case SCTP_ADDR_ADDED: - fprintf(stderr, "SCTP_ADDR_ADDED"); + fprintf(debug_target, "SCTP_ADDR_ADDED"); break; case SCTP_ADDR_MADE_PRIM: - fprintf(stderr, "SCTP_ADDR_MADE_PRIM"); + fprintf(debug_target, "SCTP_ADDR_MADE_PRIM"); break; case SCTP_ADDR_CONFIRMED: - fprintf(stderr, "SCTP_ADDR_CONFIRMED"); + fprintf(debug_target, "SCTP_ADDR_CONFIRMED"); break; default: - fprintf(stderr, "UNKNOWN"); + fprintf(debug_target, "UNKNOWN"); break; } - fprintf(stderr, " (error = 0x%08x).\n", spc->spc_error); + fprintf(debug_target, " (error = 0x%08x).\n", spc->spc_error); return; } @@ -192,37 +311,49 @@ handle_send_failed_event(struct sctp_send_failed_event *ssfe) { size_t i, n; + if (debug_target == NULL) { + debug_target = DEFAULT_TARGET; + } + if (ssfe->ssfe_flags & SCTP_DATA_UNSENT) { - fprintf(stderr, "Unsent "); + fprintf(debug_target, "Unsent "); } if (ssfe->ssfe_flags & SCTP_DATA_SENT) { - fprintf(stderr, "Sent "); + fprintf(debug_target, "Sent "); } if (ssfe->ssfe_flags & ~(SCTP_DATA_SENT | SCTP_DATA_UNSENT)) { - fprintf(stderr, "(flags = %x) ", ssfe->ssfe_flags); + fprintf(debug_target, "(flags = %x) ", ssfe->ssfe_flags); } - fprintf(stderr, "message with PPID = %u, SID = %u, flags: 0x%04x due to error = 0x%08x", - ntohl(ssfe->ssfe_info.snd_ppid), ssfe->ssfe_info.snd_sid, + fprintf(debug_target, "message with PPID = %u, SID = %u, flags: 0x%04x due to error = 0x%08x", + (uint32_t)ntohl(ssfe->ssfe_info.snd_ppid), ssfe->ssfe_info.snd_sid, ssfe->ssfe_info.snd_flags, ssfe->ssfe_error); n = ssfe->ssfe_length - sizeof(struct sctp_send_failed_event); for (i = 0; i < n; i++) { - fprintf(stderr, " 0x%02x", ssfe->ssfe_data[i]); + fprintf(debug_target, " 0x%02x", ssfe->ssfe_data[i]); } - fprintf(stderr, ".\n"); + fprintf(debug_target, ".\n"); return; } static void handle_adaptation_indication(struct sctp_adaptation_event *sai) { - fprintf(stderr, "Adaptation indication: %x.\n", sai-> sai_adaptation_ind); + if (debug_target == NULL) { + debug_target = DEFAULT_TARGET; + } + + fprintf(debug_target, "Adaptation indication: %x.\n", sai-> sai_adaptation_ind); return; } static void handle_shutdown_event(struct sctp_shutdown_event *sse) { - fprintf(stderr, "Shutdown event.\n"); + if (debug_target == NULL) { + debug_target = DEFAULT_TARGET; + } + + fprintf(debug_target, "Shutdown event.\n"); /* XXX: notify all channels. */ return; } @@ -232,32 +363,40 @@ handle_stream_reset_event(struct sctp_stream_reset_event *strrst) { uint32_t n, i; + if (debug_target == NULL) { + debug_target = DEFAULT_TARGET; + } + n = (strrst->strreset_length - sizeof(struct sctp_stream_reset_event)) / sizeof(uint16_t); - fprintf(stderr, "Stream reset event: flags = %x, ", strrst->strreset_flags); + fprintf(debug_target, "Stream reset event: flags = %x, ", strrst->strreset_flags); if (strrst->strreset_flags & SCTP_STREAM_RESET_INCOMING_SSN) { if (strrst->strreset_flags & SCTP_STREAM_RESET_OUTGOING_SSN) { - fprintf(stderr, "incoming/"); + fprintf(debug_target, "incoming/"); } - fprintf(stderr, "incoming "); + fprintf(debug_target, "incoming "); } if (strrst->strreset_flags & SCTP_STREAM_RESET_OUTGOING_SSN) { - fprintf(stderr, "outgoing "); + fprintf(debug_target, "outgoing "); } - fprintf(stderr, "stream ids = "); + fprintf(debug_target, "stream ids = "); for (i = 0; i < n; i++) { if (i > 0) { - fprintf(stderr, ", "); + fprintf(debug_target, ", "); } - fprintf(stderr, "%d", strrst->strreset_stream_list[i]); + fprintf(debug_target, "%d", strrst->strreset_stream_list[i]); } - fprintf(stderr, ".\n"); + fprintf(debug_target, ".\n"); return; } static void handle_stream_change_event(struct sctp_stream_change_event *strchg) { - fprintf(stderr, "Stream change event: streams (in/out) = (%u/%u), flags = %x.\n", + if (debug_target == NULL) { + debug_target = DEFAULT_TARGET; + } + + fprintf(debug_target, "Stream change event: streams (in/out) = (%u/%u), flags = %x.\n", strchg->strchange_instrms, strchg->strchange_outstrms, strchg->strchange_flags); return; } @@ -267,12 +406,16 @@ handle_remote_error_event(struct sctp_remote_error *sre) { size_t i, n; - n = sre->sre_length - sizeof(struct sctp_remote_error); - fprintf(stderr, "Remote Error (error = 0x%04x): ", sre->sre_error); - for (i = 0; i < n; i++) { - fprintf(stderr, " 0x%02x", sre-> sre_data[i]); + if (debug_target == NULL) { + debug_target = DEFAULT_TARGET; } - fprintf(stderr, ".\n"); + + n = sre->sre_length - sizeof(struct sctp_remote_error); + fprintf(debug_target, "Remote Error (error = 0x%04x): ", sre->sre_error); + for (i = 0; i < n; i++) { + fprintf(debug_target, " 0x%02x", sre-> sre_data[i]); + } + fprintf(debug_target, ".\n"); return; } @@ -283,54 +426,58 @@ handle_notification(union sctp_notification *notif, size_t n) return; } - fprintf(stderr, "handle_notification : "); + if (debug_target == NULL) { + debug_target = DEFAULT_TARGET; + } + + fprintf(debug_target, "handle_notification : "); switch (notif->sn_header.sn_type) { case SCTP_ASSOC_CHANGE: - fprintf(stderr, "SCTP_ASSOC_CHANGE\n"); + fprintf(debug_target, "SCTP_ASSOC_CHANGE\n"); handle_association_change_event(&(notif->sn_assoc_change)); break; case SCTP_PEER_ADDR_CHANGE: - fprintf(stderr, "SCTP_PEER_ADDR_CHANGE\n"); + fprintf(debug_target, "SCTP_PEER_ADDR_CHANGE\n"); handle_peer_address_change_event(&(notif->sn_paddr_change)); break; case SCTP_REMOTE_ERROR: - fprintf(stderr, "SCTP_REMOTE_ERROR\n"); + fprintf(debug_target, "SCTP_REMOTE_ERROR\n"); handle_remote_error_event(&(notif->sn_remote_error)); break; case SCTP_SHUTDOWN_EVENT: - fprintf(stderr, "SCTP_SHUTDOWN_EVENT\n"); + fprintf(debug_target, "SCTP_SHUTDOWN_EVENT\n"); handle_shutdown_event(&(notif->sn_shutdown_event)); break; case SCTP_ADAPTATION_INDICATION: - fprintf(stderr, "SCTP_ADAPTATION_INDICATION\n"); + fprintf(debug_target, "SCTP_ADAPTATION_INDICATION\n"); handle_adaptation_indication(&(notif->sn_adaptation_event)); break; case SCTP_PARTIAL_DELIVERY_EVENT: - fprintf(stderr, "SCTP_PARTIAL_DELIVERY_EVENT\n"); + fprintf(debug_target, "SCTP_PARTIAL_DELIVERY_EVENT\n"); break; case SCTP_AUTHENTICATION_EVENT: - fprintf(stderr, "SCTP_AUTHENTICATION_EVENT\n"); + fprintf(debug_target, "SCTP_AUTHENTICATION_EVENT\n"); break; case SCTP_SENDER_DRY_EVENT: - fprintf(stderr, "SCTP_SENDER_DRY_EVENT\n"); + fprintf(debug_target, "SCTP_SENDER_DRY_EVENT\n"); break; case SCTP_NOTIFICATIONS_STOPPED_EVENT: - fprintf(stderr, "SCTP_NOTIFICATIONS_STOPPED_EVENT\n"); + fprintf(debug_target, "SCTP_NOTIFICATIONS_STOPPED_EVENT\n"); break; case SCTP_SEND_FAILED_EVENT: - fprintf(stderr, "SCTP_SEND_FAILED_EVENT\n"); + fprintf(debug_target, "SCTP_SEND_FAILED_EVENT\n"); handle_send_failed_event(&(notif->sn_send_failed_event)); break; case SCTP_STREAM_RESET_EVENT: - fprintf(stderr, "SCTP_STREAM_RESET_EVENT\n"); + fprintf(debug_target, "SCTP_STREAM_RESET_EVENT\n"); handle_stream_reset_event(&(notif->sn_strreset_event)); break; case SCTP_ASSOC_RESET_EVENT: - fprintf(stderr, "SCTP_ASSOC_RESET_EVENT\n"); + fprintf(debug_target, "SCTP_ASSOC_RESET_EVENT\n"); break; case SCTP_STREAM_CHANGE_EVENT: - fprintf(stderr, "SCTP_STREAM_CHANGE_EVENT\n"); + fprintf(debug_target, "SCTP_STREAM_CHANGE_EVENT\n"); handle_stream_change_event(&(notif->sn_strchange_event)); break; default: diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/programs_helper.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/programs_helper.h index 2a1da5f5d0..97a471017f 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/programs_helper.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/programs_helper.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2019 Felix Weinrank + * Copyright (c) 2020 Felix Weinrank * * All rights reserved. * @@ -73,15 +73,18 @@ handle_notification(union sctp_notification *notif, size_t n); #endif void -debug_printf_runtime(void); +debug_printf(const char *format, ...); + +void +debug_printf_clean(const char *format, ...); void debug_printf_stack(const char *format, ...); -#define debug_printf(...) \ - do { \ - fprintf(stderr, "[P]"); \ - debug_printf_runtime(); \ - fprintf(stderr, __VA_ARGS__); \ - } while (0) +void +debug_set_target(FILE *fp); + +#define FUZZER_ASSERT(x) if (!(x)) { printf("USRSCTP assertion failed: function %s, file %s, line %d.\n", __PRETTY_FUNCTION__, __FILE__, __LINE__); abort(); } + + #endif /* __PROGRAMS_HELPER_H__ */ diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/rtcweb.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/rtcweb.c index 1bf3b1827d..149ecfa04d 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/rtcweb.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/rtcweb.c @@ -619,7 +619,7 @@ handle_open_request_message(struct peer_connection *pc, uint8_t unordered; if ((channel = find_channel_by_i_stream(pc, i_stream))) { - printf("handle_open_request_message: channel %d is in state %d instead of CLOSED.\n", + printf("handle_open_request_message: channel %u is in state %u instead of CLOSED.\n", channel->id, channel->state); /* XXX: some error handling */ return; @@ -707,12 +707,12 @@ handle_open_response_message(struct peer_connection *pc, } if (channel->state != DATA_CHANNEL_CONNECTING) { /* XXX: improve error handling */ - printf("handle_open_response_message: Channel with id %d for outgoing steam %d is in state %d.\n", channel->id, o_stream, channel->state); + printf("handle_open_response_message: Channel with id %u for outgoing steam %u is in state %u.\n", channel->id, o_stream, channel->state); return; } if (find_channel_by_i_stream(pc, i_stream)) { /* XXX: improve error handling */ - printf("handle_open_response_message: Channel collision for channel with id %d and streams (in/out) = (%d/%d).\n", channel->id, i_stream, o_stream); + printf("handle_open_response_message: Channel collision for channel with id %u and streams (in/out) = (%u/%u).\n", channel->id, i_stream, o_stream); return; } channel->i_stream = i_stream; @@ -778,7 +778,7 @@ handle_data_message(struct peer_connection *pc, } else { /* Assuming DATA_CHANNEL_PPID_DOMSTRING */ /* XXX: Protect for non 0 terminated buffer */ - printf("Message received of length %zu on channel with id %d: %.*s\n", + printf("Message received of length %zu on channel with id %u: %.*s\n", length, channel->id, (int)length, buffer); } return; @@ -887,6 +887,9 @@ handle_association_change_event(struct sctp_assoc_change *sac) case SCTP_ASSOC_SUPPORTS_RE_CONFIG: printf(" RE-CONFIG"); break; + case SCTP_ASSOC_SUPPORTS_INTERLEAVING: + printf(" INTERLEAVING"); + break; default: printf(" UNKNOWN(0x%02x)", sac->sac_info[i]); break; @@ -927,10 +930,12 @@ handle_peer_address_change_event(struct sctp_paddr_change *spc) break; default: #ifdef _WIN32 - _snprintf(addr_buf, INET6_ADDRSTRLEN, "Unknown family %d", spc->spc_aaddr.ss_family); + if (_snprintf(addr_buf, INET6_ADDRSTRLEN, "Unknown family %d", spc->spc_aaddr.ss_family) < 0) { #else - snprintf(addr_buf, INET6_ADDRSTRLEN, "Unknown family %d", spc->spc_aaddr.ss_family); + if (snprintf(addr_buf, INET6_ADDRSTRLEN, "Unknown family %d", spc->spc_aaddr.ss_family) < 0) { #endif + addr_buf[0] = '\0'; + } addr = addr_buf; break; } @@ -1120,7 +1125,7 @@ handle_send_failed_event(struct sctp_send_failed_event *ssfe) printf("(flags = %x) ", ssfe->ssfe_flags); } printf("message with PPID = %u, SID = %u, flags: 0x%04x due to error = 0x%08x", - ntohl(ssfe->ssfe_info.snd_ppid), ssfe->ssfe_info.snd_sid, + (uint32_t)ntohl(ssfe->ssfe_info.snd_ppid), ssfe->ssfe_info.snd_sid, ssfe->ssfe_info.snd_flags, ssfe->ssfe_error); n = ssfe->ssfe_length - sizeof(struct sctp_send_failed_event); for (i = 0; i < n; i++) { diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/st_client.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/st_client.c index da5c53bca2..8f2cc33825 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/st_client.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/st_client.c @@ -67,23 +67,26 @@ static int connecting = 0; static int finish = 0; -static unsigned int -get_tick_count(void) +static uint64_t +get_milliseconds_count(void) { #ifdef _WIN32 - return GetTickCount(); + // obtain number of milliseconds since system started + return GetTickCount64(); #else struct timeval tv; - unsigned int milliseconds; gettimeofday(&tv, NULL); /* get current time */ - milliseconds = tv.tv_sec*1000LL + tv.tv_usec/1000; /* calculate milliseconds */ - return (milliseconds); + return (tv.tv_sec * 1000LL + tv.tv_usec / 1000); #endif } static void +#ifdef _WIN32 +handle_events(SOCKET sock, struct socket* s, void* sconn_addr) +#else handle_events(int sock, struct socket* s, void* sconn_addr) +#endif { char *dump_buf; ssize_t length; @@ -92,26 +95,30 @@ handle_events(int sock, struct socket* s, void* sconn_addr) fd_set rfds; struct timeval tv; - unsigned next_fire_time = get_tick_count(); - unsigned last_fire_time = next_fire_time; - unsigned now = get_tick_count(); - int wait_time; + uint64_t next_fire_time = get_milliseconds_count(); + uint64_t last_fire_time = next_fire_time; + uint64_t now = get_milliseconds_count(); + uint32_t wait_time; while (!finish) { - if ((int) (now - next_fire_time) > 0) { - usrsctp_handle_timers(now - last_fire_time); + if (now > next_fire_time) { + usrsctp_handle_timers((uint32_t)(now - last_fire_time)); last_fire_time = now; next_fire_time = now + TIMER_INTERVAL_MSECS; } - wait_time = next_fire_time - now; + wait_time = (uint32_t)(next_fire_time - now); tv.tv_sec = wait_time / 1000; tv.tv_usec = (wait_time % 1000) * 1000; FD_ZERO(&rfds); FD_SET(sock, &rfds); +#ifdef _WIN32 + select(0 /* ignored */, &rfds, NULL, NULL, &tv); +#else select(sock + 1, &rfds, NULL, NULL, &tv); +#endif if (FD_ISSET(sock, &rfds)) { length = recv(sock, buf, MAX_PACKET_SIZE, 0); @@ -137,6 +144,9 @@ on_connect(struct socket* s) /* memset(buffer, 'A', BUFFER_SIZE); */ /* bufferlen = BUFFER_SIZE; */ bufferlen = snprintf(buffer, BUFFER_SIZE, "GET / HTTP/1.0\r\nUser-agent: libusrsctp\r\nConnection: close\r\n\r\n"); + if (bufferlen < 0) { + return; + } sndinfo.snd_sid = 0; sndinfo.snd_flags = 0; sndinfo.snd_ppid = htonl(DISCARD_PPID); @@ -179,14 +189,14 @@ on_socket_readable(struct socket* s) { if (flags & MSG_NOTIFICATION) { printf("Notification of length %d received.\n", (int)retval); } else { - printf("Msg of length %d received via %p:%u on stream %d with SSN %u and TSN %u, PPID %d, context %u.\n", + printf("Msg of length %d received via %p:%u on stream %d with SSN %u and TSN %u, PPID %u, context %u.\n", (int)retval, addr.sconn.sconn_addr, ntohs(addr.sconn.sconn_port), rcv_info.rcv_sid, rcv_info.rcv_ssn, rcv_info.rcv_tsn, - ntohl(rcv_info.rcv_ppid), + (uint32_t)ntohl(rcv_info.rcv_ppid), rcv_info.rcv_context); } } @@ -271,20 +281,20 @@ main(int argc, char *argv[]) #ifdef _WIN32 if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0) { printf("WSAStartup failed\n"); - return (-1); + exit(EXIT_FAILURE); } #endif usrsctp_init_nothreads(0, conn_output, debug_printf_stack); /* set up a connected UDP socket */ #ifdef _WIN32 if ((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) { - printf("socket() failed with error: %ld\n", WSAGetLastError()); - return (-1); + printf("socket() failed with error: %d\n", WSAGetLastError()); + exit(EXIT_FAILURE); } #else if ((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { perror("socket"); - return (-1); + exit(EXIT_FAILURE); } #endif memset(&sin, 0, sizeof(struct sockaddr_in)); @@ -295,17 +305,17 @@ main(int argc, char *argv[]) sin.sin_port = htons(atoi(argv[2])); if (!inet_pton(AF_INET, argv[1], &sin.sin_addr.s_addr)){ printf("error: invalid address\n"); - return (-1); + exit(EXIT_FAILURE); } #ifdef _WIN32 if (bind(fd, (struct sockaddr *)&sin, sizeof(struct sockaddr_in)) == SOCKET_ERROR) { - printf("bind() failed with error: %ld\n", WSAGetLastError()); - return (-1); + printf("bind() failed with error: %d\n", WSAGetLastError()); + exit(EXIT_FAILURE); } #else if (bind(fd, (struct sockaddr *)&sin, sizeof(struct sockaddr_in)) < 0) { perror("bind"); - return (-1); + exit(EXIT_FAILURE); } #endif memset(&sin, 0, sizeof(struct sockaddr_in)); @@ -316,17 +326,17 @@ main(int argc, char *argv[]) sin.sin_port = htons(atoi(argv[4])); if (!inet_pton(AF_INET, argv[3], &sin.sin_addr.s_addr)){ printf("error: invalid address\n"); - return (-1); + exit(EXIT_FAILURE); } #ifdef _WIN32 if (connect(fd, (struct sockaddr *)&sin, sizeof(struct sockaddr_in)) == SOCKET_ERROR) { - printf("connect() failed with error: %ld\n", WSAGetLastError()); - return (-1); + printf("connect() failed with error: %d\n", WSAGetLastError()); + exit(EXIT_FAILURE); } #else if (connect(fd, (struct sockaddr *)&sin, sizeof(struct sockaddr_in)) < 0) { perror("connect"); - return (-1); + exit(EXIT_FAILURE); } #endif #ifdef SCTP_DEBUG @@ -337,7 +347,7 @@ main(int argc, char *argv[]) if ((s = usrsctp_socket(AF_CONN, SOCK_STREAM, IPPROTO_SCTP, NULL, NULL, 0, NULL)) == NULL) { perror("usrsctp_socket"); - return (-1); + exit(EXIT_FAILURE); } usrsctp_setsockopt(s, IPPROTO_SCTP, SCTP_RECVRCVINFO, &on, sizeof(int)); @@ -353,7 +363,7 @@ main(int argc, char *argv[]) sconn.sconn_addr = NULL; if (usrsctp_bind(s, (struct sockaddr *)&sconn, sizeof(struct sockaddr_conn)) < 0) { perror("usrsctp_bind"); - return (-1); + exit(EXIT_FAILURE); } memset(&sconn, 0, sizeof(struct sockaddr_conn)); @@ -368,7 +378,7 @@ main(int argc, char *argv[]) if (retval < 0 && errno != EWOULDBLOCK && errno != EINPROGRESS) { perror("usrsctp_connect"); - return (-1); + exit(EXIT_FAILURE); } connecting = 1; diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/tsctp.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/tsctp.c index c2fa4aedd3..53e1f8c291 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/tsctp.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/tsctp.c @@ -50,6 +50,7 @@ #include #include #include +#include #ifdef LINUX #include #endif @@ -67,6 +68,8 @@ struct socket *psock = NULL; static struct timeval start_time; unsigned int runtime = 0; +static int policy = 0; +static unsigned int timetolive = 0; static unsigned long cb_messages = 0; static unsigned long long cb_first_length = 0; static unsigned long long cb_sum = 0; @@ -76,11 +79,29 @@ static unsigned int use_cb = 0; static void gettimeofday(struct timeval *tv, void *ignore) { - struct timeb tb; + FILETIME filetime; + ULARGE_INTEGER ularge; - ftime(&tb); - tv->tv_sec = (long)tb.time; - tv->tv_usec = tb.millitm * 1000; + GetSystemTimeAsFileTime(&filetime); + ularge.LowPart = filetime.dwLowDateTime; + ularge.HighPart = filetime.dwHighDateTime; + /* Change base from Jan 1 1601 00:00:00 to Jan 1 1970 00:00:00 */ +#if defined(__MINGW32__) + ularge.QuadPart -= 116444736000000000ULL; +#else + ularge.QuadPart -= 116444736000000000UI64; +#endif + /* + * ularge.QuadPart is now the number of 100-nanosecond intervals + * since Jan 1 1970 00:00:00. + */ +#if defined(__MINGW32__) + tv->tv_sec = (long)(ularge.QuadPart / 10000000ULL); + tv->tv_usec = (long)((ularge.QuadPart % 10000000ULL) / 10ULL); +#else + tv->tv_sec = (long)(ularge.QuadPart / 10000000UI64); + tv->tv_usec = (long)((ularge.QuadPart % 10000000UI64) / 10UI64); +#endif } #endif @@ -90,14 +111,18 @@ char Usage[] = "Options:\n" " -a set adaptation layer indication\n" " -c use callback API\n" +" -d time in seconds after which a status update is printed\n" +" -D turns Nagle off\n" " -E local UDP encapsulation port (default 9899)\n" " -f fragmentation point\n" " -l message length\n" " -L bind to local IP (default INADDR_ANY)\n" " -n number of messages sent (0 means infinite)/received\n" -" -D turns Nagle off\n" +" -p port number\n" +" -P partial reliability policy to use (0=none (default), 1=ttl, 2=rtx, 3=buf)\n" " -R socket recv buffer\n" " -S socket send buffer\n" +" -t based on -P the time to live, number of retransmissions, or priority for messages\n" " -T time to send messages\n" " -u use unordered user messages\n" " -U remote UDP encapsulation port\n" @@ -111,13 +136,23 @@ char Usage[] = #define BUFFERSIZE (1<<16) static int verbose, very_verbose; -static unsigned int done; +static unsigned int done; +static unsigned int round_duration; void stop_sender(int sig) { done = 1; } +static time_t calc_round_timeout(struct timeval round_start) +{ + time_t round_timeout = round_start.tv_sec + round_duration; + if (round_start.tv_usec >= 500000) { + round_timeout++; + } + return round_timeout; +} + #ifdef _WIN32 static DWORD WINAPI #else @@ -148,6 +183,9 @@ handle_connection(void *arg) unsigned long messages = 0; unsigned long long first_length = 0; unsigned long long sum = 0; + unsigned long long round_bytes = 0; + struct timeval round_start = (struct timeval){0}; + time_t round_timeout = 0; conn_sock = *(struct socket **)arg; @@ -165,6 +203,11 @@ handle_connection(void *arg) &infolen, &infotype, &flags); gettimeofday(&time_start, NULL); + if (round_duration > 0) { + gettimeofday(&round_start, NULL); + round_timeout = calc_round_timeout(round_start); + } + while (n > 0) { recv_calls++; if (flags & MSG_NOTIFICATION) { @@ -174,7 +217,7 @@ handle_connection(void *arg) snp = (union sctp_notification *)buf; if (snp->sn_header.sn_type == SCTP_PEER_ADDR_CHANGE) { spc = &snp->sn_paddr_change; - printf("SCTP_PEER_ADDR_CHANGE: state=%d, error=%d\n",spc->spc_state, spc->spc_error); + printf("SCTP_PEER_ADDR_CHANGE: state=%u, error=%u\n",spc->spc_state, spc->spc_error); } } else { if (very_verbose) { @@ -186,8 +229,21 @@ handle_connection(void *arg) if (first_length == 0) { first_length = sum; } + if (round_duration > 0) { + round_bytes += first_length; + } } } + if (round_duration > 0 && round_timeout <= time(NULL)) { + gettimeofday(&time_now, NULL); + timersub(&time_now, &round_start, &time_diff); + seconds = time_diff.tv_sec + (double)time_diff.tv_usec/1000000.0; + fprintf(stdout, "throughput for the last %f seconds: %f B/s\n", seconds, (double)round_bytes / seconds); + + round_bytes = 0; + gettimeofday(&round_start, NULL); + round_timeout = calc_round_timeout(round_start); + } flags = 0; len = (socklen_t)sizeof(struct sockaddr_in); infolen = sizeof(struct sctp_recvv_rn); @@ -215,10 +271,10 @@ handle_connection(void *arg) } static int -send_cb(struct socket *sock, uint32_t sb_free) { - struct sctp_sndinfo sndinfo; +send_cb(struct socket *sock, uint32_t sb_free, void *ulp_info) { + struct sctp_sendv_spa sendv_spa; - if ((cb_messages == 0) & verbose) { + if ((cb_messages == 0) && verbose) { printf("Start sending "); if (number_of_messages > 0) { printf("%ld messages ", (long)number_of_messages); @@ -230,14 +286,44 @@ send_cb(struct socket *sock, uint32_t sb_free) { fflush(stdout); } - sndinfo.snd_sid = 0; - sndinfo.snd_flags = 0; + sendv_spa.sendv_flags = SCTP_SEND_SNDINFO_VALID | SCTP_SEND_PRINFO_VALID; + + sendv_spa.sendv_sndinfo.snd_sid = 0; + sendv_spa.sendv_sndinfo.snd_flags = 0; if (unordered != 0) { - sndinfo.snd_flags |= SCTP_UNORDERED; + sendv_spa.sendv_sndinfo.snd_flags |= SCTP_UNORDERED; } - sndinfo.snd_ppid = 0; - sndinfo.snd_context = 0; - sndinfo.snd_assoc_id = 0; + sendv_spa.sendv_sndinfo.snd_ppid = 0; + sendv_spa.sendv_sndinfo.snd_context = 0; + sendv_spa.sendv_sndinfo.snd_assoc_id = 0; + + sendv_spa.sendv_prinfo.pr_policy = 0; + switch (policy) { +#ifdef SCTP_PR_SCTP_NONE + case 0: + sendv_spa.sendv_prinfo.pr_policy = SCTP_PR_SCTP_NONE; + break; +#endif +#ifdef SCTP_PR_SCTP_TTL + case 1: + sendv_spa.sendv_prinfo.pr_policy = SCTP_PR_SCTP_TTL; + break; +#endif +#ifdef SCTP_PR_SCTP_RTX + case 2: + sendv_spa.sendv_prinfo.pr_policy = SCTP_PR_SCTP_RTX; + break; +#endif +#ifdef SCTP_PR_SCTP_BUF + case 3: + sendv_spa.sendv_prinfo.pr_policy = SCTP_PR_SCTP_BUF; + break; +#endif + default: + printf("Unknown PR-SCTP policy.\n"); + break; + } + sendv_spa.sendv_prinfo.pr_value = timetolive; while (!done && ((number_of_messages == 0) || (cb_messages < (number_of_messages - 1)))) { if (very_verbose) { @@ -246,7 +332,7 @@ send_cb(struct socket *sock, uint32_t sb_free) { if (usrsctp_sendv(psock, buffer, length, (struct sockaddr *) &remote_addr, 1, - (void *)&sndinfo, (socklen_t)sizeof(struct sctp_sndinfo), SCTP_SENDV_SNDINFO, + (void *)&sendv_spa, (socklen_t)sizeof(struct sctp_sendv_spa), SCTP_SENDV_SPA, 0) < 0) { if (errno != EWOULDBLOCK && errno != EAGAIN) { perror("usrsctp_sendv (cb)"); @@ -266,9 +352,9 @@ send_cb(struct socket *sock, uint32_t sb_free) { printf("Sending final message number %lu.\n", cb_messages + 1); } - sndinfo.snd_flags |= SCTP_EOF; + sendv_spa.sendv_sndinfo.snd_flags |= SCTP_EOF; if (usrsctp_sendv(psock, buffer, length, (struct sockaddr *) &remote_addr, 1, - (void *)&sndinfo, (socklen_t)sizeof(struct sctp_sndinfo), SCTP_SENDV_SNDINFO, + (void *)&sendv_spa, (socklen_t)sizeof(struct sctp_sendv_spa), SCTP_SENDV_SPA, 0) < 0) { if (errno != EWOULDBLOCK && errno != EAGAIN) { perror("usrsctp_sendv (cb)"); @@ -329,7 +415,7 @@ client_receive_cb(struct socket *sock, union sctp_sockstore addr, void *data, int main(int argc, char **argv) { #ifndef _WIN32 - int c; + int c, rc; #endif socklen_t addr_len; struct sockaddr_in local_addr; @@ -343,10 +429,11 @@ int main(int argc, char **argv) int nodelay = 0; struct sctp_assoc_value av; struct sctp_udpencaps encaps; - struct sctp_sndinfo sndinfo; + struct sctp_sendv_spa sendv_spa; unsigned long messages = 0; #ifdef _WIN32 unsigned long srcAddr; + HANDLE tid; #else in_addr_t srcAddr; pthread_t tid; @@ -367,12 +454,13 @@ int main(int argc, char **argv) verbose = 0; very_verbose = 0; srcAddr = htonl(INADDR_ANY); + round_duration = 0; memset((void *) &remote_addr, 0, sizeof(struct sockaddr_in)); memset((void *) &local_addr, 0, sizeof(struct sockaddr_in)); #ifndef _WIN32 - while ((c = getopt(argc, argv, "a:cp:l:E:f:L:n:R:S:T:uU:vVD")) != -1) + while ((c = getopt(argc, argv, "a:cd:DE:f:l:L:n:p:P:R:S:t:T:uU:vV")) != -1) switch(c) { case 'a': ind.ssb_adaptation_ind = atoi(optarg); @@ -380,6 +468,12 @@ int main(int argc, char **argv) case 'c': use_cb = 1; break; + case 'd': + round_duration = atoi(optarg); + break; + case 'D': + nodelay = 1; + break; case 'l': length = atoi(optarg); break; @@ -389,6 +483,9 @@ int main(int argc, char **argv) case 'p': port = atoi(optarg); break; + case 'P': + policy = atoi(optarg); + break; case 'E': local_udp_port = atoi(optarg); break; @@ -406,6 +503,9 @@ int main(int argc, char **argv) case 'S': sndbufsize = atoi(optarg); break; + case 't': + timetolive = atoi(optarg); + break; case 'T': runtime = atoi(optarg); number_of_messages = 0; @@ -423,9 +523,6 @@ int main(int argc, char **argv) verbose = 1; very_verbose = 1; break; - case 'D': - nodelay = 1; - break; default: fprintf(stderr, "%s", Usage); exit(1); @@ -461,6 +558,14 @@ int main(int argc, char **argv) opt = argv[optind]; port = atoi(opt); break; + case 'P': + if (++optind >= argc) { + printf("%s", Usage); + exit(1); + } + opt = argv[optind]; + policy = atoi(opt); + break; case 'n': if (++optind >= argc) { printf("%s", Usage); @@ -517,6 +622,14 @@ int main(int argc, char **argv) opt = argv[optind]; sndbufsize = atoi(opt); break; + case 't': + if (++optind >= argc) { + printf("%s", Usage); + exit(1); + } + opt = argv[optind]; + timetolive = atoi(opt); + break; case 'T': if (++optind >= argc) { printf("%s", Usage); @@ -631,9 +744,7 @@ int main(int argc, char **argv) memset(&remote_addr, 0, sizeof(struct sockaddr_in)); addr_len = sizeof(struct sockaddr_in); if (use_cb) { - struct socket *conn_sock; - - if ((conn_sock = usrsctp_accept(psock, (struct sockaddr *) &remote_addr, &addr_len)) == NULL) { + if (usrsctp_accept(psock, (struct sockaddr *) &remote_addr, &addr_len) == NULL) { perror("usrsctp_accept"); continue; } @@ -646,10 +757,15 @@ int main(int argc, char **argv) continue; } #ifdef _WIN32 - CreateThread(NULL, 0, &handle_connection, (void *)conn_sock, 0, NULL); + if ((tid = CreateThread(NULL, 0, &handle_connection, (void *)conn_sock, 0, NULL)) == NULL) { + fprintf(stderr, "CreateThread() failed with error: %lu\n", GetLastError()); #else - pthread_create(&tid, NULL, &handle_connection, (void *)conn_sock); + if ((rc = pthread_create(&tid, NULL, &handle_connection, (void *)conn_sock)) != 0) { + fprintf(stderr, "pthread_create: %s\n", strerror(rc)); #endif + usrsctp_close(*conn_sock); + continue; + } } if (verbose) { /* const char *inet_ntop(int af, const void *src, char *dst, socklen_t size) @@ -724,7 +840,7 @@ int main(int argc, char **argv) signal(SIGALRM, stop_sender); alarm(runtime); #else - printf("You cannot set the runtime in Windows yet\n"); + fprintf(stderr, "You cannot set the runtime in Windows yet\n"); exit(-1); #endif } @@ -738,14 +854,45 @@ int main(int argc, char **argv) #endif } } else { - sndinfo.snd_sid = 0; - sndinfo.snd_flags = 0; + sendv_spa.sendv_flags = SCTP_SEND_SNDINFO_VALID | SCTP_SEND_PRINFO_VALID; + + sendv_spa.sendv_sndinfo.snd_sid = 0; + sendv_spa.sendv_sndinfo.snd_flags = 0; if (unordered != 0) { - sndinfo.snd_flags |= SCTP_UNORDERED; + sendv_spa.sendv_sndinfo.snd_flags |= SCTP_UNORDERED; } - sndinfo.snd_ppid = 0; - sndinfo.snd_context = 0; - sndinfo.snd_assoc_id = 0; + sendv_spa.sendv_sndinfo.snd_ppid = 0; + sendv_spa.sendv_sndinfo.snd_context = 0; + sendv_spa.sendv_sndinfo.snd_assoc_id = 0; + + sendv_spa.sendv_prinfo.pr_policy = 0; + switch (policy) { +#ifdef SCTP_PR_SCTP_NONE + case 0: + sendv_spa.sendv_prinfo.pr_policy = SCTP_PR_SCTP_NONE; + break; +#endif +#ifdef SCTP_PR_SCTP_TTL + case 1: + sendv_spa.sendv_prinfo.pr_policy = SCTP_PR_SCTP_TTL; + break; +#endif +#ifdef SCTP_PR_SCTP_RTX + case 2: + sendv_spa.sendv_prinfo.pr_policy = SCTP_PR_SCTP_RTX; + break; +#endif +#ifdef SCTP_PR_SCTP_BUF + case 3: + sendv_spa.sendv_prinfo.pr_policy = SCTP_PR_SCTP_BUF; + break; +#endif + default: + printf("Unknown PR-SCTP policy.\n"); + break; + } + sendv_spa.sendv_prinfo.pr_value = timetolive; + if (verbose) { printf("Start sending "); if (number_of_messages > 0) { @@ -763,7 +910,7 @@ int main(int argc, char **argv) } if (usrsctp_sendv(psock, buffer, length, (struct sockaddr *) &remote_addr, 1, - (void *)&sndinfo, (socklen_t)sizeof(struct sctp_sndinfo), SCTP_SENDV_SNDINFO, + (void *)&sendv_spa, (socklen_t)sizeof(struct sctp_sendv_spa), SCTP_SENDV_SPA, 0) < 0) { perror("usrsctp_sendv"); exit(1); @@ -774,9 +921,9 @@ int main(int argc, char **argv) printf("Sending message number %lu.\n", messages + 1); } - sndinfo.snd_flags |= SCTP_EOF; + sendv_spa.sendv_sndinfo.snd_flags |= SCTP_EOF; if (usrsctp_sendv(psock, buffer, length, (struct sockaddr *) &remote_addr, 1, - (void *)&sndinfo, (socklen_t)sizeof(struct sctp_sndinfo), SCTP_SENDV_SNDINFO, + (void *)&sendv_spa, (socklen_t)sizeof(struct sctp_sendv_spa), SCTP_SENDV_SPA, 0) < 0) { perror("usrsctp_sendv"); exit(1); @@ -793,7 +940,7 @@ int main(int argc, char **argv) gettimeofday(&time_now, NULL); timersub(&time_now, &time_start, &time_diff); seconds = time_diff.tv_sec + (double)time_diff.tv_usec/1000000; - printf("%s of %ld messages of length %u took %f seconds.\n", + printf("%s of %lu messages of length %d took %f seconds.\n", "Sending", messages, length, seconds); throughput = (double)messages * (double)length / seconds; printf("Throughput was %f Byte/sec.\n", throughput); diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/tsctp_upcall.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/tsctp_upcall.c index fab56891d0..2f5b488b55 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/tsctp_upcall.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/programs/tsctp_upcall.c @@ -105,11 +105,29 @@ struct tsctp_meta { static void gettimeofday(struct timeval *tv, void *ignore) { - struct timeb tb; + FILETIME filetime; + ULARGE_INTEGER ularge; - ftime(&tb); - tv->tv_sec = (long)tb.time; - tv->tv_usec = tb.millitm * 1000; + GetSystemTimeAsFileTime(&filetime); + ularge.LowPart = filetime.dwLowDateTime; + ularge.HighPart = filetime.dwHighDateTime; + /* Change base from Jan 1 1601 00:00:00 to Jan 1 1970 00:00:00 */ +#if defined(__MINGW32__) + ularge.QuadPart -= 116444736000000000ULL; +#else + ularge.QuadPart -= 116444736000000000UI64; +#endif + /* + * ularge.QuadPart is now the number of 100-nanosecond intervals + * since Jan 1 1970 00:00:00. + */ +#if defined(__MINGW32__) + tv->tv_sec = (long)(ularge.QuadPart / 10000000ULL); + tv->tv_usec = (long)((ularge.QuadPart % 10000000ULL) / 10ULL); +#else + tv->tv_sec = (long)(ularge.QuadPart / 10000000UI64); + tv->tv_usec = (long)((ularge.QuadPart % 10000000UI64) / 10UI64); +#endif } #endif @@ -151,7 +169,9 @@ static const char *bytes2human(uint64_t bytes) } } - snprintf(output, sizeof(output), "%.02lf %s", human_size, suffix[i]); + if (snprintf(output, sizeof(output), "%.02lf %s", human_size, suffix[i]) < 0) { + output[0] = '\0'; + } return output; } @@ -188,7 +208,7 @@ handle_accept(struct socket *upcall_socket, void *upcall_data, int upcall_flags) meta_accepted->par_role = meta_listening->par_role; meta_accepted->par_stats_human = meta_listening->par_stats_human; meta_accepted->buffer = malloc(BUFFERSIZE); - + if (!meta_accepted->buffer) { printf("malloc() failed!\n"); exit(EXIT_FAILURE); @@ -237,13 +257,13 @@ handle_upcall(struct socket *upcall_socket, void *upcall_data, int upcall_flags) snp = (union sctp_notification *)tsctp_meta->buffer; if (snp->sn_header.sn_type == SCTP_PEER_ADDR_CHANGE) { spc = &snp->sn_paddr_change; - printf("SCTP_PEER_ADDR_CHANGE: state=%d, error=%d\n",spc->spc_state, spc->spc_error); + printf("SCTP_PEER_ADDR_CHANGE: state=%u, error=%u\n",spc->spc_state, spc->spc_error); } } } else { if (par_very_verbose) { if (infotype == SCTP_RECVV_RCVINFO) { - printf("Message received - %zd bytes - %s - sid %u - tsn %u %s\n", + printf("Message received - %zd bytes - %s - sid %u - tsn %u %s\n", n, (rcvinfo->rcv_flags & SCTP_UNORDERED) ? "unordered" : "ordered", rcvinfo->rcv_sid, @@ -314,7 +334,7 @@ handle_upcall(struct socket *upcall_socket, void *upcall_data, int upcall_flags) snd_info.snd_flags |= SCTP_UNORDERED; } - while ((n = usrsctp_sendv(upcall_socket, tsctp_meta->buffer, tsctp_meta->par_message_length, NULL, 0, &snd_info, (socklen_t)sizeof(struct sctp_sndinfo), SCTP_SENDV_SNDINFO, 0)) > 0) { + while (usrsctp_sendv(upcall_socket, tsctp_meta->buffer, tsctp_meta->par_message_length, NULL, 0, &snd_info, (socklen_t)sizeof(struct sctp_sndinfo), SCTP_SENDV_SNDINFO, 0) > 0) { if (tsctp_meta->stat_messages == 0) { gettimeofday(&tsctp_meta->stat_start, NULL); } diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctp.pc.in b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctp.pc.in index a1ecd2f74e..20c4631550 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctp.pc.in +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctp.pc.in @@ -9,4 +9,5 @@ URL: https://github.com/sctplab/usrsctp Version: @VERSION@ Requires: Libs: -L${libdir} -lusrsctp +Libs.private: -lpthread Cflags: -I${includedir} @APPCFLAGS@ diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/CMakeLists.txt b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/CMakeLists.txt index d6652c1cd3..93f6f4dde7 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/CMakeLists.txt +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/CMakeLists.txt @@ -1,6 +1,6 @@ # # Copyright (C) 2015-2015 Oleg Alexeenkov -# Copyright (C) 2015-2019 Felix Weinrank +# Copyright (C) 2015-2020 Felix Weinrank # # All rights reserved. # @@ -34,61 +34,68 @@ # INCLUDE MODULES AND SETTINGS ################################################# -set(VERSION "1.0.0") +set(VERSION "0.9.5.0") + +# Shared library API and ABI versions +# Notice: shared library version must be in X.Y.Z format only +set(SOVERSION_FULL "2.0.0") +set(SOVERSION_SHORT "2") + +include(GNUInstallDirs) +set(prefix ${CMAKE_INSTALL_PREFIX}) +set(exec_prefix ${prefix}) +set(libdir ${exec_prefix}/${CMAKE_INSTALL_LIBDIR}) +set(includedir ${prefix}/${CMAKE_INSTALL_INCLUDEDIR}) -set(prefix ${CMAKE_INSTALL_PREFIX}) -set(exec_prefix ${prefix}) -set(libdir ${exec_prefix}/lib) -set(includedir ${prefix}/include/usrsctp) set(CMAKE_REQUIRED_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}) -set(CMAKE_MACOSX_RPATH 1) +set(CMAKE_MACOSX_RPATH 1) + +include(CheckCCompilerFlag) + + +option(SCTP_USE_MBEDTLS_SHA1 "Build with mbedtls sha1 support." OFF) add_definitions(-D__Userspace__) -add_definitions(-D__Userspace_os_${CMAKE_SYSTEM_NAME}) add_definitions(-DSCTP_SIMPLE_ALLOCATOR) add_definitions(-DSCTP_PROCESS_LEVEL_LOCKS) +if(SCTP_USE_MBEDTLS_SHA1) + add_definitions(-DSCTP_USE_MBEDTLS_SHA1) + find_package(MbedTLS REQUIRED) +endif() + ################################################# # OS DEPENDENT ################################################# -check_c_compiler_flag(-Wno-address-of-packed-member has_wno_address_of_packet_member) -if (has_wno_address_of_packet_member) +check_c_compiler_flag(-Wno-address-of-packed-member has_wno_address_of_packed_member) +if (has_wno_address_of_packed_member) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-address-of-packed-member") endif () +check_c_compiler_flag(-Wno-deprecated-declarations has_wno_deprecated_declarations) +if (has_wno_deprecated_declarations) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations") +endif () + if (CMAKE_SYSTEM_NAME MATCHES "Linux") add_definitions(-D_GNU_SOURCE) endif () -if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD") - add_definitions(-U__FreeBSD__) -endif () - -if (CMAKE_SYSTEM_NAME MATCHES "Darwin") - add_definitions(-U__APPLE__) +if (CMAKE_SYSTEM_NAME MATCHES "Darwin" OR CMAKE_SYSTEM_NAME MATCHES "iOS") add_definitions(-D__APPLE_USE_RFC_2292) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations") -endif () - -if (CMAKE_SYSTEM_NAME MATCHES "DragonFly") - add_definitions(-U__DragonFly__) -endif () - -if (CMAKE_SYSTEM_NAME MATCHES "NetBSD") - add_definitions(-U__NetBSD__) -endif () - -if (CMAKE_SYSTEM_NAME MATCHES "OpenBSD") - add_definitions(-U__OpenBSD__) endif () ################################################# # MISC ################################################# +if (sctp_build_shared_lib) + set(BUILD_SHARED_LIBS 1) +endif () +find_package(Threads) ################################################# # LIBRARY FILES @@ -175,30 +182,39 @@ list(APPEND usrsctp_sources user_socket.c ) -add_library(usrsctp SHARED ${usrsctp_sources} ${usrsctp_headers}) -add_library(usrsctp-static STATIC ${usrsctp_sources} ${usrsctp_headers}) +add_library(usrsctp ${usrsctp_sources} ${usrsctp_headers}) target_include_directories(usrsctp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) -target_include_directories(usrsctp-static PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) + +if(SCTP_USE_MBEDTLS_SHA1) + target_include_directories(usrsctp PRIVATE ${MBEDTLS_INCLUDE_DIRS}) +endif() + +target_link_libraries(usrsctp ${CMAKE_THREAD_LIBS_INIT}) if (WIN32) message(STATUS "link library: ws2_32") - target_link_libraries(usrsctp ws2_32 iphlpapi.lib) - target_link_libraries(usrsctp-static ws2_32 iphlpapi.lib) + target_link_libraries(usrsctp ws2_32 iphlpapi) endif () -set_target_properties(usrsctp-static PROPERTIES OUTPUT_NAME "usrsctp") +if(SCTP_USE_MBEDTLS_SHA1) + target_link_libraries(usrsctp PRIVATE ${MBEDTLS_LIBRARIES}) +endif() + + set_target_properties(usrsctp PROPERTIES IMPORT_SUFFIX "_import.lib") -set_target_properties(usrsctp PROPERTIES SOVERSION 1 VERSION 1.0.0) - -if (NOT DEFINED CMAKE_INSTALL_LIBDIR) - SET(CMAKE_INSTALL_LIBDIR lib) -endif () - +set_target_properties(usrsctp PROPERTIES SOVERSION ${SOVERSION_SHORT} VERSION ${SOVERSION_FULL}) ################################################# # INSTALL LIBRARY AND HEADER ################################################# -install(TARGETS usrsctp usrsctp-static DESTINATION ${CMAKE_INSTALL_LIBDIR}) -install(FILES usrsctp.h DESTINATION include) +install(TARGETS usrsctp DESTINATION ${CMAKE_INSTALL_LIBDIR}) +install(FILES usrsctp.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + +################################################# +# GENERATE AND INSTALL PKG-CONFIG FILE +################################################# + +configure_file("${PROJECT_SOURCE_DIR}/usrsctp.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/usrsctp.pc" @ONLY) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/usrsctp.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/Makefile.am b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/Makefile.am index 85240b7cea..dc07c6e17f 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/Makefile.am +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/Makefile.am @@ -76,6 +76,6 @@ libusrsctp_la_SOURCES = user_atomic.h \ netinet6/sctp6_var.h \ netinet6/sctp6_usrreq.c libusrsctp_la_CFLAGS = $(LIBCFLAGS) -libusrsctp_la_LDFLAGS = -version-info 1:0:0 +libusrsctp_la_LDFLAGS = -version-info 2:0:0 include_HEADERS = usrsctp.h diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/Makefile.nmake b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/Makefile.nmake index 48d2bd110c..afcda6d915 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/Makefile.nmake +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/Makefile.nmake @@ -31,7 +31,7 @@ CFLAGS=/I. /W3 /WX CVARSDLL=-DSCTP_DEBUG -DSCTP_SIMPLE_ALLOCATOR -DSCTP_PROCESS_LEVEL_LOCKS -CVARSDLL=$(CVARSDLL) -D__Userspace__ -D__Userspace_os_Windows +CVARSDLL=$(CVARSDLL) -D__Userspace__ CVARSDLL=$(CVARSDLL) -DINET -DINET6 CVARSDLL=$(CVARSDLL) -D_LIB diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp.h index 9847624657..f0dc35ad56 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp.h @@ -32,22 +32,20 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp.h 356357 2020-01-04 20:33:12Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp.h 366750 2020-10-16 10:44:48Z tuexen $"); #endif #ifndef _NETINET_SCTP_H_ #define _NETINET_SCTP_H_ -#if (defined(__APPLE__) || defined(__Userspace_os_Linux) || defined(__Userspace_os_Darwin)) +#if defined(__APPLE__) || defined(__linux__) #include #endif - #include - -#if !defined(__Userspace_os_Windows) +#if !defined(_WIN32) #define SCTP_PACKED __attribute__((packed)) #else #pragma pack (push, 1) @@ -191,7 +189,6 @@ struct sctp_paramhdr { #define SCTP_STREAM_RESET_INCOMING 0x00000001 #define SCTP_STREAM_RESET_OUTGOING 0x00000002 - /* here on down are more implementation specific */ #define SCTP_SET_DEBUG_LEVEL 0x00001005 #define SCTP_CLR_STAT_LOG 0x00001007 @@ -213,7 +210,6 @@ struct sctp_paramhdr { #define SCTP_PCB_STATUS 0x00001104 #define SCTP_GET_NONCE_VALUES 0x00001105 - /* Special hook for dynamically setting primary for all assoc's, * this is a write only option that requires root privilege. */ @@ -286,11 +282,11 @@ struct sctp_paramhdr { #define SCTP_PEELOFF 0x0000800a /* the real worker for sctp_getaddrlen() */ #define SCTP_GET_ADDR_LEN 0x0000800b -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) /* temporary workaround for Apple listen() issue, no args used */ #define SCTP_LISTEN_FIX 0x0000800c #endif -#if defined(__Windows__) +#if defined(_WIN32) && !defined(__Userspace__) /* workaround for Cygwin on Windows: returns the SOCKET handle */ #define SCTP_GET_HANDLE 0x0000800d #endif @@ -336,7 +332,6 @@ struct sctp_paramhdr { /* First-come, first-serve */ #define SCTP_SS_FIRST_COME 0x00000005 - /* fragment interleave constants * setting must be one of these or * EINVAL returned. @@ -607,13 +602,12 @@ struct sctp_error_auth_invalid_hmac { #define SCTP_MOBILITY_FASTHANDOFF 0x00000002 #define SCTP_MOBILITY_PRIM_DELETED 0x00000004 - /* Smallest PMTU allowed when disabling PMTU discovery */ #define SCTP_SMALLEST_PMTU 512 /* Largest PMTU allowed when disabling PMTU discovery */ #define SCTP_LARGEST_PMTU 65536 -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) #pragma pack(pop) #endif #undef SCTP_PACKED @@ -632,9 +626,9 @@ struct sctp_error_auth_invalid_hmac { */ #define SCTP_MAX_SACK_DELAY 500 /* per RFC4960 */ #define SCTP_MAX_HB_INTERVAL 14400000 /* 4 hours in ms */ +#define SCTP_MIN_COOKIE_LIFE 1000 /* 1 second in ms */ #define SCTP_MAX_COOKIE_LIFE 3600000 /* 1 hour in ms */ - /* Types of logging/KTR tracing that can be enabled via the * sysctl net.inet.sctp.sctp_logging. You must also enable * SUBSYS tracing. diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_asconf.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_asconf.c index 19f6fe6156..50e29a401e 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_asconf.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_asconf.c @@ -32,9 +32,9 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_asconf.c 357197 2020-01-28 10:09:05Z tuexen $"); +__FBSDID("$FreeBSD$"); #endif #include @@ -53,10 +53,6 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_asconf.c 357197 2020-01-28 10:09:05Z t * SCTP_DEBUG_ASCONF2: detailed info */ -#if defined(__APPLE__) -#define APPLE_FILE_NO 1 -#endif - /* * RFC 5061 * @@ -588,7 +584,6 @@ sctp_process_asconf_set_primary(struct sockaddr *src, SCTP_MOBILITY_PRIM_DELETED) && (stcb->asoc.primary_destination->dest_state & SCTP_ADDR_UNCONFIRMED) == 0) { - sctp_timer_stop(SCTP_TIMER_TYPE_PRIM_DELETED, stcb->sctp_ep, stcb, NULL, SCTP_FROM_SCTP_ASCONF + SCTP_LOC_1); @@ -602,8 +597,7 @@ sctp_process_asconf_set_primary(struct sockaddr *src, sctp_move_chunks_from_net(stcb, stcb->asoc.deleted_primary); } - sctp_delete_prim_timer(stcb->sctp_ep, stcb, - stcb->asoc.deleted_primary); + sctp_delete_prim_timer(stcb->sctp_ep, stcb); } } else { /* couldn't set the requested primary address! */ @@ -743,7 +737,7 @@ sctp_handle_asconf(struct mbuf *m, unsigned int offset, sctp_m_freem(m_ack); return; } - if (param_length <= sizeof(struct sctp_paramhdr)) { + if (param_length < sizeof(struct sctp_asconf_paramhdr)) { SCTPDBG(SCTP_DEBUG_ASCONF1, "handle_asconf: param length (%u) too short\n", param_length); sctp_m_freem(m_ack); return; @@ -955,12 +949,12 @@ sctp_addr_match(struct sctp_paramhdr *ph, struct sockaddr *sa) * Cleanup for non-responded/OP ERR'd ASCONF */ void -sctp_asconf_cleanup(struct sctp_tcb *stcb, struct sctp_nets *net) +sctp_asconf_cleanup(struct sctp_tcb *stcb) { /* * clear out any existing asconfs going out */ - sctp_timer_stop(SCTP_TIMER_TYPE_ASCONF, stcb->sctp_ep, stcb, net, + sctp_timer_stop(SCTP_TIMER_TYPE_ASCONF, stcb->sctp_ep, stcb, NULL, SCTP_FROM_SCTP_ASCONF + SCTP_LOC_2); stcb->asoc.asconf_seq_out_acked = stcb->asoc.asconf_seq_out; /* remove the old ASCONF on our outbound queue */ @@ -997,8 +991,12 @@ sctp_asconf_nets_cleanup(struct sctp_tcb *stcb, struct sctp_ifn *ifn) ((ifn == NULL) || (SCTP_GET_IF_INDEX_FROM_ROUTE(&net->ro) != ifn->ifn_index))) { /* clear any cached route */ +#if defined(__FreeBSD__) && !defined(__Userspace__) + RO_NHFREE(&net->ro); +#else RTFREE(net->ro.ro_rt); net->ro.ro_rt = NULL; +#endif } /* clear any cached source address */ if (net->src_addr_selected) { @@ -1009,7 +1007,6 @@ sctp_asconf_nets_cleanup(struct sctp_tcb *stcb, struct sctp_ifn *ifn) } } - void sctp_assoc_immediate_retrans(struct sctp_tcb *stcb, struct sctp_nets *dstnet) { @@ -1050,9 +1047,14 @@ sctp_assoc_immediate_retrans(struct sctp_tcb *stcb, struct sctp_nets *dstnet) (stcb->asoc.sent_queue_cnt > 0)) { struct sctp_tmit_chunk *chk; - chk = TAILQ_FIRST(&stcb->asoc.sent_queue); - sctp_timer_start(SCTP_TIMER_TYPE_SEND, stcb->sctp_ep, - stcb, chk->whoTo); + TAILQ_FOREACH(chk, &stcb->asoc.sent_queue, sctp_next) { + if (chk->whoTo != NULL) { + break; + } + } + if (chk != NULL) { + sctp_timer_start(SCTP_TIMER_TYPE_SEND, stcb->sctp_ep, stcb, chk->whoTo); + } } } return; @@ -1107,10 +1109,14 @@ sctp_path_check_and_react(struct sctp_tcb *stcb, struct sctp_ifa *newifa) if (addrnum == 1) { TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { /* clear any cached route and source address */ +#if defined(__FreeBSD__) && !defined(__Userspace__) + RO_NHFREE(&net->ro); +#else if (net->ro.ro_rt) { RTFREE(net->ro.ro_rt); net->ro.ro_rt = NULL; } +#endif if (net->src_addr_selected) { sctp_free_ifa(net->ro._s_addr); net->ro._s_addr = NULL; @@ -1129,10 +1135,14 @@ sctp_path_check_and_react(struct sctp_tcb *stcb, struct sctp_ifa *newifa) /* Multiple local addresses exsist in the association. */ TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { /* clear any cached route and source address */ +#if defined(__FreeBSD__) && !defined(__Userspace__) + RO_NHFREE(&net->ro); +#else if (net->ro.ro_rt) { RTFREE(net->ro.ro_rt); net->ro.ro_rt = NULL; } +#endif if (net->src_addr_selected) { sctp_free_ifa(net->ro._s_addr); net->ro._s_addr = NULL; @@ -1147,7 +1157,11 @@ sctp_path_check_and_react(struct sctp_tcb *stcb, struct sctp_ifa *newifa) SCTP_RTALLOC((sctp_route_t *)&net->ro, stcb->sctp_ep->def_vrf_id, stcb->sctp_ep->fibnum); +#if defined(__FreeBSD__) && !defined(__Userspace__) + if (net->ro.ro_nh == NULL) +#else if (net->ro.ro_rt == NULL) +#endif continue; changed = 0; @@ -1187,7 +1201,7 @@ sctp_path_check_and_react(struct sctp_tcb *stcb, struct sctp_ifa *newifa) } } } -#endif /* __FreeBSD__ __APPLE__ __Userspace__ */ +#endif /* * process an ADD/DELETE IP ack from peer. @@ -1219,7 +1233,7 @@ sctp_asconf_addr_mgmt_ack(struct sctp_tcb *stcb, struct sctp_ifa *addr, uint32_t sctp_path_check_and_react(stcb, addr); return; } -#endif /* __FreeBSD__ __APPLE__ __Userspace__ */ +#endif /* clear any cached/topologically incorrect source addresses */ sctp_asconf_nets_cleanup(stcb, addr->ifn_p); } @@ -1353,7 +1367,6 @@ sctp_asconf_queue_mgmt(struct sctp_tcb *stcb, struct sctp_ifa *ifa, return (0); } - /* * add an asconf operation for the given ifa and type. * type = SCTP_ADD_IP_ADDRESS, SCTP_DEL_IP_ADDRESS, SCTP_SET_PRIM_ADDR. @@ -1723,10 +1736,9 @@ sctp_handle_asconf_ack(struct mbuf *m, int offset, char msg[SCTP_DIAG_INFO_LEN]; SCTPDBG(SCTP_DEBUG_ASCONF1, "handle_asconf_ack: got unexpected next serial number! Aborting asoc!\n"); - snprintf(msg, sizeof(msg), "Never sent serial number %8.8x", - serial_num); + SCTP_SNPRINTF(msg, sizeof(msg), "Never sent serial number %8.8x", serial_num); op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg); - sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, SCTP_SO_NOT_LOCKED); + sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, false, SCTP_SO_NOT_LOCKED); *abort_no_unlock = 1; return; } @@ -1739,7 +1751,7 @@ sctp_handle_asconf_ack(struct mbuf *m, int offset, if (serial_num == asoc->asconf_seq_out - 1) { /* stop our timer */ - sctp_timer_stop(SCTP_TIMER_TYPE_ASCONF, stcb->sctp_ep, stcb, net, + sctp_timer_stop(SCTP_TIMER_TYPE_ASCONF, stcb->sctp_ep, stcb, NULL, SCTP_FROM_SCTP_ASCONF + SCTP_LOC_5); } @@ -1765,7 +1777,7 @@ sctp_handle_asconf_ack(struct mbuf *m, int offset, sctp_asconf_ack_clear(stcb); return; } - if (param_length < sizeof(struct sctp_paramhdr)) { + if (param_length < sizeof(struct sctp_asconf_paramhdr)) { sctp_asconf_ack_clear(stcb); return; } @@ -1813,9 +1825,9 @@ sctp_handle_asconf_ack(struct mbuf *m, int offset, } /* switch */ /* update remaining ASCONF-ACK message length to process */ - ack_length -= SCTP_SIZE32(param_length); - if (ack_length <= 0) { - /* no more data in the mbuf chain */ + if (ack_length > SCTP_SIZE32(param_length)) { + ack_length -= SCTP_SIZE32(param_length); + } else { break; } offset += SCTP_SIZE32(param_length); @@ -1926,7 +1938,7 @@ sctp_addr_mgmt_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, switch (ifa->address.sa.sa_family) { #ifdef INET6 case AF_INET6: -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (prison_check_ip6(inp->ip_inp.inp.inp_cred, &ifa->address.sin6.sin6_addr) != 0) { return; @@ -1936,7 +1948,7 @@ sctp_addr_mgmt_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, #endif #ifdef INET case AF_INET: -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (prison_check_ip4(inp->ip_inp.inp.inp_cred, &ifa->address.sin.sin_addr) != 0) { return; @@ -2046,7 +2058,6 @@ sctp_addr_mgmt_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, } } - int sctp_asconf_iterator_ep(struct sctp_inpcb *inp, void *ptr, uint32_t val SCTP_UNUSED) { @@ -2110,7 +2121,6 @@ sctp_asconf_iterator_ep_end(struct sctp_inpcb *inp, void *ptr, uint32_t val SCTP laddr->action = 0; break; } - } } else if (l->action == SCTP_DEL_IP_ADDRESS) { LIST_FOREACH_SAFE(laddr, &inp->sctp_addr_list, sctp_nxt_addr, nladdr) { @@ -2165,7 +2175,7 @@ sctp_asconf_iterator_stcb(struct sctp_inpcb *inp, struct sctp_tcb *stcb, /* we skip unspecifed addresses */ continue; } -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (prison_check_ip6(inp->ip_inp.inp.inp_cred, &sin6->sin6_addr) != 0) { continue; @@ -2199,7 +2209,7 @@ sctp_asconf_iterator_stcb(struct sctp_inpcb *inp, struct sctp_tcb *stcb, /* we skip unspecifed addresses */ continue; } -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (prison_check_ip4(inp->ip_inp.inp.inp_cred, &sin->sin_addr) != 0) { continue; @@ -2227,7 +2237,6 @@ sctp_asconf_iterator_stcb(struct sctp_inpcb *inp, struct sctp_tcb *stcb, return; else continue; - break; } if (type == SCTP_ADD_IP_ADDRESS) { @@ -2236,18 +2245,19 @@ sctp_asconf_iterator_stcb(struct sctp_inpcb *inp, struct sctp_tcb *stcb, } else if (type == SCTP_DEL_IP_ADDRESS) { struct sctp_nets *net; TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { - sctp_rtentry_t *rt; - /* delete this address if cached */ if (net->ro._s_addr == ifa) { sctp_free_ifa(net->ro._s_addr); net->ro._s_addr = NULL; net->src_addr_selected = 0; - rt = net->ro.ro_rt; - if (rt) { - RTFREE(rt); +#if defined(__FreeBSD__) && !defined(__Userspace__) + RO_NHFREE(&net->ro); +#else + if (net->ro.ro_rt) { + RTFREE(net->ro.ro_rt); net->ro.ro_rt = NULL; } +#endif /* * Now we deleted our src address, * should we not also now reset the @@ -2256,7 +2266,6 @@ sctp_asconf_iterator_stcb(struct sctp_inpcb *inp, struct sctp_tcb *stcb, */ stcb->asoc.cc_functions.sctp_set_initial_cc_param(stcb, net); net->RTO = 0; - } } } else if (type == SCTP_SET_PRIM_ADDR) { @@ -2488,7 +2497,7 @@ sctp_find_valid_localaddr(struct sctp_tcb *stcb, int addr_locked) /* skip unspecifed addresses */ continue; } -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (prison_check_ip4(stcb->sctp_ep->ip_inp.inp.inp_cred, &sin->sin_addr) != 0) { continue; @@ -2522,7 +2531,7 @@ sctp_find_valid_localaddr(struct sctp_tcb *stcb, int addr_locked) /* we skip unspecifed addresses */ continue; } -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (prison_check_ip6(stcb->sctp_ep->ip_inp.inp.inp_cred, &sin6->sin6_addr) != 0) { continue; @@ -2611,14 +2620,14 @@ sctp_compose_asconf(struct sctp_tcb *stcb, int *retlen, int addr_locked) if (m_asconf_chk == NULL) { /* no mbuf's */ SCTPDBG(SCTP_DEBUG_ASCONF1, - "compose_asconf: couldn't get chunk mbuf!\n"); + "sctp_compose_asconf: couldn't get chunk mbuf!\n"); return (NULL); } m_asconf = sctp_get_mbuf_for_msg(MCLBYTES, 0, M_NOWAIT, 1, MT_DATA); if (m_asconf == NULL) { /* no mbuf's */ SCTPDBG(SCTP_DEBUG_ASCONF1, - "compose_asconf: couldn't get mbuf!\n"); + "sctp_compose_asconf: couldn't get mbuf!\n"); sctp_m_freem(m_asconf_chk); return (NULL); } @@ -2743,10 +2752,12 @@ sctp_compose_asconf(struct sctp_tcb *stcb, int *retlen, int addr_locked) break; #endif default: - p_size = 0; - addr_size = 0; - addr_ptr = NULL; - break; + SCTPDBG(SCTP_DEBUG_ASCONF1, + "sctp_compose_asconf: no usable lookup addr (family = %d)!\n", + found_addr->sa_family); + sctp_m_freem(m_asconf_chk); + sctp_m_freem(m_asconf); + return (NULL); } lookup->ph.param_length = htons(SCTP_SIZE32(p_size)); memcpy(lookup->addr, addr_ptr, addr_size); @@ -2754,12 +2765,10 @@ sctp_compose_asconf(struct sctp_tcb *stcb, int *retlen, int addr_locked) } else { /* uh oh... don't have any address?? */ SCTPDBG(SCTP_DEBUG_ASCONF1, - "compose_asconf: no lookup addr!\n"); - /* XXX for now, we send a IPv4 address of 0.0.0.0 */ - lookup->ph.param_type = htons(SCTP_IPV4_ADDRESS); - lookup->ph.param_length = htons(SCTP_SIZE32(sizeof(struct sctp_ipv4addr_param))); - memset(lookup->addr, 0, sizeof(struct in_addr)); - SCTP_BUF_LEN(m_asconf_chk) += SCTP_SIZE32(sizeof(struct sctp_ipv4addr_param)); + "sctp_compose_asconf: no lookup addr!\n"); + sctp_m_freem(m_asconf_chk); + sctp_m_freem(m_asconf); + return (NULL); } } /* chain it all together */ @@ -3055,10 +3064,6 @@ sctp_check_address_list_ep(struct sctp_tcb *stcb, struct mbuf *m, int offset, "check_addr_list_ep: laddr->ifa is NULL"); continue; } - if (laddr->ifa == NULL) { - SCTPDBG(SCTP_DEBUG_ASCONF1, "check_addr_list_ep: laddr->ifa->ifa_addr is NULL"); - continue; - } /* do i have it implicitly? */ if (sctp_cmpaddr(&laddr->ifa->address.sa, init_addr)) { continue; @@ -3120,7 +3125,7 @@ sctp_check_address_list_all(struct sctp_tcb *stcb, struct mbuf *m, int offset, #ifdef INET case AF_INET: sin = &sctp_ifa->address.sin; -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (prison_check_ip4(stcb->sctp_ep->ip_inp.inp.inp_cred, &sin->sin_addr) != 0) { continue; @@ -3136,7 +3141,7 @@ sctp_check_address_list_all(struct sctp_tcb *stcb, struct mbuf *m, int offset, #ifdef INET6 case AF_INET6: sin6 = &sctp_ifa->address.sin6; -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (prison_check_ip6(stcb->sctp_ep->ip_inp.inp.inp_cred, &sin6->sin6_addr) != 0) { continue; @@ -3205,7 +3210,7 @@ sctp_check_address_list(struct sctp_tcb *stcb, struct mbuf *m, int offset, */ uint32_t sctp_addr_mgmt_ep_sa(struct sctp_inpcb *inp, struct sockaddr *sa, - uint32_t type, uint32_t vrf_id, struct sctp_ifa *sctp_ifap) + uint32_t type, uint32_t vrf_id) { struct sctp_ifa *ifa; struct sctp_laddr *laddr, *nladdr; @@ -3216,9 +3221,7 @@ sctp_addr_mgmt_ep_sa(struct sctp_inpcb *inp, struct sockaddr *sa, return (EINVAL); } #endif - if (sctp_ifap) { - ifa = sctp_ifap; - } else if (type == SCTP_ADD_IP_ADDRESS) { + if (type == SCTP_ADD_IP_ADDRESS) { /* For an add the address MUST be on the system */ ifa = sctp_find_ifa_by_addr(sa, vrf_id, SCTP_ADDR_NOT_LOCKED); } else if (type == SCTP_DEL_IP_ADDRESS) { @@ -3305,10 +3308,9 @@ sctp_addr_mgmt_ep_sa(struct sctp_inpcb *inp, struct sockaddr *sa, } void -sctp_asconf_send_nat_state_update(struct sctp_tcb *stcb, - struct sctp_nets *net) +sctp_asconf_send_nat_state_update(struct sctp_tcb *stcb, struct sctp_nets *net) { - struct sctp_asconf_addr *aa; + struct sctp_asconf_addr *aa_vtag, *aa_add, *aa_del; struct sctp_ifa *sctp_ifap; struct sctp_asconf_tag_param *vtag; #ifdef INET @@ -3317,6 +3319,7 @@ sctp_asconf_send_nat_state_update(struct sctp_tcb *stcb, #ifdef INET6 struct sockaddr_in6 *to6; #endif + if (net == NULL) { SCTPDBG(SCTP_DEBUG_ASCONF1, "sctp_asconf_send_nat_state_update: Missing net\n"); return; @@ -3325,108 +3328,84 @@ sctp_asconf_send_nat_state_update(struct sctp_tcb *stcb, SCTPDBG(SCTP_DEBUG_ASCONF1, "sctp_asconf_send_nat_state_update: Missing stcb\n"); return; } - /* Need to have in the asconf: - * - vtagparam(my_vtag/peer_vtag) - * - add(0.0.0.0) - * - del(0.0.0.0) - * - Any global addresses add(addr) - */ - SCTP_MALLOC(aa, struct sctp_asconf_addr *, sizeof(*aa), - SCTP_M_ASC_ADDR); - if (aa == NULL) { - /* didn't get memory */ - SCTPDBG(SCTP_DEBUG_ASCONF1, - "sctp_asconf_send_nat_state_update: failed to get memory!\n"); + /* Need to have in the ASCONF: + * - VTAG(my_vtag/peer_vtag) + * - ADD(wildcard) + * - DEL(wildcard) + * - ADD(Any global addresses) + */ + SCTP_MALLOC(aa_vtag, struct sctp_asconf_addr *, sizeof(struct sctp_asconf_addr), SCTP_M_ASC_ADDR); + SCTP_MALLOC(aa_add, struct sctp_asconf_addr *, sizeof(struct sctp_asconf_addr), SCTP_M_ASC_ADDR); + SCTP_MALLOC(aa_del, struct sctp_asconf_addr *, sizeof(struct sctp_asconf_addr), SCTP_M_ASC_ADDR); + + if ((aa_vtag == NULL) || (aa_add == NULL) || (aa_del == NULL)) { + /* Didn't get memory */ + SCTPDBG(SCTP_DEBUG_ASCONF1, "sctp_asconf_send_nat_state_update: failed to get memory!\n"); +out: + if (aa_vtag != NULL) { + SCTP_FREE(aa_vtag, SCTP_M_ASC_ADDR); + } + if (aa_add != NULL) { + SCTP_FREE(aa_add, SCTP_M_ASC_ADDR); + } + if (aa_del != NULL) { + SCTP_FREE(aa_del, SCTP_M_ASC_ADDR); + } return; } - aa->special_del = 0; - /* fill in asconf address parameter fields */ - /* top level elements are "networked" during send */ - aa->ifa = NULL; - aa->sent = 0; /* clear sent flag */ - vtag = (struct sctp_asconf_tag_param *)&aa->ap.aph; + memset(aa_vtag, 0, sizeof(struct sctp_asconf_addr)); + aa_vtag->special_del = 0; + /* Fill in ASCONF address parameter fields. */ + /* Top level elements are "networked" during send. */ + aa_vtag->ifa = NULL; + aa_vtag->sent = 0; /* clear sent flag */ + vtag = (struct sctp_asconf_tag_param *)&aa_vtag->ap.aph; vtag->aph.ph.param_type = SCTP_NAT_VTAGS; vtag->aph.ph.param_length = sizeof(struct sctp_asconf_tag_param); vtag->local_vtag = htonl(stcb->asoc.my_vtag); vtag->remote_vtag = htonl(stcb->asoc.peer_vtag); - TAILQ_INSERT_TAIL(&stcb->asoc.asconf_queue, aa, next); - SCTP_MALLOC(aa, struct sctp_asconf_addr *, sizeof(*aa), - SCTP_M_ASC_ADDR); - if (aa == NULL) { - /* didn't get memory */ - SCTPDBG(SCTP_DEBUG_ASCONF1, - "sctp_asconf_send_nat_state_update: failed to get memory!\n"); - return; - } - memset(aa, 0, sizeof(struct sctp_asconf_addr)); - /* fill in asconf address parameter fields */ - /* ADD(0.0.0.0) */ + memset(aa_add, 0, sizeof(struct sctp_asconf_addr)); + memset(aa_del, 0, sizeof(struct sctp_asconf_addr)); switch (net->ro._l_addr.sa.sa_family) { #ifdef INET case AF_INET: - aa->ap.aph.ph.param_type = SCTP_ADD_IP_ADDRESS; - aa->ap.aph.ph.param_length = sizeof(struct sctp_asconf_addrv4_param); - aa->ap.addrp.ph.param_type = SCTP_IPV4_ADDRESS; - aa->ap.addrp.ph.param_length = sizeof (struct sctp_ipv4addr_param); - /* No need to add an address, we are using 0.0.0.0 */ - TAILQ_INSERT_TAIL(&stcb->asoc.asconf_queue, aa, next); + aa_add->ap.aph.ph.param_type = SCTP_ADD_IP_ADDRESS; + aa_add->ap.aph.ph.param_length = sizeof(struct sctp_asconf_addrv4_param); + aa_add->ap.addrp.ph.param_type = SCTP_IPV4_ADDRESS; + aa_add->ap.addrp.ph.param_length = sizeof (struct sctp_ipv4addr_param); + /* No need to fill the address, we are using 0.0.0.0 */ + aa_del->ap.aph.ph.param_type = SCTP_ADD_IP_ADDRESS; + aa_del->ap.aph.ph.param_length = sizeof(struct sctp_asconf_addrv4_param); + aa_del->ap.addrp.ph.param_type = SCTP_IPV4_ADDRESS; + aa_del->ap.addrp.ph.param_length = sizeof (struct sctp_ipv4addr_param); + /* No need to fill the address, we are using 0.0.0.0 */ break; #endif #ifdef INET6 case AF_INET6: - aa->ap.aph.ph.param_type = SCTP_ADD_IP_ADDRESS; - aa->ap.aph.ph.param_length = sizeof(struct sctp_asconf_addr_param); - aa->ap.addrp.ph.param_type = SCTP_IPV6_ADDRESS; - aa->ap.addrp.ph.param_length = sizeof (struct sctp_ipv6addr_param); - /* No need to add an address, we are using 0.0.0.0 */ - TAILQ_INSERT_TAIL(&stcb->asoc.asconf_queue, aa, next); + aa_add->ap.aph.ph.param_type = SCTP_ADD_IP_ADDRESS; + aa_add->ap.aph.ph.param_length = sizeof(struct sctp_asconf_addr_param); + aa_add->ap.addrp.ph.param_type = SCTP_IPV6_ADDRESS; + aa_add->ap.addrp.ph.param_length = sizeof (struct sctp_ipv6addr_param); + /* No need to fill the address, we are using ::0 */ + aa_del->ap.aph.ph.param_type = SCTP_DEL_IP_ADDRESS; + aa_del->ap.aph.ph.param_length = sizeof(struct sctp_asconf_addr_param); + aa_del->ap.addrp.ph.param_type = SCTP_IPV6_ADDRESS; + aa_del->ap.addrp.ph.param_length = sizeof (struct sctp_ipv6addr_param); + /* No need to fill the address, we are using ::0 */ break; #endif default: SCTPDBG(SCTP_DEBUG_ASCONF1, - "sctp_asconf_send_nat_state_update: unknown address family\n"); - SCTP_FREE(aa, SCTP_M_ASC_ADDR); - return; - } - SCTP_MALLOC(aa, struct sctp_asconf_addr *, sizeof(*aa), - SCTP_M_ASC_ADDR); - if (aa == NULL) { - /* didn't get memory */ - SCTPDBG(SCTP_DEBUG_ASCONF1, - "sctp_asconf_send_nat_state_update: failed to get memory!\n"); - return; - } - memset(aa, 0, sizeof(struct sctp_asconf_addr)); - /* fill in asconf address parameter fields */ - /* ADD(0.0.0.0) */ - switch (net->ro._l_addr.sa.sa_family) { -#ifdef INET - case AF_INET: - aa->ap.aph.ph.param_type = SCTP_ADD_IP_ADDRESS; - aa->ap.aph.ph.param_length = sizeof(struct sctp_asconf_addrv4_param); - aa->ap.addrp.ph.param_type = SCTP_IPV4_ADDRESS; - aa->ap.addrp.ph.param_length = sizeof (struct sctp_ipv4addr_param); - /* No need to add an address, we are using 0.0.0.0 */ - TAILQ_INSERT_TAIL(&stcb->asoc.asconf_queue, aa, next); - break; -#endif -#ifdef INET6 - case AF_INET6: - aa->ap.aph.ph.param_type = SCTP_DEL_IP_ADDRESS; - aa->ap.aph.ph.param_length = sizeof(struct sctp_asconf_addr_param); - aa->ap.addrp.ph.param_type = SCTP_IPV6_ADDRESS; - aa->ap.addrp.ph.param_length = sizeof (struct sctp_ipv6addr_param); - /* No need to add an address, we are using 0.0.0.0 */ - TAILQ_INSERT_TAIL(&stcb->asoc.asconf_queue, aa, next); - break; -#endif - default: - SCTPDBG(SCTP_DEBUG_ASCONF1, - "sctp_asconf_send_nat_state_update: unknown address family\n"); - SCTP_FREE(aa, SCTP_M_ASC_ADDR); - return; + "sctp_asconf_send_nat_state_update: unknown address family %d\n", + net->ro._l_addr.sa.sa_family); + goto out; } + TAILQ_INSERT_TAIL(&stcb->asoc.asconf_queue, aa_vtag, next); + TAILQ_INSERT_TAIL(&stcb->asoc.asconf_queue, aa_add, next); + TAILQ_INSERT_TAIL(&stcb->asoc.asconf_queue, aa_del, next); + /* Now we must hunt the addresses and add all global addresses */ if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) { struct sctp_vrf *vrf = NULL; @@ -3446,7 +3425,7 @@ sctp_asconf_send_nat_state_update(struct sctp_tcb *stcb, #ifdef INET case AF_INET: to = &sctp_ifap->address.sin; -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (prison_check_ip4(stcb->sctp_ep->ip_inp.inp.inp_cred, &to->sin_addr) != 0) { continue; @@ -3463,7 +3442,7 @@ sctp_asconf_send_nat_state_update(struct sctp_tcb *stcb, #ifdef INET6 case AF_INET6: to6 = &sctp_ifap->address.sin6; -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (prison_check_ip6(stcb->sctp_ep->ip_inp.inp.inp_cred, &to6->sin6_addr) != 0) { continue; diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_asconf.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_asconf.h index 28130f3b2f..3868949208 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_asconf.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_asconf.h @@ -32,9 +32,9 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_asconf.h 324056 2017-09-27 13:05:23Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_asconf.h 365071 2020-09-01 21:19:14Z mjg $"); #endif #ifndef _NETINET_SCTP_ASCONF_H_ @@ -45,7 +45,7 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_asconf.h 324056 2017-09-27 13:05:23Z t /* * function prototypes */ -extern void sctp_asconf_cleanup(struct sctp_tcb *, struct sctp_nets *); +extern void sctp_asconf_cleanup(struct sctp_tcb *); extern struct mbuf *sctp_compose_asconf(struct sctp_tcb *, int *, int); @@ -58,9 +58,8 @@ sctp_handle_asconf_ack(struct mbuf *, int, struct sctp_asconf_ack_chunk *, struct sctp_tcb *, struct sctp_nets *, int *); extern uint32_t -sctp_addr_mgmt_ep_sa(struct sctp_inpcb *, struct sockaddr *, - uint32_t, uint32_t, struct sctp_ifa *); - +sctp_addr_mgmt_ep_sa(struct sctp_inpcb *, struct sockaddr *, uint32_t, + uint32_t); extern int sctp_asconf_iterator_ep(struct sctp_inpcb *inp, void *ptr, uint32_t val); @@ -69,7 +68,6 @@ extern void sctp_asconf_iterator_stcb(struct sctp_inpcb *inp, void *ptr, uint32_t type); extern void sctp_asconf_iterator_end(void *ptr, uint32_t val); - extern int32_t sctp_set_primary_ip_address_sa(struct sctp_tcb *, struct sockaddr *); diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_auth.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_auth.c index 65571df2d0..9281e07803 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_auth.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_auth.c @@ -32,9 +32,9 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_auth.c 355931 2019-12-20 15:25:08Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_auth.c 365071 2020-09-01 21:19:14Z mjg $"); #endif #include @@ -53,7 +53,6 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_auth.c 355931 2019-12-20 15:25:08Z tue #define SCTP_AUTH_DEBUG2 (SCTP_BASE_SYSCTL(sctp_debug_on) & SCTP_DEBUG_AUTH2) #endif /* SCTP_DEBUG */ - void sctp_clear_chunklist(sctp_auth_chklist_t *chklist) { @@ -101,7 +100,6 @@ sctp_copy_chunklist(sctp_auth_chklist_t *list) return (new_list); } - /* * add a chunk to the required chunks list */ @@ -241,7 +239,6 @@ sctp_unpack_auth_chunks(const uint8_t *ptr, uint8_t num_chunks, return (size); } - /* * allocate structure space for a key of length keylen */ @@ -458,7 +455,6 @@ sctp_compute_hashkey(sctp_key_t *key1, sctp_key_t *key2, sctp_key_t *shared) return (new_key); } - sctp_sharedkey_t * sctp_alloc_sharedkey(void) { @@ -567,11 +563,7 @@ sctp_auth_key_acquire(struct sctp_tcb *stcb, uint16_t key_id) } void -sctp_auth_key_release(struct sctp_tcb *stcb, uint16_t key_id, int so_locked -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - SCTP_UNUSED -#endif -) +sctp_auth_key_release(struct sctp_tcb *stcb, uint16_t key_id, int so_locked) { sctp_sharedkey_t *skey; @@ -636,7 +628,6 @@ sctp_copy_skeylist(const struct sctp_keyhead *src, struct sctp_keyhead *dest) return (count); } - sctp_hmaclist_t * sctp_alloc_hmaclist(uint16_t num_hmacs) { @@ -660,7 +651,6 @@ sctp_free_hmaclist(sctp_hmaclist_t *list) { if (list != NULL) { SCTP_FREE(list,SCTP_M_AUTH_HL); - list = NULL; } } @@ -831,7 +821,6 @@ sctp_free_authinfo(sctp_authinfo_t *authinfo) /* SCTP_FREE(authinfo, SCTP_M_AUTH_??); */ } - uint32_t sctp_get_auth_chunk_len(uint16_t hmac_algo) { @@ -1171,7 +1160,6 @@ sctp_auth_is_supported_hmac(sctp_hmaclist_t *list, uint16_t id) return (0); } - /*- * clear any cached key(s) if they match the given key id on an association. * the cached key(s) will be recomputed and re-cached at next use. @@ -1584,7 +1572,6 @@ sctp_fill_hmac_digest_m(struct mbuf *m, uint32_t auth_offset, m, auth_offset, auth->hmac); } - static void sctp_zero_m(struct mbuf *m, uint32_t m_offset, uint32_t size) { @@ -1650,6 +1637,9 @@ sctp_handle_auth(struct sctp_tcb *stcb, struct sctp_auth_chunk *auth, "SCTP AUTH Chunk: shared key %u, HMAC id %u\n", shared_key_id, hmac_id); +#if defined(__Userspace__) && defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION) + return (0); +#endif /* is the indicated HMAC supported? */ if (!sctp_auth_is_supported_hmac(stcb->asoc.local_hmacs, hmac_id)) { struct mbuf *op_err; @@ -1730,11 +1720,6 @@ sctp_handle_auth(struct sctp_tcb *stcb, struct sctp_auth_chunk *auth, (void)sctp_compute_hmac_m(hmac_id, stcb->asoc.authinfo.recv_key, m, offset, computed_digest); -#if defined(__Userspace__) -#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - return (0); -#endif -#endif /* compare the computed digest with the one in the AUTH chunk */ if (timingsafe_bcmp(digest, computed_digest, digestlen) != 0) { SCTP_STAT_INCR(sctps_recvauthfailed); @@ -1750,11 +1735,7 @@ sctp_handle_auth(struct sctp_tcb *stcb, struct sctp_auth_chunk *auth, */ void sctp_notify_authentication(struct sctp_tcb *stcb, uint32_t indication, - uint16_t keyid, uint16_t alt_keyid, int so_locked -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - SCTP_UNUSED -#endif -) + uint16_t keyid, uint16_t alt_keyid, int so_locked) { struct mbuf *m_notify; struct sctp_authkey_event *auth; @@ -1809,7 +1790,6 @@ sctp_notify_authentication(struct sctp_tcb *stcb, uint32_t indication, &stcb->sctp_socket->so_rcv, 1, SCTP_READ_LOCK_NOT_HELD, so_locked); } - /*- * validates the AUTHentication related parameters in an INIT/INIT-ACK * Note: currently only used for INIT as INIT-ACK is handled inline @@ -1924,7 +1904,6 @@ sctp_validate_init_auth_params(struct mbuf *m, int offset, int limit) saw_asconf = 1; if (chunks->chunk_types[i] == SCTP_ASCONF_ACK) saw_asconf_ack = 1; - } if (num_chunks) got_chklist = 1; diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_auth.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_auth.h index 9005ccb238..d43ada90da 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_auth.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_auth.h @@ -32,9 +32,9 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_auth.h 338749 2018-09-18 10:53:07Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_auth.h 365071 2020-09-01 21:19:14Z mjg $"); #endif #ifndef _NETINET_SCTP_AUTH_H_ @@ -99,8 +99,6 @@ typedef struct sctp_authinformation { uint16_t recv_keyid; /* last recv keyid (cached) */ } sctp_authinfo_t; - - /* * Macros */ @@ -149,7 +147,6 @@ extern void sctp_auth_key_acquire(struct sctp_tcb *stcb, uint16_t keyid); extern void sctp_auth_key_release(struct sctp_tcb *stcb, uint16_t keyid, int so_locked); - /* hmac list handling */ extern sctp_hmaclist_t *sctp_alloc_hmaclist(uint16_t num_hmacs); extern void sctp_free_hmaclist(sctp_hmaclist_t *list); diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_bsd_addr.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_bsd_addr.c index 8547f447cc..83201712a4 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_bsd_addr.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_bsd_addr.c @@ -32,9 +32,9 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.c 353480 2019-10-13 18:17:08Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.c 366426 2020-10-04 15:37:34Z tuexen $"); #endif #include @@ -50,12 +50,11 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.c 353480 2019-10-13 18:17:08Z #include #include #include -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) #include #endif /* Declare all of our malloc named types */ -#ifndef __Panda__ MALLOC_DEFINE(SCTP_M_MAP, "sctp_map", "sctp asoc map descriptor"); MALLOC_DEFINE(SCTP_M_STRMI, "sctp_stri", "sctp stream in array"); MALLOC_DEFINE(SCTP_M_STRMO, "sctp_stro", "sctp stream out array"); @@ -76,12 +75,11 @@ MALLOC_DEFINE(SCTP_M_MVRF, "sctp_mvrf", "sctp mvrf pcb list"); MALLOC_DEFINE(SCTP_M_ITER, "sctp_iter", "sctp iterator control"); MALLOC_DEFINE(SCTP_M_SOCKOPT, "sctp_socko", "sctp socket option"); MALLOC_DEFINE(SCTP_M_MCORE, "sctp_mcore", "sctp mcore queue"); -#endif /* Global NON-VNET structure that controls the iterator */ struct iterator_control sctp_it_ctl; +#if !(defined(__FreeBSD__) && !defined(__Userspace__)) -#if !defined(__FreeBSD__) static void sctp_cleanup_itqueue(void) { @@ -109,7 +107,7 @@ void sctp_wakeup_iterator(void) { #if defined(SCTP_PROCESS_LEVEL_LOCKS) -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) WakeAllConditionVariable(&sctp_it_ctl.iterator_wakeup); #else pthread_cond_broadcast(&sctp_it_ctl.iterator_wakeup); @@ -131,7 +129,7 @@ sctp_iterator_thread(void *v SCTP_UNUSED) #endif SCTP_IPI_ITERATOR_WQ_LOCK(); /* In FreeBSD this thread never terminates. */ -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) for (;;) { #else while ((sctp_it_ctl.iterator_flags & SCTP_ITERATOR_MUST_EXIT) == 0) { @@ -140,25 +138,25 @@ sctp_iterator_thread(void *v SCTP_UNUSED) msleep(&sctp_it_ctl.iterator_running, #if defined(__FreeBSD__) &sctp_it_ctl.ipi_iterator_wq_mtx, -#elif defined(__APPLE__) || defined(__Userspace_os_Darwin) +#elif defined(__APPLE__) sctp_it_ctl.ipi_iterator_wq_mtx, #endif 0, "waiting_for_work", 0); #else -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) SleepConditionVariableCS(&sctp_it_ctl.iterator_wakeup, &sctp_it_ctl.ipi_iterator_wq_mtx, INFINITE); #else pthread_cond_wait(&sctp_it_ctl.iterator_wakeup, &sctp_it_ctl.ipi_iterator_wq_mtx); #endif #endif -#if !defined(__FreeBSD__) +#if !(defined(__FreeBSD__) && !defined(__Userspace__)) if (sctp_it_ctl.iterator_flags & SCTP_ITERATOR_MUST_EXIT) { break; } #endif sctp_iterator_worker(); } -#if !defined(__FreeBSD__) +#if !(defined(__FreeBSD__) && !defined(__Userspace__)) /* Now this thread needs to be terminated */ sctp_cleanup_itqueue(); sctp_it_ctl.iterator_flags |= SCTP_ITERATOR_EXITED; @@ -187,23 +185,21 @@ sctp_startup_iterator(void) SCTP_ITERATOR_LOCK_INIT(); SCTP_IPI_ITERATOR_WQ_INIT(); TAILQ_INIT(&sctp_it_ctl.iteratorhead); -#if defined(__FreeBSD__) -#if __FreeBSD_version <= 701000 - kthread_create(sctp_iterator_thread, -#else +#if defined(__Userspace__) + if (sctp_userspace_thread_create(&sctp_it_ctl.thread_proc, &sctp_iterator_thread)) { + SCTP_PRINTF("ERROR: Creating sctp_iterator_thread failed.\n"); + } else { + SCTP_BASE_VAR(iterator_thread_started) = 1; + } +#elif defined(__FreeBSD__) kproc_create(sctp_iterator_thread, -#endif (void *)NULL, &sctp_it_ctl.thread_proc, - RFPROC, + 0, SCTP_KTHREAD_PAGES, SCTP_KTRHEAD_NAME); #elif defined(__APPLE__) kernel_thread_start((thread_continue_t)sctp_iterator_thread, NULL, &sctp_it_ctl.thread_proc); -#elif defined(__Userspace__) - if (sctp_userspace_thread_create(&sctp_it_ctl.thread_proc, &sctp_iterator_thread)) { - SCTP_PRINTF("ERROR: Creating sctp_iterator_thread failed.\n"); - } #endif } @@ -248,7 +244,6 @@ sctp_gather_internal_ifa_flags(struct sctp_ifa *ifa) #endif /* __Userspace__ */ #endif /* INET6 */ - #if !defined(__Userspace__) static uint32_t sctp_is_desired_interface_type(struct ifnet *ifn) @@ -256,7 +251,7 @@ sctp_is_desired_interface_type(struct ifnet *ifn) int result; /* check the interface type to see if it's one we care about */ -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) switch(ifnet_type(ifn)) { #else switch (ifn->if_type) { @@ -282,7 +277,7 @@ sctp_is_desired_interface_type(struct ifnet *ifn) case IFT_GIF: case IFT_L2VLAN: case IFT_STF: -#if !defined(__APPLE__) +#if !(defined(__APPLE__) && !defined(__Userspace__)) case IFT_IP: case IFT_IPOVERCDLC: case IFT_IPOVERCLAW: @@ -298,16 +293,17 @@ sctp_is_desired_interface_type(struct ifnet *ifn) return (result); } #endif +#if defined(__APPLE__) && !defined(__Userspace__) -#if defined(__APPLE__) int sctp_is_vmware_interface(struct ifnet *ifn) { return (strncmp(ifnet_name(ifn), "vmnet", 5) == 0); } + #endif -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) && defined(__Userspace__) #ifdef MALLOC #undef MALLOC #define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x)) @@ -480,8 +476,7 @@ sctp_init_ifns_for_vrf(int vrfid) #endif } #endif - -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) static void sctp_init_ifns_for_vrf(int vrfid) { @@ -540,7 +535,7 @@ sctp_init_ifns_for_vrf(int vrfid) } else { ifa_flags = 0; } - snprintf(name, SCTP_IFNAMSIZ, "%s%d", ifnet_name(ifn), ifnet_unit(ifn)); + SCTP_SNPRINTF(name, SCTP_IFNAMSIZ, "%s%d", ifnet_name(ifn), ifnet_unit(ifn)); sctp_ifa = sctp_add_addr_to_vrf(vrfid, (void *)ifn, /* XXX */ ifnet_index(ifn), @@ -559,8 +554,7 @@ sctp_init_ifns_for_vrf(int vrfid) ifnet_list_free(ifnetlist); } #endif - -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) static void sctp_init_ifns_for_vrf(int vrfid) { @@ -716,16 +710,15 @@ sctp_addr_change(struct ifaddr *ifa, int cmd) } if (cmd == RTM_ADD) { (void)sctp_add_addr_to_vrf(SCTP_DEFAULT_VRFID, (void *)ifa->ifa_ifp, -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) ifnet_index(ifa->ifa_ifp), ifnet_type(ifa->ifa_ifp), ifnet_name(ifa->ifa_ifp), #else ifa->ifa_ifp->if_index, ifa->ifa_ifp->if_type, ifa->ifa_ifp->if_xname, #endif (void *)ifa, ifa->ifa_addr, ifa_flags, 1); } else { - sctp_del_addr_from_vrf(SCTP_DEFAULT_VRFID, ifa->ifa_addr, -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) ifnet_index(ifa->ifa_ifp), ifnet_name(ifa->ifa_ifp)); #else @@ -740,31 +733,13 @@ sctp_addr_change(struct ifaddr *ifa, int cmd) #endif } -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) void sctp_addr_change_event_handler(void *arg __unused, struct ifaddr *ifa, int cmd) { sctp_addr_change(ifa, cmd); } - -void -sctp_add_or_del_interfaces(int (*pred)(struct ifnet *), int add) -{ - struct ifnet *ifn; - struct ifaddr *ifa; - - IFNET_RLOCK(); - CK_STAILQ_FOREACH(ifn, &MODULE_GLOBAL(ifnet), if_link) { - if (!(*pred)(ifn)) { - continue; - } - CK_STAILQ_FOREACH(ifa, &ifn->if_addrhead, ifa_link) { - sctp_addr_change(ifa, add ? RTM_ADD : RTM_DELETE); - } - } - IFNET_RUNLOCK(); -} #endif -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) void sctp_add_or_del_interfaces(int (*pred)(struct ifnet *), int add) { @@ -797,7 +772,7 @@ sctp_get_mbuf_for_msg(unsigned int space_needed, int want_header, int how, int allonebuf, int type) { struct mbuf *m = NULL; -#if defined(__FreeBSD__) && __FreeBSD_version > 1100052 || defined(__Userspace__) +#if defined(__FreeBSD__) || defined(__Userspace__) #if defined(__Userspace__) m = m_getm2(NULL, space_needed, how, type, want_header ? M_PKTHDR : 0, allonebuf); #else @@ -813,7 +788,7 @@ sctp_get_mbuf_for_msg(unsigned int space_needed, int want_header, m_freem(m); return (NULL); } - KASSERT(SCTP_BUF_NEXT(m) == NULL, ("%s: no chain allowed", __FUNCTION__)); + KASSERT(SCTP_BUF_NEXT(m) == NULL, ("%s: no chain allowed", __func__)); } #endif #ifdef SCTP_MBUF_LOGGING @@ -867,7 +842,6 @@ sctp_get_mbuf_for_msg(unsigned int space_needed, int want_header, return (m); } - #ifdef SCTP_PACKET_LOGGING void sctp_packet_log(struct mbuf *m) @@ -943,7 +917,6 @@ sctp_packet_log(struct mbuf *m) SCTP_BASE_VAR(packet_log_end)); SCTP_BASE_VAR(packet_log_end) = 0; goto no_log; - } lenat = (int *)&SCTP_BASE_VAR(packet_log_buffer)[thisbegin]; *lenat = total_len; @@ -969,7 +942,6 @@ sctp_packet_log(struct mbuf *m) atomic_subtract_int(&SCTP_BASE_VAR(packet_log_writers), 1); } - int sctp_copy_out_packet_log(uint8_t *target, int length) { diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_bsd_addr.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_bsd_addr.h index c43823cb26..d6ab91b5b5 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_bsd_addr.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_bsd_addr.h @@ -32,9 +32,9 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.h 353480 2019-10-13 18:17:08Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.h 365071 2020-09-01 21:19:14Z mjg $"); #endif #ifndef _NETINET_SCTP_BSD_ADDR_H_ @@ -49,7 +49,6 @@ void sctp_wakeup_iterator(void); void sctp_startup_iterator(void); - #ifdef INET6 void sctp_gather_internal_ifa_flags(struct sctp_ifa *ifa); #endif @@ -61,10 +60,8 @@ int sctp_copy_out_packet_log(uint8_t *target, int length); #endif -#if !defined(__Panda__) void sctp_addr_change(struct ifaddr *ifa, int cmd); -#endif -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) void sctp_addr_change_event_handler(void *, struct ifaddr *, int); #endif diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_callout.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_callout.c index c6cffc783b..4c9be7568b 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_callout.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_callout.c @@ -34,12 +34,12 @@ #if defined(__Userspace__) #include -#if !defined (__Userspace_os_Windows) +#if !defined(_WIN32) #include #include #include #endif -#if defined(__Userspace_os_NaCl) +#if defined(__native_client__) #include #endif #include @@ -54,6 +54,7 @@ #include #include #endif +#include /* * Callout/Timer routines for OS that doesn't have them @@ -86,17 +87,20 @@ sctp_os_timer_init(sctp_os_timer_t *c) memset(c, 0, sizeof(*c)); } -void +int sctp_os_timer_start(sctp_os_timer_t *c, uint32_t to_ticks, void (*ftn) (void *), void *arg) { + int ret = 0; + /* paranoia */ if ((c == NULL) || (ftn == NULL)) - return; + return (ret); SCTP_TIMERQ_LOCK(); /* check to see if we're rescheduling a timer */ if (c->c_flags & SCTP_CALLOUT_PENDING) { + ret = 1; if (c == sctp_os_timer_next) { sctp_os_timer_next = TAILQ_NEXT(c, tqe); } @@ -122,6 +126,7 @@ sctp_os_timer_start(sctp_os_timer_t *c, uint32_t to_ticks, void (*ftn) (void *), c->c_time = ticks + to_ticks; TAILQ_INSERT_TAIL(&SCTP_BASE_INFO(callqueue), c, tqe); SCTP_TIMERQ_UNLOCK(); + return (ret); } int @@ -175,7 +180,7 @@ sctp_handle_tick(uint32_t elapsed_ticks) SCTP_TIMERQ_UNLOCK(); } -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) void sctp_timeout(void *arg SCTP_UNUSED) { @@ -192,7 +197,7 @@ user_sctp_timer_iterate(void *arg) { sctp_userspace_set_threadname("SCTP timer"); for (;;) { -#if defined (__Userspace_os_Windows) +#if defined(_WIN32) Sleep(TIMEOUT_INTERVAL); #else struct timespec amount, remaining; @@ -206,13 +211,13 @@ user_sctp_timer_iterate(void *arg) if (atomic_cmpset_int(&SCTP_BASE_VAR(timer_thread_should_exit), 1, 1)) { break; } - sctp_handle_tick(MSEC_TO_TICKS(TIMEOUT_INTERVAL)); + sctp_handle_tick(sctp_msecs_to_ticks(TIMEOUT_INTERVAL)); } return (NULL); } void -sctp_start_timer(void) +sctp_start_timer_thread(void) { /* * No need to do SCTP_TIMERQ_LOCK_INIT(); @@ -223,7 +228,22 @@ sctp_start_timer(void) rc = sctp_userspace_thread_create(&SCTP_BASE_VAR(timer_thread), user_sctp_timer_iterate); if (rc) { SCTP_PRINTF("ERROR; return code from sctp_thread_create() is %d\n", rc); + } else { + SCTP_BASE_VAR(timer_thread_started) = 1; } } +void +sctp_stop_timer_thread(void) +{ + atomic_cmpset_int(&SCTP_BASE_VAR(timer_thread_should_exit), 0, 1); + if (SCTP_BASE_VAR(timer_thread_started)) { +#if defined(_WIN32) + WaitForSingleObject(SCTP_BASE_VAR(timer_thread), INFINITE); + CloseHandle(SCTP_BASE_VAR(timer_thread)); +#else + pthread_join(SCTP_BASE_VAR(timer_thread), NULL); +#endif + } +} #endif diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_callout.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_callout.h index 13279da053..81fd8530d1 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_callout.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_callout.h @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include __FBSDID("$FreeBSD$"); #endif @@ -53,7 +53,7 @@ __FBSDID("$FreeBSD$"); #define SCTP_TICKS_PER_FASTTIMO 20 /* called about every 20ms */ #if defined(__Userspace__) -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) #define SCTP_TIMERQ_LOCK() EnterCriticalSection(&SCTP_BASE_VAR(timer_mtx)) #define SCTP_TIMERQ_UNLOCK() LeaveCriticalSection(&SCTP_BASE_VAR(timer_mtx)) #define SCTP_TIMERQ_LOCK_INIT() InitializeCriticalSection(&SCTP_BASE_VAR(timer_mtx)) @@ -88,11 +88,18 @@ typedef struct sctp_callout sctp_os_timer_t; #define SCTP_CALLOUT_PENDING 0x0004 /* callout is waiting for timeout */ void sctp_os_timer_init(sctp_os_timer_t *tmr); -void sctp_os_timer_start(sctp_os_timer_t *, uint32_t, void (*)(void *), void *); +/* Returns 1 if pending timer was rescheduled, 0 otherwise. */ +int sctp_os_timer_start(sctp_os_timer_t *, uint32_t, void (*)(void *), void *); +/* Returns 1 if pending timer was stopped, 0 otherwise. */ int sctp_os_timer_stop(sctp_os_timer_t *); void sctp_handle_tick(uint32_t); #define SCTP_OS_TIMER_INIT sctp_os_timer_init +/* + * NOTE: The next two shouldn't be called directly outside of sctp_timer_start() + * and sctp_timer_stop(), since they don't handle incrementing/decrementing + * relevant reference counts. + */ #define SCTP_OS_TIMER_START sctp_os_timer_start #define SCTP_OS_TIMER_STOP sctp_os_timer_stop /* MT FIXME: Is the following correct? */ @@ -102,9 +109,10 @@ void sctp_handle_tick(uint32_t); #define SCTP_OS_TIMER_DEACTIVATE(tmr) ((tmr)->c_flags &= ~SCTP_CALLOUT_ACTIVE) #if defined(__Userspace__) -void sctp_start_timer(void); +void sctp_start_timer_thread(void); +void sctp_stop_timer_thread(void); #endif -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) void sctp_timeout(void *); #endif diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_cc_functions.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_cc_functions.c index 0139057939..68d53bd9e3 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_cc_functions.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_cc_functions.c @@ -32,9 +32,9 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_cc_functions.c 356660 2020-01-12 15:45:27Z tuexen $"); +__FBSDID("$FreeBSD$"); #endif #include @@ -50,7 +50,7 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_cc_functions.c 356660 2020-01-12 15:45 #include #include #include -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) #include #endif @@ -64,7 +64,7 @@ sctp_enforce_cwnd_limit(struct sctp_association *assoc, struct sctp_nets *net) if ((assoc->max_cwnd > 0) && (net->cwnd > assoc->max_cwnd) && (net->cwnd > (net->mtu - sizeof(struct sctphdr)))) { - net->cwnd = assoc->max_cwnd ; + net->cwnd = assoc->max_cwnd; if (net->cwnd < (net->mtu - sizeof(struct sctphdr))) { net->cwnd = net->mtu - sizeof(struct sctphdr); } @@ -101,7 +101,7 @@ sctp_set_initial_cc_param(struct sctp_tcb *stcb, struct sctp_nets *net) } sctp_enforce_cwnd_limit(assoc, net); net->ssthresh = assoc->peers_rwnd; -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) SDT_PROBE5(sctp, cwnd, net, init, stcb->asoc.my_vtag, ((stcb->sctp_ep->sctp_lport << 16) | (stcb->rport)), net, 0, net->cwnd); @@ -163,7 +163,6 @@ sctp_cwnd_update_after_fr(struct sctp_tcb *stcb, (uint64_t)net->mtu * (uint64_t)net->ssthresh) / (uint64_t)t_ssthresh); - } if (asoc->sctp_cmt_on_off == SCTP_CMT_RPV2) { uint32_t srtt; @@ -196,7 +195,7 @@ sctp_cwnd_update_after_fr(struct sctp_tcb *stcb, } net->cwnd = net->ssthresh; sctp_enforce_cwnd_limit(asoc, net); -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) SDT_PROBE5(sctp, cwnd, net, fr, stcb->asoc.my_vtag, ((stcb->sctp_ep->sctp_lport << 16) | (stcb->rport)), net, old_cwnd, net->cwnd); @@ -251,22 +250,21 @@ sctp_cwnd_update_after_fr(struct sctp_tcb *stcb, #define SCTP_INST_NEUTRAL 2 /* Neutral, no indication */ #define SCTP_INST_GAINING 3 /* Gaining, step down possible */ - -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) static int cc_bw_same(struct sctp_tcb *stcb, struct sctp_nets *net, uint64_t nbw, - uint64_t rtt_offset, uint64_t vtag, uint8_t inst_ind) + uint64_t rtt_offset, uint64_t vtag, uint8_t inst_ind) #else static int cc_bw_same(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net, uint64_t nbw, - uint64_t rtt_offset, uint8_t inst_ind) + uint64_t rtt_offset, uint8_t inst_ind) #endif { -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) uint64_t oth, probepoint; #endif -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) probepoint = (((uint64_t)net->cwnd) << 32); #endif if (net->rtt > net->cc_mod.rtcc.lbw_rtt + rtt_offset) { @@ -275,7 +273,7 @@ cc_bw_same(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net, uint64_t nb * we don't update bw.. so we don't * update the rtt either. */ -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) /* Probe point 5 */ probepoint |= ((5 << 16) | 1); SDT_PROBE5(sctp, cwnd, net, rttvar, @@ -295,7 +293,7 @@ cc_bw_same(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net, uint64_t nb ((net->cc_mod.rtcc.step_cnt > net->cc_mod.rtcc.steady_step) && ((net->cc_mod.rtcc.step_cnt % net->cc_mod.rtcc.steady_step) == 0))) { /* Try a step down */ -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) oth = net->cc_mod.rtcc.vol_reduce; oth <<= 16; oth |= net->cc_mod.rtcc.step_cnt; @@ -324,7 +322,7 @@ cc_bw_same(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net, uint64_t nb * we update both the bw and the rtt here to * lock this in as a good step down. */ -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) /* Probe point 6 */ probepoint |= ((6 << 16) | 0); SDT_PROBE5(sctp, cwnd, net, rttvar, @@ -335,7 +333,7 @@ cc_bw_same(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net, uint64_t nb probepoint); #endif if (net->cc_mod.rtcc.steady_step) { -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) oth = net->cc_mod.rtcc.vol_reduce; oth <<= 16; oth |= net->cc_mod.rtcc.step_cnt; @@ -370,7 +368,7 @@ cc_bw_same(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net, uint64_t nb } /* Ok bw and rtt remained the same .. no update to any */ -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) /* Probe point 7 */ probepoint |= ((7 << 16) | net->cc_mod.rtcc.ret_from_eq); SDT_PROBE5(sctp, cwnd, net, rttvar, @@ -407,22 +405,22 @@ cc_bw_same(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net, uint64_t nb return ((int)net->cc_mod.rtcc.ret_from_eq); } -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) static int cc_bw_decrease(struct sctp_tcb *stcb, struct sctp_nets *net, uint64_t nbw, uint64_t rtt_offset, - uint64_t vtag, uint8_t inst_ind) + uint64_t vtag, uint8_t inst_ind) #else static int cc_bw_decrease(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net, uint64_t nbw, uint64_t rtt_offset, - uint8_t inst_ind) + uint8_t inst_ind) #endif { -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) uint64_t oth, probepoint; #endif /* Bandwidth decreased.*/ -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) probepoint = (((uint64_t)net->cwnd) << 32); #endif if (net->rtt > net->cc_mod.rtcc.lbw_rtt+rtt_offset) { @@ -431,7 +429,7 @@ cc_bw_decrease(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net, uint64_ if ((net->cwnd > net->cc_mod.rtcc.cwnd_at_bw_set) && (inst_ind != SCTP_INST_LOOSING)) { /* We caused it maybe.. back off? */ -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) /* PROBE POINT 1 */ probepoint |= ((1 << 16) | 1); SDT_PROBE5(sctp, cwnd, net, rttvar, @@ -448,7 +446,7 @@ cc_bw_decrease(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net, uint64_ } return (1); } -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) /* Probe point 2 */ probepoint |= ((2 << 16) | 0); SDT_PROBE5(sctp, cwnd, net, rttvar, @@ -460,7 +458,7 @@ cc_bw_decrease(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net, uint64_ #endif /* Someone else - fight for more? */ if (net->cc_mod.rtcc.steady_step) { -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) oth = net->cc_mod.rtcc.vol_reduce; oth <<= 16; oth |= net->cc_mod.rtcc.step_cnt; @@ -488,7 +486,7 @@ cc_bw_decrease(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net, uint64_ goto out_decision; } else if (net->rtt < net->cc_mod.rtcc.lbw_rtt-rtt_offset) { /* bw & rtt decreased */ -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) /* Probe point 3 */ probepoint |= ((3 << 16) | 0); SDT_PROBE5(sctp, cwnd, net, rttvar, @@ -499,7 +497,7 @@ cc_bw_decrease(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net, uint64_ probepoint); #endif if (net->cc_mod.rtcc.steady_step) { -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) oth = net->cc_mod.rtcc.vol_reduce; oth <<= 16; oth |= net->cc_mod.rtcc.step_cnt; @@ -524,7 +522,7 @@ cc_bw_decrease(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net, uint64_ goto out_decision; } /* The bw decreased but rtt stayed the same */ -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) /* Probe point 4 */ probepoint |= ((4 << 16) | 0); SDT_PROBE5(sctp, cwnd, net, rttvar, @@ -535,7 +533,7 @@ cc_bw_decrease(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net, uint64_ probepoint); #endif if (net->cc_mod.rtcc.steady_step) { -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) oth = net->cc_mod.rtcc.vol_reduce; oth <<= 16; oth |= net->cc_mod.rtcc.step_cnt; @@ -568,7 +566,7 @@ out_decision: } } -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) static int cc_bw_increase(struct sctp_tcb *stcb, struct sctp_nets *net, uint64_t nbw, uint64_t vtag) #else @@ -576,7 +574,7 @@ static int cc_bw_increase(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net, uint64_t nbw) #endif { -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) uint64_t oth, probepoint; #endif @@ -586,7 +584,7 @@ cc_bw_increase(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net, uint64_ * update. Note that we pay no attention to * the inst_ind since our overall sum is increasing. */ -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) /* PROBE POINT 0 */ probepoint = (((uint64_t)net->cwnd) << 32); SDT_PROBE5(sctp, cwnd, net, rttvar, @@ -597,7 +595,7 @@ cc_bw_increase(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net, uint64_ probepoint); #endif if (net->cc_mod.rtcc.steady_step) { -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) oth = net->cc_mod.rtcc.vol_reduce; oth <<= 16; oth |= net->cc_mod.rtcc.step_cnt; @@ -627,7 +625,7 @@ static int cc_bw_limit(struct sctp_tcb *stcb, struct sctp_nets *net, uint64_t nbw) { uint64_t bw_offset, rtt_offset; -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) uint64_t probepoint, rtt, vtag; #endif uint64_t bytes_for_this_rtt, inst_bw; @@ -673,7 +671,7 @@ cc_bw_limit(struct sctp_tcb *stcb, struct sctp_nets *net, uint64_t nbw) * change within 1/32nd */ bw_shift = SCTP_BASE_SYSCTL(sctp_rttvar_bw); -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) rtt = stcb->asoc.my_vtag; vtag = (rtt << 32) | (((uint32_t)(stcb->sctp_ep->sctp_lport)) << 16) | (stcb->rport); probepoint = (((uint64_t)net->cwnd) << 32); @@ -694,12 +692,12 @@ cc_bw_limit(struct sctp_tcb *stcb, struct sctp_nets *net, uint64_t nbw) inst_ind = SCTP_INST_LOOSING; else inst_ind = SCTP_INST_NEUTRAL; -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) probepoint |= ((0xb << 16) | inst_ind); #endif } else { inst_ind = net->cc_mod.rtcc.last_inst_ind; -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) inst_bw = bytes_for_this_rtt / (uint64_t)(net->rtt); /* Can't determine do not change */ probepoint |= ((0xc << 16) | inst_ind); @@ -707,13 +705,13 @@ cc_bw_limit(struct sctp_tcb *stcb, struct sctp_nets *net, uint64_t nbw) } } else { inst_ind = net->cc_mod.rtcc.last_inst_ind; -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) inst_bw = bytes_for_this_rtt; /* Can't determine do not change */ probepoint |= ((0xd << 16) | inst_ind); #endif } -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) SDT_PROBE5(sctp, cwnd, net, rttvar, vtag, ((nbw << 32) | inst_bw), @@ -727,7 +725,7 @@ cc_bw_limit(struct sctp_tcb *stcb, struct sctp_nets *net, uint64_t nbw) } bw_offset = net->cc_mod.rtcc.lbw >> bw_shift; if (nbw > net->cc_mod.rtcc.lbw + bw_offset) { -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) ret = cc_bw_increase(stcb, net, nbw, vtag); #else ret = cc_bw_increase(stcb, net, nbw); @@ -736,7 +734,7 @@ cc_bw_limit(struct sctp_tcb *stcb, struct sctp_nets *net, uint64_t nbw) } rtt_offset = net->cc_mod.rtcc.lbw_rtt >> SCTP_BASE_SYSCTL(sctp_rttvar_rtt); if (nbw < net->cc_mod.rtcc.lbw - bw_offset) { -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) ret = cc_bw_decrease(stcb, net, nbw, rtt_offset, vtag, inst_ind); #else ret = cc_bw_decrease(stcb, net, nbw, rtt_offset, inst_ind); @@ -747,7 +745,7 @@ cc_bw_limit(struct sctp_tcb *stcb, struct sctp_nets *net, uint64_t nbw) * we are in a situation where * the bw stayed the same. */ -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) ret = cc_bw_same(stcb, net, nbw, rtt_offset, vtag, inst_ind); #else ret = cc_bw_same(stcb, net, nbw, rtt_offset, inst_ind); @@ -763,10 +761,10 @@ sctp_cwnd_update_after_sack_common(struct sctp_tcb *stcb, int accum_moved, int reneged_all SCTP_UNUSED, int will_exit, int use_rtcc) { struct sctp_nets *net; -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) int old_cwnd; #endif - uint32_t t_ssthresh, t_cwnd, incr; + uint32_t t_ssthresh, incr; uint64_t t_ucwnd_sbw; uint64_t t_path_mptcp; uint64_t mptcp_like_alpha; @@ -775,7 +773,6 @@ sctp_cwnd_update_after_sack_common(struct sctp_tcb *stcb, /* MT FIXME: Don't compute this over and over again */ t_ssthresh = 0; - t_cwnd = 0; t_ucwnd_sbw = 0; t_path_mptcp = 0; mptcp_like_alpha = 1; @@ -785,7 +782,6 @@ sctp_cwnd_update_after_sack_common(struct sctp_tcb *stcb, max_path = 0; TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { t_ssthresh += net->ssthresh; - t_cwnd += net->cwnd; /* lastsa>>3; we don't need to devide ...*/ srtt = net->lastsa; if (srtt > 0) { @@ -817,7 +813,6 @@ sctp_cwnd_update_after_sack_common(struct sctp_tcb *stcb, /* update cwnd and Early FR */ /******************************/ TAILQ_FOREACH(net, &asoc->nets, sctp_next) { - #ifdef JANA_CMT_FAST_RECOVERY /* * CMT fast recovery code. Need to debug. @@ -837,7 +832,7 @@ sctp_cwnd_update_after_sack_common(struct sctp_tcb *stcb, continue; } #ifdef JANA_CMT_FAST_RECOVERY - /* CMT fast recovery code + /* CMT fast recovery code */ /* if (sctp_cmt_on_off > 0 && net->fast_retran_loss_recovery && net->will_exit_fast_recovery == 0) { @@ -879,7 +874,7 @@ sctp_cwnd_update_after_sack_common(struct sctp_tcb *stcb, continue; } } else { -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) uint64_t vtag, probepoint; probepoint = (((uint64_t)net->cwnd) << 32); @@ -915,7 +910,7 @@ sctp_cwnd_update_after_sack_common(struct sctp_tcb *stcb, if (net->flight_size + net->net_ack >= net->cwnd) { uint32_t limit; -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) old_cwnd = net->cwnd; #endif switch (asoc->sctp_cmt_on_off) { @@ -987,7 +982,7 @@ sctp_cwnd_update_after_sack_common(struct sctp_tcb *stcb, sctp_log_cwnd(stcb, net, incr, SCTP_CWND_LOG_FROM_SS); } -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) SDT_PROBE5(sctp, cwnd, net, ack, stcb->asoc.my_vtag, ((stcb->sctp_ep->sctp_lport << 16) | (stcb->rport)), @@ -1008,9 +1003,9 @@ sctp_cwnd_update_after_sack_common(struct sctp_tcb *stcb, net->partial_bytes_acked += net->net_ack; if ((net->flight_size + net->net_ack >= net->cwnd) && - (net->partial_bytes_acked >= net->cwnd)) { + (net->partial_bytes_acked >= net->cwnd)) { net->partial_bytes_acked -= net->cwnd; -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) old_cwnd = net->cwnd; #endif switch (asoc->sctp_cmt_on_off) { @@ -1051,7 +1046,7 @@ sctp_cwnd_update_after_sack_common(struct sctp_tcb *stcb, } net->cwnd += incr; sctp_enforce_cwnd_limit(asoc, net); -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) SDT_PROBE5(sctp, cwnd, net, ack, stcb->asoc.my_vtag, ((stcb->sctp_ep->sctp_lport << 16) | (stcb->rport)), @@ -1078,7 +1073,7 @@ sctp_cwnd_update_after_sack_common(struct sctp_tcb *stcb, } } -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) static void sctp_cwnd_update_exit_pf_common(struct sctp_tcb *stcb, struct sctp_nets *net) #else @@ -1086,13 +1081,13 @@ static void sctp_cwnd_update_exit_pf_common(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net) #endif { -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) int old_cwnd; old_cwnd = net->cwnd; #endif net->cwnd = net->mtu; -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) SDT_PROBE5(sctp, cwnd, net, ack, stcb->asoc.my_vtag, ((stcb->sctp_ep->sctp_lport << 16) | (stcb->rport)), net, old_cwnd, net->cwnd); @@ -1101,7 +1096,6 @@ sctp_cwnd_update_exit_pf_common(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_n (void *)net, net->cwnd); } - static void sctp_cwnd_update_after_timeout(struct sctp_tcb *stcb, struct sctp_nets *net) { @@ -1165,7 +1159,7 @@ sctp_cwnd_update_after_timeout(struct sctp_tcb *stcb, struct sctp_nets *net) } net->cwnd = net->mtu; net->partial_bytes_acked = 0; -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) SDT_PROBE5(sctp, cwnd, net, to, stcb->asoc.my_vtag, ((stcb->sctp_ep->sctp_lport << 16) | (stcb->rport)), @@ -1179,7 +1173,7 @@ sctp_cwnd_update_after_timeout(struct sctp_tcb *stcb, struct sctp_nets *net) static void sctp_cwnd_update_after_ecn_echo_common(struct sctp_tcb *stcb, struct sctp_nets *net, - int in_window, int num_pkt_lost, int use_rtcc) + int in_window, int num_pkt_lost, int use_rtcc) { int old_cwnd = net->cwnd; if ((use_rtcc) && (net->lan_type == SCTP_LAN_LOCAL) && (net->cc_mod.rtcc.use_dccc_ecn)) { @@ -1207,10 +1201,9 @@ sctp_cwnd_update_after_ecn_echo_common(struct sctp_tcb *stcb, struct sctp_nets * if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_CWND_MONITOR_ENABLE) { sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd), SCTP_CWND_LOG_FROM_SAT); } - } SCTP_STAT_INCR(sctps_ecnereducedcwnd); - } else { + } else { if (in_window == 0) { SCTP_STAT_INCR(sctps_ecnereducedcwnd); net->ssthresh = net->cwnd / 2; @@ -1220,7 +1213,7 @@ sctp_cwnd_update_after_ecn_echo_common(struct sctp_tcb *stcb, struct sctp_nets * net->RTO <<= 1; } net->cwnd = net->ssthresh; -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) SDT_PROBE5(sctp, cwnd, net, ecn, stcb->asoc.my_vtag, ((stcb->sctp_ep->sctp_lport << 16) | (stcb->rport)), @@ -1341,7 +1334,7 @@ sctp_cwnd_update_after_packet_dropped(struct sctp_tcb *stcb, sctp_enforce_cwnd_limit(&stcb->asoc, net); if (net->cwnd - old_cwnd != 0) { /* log only changes */ -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) SDT_PROBE5(sctp, cwnd, net, pd, stcb->asoc.my_vtag, ((stcb->sctp_ep->sctp_lport << 16) | (stcb->rport)), @@ -1357,7 +1350,7 @@ sctp_cwnd_update_after_packet_dropped(struct sctp_tcb *stcb, static void sctp_cwnd_update_after_output(struct sctp_tcb *stcb, - struct sctp_nets *net, int burst_limit) + struct sctp_nets *net, int burst_limit) { int old_cwnd = net->cwnd; @@ -1366,7 +1359,7 @@ sctp_cwnd_update_after_output(struct sctp_tcb *stcb, if (burst_limit) { net->cwnd = (net->flight_size + (burst_limit * net->mtu)); sctp_enforce_cwnd_limit(&stcb->asoc, net); -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) SDT_PROBE5(sctp, cwnd, net, bl, stcb->asoc.my_vtag, ((stcb->sctp_ep->sctp_lport << 16) | (stcb->rport)), @@ -1381,8 +1374,8 @@ sctp_cwnd_update_after_output(struct sctp_tcb *stcb, static void sctp_cwnd_update_after_sack(struct sctp_tcb *stcb, - struct sctp_association *asoc, - int accum_moved, int reneged_all, int will_exit) + struct sctp_association *asoc, + int accum_moved, int reneged_all, int will_exit) { /* Passing a zero argument in last disables the rtcc algorithm */ sctp_cwnd_update_after_sack_common(stcb, asoc, accum_moved, reneged_all, will_exit, 0); @@ -1390,7 +1383,7 @@ sctp_cwnd_update_after_sack(struct sctp_tcb *stcb, static void sctp_cwnd_update_after_ecn_echo(struct sctp_tcb *stcb, struct sctp_nets *net, - int in_window, int num_pkt_lost) + int in_window, int num_pkt_lost) { /* Passing a zero argument in last disables the rtcc algorithm */ sctp_cwnd_update_after_ecn_echo_common(stcb, net, in_window, num_pkt_lost, 0); @@ -1403,22 +1396,20 @@ sctp_cwnd_update_after_ecn_echo(struct sctp_tcb *stcb, struct sctp_nets *net, */ static void sctp_cwnd_update_rtcc_after_ecn_echo(struct sctp_tcb *stcb, struct sctp_nets *net, - int in_window, int num_pkt_lost) + int in_window, int num_pkt_lost) { sctp_cwnd_update_after_ecn_echo_common(stcb, net, in_window, num_pkt_lost, 1); } - -static -void sctp_cwnd_update_rtcc_tsn_acknowledged(struct sctp_nets *net, - struct sctp_tmit_chunk *tp1) +static void sctp_cwnd_update_rtcc_tsn_acknowledged(struct sctp_nets *net, + struct sctp_tmit_chunk *tp1) { net->cc_mod.rtcc.bw_bytes += tp1->send_size; } static void sctp_cwnd_prepare_rtcc_net_for_sack(struct sctp_tcb *stcb SCTP_UNUSED, - struct sctp_nets *net) + struct sctp_nets *net) { if (net->cc_mod.rtcc.tls_needs_set > 0) { /* We had a bw measurment going on */ @@ -1431,14 +1422,14 @@ sctp_cwnd_prepare_rtcc_net_for_sack(struct sctp_tcb *stcb SCTP_UNUSED, static void sctp_cwnd_new_rtcc_transmission_begins(struct sctp_tcb *stcb, - struct sctp_nets *net) + struct sctp_nets *net) { -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) uint64_t vtag, probepoint; #endif if (net->cc_mod.rtcc.lbw) { -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) /* Clear the old bw.. we went to 0 in-flight */ vtag = (net->rtt << 32) | (((uint32_t)(stcb->sctp_ep->sctp_lport)) << 16) | (stcb->rport); @@ -1492,15 +1483,15 @@ sctp_cwnd_new_rtcc_transmission_begins(struct sctp_tcb *stcb, static void sctp_set_rtcc_initial_cc_param(struct sctp_tcb *stcb, - struct sctp_nets *net) + struct sctp_nets *net) { -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) uint64_t vtag, probepoint; #endif sctp_set_initial_cc_param(stcb, net); stcb->asoc.use_precise_time = 1; -#if defined(__FreeBSD__) && __FreeBSD_version >= 803000 +#if defined(__FreeBSD__) && !defined(__Userspace__) probepoint = (((uint64_t)net->cwnd) << 32); probepoint |= ((9 << 16) | 0); vtag = (net->rtt << 32) | @@ -1527,15 +1518,14 @@ sctp_set_rtcc_initial_cc_param(struct sctp_tcb *stcb, net->cc_mod.rtcc.use_dccc_ecn = SCTP_BASE_SYSCTL(sctp_use_dccc_ecn); net->cc_mod.rtcc.step_cnt = 0; net->cc_mod.rtcc.last_step_state = 0; - - } static int sctp_cwnd_rtcc_socket_option(struct sctp_tcb *stcb, int setorget, - struct sctp_cc_option *cc_opt) + struct sctp_cc_option *cc_opt) { struct sctp_nets *net; + if (setorget == 1) { /* a set */ if (cc_opt->option == SCTP_CC_OPT_RTCC_SETMODE) { @@ -1600,8 +1590,8 @@ sctp_cwnd_update_rtcc_packet_transmitted(struct sctp_tcb *stcb SCTP_UNUSED, static void sctp_cwnd_update_rtcc_after_sack(struct sctp_tcb *stcb, - struct sctp_association *asoc, - int accum_moved, int reneged_all, int will_exit) + struct sctp_association *asoc, + int accum_moved, int reneged_all, int will_exit) { /* Passing a one argument at the last enables the rtcc algorithm */ sctp_cwnd_update_after_sack_common(stcb, asoc, accum_moved, reneged_all, will_exit, 1); @@ -1842,15 +1832,14 @@ sctp_hs_cwnd_update_after_fr(struct sctp_tcb *stcb, static void sctp_hs_cwnd_update_after_sack(struct sctp_tcb *stcb, - struct sctp_association *asoc, - int accum_moved, int reneged_all SCTP_UNUSED, int will_exit) + struct sctp_association *asoc, + int accum_moved, int reneged_all SCTP_UNUSED, int will_exit) { struct sctp_nets *net; /******************************/ /* update cwnd and Early FR */ /******************************/ TAILQ_FOREACH(net, &asoc->nets, sctp_next) { - #ifdef JANA_CMT_FAST_RECOVERY /* * CMT fast recovery code. Need to debug. @@ -1870,7 +1859,7 @@ sctp_hs_cwnd_update_after_sack(struct sctp_tcb *stcb, continue; } #ifdef JANA_CMT_FAST_RECOVERY - /* CMT fast recovery code + /* CMT fast recovery code */ /* if (sctp_cmt_on_off > 0 && net->fast_retran_loss_recovery && net->will_exit_fast_recovery == 0) { @@ -1934,7 +1923,6 @@ sctp_hs_cwnd_update_after_sack(struct sctp_tcb *stcb, } } - /* * H-TCP congestion control. The algorithm is detailed in: * R.N.Shorten, D.J.Leith: @@ -1943,7 +1931,6 @@ sctp_hs_cwnd_update_after_sack(struct sctp_tcb *stcb, * http://www.hamilton.ie/net/htcp3.pdf */ - static int use_rtt_scaling = 1; static int use_bandwidth_switch = 1; @@ -2000,7 +1987,7 @@ measure_rtt(struct sctp_nets *net) if (net->fast_retran_ip == 0 && net->ssthresh < 0xFFFF && htcp_ccount(&net->cc_mod.htcp_ca) > 3) { if (net->cc_mod.htcp_ca.maxRTT < net->cc_mod.htcp_ca.minRTT) net->cc_mod.htcp_ca.maxRTT = net->cc_mod.htcp_ca.minRTT; - if (net->cc_mod.htcp_ca.maxRTT < srtt && srtt <= net->cc_mod.htcp_ca.maxRTT+MSEC_TO_TICKS(20)) + if (net->cc_mod.htcp_ca.maxRTT < srtt && srtt <= net->cc_mod.htcp_ca.maxRTT+sctp_msecs_to_ticks(20)) net->cc_mod.htcp_ca.maxRTT = srtt; } } @@ -2060,7 +2047,7 @@ htcp_beta_update(struct htcp *ca, uint32_t minRTT, uint32_t maxRTT) } } - if (ca->modeswitch && minRTT > (uint32_t)MSEC_TO_TICKS(10) && maxRTT) { + if (ca->modeswitch && minRTT > sctp_msecs_to_ticks(10) && maxRTT) { ca->beta = (minRTT<<7)/maxRTT; if (ca->beta < BETA_MIN) ca->beta = BETA_MIN; @@ -2081,19 +2068,19 @@ htcp_alpha_update(struct htcp *ca) if (diff > (uint32_t)hz) { diff -= hz; - factor = 1+ ( 10*diff + ((diff/2)*(diff/2)/hz))/hz; + factor = 1+ (10 * diff + ((diff / 2) * (diff / 2) / hz)) / hz; } if (use_rtt_scaling && minRTT) { - uint32_t scale = (hz<<3)/(10*minRTT); - scale = min(max(scale, 1U<<2), 10U<<3); /* clamping ratio to interval [0.5,10]<<3 */ - factor = (factor<<3)/scale; - if (!factor) + uint32_t scale = (hz << 3) / (10 * minRTT); + scale = min(max(scale, 1U << 2), 10U << 3); /* clamping ratio to interval [0.5,10]<<3 */ + factor = (factor << 3) / scale; + if (factor != 0) factor = 1; } - ca->alpha = 2*factor*((1<<7)-ca->beta); - if (!ca->alpha) + ca->alpha = 2 * factor * ((1 << 7) - ca->beta); + if (ca->alpha != 0) ca->alpha = ALPHA_BASE; } @@ -2131,10 +2118,10 @@ htcp_cong_avoid(struct sctp_tcb *stcb, struct sctp_nets *net) { /*- * How to handle these functions? - * if (!tcp_is_cwnd_limited(sk, in_flight)) RRS - good question. + * if (!tcp_is_cwnd_limited(sk, in_flight)) RRS - good question. * return; */ - if (net->cwnd <= net->ssthresh) { + if (net->cwnd <= net->ssthresh) { /* We are in slow start */ if (net->flight_size + net->net_ack >= net->cwnd) { if (net->net_ack > (net->mtu * SCTP_BASE_SYSCTL(sctp_L2_abc_variable))) { @@ -2150,7 +2137,6 @@ htcp_cong_avoid(struct sctp_tcb *stcb, struct sctp_nets *net) sctp_log_cwnd(stcb, net, net->net_ack, SCTP_CWND_LOG_FROM_SS); } - } sctp_enforce_cwnd_limit(&stcb->asoc, net); } else { @@ -2167,7 +2153,7 @@ htcp_cong_avoid(struct sctp_tcb *stcb, struct sctp_nets *net) */ /* What is snd_cwnd_cnt?? */ if (((net->partial_bytes_acked/net->mtu * net->cc_mod.htcp_ca.alpha) >> 7)*net->mtu >= net->cwnd) { - /*- + /*- * Does SCTP have a cwnd clamp? * if (net->snd_cwnd < net->snd_cwnd_clamp) - Nope (RRS). */ @@ -2238,7 +2224,6 @@ sctp_htcp_cwnd_update_after_sack(struct sctp_tcb *stcb, /* update cwnd and Early FR */ /******************************/ TAILQ_FOREACH(net, &asoc->nets, sctp_next) { - #ifdef JANA_CMT_FAST_RECOVERY /* * CMT fast recovery code. Need to debug. @@ -2258,7 +2243,7 @@ sctp_htcp_cwnd_update_after_sack(struct sctp_tcb *stcb, continue; } #ifdef JANA_CMT_FAST_RECOVERY - /* CMT fast recovery code + /* CMT fast recovery code */ /* if (sctp_cmt_on_off > 0 && net->fast_retran_loss_recovery && net->will_exit_fast_recovery == 0) { @@ -2410,7 +2395,7 @@ sctp_htcp_cwnd_update_after_ecn_echo(struct sctp_tcb *stcb, const struct sctp_cc_functions sctp_cc_functions[] = { { -#if defined(__Windows__) || (defined(__Userspace_os_Windows) && !defined(__MINGW32__)) +#if defined(_WIN32) && !defined(__MINGW32__) sctp_set_initial_cc_param, sctp_cwnd_update_after_sack, sctp_cwnd_update_exit_pf_common, @@ -2431,7 +2416,7 @@ const struct sctp_cc_functions sctp_cc_functions[] = { #endif }, { -#if defined(__Windows__) || (defined(__Userspace_os_Windows) && !defined(__MINGW32__)) +#if defined(_WIN32) && !defined(__MINGW32__) sctp_set_initial_cc_param, sctp_hs_cwnd_update_after_sack, sctp_cwnd_update_exit_pf_common, @@ -2452,7 +2437,7 @@ const struct sctp_cc_functions sctp_cc_functions[] = { #endif }, { -#if defined(__Windows__) || (defined(__Userspace_os_Windows) && !defined(__MINGW32__)) +#if defined(_WIN32) && !defined(__MINGW32__) sctp_htcp_set_initial_cc_param, sctp_htcp_cwnd_update_after_sack, sctp_cwnd_update_exit_pf_common, @@ -2473,7 +2458,7 @@ const struct sctp_cc_functions sctp_cc_functions[] = { #endif }, { -#if defined(__Windows__) || (defined(__Userspace_os_Windows) && !defined(__MINGW32__)) +#if defined(_WIN32) && !defined(__MINGW32__) sctp_set_rtcc_initial_cc_param, sctp_cwnd_update_rtcc_after_sack, sctp_cwnd_update_exit_pf_common, diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_constants.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_constants.h index 038a340246..5d3d246012 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_constants.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_constants.h @@ -32,18 +32,18 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_constants.h 343089 2019-01-16 11:33:47Z tuexen $"); +__FBSDID("$FreeBSD$"); #endif #ifndef _NETINET_SCTP_CONSTANTS_H_ #define _NETINET_SCTP_CONSTANTS_H_ -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) && defined(__Userspace__) extern void getwintimeofday(struct timeval *tv); -#endif +#endif /* IANA assigned port number for SCTP over UDP encapsulation */ #define SCTP_OVER_UDP_TUNNELING_PORT 9899 @@ -92,13 +92,11 @@ extern void getwintimeofday(struct timeval *tv); /* #define SCTP_AUDITING_ENABLED 1 used for debug/auditing */ #define SCTP_AUDIT_SIZE 256 - #define SCTP_KTRHEAD_NAME "sctp_iterator" #define SCTP_KTHREAD_PAGES 0 #define SCTP_MCORE_NAME "sctp_core_worker" - /* If you support Multi-VRF how big to * make the initial array of VRF's to. */ @@ -268,7 +266,6 @@ extern void getwintimeofday(struct timeval *tv); #define SCTP_LOCK_UNKNOWN 2 - /* number of associations by default for zone allocation */ #define SCTP_MAX_NUM_OF_ASOC 40000 /* how many addresses per assoc remote and local */ @@ -393,7 +390,6 @@ extern void getwintimeofday(struct timeval *tv); #define IS_SCTP_CONTROL(a) (((a)->chunk_type != SCTP_DATA) && ((a)->chunk_type != SCTP_IDATA)) #define IS_SCTP_DATA(a) (((a)->chunk_type == SCTP_DATA) || ((a)->chunk_type == SCTP_IDATA)) - /* SCTP parameter types */ /*************0x0000 series*************/ #define SCTP_HEARTBEAT_INFO 0x0001 @@ -458,7 +454,6 @@ extern void getwintimeofday(struct timeval *tv); /* mask to get sticky */ #define SCTP_STICKY_OPTIONS_MASK 0x0c - /* * SCTP states for internal state machine */ @@ -551,24 +546,22 @@ extern void getwintimeofday(struct timeval *tv); #define SCTP_TIMER_TYPE_ASCONF 10 #define SCTP_TIMER_TYPE_SHUTDOWNGUARD 11 #define SCTP_TIMER_TYPE_AUTOCLOSE 12 -#define SCTP_TIMER_TYPE_EVENTWAKE 13 -#define SCTP_TIMER_TYPE_STRRESET 14 -#define SCTP_TIMER_TYPE_INPKILL 15 -#define SCTP_TIMER_TYPE_ASOCKILL 16 -#define SCTP_TIMER_TYPE_ADDR_WQ 17 -#define SCTP_TIMER_TYPE_PRIM_DELETED 18 +#define SCTP_TIMER_TYPE_STRRESET 13 +#define SCTP_TIMER_TYPE_INPKILL 14 +#define SCTP_TIMER_TYPE_ASOCKILL 15 +#define SCTP_TIMER_TYPE_ADDR_WQ 16 +#define SCTP_TIMER_TYPE_PRIM_DELETED 17 /* add new timers here - and increment LAST */ -#define SCTP_TIMER_TYPE_LAST 19 +#define SCTP_TIMER_TYPE_LAST 18 #define SCTP_IS_TIMER_TYPE_VALID(t) (((t) > SCTP_TIMER_TYPE_NONE) && \ ((t) < SCTP_TIMER_TYPE_LAST)) - -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) /* Number of ticks to run the main timer at in msec */ #define SCTP_MAIN_TIMER_DEFAULT 10 -#endif +#endif /* max number of TSN's dup'd that I will hold */ #define SCTP_MAX_DUP_TSNS 20 @@ -587,22 +580,7 @@ extern void getwintimeofday(struct timeval *tv); * number of clusters as a base. This way high bandwidth environments will * not get impacted by the lower bandwidth sending a bunch of 1 byte chunks */ -#ifdef __Panda__ -#define SCTP_ASOC_MAX_CHUNKS_ON_QUEUE 10240 -#else #define SCTP_ASOC_MAX_CHUNKS_ON_QUEUE 512 -#endif - - -/* The conversion from time to ticks and vice versa is done by rounding - * upwards. This way we can test in the code the time to be positive and - * know that this corresponds to a positive number of ticks. - */ -#define MSEC_TO_TICKS(x) ((hz == 1000) ? x : ((((x) * hz) + 999) / 1000)) -#define TICKS_TO_MSEC(x) ((hz == 1000) ? x : ((((x) * 1000) + (hz - 1)) / hz)) - -#define SEC_TO_TICKS(x) ((x) * hz) -#define TICKS_TO_SEC(x) (((x) + (hz - 1)) / hz) /* * Basically the minimum amount of time before I do a early FR. Making this @@ -632,8 +610,7 @@ extern void getwintimeofday(struct timeval *tv); #define SCTP_RTO_UPPER_BOUND (60000) /* 60 sec in ms */ #define SCTP_RTO_LOWER_BOUND (1000) /* 1 sec is ms */ -#define SCTP_RTO_INITIAL (3000) /* 3 sec in ms */ - +#define SCTP_RTO_INITIAL (1000) /* 1 sec in ms */ #define SCTP_INP_KILL_TIMEOUT 20 /* number of ms to retry kill of inpcb */ #define SCTP_ASOC_KILL_TIMEOUT 10 /* number of ms to retry kill of inpcb */ @@ -645,7 +622,6 @@ extern void getwintimeofday(struct timeval *tv); #define SCTP_DEF_PMTU_RAISE_SEC 600 /* 10 min between raise attempts */ - /* How many streams I request initially by default */ #define SCTP_OSTREAM_INITIAL 10 #define SCTP_ISTREAM_INITIAL 2048 @@ -715,8 +691,6 @@ extern void getwintimeofday(struct timeval *tv); /* amount peer is obligated to have in rwnd or I will abort */ #define SCTP_MIN_RWND 1500 -#define SCTP_DEFAULT_MAXSEGMENT 65535 - #define SCTP_CHUNK_BUFFER_SIZE 512 #define SCTP_PARAM_BUFFER_SIZE 512 @@ -728,7 +702,6 @@ extern void getwintimeofday(struct timeval *tv); #define SCTP_NUMBER_OF_SECRETS 8 /* or 8 * 4 = 32 octets */ #define SCTP_SECRET_SIZE 32 /* number of octets in a 256 bits */ - /* * SCTP upper layer notifications */ @@ -759,6 +732,7 @@ extern void getwintimeofday(struct timeval *tv); #define SCTP_NOTIFY_NO_PEER_AUTH 25 #define SCTP_NOTIFY_SENDER_DRY 26 #define SCTP_NOTIFY_REMOTE_ERROR 27 +#define SCTP_NOTIFY_ASSOC_TIMEDOUT 28 /* This is the value for messages that are NOT completely * copied down where we will start to split the message. @@ -769,7 +743,11 @@ extern void getwintimeofday(struct timeval *tv); #define SCTP_DEFAULT_SPLIT_POINT_MIN 2904 /* Maximum length of diagnostic information in error causes */ +#if defined(__Userspace__) +#define SCTP_DIAG_INFO_LEN 256 +#else #define SCTP_DIAG_INFO_LEN 128 +#endif /* ABORT CODES and other tell-tale location * codes are generated by adding the below @@ -787,9 +765,8 @@ extern void getwintimeofday(struct timeval *tv); #define SCTP_FROM_SCTP_ASCONF 0x80000000 #define SCTP_FROM_SCTP_OUTPUT 0x90000000 #define SCTP_FROM_SCTP_PEELOFF 0xa0000000 -#define SCTP_FROM_SCTP_PANDA 0xb0000000 -#define SCTP_FROM_SCTP_SYSCTL 0xc0000000 -#define SCTP_FROM_SCTP_CC_FUNCTIONS 0xd0000000 +#define SCTP_FROM_SCTP_SYSCTL 0xb0000000 +#define SCTP_FROM_SCTP_CC_FUNCTIONS 0xc0000000 /* Location ID's */ #define SCTP_LOC_1 0x00000001 @@ -827,7 +804,8 @@ extern void getwintimeofday(struct timeval *tv); #define SCTP_LOC_33 0x00000021 #define SCTP_LOC_34 0x00000022 #define SCTP_LOC_35 0x00000023 - +#define SCTP_LOC_36 0x00000024 +#define SCTP_LOC_37 0x00000025 /* Free assoc codes */ #define SCTP_NORMAL_PROC 0 @@ -847,7 +825,6 @@ extern void getwintimeofday(struct timeval *tv); #define SCTP_DONOT_SETSCOPE 0 #define SCTP_DO_SETSCOPE 1 - /* This value determines the default for when * we try to add more on the send queue., if * there is room. This prevents us from cycling @@ -874,7 +851,7 @@ extern void getwintimeofday(struct timeval *tv); #define SCTP_CHUNKQUEUE_SCALE 10 #endif -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) /* clock variance is 1 ms */ #define SCTP_CLOCK_GRANULARITY 1 #else @@ -930,7 +907,6 @@ extern void getwintimeofday(struct timeval *tv); } \ } while (0) - #define SCTP_RETRAN_DONE -1 #define SCTP_RETRAN_EXIT -2 @@ -981,12 +957,11 @@ extern void getwintimeofday(struct timeval *tv); /*- * defines for socket lock states. - * Used by __APPLE__ and SCTP_SO_LOCK_TESTING + * Used by __APPLE__ */ #define SCTP_SO_LOCKED 1 #define SCTP_SO_NOT_LOCKED 0 - /*- * For address locks, do we hold the lock? */ @@ -1012,7 +987,7 @@ extern void getwintimeofday(struct timeval *tv); #define SCTP_SOCKET_OPTION_LIMIT (64 * 1024) #if defined(__Userspace__) -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) #define SCTP_GETTIME_TIMEVAL(x) getwintimeofday(x) #define SCTP_GETPTIME_TIMEVAL(x) getwintimeofday(x) /* this doesn't seem to ever be used.. */ #else @@ -1020,7 +995,6 @@ extern void getwintimeofday(struct timeval *tv); #define SCTP_GETPTIME_TIMEVAL(x) gettimeofday(x, NULL) #endif #endif - #if defined(_KERNEL) #define SCTP_GETTIME_TIMEVAL(x) (getmicrouptime(x)) #define SCTP_GETPTIME_TIMEVAL(x) (microuptime(x)) @@ -1036,11 +1010,11 @@ do { \ } \ } while (0) -#if defined(__FreeBSD__) || defined(__Windows__) || defined(__Userspace__) +#if defined(__FreeBSD__) || defined(_WIN32) || defined(__Userspace__) #define sctp_sowwakeup_locked(inp, so) \ do { \ if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \ - SOCKBUF_UNLOCK(&((so)->so_snd)); \ + SOCKBUF_UNLOCK(&((so)->so_snd)); \ inp->sctp_flags |= SCTP_PCB_FLAGS_WAKEOUTPUT; \ } else { \ sowwakeup_locked(so); \ @@ -1050,7 +1024,7 @@ do { \ #define sctp_sowwakeup_locked(inp, so) \ do { \ if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \ - SOCKBUF_UNLOCK(&((so)->so_snd)); \ + SOCKBUF_UNLOCK(&((so)->so_snd)); \ inp->sctp_flags |= SCTP_PCB_FLAGS_WAKEOUTPUT; \ } else { \ sowwakeup(so); \ @@ -1067,12 +1041,12 @@ do { \ } \ } while (0) -#if defined(__FreeBSD__) || defined(__Windows__) || defined(__Userspace__) +#if defined(__FreeBSD__) || defined(_WIN32) || defined(__Userspace__) #define sctp_sorwakeup_locked(inp, so) \ do { \ if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \ inp->sctp_flags |= SCTP_PCB_FLAGS_WAKEINPUT; \ - SOCKBUF_UNLOCK(&((so)->so_rcv)); \ + SOCKBUF_UNLOCK(&((so)->so_rcv)); \ } else { \ sorwakeup_locked(so); \ } \ @@ -1083,7 +1057,7 @@ do { \ do { \ if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \ inp->sctp_flags |= SCTP_PCB_FLAGS_WAKEINPUT; \ - SOCKBUF_UNLOCK(&((so)->so_rcv)); \ + SOCKBUF_UNLOCK(&((so)->so_rcv)); \ } else { \ sorwakeup(so); \ } \ diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_crc32.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_crc32.c index c08392a7aa..0b5a06e067 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_crc32.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_crc32.c @@ -32,26 +32,22 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_crc32.c 352361 2019-09-15 18:29:45Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_crc32.c 362498 2020-06-22 14:36:14Z tuexen $"); #include "opt_sctp.h" -#if defined(__FreeBSD__) -#include -#endif -#ifdef SCTP -#include -#include -#include -#include -#else #include #include +#include #include +#include #include +#if defined(SCTP) || defined(SCTP_SUPPORT) +#include +#include #endif #else #include @@ -60,7 +56,7 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_crc32.c 352361 2019-09-15 18:29:45Z tu #include #endif -#if !defined(__FreeBSD__) +#if !(defined(__FreeBSD__) && !defined(__Userspace__)) /** * * Routine Description: @@ -799,8 +795,11 @@ sctp_calculate_cksum(struct mbuf *m, uint32_t offset) return (base); } -#if defined(__FreeBSD__) -#ifdef SCTP +#if defined(__FreeBSD__) && !defined(__Userspace__) +#if defined(SCTP) || defined(SCTP_SUPPORT) + +VNET_DEFINE(struct sctp_base_info, system_base_info); + /* * Compute and insert the SCTP checksum in network byte order for a given * mbuf chain m which contains an SCTP packet starting at offset. diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_crc32.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_crc32.h index ac20c10341..5e76ff21bf 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_crc32.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_crc32.h @@ -32,9 +32,9 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_crc32.h 327200 2017-12-26 12:35:02Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_crc32.h 362338 2020-06-18 19:32:34Z markj $"); #endif #ifndef _NETINET_SCTP_CRC32_H_ @@ -42,8 +42,8 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_crc32.h 327200 2017-12-26 12:35:02Z tu #if defined(_KERNEL) uint32_t sctp_calculate_cksum(struct mbuf *, uint32_t); -#if defined(__FreeBSD__) -#ifdef SCTP +#if defined(__FreeBSD__) && !defined(__Userspace__) +#if defined(SCTP) || defined(SCTP_SUPPORT) void sctp_delayed_cksum(struct mbuf *, uint32_t offset); #endif #endif diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_header.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_header.h index 6035d9cbdb..9226a9ef99 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_header.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_header.h @@ -32,24 +32,24 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_header.h 309682 2016-12-07 19:30:59Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_header.h 366114 2020-09-24 12:26:06Z tuexen $"); #endif #ifndef _NETINET_SCTP_HEADER_H_ #define _NETINET_SCTP_HEADER_H_ -#if defined(__Windows__) && !defined(__Userspace_os_Windows) +#if defined(_WIN32) && !defined(__Userspace__) #include #endif -#if !defined(__Userspace_os_Windows) +#if !defined(_WIN32) #include #endif #include #include -#if !defined(__Userspace_os_Windows) +#if !defined(_WIN32) #define SCTP_PACKED __attribute__((packed)) #else #pragma pack (push, 1) @@ -66,7 +66,6 @@ struct sctp_ipv4addr_param { #define SCTP_V6_ADDR_BYTES 16 - struct sctp_ipv6addr_param { struct sctp_paramhdr ph;/* type=SCTP_IPV6_PARAM_TYPE, len=20 */ uint8_t addr[SCTP_V6_ADDR_BYTES]; /* IPV6 address */ @@ -110,14 +109,12 @@ struct sctp_heartbeat_info_param { char address[SCTP_ADDRMAX]; } SCTP_PACKED; - /* draft-ietf-tsvwg-prsctp */ /* PR-SCTP supported parameter */ struct sctp_prsctp_supported_param { struct sctp_paramhdr ph; } SCTP_PACKED; - /* draft-ietf-tsvwg-addip-sctp */ struct sctp_asconf_paramhdr { /* an ASCONF "parameter" */ struct sctp_paramhdr ph;/* a SCTP parameter header */ @@ -129,14 +126,12 @@ struct sctp_asconf_addr_param { /* an ASCONF address parameter */ struct sctp_ipv6addr_param addrp; /* max storage size */ } SCTP_PACKED; - struct sctp_asconf_tag_param { /* an ASCONF NAT-Vtag parameter */ struct sctp_asconf_paramhdr aph; /* asconf "parameter" */ - uint32_t local_vtag; - uint32_t remote_vtag; + uint32_t local_vtag; + uint32_t remote_vtag; } SCTP_PACKED; - struct sctp_asconf_addrv4_param { /* an ASCONF address (v4) parameter */ struct sctp_asconf_paramhdr aph; /* asconf "parameter" */ struct sctp_ipv4addr_param addrp; /* max storage size */ @@ -149,7 +144,6 @@ struct sctp_supported_chunk_types_param { uint8_t chunk_types[]; } SCTP_PACKED; - /* * Structures for DATA chunks */ @@ -260,7 +254,6 @@ struct sctp_init_msg { #define sctp_init_ack_chunk sctp_init_chunk #define sctp_init_ack_msg sctp_init_msg - /* Selective Ack (SACK) */ struct sctp_gap_ack_block { uint16_t start; /* Gap Ack block start */ @@ -297,7 +290,6 @@ struct sctp_nr_sack_chunk { struct sctp_nr_sack nr_sack; } SCTP_PACKED; - /* Heartbeat Request (HEARTBEAT) */ struct sctp_heartbeat { struct sctp_heartbeat_info_param hb_info; @@ -312,7 +304,6 @@ struct sctp_heartbeat_chunk { #define sctp_heartbeat_ack sctp_heartbeat #define sctp_heartbeat_ack_chunk sctp_heartbeat_chunk - /* Abort Asssociation (ABORT) */ struct sctp_abort_chunk { struct sctp_chunkhdr ch; @@ -324,27 +315,23 @@ struct sctp_abort_msg { struct sctp_abort_chunk msg; } SCTP_PACKED; - /* Shutdown Association (SHUTDOWN) */ struct sctp_shutdown_chunk { struct sctp_chunkhdr ch; uint32_t cumulative_tsn_ack; } SCTP_PACKED; - /* Shutdown Acknowledgment (SHUTDOWN ACK) */ struct sctp_shutdown_ack_chunk { struct sctp_chunkhdr ch; } SCTP_PACKED; - /* Operation Error (ERROR) */ struct sctp_error_chunk { struct sctp_chunkhdr ch; /* optional error causes follow */ } SCTP_PACKED; - /* Cookie Echo (COOKIE ECHO) */ struct sctp_cookie_echo_chunk { struct sctp_chunkhdr ch; @@ -436,7 +423,6 @@ struct sctp_chunk_desc { uint32_t tsn_ifany; } SCTP_PACKED; - struct sctp_pktdrop_chunk { struct sctp_chunkhdr ch; uint32_t bottle_bw; @@ -487,10 +473,10 @@ struct sctp_stream_reset_response_tsn { } SCTP_PACKED; struct sctp_stream_reset_add_strm { - struct sctp_paramhdr ph; - uint32_t request_seq; - uint16_t number_of_streams; - uint16_t reserved; + struct sctp_paramhdr ph; + uint32_t request_seq; + uint16_t number_of_streams; + uint16_t reserved; } SCTP_PACKED; #define SCTP_STREAM_RESET_RESULT_NOTHING_TO_DO 0x00000000 /* XXX: unused */ @@ -563,48 +549,46 @@ struct sctp_auth_chunk { #ifndef SCTP_MAX_OVERHEAD #ifdef INET6 #define SCTP_MAX_OVERHEAD (sizeof(struct sctp_data_chunk) + \ - sizeof(struct sctphdr) + \ - sizeof(struct sctp_ecne_chunk) + \ - sizeof(struct sctp_sack_chunk) + \ - sizeof(struct ip6_hdr)) + sizeof(struct sctphdr) + \ + sizeof(struct sctp_ecne_chunk) + \ + sizeof(struct sctp_sack_chunk) + \ + sizeof(struct ip6_hdr)) #define SCTP_MED_OVERHEAD (sizeof(struct sctp_data_chunk) + \ - sizeof(struct sctphdr) + \ - sizeof(struct ip6_hdr)) - + sizeof(struct sctphdr) + \ + sizeof(struct ip6_hdr)) #define SCTP_MIN_OVERHEAD (sizeof(struct ip6_hdr) + \ - sizeof(struct sctphdr)) + sizeof(struct sctphdr)) #else #define SCTP_MAX_OVERHEAD (sizeof(struct sctp_data_chunk) + \ - sizeof(struct sctphdr) + \ - sizeof(struct sctp_ecne_chunk) + \ - sizeof(struct sctp_sack_chunk) + \ - sizeof(struct ip)) + sizeof(struct sctphdr) + \ + sizeof(struct sctp_ecne_chunk) + \ + sizeof(struct sctp_sack_chunk) + \ + sizeof(struct ip)) #define SCTP_MED_OVERHEAD (sizeof(struct sctp_data_chunk) + \ - sizeof(struct sctphdr) + \ - sizeof(struct ip)) - + sizeof(struct sctphdr) + \ + sizeof(struct ip)) #define SCTP_MIN_OVERHEAD (sizeof(struct ip) + \ - sizeof(struct sctphdr)) + sizeof(struct sctphdr)) #endif /* INET6 */ #endif /* !SCTP_MAX_OVERHEAD */ #define SCTP_MED_V4_OVERHEAD (sizeof(struct sctp_data_chunk) + \ - sizeof(struct sctphdr) + \ - sizeof(struct ip)) + sizeof(struct sctphdr) + \ + sizeof(struct ip)) #define SCTP_MIN_V4_OVERHEAD (sizeof(struct ip) + \ - sizeof(struct sctphdr)) + sizeof(struct sctphdr)) -#if defined(__Windows__) +#if defined(_WIN32) && !defined(__Userspace__) #include #endif -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) && defined(__Userspace__) #pragma pack(pop) #endif #undef SCTP_PACKED diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_indata.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_indata.c index 8b332355a5..64e4d0b61e 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_indata.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_indata.c @@ -32,13 +32,13 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_indata.c 353145 2019-10-06 08:47:10Z tuexen $"); +__FBSDID("$FreeBSD$"); #endif #include -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include #endif #include @@ -55,7 +55,7 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_indata.c 353145 2019-10-06 08:47:10Z t #include #include #include -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include #endif /* @@ -72,8 +72,7 @@ sctp_add_chk_to_control(struct sctp_queued_to_read *control, struct sctp_stream_in *strm, struct sctp_tcb *stcb, struct sctp_association *asoc, - struct sctp_tmit_chunk *chk, int lock_held); - + struct sctp_tmit_chunk *chk, int hold_rlock); void sctp_set_rwnd(struct sctp_tcb *stcb, struct sctp_association *asoc) @@ -134,8 +133,6 @@ sctp_calc_rwnd(struct sctp_tcb *stcb, struct sctp_association *asoc) return (calc); } - - /* * Build out our readq entry based on the incoming packet. */ @@ -169,6 +166,9 @@ sctp_build_readq_entry(struct sctp_tcb *stcb, read_queue_e->data = dm; read_queue_e->stcb = stcb; read_queue_e->port_from = stcb->rport; + if (stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) { + read_queue_e->do_not_ref_stcb = 1; + } failed_build: return (read_queue_e); } @@ -180,7 +180,7 @@ sctp_build_ctl_nchunk(struct sctp_inpcb *inp, struct sctp_sndrcvinfo *sinfo) struct sctp_sndrcvinfo *outinfo; struct sctp_rcvinfo *rcvinfo; struct sctp_nxtinfo *nxtinfo; -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) WSACMSGHDR *cmh; #else struct cmsghdr *cmh; @@ -229,7 +229,7 @@ sctp_build_ctl_nchunk(struct sctp_inpcb *inp, struct sctp_sndrcvinfo *sinfo) SCTP_BUF_LEN(ret) = 0; /* We need a CMSG header followed by the struct */ -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) cmh = mtod(ret, WSACMSGHDR *); #else cmh = mtod(ret, struct cmsghdr *); @@ -252,7 +252,7 @@ sctp_build_ctl_nchunk(struct sctp_inpcb *inp, struct sctp_sndrcvinfo *sinfo) rcvinfo->rcv_cumtsn = sinfo->sinfo_cumtsn; rcvinfo->rcv_context = sinfo->sinfo_context; rcvinfo->rcv_assoc_id = sinfo->sinfo_assoc_id; -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) cmh = (WSACMSGHDR *)((caddr_t)cmh + CMSG_SPACE(sizeof(struct sctp_rcvinfo))); #else cmh = (struct cmsghdr *)((caddr_t)cmh + CMSG_SPACE(sizeof(struct sctp_rcvinfo))); @@ -278,7 +278,7 @@ sctp_build_ctl_nchunk(struct sctp_inpcb *inp, struct sctp_sndrcvinfo *sinfo) nxtinfo->nxt_ppid = seinfo->serinfo_next_ppid; nxtinfo->nxt_length = seinfo->serinfo_next_length; nxtinfo->nxt_assoc_id = seinfo->serinfo_next_aid; -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) cmh = (WSACMSGHDR *)((caddr_t)cmh + CMSG_SPACE(sizeof(struct sctp_nxtinfo))); #else cmh = (struct cmsghdr *)((caddr_t)cmh + CMSG_SPACE(sizeof(struct sctp_nxtinfo))); @@ -303,19 +303,18 @@ sctp_build_ctl_nchunk(struct sctp_inpcb *inp, struct sctp_sndrcvinfo *sinfo) return (ret); } - static void sctp_mark_non_revokable(struct sctp_association *asoc, uint32_t tsn) { - uint32_t gap, i, cumackp1; - int fnd = 0; - int in_r=0, in_nr=0; + uint32_t gap, i; + int in_r, in_nr; + if (SCTP_BASE_SYSCTL(sctp_do_drain) == 0) { return; } - cumackp1 = asoc->cumulative_tsn + 1; - if (SCTP_TSN_GT(cumackp1, tsn)) { - /* this tsn is behind the cum ack and thus we don't + if (SCTP_TSN_GE(asoc->cumulative_tsn, tsn)) { + /* + * This tsn is behind the cum ack and thus we don't * need to worry about it being moved from one to the other. */ return; @@ -323,33 +322,27 @@ sctp_mark_non_revokable(struct sctp_association *asoc, uint32_t tsn) SCTP_CALC_TSN_TO_GAP(gap, tsn, asoc->mapping_array_base_tsn); in_r = SCTP_IS_TSN_PRESENT(asoc->mapping_array, gap); in_nr = SCTP_IS_TSN_PRESENT(asoc->nr_mapping_array, gap); - if ((in_r == 0) && (in_nr == 0)) { -#ifdef INVARIANTS - panic("Things are really messed up now"); -#else - SCTP_PRINTF("gap:%x tsn:%x\n", gap, tsn); - sctp_print_mapping_array(asoc); -#endif - } - if (in_nr == 0) + KASSERT(in_r || in_nr, ("%s: Things are really messed up now", __func__)); + if (!in_nr) { SCTP_SET_TSN_PRESENT(asoc->nr_mapping_array, gap); - if (in_r) - SCTP_UNSET_TSN_PRESENT(asoc->mapping_array, gap); - if (SCTP_TSN_GT(tsn, asoc->highest_tsn_inside_nr_map)) { - asoc->highest_tsn_inside_nr_map = tsn; - } - if (tsn == asoc->highest_tsn_inside_map) { - /* We must back down to see what the new highest is */ - for (i = tsn - 1; SCTP_TSN_GE(i, asoc->mapping_array_base_tsn); i--) { - SCTP_CALC_TSN_TO_GAP(gap, i, asoc->mapping_array_base_tsn); - if (SCTP_IS_TSN_PRESENT(asoc->mapping_array, gap)) { - asoc->highest_tsn_inside_map = i; - fnd = 1; - break; - } + if (SCTP_TSN_GT(tsn, asoc->highest_tsn_inside_nr_map)) { + asoc->highest_tsn_inside_nr_map = tsn; } - if (!fnd) { - asoc->highest_tsn_inside_map = asoc->mapping_array_base_tsn - 1; + } + if (in_r) { + SCTP_UNSET_TSN_PRESENT(asoc->mapping_array, gap); + if (tsn == asoc->highest_tsn_inside_map) { + /* We must back down to see what the new highest is. */ + for (i = tsn - 1; SCTP_TSN_GE(i, asoc->mapping_array_base_tsn); i--) { + SCTP_CALC_TSN_TO_GAP(gap, i, asoc->mapping_array_base_tsn); + if (SCTP_IS_TSN_PRESENT(asoc->mapping_array, gap)) { + asoc->highest_tsn_inside_map = i; + break; + } + } + if (!SCTP_TSN_GE(i, asoc->mapping_array_base_tsn)) { + asoc->highest_tsn_inside_map = asoc->mapping_array_base_tsn - 1; + } } } } @@ -404,7 +397,7 @@ sctp_place_control_in_stream(struct sctp_stream_in *strm, if (unordered) { control->on_strm_q = SCTP_ON_UNORDERED; } else { - control->on_strm_q = SCTP_ON_ORDERED ; + control->on_strm_q = SCTP_ON_ORDERED; } break; } else if (SCTP_MID_EQ(asoc->idata_supported, at->mid, control->mid)) { @@ -425,9 +418,9 @@ sctp_place_control_in_stream(struct sctp_stream_in *strm, } TAILQ_INSERT_AFTER(q, at, control, next_instrm); if (unordered) { - control->on_strm_q = SCTP_ON_UNORDERED ; + control->on_strm_q = SCTP_ON_UNORDERED; } else { - control->on_strm_q = SCTP_ON_ORDERED ; + control->on_strm_q = SCTP_ON_ORDERED; } break; } @@ -447,36 +440,36 @@ sctp_abort_in_reasm(struct sctp_tcb *stcb, struct mbuf *oper; if (stcb->asoc.idata_supported) { - snprintf(msg, sizeof(msg), - "Reass %x,CF:%x,TSN=%8.8x,SID=%4.4x,FSN=%8.8x,MID:%8.8x", - opspot, - control->fsn_included, - chk->rec.data.tsn, - chk->rec.data.sid, - chk->rec.data.fsn, chk->rec.data.mid); + SCTP_SNPRINTF(msg, sizeof(msg), + "Reass %x,CF:%x,TSN=%8.8x,SID=%4.4x,FSN=%8.8x,MID:%8.8x", + opspot, + control->fsn_included, + chk->rec.data.tsn, + chk->rec.data.sid, + chk->rec.data.fsn, chk->rec.data.mid); } else { - snprintf(msg, sizeof(msg), - "Reass %x,CI:%x,TSN=%8.8x,SID=%4.4x,FSN=%4.4x,SSN:%4.4x", - opspot, - control->fsn_included, - chk->rec.data.tsn, - chk->rec.data.sid, - chk->rec.data.fsn, - (uint16_t)chk->rec.data.mid); + SCTP_SNPRINTF(msg, sizeof(msg), + "Reass %x,CI:%x,TSN=%8.8x,SID=%4.4x,FSN=%4.4x,SSN:%4.4x", + opspot, + control->fsn_included, + chk->rec.data.tsn, + chk->rec.data.sid, + chk->rec.data.fsn, + (uint16_t)chk->rec.data.mid); } oper = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg); sctp_m_freem(chk->data); chk->data = NULL; sctp_free_a_chunk(stcb, chk, SCTP_SO_NOT_LOCKED); stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_1; - sctp_abort_an_association(stcb->sctp_ep, stcb, oper, SCTP_SO_NOT_LOCKED); + sctp_abort_an_association(stcb->sctp_ep, stcb, oper, false, SCTP_SO_NOT_LOCKED); *abort_flag = 1; } static void sctp_clean_up_control(struct sctp_tcb *stcb, struct sctp_queued_to_read *control) { - /* + /* * The control could not be placed and must be cleaned. */ struct sctp_tmit_chunk *chk, *nchk; @@ -545,29 +538,28 @@ sctp_queue_data_to_stream(struct sctp_tcb *stcb, */ TAILQ_INSERT_HEAD(&strm->inqueue, control, next_instrm); if (asoc->idata_supported) { - snprintf(msg, sizeof(msg), "Delivered MID=%8.8x, got TSN=%8.8x, SID=%4.4x, MID=%8.8x", - strm->last_mid_delivered, control->sinfo_tsn, - control->sinfo_stream, control->mid); + SCTP_SNPRINTF(msg, sizeof(msg), "Delivered MID=%8.8x, got TSN=%8.8x, SID=%4.4x, MID=%8.8x", + strm->last_mid_delivered, control->sinfo_tsn, + control->sinfo_stream, control->mid); } else { - snprintf(msg, sizeof(msg), "Delivered SSN=%4.4x, got TSN=%8.8x, SID=%4.4x, SSN=%4.4x", - (uint16_t)strm->last_mid_delivered, - control->sinfo_tsn, - control->sinfo_stream, - (uint16_t)control->mid); + SCTP_SNPRINTF(msg, sizeof(msg), "Delivered SSN=%4.4x, got TSN=%8.8x, SID=%4.4x, SSN=%4.4x", + (uint16_t)strm->last_mid_delivered, + control->sinfo_tsn, + control->sinfo_stream, + (uint16_t)control->mid); } op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg); stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_2; - sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, SCTP_SO_NOT_LOCKED); + sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, false, SCTP_SO_NOT_LOCKED); *abort_flag = 1; return; - } queue_needed = 1; asoc->size_on_all_streams += control->length; sctp_ucount_incr(asoc->cnt_on_all_streams); nxt_todel = strm->last_mid_delivered + 1; if (SCTP_MID_EQ(asoc->idata_supported, nxt_todel, control->mid)) { -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) struct socket *so; so = SCTP_INP_SO(stcb->sctp_ep); @@ -650,7 +642,7 @@ sctp_queue_data_to_stream(struct sctp_tcb *stcb, } break; } -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_UNLOCK(so, 1); #endif } @@ -660,19 +652,17 @@ sctp_queue_data_to_stream(struct sctp_tcb *stcb, * to put it on the queue. */ if (sctp_place_control_in_stream(strm, asoc, control)) { - snprintf(msg, sizeof(msg), - "Queue to str MID: %u duplicate", - control->mid); + SCTP_SNPRINTF(msg, sizeof(msg), + "Queue to str MID: %u duplicate", control->mid); sctp_clean_up_control(stcb, control); op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg); stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_3; - sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, SCTP_SO_NOT_LOCKED); + sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, false, SCTP_SO_NOT_LOCKED); *abort_flag = 1; } } } - static void sctp_setup_tail_pointer(struct sctp_queued_to_read *control) { @@ -770,7 +760,7 @@ sctp_add_to_tail_pointer(struct sctp_queued_to_read *control, struct mbuf *m, ui } } -static void +static void sctp_build_readq_entry_from_ctl(struct sctp_queued_to_read *nc, struct sctp_queued_to_read *control) { memset(nc, 0, sizeof(struct sctp_queued_to_read)); @@ -790,15 +780,16 @@ sctp_build_readq_entry_from_ctl(struct sctp_queued_to_read *nc, struct sctp_queu atomic_add_int(&nc->whoFrom->ref_count, 1); nc->stcb = control->stcb; nc->port_from = control->port_from; + nc->do_not_ref_stcb = control->do_not_ref_stcb; } -static void +static void sctp_reset_a_control(struct sctp_queued_to_read *control, struct sctp_inpcb *inp, uint32_t tsn) { control->fsn_included = tsn; if (control->on_read_q) { - /* + /* * We have to purge it from there, * hopefully this will work :-) */ @@ -847,14 +838,14 @@ restart: } memset(nc, 0, sizeof(struct sctp_queued_to_read)); TAILQ_REMOVE(&control->reasm, chk, sctp_next); - sctp_add_chk_to_control(control, strm, stcb, asoc, chk, SCTP_READ_LOCK_NOT_HELD); + sctp_add_chk_to_control(control, strm, stcb, asoc, chk, inp_read_lock_held); fsn++; cnt_added++; chk = NULL; if (control->end_added) { /* We are done */ if (!TAILQ_EMPTY(&control->reasm)) { - /* + /* * Ok we have to move anything left on * the control queue to a new control. */ @@ -936,7 +927,7 @@ restart: } if (cnt_added && strm->pd_api_started) { #if defined(__Userspace__) - sctp_invoke_recv_callback(stcb->sctp_ep, stcb, control, SCTP_READ_LOCK_NOT_HELD); + sctp_invoke_recv_callback(stcb->sctp_ep, stcb, control, inp_read_lock_held); #endif sctp_wakeup_the_read_socket(stcb->sctp_ep, stcb, SCTP_SO_NOT_LOCKED); } @@ -973,7 +964,7 @@ sctp_inject_old_unordered_data(struct sctp_tcb *stcb, chk->rec.data.fsn); at = TAILQ_FIRST(&control->reasm); if (at && SCTP_TSN_GT(chk->rec.data.fsn, at->rec.data.fsn)) { - /* + /* * The first chunk in the reassembly is * a smaller TSN than this one, even though * this has a first, it must be from a subsequent @@ -997,7 +988,7 @@ sctp_inject_old_unordered_data(struct sctp_tcb *stcb, } if ((chk->rec.data.fsn == control->fsn_included) || (control->pdapi_started)) { - /* + /* * Ok this should not happen, if it does * we started the pd-api on the higher TSN (since * the equals part is a TSN failure it must be that). @@ -1066,7 +1057,7 @@ place_chunk: TAILQ_INSERT_BEFORE(at, chk, sctp_next); break; } else if (at->rec.data.fsn == chk->rec.data.fsn) { - /* + /* * They sent a duplicate fsn number. This * really should not happen since the FSN is * a TSN and it should have been dropped earlier. @@ -1076,7 +1067,6 @@ place_chunk: SCTP_FROM_SCTP_INDATA + SCTP_LOC_5); return; } - } if (inserted == 0) { /* Its at the end */ @@ -1131,13 +1121,23 @@ sctp_deliver_reasm_check(struct sctp_tcb *stcb, struct sctp_association *asoc, /* We just put the last bit on */ if (control->on_strm_q) { #ifdef INVARIANTS - if (control->on_strm_q != SCTP_ON_UNORDERED ) { + if (control->on_strm_q != SCTP_ON_UNORDERED) { panic("Huh control: %p on_q: %d -- not unordered?", control, control->on_strm_q); } #endif SCTP_STAT_INCR_COUNTER64(sctps_reasmusrmsgs); TAILQ_REMOVE(&strm->uno_inqueue, control, next_instrm); + if (asoc->size_on_all_streams >= control->length) { + asoc->size_on_all_streams -= control->length; + } else { +#ifdef INVARIANTS + panic("size_on_all_streams = %u smaller than control length %u", asoc->size_on_all_streams, control->length); +#else + asoc->size_on_all_streams = 0; +#endif + } + sctp_ucount_decr(asoc->cnt_on_all_streams); control->on_strm_q = 0; } if (control->on_read_q == 0) { @@ -1185,7 +1185,7 @@ done_un: if (control->end_added) { if (control->on_strm_q) { #ifdef INVARIANTS - if (control->on_strm_q != SCTP_ON_ORDERED ) { + if (control->on_strm_q != SCTP_ON_ORDERED) { panic("Huh control: %p on_q: %d -- not ordered?", control, control->on_strm_q); } @@ -1238,7 +1238,7 @@ deliver_more: /* We are done with it afterwards */ if (control->on_strm_q) { #ifdef INVARIANTS - if (control->on_strm_q != SCTP_ON_ORDERED ) { + if (control->on_strm_q != SCTP_ON_ORDERED) { panic("Huh control: %p on_q: %d -- not ordered?", control, control->on_strm_q); } @@ -1300,7 +1300,6 @@ out: return (ret); } - uint32_t sctp_add_chk_to_control(struct sctp_queued_to_read *control, struct sctp_stream_in *strm, @@ -1406,7 +1405,7 @@ sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struct sctp_association *asoc, } /* Must be added to the stream-in queue */ if (created_control) { - if (unordered == 0) { + if ((unordered == 0) || (asoc->idata_supported)) { sctp_ucount_incr(asoc->cnt_on_all_streams); } if (sctp_place_control_in_stream(strm, asoc, control)) { @@ -1497,7 +1496,7 @@ sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struct sctp_association *asoc, } } if (asoc->idata_supported || control->first_frag_seen) { - /* + /* * For IDATA we always check since we know that * the first fragment is 0. For old DATA we have * to receive the first before we know the first FSN @@ -1523,7 +1522,7 @@ sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struct sctp_association *asoc, return; } if (asoc->idata_supported || control->first_frag_seen) { - /* + /* * For IDATA we always check since we know that * the first fragment is 0. For old DATA we have * to receive the first before we know the first FSN @@ -1555,7 +1554,7 @@ sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struct sctp_association *asoc, } /* * If we reach here, we need to place the - * new chunk in the reassembly for this + * new chunk in the reassembly for this * control. */ SCTPDBG(SCTP_DEBUG_XXX, @@ -1563,6 +1562,15 @@ sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struct sctp_association *asoc, chk->rec.data.fsn); TAILQ_FOREACH(at, &control->reasm, sctp_next) { if (SCTP_TSN_GT(at->rec.data.fsn, chk->rec.data.fsn)) { + if (chk->rec.data.rcv_flags & SCTP_DATA_LAST_FRAG) { + /* Last not at the end? huh? */ + SCTPDBG(SCTP_DEBUG_XXX, + "Last fragment not last in list: -- abort\n"); + sctp_abort_in_reasm(stcb, control, + chk, abort_flag, + SCTP_FROM_SCTP_INDATA + SCTP_LOC_14); + return; + } /* * This one in queue is bigger than the new one, insert * the new one before at. @@ -1589,7 +1597,7 @@ sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struct sctp_association *asoc, at->rec.data.fsn); sctp_abort_in_reasm(stcb, control, chk, abort_flag, - SCTP_FROM_SCTP_INDATA + SCTP_LOC_14); + SCTP_FROM_SCTP_INDATA + SCTP_LOC_15); return; } } @@ -1694,6 +1702,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, int *break_flag, int last_chunk, uint8_t chk_type) { struct sctp_tmit_chunk *chk = NULL; /* make gcc happy */ + struct sctp_stream_in *strm; uint32_t tsn, fsn, gap, mid; struct mbuf *dmbuf; int the_len; @@ -1745,8 +1754,8 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, * empty data chunk. */ op_err = sctp_generate_no_user_data_cause(tsn); - stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_14; - sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, SCTP_SO_NOT_LOCKED); + stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_16; + sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, false, SCTP_SO_NOT_LOCKED); *abort_flag = 1; return (0); } @@ -1812,7 +1821,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, * receiver. Send peer an ABORT! */ op_err = sctp_generate_cause(SCTP_CAUSE_OUT_OF_RESC, ""); - sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, SCTP_SO_NOT_LOCKED); + sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, false, SCTP_SO_NOT_LOCKED); *abort_flag = 1; return (0); } @@ -1863,14 +1872,13 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, if ((chk_type == SCTP_IDATA) && ((chk_flags & SCTP_DATA_FIRST_FRAG) == 0) && (fsn == 0)) { - /* - * The first *must* be fsn 0, and other + /* + * The first *must* be fsn 0, and other * (middle/end) pieces can *not* be fsn 0. * XXX: This can happen in case of a wrap around. * Ignore is for now. */ - snprintf(msg, sizeof(msg), "FSN zero for MID=%8.8x, but flags=%2.2x", - mid, chk_flags); + SCTP_SNPRINTF(msg, sizeof(msg), "FSN zero for MID=%8.8x, but flags=%2.2x", mid, chk_flags); goto err_out; } control = sctp_find_reasm_entry(&asoc->strmin[sid], mid, ordered, asoc->idata_supported); @@ -1881,24 +1889,26 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, if (control != NULL) { /* We found something, does it belong? */ if (ordered && (mid != control->mid)) { - snprintf(msg, sizeof(msg), "Reassembly problem (MID=%8.8x)", mid); + SCTP_SNPRINTF(msg, sizeof(msg), "Reassembly problem (MID=%8.8x)", mid); err_out: op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg); - stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_15; - sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, SCTP_SO_NOT_LOCKED); + stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_17; + sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, false, SCTP_SO_NOT_LOCKED); *abort_flag = 1; return (0); } if (ordered && ((control->sinfo_flags >> 8) & SCTP_DATA_UNORDERED)) { /* We can't have a switched order with an unordered chunk */ - snprintf(msg, sizeof(msg), "All fragments of a user message must be ordered or unordered (TSN=%8.8x)", - tsn); + SCTP_SNPRINTF(msg, sizeof(msg), + "All fragments of a user message must be ordered or unordered (TSN=%8.8x)", + tsn); goto err_out; } if (!ordered && (((control->sinfo_flags >> 8) & SCTP_DATA_UNORDERED) == 0)) { /* We can't have a switched unordered with a ordered chunk */ - snprintf(msg, sizeof(msg), "All fragments of a user message must be ordered or unordered (TSN=%8.8x)", - tsn); + SCTP_SNPRINTF(msg, sizeof(msg), + "All fragments of a user message must be ordered or unordered (TSN=%8.8x)", + tsn); goto err_out; } } @@ -1912,12 +1922,14 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, if (ordered || asoc->idata_supported) { SCTPDBG(SCTP_DEBUG_XXX, "chunk_flags: 0x%x dup detected on MID: %u\n", chk_flags, mid); - snprintf(msg, sizeof(msg), "Duplicate MID=%8.8x detected.", mid); + SCTP_SNPRINTF(msg, sizeof(msg), "Duplicate MID=%8.8x detected.", mid); goto err_out; } else { if ((tsn == control->fsn_included + 1) && (control->end_added == 0)) { - snprintf(msg, sizeof(msg), "Illegal message sequence, missing end for MID: %8.8x", control->fsn_included); + SCTP_SNPRINTF(msg, sizeof(msg), + "Illegal message sequence, missing end for MID: %8.8x", + control->fsn_included); goto err_out; } else { control = NULL; @@ -1936,7 +1948,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, */ if (stcb->sctp_socket->so_rcv.sb_cc) { /* some to read, wake-up */ -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) struct socket *so; so = SCTP_INP_SO(stcb->sctp_ep); @@ -1952,7 +1964,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, } #endif sctp_sorwakeup(stcb->sctp_ep, stcb->sctp_socket); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_UNLOCK(so, 1); #endif } @@ -2014,21 +2026,21 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, mid, asoc->strmin[sid].last_mid_delivered); if (asoc->idata_supported) { - snprintf(msg, sizeof(msg), "Delivered MID=%8.8x, got TSN=%8.8x, SID=%4.4x, MID=%8.8x", - asoc->strmin[sid].last_mid_delivered, - tsn, - sid, - mid); + SCTP_SNPRINTF(msg, sizeof(msg), "Delivered MID=%8.8x, got TSN=%8.8x, SID=%4.4x, MID=%8.8x", + asoc->strmin[sid].last_mid_delivered, + tsn, + sid, + mid); } else { - snprintf(msg, sizeof(msg), "Delivered SSN=%4.4x, got TSN=%8.8x, SID=%4.4x, SSN=%4.4x", - (uint16_t)asoc->strmin[sid].last_mid_delivered, - tsn, - sid, - (uint16_t)mid); + SCTP_SNPRINTF(msg, sizeof(msg), "Delivered SSN=%4.4x, got TSN=%8.8x, SID=%4.4x, SSN=%4.4x", + (uint16_t)asoc->strmin[sid].last_mid_delivered, + tsn, + sid, + (uint16_t)mid); } op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg); - stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_16; - sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, SCTP_SO_NOT_LOCKED); + stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_18; + sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, false, SCTP_SO_NOT_LOCKED); *abort_flag = 1; return (0); } @@ -2224,7 +2236,6 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, unsigned char inserted = 0; TAILQ_FOREACH_SAFE(lcontrol, &asoc->pending_reply_queue, next, nlcontrol) { if (SCTP_TSN_GT(control->sinfo_tsn, lcontrol->sinfo_tsn)) { - continue; } else { /* found it */ @@ -2329,12 +2340,13 @@ finish_express_del: /* All can be removed */ TAILQ_FOREACH_SAFE(control, &asoc->pending_reply_queue, next, ncontrol) { TAILQ_REMOVE(&asoc->pending_reply_queue, control, next); + strm = &asoc->strmin[control->sinfo_stream]; sctp_queue_data_to_stream(stcb, asoc, control, abort_flag, &need_reasm_check); if (*abort_flag) { return (0); } if (need_reasm_check) { - (void)sctp_deliver_reasm_check(stcb, asoc, &asoc->strmin[control->sinfo_stream], SCTP_READ_LOCK_NOT_HELD); + (void)sctp_deliver_reasm_check(stcb, asoc, strm, SCTP_READ_LOCK_NOT_HELD); need_reasm_check = 0; } } @@ -2349,12 +2361,13 @@ finish_express_del: * control->sinfo_tsn > liste->tsn */ TAILQ_REMOVE(&asoc->pending_reply_queue, control, next); + strm = &asoc->strmin[control->sinfo_stream]; sctp_queue_data_to_stream(stcb, asoc, control, abort_flag, &need_reasm_check); if (*abort_flag) { return (0); } if (need_reasm_check) { - (void)sctp_deliver_reasm_check(stcb, asoc, &asoc->strmin[control->sinfo_stream], SCTP_READ_LOCK_NOT_HELD); + (void)sctp_deliver_reasm_check(stcb, asoc, strm, SCTP_READ_LOCK_NOT_HELD); need_reasm_check = 0; } } @@ -2398,7 +2411,6 @@ static const int8_t sctp_map_lookup_tab[256] = { 0, 1, 0, 2, 0, 1, 0, 8 }; - void sctp_slide_mapping_arrays(struct sctp_tcb *stcb) { @@ -2534,7 +2546,6 @@ sctp_slide_mapping_arrays(struct sctp_tcb *stcb) * we will be able to slide it forward. Really I * don't think this should happen :-0 */ - if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MAP_LOGGING_ENABLE) { sctp_log_map((uint32_t) distance, (uint32_t) slide_from, (uint32_t) asoc->mapping_array_size, @@ -2546,7 +2557,6 @@ sctp_slide_mapping_arrays(struct sctp_tcb *stcb) for (ii = 0; ii < distance; ii++) { asoc->mapping_array[ii] = asoc->mapping_array[slide_from + ii]; asoc->nr_mapping_array[ii] = asoc->nr_mapping_array[slide_from + ii]; - } for (ii = distance; ii < asoc->mapping_array_size; ii++) { asoc->mapping_array[ii] = 0; @@ -2598,7 +2608,7 @@ sctp_sack_check(struct sctp_tcb *stcb, int was_a_gap) if (SCTP_OS_TIMER_PENDING(&stcb->asoc.dack_timer.timer)) { sctp_timer_stop(SCTP_TIMER_TYPE_RECV, stcb->sctp_ep, stcb, NULL, - SCTP_FROM_SCTP_INDATA + SCTP_LOC_17); + SCTP_FROM_SCTP_INDATA + SCTP_LOC_19); } sctp_send_shutdown(stcb, ((stcb->asoc.alternate) ? stcb->asoc.alternate : stcb->asoc.primary_destination)); @@ -2618,20 +2628,16 @@ sctp_sack_check(struct sctp_tcb *stcb, int was_a_gap) (stcb->asoc.numduptsns) || /* we have dup's */ (is_a_gap) || /* is still a gap */ (stcb->asoc.delayed_ack == 0) || /* Delayed sack disabled */ - (stcb->asoc.data_pkts_seen >= stcb->asoc.sack_freq) /* hit limit of pkts */ - ) { - + (stcb->asoc.data_pkts_seen >= stcb->asoc.sack_freq)) { /* hit limit of pkts */ if ((stcb->asoc.sctp_cmt_on_off > 0) && (SCTP_BASE_SYSCTL(sctp_cmt_use_dac)) && (stcb->asoc.send_sack == 0) && (stcb->asoc.numduptsns == 0) && (stcb->asoc.delayed_ack) && (!SCTP_OS_TIMER_PENDING(&stcb->asoc.dack_timer.timer))) { - /* * CMT DAC algorithm: With CMT, * delay acks even in the face of - * reordering. Therefore, if acks * that do not have to be sent * because of the above reasons, @@ -2649,7 +2655,8 @@ sctp_sack_check(struct sctp_tcb *stcb, int was_a_gap) * first packet OR there are gaps or * duplicates. */ - (void)SCTP_OS_TIMER_STOP(&stcb->asoc.dack_timer.timer); + sctp_timer_stop(SCTP_TIMER_TYPE_RECV, stcb->sctp_ep, stcb, NULL, + SCTP_FROM_SCTP_INDATA + SCTP_LOC_20); sctp_send_sack(stcb, SCTP_SO_NOT_LOCKED); } } else { @@ -2695,14 +2702,12 @@ sctp_process_data(struct mbuf **mm, int iphlen, int *offset, int length, */ asoc->last_data_chunk_from = net; -#ifndef __Panda__ /*- * Now before we proceed we must figure out if this is a wasted * cluster... i.e. it is a small packet sent in and yet the driver * underneath allocated a full cluster for it. If so we must copy it * to a smaller mbuf and free up the cluster mbuf. This will help - * with cluster starvation. Note for __Panda__ we don't do this - * since it has clusters all the way down to 64 bytes. + * with cluster starvation. */ if (SCTP_BUF_LEN(m) < (long)MLEN && SCTP_BUF_NEXT(m) == NULL) { /* we only handle mbufs that are singletons.. not chains */ @@ -2724,7 +2729,6 @@ sctp_process_data(struct mbuf **mm, int iphlen, int *offset, int length, m = *mm; } } -#endif /* get pointer to the first chunk header */ ch = (struct sctp_chunkhdr *)sctp_m_getptr(m, *offset, sizeof(struct sctp_chunkhdr), @@ -2751,10 +2755,10 @@ sctp_process_data(struct mbuf **mm, int iphlen, int *offset, int length, struct mbuf *op_err; char msg[SCTP_DIAG_INFO_LEN]; - snprintf(msg, sizeof(msg), "%s", "I-DATA chunk received when DATA was negotiated"); + SCTP_SNPRINTF(msg, sizeof(msg), "%s", "DATA chunk received when I-DATA was negotiated"); op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg); - stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_18; - sctp_abort_an_association(inp, stcb, op_err, SCTP_SO_NOT_LOCKED); + stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_21; + sctp_abort_an_association(inp, stcb, op_err, false, SCTP_SO_NOT_LOCKED); return (2); } if ((asoc->idata_supported == 0) && @@ -2762,10 +2766,10 @@ sctp_process_data(struct mbuf **mm, int iphlen, int *offset, int length, struct mbuf *op_err; char msg[SCTP_DIAG_INFO_LEN]; - snprintf(msg, sizeof(msg), "%s", "DATA chunk received when I-DATA was negotiated"); + SCTP_SNPRINTF(msg, sizeof(msg), "%s", "I-DATA chunk received when DATA was negotiated"); op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg); - stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_19; - sctp_abort_an_association(inp, stcb, op_err, SCTP_SO_NOT_LOCKED); + stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_22; + sctp_abort_an_association(inp, stcb, op_err, false, SCTP_SO_NOT_LOCKED); return (2); } if ((ch->chunk_type == SCTP_DATA) || @@ -2785,12 +2789,12 @@ sctp_process_data(struct mbuf **mm, int iphlen, int *offset, int length, struct mbuf *op_err; char msg[SCTP_DIAG_INFO_LEN]; - snprintf(msg, sizeof(msg), "%s chunk of length %u", - ch->chunk_type == SCTP_DATA ? "DATA" : "I-DATA", - chk_length); + SCTP_SNPRINTF(msg, sizeof(msg), "%s chunk of length %u", + ch->chunk_type == SCTP_DATA ? "DATA" : "I-DATA", + chk_length); op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg); - stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_20; - sctp_abort_an_association(inp, stcb, op_err, SCTP_SO_NOT_LOCKED); + stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_23; + sctp_abort_an_association(inp, stcb, op_err, false, SCTP_SO_NOT_LOCKED); return (2); } #ifdef SCTP_AUDITING_ENABLED @@ -2801,7 +2805,7 @@ sctp_process_data(struct mbuf **mm, int iphlen, int *offset, int length, } else { last_chunk = 0; } - if (sctp_process_a_data_chunk(stcb, asoc, mm, *offset, + if (sctp_process_a_data_chunk(stcb, asoc, mm, *offset, chk_length, net, high_tsn, &abort_flag, &break_flag, last_chunk, ch->chunk_type)) { num_chunks++; @@ -2854,10 +2858,10 @@ sctp_process_data(struct mbuf **mm, int iphlen, int *offset, int length, struct mbuf *op_err; char msg[SCTP_DIAG_INFO_LEN]; - snprintf(msg, sizeof(msg), "DATA chunk followed by chunk of type %2.2x", - ch->chunk_type); + SCTP_SNPRINTF(msg, sizeof(msg), "DATA chunk followed by chunk of type %2.2x", + ch->chunk_type); op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg); - sctp_abort_an_association(inp, stcb, op_err, SCTP_SO_NOT_LOCKED); + sctp_abort_an_association(inp, stcb, op_err, false, SCTP_SO_NOT_LOCKED); return (2); } default: @@ -2873,11 +2877,10 @@ sctp_process_data(struct mbuf **mm, int iphlen, int *offset, int length, struct mbuf *op_err; char msg[SCTP_DIAG_INFO_LEN]; - snprintf(msg, sizeof(msg), "Chunk of length %u", - chk_length); + SCTP_SNPRINTF(msg, sizeof(msg), "Chunk of length %u", chk_length); op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg); - stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_20; - sctp_abort_an_association(inp, stcb, op_err, SCTP_SO_NOT_LOCKED); + stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_24; + sctp_abort_an_association(inp, stcb, op_err, false, SCTP_SO_NOT_LOCKED); return (2); } if (ch->chunk_type & 0x40) { @@ -3116,7 +3119,6 @@ sctp_process_segment_range(struct sctp_tcb *stcb, struct sctp_tmit_chunk **p_tp1 tp1->do_rtt = 0; } } - } if (tp1->sent <= SCTP_DATAGRAM_RESEND) { if (SCTP_TSN_GT(tp1->rec.data.tsn, @@ -3191,7 +3193,6 @@ sctp_process_segment_range(struct sctp_tcb *stcb, struct sctp_tmit_chunk **p_tp1 return (wake_him); /* Return value only used for nr-sack */ } - static int sctp_handle_segments(struct mbuf *m, int *offset, struct sctp_tcb *stcb, struct sctp_association *asoc, uint32_t last_tsn, uint32_t *biggest_tsn_acked, @@ -3312,7 +3313,6 @@ sctp_check_for_revoked(struct sctp_tcb *stcb, } } - static void sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc, uint32_t biggest_tsn_acked, uint32_t biggest_tsn_newly_acked, uint32_t this_sack_lowest_newack, int accum_moved) @@ -3368,7 +3368,7 @@ sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc, if (stcb->asoc.prsctp_supported) { if ((PR_SCTP_TTL_ENABLED(tp1->flags)) && tp1->sent < SCTP_DATAGRAM_ACKED) { /* Is it expired? */ -#ifndef __FreeBSD__ +#if !(defined(__FreeBSD__) && !defined(__Userspace__)) if (timercmp(&now, &tp1->rec.data.timetodrop, >)) { #else if (timevalcmp(&now, &tp1->rec.data.timetodrop, >)) { @@ -3381,7 +3381,6 @@ sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc, continue; } } - } if (SCTP_TSN_GT(tp1->rec.data.tsn, asoc->this_sack_highest_gap) && !(accum_moved && asoc->fast_retran_loss_recovery)) { @@ -3491,7 +3490,6 @@ sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc, (1) #endif ) { - if (SCTP_TSN_GE(biggest_tsn_newly_acked, tp1->rec.data.fast_retran_tsn)) { /* @@ -3678,9 +3676,7 @@ sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc, tp1->whoTo->find_pseudo_cumack = 1; tp1->whoTo->find_rtx_pseudo_cumack = 1; } - } else {/* CMT is OFF */ - #ifdef SCTP_FR_TO_ALTERNATE /* Can we find an alternate? */ alt = sctp_find_alternate_net(stcb, tp1->whoTo, 0); @@ -3796,7 +3792,7 @@ sctp_try_advance_peer_ack_point(struct sctp_tcb *stcb, * Now is this one marked for resend and its time is * now up? */ -#ifndef __FreeBSD__ +#if !(defined(__FreeBSD__) && !defined(__Userspace__)) if (timercmp(&now, &tp1->rec.data.timetodrop, >)) { #else if (timevalcmp(&now, &tp1->rec.data.timetodrop, >)) { @@ -3891,11 +3887,10 @@ sctp_fs_audit(struct sctp_association *asoc) return (ret); } - static void sctp_window_probe_recovery(struct sctp_tcb *stcb, - struct sctp_association *asoc, - struct sctp_tmit_chunk *tp1) + struct sctp_association *asoc, + struct sctp_tmit_chunk *tp1) { tp1->window_probe = 0; if ((tp1->sent >= SCTP_DATAGRAM_ACKED) || (tp1->data == NULL)) { @@ -4005,11 +4000,12 @@ sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack, *abort_now = 1; /* XXX */ - snprintf(msg, sizeof(msg), "Cum ack %8.8x greater or equal than TSN %8.8x", - cumack, send_s); + SCTP_SNPRINTF(msg, sizeof(msg), + "Cum ack %8.8x greater or equal than TSN %8.8x", + cumack, send_s); op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg); - stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_21; - sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, SCTP_SO_NOT_LOCKED); + stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_25; + sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, false, SCTP_SO_NOT_LOCKED); return; } asoc->this_sack_highest_gap = cumack; @@ -4090,7 +4086,6 @@ sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack, tp1->whoTo->new_pseudo_cumack = 1; tp1->whoTo->find_pseudo_cumack = 1; tp1->whoTo->find_rtx_pseudo_cumack = 1; - if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_CWND_LOGGING_ENABLE) { /* sa_ignore NO_NULL_CHK */ sctp_log_cwnd(stcb, tp1->whoTo, tp1->rec.data.tsn, SCTP_CWND_LOG_FROM_SACK); @@ -4139,7 +4134,6 @@ sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack, break; } } - } #if defined(__Userspace__) if (stcb->sctp_ep->recv_callback) { @@ -4159,7 +4153,7 @@ sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack, (inp->send_sb_threshold == 0))) { atomic_add_int(&stcb->asoc.refcnt, 1); SCTP_TCB_UNLOCK(stcb); - inp->send_callback(stcb->sctp_socket, sb_free_now); + inp->send_callback(stcb->sctp_socket, sb_free_now, inp->ulp_info); SCTP_TCB_LOCK(stcb); atomic_subtract_int(&stcb->asoc.refcnt, 1); } @@ -4169,7 +4163,7 @@ sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack, /* sa_ignore NO_NULL_CHK */ if (stcb->sctp_socket) { #endif -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) struct socket *so; #endif @@ -4178,7 +4172,7 @@ sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack, /* sa_ignore NO_NULL_CHK */ sctp_wakeup_log(stcb, 1, SCTP_WAKESND_FROM_SACK); } -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) so = SCTP_INP_SO(stcb->sctp_ep); atomic_add_int(&stcb->asoc.refcnt, 1); SCTP_TCB_UNLOCK(stcb); @@ -4192,7 +4186,7 @@ sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack, } #endif sctp_sowwakeup_locked(stcb->sctp_ep, stcb->sctp_socket); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_UNLOCK(so, 1); #endif } else { @@ -4227,7 +4221,7 @@ sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack, net->dest_state &= ~SCTP_ADDR_PF; sctp_timer_stop(SCTP_TIMER_TYPE_HEARTBEAT, stcb->sctp_ep, stcb, net, - SCTP_FROM_SCTP_INDATA + SCTP_LOC_22); + SCTP_FROM_SCTP_INDATA + SCTP_LOC_26); sctp_timer_start(SCTP_TIMER_TYPE_HEARTBEAT, stcb->sctp_ep, stcb, net); asoc->cc_functions.sctp_cwnd_update_exit_pf(stcb, net); /* Done with this net */ @@ -4302,7 +4296,7 @@ again: } else if (SCTP_OS_TIMER_PENDING(&net->rxt_timer.timer)) { sctp_timer_stop(SCTP_TIMER_TYPE_SEND, stcb->sctp_ep, stcb, net, - SCTP_FROM_SCTP_INDATA + SCTP_LOC_23); + SCTP_FROM_SCTP_INDATA + SCTP_LOC_27); } } } @@ -4354,8 +4348,8 @@ again: *abort_now = 1; /* XXX */ op_err = sctp_generate_cause(SCTP_CAUSE_USER_INITIATED_ABT, ""); - stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_24; - sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, SCTP_SO_NOT_LOCKED); + stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_28; + sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, false, SCTP_SO_NOT_LOCKED); return; } if ((asoc->state & SCTP_STATE_SHUTDOWN_PENDING) && @@ -4377,7 +4371,7 @@ again: sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN, stcb->sctp_ep, stcb, netp); sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, - stcb->sctp_ep, stcb, netp); + stcb->sctp_ep, stcb, NULL); } else if ((SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_RECEIVED) && (asoc->stream_queue_cnt == 0)) { struct sctp_nets *netp; @@ -4424,10 +4418,15 @@ again: } } } - if (lchk) { + for (; lchk != NULL; lchk = TAILQ_NEXT(lchk, sctp_next)) { + if (lchk->whoTo != NULL) { + break; + } + } + if (lchk != NULL) { /* Assure a timer is up */ sctp_timer_start(SCTP_TIMER_TYPE_SEND, - stcb->sctp_ep, stcb, lchk->whoTo); + stcb->sctp_ep, stcb, lchk->whoTo); } } if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_SACK_RWND_LOGGING_ENABLE) { @@ -4560,11 +4559,12 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup, hopeless_peer: *abort_now = 1; /* XXX */ - snprintf(msg, sizeof(msg), "Cum ack %8.8x greater or equal than TSN %8.8x", - cum_ack, send_s); + SCTP_SNPRINTF(msg, sizeof(msg), + "Cum ack %8.8x greater or equal than TSN %8.8x", + cum_ack, send_s); op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg); - stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_25; - sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, SCTP_SO_NOT_LOCKED); + stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_29; + sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, false, SCTP_SO_NOT_LOCKED); return; } /**********************/ @@ -4595,7 +4595,7 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup, /* stop any timers */ TAILQ_FOREACH(net, &asoc->nets, sctp_next) { sctp_timer_stop(SCTP_TIMER_TYPE_SEND, stcb->sctp_ep, - stcb, net, SCTP_FROM_SCTP_INDATA + SCTP_LOC_26); + stcb, net, SCTP_FROM_SCTP_INDATA + SCTP_LOC_30); net->partial_bytes_acked = 0; net->flight_size = 0; } @@ -4722,8 +4722,6 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup, tp1->whoTo->new_pseudo_cumack = 1; tp1->whoTo->find_pseudo_cumack = 1; tp1->whoTo->find_rtx_pseudo_cumack = 1; - - if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_SACK_LOGGING_ENABLE) { sctp_log_sack(asoc->last_acked_seq, cum_ack, @@ -4761,7 +4759,6 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup, asoc->this_sack_highest_gap = last_tsn; if ((num_seg > 0) || (num_nr_seg > 0)) { - /* * thisSackHighestGap will increase while handling NEW * segments this_sack_highest_newack will increase while @@ -4795,14 +4792,13 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup, if (net->new_pseudo_cumack) sctp_timer_stop(SCTP_TIMER_TYPE_SEND, stcb->sctp_ep, stcb, net, - SCTP_FROM_SCTP_INDATA + SCTP_LOC_27); - + SCTP_FROM_SCTP_INDATA + SCTP_LOC_31); } } else { if (accum_moved) { TAILQ_FOREACH(net, &asoc->nets, sctp_next) { sctp_timer_stop(SCTP_TIMER_TYPE_SEND, stcb->sctp_ep, - stcb, net, SCTP_FROM_SCTP_INDATA + SCTP_LOC_28); + stcb, net, SCTP_FROM_SCTP_INDATA + SCTP_LOC_32); } } } @@ -4881,7 +4877,7 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup, (inp->send_sb_threshold == 0))) { atomic_add_int(&stcb->asoc.refcnt, 1); SCTP_TCB_UNLOCK(stcb); - inp->send_callback(stcb->sctp_socket, sb_free_now); + inp->send_callback(stcb->sctp_socket, sb_free_now, inp->ulp_info); SCTP_TCB_LOCK(stcb); atomic_subtract_int(&stcb->asoc.refcnt, 1); } @@ -4891,7 +4887,7 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup, /* sa_ignore NO_NULL_CHK */ if ((wake_him) && (stcb->sctp_socket)) { #endif -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) struct socket *so; #endif @@ -4899,7 +4895,7 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup, if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_WAKE_LOGGING_ENABLE) { sctp_wakeup_log(stcb, wake_him, SCTP_WAKESND_FROM_SACK); } -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) so = SCTP_INP_SO(stcb->sctp_ep); atomic_add_int(&stcb->asoc.refcnt, 1); SCTP_TCB_UNLOCK(stcb); @@ -4913,7 +4909,7 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup, } #endif sctp_sowwakeup_locked(stcb->sctp_ep, stcb->sctp_socket); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_UNLOCK(so, 1); #endif } else { @@ -5007,7 +5003,7 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup, net->dest_state &= ~SCTP_ADDR_PF; sctp_timer_stop(SCTP_TIMER_TYPE_HEARTBEAT, stcb->sctp_ep, stcb, net, - SCTP_FROM_SCTP_INDATA + SCTP_LOC_29); + SCTP_FROM_SCTP_INDATA + SCTP_LOC_33); sctp_timer_start(SCTP_TIMER_TYPE_HEARTBEAT, stcb->sctp_ep, stcb, net); asoc->cc_functions.sctp_cwnd_update_exit_pf(stcb, net); /* Done with this net */ @@ -5032,7 +5028,7 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup, /* stop all timers */ sctp_timer_stop(SCTP_TIMER_TYPE_SEND, stcb->sctp_ep, stcb, net, - SCTP_FROM_SCTP_INDATA + SCTP_LOC_30); + SCTP_FROM_SCTP_INDATA + SCTP_LOC_34); net->flight_size = 0; net->partial_bytes_acked = 0; } @@ -5070,8 +5066,8 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup, *abort_now = 1; /* XXX */ op_err = sctp_generate_cause(SCTP_CAUSE_USER_INITIATED_ABT, ""); - stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_24; - sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, SCTP_SO_NOT_LOCKED); + stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_35; + sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, false, SCTP_SO_NOT_LOCKED); return; } if ((asoc->state & SCTP_STATE_SHUTDOWN_PENDING) && @@ -5093,7 +5089,7 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup, sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN, stcb->sctp_ep, stcb, netp); sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, - stcb->sctp_ep, stcb, netp); + stcb->sctp_ep, stcb, NULL); return; } else if ((SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_RECEIVED) && (asoc->stream_queue_cnt == 0)) { @@ -5211,12 +5207,11 @@ again: if (!SCTP_OS_TIMER_PENDING(&net->rxt_timer.timer)) { sctp_timer_start(SCTP_TIMER_TYPE_SEND, stcb->sctp_ep, stcb, net); - } } else if (SCTP_OS_TIMER_PENDING(&net->rxt_timer.timer)) { sctp_timer_stop(SCTP_TIMER_TYPE_SEND, stcb->sctp_ep, stcb, net, - SCTP_FROM_SCTP_INDATA + SCTP_LOC_32); + SCTP_FROM_SCTP_INDATA + SCTP_LOC_36); } } } @@ -5281,7 +5276,12 @@ again: } } } - if (lchk) { + for (; lchk != NULL; lchk = TAILQ_NEXT(lchk, sctp_next)) { + if (lchk->whoTo != NULL) { + break; + } + } + if (lchk != NULL) { /* Assure a timer is up */ sctp_timer_start(SCTP_TIMER_TYPE_SEND, stcb->sctp_ep, stcb, lchk->whoTo); @@ -5430,7 +5430,6 @@ sctp_kick_prsctp_reorder_queue(struct sctp_tcb *stcb, control, &stcb->sctp_socket->so_rcv, 1, SCTP_READ_LOCK_HELD, SCTP_SO_NOT_LOCKED); - } mid = strmin->last_mid_delivered + 1; } else { @@ -5451,17 +5450,12 @@ sctp_kick_prsctp_reorder_queue(struct sctp_tcb *stcb, } } - - static void sctp_flush_reassm_for_str_seq(struct sctp_tcb *stcb, - struct sctp_association *asoc, - uint16_t stream, uint32_t mid, int ordered, uint32_t cumtsn) + struct sctp_association *asoc, struct sctp_stream_in *strm, + struct sctp_queued_to_read *control, int ordered, uint32_t cumtsn) { - struct sctp_queued_to_read *control; - struct sctp_stream_in *strm; struct sctp_tmit_chunk *chk, *nchk; - int cnt_removed=0; /* * For now large messages held on the stream reasm that are @@ -5471,23 +5465,18 @@ sctp_flush_reassm_for_str_seq(struct sctp_tcb *stcb, * delivery function... to see if it can be delivered... But * for now we just dump everything on the queue. */ - strm = &asoc->strmin[stream]; - control = sctp_find_reasm_entry(strm, mid, ordered, asoc->idata_supported); - if (control == NULL) { - /* Not found */ - return; - } - if (!asoc->idata_supported && !ordered && SCTP_TSN_GT(control->fsn_included, cumtsn)) { + if (!asoc->idata_supported && !ordered && + control->first_frag_seen && + SCTP_TSN_GT(control->fsn_included, cumtsn)) { return; } TAILQ_FOREACH_SAFE(chk, &control->reasm, sctp_next, nchk) { /* Purge hanging chunks */ - if (!asoc->idata_supported && (ordered == 0)) { + if (!asoc->idata_supported && !ordered) { if (SCTP_TSN_GT(chk->rec.data.tsn, cumtsn)) { break; } } - cnt_removed++; TAILQ_REMOVE(&control->reasm, chk, sctp_next); if (asoc->size_on_reasm_queue >= chk->send_size) { asoc->size_on_reasm_queue -= chk->send_size; @@ -5566,10 +5555,10 @@ sctp_handle_forward_tsn(struct sctp_tcb *stcb, * * Assume we get FwdTSN(x): * - * 1) update local cumTSN to x - * 2) try to further advance cumTSN to x + others we have - * 3) examine and update re-ordering queue on pr-in-streams - * 4) clean up re-assembly queue + * 1) update local cumTSN to x + * 2) try to further advance cumTSN to x + others we have + * 3) examine and update re-ordering queue on pr-in-streams + * 4) clean up re-assembly queue * 5) Send a sack to report where we are. */ struct sctp_association *asoc; @@ -5577,7 +5566,7 @@ sctp_handle_forward_tsn(struct sctp_tcb *stcb, unsigned int i, fwd_sz, m_size; uint32_t str_seq; struct sctp_stream_in *strm; - struct sctp_queued_to_read *control, *sv; + struct sctp_queued_to_read *control, *ncontrol, *sv; asoc = &stcb->asoc; if ((fwd_sz = ntohs(fwd->ch.chunk_length)) < sizeof(struct sctp_forward_tsn_chunk)) { @@ -5611,12 +5600,12 @@ sctp_handle_forward_tsn(struct sctp_tcb *stcb, * give out). This must be an attacker. */ *abort_flag = 1; - snprintf(msg, sizeof(msg), - "New cum ack %8.8x too high, highest TSN %8.8x", - new_cum_tsn, asoc->highest_tsn_inside_map); + SCTP_SNPRINTF(msg, sizeof(msg), + "New cum ack %8.8x too high, highest TSN %8.8x", + new_cum_tsn, asoc->highest_tsn_inside_map); op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg); - stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_33; - sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, SCTP_SO_NOT_LOCKED); + stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_37; + sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, false, SCTP_SO_NOT_LOCKED); return; } SCTP_STAT_INCR(sctps_fwdtsn_map_over); @@ -5650,10 +5639,14 @@ sctp_handle_forward_tsn(struct sctp_tcb *stcb, /* This is now done as part of clearing up the stream/seq */ if (asoc->idata_supported == 0) { uint16_t sid; + /* Flush all the un-ordered data based on cum-tsn */ SCTP_INP_READ_LOCK(stcb->sctp_ep); - for (sid = 0 ; sid < asoc->streamincnt; sid++) { - sctp_flush_reassm_for_str_seq(stcb, asoc, sid, 0, 0, new_cum_tsn); + for (sid = 0; sid < asoc->streamincnt; sid++) { + strm = &asoc->strmin[sid]; + if (!TAILQ_EMPTY(&strm->uno_inqueue)) { + sctp_flush_reassm_for_str_seq(stcb, asoc, strm, TAILQ_FIRST(&strm->uno_inqueue), 0, new_cum_tsn); + } } SCTP_INP_READ_UNLOCK(stcb->sctp_ep); } @@ -5665,7 +5658,7 @@ sctp_handle_forward_tsn(struct sctp_tcb *stcb, if (m && fwd_sz) { /* New method. */ unsigned int num_str; - uint32_t mid, cur_mid; + uint32_t mid; uint16_t sid; uint16_t ordered, flags; struct sctp_strseq *stseq, strseqbuf; @@ -5729,8 +5722,24 @@ sctp_handle_forward_tsn(struct sctp_tcb *stcb, asoc->fragmented_delivery_inprogress = 0; } strm = &asoc->strmin[sid]; - for (cur_mid = strm->last_mid_delivered; SCTP_MID_GE(asoc->idata_supported, mid, cur_mid); cur_mid++) { - sctp_flush_reassm_for_str_seq(stcb, asoc, sid, cur_mid, ordered, new_cum_tsn); + if (ordered) { + TAILQ_FOREACH_SAFE(control, &strm->inqueue, next_instrm, ncontrol) { + if (SCTP_MID_GE(asoc->idata_supported, mid, control->mid)) { + sctp_flush_reassm_for_str_seq(stcb, asoc, strm, control, ordered, new_cum_tsn); + } + } + } else { + if (asoc->idata_supported) { + TAILQ_FOREACH_SAFE(control, &strm->uno_inqueue, next_instrm, ncontrol) { + if (SCTP_MID_GE(asoc->idata_supported, mid, control->mid)) { + sctp_flush_reassm_for_str_seq(stcb, asoc, strm, control, ordered, new_cum_tsn); + } + } + } else { + if (!TAILQ_EMPTY(&strm->uno_inqueue)) { + sctp_flush_reassm_for_str_seq(stcb, asoc, strm, TAILQ_FIRST(&strm->uno_inqueue), ordered, new_cum_tsn); + } + } } TAILQ_FOREACH(control, &stcb->sctp_ep->read_queue, next) { if ((control->sinfo_stream == sid) && diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_indata.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_indata.h index 96c8bff4ed..651493b917 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_indata.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_indata.h @@ -32,9 +32,9 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_indata.h 351655 2019-09-01 10:39:16Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_indata.h 365071 2020-09-01 21:19:14Z mjg $"); #endif #ifndef _NETINET_SCTP_INDATA_H_ @@ -44,12 +44,11 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_indata.h 351655 2019-09-01 10:39:16Z t struct sctp_queued_to_read * sctp_build_readq_entry(struct sctp_tcb *stcb, - struct sctp_nets *net, - uint32_t tsn, uint32_t ppid, - uint32_t context, uint16_t sid, - uint32_t mid, uint8_t flags, - struct mbuf *dm); - + struct sctp_nets *net, + uint32_t tsn, uint32_t ppid, + uint32_t context, uint16_t sid, + uint32_t mid, uint8_t flags, + struct mbuf *dm); #define sctp_build_readq_entry_mac(_ctl, in_it, context, net, tsn, ppid, sid, flags, dm, tfsn, mid) do { \ if (_ctl) { \ @@ -70,14 +69,15 @@ sctp_build_readq_entry(struct sctp_tcb *stcb, (_ctl)->data = dm; \ (_ctl)->stcb = (in_it); \ (_ctl)->port_from = (in_it)->rport; \ + if ((in_it)->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) { \ + (_ctl)->do_not_ref_stcb = 1; \ + }\ } \ } while (0) - - struct mbuf * sctp_build_ctl_nchunk(struct sctp_inpcb *inp, - struct sctp_sndrcvinfo *sinfo); + struct sctp_sndrcvinfo *sinfo); void sctp_set_rwnd(struct sctp_tcb *, struct sctp_association *); @@ -86,7 +86,7 @@ sctp_calc_rwnd(struct sctp_tcb *stcb, struct sctp_association *asoc); void sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack, - uint32_t rwnd, int *abort_now, int ecne_seen); + uint32_t rwnd, int *abort_now, int ecne_seen); void sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup, @@ -98,7 +98,7 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup, /* draft-ietf-tsvwg-usctp */ void sctp_handle_forward_tsn(struct sctp_tcb *, - struct sctp_forward_tsn_chunk *, int *, struct mbuf *, int); + struct sctp_forward_tsn_chunk *, int *, struct mbuf *, int); struct sctp_tmit_chunk * sctp_try_advance_peer_ack_point(struct sctp_tcb *, struct sctp_association *); @@ -110,8 +110,8 @@ sctp_update_acked(struct sctp_tcb *, struct sctp_shutdown_chunk *, int *); int sctp_process_data(struct mbuf **, int, int *, int, - struct sctp_inpcb *, struct sctp_tcb *, - struct sctp_nets *, uint32_t *); + struct sctp_inpcb *, struct sctp_tcb *, + struct sctp_nets *, uint32_t *); void sctp_slide_mapping_arrays(struct sctp_tcb *stcb); diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.c index 5afe7813b6..ed03405d01 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.c @@ -32,9 +32,9 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_input.c 355135 2019-11-27 19:32:29Z tuexen $"); +__FBSDID("$FreeBSD$"); #endif #include @@ -51,23 +51,18 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_input.c 355135 2019-11-27 19:32:29Z tu #include #include #include -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) #include #endif #if defined(INET) || defined(INET6) -#if !defined(__Userspace_os_Windows) +#if !defined(_WIN32) #include #endif #endif -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) #include #endif -#if defined(__APPLE__) -#define APPLE_FILE_NO 2 -#endif - - static void sctp_stop_all_cookie_timers(struct sctp_tcb *stcb) { @@ -99,8 +94,8 @@ static void sctp_handle_init(struct mbuf *m, int iphlen, int offset, struct sockaddr *src, struct sockaddr *dst, struct sctphdr *sh, struct sctp_init_chunk *cp, struct sctp_inpcb *inp, - struct sctp_tcb *stcb, struct sctp_nets *net, int *abort_no_unlock, -#if defined(__FreeBSD__) + struct sctp_tcb *stcb, struct sctp_nets *net, +#if defined(__FreeBSD__) && !defined(__Userspace__) uint8_t mflowtype, uint32_t mflowid, #endif uint32_t vrf_id, uint16_t port) @@ -113,66 +108,21 @@ sctp_handle_init(struct mbuf *m, int iphlen, int offset, if (stcb == NULL) { SCTP_INP_RLOCK(inp); } - /* validate length */ - if (ntohs(cp->ch.chunk_length) < sizeof(struct sctp_init_chunk)) { - op_err = sctp_generate_cause(SCTP_CAUSE_INVALID_PARAM, ""); - sctp_abort_association(inp, stcb, m, iphlen, src, dst, sh, op_err, -#if defined(__FreeBSD__) - mflowtype, mflowid, -#endif - vrf_id, port); - if (stcb) - *abort_no_unlock = 1; - goto outnow; - } - /* validate parameters */ + /* Validate parameters */ init = &cp->init; - if (init->initiate_tag == 0) { - /* protocol error... send abort */ - op_err = sctp_generate_cause(SCTP_CAUSE_INVALID_PARAM, ""); - sctp_abort_association(inp, stcb, m, iphlen, src, dst, sh, op_err, -#if defined(__FreeBSD__) - mflowtype, mflowid, -#endif - vrf_id, port); - if (stcb) - *abort_no_unlock = 1; + if (ntohl(init->initiate_tag) == 0) { goto outnow; } - if (ntohl(init->a_rwnd) < SCTP_MIN_RWND) { - /* invalid parameter... send abort */ - op_err = sctp_generate_cause(SCTP_CAUSE_INVALID_PARAM, ""); - sctp_abort_association(inp, stcb, m, iphlen, src, dst, sh, op_err, -#if defined(__FreeBSD__) - mflowtype, mflowid, -#endif - vrf_id, port); - if (stcb) - *abort_no_unlock = 1; - goto outnow; - } - if (init->num_inbound_streams == 0) { + if ((ntohl(init->a_rwnd) < SCTP_MIN_RWND) || + (ntohs(init->num_inbound_streams) == 0) || + (ntohs(init->num_outbound_streams) == 0)) { /* protocol error... send abort */ op_err = sctp_generate_cause(SCTP_CAUSE_INVALID_PARAM, ""); - sctp_abort_association(inp, stcb, m, iphlen, src, dst, sh, op_err, -#if defined(__FreeBSD__) - mflowtype, mflowid, + sctp_send_abort(m, iphlen, src, dst, sh, init->initiate_tag, op_err, +#if defined(__FreeBSD__) && !defined(__Userspace__) + mflowtype, mflowid, inp->fibnum, #endif - vrf_id, port); - if (stcb) - *abort_no_unlock = 1; - goto outnow; - } - if (init->num_outbound_streams == 0) { - /* protocol error... send abort */ - op_err = sctp_generate_cause(SCTP_CAUSE_INVALID_PARAM, ""); - sctp_abort_association(inp, stcb, m, iphlen, src, dst, sh, op_err, -#if defined(__FreeBSD__) - mflowtype, mflowid, -#endif - vrf_id, port); - if (stcb) - *abort_no_unlock = 1; + vrf_id, port); goto outnow; } if (sctp_validate_init_auth_params(m, offset + sizeof(*cp), @@ -180,13 +130,11 @@ sctp_handle_init(struct mbuf *m, int iphlen, int offset, /* auth parameter(s) error... send abort */ op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code), "Problem with AUTH parameters"); - sctp_abort_association(inp, stcb, m, iphlen, src, dst, sh, op_err, -#if defined(__FreeBSD__) - mflowtype, mflowid, + sctp_send_abort(m, iphlen, src, dst, sh, init->initiate_tag, op_err, +#if defined(__FreeBSD__) && !defined(__Userspace__) + mflowtype, mflowid, inp->fibnum, #endif - vrf_id, port); - if (stcb) - *abort_no_unlock = 1; + vrf_id, port); goto outnow; } /* We are only accepting if we have a listening socket.*/ @@ -210,7 +158,7 @@ sctp_handle_init(struct mbuf *m, int iphlen, int offset, op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code), "No listener"); sctp_send_abort(m, iphlen, src, dst, sh, 0, op_err, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) mflowtype, mflowid, inp->fibnum, #endif vrf_id, port); @@ -226,7 +174,7 @@ sctp_handle_init(struct mbuf *m, int iphlen, int offset, SCTPDBG(SCTP_DEBUG_INPUT3, "sctp_handle_init: sending INIT-ACK\n"); sctp_send_initiate_ack(inp, stcb, net, m, iphlen, offset, src, dst, sh, cp, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) mflowtype, mflowid, #endif vrf_id, port); @@ -242,11 +190,7 @@ sctp_handle_init(struct mbuf *m, int iphlen, int offset, */ int -sctp_is_there_unsent_data(struct sctp_tcb *stcb, int so_locked -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - SCTP_UNUSED -#endif -) +sctp_is_there_unsent_data(struct sctp_tcb *stcb, int so_locked) { int unsent_data; unsigned int i; @@ -285,7 +229,7 @@ sctp_is_there_unsent_data(struct sctp_tcb *stcb, int so_locked } atomic_subtract_int(&stcb->asoc.stream_queue_cnt, 1); TAILQ_REMOVE(&stcb->asoc.strmout[i].outqueue, sp, next); - stcb->asoc.ss_functions.sctp_ss_remove_from_stream(stcb, asoc, &asoc->strmout[i], sp, 1); + stcb->asoc.ss_functions.sctp_ss_remove_from_stream(stcb, asoc, &asoc->strmout[i], sp); if (sp->net) { sctp_free_remote_addr(sp->net); sp->net = NULL; @@ -333,7 +277,6 @@ sctp_process_init(struct sctp_init_chunk *cp, struct sctp_tcb *stcb) if (SCTP_BASE_SYSCTL(sctp_logging_level) & (SCTP_CWND_MONITOR_ENABLE|SCTP_CWND_LOGGING_ENABLE)) { sctp_log_cwnd(stcb, lnet, 0, SCTP_CWND_INITIALIZATION); } - } } SCTP_TCB_SEND_LOCK(stcb); @@ -375,7 +318,7 @@ sctp_process_init(struct sctp_init_chunk *cp, struct sctp_tcb *stcb) TAILQ_FOREACH_SAFE(sp, &outs->outqueue, next, nsp) { atomic_subtract_int(&stcb->asoc.stream_queue_cnt, 1); TAILQ_REMOVE(&outs->outqueue, sp, next); - stcb->asoc.ss_functions.sctp_ss_remove_from_stream(stcb, asoc, outs, sp, 1); + stcb->asoc.ss_functions.sctp_ss_remove_from_stream(stcb, asoc, outs, sp); sctp_ulp_notify(SCTP_NOTIFY_SPECIAL_SP_FAIL, stcb, 0, sp, SCTP_SO_NOT_LOCKED); if (sp->data) { @@ -466,7 +409,7 @@ sctp_process_init_ack(struct mbuf *m, int iphlen, int offset, struct sockaddr *src, struct sockaddr *dst, struct sctphdr *sh, struct sctp_init_ack_chunk *cp, struct sctp_tcb *stcb, struct sctp_nets *net, int *abort_no_unlock, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) uint8_t mflowtype, uint32_t mflowid, #endif uint32_t vrf_id) @@ -487,7 +430,7 @@ sctp_process_init_ack(struct mbuf *m, int iphlen, int offset, &nat_friendly, &cookie_found); if (abort_flag) { /* Send an abort and notify peer */ - sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, SCTP_SO_NOT_LOCKED); + sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, false, SCTP_SO_NOT_LOCKED); *abort_no_unlock = 1; return (-1); } @@ -514,7 +457,7 @@ sctp_process_init_ack(struct mbuf *m, int iphlen, int offset, } sctp_abort_association(stcb->sctp_ep, stcb, m, iphlen, src, dst, sh, op_err, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) mflowtype, mflowid, #endif vrf_id, net->port); @@ -524,29 +467,37 @@ sctp_process_init_ack(struct mbuf *m, int iphlen, int offset, asoc = &stcb->asoc; asoc->peer_supports_nat = (uint8_t)nat_friendly; /* process the peer's parameters in the INIT-ACK */ - retval = sctp_process_init((struct sctp_init_chunk *)cp, stcb); - if (retval < 0) { + if (sctp_process_init((struct sctp_init_chunk *)cp, stcb) < 0) { if (op_err != NULL) { sctp_m_freem(op_err); } - return (retval); + op_err = sctp_generate_cause(SCTP_CAUSE_OUT_OF_RESC, ""); + SCTPDBG(SCTP_DEBUG_INPUT1, "sctp_process_init() failed\n"); + sctp_abort_association(stcb->sctp_ep, stcb, m, iphlen, + src, dst, sh, op_err, +#if defined(__FreeBSD__) && !defined(__Userspace__) + mflowtype, mflowid, +#endif + vrf_id, net->port); + *abort_no_unlock = 1; + return (-1); } initack_limit = offset + ntohs(cp->ch.chunk_length); /* load all addresses */ if ((retval = sctp_load_addresses_from_init(stcb, m, - (offset + sizeof(struct sctp_init_chunk)), initack_limit, - src, dst, NULL, stcb->asoc.port))) { + offset + sizeof(struct sctp_init_chunk), + initack_limit, src, dst, NULL, stcb->asoc.port)) < 0) { if (op_err != NULL) { sctp_m_freem(op_err); } op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code), "Problem with address parameters"); SCTPDBG(SCTP_DEBUG_INPUT1, - "Load addresses from INIT causes an abort %d\n", - retval); + "Load addresses from INIT causes an abort %d\n", + retval); sctp_abort_association(stcb->sctp_ep, stcb, m, iphlen, src, dst, sh, op_err, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) mflowtype, mflowid, #endif vrf_id, net->port); @@ -583,7 +534,7 @@ sctp_process_init_ack(struct mbuf *m, int iphlen, int offset, /* * Cancel the INIT timer, We do this first before queueing the - * cookie. We always cancel at the primary to assue that we are + * cookie. We always cancel at the primary to assume that we are * canceling the timer started by the INIT which always goes to the * primary. */ @@ -611,7 +562,7 @@ sctp_process_init_ack(struct mbuf *m, int iphlen, int offset, (inp->send_sb_threshold == 0))) { atomic_add_int(&stcb->asoc.refcnt, 1); SCTP_TCB_UNLOCK(stcb); - inp->send_callback(stcb->sctp_socket, sb_free_now); + inp->send_callback(stcb->sctp_socket, sb_free_now, inp->ulp_info); SCTP_TCB_LOCK(stcb); atomic_subtract_int(&stcb->asoc.refcnt, 1); } @@ -764,22 +715,20 @@ sctp_handle_heartbeat_ack(struct sctp_heartbeat_chunk *cp, SCTP_MOBILITY_FASTHANDOFF)) && sctp_is_mobility_feature_on(stcb->sctp_ep, SCTP_MOBILITY_PRIM_DELETED)) { - sctp_timer_stop(SCTP_TIMER_TYPE_PRIM_DELETED, stcb->sctp_ep, stcb, NULL, SCTP_FROM_SCTP_INPUT + SCTP_LOC_6); if (sctp_is_mobility_feature_on(stcb->sctp_ep, - SCTP_MOBILITY_FASTHANDOFF)) { + SCTP_MOBILITY_FASTHANDOFF)) { sctp_assoc_immediate_retrans(stcb, - stcb->asoc.primary_destination); + stcb->asoc.primary_destination); } if (sctp_is_mobility_feature_on(stcb->sctp_ep, - SCTP_MOBILITY_BASE)) { + SCTP_MOBILITY_BASE)) { sctp_move_chunks_from_net(stcb, - stcb->asoc.deleted_primary); + stcb->asoc.deleted_primary); } - sctp_delete_prim_timer(stcb->sctp_ep, stcb, - stcb->asoc.deleted_primary); + sctp_delete_prim_timer(stcb->sctp_ep, stcb); } } } @@ -796,7 +745,6 @@ sctp_handle_nat_colliding_state(struct sctp_tcb *stcb) if ((SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_WAIT) || (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_ECHOED)) { - new_vtag = sctp_select_a_tag(stcb->sctp_ep, stcb->sctp_ep->sctp_lport, stcb->rport, 1); atomic_add_int(&stcb->asoc.refcnt, 1); SCTP_TCB_UNLOCK(stcb); SCTP_INP_INFO_WLOCK(); @@ -805,6 +753,7 @@ sctp_handle_nat_colliding_state(struct sctp_tcb *stcb) } else { return (0); } + new_vtag = sctp_select_a_tag(stcb->sctp_ep, stcb->sctp_ep->sctp_lport, stcb->rport, 1); if (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_WAIT) { /* generate a new vtag and send init */ LIST_REMOVE(stcb, sctp_asocs); @@ -852,13 +801,12 @@ sctp_handle_nat_missing_state(struct sctp_tcb *stcb, return (1); } - /* Returns 1 if the stcb was aborted, 0 otherwise */ static int sctp_handle_abort(struct sctp_abort_chunk *abort, struct sctp_tcb *stcb, struct sctp_nets *net) { -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) struct socket *so; #endif uint16_t len; @@ -879,13 +827,13 @@ sctp_handle_abort(struct sctp_abort_chunk *abort, cause = (struct sctp_error_cause *)(abort + 1); error = ntohs(cause->code); if (error == SCTP_CAUSE_NAT_COLLIDING_STATE) { - SCTPDBG(SCTP_DEBUG_INPUT2, "Received Colliding state abort flags:%x\n", + SCTPDBG(SCTP_DEBUG_INPUT2, "Received Colliding state, ABORT flags:%x\n", abort->ch.chunk_flags); if (sctp_handle_nat_colliding_state(stcb)) { return (0); } } else if (error == SCTP_CAUSE_NAT_MISSING_STATE) { - SCTPDBG(SCTP_DEBUG_INPUT2, "Received missing state abort flags:%x\n", + SCTPDBG(SCTP_DEBUG_INPUT2, "Received missing state, ABORT flags:%x\n", abort->ch.chunk_flags); if (sctp_handle_nat_missing_state(stcb, net)) { return (0); @@ -895,10 +843,10 @@ sctp_handle_abort(struct sctp_abort_chunk *abort, error = 0; } /* stop any receive timers */ - sctp_timer_stop(SCTP_TIMER_TYPE_RECV, stcb->sctp_ep, stcb, net, + sctp_timer_stop(SCTP_TIMER_TYPE_RECV, stcb->sctp_ep, stcb, NULL, SCTP_FROM_SCTP_INPUT + SCTP_LOC_7); /* notify user of the abort and clean up... */ - sctp_abort_notification(stcb, 1, error, abort, SCTP_SO_NOT_LOCKED); + sctp_abort_notification(stcb, true, false, error, abort, SCTP_SO_NOT_LOCKED); /* free the tcb */ SCTP_STAT_INCR_COUNTER32(sctps_aborted); if ((SCTP_GET_STATE(stcb) == SCTP_STATE_OPEN) || @@ -908,7 +856,7 @@ sctp_handle_abort(struct sctp_abort_chunk *abort, #ifdef SCTP_ASOCLOG_OF_TSNS sctp_print_out_track_log(stcb); #endif -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) so = SCTP_INP_SO(stcb->sctp_ep); atomic_add_int(&stcb->asoc.refcnt, 1); SCTP_TCB_UNLOCK(stcb); @@ -916,10 +864,9 @@ sctp_handle_abort(struct sctp_abort_chunk *abort, SCTP_TCB_LOCK(stcb); atomic_subtract_int(&stcb->asoc.refcnt, 1); #endif - SCTP_ADD_SUBSTATE(stcb, SCTP_STATE_WAS_ABORTED); (void)sctp_free_assoc(stcb->sctp_ep, stcb, SCTP_NORMAL_PROC, SCTP_FROM_SCTP_INPUT + SCTP_LOC_8); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_UNLOCK(so, 1); #endif SCTPDBG(SCTP_DEBUG_INPUT2, "sctp_handle_abort: finished\n"); @@ -956,7 +903,6 @@ sctp_start_net_timers(struct sctp_tcb *stcb) } } - static void sctp_handle_shutdown(struct sctp_shutdown_chunk *cp, struct sctp_tcb *stcb, struct sctp_nets *net, int *abort_flag) @@ -964,7 +910,7 @@ sctp_handle_shutdown(struct sctp_shutdown_chunk *cp, struct sctp_association *asoc; int some_on_streamwheel; int old_state; -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) struct socket *so; #endif @@ -1015,7 +961,7 @@ sctp_handle_shutdown(struct sctp_shutdown_chunk *cp, asoc->control_pdapi->pdapi_aborted = 1; asoc->control_pdapi = NULL; SCTP_INP_READ_UNLOCK(stcb->sctp_ep); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) so = SCTP_INP_SO(stcb->sctp_ep); atomic_add_int(&stcb->asoc.refcnt, 1); SCTP_TCB_UNLOCK(stcb); @@ -1031,7 +977,7 @@ sctp_handle_shutdown(struct sctp_shutdown_chunk *cp, if (stcb->sctp_socket) { sctp_sorwakeup(stcb->sctp_ep, stcb->sctp_socket); } -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_UNLOCK(so, 1); #endif } @@ -1090,7 +1036,7 @@ sctp_handle_shutdown_ack(struct sctp_shutdown_ack_chunk *cp SCTP_UNUSED, struct sctp_nets *net) { struct sctp_association *asoc; -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) struct socket *so; so = SCTP_INP_SO(stcb->sctp_ep); @@ -1124,7 +1070,7 @@ sctp_handle_shutdown_ack(struct sctp_shutdown_ack_chunk *cp SCTP_UNUSED, asoc->control_pdapi->pdapi_aborted = 1; asoc->control_pdapi = NULL; SCTP_INP_READ_UNLOCK(stcb->sctp_ep); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) atomic_add_int(&stcb->asoc.refcnt, 1); SCTP_TCB_UNLOCK(stcb); SCTP_SOCKET_LOCK(so, 1); @@ -1137,7 +1083,7 @@ sctp_handle_shutdown_ack(struct sctp_shutdown_ack_chunk *cp SCTP_UNUSED, } #endif sctp_sorwakeup(stcb->sctp_ep, stcb->sctp_socket); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_UNLOCK(so, 1); #endif } @@ -1163,7 +1109,7 @@ sctp_handle_shutdown_ack(struct sctp_shutdown_ack_chunk *cp SCTP_UNUSED, } SCTP_STAT_INCR_COUNTER32(sctps_shutdown); /* free the TCB but first save off the ep */ -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) atomic_add_int(&stcb->asoc.refcnt, 1); SCTP_TCB_UNLOCK(stcb); SCTP_SOCKET_LOCK(so, 1); @@ -1172,19 +1118,18 @@ sctp_handle_shutdown_ack(struct sctp_shutdown_ack_chunk *cp SCTP_UNUSED, #endif (void)sctp_free_assoc(stcb->sctp_ep, stcb, SCTP_NORMAL_PROC, SCTP_FROM_SCTP_INPUT + SCTP_LOC_11); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_UNLOCK(so, 1); #endif } static void -sctp_process_unrecog_chunk(struct sctp_tcb *stcb, uint8_t chunk_type, - struct sctp_nets *net) +sctp_process_unrecog_chunk(struct sctp_tcb *stcb, uint8_t chunk_type) { switch (chunk_type) { case SCTP_ASCONF_ACK: case SCTP_ASCONF: - sctp_asconf_cleanup(stcb, net); + sctp_asconf_cleanup(stcb); break; case SCTP_IFORWARD_CUM_TSN: case SCTP_FORWARD_CUM_TSN: @@ -1246,7 +1191,7 @@ sctp_handle_error(struct sctp_chunkhdr *ch, struct sctp_association *asoc; uint32_t remaining_length, adjust; uint16_t code, cause_code, cause_length; -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) struct socket *so; #endif @@ -1287,14 +1232,14 @@ sctp_handle_error(struct sctp_chunkhdr *ch, cause_code); break; case SCTP_CAUSE_NAT_COLLIDING_STATE: - SCTPDBG(SCTP_DEBUG_INPUT2, "Received Colliding state abort flags: %x\n", + SCTPDBG(SCTP_DEBUG_INPUT2, "Received Colliding state, ERROR flags: %x\n", ch->chunk_flags); if (sctp_handle_nat_colliding_state(stcb)) { return (0); } break; case SCTP_CAUSE_NAT_MISSING_STATE: - SCTPDBG(SCTP_DEBUG_INPUT2, "Received missing state abort flags: %x\n", + SCTPDBG(SCTP_DEBUG_INPUT2, "Received missing state, ERROR flags: %x\n", ch->chunk_flags); if (sctp_handle_nat_missing_state(stcb, net)) { return (0); @@ -1310,19 +1255,16 @@ sctp_handle_error(struct sctp_chunkhdr *ch, struct sctp_error_stale_cookie *stale_cookie; stale_cookie = (struct sctp_error_stale_cookie *)cause; - asoc->cookie_preserve_req = ntohl(stale_cookie->stale_time); - /* Double it to be more robust on RTX */ - if (asoc->cookie_preserve_req <= UINT32_MAX / 2) { - asoc->cookie_preserve_req *= 2; - } else { - asoc->cookie_preserve_req = UINT32_MAX; - } + /* stable_time is in usec, convert to msec. */ + asoc->cookie_preserve_req = ntohl(stale_cookie->stale_time) / 1000; + /* Double it to be more robust on RTX. */ + asoc->cookie_preserve_req *= 2; asoc->stale_cookie_count++; if (asoc->stale_cookie_count > asoc->max_init_times) { - sctp_abort_notification(stcb, 0, 0, NULL, SCTP_SO_NOT_LOCKED); + sctp_abort_notification(stcb, false, true, 0, NULL, SCTP_SO_NOT_LOCKED); /* now free the asoc */ -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) so = SCTP_INP_SO(stcb->sctp_ep); atomic_add_int(&stcb->asoc.refcnt, 1); SCTP_TCB_UNLOCK(stcb); @@ -1332,7 +1274,7 @@ sctp_handle_error(struct sctp_chunkhdr *ch, #endif (void)sctp_free_assoc(stcb->sctp_ep, stcb, SCTP_NORMAL_PROC, SCTP_FROM_SCTP_INPUT + SCTP_LOC_12); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_UNLOCK(so, 1); #endif return (-1); @@ -1362,7 +1304,7 @@ sctp_handle_error(struct sctp_chunkhdr *ch, struct sctp_error_unrecognized_chunk *unrec_chunk; unrec_chunk = (struct sctp_error_unrecognized_chunk *)cause; - sctp_process_unrecog_chunk(stcb, unrec_chunk->ch.chunk_type, net); + sctp_process_unrecog_chunk(stcb, unrec_chunk->ch.chunk_type); } break; case SCTP_CAUSE_UNRECOG_PARAM: @@ -1423,7 +1365,7 @@ sctp_handle_init_ack(struct mbuf *m, int iphlen, int offset, struct sockaddr *src, struct sockaddr *dst, struct sctphdr *sh, struct sctp_init_ack_chunk *cp, struct sctp_tcb *stcb, struct sctp_nets *net, int *abort_no_unlock, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) uint8_t mflowtype, uint32_t mflowid, #endif uint32_t vrf_id) @@ -1439,73 +1381,25 @@ sctp_handle_init_ack(struct mbuf *m, int iphlen, int offset, "sctp_handle_init_ack: TCB is null\n"); return (-1); } - if (ntohs(cp->ch.chunk_length) < sizeof(struct sctp_init_ack_chunk)) { - /* Invalid length */ - op_err = sctp_generate_cause(SCTP_CAUSE_INVALID_PARAM, ""); - sctp_abort_association(stcb->sctp_ep, stcb, m, iphlen, - src, dst, sh, op_err, -#if defined(__FreeBSD__) - mflowtype, mflowid, -#endif - vrf_id, net->port); - *abort_no_unlock = 1; - return (-1); - } - init_ack = &cp->init; - /* validate parameters */ - if (init_ack->initiate_tag == 0) { - /* protocol error... send an abort */ - op_err = sctp_generate_cause(SCTP_CAUSE_INVALID_PARAM, ""); - sctp_abort_association(stcb->sctp_ep, stcb, m, iphlen, - src, dst, sh, op_err, -#if defined(__FreeBSD__) - mflowtype, mflowid, -#endif - vrf_id, net->port); - *abort_no_unlock = 1; - return (-1); - } - if (ntohl(init_ack->a_rwnd) < SCTP_MIN_RWND) { - /* protocol error... send an abort */ - op_err = sctp_generate_cause(SCTP_CAUSE_INVALID_PARAM, ""); - sctp_abort_association(stcb->sctp_ep, stcb, m, iphlen, - src, dst, sh, op_err, -#if defined(__FreeBSD__) - mflowtype, mflowid, -#endif - vrf_id, net->port); - *abort_no_unlock = 1; - return (-1); - } - if (init_ack->num_inbound_streams == 0) { - /* protocol error... send an abort */ - op_err = sctp_generate_cause(SCTP_CAUSE_INVALID_PARAM, ""); - sctp_abort_association(stcb->sctp_ep, stcb, m, iphlen, - src, dst, sh, op_err, -#if defined(__FreeBSD__) - mflowtype, mflowid, -#endif - vrf_id, net->port); - *abort_no_unlock = 1; - return (-1); - } - if (init_ack->num_outbound_streams == 0) { - /* protocol error... send an abort */ - op_err = sctp_generate_cause(SCTP_CAUSE_INVALID_PARAM, ""); - sctp_abort_association(stcb->sctp_ep, stcb, m, iphlen, - src, dst, sh, op_err, -#if defined(__FreeBSD__) - mflowtype, mflowid, -#endif - vrf_id, net->port); - *abort_no_unlock = 1; - return (-1); - } - /* process according to association state... */ - switch (SCTP_GET_STATE(stcb)) { - case SCTP_STATE_COOKIE_WAIT: - /* this is the expected state for this chunk */ - /* process the INIT-ACK parameters */ + /* Only process the INIT-ACK chunk in COOKIE WAIT state.*/ + if (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_WAIT) { + init_ack = &cp->init; + /* Validate parameters. */ + if ((ntohl(init_ack->initiate_tag) == 0) || + (ntohl(init_ack->a_rwnd) < SCTP_MIN_RWND) || + (ntohs(init_ack->num_inbound_streams) == 0) || + (ntohs(init_ack->num_outbound_streams) == 0)) { + /* One of the mandatory parameters is illegal. */ + op_err = sctp_generate_cause(SCTP_CAUSE_INVALID_PARAM, ""); + sctp_abort_association(stcb->sctp_ep, stcb, m, iphlen, + src, dst, sh, op_err, + #if defined(__FreeBSD__) && !defined(__Userspace__) + mflowtype, mflowid, + #endif + vrf_id, net->port); + *abort_no_unlock = 1; + return (-1); + } if (stcb->asoc.primary_destination->dest_state & SCTP_ADDR_UNCONFIRMED) { /* @@ -1521,56 +1415,42 @@ sctp_handle_init_ack(struct mbuf *m, int iphlen, int offset, } if (sctp_process_init_ack(m, iphlen, offset, src, dst, sh, cp, stcb, net, abort_no_unlock, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) mflowtype, mflowid, #endif vrf_id) < 0) { /* error in parsing parameters */ return (-1); } - /* update our state */ + /* Update our state. */ SCTPDBG(SCTP_DEBUG_INPUT2, "moving to COOKIE-ECHOED state\n"); SCTP_SET_STATE(stcb, SCTP_STATE_COOKIE_ECHOED); - /* reset the RTO calc */ + /* Reset the RTO calculation. */ if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_THRESHOLD_LOGGING) { sctp_misc_ints(SCTP_THRESHOLD_CLEAR, - stcb->asoc.overall_error_count, - 0, - SCTP_FROM_SCTP_INPUT, - __LINE__); + stcb->asoc.overall_error_count, + 0, + SCTP_FROM_SCTP_INPUT, + __LINE__); } stcb->asoc.overall_error_count = 0; (void)SCTP_GETTIME_TIMEVAL(&stcb->asoc.time_entered); /* - * collapse the init timer back in case of a exponential - * backoff + * Collapse the init timer back in case of a exponential + * backoff. */ sctp_timer_start(SCTP_TIMER_TYPE_COOKIE, stcb->sctp_ep, stcb, net); /* - * the send at the end of the inbound data processing will - * cause the cookie to be sent + * The output routine at the end of the inbound data processing + * will cause the cookie to be sent. */ - break; - case SCTP_STATE_SHUTDOWN_SENT: - /* incorrect state... discard */ - break; - case SCTP_STATE_COOKIE_ECHOED: - /* incorrect state... discard */ - break; - case SCTP_STATE_OPEN: - /* incorrect state... discard */ - break; - case SCTP_STATE_EMPTY: - case SCTP_STATE_INUSE: - default: - /* incorrect state... discard */ + SCTPDBG(SCTP_DEBUG_INPUT1, "Leaving handle-init-ack end\n"); + return (0); + } else { return (-1); - break; } - SCTPDBG(SCTP_DEBUG_INPUT1, "Leaving handle-init-ack end\n"); - return (0); } static struct sctp_tcb * @@ -1580,12 +1460,11 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset, struct sctp_inpcb *inp, struct sctp_nets **netp, struct sockaddr *init_src, int *notification, int auth_skipped, uint32_t auth_offset, uint32_t auth_len, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) uint8_t mflowtype, uint32_t mflowid, #endif uint32_t vrf_id, uint16_t port); - /* * handle a state cookie for an existing association m: input packet mbuf * chain-- assumes a pullup on IP/SCTP/COOKIE-ECHO chunk note: this is a @@ -1599,7 +1478,7 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, struct sctp_inpcb *inp, struct sctp_tcb *stcb, struct sctp_nets **netp, struct sockaddr *init_src, int *notification, int auth_skipped, uint32_t auth_offset, uint32_t auth_len, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) uint8_t mflowtype, uint32_t mflowid, #endif uint32_t vrf_id, uint16_t port) @@ -1607,6 +1486,11 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, struct sctp_association *asoc; struct sctp_init_chunk *init_cp, init_buf; struct sctp_init_ack_chunk *initack_cp, initack_buf; + struct sctp_asconf_addr *aparam, *naparam; + struct sctp_asconf_ack *aack, *naack; + struct sctp_tmit_chunk *chk, *nchk; + struct sctp_stream_reset_list *strrst, *nstrrst; + struct sctp_queued_to_read *sq, *nsq; struct sctp_nets *net; struct mbuf *op_err; struct timeval old; @@ -1633,12 +1517,13 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, sctp_send_shutdown_ack(stcb, stcb->asoc.primary_destination); op_err = sctp_generate_cause(SCTP_CAUSE_COOKIE_IN_SHUTDOWN, ""); sctp_send_operr_to(src, dst, sh, cookie->peers_vtag, op_err, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) mflowtype, mflowid, inp->fibnum, #endif vrf_id, net->port); if (how_indx < sizeof(asoc->cookie_how)) asoc->cookie_how[how_indx] = 2; + SCTP_TCB_UNLOCK(stcb); return (NULL); } /* @@ -1653,9 +1538,11 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, (uint8_t *) & init_buf); if (init_cp == NULL) { /* could not pull a INIT chunk in cookie */ + SCTP_TCB_UNLOCK(stcb); return (NULL); } if (init_cp->ch.chunk_type != SCTP_INITIATION) { + SCTP_TCB_UNLOCK(stcb); return (NULL); } /* @@ -1668,9 +1555,11 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, (uint8_t *) & initack_buf); if (initack_cp == NULL) { /* could not pull INIT-ACK chunk in cookie */ + SCTP_TCB_UNLOCK(stcb); return (NULL); } if (initack_cp->ch.chunk_type != SCTP_INITIATION_ACK) { + SCTP_TCB_UNLOCK(stcb); return (NULL); } if ((ntohl(initack_cp->init.initiate_tag) == asoc->my_vtag) && @@ -1688,7 +1577,7 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, * ----INIT-ACK(tag=t)--> * ----INIT(tag=t)------> *1 * <---INIT-ACK(tag=a)--- - * <----CE(tag=t)------------- *2 + * <----CE(tag=t)------------- *2 * * At point *1 we should be generating a different * tag t'. Which means we would throw away the CE and send @@ -1696,8 +1585,8 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, */ if (how_indx < sizeof(asoc->cookie_how)) asoc->cookie_how[how_indx] = 17; + SCTP_TCB_UNLOCK(stcb); return (NULL); - } switch (SCTP_GET_STATE(stcb)) { case SCTP_STATE_COOKIE_WAIT: @@ -1709,10 +1598,17 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, * have the right seq no's. */ /* First we must process the INIT !! */ - retval = sctp_process_init(init_cp, stcb); - if (retval < 0) { + if (sctp_process_init(init_cp, stcb) < 0) { if (how_indx < sizeof(asoc->cookie_how)) asoc->cookie_how[how_indx] = 3; + op_err = sctp_generate_cause(SCTP_CAUSE_OUT_OF_RESC, ""); + SCTPDBG(SCTP_DEBUG_INPUT1, "sctp_process_init() failed\n"); + sctp_abort_association(stcb->sctp_ep, stcb, m, iphlen, + src, dst, sh, op_err, +#if defined(__FreeBSD__) && !defined(__Userspace__) + mflowtype, mflowid, +#endif + vrf_id, net->port); return (NULL); } /* we have already processed the INIT so no problem */ @@ -1731,14 +1627,14 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, SCTP_SET_STATE(stcb, SCTP_STATE_OPEN); if (asoc->state & SCTP_STATE_SHUTDOWN_PENDING) { sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, - stcb->sctp_ep, stcb, asoc->primary_destination); + stcb->sctp_ep, stcb, NULL); } SCTP_STAT_INCR_GAUGE32(sctps_currestab); sctp_stop_all_cookie_timers(stcb); if (((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) && (!SCTP_IS_LISTENING(inp))) { -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) struct socket *so; #endif /* @@ -1749,20 +1645,21 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, */ stcb->sctp_ep->sctp_flags |= SCTP_PCB_FLAGS_CONNECTED; -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) so = SCTP_INP_SO(stcb->sctp_ep); atomic_add_int(&stcb->asoc.refcnt, 1); SCTP_TCB_UNLOCK(stcb); SCTP_SOCKET_LOCK(so, 1); SCTP_TCB_LOCK(stcb); - atomic_add_int(&stcb->asoc.refcnt, -1); + atomic_subtract_int(&stcb->asoc.refcnt, 1); if (stcb->asoc.state & SCTP_STATE_CLOSED_SOCKET) { + SCTP_TCB_UNLOCK(stcb); SCTP_SOCKET_UNLOCK(so, 1); return (NULL); } #endif soisconnected(stcb->sctp_socket); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_UNLOCK(so, 1); #endif } @@ -1781,7 +1678,7 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, if (stcb->asoc.sctp_autoclose_ticks && (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_AUTOCLOSE))) { sctp_timer_start(SCTP_TIMER_TYPE_AUTOCLOSE, - inp, stcb, NULL); + inp, stcb, NULL); } break; default: @@ -1792,16 +1689,22 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, break; } /* end switch */ sctp_stop_all_cookie_timers(stcb); - /* - * We ignore the return code here.. not sure if we should - * somehow abort.. but we do have an existing asoc. This - * really should not fail. - */ - if (sctp_load_addresses_from_init(stcb, m, - init_offset + sizeof(struct sctp_init_chunk), - initack_offset, src, dst, init_src, stcb->asoc.port)) { + if ((retval = sctp_load_addresses_from_init(stcb, m, + init_offset + sizeof(struct sctp_init_chunk), + initack_offset, src, dst, init_src, stcb->asoc.port)) < 0) { if (how_indx < sizeof(asoc->cookie_how)) asoc->cookie_how[how_indx] = 4; + op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code), + "Problem with address parameters"); + SCTPDBG(SCTP_DEBUG_INPUT1, + "Load addresses from INIT causes an abort %d\n", + retval); + sctp_abort_association(stcb->sctp_ep, stcb, m, iphlen, + src, dst, sh, op_err, +#if defined(__FreeBSD__) && !defined(__Userspace__) + mflowtype, mflowid, +#endif + vrf_id, net->port); return (NULL); } /* respond with a COOKIE-ACK */ @@ -1821,6 +1724,7 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, */ if (how_indx < sizeof(asoc->cookie_how)) asoc->cookie_how[how_indx] = 6; + SCTP_TCB_UNLOCK(stcb); return (NULL); } /* If nat support, and the below and stcb is established, @@ -1842,10 +1746,11 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, */ op_err = sctp_generate_cause(SCTP_CAUSE_NAT_COLLIDING_STATE, ""); sctp_send_abort(m, iphlen, src, dst, sh, 0, op_err, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) mflowtype, mflowid, inp->fibnum, #endif vrf_id, port); + SCTP_TCB_UNLOCK(stcb); return (NULL); } if ((ntohl(initack_cp->init.initiate_tag) == asoc->my_vtag) && @@ -1875,6 +1780,7 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, if (how_indx < sizeof(asoc->cookie_how)) asoc->cookie_how[how_indx] = 7; + SCTP_TCB_UNLOCK(stcb); return (NULL); } if (how_indx < sizeof(asoc->cookie_how)) @@ -1890,10 +1796,12 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, if (stcb->asoc.sctp_autoclose_ticks && sctp_is_feature_on(inp, SCTP_PCB_FLAGS_AUTOCLOSE)) { sctp_timer_start(SCTP_TIMER_TYPE_AUTOCLOSE, inp, stcb, - NULL); + NULL); } asoc->my_rwnd = ntohl(initack_cp->init.a_rwnd); - asoc->pre_open_streams = ntohs(initack_cp->init.num_outbound_streams); + if (asoc->pre_open_streams < asoc->streamoutcnt) { + asoc->pre_open_streams = asoc->streamoutcnt; + } if (ntohl(init_cp->init.initiate_tag) != asoc->peer_vtag) { /* Ok the peer probably discarded our @@ -1903,8 +1811,8 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, * kick us so it COULD still take a timeout * to move these.. but it can't hurt to mark them. */ - struct sctp_tmit_chunk *chk; - TAILQ_FOREACH(chk, &stcb->asoc.sent_queue, sctp_next) { + + TAILQ_FOREACH(chk, &stcb->asoc.sent_queue, sctp_next) { if (chk->sent < SCTP_DATAGRAM_RESEND) { chk->sent = SCTP_DATAGRAM_RESEND; sctp_flight_size_decrease(chk); @@ -1913,20 +1821,37 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, spec_flag++; } } - } /* process the INIT info (peer's info) */ - retval = sctp_process_init(init_cp, stcb); - if (retval < 0) { + if (sctp_process_init(init_cp, stcb) < 0) { if (how_indx < sizeof(asoc->cookie_how)) asoc->cookie_how[how_indx] = 9; + op_err = sctp_generate_cause(SCTP_CAUSE_OUT_OF_RESC, ""); + SCTPDBG(SCTP_DEBUG_INPUT1, "sctp_process_init() failed\n"); + sctp_abort_association(stcb->sctp_ep, stcb, m, iphlen, + src, dst, sh, op_err, +#if defined(__FreeBSD__) && !defined(__Userspace__) + mflowtype, mflowid, +#endif + vrf_id, net->port); return (NULL); } - if (sctp_load_addresses_from_init(stcb, m, - init_offset + sizeof(struct sctp_init_chunk), - initack_offset, src, dst, init_src, stcb->asoc.port)) { + if ((retval = sctp_load_addresses_from_init(stcb, m, + init_offset + sizeof(struct sctp_init_chunk), + initack_offset, src, dst, init_src, stcb->asoc.port)) < 0) { if (how_indx < sizeof(asoc->cookie_how)) asoc->cookie_how[how_indx] = 10; + op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code), + "Problem with address parameters"); + SCTPDBG(SCTP_DEBUG_INPUT1, + "Load addresses from INIT causes an abort %d\n", + retval); + sctp_abort_association(stcb->sctp_ep, stcb, m, iphlen, + src, dst, sh, op_err, +#if defined(__FreeBSD__) && !defined(__Userspace__) + mflowtype, mflowid, +#endif + vrf_id, net->port); return (NULL); } if ((SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_WAIT) || @@ -1936,25 +1861,25 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, if (((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) && (!SCTP_IS_LISTENING(inp))) { -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) struct socket *so; #endif - stcb->sctp_ep->sctp_flags |= - SCTP_PCB_FLAGS_CONNECTED; -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) + stcb->sctp_ep->sctp_flags |= SCTP_PCB_FLAGS_CONNECTED; +#if defined(__APPLE__) && !defined(__Userspace__) so = SCTP_INP_SO(stcb->sctp_ep); atomic_add_int(&stcb->asoc.refcnt, 1); SCTP_TCB_UNLOCK(stcb); SCTP_SOCKET_LOCK(so, 1); SCTP_TCB_LOCK(stcb); - atomic_add_int(&stcb->asoc.refcnt, -1); + atomic_subtract_int(&stcb->asoc.refcnt, 1); if (stcb->asoc.state & SCTP_STATE_CLOSED_SOCKET) { + SCTP_TCB_UNLOCK(stcb); SCTP_SOCKET_UNLOCK(so, 1); return (NULL); } #endif soisconnected(stcb->sctp_socket); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_UNLOCK(so, 1); #endif } @@ -1971,7 +1896,7 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, SCTP_SET_STATE(stcb, SCTP_STATE_OPEN); if (asoc->state & SCTP_STATE_SHUTDOWN_PENDING) { sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, - stcb->sctp_ep, stcb, asoc->primary_destination); + stcb->sctp_ep, stcb, NULL); } sctp_stop_all_cookie_timers(stcb); sctp_toss_old_cookies(stcb, asoc); @@ -1996,24 +1921,30 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, cookie->tie_tag_peer_vtag == asoc->peer_vtag_nonce && cookie->tie_tag_peer_vtag != 0) { struct sctpasochead *head; -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) struct socket *so; #endif if (asoc->peer_supports_nat) { + struct sctp_tcb *local_stcb; + /* This is a gross gross hack. * Just call the cookie_new code since we * are allowing a duplicate association. * I hope this works... */ - return (sctp_process_cookie_new(m, iphlen, offset, src, dst, - sh, cookie, cookie_len, - inp, netp, init_src,notification, - auth_skipped, auth_offset, auth_len, -#if defined(__FreeBSD__) - mflowtype, mflowid, + local_stcb = sctp_process_cookie_new(m, iphlen, offset, src, dst, + sh, cookie, cookie_len, + inp, netp, init_src,notification, + auth_skipped, auth_offset, auth_len, +#if defined(__FreeBSD__) && !defined(__Userspace__) + mflowtype, mflowid, #endif - vrf_id, port)); + vrf_id, port); + if (local_stcb == NULL) { + SCTP_TCB_UNLOCK(stcb); + } + return (local_stcb); } /* * case A in Section 5.2.4 Table 2: XXMM (peer restarted) @@ -2021,11 +1952,7 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, /* temp code */ if (how_indx < sizeof(asoc->cookie_how)) asoc->cookie_how[how_indx] = 12; - sctp_timer_stop(SCTP_TIMER_TYPE_INIT, inp, stcb, net, - SCTP_FROM_SCTP_INPUT + SCTP_LOC_16); - sctp_timer_stop(SCTP_TIMER_TYPE_HEARTBEAT, inp, stcb, net, - SCTP_FROM_SCTP_INPUT + SCTP_LOC_17); - + sctp_stop_association_timers(stcb, false); /* notify upper layer */ *notification = SCTP_NOTIFY_ASSOC_RESTART; atomic_add_int(&stcb->asoc.refcnt, 1); @@ -2042,23 +1969,26 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, if (asoc->state & SCTP_STATE_SHUTDOWN_PENDING) { SCTP_SET_STATE(stcb, SCTP_STATE_OPEN); sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, - stcb->sctp_ep, stcb, asoc->primary_destination); + stcb->sctp_ep, stcb, NULL); } else if (SCTP_GET_STATE(stcb) != SCTP_STATE_SHUTDOWN_SENT) { /* move to OPEN state, if not in SHUTDOWN_SENT */ SCTP_SET_STATE(stcb, SCTP_STATE_OPEN); } - asoc->pre_open_streams = - ntohs(initack_cp->init.num_outbound_streams); + if (asoc->pre_open_streams < asoc->streamoutcnt) { + asoc->pre_open_streams = asoc->streamoutcnt; + } asoc->init_seq_number = ntohl(initack_cp->init.initial_tsn); asoc->sending_seq = asoc->asconf_seq_out = asoc->str_reset_seq_out = asoc->init_seq_number; asoc->asconf_seq_out_acked = asoc->asconf_seq_out - 1; - asoc->asconf_seq_in = asoc->last_acked_seq = asoc->init_seq_number - 1; - asoc->str_reset_seq_in = asoc->init_seq_number; - asoc->advanced_peer_ack_point = asoc->last_acked_seq; + asoc->send_sack = 1; + asoc->data_pkts_seen = 0; + asoc->last_data_chunk_from = NULL; + asoc->last_control_chunk_from = NULL; + asoc->last_net_cmt_send_started = NULL; if (asoc->mapping_array) { memset(asoc->mapping_array, 0, asoc->mapping_array_size); @@ -2068,18 +1998,18 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, asoc->mapping_array_size); } SCTP_TCB_UNLOCK(stcb); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) so = SCTP_INP_SO(stcb->sctp_ep); SCTP_SOCKET_LOCK(so, 1); #endif SCTP_INP_INFO_WLOCK(); SCTP_INP_WLOCK(stcb->sctp_ep); SCTP_TCB_LOCK(stcb); - atomic_add_int(&stcb->asoc.refcnt, -1); + atomic_subtract_int(&stcb->asoc.refcnt, 1); /* send up all the data */ SCTP_TCB_SEND_LOCK(stcb); - sctp_report_all_outbound(stcb, 0, 1, SCTP_SO_LOCKED); + sctp_report_all_outbound(stcb, 0, SCTP_SO_LOCKED); for (i = 0; i < stcb->asoc.streamoutcnt; i++) { stcb->asoc.strmout[i].chunks_on_queues = 0; #if defined(SCTP_DETAILED_STR_STATS) @@ -2091,11 +2021,65 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, asoc->strmout[i].abandoned_sent[0] = 0; asoc->strmout[i].abandoned_unsent[0] = 0; #endif - stcb->asoc.strmout[i].sid = i; stcb->asoc.strmout[i].next_mid_ordered = 0; stcb->asoc.strmout[i].next_mid_unordered = 0; + stcb->asoc.strmout[i].sid = i; stcb->asoc.strmout[i].last_msg_incomplete = 0; } + TAILQ_FOREACH_SAFE(strrst, &asoc->resetHead, next_resp, nstrrst) { + TAILQ_REMOVE(&asoc->resetHead, strrst, next_resp); + SCTP_FREE(strrst, SCTP_M_STRESET); + } + TAILQ_FOREACH_SAFE(sq, &asoc->pending_reply_queue, next, nsq) { + TAILQ_REMOVE(&asoc->pending_reply_queue, sq, next); + if (sq->data) { + sctp_m_freem(sq->data); + sq->data = NULL; + } + sctp_free_remote_addr(sq->whoFrom); + sq->whoFrom = NULL; + sq->stcb = NULL; + sctp_free_a_readq(stcb, sq); + } + TAILQ_FOREACH_SAFE(chk, &asoc->control_send_queue, sctp_next, nchk) { + TAILQ_REMOVE(&asoc->control_send_queue, chk, sctp_next); + if (chk->data) { + sctp_m_freem(chk->data); + chk->data = NULL; + } + if (chk->holds_key_ref) + sctp_auth_key_release(stcb, chk->auth_keyid, SCTP_SO_LOCKED); + sctp_free_remote_addr(chk->whoTo); + SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_chunk), chk); + SCTP_DECR_CHK_COUNT(); + } + asoc->ctrl_queue_cnt = 0; + asoc->str_reset = NULL; + asoc->stream_reset_outstanding = 0; + TAILQ_FOREACH_SAFE(chk, &asoc->asconf_send_queue, sctp_next, nchk) { + TAILQ_REMOVE(&asoc->asconf_send_queue, chk, sctp_next); + if (chk->data) { + sctp_m_freem(chk->data); + chk->data = NULL; + } + if (chk->holds_key_ref) + sctp_auth_key_release(stcb, chk->auth_keyid, SCTP_SO_LOCKED); + sctp_free_remote_addr(chk->whoTo); + SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_chunk), chk); + SCTP_DECR_CHK_COUNT(); + } + TAILQ_FOREACH_SAFE(aparam, &asoc->asconf_queue, next, naparam) { + TAILQ_REMOVE(&asoc->asconf_queue, aparam, next); + SCTP_FREE(aparam,SCTP_M_ASC_ADDR); + } + TAILQ_FOREACH_SAFE(aack, &asoc->asconf_ack_sent, next, naack) { + TAILQ_REMOVE(&asoc->asconf_ack_sent, aack, next); + if (aack->data != NULL) { + sctp_m_freem(aack->data); + } + SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_asconf_ack), aack); + } + /* process the INIT-ACK info (my info) */ asoc->my_vtag = ntohl(initack_cp->init.initiate_tag); asoc->my_rwnd = ntohl(initack_cp->init.a_rwnd); @@ -2104,7 +2088,7 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, LIST_REMOVE(stcb, sctp_asocs); /* re-insert to new vtag position */ head = &SCTP_BASE_INFO(sctp_asochash)[SCTP_PCBHASH_ASOC(stcb->asoc.my_vtag, - SCTP_BASE_INFO(hashasocmark))]; + SCTP_BASE_INFO(hashasocmark))]; /* * put it in the bucket in the vtag hash of assoc's for the * system @@ -2114,17 +2098,23 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, SCTP_TCB_SEND_UNLOCK(stcb); SCTP_INP_WUNLOCK(stcb->sctp_ep); SCTP_INP_INFO_WUNLOCK(); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_UNLOCK(so, 1); #endif asoc->total_flight = 0; asoc->total_flight_count = 0; /* process the INIT info (peer's info) */ - retval = sctp_process_init(init_cp, stcb); - if (retval < 0) { + if (sctp_process_init(init_cp, stcb) < 0) { if (how_indx < sizeof(asoc->cookie_how)) asoc->cookie_how[how_indx] = 13; - + op_err = sctp_generate_cause(SCTP_CAUSE_OUT_OF_RESC, ""); + SCTPDBG(SCTP_DEBUG_INPUT1, "sctp_process_init() failed\n"); + sctp_abort_association(stcb->sctp_ep, stcb, m, iphlen, + src, dst, sh, op_err, +#if defined(__FreeBSD__) && !defined(__Userspace__) + mflowtype, mflowid, +#endif + vrf_id, net->port); return (NULL); } /* @@ -2133,30 +2123,41 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, */ net->hb_responded = 1; - if (sctp_load_addresses_from_init(stcb, m, - init_offset + sizeof(struct sctp_init_chunk), - initack_offset, src, dst, init_src, stcb->asoc.port)) { + if ((retval = sctp_load_addresses_from_init(stcb, m, + init_offset + sizeof(struct sctp_init_chunk), + initack_offset, src, dst, init_src, stcb->asoc.port)) < 0) { if (how_indx < sizeof(asoc->cookie_how)) asoc->cookie_how[how_indx] = 14; - + op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code), + "Problem with address parameters"); + SCTPDBG(SCTP_DEBUG_INPUT1, + "Load addresses from INIT causes an abort %d\n", + retval); + sctp_abort_association(stcb->sctp_ep, stcb, m, iphlen, + src, dst, sh, op_err, +#if defined(__FreeBSD__) && !defined(__Userspace__) + mflowtype, mflowid, +#endif + vrf_id, net->port); return (NULL); } /* respond with a COOKIE-ACK */ - sctp_stop_all_cookie_timers(stcb); - sctp_toss_old_cookies(stcb, asoc); sctp_send_cookie_ack(stcb); if (how_indx < sizeof(asoc->cookie_how)) asoc->cookie_how[how_indx] = 15; - + if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_AUTOCLOSE) && + (asoc->sctp_autoclose_ticks > 0)) { + sctp_timer_start(SCTP_TIMER_TYPE_AUTOCLOSE, inp, stcb, NULL); + } return (stcb); } if (how_indx < sizeof(asoc->cookie_how)) asoc->cookie_how[how_indx] = 16; /* all other cases... */ + SCTP_TCB_UNLOCK(stcb); return (NULL); } - /* * handle a state cookie for a new association m: input packet mbuf chain-- * assumes a pullup on IP/SCTP/COOKIE-ECHO chunk note: this is a "split" mbuf @@ -2171,7 +2172,7 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset, struct sctp_inpcb *inp, struct sctp_nets **netp, struct sockaddr *init_src, int *notification, int auth_skipped, uint32_t auth_offset, uint32_t auth_len, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) uint8_t mflowtype, uint32_t mflowid, #endif uint32_t vrf_id, uint16_t port) @@ -2182,10 +2183,9 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset, union sctp_sockstore store; struct sctp_association *asoc; int init_offset, initack_offset, initack_limit; - int retval; int error = 0; - uint8_t auth_chunk_buf[SCTP_PARAM_BUFFER_SIZE]; -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) + uint8_t auth_chunk_buf[SCTP_CHUNK_BUFFER_SIZE]; +#if defined(__APPLE__) && !defined(__Userspace__) struct socket *so; so = SCTP_INP_SO(inp); @@ -2246,12 +2246,13 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset, * Since we are getting a cookie, we cannot be unbound. */ stcb = sctp_aloc_assoc(inp, init_src, &error, - ntohl(initack_cp->init.initiate_tag), vrf_id, + ntohl(initack_cp->init.initiate_tag), + ntohl(initack_cp->init.initial_tsn), vrf_id, ntohs(initack_cp->init.num_outbound_streams), port, -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 +#if defined(__FreeBSD__) && !defined(__Userspace__) (struct thread *)NULL, -#elif defined(__Windows__) +#elif defined(_WIN32) && !defined(__Userspace__) (PKTHREAD)NULL, #else (struct proc *)NULL, @@ -2266,16 +2267,12 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset, op_err = sctp_generate_cause(SCTP_CAUSE_OUT_OF_RESC, ""); sctp_abort_association(inp, (struct sctp_tcb *)NULL, m, iphlen, src, dst, sh, op_err, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) mflowtype, mflowid, #endif vrf_id, port); return (NULL); } - /* get the correct sctp_nets */ - if (netp) - *netp = sctp_findnet(stcb, init_src); - asoc = &stcb->asoc; /* get scope variables out of cookie */ asoc->scope.ipv4_local_scope = cookie->ipv4_scope; @@ -2301,11 +2298,11 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset, op_err = sctp_generate_cause(SCTP_CAUSE_OUT_OF_RESC, ""); sctp_abort_association(inp, (struct sctp_tcb *)NULL, m, iphlen, src, dst, sh, op_err, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) mflowtype, mflowid, #endif vrf_id, port); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) atomic_add_int(&stcb->asoc.refcnt, 1); SCTP_TCB_UNLOCK(stcb); SCTP_SOCKET_LOCK(so, 1); @@ -2314,30 +2311,17 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset, #endif (void)sctp_free_assoc(inp, stcb, SCTP_NORMAL_PROC, SCTP_FROM_SCTP_INPUT + SCTP_LOC_18); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_UNLOCK(so, 1); #endif return (NULL); } /* process the INIT-ACK info (my info) */ - asoc->my_vtag = ntohl(initack_cp->init.initiate_tag); asoc->my_rwnd = ntohl(initack_cp->init.a_rwnd); - asoc->pre_open_streams = ntohs(initack_cp->init.num_outbound_streams); - asoc->init_seq_number = ntohl(initack_cp->init.initial_tsn); - asoc->sending_seq = asoc->asconf_seq_out = asoc->str_reset_seq_out = asoc->init_seq_number; - asoc->asconf_seq_out_acked = asoc->asconf_seq_out - 1; - asoc->asconf_seq_in = asoc->last_acked_seq = asoc->init_seq_number - 1; - asoc->str_reset_seq_in = asoc->init_seq_number; - - asoc->advanced_peer_ack_point = asoc->last_acked_seq; /* process the INIT info (peer's info) */ - if (netp) - retval = sctp_process_init(init_cp, stcb); - else - retval = 0; - if (retval < 0) { -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) + if (sctp_process_init(init_cp, stcb) < 0) { +#if defined(__APPLE__) && !defined(__Userspace__) atomic_add_int(&stcb->asoc.refcnt, 1); SCTP_TCB_UNLOCK(stcb); SCTP_SOCKET_LOCK(so, 1); @@ -2346,16 +2330,16 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset, #endif (void)sctp_free_assoc(inp, stcb, SCTP_NORMAL_PROC, SCTP_FROM_SCTP_INPUT + SCTP_LOC_19); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_UNLOCK(so, 1); #endif return (NULL); } /* load all addresses */ if (sctp_load_addresses_from_init(stcb, m, - init_offset + sizeof(struct sctp_init_chunk), initack_offset, - src, dst, init_src, port)) { -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) + init_offset + sizeof(struct sctp_init_chunk), + initack_offset, src, dst, init_src, port) < 0) { +#if defined(__APPLE__) && !defined(__Userspace__) atomic_add_int(&stcb->asoc.refcnt, 1); SCTP_TCB_UNLOCK(stcb); SCTP_SOCKET_LOCK(so, 1); @@ -2364,7 +2348,7 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset, #endif (void)sctp_free_assoc(inp, stcb, SCTP_NORMAL_PROC, SCTP_FROM_SCTP_INPUT + SCTP_LOC_20); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_UNLOCK(so, 1); #endif return (NULL); @@ -2379,13 +2363,16 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset, if (auth_skipped) { struct sctp_auth_chunk *auth; - auth = (struct sctp_auth_chunk *) - sctp_m_getptr(m, auth_offset, auth_len, auth_chunk_buf); + if (auth_len <= SCTP_CHUNK_BUFFER_SIZE) { + auth = (struct sctp_auth_chunk *)sctp_m_getptr(m, auth_offset, auth_len, auth_chunk_buf); + } else { + auth = NULL; + } if ((auth == NULL) || sctp_handle_auth(stcb, auth, m, auth_offset)) { /* auth HMAC failed, dump the assoc and packet */ SCTPDBG(SCTP_DEBUG_AUTH1, "COOKIE-ECHO: AUTH failed\n"); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) atomic_add_int(&stcb->asoc.refcnt, 1); SCTP_TCB_UNLOCK(stcb); SCTP_SOCKET_LOCK(so, 1); @@ -2394,7 +2381,7 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset, #endif (void)sctp_free_assoc(inp, stcb, SCTP_NORMAL_PROC, SCTP_FROM_SCTP_INPUT + SCTP_LOC_21); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_UNLOCK(so, 1); #endif return (NULL); @@ -2451,7 +2438,7 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset, break; #endif default: -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) atomic_add_int(&stcb->asoc.refcnt, 1); SCTP_TCB_UNLOCK(stcb); SCTP_SOCKET_LOCK(so, 1); @@ -2460,7 +2447,7 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset, #endif (void)sctp_free_assoc(inp, stcb, SCTP_NORMAL_PROC, SCTP_FROM_SCTP_INPUT + SCTP_LOC_22); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_UNLOCK(so, 1); #endif return (NULL); @@ -2471,7 +2458,7 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset, SCTP_SET_STATE(stcb, SCTP_STATE_OPEN); if (asoc->state & SCTP_STATE_SHUTDOWN_PENDING) { sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, - stcb->sctp_ep, stcb, asoc->primary_destination); + stcb->sctp_ep, stcb, NULL); } sctp_stop_all_cookie_timers(stcb); SCTP_STAT_INCR_COUNTER32(sctps_passiveestab); @@ -2489,9 +2476,11 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset, * INIT/INIT-ACK/COOKIE arrived. But of course then it * should have went to the other code.. not here.. oh well.. * a bit of protection is worth having.. + * + * XXXMJ unlocked */ stcb->sctp_ep->sctp_flags |= SCTP_PCB_FLAGS_CONNECTED; -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) atomic_add_int(&stcb->asoc.refcnt, 1); SCTP_TCB_UNLOCK(stcb); SCTP_SOCKET_LOCK(so, 1); @@ -2503,7 +2492,7 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset, } #endif soisconnected(stcb->sctp_socket); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_UNLOCK(so, 1); #endif } else if ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) && @@ -2515,19 +2504,21 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset, */ ; } - /* since we did not send a HB make sure we don't double things */ - if ((netp) && (*netp)) - (*netp)->hb_responded = 1; - if (stcb->asoc.sctp_autoclose_ticks && sctp_is_feature_on(inp, SCTP_PCB_FLAGS_AUTOCLOSE)) { sctp_timer_start(SCTP_TIMER_TYPE_AUTOCLOSE, inp, stcb, NULL); } (void)SCTP_GETTIME_TIMEVAL(&stcb->asoc.time_entered); - if ((netp != NULL) && (*netp != NULL)) { + *netp = sctp_findnet(stcb, init_src); + if (*netp != NULL) { struct timeval old; - /* calculate the RTT and set the encaps port */ + /* + * Since we did not send a HB, make sure we don't double + * things. + */ + (*netp)->hb_responded = 1; + /* Calculate the RTT. */ old.tv_sec = cookie->time_entered.tv_sec; old.tv_usec = cookie->time_entered.tv_usec; sctp_calculate_rto(stcb, asoc, *netp, &old, SCTP_RTT_FROM_NON_DATA); @@ -2545,7 +2536,6 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset, &store.sa, cookie->local_scope, cookie->site_scope, cookie->ipv4_scope, cookie->loopback_scope); - return (stcb); } @@ -2573,7 +2563,7 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset, struct sctp_inpcb **inp_p, struct sctp_tcb **stcb, struct sctp_nets **netp, int auth_skipped, uint32_t auth_offset, uint32_t auth_len, struct sctp_tcb **locked_tcb, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) uint8_t mflowtype, uint32_t mflowid, #endif uint32_t vrf_id, uint16_t port) @@ -2586,11 +2576,15 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset, struct mbuf *m_sig; uint8_t calc_sig[SCTP_SIGNATURE_SIZE], tmp_sig[SCTP_SIGNATURE_SIZE]; uint8_t *sig; +#if defined(__Userspace__) && defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION) + uint8_t cookie_ok = 1; +#else uint8_t cookie_ok = 0; +#endif unsigned int sig_offset, cookie_offset; unsigned int cookie_len; struct timeval now; - struct timeval time_expires; + struct timeval time_entered, time_expires; int notification = 0; struct sctp_nets *netl; int had_a_existing_tcb = 0; @@ -2633,6 +2627,27 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset, */ return (NULL); } +#if defined(__Userspace__) + /* + * Recover the AF_CONN addresses within the cookie. + * This needs to be done in the buffer provided for later processing + * of the cookie and in the mbuf chain for HMAC validation. + */ + if ((cookie->addr_type == SCTP_CONN_ADDRESS) && (src->sa_family == AF_CONN)) { + struct sockaddr_conn *sconnp = (struct sockaddr_conn *)src; + + memcpy(cookie->address, &sconnp->sconn_addr , sizeof(void *)); + m_copyback(m, cookie_offset + offsetof(struct sctp_state_cookie, address), + (int)sizeof(void *), (caddr_t)&sconnp->sconn_addr); + } + if ((cookie->laddr_type == SCTP_CONN_ADDRESS) && (dst->sa_family == AF_CONN)) { + struct sockaddr_conn *sconnp = (struct sockaddr_conn *)dst; + + memcpy(cookie->laddress, &sconnp->sconn_addr , sizeof(void *)); + m_copyback(m, cookie_offset + offsetof(struct sctp_state_cookie, laddress), + (int)sizeof(void *), (caddr_t)&sconnp->sconn_addr); + } +#endif /* * split off the signature into its own mbuf (since it should not be * calculated in the sctp_hmac_m() call). @@ -2721,14 +2736,35 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset, return (NULL); } - /* - * check the cookie timestamps to be sure it's not stale - */ + if (sctp_ticks_to_msecs(cookie->cookie_life) > SCTP_MAX_COOKIE_LIFE) { + SCTPDBG(SCTP_DEBUG_INPUT2, "handle_cookie_echo: Invalid cookie lifetime\n"); + return (NULL); + } + time_entered.tv_sec = cookie->time_entered.tv_sec; + time_entered.tv_usec = cookie->time_entered.tv_usec; + if ((time_entered.tv_sec < 0) || + (time_entered.tv_usec < 0) || + (time_entered.tv_usec >= 1000000)) { + /* Invalid time stamp. Cookie must have been modified. */ + SCTPDBG(SCTP_DEBUG_INPUT2, "handle_cookie_echo: Invalid time stamp\n"); + return (NULL); + } (void)SCTP_GETTIME_TIMEVAL(&now); - /* Expire time is in Ticks, so we convert to seconds */ - time_expires.tv_sec = cookie->time_entered.tv_sec + TICKS_TO_SEC(cookie->cookie_life); - time_expires.tv_usec = cookie->time_entered.tv_usec; -#ifndef __FreeBSD__ +#if !(defined(__FreeBSD__) && !defined(__Userspace__)) + if (timercmp(&now, &time_entered, <)) { +#else + if (timevalcmp(&now, &time_entered, <)) { +#endif + SCTPDBG(SCTP_DEBUG_INPUT2, "handle_cookie_echo: cookie generated in the future!\n"); + return (NULL); + } + /* + * Check the cookie timestamps to be sure it's not stale. + * cookie_life is in ticks, so we convert to seconds. + */ + time_expires.tv_sec = time_entered.tv_sec + sctp_ticks_to_secs(cookie->cookie_life); + time_expires.tv_usec = time_entered.tv_usec; +#if !(defined(__FreeBSD__) && !defined(__Userspace__)) if (timercmp(&now, &time_expires, >)) #else if (timevalcmp(&now, &time_expires, >)) @@ -2750,9 +2786,8 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset, SCTP_BUF_LEN(op_err) = sizeof(struct sctp_error_stale_cookie); cause = mtod(op_err, struct sctp_error_stale_cookie *); cause->cause.code = htons(SCTP_CAUSE_STALE_COOKIE); - cause->cause.length = htons((sizeof(struct sctp_paramhdr) + - (sizeof(uint32_t)))); -#ifndef __FreeBSD__ + cause->cause.length = htons(sizeof(struct sctp_error_stale_cookie)); +#if !(defined(__FreeBSD__) && !defined(__Userspace__)) timersub(&now, &time_expires, &diff); #else diff = now; @@ -2761,16 +2796,16 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset, if ((uint32_t)diff.tv_sec > UINT32_MAX / 1000000) { staleness = UINT32_MAX; } else { - staleness = diff.tv_sec * 1000000; + staleness = (uint32_t)diff.tv_sec * 1000000; } if (UINT32_MAX - staleness >= (uint32_t)diff.tv_usec) { - staleness += diff.tv_usec; + staleness += (uint32_t)diff.tv_usec; } else { staleness = UINT32_MAX; } cause->stale_time = htonl(staleness); sctp_send_operr_to(src, dst, sh, cookie->peers_vtag, op_err, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) mflowtype, mflowid, l_inp->fibnum, #endif vrf_id, port); @@ -2873,7 +2908,7 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset, cookie, cookie_len, *inp_p, netp, to, ¬ification, auth_skipped, auth_offset, auth_len, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) mflowtype, mflowid, #endif vrf_id, port); @@ -2882,19 +2917,22 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset, had_a_existing_tcb = 1; *stcb = sctp_process_cookie_existing(m, iphlen, offset, src, dst, sh, - cookie, cookie_len, *inp_p, *stcb, netp, to, - ¬ification, auth_skipped, auth_offset, auth_len, -#if defined(__FreeBSD__) + cookie, cookie_len, *inp_p, *stcb, netp, to, + ¬ification, auth_skipped, auth_offset, auth_len, +#if defined(__FreeBSD__) && !defined(__Userspace__) mflowtype, mflowid, #endif vrf_id, port); + if (*stcb == NULL) { + *locked_tcb = NULL; + } } if (*stcb == NULL) { /* still no TCB... must be bad cookie-echo */ return (NULL); } -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (*netp != NULL) { (*netp)->flowtype = mflowtype; (*netp)->flowid = mflowid; @@ -2949,36 +2987,23 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset, return (m); } oso = (*inp_p)->sctp_socket; -#if (defined(__FreeBSD__) && __FreeBSD_version < 700000) - /* - * We do this to keep the sockets side happy during - * the sonewcon ONLY. - */ - NET_LOCK_GIANT(); -#endif atomic_add_int(&(*stcb)->asoc.refcnt, 1); SCTP_TCB_UNLOCK((*stcb)); -#if defined(__FreeBSD__) && __FreeBSD_version >= 801000 +#if defined(__FreeBSD__) && !defined(__Userspace__) CURVNET_SET(oso->so_vnet); #endif -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_LOCK(oso, 1); #endif so = sonewconn(oso, 0 -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) ,NULL -#endif -#ifdef __Panda__ - ,NULL , (*inp_p)->def_vrf_id #endif ); -#if (defined(__FreeBSD__) && __FreeBSD_version < 700000) - NET_UNLOCK_GIANT(); -#endif -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_UNLOCK(oso, 1); #endif -#if defined(__FreeBSD__) && __FreeBSD_version >= 801000 +#if defined(__FreeBSD__) && !defined(__Userspace__) CURVNET_RESTORE(); #endif SCTP_TCB_LOCK((*stcb)); @@ -2986,7 +3011,7 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset, if (so == NULL) { struct mbuf *op_err; -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) struct socket *pcb_so; #endif /* Too many sockets */ @@ -2994,11 +3019,11 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset, op_err = sctp_generate_cause(SCTP_CAUSE_OUT_OF_RESC, ""); sctp_abort_association(*inp_p, NULL, m, iphlen, src, dst, sh, op_err, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) mflowtype, mflowid, #endif vrf_id, port); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) pcb_so = SCTP_INP_SO(*inp_p); atomic_add_int(&(*stcb)->asoc.refcnt, 1); SCTP_TCB_UNLOCK((*stcb)); @@ -3008,7 +3033,7 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset, #endif (void)sctp_free_assoc(*inp_p, *stcb, SCTP_NORMAL_PROC, SCTP_FROM_SCTP_INPUT + SCTP_LOC_23); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_UNLOCK(pcb_so, 1); #endif return (NULL); @@ -3043,7 +3068,6 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset, inp->sctp_context = (*inp_p)->sctp_context; inp->local_strreset_support = (*inp_p)->local_strreset_support; inp->fibnum = (*inp_p)->fibnum; - inp->inp_starting_point_for_iterator = NULL; #if defined(__Userspace__) inp->ulp_info = (*inp_p)->ulp_info; inp->recv_callback = (*inp_p)->recv_callback; @@ -3079,7 +3103,7 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset, atomic_add_int(&(*stcb)->asoc.refcnt, 1); SCTP_TCB_UNLOCK((*stcb)); -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) sctp_pull_off_control_to_new_inp((*inp_p), inp, *stcb, 0); #else @@ -3088,7 +3112,6 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset, SCTP_TCB_LOCK((*stcb)); atomic_subtract_int(&(*stcb)->asoc.refcnt, 1); - /* now we must check to see if we were aborted while * the move was going on and the lock/unlock happened. */ @@ -3111,13 +3134,13 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset, } /* Pull it from the incomplete queue and wake the guy */ -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) atomic_add_int(&(*stcb)->asoc.refcnt, 1); SCTP_TCB_UNLOCK((*stcb)); SCTP_SOCKET_LOCK(so, 1); #endif soisconnected(so); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_TCB_LOCK((*stcb)); atomic_subtract_int(&(*stcb)->asoc.refcnt, 1); SCTP_SOCKET_UNLOCK(so, 1); @@ -3141,6 +3164,7 @@ sctp_handle_cookie_ack(struct sctp_cookie_ack_chunk *cp SCTP_UNUSED, { /* cp must not be used, others call this without a c-ack :-) */ struct sctp_association *asoc; + struct sctp_tmit_chunk *chk; SCTPDBG(SCTP_DEBUG_INPUT2, "sctp_handle_cookie_ack: handling COOKIE-ACK\n"); @@ -3166,8 +3190,7 @@ sctp_handle_cookie_ack(struct sctp_cookie_ack_chunk *cp SCTP_UNUSED, sctp_start_net_timers(stcb); if (asoc->state & SCTP_STATE_SHUTDOWN_PENDING) { sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, - stcb->sctp_ep, stcb, asoc->primary_destination); - + stcb->sctp_ep, stcb, NULL); } /* update RTO */ SCTP_STAT_INCR_COUNTER32(sctps_activeestab); @@ -3180,12 +3203,12 @@ sctp_handle_cookie_ack(struct sctp_cookie_ack_chunk *cp SCTP_UNUSED, sctp_ulp_notify(SCTP_NOTIFY_ASSOC_UP, stcb, 0, NULL, SCTP_SO_NOT_LOCKED); if ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) { -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) struct socket *so; #endif stcb->sctp_ep->sctp_flags |= SCTP_PCB_FLAGS_CONNECTED; -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) so = SCTP_INP_SO(stcb->sctp_ep); atomic_add_int(&stcb->asoc.refcnt, 1); SCTP_TCB_UNLOCK(stcb); @@ -3196,7 +3219,7 @@ sctp_handle_cookie_ack(struct sctp_cookie_ack_chunk *cp SCTP_UNUSED, if ((stcb->asoc.state & SCTP_STATE_CLOSED_SOCKET) == 0) { soisconnected(stcb->sctp_socket); } -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_UNLOCK(so, 1); #endif } @@ -3216,7 +3239,6 @@ sctp_handle_cookie_ack(struct sctp_cookie_ack_chunk *cp SCTP_UNUSED, sctp_timer_start(SCTP_TIMER_TYPE_HEARTBEAT, stcb->sctp_ep, stcb, net); - if (stcb->asoc.sctp_autoclose_ticks && sctp_is_feature_on(stcb->sctp_ep, SCTP_PCB_FLAGS_AUTOCLOSE)) { sctp_timer_start(SCTP_TIMER_TYPE_AUTOCLOSE, @@ -3243,11 +3265,13 @@ sctp_handle_cookie_ack(struct sctp_cookie_ack_chunk *cp SCTP_UNUSED, closed_socket: /* Toss the cookie if I can */ sctp_toss_old_cookies(stcb, asoc); - if (!TAILQ_EMPTY(&asoc->sent_queue)) { - /* Restart the timer if we have pending data */ - struct sctp_tmit_chunk *chk; - - chk = TAILQ_FIRST(&asoc->sent_queue); + /* Restart the timer if we have pending data */ + TAILQ_FOREACH(chk, &asoc->sent_queue, sctp_next) { + if (chk->whoTo != NULL) { + break; + } + } + if (chk != NULL) { sctp_timer_start(SCTP_TIMER_TYPE_SEND, stcb->sctp_ep, stcb, chk->whoTo); } } @@ -3265,10 +3289,6 @@ sctp_handle_ecn_echo(struct sctp_ecne_chunk *cp, unsigned int pkt_cnt; len = ntohs(cp->ch.chunk_length); - if ((len != sizeof(struct sctp_ecne_chunk)) && - (len != sizeof(struct old_sctp_ecne_chunk))) { - return; - } if (len == sizeof(struct old_sctp_ecne_chunk)) { /* Its the old format */ memcpy(&bkup, cp, sizeof(struct old_sctp_ecne_chunk)); @@ -3415,7 +3435,7 @@ static void sctp_handle_shutdown_complete(struct sctp_shutdown_complete_chunk *cp SCTP_UNUSED, struct sctp_tcb *stcb, struct sctp_nets *net) { -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) struct socket *so; #endif @@ -3450,7 +3470,7 @@ sctp_handle_shutdown_complete(struct sctp_shutdown_complete_chunk *cp SCTP_UNUSE /* free the TCB */ SCTPDBG(SCTP_DEBUG_INPUT2, "sctp_handle_shutdown_complete: calls free-asoc\n"); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) so = SCTP_INP_SO(stcb->sctp_ep); atomic_add_int(&stcb->asoc.refcnt, 1); SCTP_TCB_UNLOCK(stcb); @@ -3460,7 +3480,7 @@ sctp_handle_shutdown_complete(struct sctp_shutdown_complete_chunk *cp SCTP_UNUSE #endif (void)sctp_free_assoc(stcb->sctp_ep, stcb, SCTP_NORMAL_PROC, SCTP_FROM_SCTP_INPUT + SCTP_LOC_25); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_UNLOCK(so, 1); #endif return; @@ -3472,7 +3492,8 @@ process_chunk_drop(struct sctp_tcb *stcb, struct sctp_chunk_desc *desc, { switch (desc->chunk_type) { case SCTP_DATA: - /* find the tsn to resend (possibly */ + case SCTP_IDATA: + /* find the tsn to resend (possibly) */ { uint32_t tsn; struct sctp_tmit_chunk *tp1; @@ -3506,8 +3527,6 @@ process_chunk_drop(struct sctp_tcb *stcb, struct sctp_chunk_desc *desc, SCTP_STAT_INCR(sctps_pdrptsnnf); } if ((tp1) && (tp1->sent < SCTP_DATAGRAM_ACKED)) { - uint8_t *ddp; - if (((flg & SCTP_BADCRC) == 0) && ((flg & SCTP_FROM_MIDDLE_BOX) == 0)) { return (0); @@ -3522,20 +3541,18 @@ process_chunk_drop(struct sctp_tcb *stcb, struct sctp_chunk_desc *desc, SCTP_STAT_INCR(sctps_pdrpdizrw); return (0); } - ddp = (uint8_t *) (mtod(tp1->data, caddr_t) + - sizeof(struct sctp_data_chunk)); - { - unsigned int iii; - - for (iii = 0; iii < sizeof(desc->data_bytes); - iii++) { - if (ddp[iii] != desc->data_bytes[iii]) { - SCTP_STAT_INCR(sctps_pdrpbadd); - return (-1); - } - } + if ((uint32_t)SCTP_BUF_LEN(tp1->data) < + SCTP_DATA_CHUNK_OVERHEAD(stcb) + SCTP_NUM_DB_TO_VERIFY) { + /* Payload not matching. */ + SCTP_STAT_INCR(sctps_pdrpbadd); + return (-1); + } + if (memcmp(mtod(tp1->data, caddr_t) + SCTP_DATA_CHUNK_OVERHEAD(stcb), + desc->data_bytes, SCTP_NUM_DB_TO_VERIFY) != 0) { + /* Payload not matching. */ + SCTP_STAT_INCR(sctps_pdrpbadd); + return (-1); } - if (tp1->do_rtt) { /* * this guy had a RTO calculation @@ -3779,7 +3796,6 @@ sctp_reset_clear_pending(struct sctp_tcb *stcb, uint32_t number_entries, uint16_ } } - struct sctp_stream_reset_request * sctp_find_stream_reset(struct sctp_tcb *stcb, uint32_t seq, struct sctp_tmit_chunk **bchk) { @@ -3790,19 +3806,16 @@ sctp_find_stream_reset(struct sctp_tcb *stcb, uint32_t seq, struct sctp_tmit_chu int len, clen; asoc = &stcb->asoc; - if (TAILQ_EMPTY(&stcb->asoc.control_send_queue)) { + chk = asoc->str_reset; + if (TAILQ_EMPTY(&asoc->control_send_queue) || + (chk == NULL)) { asoc->stream_reset_outstanding = 0; return (NULL); } - if (stcb->asoc.str_reset == NULL) { - asoc->stream_reset_outstanding = 0; - return (NULL); - } - chk = stcb->asoc.str_reset; if (chk->data == NULL) { return (NULL); } - if (bchk) { + if (bchk != NULL) { /* he wants a copy of the chk pointer */ *bchk = chk; } @@ -3838,7 +3851,7 @@ sctp_clean_up_stream_reset(struct sctp_tcb *stcb) } asoc->str_reset = NULL; sctp_timer_stop(SCTP_TIMER_TYPE_STRRESET, stcb->sctp_ep, stcb, - chk->whoTo, SCTP_FROM_SCTP_INPUT + SCTP_LOC_28); + NULL, SCTP_FROM_SCTP_INPUT + SCTP_LOC_28); TAILQ_REMOVE(&asoc->control_send_queue, chk, sctp_next); asoc->ctrl_queue_cnt--; if (chk->data) { @@ -3848,7 +3861,6 @@ sctp_clean_up_stream_reset(struct sctp_tcb *stcb) sctp_free_a_chunk(stcb, chk, SCTP_SO_NOT_LOCKED); } - static int sctp_handle_stream_reset_response(struct sctp_tcb *stcb, uint32_t seq, uint32_t action, @@ -3925,7 +3937,7 @@ sctp_handle_stream_reset_response(struct sctp_tcb *stcb, if (action == SCTP_STREAM_RESET_RESULT_PERFORMED) { /* Put the new streams into effect */ int i; - for ( i = asoc->streamoutcnt; i< (asoc->streamoutcnt + num_stream); i++) { + for (i = asoc->streamoutcnt; i < (asoc->streamoutcnt + num_stream); i++) { asoc->strmout[i].state = SCTP_STREAM_OPEN; } asoc->streamoutcnt += num_stream; @@ -4309,7 +4321,6 @@ sctp_handle_str_reset_add_strm(struct sctp_tcb *stcb, struct sctp_tmit_chunk *ch sctp_add_stream_reset_result(chk, seq, asoc->last_reset_action[1]); } else { sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_RESULT_ERR_BAD_SEQNO); - } } @@ -4370,11 +4381,9 @@ sctp_handle_str_reset_add_out_strm(struct sctp_tcb *stcb, struct sctp_tmit_chunk } } -#if !defined(__Panda__) #ifdef __GNUC__ __attribute__ ((noinline)) #endif -#endif static int sctp_handle_stream_reset(struct sctp_tcb *stcb, struct mbuf *m, int offset, struct sctp_chunkhdr *ch_req) @@ -4556,104 +4565,116 @@ static void sctp_handle_packet_dropped(struct sctp_pktdrop_chunk *cp, struct sctp_tcb *stcb, struct sctp_nets *net, uint32_t limit) { - uint32_t bottle_bw, on_queue; - uint16_t trunc_len; - unsigned int chlen; - unsigned int at; struct sctp_chunk_desc desc; - struct sctp_chunkhdr *ch; + struct sctp_chunkhdr *chk_hdr; + struct sctp_data_chunk *data_chunk; + struct sctp_idata_chunk *idata_chunk; + uint32_t bottle_bw, on_queue; + uint32_t offset, chk_len; + uint16_t pktdrp_len; + uint8_t pktdrp_flags; - chlen = ntohs(cp->ch.chunk_length); - chlen -= sizeof(struct sctp_pktdrop_chunk); - /* XXX possible chlen underflow */ - if (chlen == 0) { - ch = NULL; - if (cp->ch.chunk_flags & SCTP_FROM_MIDDLE_BOX) + KASSERT(sizeof(struct sctp_pktdrop_chunk) <= limit, + ("PKTDROP chunk too small")); + pktdrp_flags = cp->ch.chunk_flags; + pktdrp_len = ntohs(cp->ch.chunk_length); + KASSERT(limit <= pktdrp_len, ("Inconsistent limit")); + if (pktdrp_flags & SCTP_PACKET_TRUNCATED) { + if (ntohs(cp->trunc_len) <= pktdrp_len - sizeof(struct sctp_pktdrop_chunk)) { + /* The peer plays games with us. */ + return; + } + } + limit -= sizeof(struct sctp_pktdrop_chunk); + offset = 0; + if (offset == limit) { + if (pktdrp_flags & SCTP_FROM_MIDDLE_BOX) { SCTP_STAT_INCR(sctps_pdrpbwrpt); + } + } else if (offset + sizeof(struct sctphdr) > limit) { + /* Only a partial SCTP common header. */ + SCTP_STAT_INCR(sctps_pdrpcrupt); + offset = limit; } else { - ch = (struct sctp_chunkhdr *)(cp->data + sizeof(struct sctphdr)); - chlen -= sizeof(struct sctphdr); - /* XXX possible chlen underflow */ - memset(&desc, 0, sizeof(desc)); + /* XXX: Check embedded SCTP common header. */ + offset += sizeof(struct sctphdr); } - trunc_len = (uint16_t) ntohs(cp->trunc_len); - if (trunc_len > limit) { - trunc_len = limit; - } - - /* now the chunks themselves */ - while ((ch != NULL) && (chlen >= sizeof(struct sctp_chunkhdr))) { - desc.chunk_type = ch->chunk_type; - /* get amount we need to move */ - at = ntohs(ch->chunk_length); - if (at < sizeof(struct sctp_chunkhdr)) { - /* corrupt chunk, maybe at the end? */ + /* Now parse through the chunks themselves. */ + while (offset < limit) { + if (offset + sizeof(struct sctp_chunkhdr) > limit) { SCTP_STAT_INCR(sctps_pdrpcrupt); break; } - if (trunc_len == 0) { - /* we are supposed to have all of it */ - if (at > chlen) { - /* corrupt skip it */ - SCTP_STAT_INCR(sctps_pdrpcrupt); - break; - } - } else { - /* is there enough of it left ? */ - if (desc.chunk_type == SCTP_DATA) { - if (chlen < (sizeof(struct sctp_data_chunk) + - sizeof(desc.data_bytes))) { - break; - } - } else { - if (chlen < sizeof(struct sctp_chunkhdr)) { - break; - } - } + chk_hdr = (struct sctp_chunkhdr *)(cp->data + offset); + desc.chunk_type = chk_hdr->chunk_type; + /* get amount we need to move */ + chk_len = (uint32_t)ntohs(chk_hdr->chunk_length); + if (chk_len < sizeof(struct sctp_chunkhdr)) { + /* Someone is lying... */ + break; } if (desc.chunk_type == SCTP_DATA) { - /* can we get out the tsn? */ - if ((cp->ch.chunk_flags & SCTP_FROM_MIDDLE_BOX)) - SCTP_STAT_INCR(sctps_pdrpmbda); - - if (chlen >= (sizeof(struct sctp_data_chunk) + sizeof(uint32_t))) { - /* yep */ - struct sctp_data_chunk *dcp; - uint8_t *ddp; - unsigned int iii; - - dcp = (struct sctp_data_chunk *)ch; - ddp = (uint8_t *) (dcp + 1); - for (iii = 0; iii < sizeof(desc.data_bytes); iii++) { - desc.data_bytes[iii] = ddp[iii]; - } - desc.tsn_ifany = dcp->dp.tsn; - } else { - /* nope we are done. */ - SCTP_STAT_INCR(sctps_pdrpnedat); + if (stcb->asoc.idata_supported) { + /* Some is playing games with us. */ break; } + if (chk_len <= sizeof(struct sctp_data_chunk)) { + /* Some is playing games with us. */ + break; + } + if (chk_len < sizeof(struct sctp_data_chunk) + SCTP_NUM_DB_TO_VERIFY) { + /* Not enough data bytes available in the chunk. */ + SCTP_STAT_INCR(sctps_pdrpnedat); + goto next_chunk; + } + if (offset + sizeof(struct sctp_data_chunk) + SCTP_NUM_DB_TO_VERIFY > limit) { + /* Not enough data in buffer. */ + break; + } + data_chunk = (struct sctp_data_chunk *)(cp->data + offset); + memcpy(desc.data_bytes, data_chunk + 1, SCTP_NUM_DB_TO_VERIFY); + desc.tsn_ifany = data_chunk->dp.tsn; + if (pktdrp_flags & SCTP_FROM_MIDDLE_BOX) { + SCTP_STAT_INCR(sctps_pdrpmbda); + } + } else if (desc.chunk_type == SCTP_IDATA) { + if (!stcb->asoc.idata_supported) { + /* Some is playing games with us. */ + break; + } + if (chk_len <= sizeof(struct sctp_idata_chunk)) { + /* Some is playing games with us. */ + break; + } + if (chk_len < sizeof(struct sctp_idata_chunk) + SCTP_NUM_DB_TO_VERIFY) { + /* Not enough data bytes available in the chunk. */ + SCTP_STAT_INCR(sctps_pdrpnedat); + goto next_chunk; + } + if (offset + sizeof(struct sctp_idata_chunk) + SCTP_NUM_DB_TO_VERIFY > limit) { + /* Not enough data in buffer. */ + break; + } + idata_chunk = (struct sctp_idata_chunk *)(cp->data + offset); + memcpy(desc.data_bytes, idata_chunk + 1, SCTP_NUM_DB_TO_VERIFY); + desc.tsn_ifany = idata_chunk->dp.tsn; + if (pktdrp_flags & SCTP_FROM_MIDDLE_BOX) { + SCTP_STAT_INCR(sctps_pdrpmbda); + } } else { - if ((cp->ch.chunk_flags & SCTP_FROM_MIDDLE_BOX)) + if (pktdrp_flags & SCTP_FROM_MIDDLE_BOX) { SCTP_STAT_INCR(sctps_pdrpmbct); + } } - - if (process_chunk_drop(stcb, &desc, net, cp->ch.chunk_flags)) { + if (process_chunk_drop(stcb, &desc, net, pktdrp_flags)) { SCTP_STAT_INCR(sctps_pdrppdbrk); break; } - if (SCTP_SIZE32(at) > chlen) { - break; - } - chlen -= SCTP_SIZE32(at); - if (chlen < sizeof(struct sctp_chunkhdr)) { - /* done, none left */ - break; - } - ch = (struct sctp_chunkhdr *)((caddr_t)ch + SCTP_SIZE32(at)); +next_chunk: + offset += SCTP_SIZE32(chk_len); } /* Now update any rwnd --- possibly */ - if ((cp->ch.chunk_flags & SCTP_FROM_MIDDLE_BOX) == 0) { + if ((pktdrp_flags & SCTP_FROM_MIDDLE_BOX) == 0) { /* From a peer, we get a rwnd report */ uint32_t a_rwnd; @@ -4689,7 +4710,7 @@ sctp_handle_packet_dropped(struct sctp_pktdrop_chunk *cp, } /* now middle boxes in sat networks get a cwnd bump */ - if ((cp->ch.chunk_flags & SCTP_FROM_MIDDLE_BOX) && + if ((pktdrp_flags & SCTP_FROM_MIDDLE_BOX) && (stcb->asoc.sat_t3_loss_recovery == 0) && (stcb->asoc.sat_network)) { /* @@ -4711,17 +4732,15 @@ sctp_handle_packet_dropped(struct sctp_pktdrop_chunk *cp, * cookie-echo processing - return NULL to discard the packet (ie. no asoc, * bad packet,...) otherwise return the tcb for this packet */ -#if !defined(__Panda__) #ifdef __GNUC__ __attribute__ ((noinline)) #endif -#endif static struct sctp_tcb * sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, struct sockaddr *src, struct sockaddr *dst, struct sctphdr *sh, struct sctp_chunkhdr *ch, struct sctp_inpcb *inp, struct sctp_tcb *stcb, struct sctp_nets **netp, int *fwd_tsn_seen, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) uint8_t mflowtype, uint32_t mflowid, uint16_t fibnum, #endif uint32_t vrf_id, uint16_t port) @@ -4735,6 +4754,7 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, int ret; int abort_no_unlock = 0; int ecne_seen = 0; + int abort_flag; /* * How big should this be, and should it be alloc'd? Lets try the * d-mtu-ceiling for now (2k) and that should hopefully work ... @@ -4745,7 +4765,7 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, uint32_t auth_offset = 0, auth_len = 0; int auth_skipped = 0; int asconf_cnt = 0; -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) struct socket *so; #endif @@ -4848,11 +4868,13 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, if (auth_skipped && (stcb != NULL)) { struct sctp_auth_chunk *auth; - auth = (struct sctp_auth_chunk *) - sctp_m_getptr(m, auth_offset, - auth_len, chunk_buf); - got_auth = 1; - auth_skipped = 0; + if (auth_len <= SCTP_CHUNK_BUFFER_SIZE) { + auth = (struct sctp_auth_chunk *)sctp_m_getptr(m, auth_offset, auth_len, chunk_buf); + got_auth = 1; + auth_skipped = 0; + } else { + auth = NULL; + } if ((auth == NULL) || sctp_handle_auth(stcb, auth, m, auth_offset)) { /* auth HMAC failed so dump it */ @@ -4865,12 +4887,12 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, } } if (stcb == NULL) { - snprintf(msg, sizeof(msg), "OOTB, %s:%d at %s", __FILE__, __LINE__, __func__); + SCTP_SNPRINTF(msg, sizeof(msg), "OOTB, %s:%d at %s", __FILE__, __LINE__, __func__); op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code), msg); /* no association, so it's out of the blue... */ sctp_handle_ootb(m, iphlen, *offset, src, dst, sh, inp, op_err, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) mflowtype, mflowid, inp->fibnum, #endif vrf_id, port); @@ -4897,29 +4919,6 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, } return (NULL); } - } else if (ch->chunk_type == SCTP_SHUTDOWN_ACK) { - if (vtag_in != asoc->my_vtag) { - /* - * this could be a stale SHUTDOWN-ACK or the - * peer never got the SHUTDOWN-COMPLETE and - * is still hung; we have started a new asoc - * but it won't complete until the shutdown - * is completed - */ - if (stcb != NULL) { - SCTP_TCB_UNLOCK(stcb); - } - snprintf(msg, sizeof(msg), "OOTB, %s:%d at %s", __FILE__, __LINE__, __func__); - op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code), - msg); - sctp_handle_ootb(m, iphlen, *offset, src, dst, - sh, inp, op_err, -#if defined(__FreeBSD__) - mflowtype, mflowid, fibnum, -#endif - vrf_id, port); - return (NULL); - } } else { /* for all other chunks, vtag must match */ if (vtag_in != asoc->my_vtag) { @@ -4982,10 +4981,7 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, chunk_buf); if (ch == NULL) { *offset = length; - if (stcb != NULL) { - SCTP_TCB_UNLOCK(stcb); - } - return (NULL); + return (stcb); } num_chunks++; @@ -5019,34 +5015,36 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, /* The INIT chunk must be the only chunk. */ if ((num_chunks > 1) || (length - *offset > (int)SCTP_SIZE32(chk_length))) { - /* RFC 4960 requires that no ABORT is sent */ + /* + * RFC 4960bis requires stopping the + * processing of the packet. + */ + *offset = length; + return (stcb); + } + /* Honor our resource limit. */ + if (chk_length > SCTP_LARGEST_INIT_ACCEPTED) { + op_err = sctp_generate_cause(SCTP_CAUSE_OUT_OF_RESC, ""); + sctp_send_abort(m, iphlen, src, dst, sh, 0, op_err, +#if defined(__FreeBSD__) && !defined(__Userspace__) + mflowtype, mflowid, inp->fibnum, +#endif + vrf_id, port); *offset = length; if (stcb != NULL) { SCTP_TCB_UNLOCK(stcb); } return (NULL); } - /* Honor our resource limit. */ - if (chk_length > SCTP_LARGEST_INIT_ACCEPTED) { - op_err = sctp_generate_cause(SCTP_CAUSE_OUT_OF_RESC, ""); - sctp_abort_association(inp, stcb, m, iphlen, - src, dst, sh, op_err, -#if defined(__FreeBSD__) - mflowtype, mflowid, -#endif - vrf_id, port); - *offset = length; - return (NULL); - } sctp_handle_init(m, iphlen, *offset, src, dst, sh, (struct sctp_init_chunk *)ch, inp, - stcb, *netp, &abort_no_unlock, -#if defined(__FreeBSD__) + stcb, *netp, +#if defined(__FreeBSD__) && !defined(__Userspace__) mflowtype, mflowid, #endif vrf_id, port); *offset = length; - if ((!abort_no_unlock) && (stcb != NULL)) { + if (stcb != NULL) { SCTP_TCB_UNLOCK(stcb); } return (NULL); @@ -5062,7 +5060,7 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, } else { *offset = length; if (stcb != NULL) { -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) so = SCTP_INP_SO(inp); atomic_add_int(&stcb->asoc.refcnt, 1); SCTP_TCB_UNLOCK(stcb); @@ -5072,7 +5070,7 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, #endif (void)sctp_free_assoc(inp, stcb, SCTP_NORMAL_PROC, SCTP_FROM_SCTP_INPUT + SCTP_LOC_29); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_UNLOCK(so, 1); #endif } @@ -5091,7 +5089,7 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, (struct sctp_init_ack_chunk *)ch, stcb, *netp, &abort_no_unlock, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) mflowtype, mflowid, #endif vrf_id); @@ -5231,20 +5229,19 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, if ((stcb != NULL) && (netp != NULL) && (*netp != NULL)) { SCTP_STAT_INCR(sctps_recvheartbeat); sctp_send_heartbeat_ack(stcb, m, *offset, - chk_length, *netp); + chk_length, *netp); } break; case SCTP_HEARTBEAT_ACK: SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_HEARTBEAT_ACK\n"); if ((stcb == NULL) || (chk_length != sizeof(struct sctp_heartbeat_chunk))) { /* Its not ours */ - *offset = length; - return (stcb); + break; } SCTP_STAT_INCR(sctps_recvheartbeatack); if ((netp != NULL) && (*netp != NULL)) { sctp_handle_heartbeat_ack((struct sctp_heartbeat_chunk *)ch, - stcb, *netp); + stcb, *netp); } break; case SCTP_ABORT_ASSOCIATION: @@ -5265,14 +5262,12 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_SHUTDOWN, stcb %p\n", (void *)stcb); if ((stcb == NULL) || (chk_length != sizeof(struct sctp_shutdown_chunk))) { - *offset = length; - return (stcb); + break; } if ((netp != NULL) && (*netp != NULL)) { - int abort_flag = 0; - + abort_flag = 0; sctp_handle_shutdown((struct sctp_shutdown_chunk *)ch, - stcb, *netp, &abort_flag); + stcb, *netp, &abort_flag); if (abort_flag) { *offset = length; return (NULL); @@ -5281,11 +5276,12 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, break; case SCTP_SHUTDOWN_ACK: SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_SHUTDOWN_ACK, stcb %p\n", (void *)stcb); - if ((stcb != NULL) && (netp != NULL) && (*netp != NULL)) { + if ((chk_length == sizeof(struct sctp_shutdown_ack_chunk)) && + (stcb != NULL) && (netp != NULL) && (*netp != NULL)) { sctp_handle_shutdown_ack((struct sctp_shutdown_ack_chunk *)ch, stcb, *netp); + *offset = length; + return (NULL); } - *offset = length; - return (NULL); break; case SCTP_OPERATION_ERROR: SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_OP_ERR\n"); @@ -5331,7 +5327,7 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, if ((stcb == NULL) && (!SCTP_IS_LISTENING(inp) || (!(inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) && -#if defined(__FreeBSD__) && __FreeBSD_version >= 1200034 +#if defined(__FreeBSD__) && !defined(__Userspace__) inp->sctp_socket->sol_qlen >= inp->sctp_socket->sol_qlimit))) { #else inp->sctp_socket->so_qlen >= inp->sctp_socket->so_qlimit))) { @@ -5341,7 +5337,7 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, op_err = sctp_generate_cause(SCTP_CAUSE_OUT_OF_RESC, ""); sctp_abort_association(inp, stcb, m, iphlen, src, dst, sh, op_err, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) mflowtype, mflowid, #endif vrf_id, port); @@ -5351,6 +5347,13 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, } else { struct mbuf *ret_buf; struct sctp_inpcb *linp; + struct sctp_tmit_chunk *chk; + + if (inp->sctp_flags & (SCTP_PCB_FLAGS_SOCKET_GONE | + SCTP_PCB_FLAGS_SOCKET_ALLGONE)) { + goto abend; + } + if (stcb) { linp = NULL; } else { @@ -5359,11 +5362,6 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, if (linp != NULL) { SCTP_ASOC_CREATE_LOCK(linp); - if ((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) || - (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE)) { - SCTP_ASOC_CREATE_UNLOCK(linp); - goto abend; - } } if (netp != NULL) { @@ -5381,7 +5379,7 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, auth_offset, auth_len, &locked_stcb, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) mflowtype, mflowid, #endif @@ -5413,14 +5411,13 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, got_auth = 1; auth_skipped = 0; } - if (!TAILQ_EMPTY(&stcb->asoc.sent_queue)) { - /* - * Restart the timer if we have - * pending data - */ - struct sctp_tmit_chunk *chk; - - chk = TAILQ_FIRST(&stcb->asoc.sent_queue); + /* Restart the timer if we have pending data */ + TAILQ_FOREACH(chk, &stcb->asoc.sent_queue, sctp_next) { + if (chk->whoTo != NULL) { + break; + } + } + if (chk != NULL) { sctp_timer_start(SCTP_TIMER_TYPE_SEND, stcb->sctp_ep, stcb, chk->whoTo); } } @@ -5428,14 +5425,14 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, case SCTP_COOKIE_ACK: SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_COOKIE_ACK, stcb %p\n", (void *)stcb); if ((stcb == NULL) || chk_length != sizeof(struct sctp_cookie_ack_chunk)) { - return (stcb); + break; } if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) { /* We are not interested anymore */ if ((stcb) && (stcb->asoc.total_output_queue_size)) { ; } else if (stcb) { -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) so = SCTP_INP_SO(inp); atomic_add_int(&stcb->asoc.refcnt, 1); SCTP_TCB_UNLOCK(stcb); @@ -5445,7 +5442,7 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, #endif (void)sctp_free_assoc(inp, stcb, SCTP_NORMAL_PROC, SCTP_FROM_SCTP_INPUT + SCTP_LOC_30); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_UNLOCK(so, 1); #endif *offset = length; @@ -5458,26 +5455,30 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, break; case SCTP_ECN_ECHO: SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_ECN_ECHO\n"); - if ((stcb == NULL) || (chk_length != sizeof(struct sctp_ecne_chunk))) { - /* Its not ours */ - *offset = length; - return (stcb); + if (stcb == NULL) { + break; } if (stcb->asoc.ecn_supported == 0) { goto unknown_chunk; } + if ((chk_length != sizeof(struct sctp_ecne_chunk)) && + (chk_length != sizeof(struct old_sctp_ecne_chunk))) { + break; + } sctp_handle_ecn_echo((struct sctp_ecne_chunk *)ch, stcb); ecne_seen = 1; break; case SCTP_ECN_CWR: SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_ECN_CWR\n"); - if ((stcb == NULL) || (chk_length != sizeof(struct sctp_cwr_chunk))) { - *offset = length; - return (stcb); + if (stcb == NULL) { + break; } if (stcb->asoc.ecn_supported == 0) { goto unknown_chunk; } + if (chk_length != sizeof(struct sctp_cwr_chunk)) { + break; + } sctp_handle_ecn_cwr((struct sctp_cwr_chunk *)ch, stcb, *netp); break; case SCTP_SHUTDOWN_COMPLETE: @@ -5488,12 +5489,13 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, *offset = length; return (stcb); } - if ((stcb != NULL) && (netp != NULL) && (*netp != NULL)) { + if ((chk_length == sizeof(struct sctp_shutdown_complete_chunk)) && + (stcb != NULL) && (netp != NULL) && (*netp != NULL)) { sctp_handle_shutdown_complete((struct sctp_shutdown_complete_chunk *)ch, - stcb, *netp); + stcb, *netp); + *offset = length; + return (NULL); } - *offset = length; - return (NULL); break; case SCTP_ASCONF: SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_ASCONF\n"); @@ -5502,93 +5504,105 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, goto unknown_chunk; } sctp_handle_asconf(m, *offset, src, - (struct sctp_asconf_chunk *)ch, stcb, asconf_cnt == 0); + (struct sctp_asconf_chunk *)ch, stcb, asconf_cnt == 0); asconf_cnt++; } break; case SCTP_ASCONF_ACK: SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_ASCONF_ACK\n"); - if (chk_length < sizeof(struct sctp_asconf_ack_chunk)) { - /* Its not ours */ - *offset = length; - return (stcb); + if (stcb == NULL) { + break; } - if ((stcb != NULL) && (netp != NULL) && (*netp != NULL)) { - if (stcb->asoc.asconf_supported == 0) { - goto unknown_chunk; - } + if (stcb->asoc.asconf_supported == 0) { + goto unknown_chunk; + } + if (chk_length < sizeof(struct sctp_asconf_ack_chunk)) { + break; + } + if ((netp != NULL) && (*netp != NULL)) { /* He's alive so give him credit */ if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_THRESHOLD_LOGGING) { sctp_misc_ints(SCTP_THRESHOLD_CLEAR, - stcb->asoc.overall_error_count, - 0, - SCTP_FROM_SCTP_INPUT, - __LINE__); + stcb->asoc.overall_error_count, + 0, + SCTP_FROM_SCTP_INPUT, + __LINE__); } stcb->asoc.overall_error_count = 0; sctp_handle_asconf_ack(m, *offset, - (struct sctp_asconf_ack_chunk *)ch, stcb, *netp, &abort_no_unlock); + (struct sctp_asconf_ack_chunk *)ch, stcb, *netp, &abort_no_unlock); if (abort_no_unlock) return (NULL); } break; case SCTP_FORWARD_CUM_TSN: case SCTP_IFORWARD_CUM_TSN: - SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_FWD_TSN\n"); - if (chk_length < sizeof(struct sctp_forward_tsn_chunk)) { - /* Its not ours */ - *offset = length; - return (stcb); + SCTPDBG(SCTP_DEBUG_INPUT3, "%s\n", + ch->chunk_type == SCTP_FORWARD_CUM_TSN ? "FORWARD_TSN" : "I_FORWARD_TSN"); + if (stcb == NULL) { + break; } - - if (stcb != NULL) { - int abort_flag = 0; - - if (stcb->asoc.prsctp_supported == 0) { - goto unknown_chunk; + if (stcb->asoc.prsctp_supported == 0) { + goto unknown_chunk; + } + if (chk_length < sizeof(struct sctp_forward_tsn_chunk)) { + break; + } + if (((stcb->asoc.idata_supported == 1) && (ch->chunk_type == SCTP_FORWARD_CUM_TSN)) || + ((stcb->asoc.idata_supported == 0) && (ch->chunk_type == SCTP_IFORWARD_CUM_TSN))) { + if (ch->chunk_type == SCTP_FORWARD_CUM_TSN) { + SCTP_SNPRINTF(msg, sizeof(msg), "%s", "FORWARD-TSN chunk received when I-FORWARD-TSN was negotiated"); + } else { + SCTP_SNPRINTF(msg, sizeof(msg), "%s", "I-FORWARD-TSN chunk received when FORWARD-TSN was negotiated"); } - *fwd_tsn_seen = 1; - if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) { - /* We are not interested anymore */ -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) - so = SCTP_INP_SO(inp); - atomic_add_int(&stcb->asoc.refcnt, 1); - SCTP_TCB_UNLOCK(stcb); - SCTP_SOCKET_LOCK(so, 1); - SCTP_TCB_LOCK(stcb); - atomic_subtract_int(&stcb->asoc.refcnt, 1); + op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg); + sctp_abort_an_association(inp, stcb, op_err, false, SCTP_SO_NOT_LOCKED); + *offset = length; + return (NULL); + } + *fwd_tsn_seen = 1; + if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) { + /* We are not interested anymore */ +#if defined(__APPLE__) && !defined(__Userspace__) + so = SCTP_INP_SO(inp); + atomic_add_int(&stcb->asoc.refcnt, 1); + SCTP_TCB_UNLOCK(stcb); + SCTP_SOCKET_LOCK(so, 1); + SCTP_TCB_LOCK(stcb); + atomic_subtract_int(&stcb->asoc.refcnt, 1); #endif - (void)sctp_free_assoc(inp, stcb, SCTP_NORMAL_PROC, - SCTP_FROM_SCTP_INPUT + SCTP_LOC_31); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) - SCTP_SOCKET_UNLOCK(so, 1); + (void)sctp_free_assoc(inp, stcb, SCTP_NORMAL_PROC, + SCTP_FROM_SCTP_INPUT + SCTP_LOC_31); +#if defined(__APPLE__) && !defined(__Userspace__) + SCTP_SOCKET_UNLOCK(so, 1); #endif - *offset = length; - return (NULL); - } - /* - * For sending a SACK this looks like DATA - * chunks. - */ - stcb->asoc.last_data_chunk_from = stcb->asoc.last_control_chunk_from; - sctp_handle_forward_tsn(stcb, - (struct sctp_forward_tsn_chunk *)ch, &abort_flag, m, *offset); - if (abort_flag) { - *offset = length; - return (NULL); - } + *offset = length; + return (NULL); + } + /* + * For sending a SACK this looks like DATA + * chunks. + */ + stcb->asoc.last_data_chunk_from = stcb->asoc.last_control_chunk_from; + abort_flag = 0; + sctp_handle_forward_tsn(stcb, + (struct sctp_forward_tsn_chunk *)ch, &abort_flag, m, *offset); + if (abort_flag) { + *offset = length; + return (NULL); } break; case SCTP_STREAM_RESET: SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_STREAM_RESET\n"); - if (((stcb == NULL) || (ch == NULL) || (chk_length < sizeof(struct sctp_stream_reset_tsn_req)))) { - /* Its not ours */ - *offset = length; - return (stcb); + if (stcb == NULL) { + break; } if (stcb->asoc.reconfig_supported == 0) { goto unknown_chunk; } + if (chk_length < sizeof(struct sctp_stream_reset_tsn_req)) { + break; + } if (sctp_handle_stream_reset(stcb, m, *offset, ch)) { /* stop processing */ *offset = length; @@ -5597,20 +5611,19 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, break; case SCTP_PACKET_DROPPED: SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_PACKET_DROPPED\n"); - /* re-get it all please */ - if (chk_length < sizeof(struct sctp_pktdrop_chunk)) { - /* Its not ours */ - *offset = length; - return (stcb); + if (stcb == NULL) { + break; } - - if ((ch != NULL) && (stcb != NULL) && (netp != NULL) && (*netp != NULL)) { - if (stcb->asoc.pktdrop_supported == 0) { - goto unknown_chunk; - } + if (stcb->asoc.pktdrop_supported == 0) { + goto unknown_chunk; + } + if (chk_length < sizeof(struct sctp_pktdrop_chunk)) { + break; + } + if ((netp != NULL) && (*netp != NULL)) { sctp_handle_packet_dropped((struct sctp_pktdrop_chunk *)ch, - stcb, *netp, - min(chk_length, contiguous)); + stcb, *netp, + min(chk_length, contiguous)); } break; case SCTP_AUTHENTICATION: @@ -5623,25 +5636,24 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, auth_skipped = 1; } /* skip this chunk (temporarily) */ - goto next_chunk; + break; } if (stcb->asoc.auth_supported == 0) { goto unknown_chunk; } if ((chk_length < (sizeof(struct sctp_auth_chunk))) || (chk_length > (sizeof(struct sctp_auth_chunk) + - SCTP_AUTH_DIGEST_LEN_MAX))) { + SCTP_AUTH_DIGEST_LEN_MAX))) { /* Its not ours */ *offset = length; return (stcb); } if (got_auth == 1) { /* skip this chunk... it's already auth'd */ - goto next_chunk; + break; } got_auth = 1; - if ((ch == NULL) || sctp_handle_auth(stcb, (struct sctp_auth_chunk *)ch, - m, *offset)) { + if (sctp_handle_auth(stcb, (struct sctp_auth_chunk *)ch, m, *offset)) { /* auth HMAC failed so dump the packet */ *offset = length; return (stcb); @@ -5654,7 +5666,11 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, default: unknown_chunk: /* it's an unknown chunk! */ - if ((ch->chunk_type & 0x40) && (stcb != NULL)) { + if ((ch->chunk_type & 0x40) && + (stcb != NULL) && + (SCTP_GET_STATE(stcb) != SCTP_STATE_EMPTY) && + (SCTP_GET_STATE(stcb) != SCTP_STATE_INUSE) && + (SCTP_GET_STATE(stcb) != SCTP_STATE_COOKIE_WAIT)) { struct sctp_gen_error_cause *cause; int len; @@ -5663,7 +5679,7 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, if (op_err != NULL) { len = min(SCTP_SIZE32(chk_length), (uint32_t)(length - *offset)); cause = mtod(op_err, struct sctp_gen_error_cause *); - cause->code = htons(SCTP_CAUSE_UNRECOG_CHUNK); + cause->code = htons(SCTP_CAUSE_UNRECOG_CHUNK); cause->length = htons((uint16_t)(len + sizeof(struct sctp_gen_error_cause))); SCTP_BUF_LEN(op_err) = sizeof(struct sctp_gen_error_cause); SCTP_BUF_NEXT(op_err) = SCTP_M_COPYM(m, *offset, len, M_NOWAIT); @@ -5687,7 +5703,6 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, break; } /* switch (ch->chunk_type) */ - next_chunk: /* get the next chunk */ *offset += SCTP_SIZE32(chk_length); @@ -5696,7 +5711,7 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, break; } ch = (struct sctp_chunkhdr *)sctp_m_getptr(m, *offset, - sizeof(struct sctp_chunkhdr), chunk_buf); + sizeof(struct sctp_chunkhdr), chunk_buf); if (ch == NULL) { *offset = length; return (stcb); @@ -5709,7 +5724,6 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, return (stcb); } - /* * common input chunk processing (v4 and v6) */ @@ -5719,7 +5733,7 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt struct sctphdr *sh, struct sctp_chunkhdr *ch, uint8_t compute_crc, uint8_t ecn_bits, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) uint8_t mflowtype, uint32_t mflowid, uint16_t fibnum, #endif uint32_t vrf_id, uint16_t port) @@ -5761,7 +5775,7 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt /* UDP encapsulation turned on. */ net->mtu -= sizeof(struct udphdr); if (stcb->asoc.smallest_mtu > net->mtu) { - sctp_pathmtu_adjustment(stcb, net->mtu); + sctp_pathmtu_adjustment(stcb, net->mtu, true); } } else if (port == 0) { /* UDP encapsulation turned off. */ @@ -5771,7 +5785,7 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt net->port = port; } #endif -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (net != NULL) { net->flowtype = mflowtype; net->flowid = mflowid; @@ -5803,7 +5817,7 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt /* UDP encapsulation turned on. */ net->mtu -= sizeof(struct udphdr); if (stcb->asoc.smallest_mtu > net->mtu) { - sctp_pathmtu_adjustment(stcb, net->mtu); + sctp_pathmtu_adjustment(stcb, net->mtu, true); } } else if (port == 0) { /* UDP encapsulation turned off. */ @@ -5813,31 +5827,33 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt net->port = port; } #endif -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (net != NULL) { net->flowtype = mflowtype; net->flowid = mflowid; } #endif if (inp == NULL) { -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) SCTP_PROBE5(receive, NULL, stcb, m, stcb, sh); #endif SCTP_STAT_INCR(sctps_noport); -#if defined(__FreeBSD__) && (((__FreeBSD_version < 900000) && (__FreeBSD_version >= 804000)) || (__FreeBSD_version > 900000)) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (badport_bandlim(BANDLIM_SCTP_OOTB) < 0) { goto out; } #endif if (ch->chunk_type == SCTP_SHUTDOWN_ACK) { + SCTP_STAT_INCR_COUNTER64(sctps_incontrolchunks); sctp_send_shutdown_complete2(src, dst, sh, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) mflowtype, mflowid, fibnum, #endif vrf_id, port); goto out; } if (ch->chunk_type == SCTP_SHUTDOWN_COMPLETE) { + SCTP_STAT_INCR_COUNTER64(sctps_incontrolchunks); goto out; } if (ch->chunk_type != SCTP_ABORT_ASSOCIATION) { @@ -5848,7 +5864,7 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt "Out of the blue"); sctp_send_abort(m, iphlen, src, dst, sh, 0, op_err, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) mflowtype, mflowid, fibnum, #endif vrf_id, port); @@ -5877,14 +5893,14 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt */ SCTP_TCB_UNLOCK(stcb); stcb = NULL; -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) SCTP_PROBE5(receive, NULL, stcb, m, stcb, sh); #endif - snprintf(msg, sizeof(msg), "OOTB, %s:%d at %s", __FILE__, __LINE__, __func__); + SCTP_SNPRINTF(msg, sizeof(msg), "OOTB, %s:%d at %s", __FILE__, __LINE__, __func__); op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code), msg); sctp_handle_ootb(m, iphlen, offset, src, dst, sh, inp, op_err, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) mflowtype, mflowid, inp->fibnum, #endif vrf_id, port); @@ -5911,7 +5927,7 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt stcb = sctp_process_control(m, iphlen, &offset, length, src, dst, sh, ch, inp, stcb, &net, &fwd_tsn_seen, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) mflowtype, mflowid, fibnum, #endif vrf_id, port); @@ -5927,7 +5943,7 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt /* UDP encapsulation turned on. */ net->mtu -= sizeof(struct udphdr); if (stcb->asoc.smallest_mtu > net->mtu) { - sctp_pathmtu_adjustment(stcb, net->mtu); + sctp_pathmtu_adjustment(stcb, net->mtu, true); } } else if (port == 0) { /* UDP encapsulation turned off. */ @@ -5952,7 +5968,7 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt if ((stcb != NULL) && sctp_auth_is_required_chunk(SCTP_DATA, stcb->asoc.local_auth_chunks)) { /* "silently" ignore */ -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) SCTP_PROBE5(receive, NULL, stcb, m, stcb, sh); #endif SCTP_STAT_INCR(sctps_recvauthmissing); @@ -5960,14 +5976,14 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt } if (stcb == NULL) { /* out of the blue DATA chunk */ -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) SCTP_PROBE5(receive, NULL, NULL, m, NULL, sh); #endif - snprintf(msg, sizeof(msg), "OOTB, %s:%d at %s", __FILE__, __LINE__, __func__); + SCTP_SNPRINTF(msg, sizeof(msg), "OOTB, %s:%d at %s", __FILE__, __LINE__, __func__); op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code), msg); sctp_handle_ootb(m, iphlen, offset, src, dst, sh, inp, op_err, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) mflowtype, mflowid, fibnum, #endif vrf_id, port); @@ -5975,7 +5991,7 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt } if (stcb->asoc.my_vtag != ntohl(sh->v_tag)) { /* v_tag mismatch! */ -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) SCTP_PROBE5(receive, NULL, stcb, m, stcb, sh); #endif SCTP_STAT_INCR(sctps_badvtag); @@ -5983,7 +5999,7 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt } } -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) SCTP_PROBE5(receive, NULL, stcb, m, stcb, sh); #endif if (stcb == NULL) { @@ -6049,11 +6065,11 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt /* * We consider OOTB any data sent during asoc setup. */ - snprintf(msg, sizeof(msg), "OOTB, %s:%d at %s", __FILE__, __LINE__, __func__); + SCTP_SNPRINTF(msg, sizeof(msg), "OOTB, %s:%d at %s", __FILE__, __LINE__, __func__); op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code), msg); sctp_handle_ootb(m, iphlen, offset, src, dst, sh, inp, op_err, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) mflowtype, mflowid, inp->fibnum, #endif vrf_id, port); @@ -6083,7 +6099,9 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt stcb = NULL; goto out; } - data_processed = 1; + if (retval == 0) { + data_processed = 1; + } /* * Anything important needs to have been m_copy'ed in * process_data @@ -6131,9 +6149,8 @@ trigger_send: if (!TAILQ_EMPTY(&stcb->asoc.asconf_send_queue) || cnt_ctrl_ready || stcb->asoc.trigger_reset || - ((un_sent) && - (stcb->asoc.peers_rwnd > 0 || - (stcb->asoc.peers_rwnd <= 0 && stcb->asoc.total_flight == 0)))) { + ((un_sent > 0) && + (stcb->asoc.peers_rwnd > 0 || stcb->asoc.total_flight == 0))) { SCTPDBG(SCTP_DEBUG_INPUT3, "Calling chunk OUTPUT\n"); sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_CONTROL_PROC, SCTP_SO_NOT_LOCKED); SCTPDBG(SCTP_DEBUG_INPUT3, "chunk OUTPUT returns\n"); @@ -6171,21 +6188,8 @@ trigger_send: #ifdef INET #if !defined(__Userspace__) -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) void sctp_input_with_port(struct mbuf *i_pak, int off, uint16_t port) -#elif defined(__Panda__) -void -sctp_input(pakhandle_type i_pak) -#else -void -#if __STDC__ -sctp_input(struct mbuf *i_pak,...) -#else -sctp_input(i_pak, va_alist) - struct mbuf *i_pak; -#endif -#endif { struct mbuf *m; int iphlen; @@ -6197,30 +6201,21 @@ sctp_input(i_pak, va_alist) struct sctp_chunkhdr *ch; int length, offset; uint8_t compute_crc; -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) uint32_t mflowid; uint8_t mflowtype; uint16_t fibnum; #endif -#if !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__)) +#if defined(__Userspace__) uint16_t port = 0; #endif -#if defined(__Panda__) - /* This is Evil, but its the only way to make panda work right. */ - iphlen = sizeof(struct ip); -#else iphlen = off; -#endif if (SCTP_GET_PKT_VRFID(i_pak, vrf_id)) { SCTP_RELEASE_PKT(i_pak); return; } m = SCTP_HEADER_TO_CHAIN(i_pak); -#ifdef __Panda__ - SCTP_DETACH_HEADER_FROM_CHAIN(i_pak); - (void)SCTP_RELEASE_HEADER(i_pak); -#endif #ifdef SCTP_MBUF_LOGGING /* Log in any input mbufs */ if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { @@ -6232,28 +6227,14 @@ sctp_input(i_pak, va_alist) sctp_packet_log(m); } #endif -#if defined(__FreeBSD__) -#if __FreeBSD_version > 1000049 +#if defined(__FreeBSD__) && !defined(__Userspace__) SCTPDBG(SCTP_DEBUG_CRCOFFLOAD, "sctp_input(): Packet of length %d received on %s with csum_flags 0x%b.\n", m->m_pkthdr.len, if_name(m->m_pkthdr.rcvif), (int)m->m_pkthdr.csum_flags, CSUM_BITS); -#elif __FreeBSD_version >= 800000 - SCTPDBG(SCTP_DEBUG_CRCOFFLOAD, - "sctp_input(): Packet of length %d received on %s with csum_flags 0x%x.\n", - m->m_pkthdr.len, - if_name(m->m_pkthdr.rcvif), - m->m_pkthdr.csum_flags); -#else - SCTPDBG(SCTP_DEBUG_CRCOFFLOAD, - "sctp_input(): Packet of length %d received on %s with csum_flags 0x%x.\n", - m->m_pkthdr.len, - m->m_pkthdr.rcvif->if_xname, - m->m_pkthdr.csum_flags); #endif -#endif -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) SCTPDBG(SCTP_DEBUG_CRCOFFLOAD, "sctp_input(): Packet of length %d received on %s%d with csum_flags 0x%x.\n", m->m_pkthdr.len, @@ -6261,14 +6242,14 @@ sctp_input(i_pak, va_alist) m->m_pkthdr.rcvif->if_unit, m->m_pkthdr.csum_flags); #endif -#if defined(__Windows__) +#if defined(_WIN32) && !defined(__Userspace__) SCTPDBG(SCTP_DEBUG_CRCOFFLOAD, "sctp_input(): Packet of length %d received on %s with csum_flags 0x%x.\n", m->m_pkthdr.len, m->m_pkthdr.rcvif->if_xname, m->m_pkthdr.csum_flags); #endif -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) mflowid = m->m_pkthdr.flowid; mflowtype = M_HASHTYPE_GET(m); fibnum = M_GETFIB(m); @@ -6301,26 +6282,22 @@ sctp_input(i_pak, va_alist) #endif dst.sin_port = sh->dest_port; dst.sin_addr = ip->ip_dst; -#if defined(__Windows__) +#if defined(_WIN32) && !defined(__Userspace__) NTOHS(ip->ip_len); #endif -#if defined(__Userspace_os_Linux) || defined(__Userspace_os_Windows) +#if defined(__linux__) || (defined(_WIN32) && defined(__Userspace__)) ip->ip_len = ntohs(ip->ip_len); #endif -#if defined(__FreeBSD__) -#if __FreeBSD_version >= 1000000 - length = ntohs(ip->ip_len); -#else - length = ip->ip_len + iphlen; -#endif -#elif defined(__APPLE__) - length = ip->ip_len + iphlen; -#elif defined(__Userspace__) -#if defined(__Userspace_os_Linux) || defined(__Userspace_os_Windows) +#if defined(__Userspace__) +#if defined(__linux__) || defined(_WIN32) length = ip->ip_len; #else length = ip->ip_len + iphlen; #endif +#elif defined(__FreeBSD__) + length = ntohs(ip->ip_len); +#elif defined(__APPLE__) + length = ip->ip_len + iphlen; #else length = ip->ip_len; #endif @@ -6339,7 +6316,7 @@ sctp_input(i_pak, va_alist) goto out; } ecn_bits = ip->ip_tos; -#if defined(__FreeBSD__) && __FreeBSD_version >= 800000 +#if defined(__FreeBSD__) && !defined(__Userspace__) if (m->m_pkthdr.csum_flags & CSUM_SCTP_VALID) { SCTP_STAT_INCR(sctps_recvhwcrc); compute_crc = 0; @@ -6361,7 +6338,7 @@ sctp_input(i_pak, va_alist) sh, ch, compute_crc, ecn_bits, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) mflowtype, mflowid, fibnum, #endif vrf_id, port); @@ -6372,11 +6349,13 @@ sctp_input(i_pak, va_alist) return; } -#if defined(__FreeBSD__) && defined(SCTP_MCORE_INPUT) && defined(SMP) +#if defined(__FreeBSD__) && !defined(__Userspace__) +#if defined(SCTP_MCORE_INPUT) && defined(SMP) extern int *sctp_cpuarry; #endif +#endif -#if defined(__FreeBSD__) && __FreeBSD_version >= 1100020 +#if defined(__FreeBSD__) && !defined(__Userspace__) int sctp_input(struct mbuf **mp, int *offp, int proto SCTP_UNUSED) { @@ -6390,7 +6369,8 @@ void sctp_input(struct mbuf *m, int off) { #endif -#if defined(__FreeBSD__) && defined(SCTP_MCORE_INPUT) && defined(SMP) +#if defined(__FreeBSD__) && !defined(__Userspace__) +#if defined(SCTP_MCORE_INPUT) && defined(SMP) if (mp_ncpus > 1) { struct ip *ip; struct sctphdr *sh; @@ -6408,11 +6388,7 @@ sctp_input(struct mbuf *m, int off) if (SCTP_BUF_LEN(m) < offset) { if ((m = m_pullup(m, offset)) == NULL) { SCTP_STAT_INCR(sctps_hdrops); -#if defined(__FreeBSD__) && __FreeBSD_version >= 1100020 return (IPPROTO_DONE); -#else - return; -#endif } } ip = mtod(m, struct ip *); @@ -6424,15 +6400,12 @@ sctp_input(struct mbuf *m, int off) } cpu_to_use = sctp_cpuarry[flowid % mp_ncpus]; sctp_queue_to_mcore(m, off, cpu_to_use); -#if defined(__FreeBSD__) && __FreeBSD_version >= 1100020 return (IPPROTO_DONE); -#else - return; -#endif } +#endif #endif sctp_input_with_port(m, off, 0); -#if defined(__FreeBSD__) && __FreeBSD_version >= 1100020 +#if defined(__FreeBSD__) && !defined(__Userspace__) return (IPPROTO_DONE); #endif } diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.h index 2d01beb08d..47ae2127be 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.h @@ -32,9 +32,9 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_input.h 326672 2017-12-07 22:19:08Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_input.h 365071 2020-09-01 21:19:14Z mjg $"); #endif #ifndef _NETINET_SCTP_INPUT_H_ @@ -47,7 +47,7 @@ sctp_common_input_processing(struct mbuf **, int, int, int, struct sctphdr *, struct sctp_chunkhdr *, uint8_t, uint8_t, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) uint8_t, uint32_t, uint16_t, #endif uint32_t, uint16_t); @@ -56,9 +56,9 @@ struct sctp_stream_reset_request * sctp_find_stream_reset(struct sctp_tcb *stcb, uint32_t seq, struct sctp_tmit_chunk **bchk); -void sctp_reset_in_stream(struct sctp_tcb *stcb, uint32_t number_entries, - uint16_t *list); - +void +sctp_reset_in_stream(struct sctp_tcb *stcb, uint32_t number_entries, + uint16_t *list); int sctp_is_there_unsent_data(struct sctp_tcb *stcb, int so_locked); diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_lock_userspace.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_lock_userspace.h index 7b8b0cbddd..99f1a89b0c 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_lock_userspace.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_lock_userspace.h @@ -33,7 +33,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include __FBSDID("$FreeBSD$"); #endif @@ -63,12 +63,15 @@ __FBSDID("$FreeBSD$"); #define SCTP_INP_INFO_TRYLOCK() 1 #define SCTP_INP_INFO_RUNLOCK() #define SCTP_INP_INFO_WUNLOCK() +#define SCTP_INP_INFO_LOCK_ASSERT() +#define SCTP_INP_INFO_RLOCK_ASSERT() +#define SCTP_INP_INFO_WLOCK_ASSERT() #define SCTP_WQ_ADDR_INIT() #define SCTP_WQ_ADDR_DESTROY() #define SCTP_WQ_ADDR_LOCK() #define SCTP_WQ_ADDR_UNLOCK() - +#define SCTP_WQ_ADDR_LOCK_ASSERT() #define SCTP_IPI_ADDR_INIT() #define SCTP_IPI_ADDR_DESTROY() @@ -76,20 +79,19 @@ __FBSDID("$FreeBSD$"); #define SCTP_IPI_ADDR_WLOCK() #define SCTP_IPI_ADDR_RUNLOCK() #define SCTP_IPI_ADDR_WUNLOCK() +#define SCTP_IPI_ADDR_LOCK_ASSERT() +#define SCTP_IPI_ADDR_WLOCK_ASSERT() #define SCTP_IPI_ITERATOR_WQ_INIT() #define SCTP_IPI_ITERATOR_WQ_DESTROY() #define SCTP_IPI_ITERATOR_WQ_LOCK() #define SCTP_IPI_ITERATOR_WQ_UNLOCK() - #define SCTP_IP_PKTLOG_INIT() #define SCTP_IP_PKTLOG_LOCK() #define SCTP_IP_PKTLOG_UNLOCK() #define SCTP_IP_PKTLOG_DESTROY() - - #define SCTP_INP_READ_INIT(_inp) #define SCTP_INP_READ_DESTROY(_inp) #define SCTP_INP_READ_LOCK(_inp) @@ -100,9 +102,10 @@ __FBSDID("$FreeBSD$"); #define SCTP_INP_LOCK_DESTROY(_inp) #define SCTP_ASOC_CREATE_LOCK_DESTROY(_inp) - #define SCTP_INP_RLOCK(_inp) #define SCTP_INP_WLOCK(_inp) +#define SCTP_INP_RLOCK_ASSERT(_inp) +#define SCTP_INP_WLOCK_ASSERT(_inp) #define SCTP_INP_LOCK_CONTENDED(_inp) (0) /* Don't know if this is possible */ @@ -115,6 +118,7 @@ __FBSDID("$FreeBSD$"); #define SCTP_TCB_SEND_LOCK_DESTROY(_tcb) #define SCTP_TCB_SEND_LOCK(_tcb) #define SCTP_TCB_SEND_UNLOCK(_tcb) +#define SCTP_TCB_SEND_LOCK_ASSERT(_tcb) #define SCTP_INP_INCR_REF(_inp) #define SCTP_INP_DECR_REF(_inp) @@ -214,14 +218,6 @@ __FBSDID("$FreeBSD$"); } while (0) -/* not sure if __Userspace__ needs these (but copied nonetheless...) */ -#if defined(SCTP_SO_LOCK_TESTING) -#define SCTP_INP_SO(sctpinp) (sctpinp)->ip_inp.inp.inp_socket -#define SCTP_SOCKET_LOCK(so, refcnt) -#define SCTP_SOCKET_UNLOCK(so, refcnt) -#endif - - /* these were in sctp_lock_empty.h but aren't in sctp_lock_bsd.h ... */ #if 0 #define SCTP_IPI_ADDR_LOCK() diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_os.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_os.h index b3746dd946..0e03ce9e59 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_os.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_os.h @@ -32,9 +32,9 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_os.h 235828 2012-05-23 11:26:28Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_os.h 365071 2020-09-01 21:19:14Z mjg $"); #endif #ifndef _NETINET_SCTP_OS_H_ @@ -64,25 +64,18 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_os.h 235828 2012-05-23 11:26:28Z tuexe * SCTP_ZONE_DESTROY(zone) */ -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) #include #else #define MODULE_GLOBAL(_B) (_B) #endif - #if defined(__Userspace__) #include #endif - -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #include #endif - -#if defined(__Panda__) -#include -#endif - -#if defined(__Windows__) +#if defined(_WIN32) && !defined(__Userspace__) #include #endif diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_os_userspace.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_os_userspace.h index f09cb8da25..9fb145a3a9 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_os_userspace.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_os_userspace.h @@ -43,7 +43,7 @@ #include -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) #include #include #include @@ -52,6 +52,7 @@ #include "user_environment.h" typedef CRITICAL_SECTION userland_mutex_t; #if WINVER < 0x0600 +typedef CRITICAL_SECTION userland_rwlock_t; enum { C_SIGNAL = 0, C_BROADCAST = 1, @@ -72,6 +73,7 @@ void WakeAllXPConditionVariable(userland_cond_t *); #define SleepConditionVariableCS(cond, mtx, time) SleepXPConditionVariable(cond, mtx) #define WakeAllConditionVariable(cond) WakeAllXPConditionVariable(cond) #else +typedef SRWLOCK userland_rwlock_t; #define DeleteConditionVariable(cond) typedef CONDITION_VARIABLE userland_cond_t; #endif @@ -83,28 +85,24 @@ typedef HANDLE userland_thread_t; #if !defined(_MSC_VER) || (_MSC_VER >= 1600) #include #else -#define uint64_t unsigned __int64 -#define uint32_t unsigned __int32 -#define int32_t __int32 -#define uint16_t unsigned __int16 -#define int16_t __int16 -#define uint8_t unsigned __int8 -#define int8_t __int8 +typedef unsigned __int64 uint64_t; +typedef unsigned __int32 uint32_t; +typedef __int32 int32_t; +typedef unsigned __int16 uint16_t; +typedef __int16 int16_t; +typedef unsigned __int8 uint8_t; +typedef __int8 int8_t; #endif #ifndef _SIZE_T_DEFINED -#define size_t __int32 +#typedef __int32 size_t; +#endif +typedef unsigned __int32 u_int; +typedef unsigned char u_char; +typedef unsigned __int16 u_short; +typedef unsigned __int8 sa_family_t; +#ifndef _SSIZE_T_DEFINED +typedef __int64 ssize_t; #endif -#define u_long unsigned __int64 -#define u_int unsigned __int32 -#define u_int32_t unsigned __int32 -#define u_int16_t unsigned __int16 -#define u_int8_t unsigned __int8 -#define u_char unsigned char -#define n_short unsigned __int16 -#define u_short unsigned __int16 -#define n_time unsigned __int32 -#define sa_family_t unsigned __int8 -#define ssize_t __int64 #if !defined(__MINGW32__) #define __func__ __FUNCTION__ #endif @@ -221,9 +219,19 @@ typedef char* caddr_t; #define bzero(buf, len) memset(buf, 0, len) #define bcopy(srcKey, dstKey, len) memcpy(dstKey, srcKey, len) + #if defined(_MSC_VER) && (_MSC_VER < 1900) && !defined(__MINGW32__) -#define snprintf(data, size, format, ...) _snprintf_s(data, size, _TRUNCATE, format, __VA_ARGS__) +#define SCTP_SNPRINTF(data, size, format, ...) \ + if (_snprintf_s(data, size, _TRUNCATE, format, __VA_ARGS__) < 0) { \ + data[0] = '\0'; \ + } +#else +#define SCTP_SNPRINTF(data, ...) \ + if (snprintf(data, __VA_ARGS__) < 0 ) { \ + data[0] = '\0'; \ + } #endif + #define inline __inline #define __inline__ __inline #define MSG_EOR 0x8 /* data completes record */ @@ -277,15 +285,20 @@ typedef char* caddr_t; #else /* !defined(Userspace_os_Windows) */ #include -#if defined(__Userspace_os_DragonFly) || defined(__Userspace_os_FreeBSD) || defined(__Userspace_os_Linux) || defined(__Userspace_os_NetBSD) || defined(__Userspace_os_OpenBSD) || defined(__Userspace_os_NaCl) || defined(__Userspace_os_Fuchsia) -#include + +#if defined(__EMSCRIPTEN__) && !defined(__EMSCRIPTEN_PTHREADS__) +#error "Unsupported build configuration." #endif + +#include + typedef pthread_mutex_t userland_mutex_t; +typedef pthread_rwlock_t userland_rwlock_t; typedef pthread_cond_t userland_cond_t; typedef pthread_t userland_thread_t; #endif -#if defined(__Userspace_os_Windows) || defined(__Userspace_os_NaCl) +#if defined(_WIN32) || defined(__native_client__) #define IFNAMSIZ 64 @@ -379,43 +392,9 @@ struct ifkpi { int ifk_value; } ifk_data; }; - -struct ifreq { - char ifr_name[16]; - union { - struct sockaddr ifru_addr; - struct sockaddr ifru_dstaddr; - struct sockaddr ifru_broadaddr; - short ifru_flags; - int ifru_metric; - int ifru_mtu; - int ifru_phys; - int ifru_media; - int ifru_intval; - char* ifru_data; - struct ifdevmtu ifru_devmtu; - struct ifkpi ifru_kpi; - uint32_t ifru_wake_flags; - } ifr_ifru; -#define ifr_addr ifr_ifru.ifru_addr -#define ifr_dstaddr ifr_ifru.ifru_dstaddr -#define ifr_broadaddr ifr_ifru.ifru_broadaddr -#define ifr_flags ifr_ifru.ifru_flags[0] -#define ifr_prevflags ifr_ifru.ifru_flags[1] -#define ifr_metric ifr_ifru.ifru_metric -#define ifr_mtu ifr_ifru.ifru_mtu -#define ifr_phys ifr_ifru.ifru_phys -#define ifr_media ifr_ifru.ifru_media -#define ifr_data ifr_ifru.ifru_data -#define ifr_devmtu ifr_ifru.ifru_devmtu -#define ifr_intval ifr_ifru.ifru_intval -#define ifr_kpi ifr_ifru.ifru_kpi -#define ifr_wake_flags ifr_ifru.ifru_wake_flags -}; - #endif -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) int Win_getifaddrs(struct ifaddrs**); #define getifaddrs(interfaces) (int)Win_getifaddrs(interfaces) int win_if_nametoindex(const char *); @@ -426,9 +405,9 @@ int win_if_nametoindex(const char *); #define mtx_unlock(arg1) #define mtx_assert(arg1,arg2) #define MA_OWNED 7 /* sys/mutex.h typically on FreeBSD */ -#if !defined(__Userspace_os_FreeBSD) +#if !defined(__FreeBSD__) struct mtx {int dummy;}; -#if !defined(__Userspace_os_NetBSD) +#if !defined(__NetBSD__) struct selinfo {int dummy;}; #endif struct sx {int dummy;}; @@ -436,6 +415,7 @@ struct sx {int dummy;}; #include #include +#include /* #include in FreeBSD defines MSIZE */ /* #include */ /* #include */ @@ -458,22 +438,22 @@ struct sx {int dummy;}; #include /* #include */ /* #include */ -#if defined(__FreeBSD__) && __FreeBSD_version > 602000 +#if defined(__FreeBSD__) && !defined(__Userspace__) #include #endif /* #include */ -#if defined(__FreeBSD__) && __FreeBSD_version > 602000 +#if defined(__FreeBSD__) && !defined(__Userspace__) #include #endif /* #include */ #include /* #include */ -#if defined(__Userspace_os_Darwin) +#if defined(__APPLE__) /* was a 0 byte file. needed for structs if_data(64) and net_event_data */ #include #endif -#if defined(__Userspace_os_FreeBSD) +#if defined(__FreeBSD__) #include /* #include was a 0 byte file. causes struct mtx redefinition */ #endif @@ -481,7 +461,7 @@ struct sx {int dummy;}; * userspace as well? */ /* on FreeBSD, this results in a redefintion of struct route */ /* #include */ -#if !defined(__Userspace_os_Windows) && !defined(__Userspace_os_NaCl) +#if !defined(_WIN32) && !defined(__native_client__) #include #include #include @@ -497,7 +477,7 @@ struct sx {int dummy;}; /* for getifaddrs */ #include -#if !defined(__Userspace_os_Windows) +#if !defined(_WIN32) #if defined(INET) || defined(INET6) #include #endif @@ -507,6 +487,8 @@ struct sx {int dummy;}; /* for close, etc. */ #include +/* for gettimeofday */ +#include #endif /* lots of errno's used and needed in userspace */ @@ -514,7 +496,7 @@ struct sx {int dummy;}; /* for offsetof */ #include -#if defined(SCTP_PROCESS_LEVEL_LOCKS) && !defined(__Userspace_os_Windows) +#if defined(SCTP_PROCESS_LEVEL_LOCKS) && !defined(_WIN32) /* for pthread_mutex_lock, pthread_mutex_unlock, etc. */ #include #endif @@ -525,21 +507,21 @@ struct sx {int dummy;}; #endif /* IPSEC */ #ifdef INET6 -#if defined(__Userspace_os_FreeBSD) +#if defined(__FreeBSD__) #include #endif #ifdef IPSEC #include #endif -#if !defined(__Userspace_os_Windows) +#if !defined(_WIN32) #include #endif -#if defined(__Userspace_os_Darwin) || defined(__Userspace_os_FreeBSD) || defined(__Userspace_os_Linux) || defined(__Userspace_os_NetBSD) || defined(__Userspace_os_OpenBSD) || defined(__Userspace_os_Windows) +#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__linux__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(_WIN32) || defined(__EMSCRIPTEN__) #include "user_ip6_var.h" #else #include #endif -#if defined(__Userspace_os_FreeBSD) +#if defined(__FreeBSD__) #include #include /* #include was a 0 byte file */ @@ -554,7 +536,7 @@ struct sx {int dummy;}; #include "netinet/sctp_sha1.h" -#if __FreeBSD_version >= 700000 +#if defined(__FreeBSD__) && !defined(__Userspace__) #include #endif @@ -607,12 +589,12 @@ MALLOC_DECLARE(SCTP_M_SOCKOPT); /* * */ -#if !defined(__Userspace_os_Darwin) +#if !defined(__APPLE__) #define USER_ADDR_NULL (NULL) /* FIX ME: temp */ #endif -#if defined(SCTP_DEBUG) #include +#if defined(SCTP_DEBUG) #define SCTPDBG(level, ...) \ { \ do { \ @@ -666,7 +648,7 @@ MALLOC_DECLARE(SCTP_M_SOCKOPT); #define SCTP_VRF_IFN_HASH_SIZE 3 #define SCTP_INIT_VRF_TABLEID(vrf) -#if !defined(__Userspace_os_Windows) +#if !defined(_WIN32) #define SCTP_IFN_IS_IFT_LOOP(ifn) (strncmp((ifn)->ifn_name, "lo", 2) == 0) /* BSD definition */ /* #define SCTP_ROUTE_IS_REAL_LOOP(ro) ((ro)->ro_rt && (ro)->ro_rt->rt_ifa && (ro)->ro_rt->rt_ifa->ifa_ifp && (ro)->ro_rt->rt_ifa->ifa_ifp->if_type == IFT_LOOP) */ @@ -800,7 +782,7 @@ sctp_hashfreedestroy(void *vhashtbl, struct malloc_type *type, u_long hashmask); #define KTR_SUBSYS 1 /* The packed define for 64 bit platforms */ -#if !defined(__Userspace_os_Windows) +#if !defined(_WIN32) #define SCTP_PACKED __attribute__((packed)) #define SCTP_UNUSED __attribute__((unused)) #else @@ -829,6 +811,13 @@ sctp_hashfreedestroy(void *vhashtbl, struct malloc_type *type, u_long hashmask); M_ALIGN(m, len); \ } +#if !defined(_WIN32) +#define SCTP_SNPRINTF(data, ...) \ + if (snprintf(data, __VA_ARGS__) < 0) { \ + data[0] = '\0'; \ + } +#endif + /* We make it so if you have up to 4 threads * writting based on the default size of * the packet log 65 k, that would be @@ -887,7 +876,6 @@ static inline void sctp_userspace_rtfree(sctp_rtentry_t *rt) return; } free(rt); - rt = NULL; } #define rtfree(arg1) sctp_userspace_rtfree(arg1) @@ -901,17 +889,13 @@ int sctp_userspace_get_mtu_from_ifn(uint32_t if_index, int af); #define SCTP_GATHER_MTU_FROM_ROUTE(sctp_ifa, sa, rt) ((rt != NULL) ? rt->rt_rmx.rmx_mtu : 0) -#define SCTP_GATHER_MTU_FROM_INTFC(sctp_ifn) sctp_userspace_get_mtu_from_ifn(if_nametoindex(((struct ifaddrs *) (sctp_ifn))->ifa_name), AF_INET) +#define SCTP_GATHER_MTU_FROM_INTFC(sctp_ifn) (sctp_ifn->ifn_mtu) #define SCTP_SET_MTU_OF_ROUTE(sa, rt, mtu) do { \ if (rt != NULL) \ rt->rt_rmx.rmx_mtu = mtu; \ } while(0) -/* (de-)register interface event notifications */ -#define SCTP_REGISTER_INTERFACE(ifhandle, af) -#define SCTP_DEREGISTER_INTERFACE(ifhandle, af) - /*************************/ /* These are for logging */ @@ -961,7 +945,7 @@ int sctp_userspace_get_mtu_from_ifn(uint32_t if_index, int af); */ /* get the v6 hop limit */ -#define SCTP_GET_HLIM(inp, ro) 128 /* As done for __Windows__ */ +#define SCTP_GET_HLIM(inp, ro) 128 #define IPv6_HOP_LIMIT 128 /* is the endpoint v6only? */ @@ -1000,7 +984,7 @@ int sctp_userspace_get_mtu_from_ifn(uint32_t if_index, int af); /* sctp_pcb.h */ -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) #define SHUT_RD 1 #define SHUT_WR 2 #define SHUT_RDWR 3 @@ -1057,13 +1041,13 @@ extern void sctp_userspace_ip_output(int *result, struct mbuf *o_pak, sctp_route_t *ro, void *stcb, uint32_t vrf_id); -#define SCTP_IP_OUTPUT(result, o_pak, ro, stcb, vrf_id) sctp_userspace_ip_output(&result, o_pak, ro, stcb, vrf_id); +#define SCTP_IP_OUTPUT(result, o_pak, ro, inp, vrf_id) sctp_userspace_ip_output(&result, o_pak, ro, inp, vrf_id); #if defined(INET6) extern void sctp_userspace_ip6_output(int *result, struct mbuf *o_pak, struct route_in6 *ro, void *stcb, uint32_t vrf_id); -#define SCTP_IP6_OUTPUT(result, o_pak, ro, ifp, stcb, vrf_id) sctp_userspace_ip6_output(&result, o_pak, ro, stcb, vrf_id); +#define SCTP_IP6_OUTPUT(result, o_pak, ro, ifp, inp, vrf_id) sctp_userspace_ip6_output(&result, o_pak, ro, inp, vrf_id); #endif @@ -1087,12 +1071,12 @@ sctp_get_mbuf_for_msg(unsigned int space_needed, int want_header, int how, int a /* with the current included files, this is defined in Linux but * in FreeBSD, it is behind a _KERNEL in sys/socket.h ... */ -#if defined(__Userspace_os_DragonFly) || defined(__Userspace_os_FreeBSD) || defined(__Userspace_os_OpenBSD) || defined(__Userspace_os_NaCl) +#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__native_client__) /* stolen from /usr/include/sys/socket.h */ #define CMSG_ALIGN(n) _ALIGN(n) -#elif defined(__Userspace_os_NetBSD) +#elif defined(__NetBSD__) #define CMSG_ALIGN(n) (((n) + __ALIGNBYTES) & ~__ALIGNBYTES) -#elif defined(__Userspace_os_Darwin) +#elif defined(__APPLE__) #if !defined(__DARWIN_ALIGNBYTES) #define __DARWIN_ALIGNBYTES (sizeof(__darwin_size_t) - 1) #endif @@ -1127,7 +1111,7 @@ sctp_get_mbuf_for_msg(unsigned int space_needed, int want_header, int how, int a } while (0) #endif -#if defined(__Userspace_os_Linux) +#if defined(__linux__) #if !defined(TAILQ_FOREACH_SAFE) #define TAILQ_FOREACH_SAFE(var, head, field, tvar) \ for ((var) = ((head)->tqh_first); \ @@ -1141,12 +1125,12 @@ sctp_get_mbuf_for_msg(unsigned int space_needed, int want_header, int how, int a (var) = (tvar)) #endif #endif -#if defined(__Userspace_os_DragonFly) +#if defined(__DragonFly__) #define TAILQ_FOREACH_SAFE TAILQ_FOREACH_MUTABLE #define LIST_FOREACH_SAFE LIST_FOREACH_MUTABLE #endif -#if defined(__Userspace_os_NaCl) +#if defined(__native_client__) #define timercmp(tvp, uvp, cmp) \ (((tvp)->tv_sec == (uvp)->tv_sec) ? \ ((tvp)->tv_usec cmp (uvp)->tv_usec) : \ @@ -1155,7 +1139,7 @@ sctp_get_mbuf_for_msg(unsigned int space_needed, int want_header, int how, int a #define SCTP_IS_LISTENING(inp) ((inp->sctp_flags & SCTP_PCB_FLAGS_ACCEPTING) != 0) -#if defined(__Userspace_os_Darwin) || defined(__Userspace_os_DragonFly) || defined(__Userspace_os_Linux) || defined(__Userspace_os_NaCl) || defined(__Userspace_os_NetBSD) || defined(__Userspace_os_Windows) || defined(__Userspace_os_Fuchsia) +#if defined(__APPLE__) || defined(__DragonFly__) || defined(__linux__) || defined(__native_client__) || defined(__NetBSD__) || defined(_WIN32) || defined(__Fuchsia__) || defined(__EMSCRIPTEN__) int timingsafe_bcmp(const void *, const void *, size_t); #endif diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_output.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_output.c index acc7307b9a..350c1fd4f0 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_output.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_output.c @@ -32,13 +32,13 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.c 357197 2020-01-28 10:09:05Z tuexen $"); +__FBSDID("$FreeBSD$"); #endif #include -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include #endif #include @@ -56,35 +56,30 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_output.c 357197 2020-01-28 10:09:05Z t #include #include #include -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) #include #endif -#if defined(__Userspace_os_Linux) +#if defined(__linux__) #define __FAVOR_BSD /* (on Ubuntu at least) enables UDP header field names like BSD in RFC 768 */ #endif #if defined(INET) || defined(INET6) -#if !defined(__Userspace_os_Windows) +#if !defined(_WIN32) #include #endif #endif +#if !defined(__Userspace__) #if defined(__APPLE__) #include #endif -#if defined(__FreeBSD__) -#if defined(__FreeBSD__) && __FreeBSD_version >= 800000 +#if defined(__FreeBSD__) && !defined(__Userspace__) #include -#endif #include #endif +#endif #if defined(__Userspace__) && defined(INET6) #include #endif - -#if defined(__APPLE__) -#define APPLE_FILE_NO 3 -#endif - -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #if !(defined(APPLE_LEOPARD) || defined(APPLE_SNOWLEOPARD)) #define SCTP_MAX_LINKHDR 16 #endif @@ -1894,7 +1889,6 @@ const struct sack_track sack_array[256] = { } }; - int sctp_is_address_in_scope(struct sctp_ifa *ifa, struct sctp_scoping *scope, @@ -1933,14 +1927,12 @@ sctp_is_address_in_scope(struct sctp_ifa *ifa, if (scope->ipv6_addr_legal) { struct sockaddr_in6 *sin6; -#if !defined(__Panda__) /* Must update the flags, bummer, which * means any IFA locks must now be applied HERE <-> */ if (do_update) { sctp_gather_internal_ifa_flags(ifa); } -#endif if (ifa->localifa_flags & SCTP_ADDR_IFA_UNUSEABLE) { return (0); } @@ -2065,7 +2057,6 @@ sctp_add_addr_to_mbuf(struct mbuf *m, struct sctp_ifa *ifa, uint16_t *len) #endif } - struct mbuf * sctp_add_addresses_to_i_ia(struct sctp_inpcb *inp, struct sctp_tcb *stcb, struct sctp_scoping *scope, @@ -2103,7 +2094,7 @@ sctp_add_addresses_to_i_ia(struct sctp_inpcb *inp, struct sctp_tcb *stcb, continue; } LIST_FOREACH(sctp_ifap, &sctp_ifnp->ifalist, next_ifa) { -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) #ifdef INET if ((sctp_ifap->address.sa.sa_family == AF_INET) && (prison_check_ip4(inp->ip_inp.inp.inp_cred, @@ -2153,7 +2144,7 @@ sctp_add_addresses_to_i_ia(struct sctp_inpcb *inp, struct sctp_tcb *stcb, continue; } LIST_FOREACH(sctp_ifap, &sctp_ifnp->ifalist, next_ifa) { -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) #ifdef INET if ((sctp_ifap->address.sa.sa_family == AF_INET) && (prison_check_ip4(inp->ip_inp.inp.inp_cred, @@ -2486,7 +2477,6 @@ sctp_is_addr_restricted(struct sctp_tcb *stcb, struct sctp_ifa *ifa) return (0); } - int sctp_is_addr_in_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa) { @@ -2507,8 +2497,6 @@ sctp_is_addr_in_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa) return (0); } - - static struct sctp_ifa * sctp_choose_boundspecific_inp(struct sctp_inpcb *inp, sctp_route_t *ro, @@ -2541,7 +2529,7 @@ sctp_choose_boundspecific_inp(struct sctp_inpcb *inp, if (sctp_ifn) { /* is a preferred one on the interface we route out? */ LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) { -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) #ifdef INET if ((sctp_ifa->address.sa.sa_family == AF_INET) && (prison_check_ip4(inp->ip_inp.inp.inp_cred, @@ -2643,8 +2631,6 @@ sctp_choose_boundspecific_inp(struct sctp_inpcb *inp, return (NULL); } - - static struct sctp_ifa * sctp_choose_boundspecific_stcb(struct sctp_inpcb *inp, struct sctp_tcb *stcb, @@ -2673,7 +2659,7 @@ sctp_choose_boundspecific_stcb(struct sctp_inpcb *inp, ifn = SCTP_GET_IFN_VOID_FROM_ROUTE(ro); ifn_index = SCTP_GET_IF_INDEX_FROM_ROUTE(ro); - sctp_ifn = sctp_find_ifn( ifn, ifn_index); + sctp_ifn = sctp_find_ifn(ifn, ifn_index); /* * first question, is the ifn we will emit on in our list? If so, @@ -2683,7 +2669,7 @@ sctp_choose_boundspecific_stcb(struct sctp_inpcb *inp, if (sctp_ifn) { /* first try for a preferred address on the ep */ LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) { -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) #ifdef INET if ((sctp_ifa->address.sa.sa_family == AF_INET) && (prison_check_ip4(inp->ip_inp.inp.inp_cred, @@ -2719,7 +2705,7 @@ sctp_choose_boundspecific_stcb(struct sctp_inpcb *inp, } /* next try for an acceptable address on the ep */ LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) { -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) #ifdef INET if ((sctp_ifa->address.sa.sa_family == AF_INET) && (prison_check_ip4(inp->ip_inp.inp.inp_cred, @@ -2753,7 +2739,6 @@ sctp_choose_boundspecific_stcb(struct sctp_inpcb *inp, return (sifa); } } - } /* * if we can't find one like that then we must look at all @@ -2840,19 +2825,18 @@ sctp_choose_boundspecific_stcb(struct sctp_inpcb *inp, static struct sctp_ifa * sctp_select_nth_preferred_addr_from_ifn_boundall(struct sctp_ifn *ifn, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) struct sctp_inpcb *inp, #else struct sctp_inpcb *inp SCTP_UNUSED, #endif - struct sctp_tcb *stcb, - int non_asoc_addr_ok, - uint8_t dest_is_loop, - uint8_t dest_is_priv, - int addr_wanted, - sa_family_t fam, - sctp_route_t *ro - ) + struct sctp_tcb *stcb, + int non_asoc_addr_ok, + uint8_t dest_is_loop, + uint8_t dest_is_priv, + int addr_wanted, + sa_family_t fam, + sctp_route_t *ro) { struct sctp_ifa *ifa, *sifa; int num_eligible_addr = 0; @@ -2871,7 +2855,7 @@ sctp_select_nth_preferred_addr_from_ifn_boundall(struct sctp_ifn *ifn, #endif /* SCTP_EMBEDDED_V6_SCOPE */ #endif /* INET6 */ LIST_FOREACH(ifa, &ifn->ifalist, next_ifa) { -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) #ifdef INET if ((ifa->address.sa.sa_family == AF_INET) && (prison_check_ip4(inp->ip_inp.inp.inp_cred, @@ -2971,10 +2955,9 @@ sctp_select_nth_preferred_addr_from_ifn_boundall(struct sctp_ifn *ifn, return (NULL); } - static int sctp_count_num_preferred_boundall(struct sctp_ifn *ifn, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) struct sctp_inpcb *inp, #else struct sctp_inpcb *inp SCTP_UNUSED, @@ -2989,7 +2972,7 @@ sctp_count_num_preferred_boundall(struct sctp_ifn *ifn, int num_eligible_addr = 0; LIST_FOREACH(ifa, &ifn->ifalist, next_ifa) { -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) #ifdef INET if ((ifa->address.sa.sa_family == AF_INET) && (prison_check_ip4(inp->ip_inp.inp.inp_cred, @@ -3199,7 +3182,7 @@ again_with_private_addresses_allowed: } LIST_FOREACH(sctp_ifa, &emit_ifn->ifalist, next_ifa) { SCTPDBG(SCTP_DEBUG_OUTPUT2, "ifa:%p\n", (void *)sctp_ifa); -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) #ifdef INET if ((sctp_ifa->address.sa.sa_family == AF_INET) && (prison_check_ip4(inp->ip_inp.inp.inp_cred, @@ -3265,7 +3248,7 @@ again_with_private_addresses_allowed: continue; } LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) { -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) #ifdef INET if ((sctp_ifa->address.sa.sa_family == AF_INET) && (prison_check_ip4(inp->ip_inp.inp.inp_cred, @@ -3333,7 +3316,7 @@ out: LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) { struct sctp_ifa *tmp_sifa; -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) #ifdef INET if ((sctp_ifa->address.sa.sa_family == AF_INET) && (prison_check_ip4(inp->ip_inp.inp.inp_cred, @@ -3391,8 +3374,6 @@ out: return (sifa); } - - /* tcb may be NULL */ struct sctp_ifa * sctp_source_address_selection(struct sctp_inpcb *inp, @@ -3474,16 +3455,24 @@ sctp_source_address_selection(struct sctp_inpcb *inp, * addresses. If the bound set is NOT assigned to the interface then * we must use rotation amongst the bound addresses.. */ +#if defined(__FreeBSD__) && !defined(__Userspace__) + if (ro->ro_nh == NULL) { +#else if (ro->ro_rt == NULL) { +#endif /* * Need a route to cache. */ SCTP_RTALLOC(ro, vrf_id, inp->fibnum); } +#if defined(__FreeBSD__) && !defined(__Userspace__) + if (ro->ro_nh == NULL) { +#else if (ro->ro_rt == NULL) { +#endif return (NULL); } -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) /* On Windows the sa_family is U_SHORT or ADDRESS_FAMILY */ fam = (sa_family_t)ro->ro_dst.sa_family; #else @@ -3509,7 +3498,7 @@ sctp_source_address_selection(struct sctp_inpcb *inp, #ifdef INET6 case AF_INET6: /* Scope based on outbound address */ -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) if (IN6_IS_ADDR_LOOPBACK(&to6->sin6_addr)) { #else if (IN6_IS_ADDR_LOOPBACK(&to6->sin6_addr) || @@ -3566,7 +3555,7 @@ sctp_source_address_selection(struct sctp_inpcb *inp, static int sctp_find_cmsg(int c_type, void *data, struct mbuf *control, size_t cpsize) { -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) WSACMSGHDR cmh; #else struct cmsghdr cmh; @@ -3671,7 +3660,7 @@ sctp_find_cmsg(int c_type, void *data, struct mbuf *control, size_t cpsize) static int sctp_process_cmsgs_for_init(struct sctp_tcb *stcb, struct mbuf *control, int *error) { -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) WSACMSGHDR cmh; #else struct cmsghdr cmh; @@ -3747,9 +3736,8 @@ sctp_process_cmsgs_for_init(struct sctp_tcb *stcb, struct mbuf *control, int *er } for (i = 0; i < stcb->asoc.streamoutcnt; i++) { TAILQ_INIT(&stcb->asoc.strmout[i].outqueue); + stcb->asoc.ss_functions.sctp_ss_init_stream(stcb, &stcb->asoc.strmout[i], NULL); stcb->asoc.strmout[i].chunks_on_queues = 0; - stcb->asoc.strmout[i].next_mid_ordered = 0; - stcb->asoc.strmout[i].next_mid_unordered = 0; #if defined(SCTP_DETAILED_STR_STATS) for (j = 0; j < SCTP_PR_SCTP_MAX + 1; j++) { stcb->asoc.strmout[i].abandoned_sent[j] = 0; @@ -3759,10 +3747,11 @@ sctp_process_cmsgs_for_init(struct sctp_tcb *stcb, struct mbuf *control, int *er stcb->asoc.strmout[i].abandoned_sent[0] = 0; stcb->asoc.strmout[i].abandoned_unsent[0] = 0; #endif + stcb->asoc.strmout[i].next_mid_ordered = 0; + stcb->asoc.strmout[i].next_mid_unordered = 0; stcb->asoc.strmout[i].sid = i; stcb->asoc.strmout[i].last_msg_incomplete = 0; stcb->asoc.strmout[i].state = SCTP_STREAM_OPENING; - stcb->asoc.ss_functions.sctp_ss_init_stream(stcb, &stcb->asoc.strmout[i], NULL); } } break; @@ -3849,7 +3838,7 @@ sctp_findassociation_cmsgs(struct sctp_inpcb **inp_p, struct sctp_nets **net_p, int *error) { -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) WSACMSGHDR cmh; #else struct cmsghdr cmh; @@ -3948,8 +3937,6 @@ sctp_add_cookie(struct mbuf *init, int init_offset, struct mbuf *copy_init, *copy_initack, *m_at, *sig, *mret; struct sctp_state_cookie *stc; struct sctp_paramhdr *ph; - uint8_t *foo; - int sig_offset; uint16_t cookie_sz; mret = sctp_get_mbuf_for_msg((sizeof(struct sctp_state_cookie) + @@ -4013,25 +4000,21 @@ sctp_add_cookie(struct mbuf *init, int init_offset, break; } } - sig = sctp_get_mbuf_for_msg(SCTP_SECRET_SIZE, 0, M_NOWAIT, 1, MT_DATA); + sig = sctp_get_mbuf_for_msg(SCTP_SIGNATURE_SIZE, 0, M_NOWAIT, 1, MT_DATA); if (sig == NULL) { /* no space, so free the entire chain */ sctp_m_freem(mret); return (NULL); } - SCTP_BUF_LEN(sig) = 0; SCTP_BUF_NEXT(m_at) = sig; - sig_offset = 0; - foo = (uint8_t *) (mtod(sig, caddr_t) + sig_offset); - memset(foo, 0, SCTP_SIGNATURE_SIZE); - *signature = foo; - SCTP_BUF_LEN(sig) += SCTP_SIGNATURE_SIZE; + SCTP_BUF_LEN(sig) = SCTP_SIGNATURE_SIZE; cookie_sz += SCTP_SIGNATURE_SIZE; ph->param_length = htons(cookie_sz); + *signature = (uint8_t *)mtod(sig, caddr_t); + memset(*signature, 0, SCTP_SIGNATURE_SIZE); return (mret); } - static uint8_t sctp_get_ect(struct sctp_tcb *stcb) { @@ -4105,15 +4088,10 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, uint32_t v_tag, uint16_t port, union sctp_sockstore *over_addr, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) uint8_t mflowtype, uint32_t mflowid, #endif -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - int so_locked SCTP_UNUSED -#else - int so_locked -#endif - ) +int so_locked) /* nofragment_flag to tell if IP_DF should be set (IPv4 only) */ { /** @@ -4129,9 +4107,6 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, * interface and smallest_mtu size as well. */ /* Will need ifdefs around this */ -#ifdef __Panda__ - pakhandle_type o_pak; -#endif struct mbuf *newm; struct sctphdr *sctphdr; int packet_length; @@ -4140,18 +4115,16 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, uint32_t vrf_id; #endif #if defined(INET) || defined(INET6) -#if !defined(__Panda__) struct mbuf *o_pak; -#endif sctp_route_t *ro = NULL; struct udphdr *udp = NULL; #endif uint8_t tos_value; -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) struct socket *so = NULL; #endif -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) if (so_locked) { sctp_lock_assert(SCTP_INP_SO(inp)); SCTP_TCB_LOCK_ASSERT(stcb); @@ -4206,7 +4179,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, SCTP_BUF_LEN(newm) = len; SCTP_BUF_NEXT(newm) = m; m = newm; -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (net != NULL) { m->m_pkthdr.flowid = net->flowid; M_HASHTYPE_SET(m, net->flowtype); @@ -4224,36 +4197,30 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, * This means especially, that it is not set at the * SCTP layer. So use the value from the IP layer. */ -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Panda__) || defined(__Windows__) || defined(__Userspace__) tos_value = inp->ip_inp.inp.inp_ip_tos; -#else - tos_value = inp->inp_ip_tos; -#endif } tos_value &= 0xfc; if (ecn_ok) { tos_value |= sctp_get_ect(stcb); } if ((nofragment_flag) && (port == 0)) { -#if defined(__FreeBSD__) -#if __FreeBSD_version >= 1000000 +#if defined(__FreeBSD__) && !defined(__Userspace__) ip->ip_off = htons(IP_DF); -#else - ip->ip_off = IP_DF; -#endif -#elif defined(WITH_CONVERT_IP_OFF) || defined(__APPLE__) || defined(__Userspace_os_Darwin) +#elif defined(WITH_CONVERT_IP_OFF) || defined(__APPLE__) ip->ip_off = IP_DF; #else ip->ip_off = htons(IP_DF); #endif } else { -#if defined(__FreeBSD__) && __FreeBSD_version >= 1000000 +#if defined(__FreeBSD__) && !defined(__Userspace__) ip->ip_off = htons(0); #else ip->ip_off = 0; #endif } -#if defined(__FreeBSD__) +#if defined(__Userspace__) + ip->ip_id = htons(SCTP_IP_ID(inp)++); +#elif defined(__FreeBSD__) /* FreeBSD has a function for ip_id's */ ip_fillid(ip); #elif defined(__APPLE__) @@ -4262,18 +4229,12 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, #else ip->ip_id = htons(ip_id++); #endif -#elif defined(__Userspace__) - ip->ip_id = htons(SCTP_IP_ID(inp)++); #else ip->ip_id = SCTP_IP_ID(inp)++; #endif -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Panda__) || defined(__Windows__) || defined(__Userspace__) ip->ip_ttl = inp->ip_inp.inp.inp_ip_ttl; -#else - ip->ip_ttl = inp->inp_ip_ttl; -#endif -#if defined(__FreeBSD__) && __FreeBSD_version >= 1000000 +#if defined(__FreeBSD__) && !defined(__Userspace__) ip->ip_len = htons(packet_length); #else ip->ip_len = packet_length; @@ -4305,10 +4266,14 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, sctp_free_ifa(net->ro._s_addr); net->ro._s_addr = NULL; net->src_addr_selected = 0; +#if defined(__FreeBSD__) && !defined(__Userspace__) + RO_NHFREE(ro); +#else if (ro->ro_rt) { RTFREE(ro->ro_rt); ro->ro_rt = NULL; } +#endif } if (net->src_addr_selected == 0) { /* Cache the source address */ @@ -4358,8 +4323,8 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, udp->uh_sport = htons(SCTP_BASE_SYSCTL(sctp_udp_tunneling_port)); udp->uh_dport = port; udp->uh_ulen = htons((uint16_t)(packet_length - sizeof(struct ip))); -#if !defined(__Windows__) && !defined(__Userspace__) -#if defined(__FreeBSD__) && ((__FreeBSD_version > 803000 && __FreeBSD_version < 900000) || __FreeBSD_version > 900000) +#if !defined(__Userspace__) +#if defined(__FreeBSD__) if (V_udp_cksum) { udp->uh_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP)); } else { @@ -4388,7 +4353,11 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, * that somewhere and abort the association right away * (assuming this is an INIT being sent). */ +#if defined(__FreeBSD__) && !defined(__Userspace__) + if (ro->ro_nh == NULL) { +#else if (ro->ro_rt == NULL) { +#endif /* * src addr selection failed to find a route (or * valid source addr), so we can't get there from @@ -4406,8 +4375,13 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, (uint32_t) (ntohl(ip->ip_src.s_addr))); SCTPDBG(SCTP_DEBUG_OUTPUT3, "Destination is %x\n", (uint32_t)(ntohl(ip->ip_dst.s_addr))); +#if defined(__FreeBSD__) && !defined(__Userspace__) + SCTPDBG(SCTP_DEBUG_OUTPUT3, "RTP route is %p through\n", + (void *)ro->ro_nh); +#else SCTPDBG(SCTP_DEBUG_OUTPUT3, "RTP route is %p through\n", (void *)ro->ro_rt); +#endif if (SCTP_GET_HEADER_FOR_OUTPUT(o_pak)) { /* failed to prepend data, give up */ @@ -4419,8 +4393,8 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, if (port) { sctphdr->checksum = sctp_calculate_cksum(m, sizeof(struct ip) + sizeof(struct udphdr)); SCTP_STAT_INCR(sctps_sendswcrc); -#if !defined(__Windows__) && !defined(__Userspace__) -#if defined(__FreeBSD__) && ((__FreeBSD_version > 803000 && __FreeBSD_version < 900000) || __FreeBSD_version > 900000) +#if !defined(__Userspace__) +#if defined(__FreeBSD__) if (V_udp_cksum) { SCTP_ENABLE_UDP_CSUM(o_pak); } @@ -4429,7 +4403,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, #endif #endif } else { -#if defined(__FreeBSD__) && __FreeBSD_version >= 800000 +#if defined(__FreeBSD__) && !defined(__Userspace__) m->m_pkthdr.csum_flags = CSUM_SCTP; m->m_pkthdr.csum_data = offsetof(struct sctphdr, checksum); SCTP_STAT_INCR(sctps_sendhwcrc); @@ -4448,17 +4422,17 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, sctp_packet_log(o_pak); #endif /* send it out. table id is taken from stcb */ -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) if ((SCTP_BASE_SYSCTL(sctp_output_unlocked)) && (so_locked)) { so = SCTP_INP_SO(inp); SCTP_SOCKET_UNLOCK(so, 0); } #endif -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) SCTP_PROBE5(send, NULL, stcb, ip, stcb, sctphdr); #endif - SCTP_IP_OUTPUT(ret, o_pak, ro, stcb, vrf_id); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) + SCTP_IP_OUTPUT(ret, o_pak, ro, inp, vrf_id); +#if defined(__APPLE__) && !defined(__Userspace__) if ((SCTP_BASE_SYSCTL(sctp_output_unlocked)) && (so_locked)) { atomic_add_int(&stcb->asoc.refcnt, 1); SCTP_TCB_UNLOCK(stcb); @@ -4467,7 +4441,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, atomic_subtract_int(&stcb->asoc.refcnt, 1); } #endif -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (port) { UDPSTAT_INC(udps_opackets); } @@ -4480,8 +4454,8 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, SCTPDBG(SCTP_DEBUG_OUTPUT3, "IP output returns %d\n", ret); if (net == NULL) { /* free tempy routes */ -#if defined(__FreeBSD__) && __FreeBSD_version > 901000 - RO_RTFREE(ro); +#if defined(__FreeBSD__) && !defined(__Userspace__) + RO_NHFREE(ro); #else if (ro->ro_rt) { RTFREE(ro->ro_rt); @@ -4489,23 +4463,35 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, } #endif } else { +#if defined(__FreeBSD__) && !defined(__Userspace__) + if ((ro->ro_nh != NULL) && (net->ro._s_addr) && +#else if ((ro->ro_rt != NULL) && (net->ro._s_addr) && +#endif ((net->dest_state & SCTP_ADDR_NO_PMTUD) == 0)) { uint32_t mtu; +#if defined(__FreeBSD__) && !defined(__Userspace__) + mtu = SCTP_GATHER_MTU_FROM_ROUTE(net->ro._s_addr, &net->ro._l_addr.sa, ro->ro_nh); +#else mtu = SCTP_GATHER_MTU_FROM_ROUTE(net->ro._s_addr, &net->ro._l_addr.sa, ro->ro_rt); +#endif if (mtu > 0) { if (net->port) { mtu -= sizeof(struct udphdr); } if (mtu < net->mtu) { - if ((stcb != NULL) && (stcb->asoc.smallest_mtu > mtu)) { - sctp_mtu_size_reset(inp, &stcb->asoc, mtu); - } net->mtu = mtu; + if ((stcb != NULL) && (stcb->asoc.smallest_mtu > mtu)) { + sctp_pathmtu_adjustment(stcb, mtu, true); + } } } +#if defined(__FreeBSD__) && !defined(__Userspace__) + } else if (ro->ro_nh == NULL) { +#else } else if (ro->ro_rt == NULL) { +#endif /* route was freed */ if (net->ro._s_addr && net->src_addr_selected) { @@ -4524,7 +4510,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, uint32_t flowlabel, flowinfo; struct ip6_hdr *ip6h; struct route_in6 ip6route; -#if !(defined(__Panda__) || defined(__Userspace__)) +#if !defined(__Userspace__) struct ifnet *ifp; #endif struct sockaddr_in6 *sin6, tmp, *lsa6, lsa6_tmp; @@ -4548,7 +4534,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, * This means especially, that it is not set at the * SCTP layer. So use the value from the IP layer. */ -#if defined(__APPLE__) && (!defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) && !defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION)) +#if defined(__APPLE__) && !defined(__Userspace__) && (!defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) && !defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION)) flowlabel = ntohl(inp->ip_inp.inp.inp_flow); #else flowlabel = ntohl(((struct inpcb *)inp)->inp_flow); @@ -4569,7 +4555,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, SCTP_BUF_LEN(newm) = len; SCTP_BUF_NEXT(newm) = m; m = newm; -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (net != NULL) { m->m_pkthdr.flowid = net->flowid; M_HASHTYPE_SET(m, net->flowtype); @@ -4588,7 +4574,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, #ifdef SCTP_EMBEDDED_V6_SCOPE /* KAME hack: embed scopeid */ -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #if defined(APPLE_LEOPARD) || defined(APPLE_SNOWLEOPARD) if (in6_embedscope(&sin6->sin6_addr, sin6, NULL, NULL) != 0) #else @@ -4625,12 +4611,10 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, * This means especially, that it is not set at the * SCTP layer. So use the value from the IP layer. */ -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Panda__) || defined(__Windows__) || defined(__Userspace__) -#if defined(__APPLE__) && (!defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) && !defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION)) +#if defined(__APPLE__) && !defined(__Userspace__) && (!defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) && !defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION)) tos_value = (ntohl(inp->ip_inp.inp.inp_flow) >> 20) & 0xff; #else tos_value = (ntohl(((struct inpcb *)inp)->inp_flow) >> 20) & 0xff; -#endif #endif } tos_value &= 0xfc; @@ -4667,16 +4651,20 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, sctp_free_ifa(net->ro._s_addr); net->ro._s_addr = NULL; net->src_addr_selected = 0; +#if defined(__FreeBSD__) && !defined(__Userspace__) + RO_NHFREE(ro); +#else if (ro->ro_rt) { RTFREE(ro->ro_rt); ro->ro_rt = NULL; } +#endif } if (net->src_addr_selected == 0) { #ifdef SCTP_EMBEDDED_V6_SCOPE sin6 = (struct sockaddr_in6 *)&net->ro._l_addr; /* KAME hack: embed scopeid */ -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #if defined(APPLE_LEOPARD) || defined(APPLE_SNOWLEOPARD) if (in6_embedscope(&sin6->sin6_addr, sin6, NULL, NULL) != 0) #else @@ -4722,7 +4710,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, #ifdef SCTP_EMBEDDED_V6_SCOPE sin6 = (struct sockaddr_in6 *)&ro->ro_dst; /* KAME hack: embed scopeid */ -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #if defined(APPLE_LEOPARD) || defined(APPLE_SNOWLEOPARD) if (in6_embedscope(&sin6->sin6_addr, sin6, NULL, NULL) != 0) #else @@ -4768,7 +4756,11 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, } lsa6->sin6_port = inp->sctp_lport; +#if defined(__FreeBSD__) && !defined(__Userspace__) + if (ro->ro_nh == NULL) { +#else if (ro->ro_rt == NULL) { +#endif /* * src addr selection failed to find a route (or * valid source addr), so we can't get there from @@ -4836,7 +4828,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, * that our ro pointer is now filled */ ip6h->ip6_hlim = SCTP_GET_HLIM(inp, ro); -#if !(defined(__Panda__) || defined(__Userspace__)) +#if !defined(__Userspace__) ifp = SCTP_GET_IFN_VOID_FROM_ROUTE(ro); #endif @@ -4868,27 +4860,20 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, if (port) { sctphdr->checksum = sctp_calculate_cksum(m, sizeof(struct ip6_hdr) + sizeof(struct udphdr)); SCTP_STAT_INCR(sctps_sendswcrc); -#if defined(__Windows__) +#if !defined(__Userspace__) +#if defined(_WIN32) udp->uh_sum = 0; -#elif !defined(__Userspace__) +#else if ((udp->uh_sum = in6_cksum(o_pak, IPPROTO_UDP, sizeof(struct ip6_hdr), packet_length - sizeof(struct ip6_hdr))) == 0) { udp->uh_sum = 0xffff; } #endif - } else { -#if defined(__FreeBSD__) && __FreeBSD_version >= 800000 -#if __FreeBSD_version < 900000 - sctphdr->checksum = sctp_calculate_cksum(m, sizeof(struct ip6_hdr)); - SCTP_STAT_INCR(sctps_sendswcrc); -#else -#if __FreeBSD_version > 901000 - m->m_pkthdr.csum_flags = CSUM_SCTP_IPV6; -#else - m->m_pkthdr.csum_flags = CSUM_SCTP; #endif + } else { +#if defined(__FreeBSD__) && !defined(__Userspace__) + m->m_pkthdr.csum_flags = CSUM_SCTP_IPV6; m->m_pkthdr.csum_data = offsetof(struct sctphdr, checksum); SCTP_STAT_INCR(sctps_sendhwcrc); -#endif #else if (!(SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback) && (stcb) && (stcb->asoc.scope.loopback_scope))) { @@ -4900,7 +4885,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, #endif } /* send it out. table id is taken from stcb */ -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) if ((SCTP_BASE_SYSCTL(sctp_output_unlocked)) && (so_locked)) { so = SCTP_INP_SO(inp); SCTP_SOCKET_UNLOCK(so, 0); @@ -4910,15 +4895,15 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LAST_PACKET_TRACING) sctp_packet_log(o_pak); #endif -#if !(defined(__Panda__) || defined(__Userspace__)) +#if !defined(__Userspace__) #if defined(__FreeBSD__) SCTP_PROBE5(send, NULL, stcb, ip6h, stcb, sctphdr); #endif - SCTP_IP6_OUTPUT(ret, o_pak, (struct route_in6 *)ro, &ifp, stcb, vrf_id); + SCTP_IP6_OUTPUT(ret, o_pak, (struct route_in6 *)ro, &ifp, inp, vrf_id); #else - SCTP_IP6_OUTPUT(ret, o_pak, (struct route_in6 *)ro, NULL, stcb, vrf_id); + SCTP_IP6_OUTPUT(ret, o_pak, (struct route_in6 *)ro, NULL, inp, vrf_id); #endif -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) if ((SCTP_BASE_SYSCTL(sctp_output_unlocked)) && (so_locked)) { atomic_add_int(&stcb->asoc.refcnt, 1); SCTP_TCB_UNLOCK(stcb); @@ -4933,7 +4918,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, sin6->sin6_port = prev_port; } SCTPDBG(SCTP_DEBUG_OUTPUT3, "return from send is %d\n", ret); -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (port) { UDPSTAT_INC(udps_opackets); } @@ -4945,8 +4930,8 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, } if (net == NULL) { /* Now if we had a temp route free it */ -#if defined(__FreeBSD__) && __FreeBSD_version > 901000 - RO_RTFREE(ro); +#if defined(__FreeBSD__) && !defined(__Userspace__) + RO_NHFREE(ro); #else if (ro->ro_rt) { RTFREE(ro->ro_rt); @@ -4955,7 +4940,11 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, #endif } else { /* PMTU check versus smallest asoc MTU goes here */ +#if defined(__FreeBSD__) && !defined(__Userspace__) + if (ro->ro_nh == NULL) { +#else if (ro->ro_rt == NULL) { +#endif /* Route was freed */ if (net->ro._s_addr && net->src_addr_selected) { @@ -4964,34 +4953,40 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, } net->src_addr_selected = 0; } +#if defined(__FreeBSD__) && !defined(__Userspace__) + if ((ro->ro_nh != NULL) && (net->ro._s_addr) && +#else if ((ro->ro_rt != NULL) && (net->ro._s_addr) && +#endif ((net->dest_state & SCTP_ADDR_NO_PMTUD) == 0)) { uint32_t mtu; +#if defined(__FreeBSD__) && !defined(__Userspace__) + mtu = SCTP_GATHER_MTU_FROM_ROUTE(net->ro._s_addr, &net->ro._l_addr.sa, ro->ro_nh); +#else mtu = SCTP_GATHER_MTU_FROM_ROUTE(net->ro._s_addr, &net->ro._l_addr.sa, ro->ro_rt); +#endif if (mtu > 0) { if (net->port) { mtu -= sizeof(struct udphdr); } if (mtu < net->mtu) { - if ((stcb != NULL) && (stcb->asoc.smallest_mtu > mtu)) { - sctp_mtu_size_reset(inp, &stcb->asoc, mtu); - } net->mtu = mtu; + if ((stcb != NULL) && (stcb->asoc.smallest_mtu > mtu)) { + sctp_pathmtu_adjustment(stcb, mtu, false); + } } } } -#if !defined(__Panda__) && !defined(__Userspace__) - else if (ifp) { -#if defined(__Windows__) +#if !defined(__Userspace__) + else if (ifp != NULL) { +#if defined(_WIN32) #define ND_IFINFO(ifp) (ifp) #define linkmtu if_mtu #endif - if (ND_IFINFO(ifp)->linkmtu && + if ((ND_IFINFO(ifp)->linkmtu > 0) && (stcb->asoc.smallest_mtu > ND_IFINFO(ifp)->linkmtu)) { - sctp_mtu_size_reset(inp, - &stcb->asoc, - ND_IFINFO(ifp)->linkmtu); + sctp_pathmtu_adjustment(stcb, ND_IFINFO(ifp)->linkmtu, false); } } #endif @@ -5058,13 +5053,8 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, } } - void -sctp_send_initiate(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int so_locked -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - SCTP_UNUSED -#endif - ) +sctp_send_initiate(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int so_locked) { struct mbuf *m, *m_last; struct sctp_nets *net; @@ -5077,7 +5067,7 @@ sctp_send_initiate(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int so_locked int error; uint16_t num_ext, chunk_len, padding_len, parameter_len; -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) if (so_locked) { sctp_lock_assert(SCTP_INP_SO(inp)); } else { @@ -5271,7 +5261,7 @@ sctp_send_initiate(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int so_locked } /* now any cookie time extensions */ - if (stcb->asoc.cookie_preserve_req) { + if (stcb->asoc.cookie_preserve_req > 0) { struct sctp_cookie_perserve_param *cookie_preserve; if (padding_len > 0) { @@ -5342,7 +5332,7 @@ sctp_send_initiate(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int so_locked m, 0, NULL, 0, 0, 0, 0, inp->sctp_lport, stcb->rport, htonl(0), net->port, NULL, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) 0, 0, #endif so_locked))) { @@ -5557,7 +5547,6 @@ sctp_arethere_unrecognized_parameters(struct mbuf *in_initpkt, } } return (op_err); - break; } default: /* @@ -5649,7 +5638,6 @@ sctp_arethere_unrecognized_parameters(struct mbuf *in_initpkt, at += SCTP_SIZE32(plen); } break; - } phdr = sctp_get_next_param(mat, at, ¶ms, sizeof(params)); } @@ -5692,24 +5680,23 @@ sctp_arethere_unrecognized_parameters(struct mbuf *in_initpkt, return (op_err); } -static int +/* + * Given a INIT chunk, look through the parameters to verify that there + * are no new addresses. + * Return true, if there is a new address or there is a problem parsing + the parameters. Provide an optional error cause used when sending an ABORT. + * Return false, if there are no new addresses and there is no problem in + parameter processing. + */ +static bool sctp_are_there_new_addresses(struct sctp_association *asoc, - struct mbuf *in_initpkt, int offset, struct sockaddr *src) + struct mbuf *in_initpkt, int offset, int limit, struct sockaddr *src, + struct mbuf **op_err) { - /* - * Given a INIT packet, look through the packet to verify that there - * are NO new addresses. As we go through the parameters add reports - * of any un-understood parameters that require an error. Also we - * must return (1) to drop the packet if we see a un-understood - * parameter that tells us to drop the chunk. - */ struct sockaddr *sa_touse; struct sockaddr *sa; struct sctp_paramhdr *phdr, params; - uint16_t ptype, plen; - uint8_t fnd; struct sctp_nets *net; - int check_src; #ifdef INET struct sockaddr_in sin4, *sa4; #endif @@ -5719,7 +5706,10 @@ sctp_are_there_new_addresses(struct sctp_association *asoc, #if defined(__Userspace__) struct sockaddr_conn *sac; #endif + uint16_t ptype, plen; + bool fnd, check_src; + *op_err = NULL; #ifdef INET memset(&sin4, 0, sizeof(sin4)); sin4.sin_family = AF_INET; @@ -5735,26 +5725,26 @@ sctp_are_there_new_addresses(struct sctp_association *asoc, #endif #endif /* First what about the src address of the pkt ? */ - check_src = 0; + check_src = false; switch (src->sa_family) { #ifdef INET case AF_INET: if (asoc->scope.ipv4_addr_legal) { - check_src = 1; + check_src = true; } break; #endif #ifdef INET6 case AF_INET6: if (asoc->scope.ipv6_addr_legal) { - check_src = 1; + check_src = true; } break; #endif #if defined(__Userspace__) case AF_CONN: if (asoc->scope.conn_addr_legal) { - check_src = 1; + check_src = true; } break; #endif @@ -5763,7 +5753,7 @@ sctp_are_there_new_addresses(struct sctp_association *asoc, break; } if (check_src) { - fnd = 0; + fnd = false; TAILQ_FOREACH(net, &asoc->nets, sctp_next) { sa = (struct sockaddr *)&net->ro._l_addr; if (sa->sa_family == src->sa_family) { @@ -5774,7 +5764,7 @@ sctp_are_there_new_addresses(struct sctp_association *asoc, sa4 = (struct sockaddr_in *)sa; src4 = (struct sockaddr_in *)src; if (sa4->sin_addr.s_addr == src4->sin_addr.s_addr) { - fnd = 1; + fnd = true; break; } } @@ -5786,7 +5776,7 @@ sctp_are_there_new_addresses(struct sctp_association *asoc, sa6 = (struct sockaddr_in6 *)sa; src6 = (struct sockaddr_in6 *)src; if (SCTP6_ARE_ADDR_EQUAL(sa6, src6)) { - fnd = 1; + fnd = true; break; } } @@ -5798,16 +5788,22 @@ sctp_are_there_new_addresses(struct sctp_association *asoc, sac = (struct sockaddr_conn *)sa; srcc = (struct sockaddr_conn *)src; if (sac->sconn_addr == srcc->sconn_addr) { - fnd = 1; + fnd = true; break; } } #endif } } - if (fnd == 0) { - /* New address added! no need to look further. */ - return (1); + if (!fnd) { + /* + * If sending an ABORT in case of an additional address, + * don't use the new address error cause. + * This looks no different than if no listener was + * present. + */ + *op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code), "Address added"); + return (true); } } /* Ok so far lets munge through the rest of the packet */ @@ -5817,6 +5813,14 @@ sctp_are_there_new_addresses(struct sctp_association *asoc, sa_touse = NULL; ptype = ntohs(phdr->param_type); plen = ntohs(phdr->param_length); + if (offset + plen > limit) { + *op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, "Partial parameter"); + return (true); + } + if (plen < sizeof(struct sctp_paramhdr)) { + *op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, "Parameter length too small"); + return (true); + } switch (ptype) { #ifdef INET case SCTP_IPV4_ADDRESS: @@ -5824,12 +5828,14 @@ sctp_are_there_new_addresses(struct sctp_association *asoc, struct sctp_ipv4addr_param *p4, p4_buf; if (plen != sizeof(struct sctp_ipv4addr_param)) { - return (1); + *op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, "Parameter length illegal"); + return (true); } phdr = sctp_get_next_param(in_initpkt, offset, (struct sctp_paramhdr *)&p4_buf, sizeof(p4_buf)); if (phdr == NULL) { - return (1); + *op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, ""); + return (true); } if (asoc->scope.ipv4_addr_legal) { p4 = (struct sctp_ipv4addr_param *)phdr; @@ -5845,12 +5851,14 @@ sctp_are_there_new_addresses(struct sctp_association *asoc, struct sctp_ipv6addr_param *p6, p6_buf; if (plen != sizeof(struct sctp_ipv6addr_param)) { - return (1); + *op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, "Parameter length illegal"); + return (true); } phdr = sctp_get_next_param(in_initpkt, offset, (struct sctp_paramhdr *)&p6_buf, sizeof(p6_buf)); if (phdr == NULL) { - return (1); + *op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, ""); + return (true); } if (asoc->scope.ipv6_addr_legal) { p6 = (struct sctp_ipv6addr_param *)phdr; @@ -5867,7 +5875,7 @@ sctp_are_there_new_addresses(struct sctp_association *asoc, } if (sa_touse) { /* ok, sa_touse points to one to check */ - fnd = 0; + fnd = false; TAILQ_FOREACH(net, &asoc->nets, sctp_next) { sa = (struct sockaddr *)&net->ro._l_addr; if (sa->sa_family != sa_touse->sa_family) { @@ -5878,7 +5886,7 @@ sctp_are_there_new_addresses(struct sctp_association *asoc, sa4 = (struct sockaddr_in *)sa; if (sa4->sin_addr.s_addr == sin4.sin_addr.s_addr) { - fnd = 1; + fnd = true; break; } } @@ -5888,21 +5896,31 @@ sctp_are_there_new_addresses(struct sctp_association *asoc, sa6 = (struct sockaddr_in6 *)sa; if (SCTP6_ARE_ADDR_EQUAL( sa6, &sin6)) { - fnd = 1; + fnd = true; break; } } #endif } if (!fnd) { - /* New addr added! no need to look further */ - return (1); + /* + * If sending an ABORT in case of an additional + * address, don't use the new address error + * cause. + * This looks no different than if no listener + * was present. + */ + *op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code), "Address added"); + return (true); } } offset += SCTP_SIZE32(plen); + if (offset >= limit) { + break; + } phdr = sctp_get_next_param(in_initpkt, offset, ¶ms, sizeof(params)); } - return (0); + return (false); } /* @@ -5917,8 +5935,8 @@ sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int iphlen, int offset, struct sockaddr *src, struct sockaddr *dst, struct sctphdr *sh, struct sctp_init_chunk *init_chk, -#if defined(__FreeBSD__) - uint8_t mflowtype, uint32_t mflowid, +#if defined(__FreeBSD__) && !defined(__Userspace__) + uint8_t mflowtype, uint32_t mflowid, #endif uint32_t vrf_id, uint16_t port) { @@ -5965,18 +5983,12 @@ sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb, } if ((asoc != NULL) && (SCTP_GET_STATE(stcb) != SCTP_STATE_COOKIE_WAIT)) { - if (sctp_are_there_new_addresses(asoc, init_pkt, offset, src)) { + if (sctp_are_there_new_addresses(asoc, init_pkt, offset, offset + ntohs(init_chk->ch.chunk_length), src, &op_err)) { /* * new addresses, out of here in non-cookie-wait states - * - * Send an ABORT, without the new address error cause. - * This looks no different than if no listener - * was present. */ - op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code), - "Address added"); sctp_send_abort(init_pkt, iphlen, src, dst, sh, 0, op_err, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) mflowtype, mflowid, inp->fibnum, #endif vrf_id, port); @@ -5994,7 +6006,7 @@ sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb, op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code), "Remote encapsulation port changed"); sctp_send_abort(init_pkt, iphlen, src, dst, sh, 0, op_err, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) mflowtype, mflowid, inp->fibnum, #endif vrf_id, port); @@ -6012,13 +6024,13 @@ sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb, if (op_err == NULL) { char msg[SCTP_DIAG_INFO_LEN]; - snprintf(msg, sizeof(msg), "%s:%d at %s", __FILE__, __LINE__, __func__); + SCTP_SNPRINTF(msg, sizeof(msg), "%s:%d at %s", __FILE__, __LINE__, __func__); op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code), msg); } sctp_send_abort(init_pkt, iphlen, src, dst, sh, init_chk->init.initiate_tag, op_err, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) mflowtype, mflowid, inp->fibnum, #endif vrf_id, port); @@ -6133,7 +6145,7 @@ sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb, { stc.addr_type = SCTP_IPV6_ADDRESS; memcpy(&stc.address, &src6->sin6_addr, sizeof(struct in6_addr)); -#if defined(__FreeBSD__) && (((__FreeBSD_version < 900000) && (__FreeBSD_version >= 804000)) || (__FreeBSD_version > 900000)) +#if defined(__FreeBSD__) && !defined(__Userspace__) stc.scope_id = ntohs(in6_getscope(&src6->sin6_addr)); #else stc.scope_id = 0; @@ -6154,7 +6166,7 @@ sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb, * because we share one link that all links are * common. */ -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) /* Mac OS X currently doesn't have in6_getscope() */ stc.scope_id = src6->sin6_addr.s6_addr16[1]; #endif @@ -6261,7 +6273,6 @@ sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb, } net->src_addr_selected = 1; - } stc.laddress[0] = net->ro._s_addr->address.sin.sin_addr.s_addr; stc.laddress[1] = 0; @@ -6348,7 +6359,9 @@ sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb, atomic_add_int(&asoc->refcnt, 1); SCTP_TCB_UNLOCK(stcb); new_tag: + SCTP_INP_INFO_RLOCK(); vtag = sctp_select_a_tag(inp, inp->sctp_lport, sh->src_port, 1); + SCTP_INP_INFO_RUNLOCK(); if ((asoc->peer_supports_nat) && (vtag == asoc->my_vtag)) { /* Got a duplicate vtag on some guy behind a nat * make sure we don't use it. @@ -6360,11 +6373,13 @@ sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb, itsn = sctp_select_initial_TSN(&inp->sctp_ep); initack->init.initial_tsn = htonl(itsn); SCTP_TCB_LOCK(stcb); - atomic_add_int(&asoc->refcnt, -1); + atomic_subtract_int(&asoc->refcnt, 1); } else { SCTP_INP_INCR_REF(inp); SCTP_INP_RUNLOCK(inp); + SCTP_INP_INFO_RLOCK(); vtag = sctp_select_a_tag(inp, inp->sctp_lport, sh->src_port, 1); + SCTP_INP_INFO_RUNLOCK(); initack->init.initiate_tag = htonl(vtag); /* get a TSN to use too */ initack->init.initial_tsn = htonl(sctp_select_initial_TSN(&inp->sctp_ep)); @@ -6626,6 +6641,27 @@ sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb, (uint8_t *)inp->sctp_ep.secret_key[(int)(inp->sctp_ep.current_secret_number)], SCTP_SECRET_SIZE, m_cookie, sizeof(struct sctp_paramhdr), (uint8_t *)signature, SCTP_SIGNATURE_SIZE); +#if defined(__Userspace__) + /* + * Don't put AF_CONN addresses on the wire, in case this is critical + * for the application. However, they are protected by the HMAC and + * need to be reconstructed before checking the HMAC. + * Clearing is only done in the mbuf chain, since the local stc is + * not used anymore. + */ + if (stc.addr_type == SCTP_CONN_ADDRESS) { + const void *p = NULL; + + m_copyback(m_cookie, sizeof(struct sctp_paramhdr) + offsetof(struct sctp_state_cookie, address), + (int)sizeof(void *), (caddr_t)&p); + } + if (stc.laddr_type == SCTP_CONN_ADDRESS) { + const void *p = NULL; + + m_copyback(m_cookie, sizeof(struct sctp_paramhdr) + offsetof(struct sctp_state_cookie, laddress), + (int)sizeof(void *), (caddr_t)&p); + } +#endif /* * We sifa 0 here to NOT set IP_DF if its IPv4, we ignore the return * here since the timer will drive a retranmission. @@ -6646,7 +6682,7 @@ sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb, 0, 0, inp->sctp_lport, sh->src_port, init_chk->init.initiate_tag, port, over_addr, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) mflowtype, mflowid, #endif SCTP_SO_NOT_LOCKED))) { @@ -6665,7 +6701,6 @@ sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb, SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks); } - static void sctp_prune_prsctp(struct sctp_tcb *stcb, struct sctp_association *asoc, @@ -6690,13 +6725,13 @@ sctp_prune_prsctp(struct sctp_tcb *stcb, * This one is PR-SCTP AND buffer space * limited type */ - if (chk->rec.data.timetodrop.tv_sec >= (long)srcv->sinfo_timetolive) { + if (chk->rec.data.timetodrop.tv_sec > (long)srcv->sinfo_timetolive) { /* * Lower numbers equates to higher - * priority so if the one we are - * looking at has a larger or equal - * priority we want to drop the data - * and NOT retransmit it. + * priority. So if the one we are + * looking at has a larger priority, + * we want to drop the data and NOT + * retransmit it. */ if (chk->data) { /* @@ -6725,7 +6760,7 @@ sctp_prune_prsctp(struct sctp_tcb *stcb, TAILQ_FOREACH_SAFE(chk, &asoc->send_queue, sctp_next, nchk) { /* Here we must move to the sent queue and mark */ if (PR_SCTP_BUF_ENABLED(chk->flags)) { - if (chk->rec.data.timetodrop.tv_sec >= (long)srcv->sinfo_timetolive) { + if (chk->rec.data.timetodrop.tv_sec > (long)srcv->sinfo_timetolive) { if (chk->data) { /* * We release the book_size @@ -6747,51 +6782,57 @@ sctp_prune_prsctp(struct sctp_tcb *stcb, } /* if enabled in asoc */ } -int -sctp_get_frag_point(struct sctp_tcb *stcb, - struct sctp_association *asoc) +uint32_t +sctp_get_frag_point(struct sctp_tcb *stcb) { - int siz, ovh; + struct sctp_association *asoc; + uint32_t frag_point, overhead; - /* - * For endpoints that have both v6 and v4 addresses we must reserve - * room for the ipv6 header, for those that are only dealing with V4 - * we use a larger frag point. - */ + asoc = &stcb->asoc; + /* Consider IP header and SCTP common header. */ if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) { - ovh = SCTP_MIN_OVERHEAD; + overhead = SCTP_MIN_OVERHEAD; } else { #if defined(__Userspace__) if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_BOUND_CONN) { - ovh = sizeof(struct sctphdr); + overhead = sizeof(struct sctphdr); } else { - ovh = SCTP_MIN_V4_OVERHEAD; + overhead = SCTP_MIN_V4_OVERHEAD; } #else - ovh = SCTP_MIN_V4_OVERHEAD; + overhead = SCTP_MIN_V4_OVERHEAD; #endif } - ovh += SCTP_DATA_CHUNK_OVERHEAD(stcb); - if (stcb->asoc.sctp_frag_point > asoc->smallest_mtu) - siz = asoc->smallest_mtu - ovh; - else - siz = (stcb->asoc.sctp_frag_point - ovh); - /* - * if (siz > (MCLBYTES-sizeof(struct sctp_data_chunk))) { - */ - /* A data chunk MUST fit in a cluster */ - /* siz = (MCLBYTES - sizeof(struct sctp_data_chunk)); */ - /* } */ - - /* adjust for an AUTH chunk if DATA requires auth */ - if (sctp_auth_is_required_chunk(SCTP_DATA, stcb->asoc.peer_auth_chunks)) - siz -= sctp_get_auth_chunk_len(stcb->asoc.peer_hmac_id); - - if (siz % 4) { - /* make it an even word boundary please */ - siz -= (siz % 4); + /* Consider DATA/IDATA chunk header and AUTH header, if needed. */ + if (asoc->idata_supported) { + overhead += sizeof(struct sctp_idata_chunk); + if (sctp_auth_is_required_chunk(SCTP_IDATA, asoc->peer_auth_chunks)) { + overhead += sctp_get_auth_chunk_len(asoc->peer_hmac_id); + } + } else { + overhead += sizeof(struct sctp_data_chunk); + if (sctp_auth_is_required_chunk(SCTP_DATA, asoc->peer_auth_chunks)) { + overhead += sctp_get_auth_chunk_len(asoc->peer_hmac_id); + } } - return (siz); + KASSERT(overhead % 4 == 0, + ("overhead (%u) not a multiple of 4", overhead)); + /* Consider padding. */ + if (asoc->smallest_mtu % 4 > 0) { + overhead += (asoc->smallest_mtu % 4); + } + KASSERT(asoc->smallest_mtu > overhead, + ("Association MTU (%u) too small for overhead (%u)", + asoc->smallest_mtu, overhead)); + frag_point = asoc->smallest_mtu - overhead; + KASSERT(frag_point % 4 == 0, + ("frag_point (%u) not a multiple of 4", frag_point)); + /* Honor MAXSEG socket option. */ + if ((asoc->sctp_frag_point > 0) && + (asoc->sctp_frag_point < frag_point)) { + frag_point = asoc->sctp_frag_point; + } + return (frag_point); } static void @@ -6828,7 +6869,7 @@ sctp_set_prsctp_policy(struct sctp_stream_queue_pending *sp) /* TODO sctp_constants.h needs alternative time macros when * _KERNEL is undefined. */ -#ifndef __FreeBSD__ +#if !(defined(__FreeBSD__) && !defined(__Userspace__)) timeradd(&sp->ts, &tv, &sp->ts); #else timevaladd(&sp->ts, &tv); @@ -6878,7 +6919,6 @@ sctp_msg_append(struct sctp_tcb *stcb, error = EINVAL; goto out_now; } - strm = &stcb->asoc.strmout[srcv->sinfo_stream]; /* Now can we send this? */ if ((SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_SENT) || (SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_ACK_SENT) || @@ -6936,10 +6976,11 @@ sctp_msg_append(struct sctp_tcb *stcb, if (hold_stcb_lock == 0) { SCTP_TCB_SEND_LOCK(stcb); } + strm = &stcb->asoc.strmout[srcv->sinfo_stream]; sctp_snd_sb_alloc(stcb, sp->length); atomic_add_int(&stcb->asoc.stream_queue_cnt, 1); TAILQ_INSERT_TAIL(&strm->outqueue, sp, next); - stcb->asoc.ss_functions.sctp_ss_add_to_stream(stcb, &stcb->asoc, strm, sp, 1); + stcb->asoc.ss_functions.sctp_ss_add_to_stream(stcb, &stcb->asoc, strm, sp); m = NULL; if (hold_stcb_lock == 0) { SCTP_TCB_SEND_UNLOCK(stcb); @@ -6951,7 +6992,6 @@ out_now: return (error); } - static struct mbuf * sctp_copy_mbufchain(struct mbuf *clonechain, struct mbuf *outchain, @@ -6976,12 +7016,7 @@ sctp_copy_mbufchain(struct mbuf *clonechain, appendchain = clonechain; } else { if (!copy_by_ref && -#if defined(__Panda__) - 0 -#else - (sizeofcpy <= (int)((((SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count) - 1) * MLEN) + MHLEN))) -#endif - ) { + (sizeofcpy <= (int)((((SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count) - 1) * MLEN) + MHLEN)))) { /* Its not in a cluster */ if (*endofchain == NULL) { /* lets get a mbuf cluster */ @@ -7112,11 +7147,8 @@ sctp_med_chunk_output(struct sctp_inpcb *inp, int *num_out, int *reason_code, int control_only, int from_where, - struct timeval *now, int *now_filled, int frag_point, int so_locked -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - SCTP_UNUSED -#endif - ); + struct timeval *now, int *now_filled, + uint32_t frag_point, int so_locked); static void sctp_sendall_iterator(struct sctp_inpcb *inp, struct sctp_tcb *stcb, void *ptr, @@ -7179,7 +7211,7 @@ sctp_sendall_iterator(struct sctp_inpcb *inp, struct sctp_tcb *stcb, void *ptr, * dis-appearing on us. */ atomic_add_int(&stcb->asoc.refcnt, 1); - sctp_abort_an_association(inp, stcb, m, SCTP_SO_NOT_LOCKED); + sctp_abort_an_association(inp, stcb, m, false, SCTP_SO_NOT_LOCKED); /* sctp_abort_an_association calls sctp_free_asoc() * free association will NOT free it since we * incremented the refcnt .. we do this to prevent @@ -7192,7 +7224,7 @@ sctp_sendall_iterator(struct sctp_inpcb *inp, struct sctp_tcb *stcb, void *ptr, * must relock.. to unlock in the iterator timer :-0 */ SCTP_TCB_LOCK(stcb); - atomic_add_int(&stcb->asoc.refcnt, -1); + atomic_subtract_int(&stcb->asoc.refcnt, 1); goto no_chunk_output; } else { if (m) { @@ -7222,7 +7254,7 @@ sctp_sendall_iterator(struct sctp_inpcb *inp, struct sctp_tcb *stcb, void *ptr, sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN, stcb->sctp_ep, stcb, net); sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb, - asoc->primary_destination); + NULL); added_control = 1; do_chunk_output = 0; } @@ -7251,21 +7283,20 @@ sctp_sendall_iterator(struct sctp_inpcb *inp, struct sctp_tcb *stcb, void *ptr, char msg[SCTP_DIAG_INFO_LEN]; abort_anyway: - snprintf(msg, sizeof(msg), - "%s:%d at %s", __FILE__, __LINE__, __func__); + SCTP_SNPRINTF(msg, sizeof(msg), + "%s:%d at %s", __FILE__, __LINE__, __func__); op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code), msg); atomic_add_int(&stcb->asoc.refcnt, 1); sctp_abort_an_association(stcb->sctp_ep, stcb, - op_err, SCTP_SO_NOT_LOCKED); - atomic_add_int(&stcb->asoc.refcnt, -1); + op_err, false, SCTP_SO_NOT_LOCKED); + atomic_subtract_int(&stcb->asoc.refcnt, 1); goto no_chunk_output; } sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb, - asoc->primary_destination); + NULL); } } - } } un_sent = ((stcb->asoc.total_output_queue_size - stcb->asoc.total_flight) + @@ -7279,13 +7310,13 @@ sctp_sendall_iterator(struct sctp_inpcb *inp, struct sctp_tcb *stcb, void *ptr, if (do_chunk_output) sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_USR_SEND, SCTP_SO_NOT_LOCKED); else if (added_control) { - int num_out, reason, now_filled = 0; struct timeval now; - int frag_point; + int num_out, reason, now_filled = 0; - frag_point = sctp_get_frag_point(stcb, &stcb->asoc); (void)sctp_med_chunk_output(inp, stcb, &stcb->asoc, &num_out, - &reason, 1, 1, &now, &now_filled, frag_point, SCTP_SO_NOT_LOCKED); + &reason, 1, 1, &now, &now_filled, + sctp_get_frag_point(stcb), + SCTP_SO_NOT_LOCKED); } no_chunk_output: if (ret) { @@ -7313,7 +7344,9 @@ sctp_sendall_completes(void *ptr, uint32_t val SCTP_UNUSED) /* now free everything */ if (ca->inp) { /* Lets clear the flag to allow others to run. */ + SCTP_INP_WLOCK(ca->inp); ca->inp->sctp_flags &= ~SCTP_PCB_FLAGS_SND_ITERATOR_UP; + SCTP_INP_WUNLOCK(ca->inp); } sctp_m_freem(ca->m); SCTP_FREE(ca, SCTP_M_COPYAL); @@ -7368,11 +7401,7 @@ sctp_sendall(struct sctp_inpcb *inp, struct uio *uio, struct mbuf *m, int ret; struct sctp_copy_all *ca; - if (inp->sctp_flags & SCTP_PCB_FLAGS_SND_ITERATOR_UP) { - /* There is another. */ - return (EBUSY); - } -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #if defined(APPLE_LEOPARD) if (uio->uio_resid > SCTP_BASE_SYSCTL(sctp_sendall_limit)) { #else @@ -7397,6 +7426,18 @@ sctp_sendall(struct sctp_inpcb *inp, struct uio *uio, struct mbuf *m, if (srcv) { memcpy(&ca->sndrcv, srcv, sizeof(struct sctp_nonpad_sndrcvinfo)); } + + /* Serialize. */ + SCTP_INP_WLOCK(inp); + if ((inp->sctp_flags & SCTP_PCB_FLAGS_SND_ITERATOR_UP) != 0) { + SCTP_INP_WUNLOCK(inp); + sctp_m_freem(m); + SCTP_FREE(ca, SCTP_M_COPYAL); + return (EBUSY); + } + inp->sctp_flags |= SCTP_PCB_FLAGS_SND_ITERATOR_UP; + SCTP_INP_WUNLOCK(inp); + /* * take off the sendall flag, it would be bad if we failed to do * this :-0 @@ -7404,7 +7445,7 @@ sctp_sendall(struct sctp_inpcb *inp, struct uio *uio, struct mbuf *m, ca->sndrcv.sinfo_flags &= ~SCTP_SENDALL; /* get length and mbuf chain */ if (uio) { -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #if defined(APPLE_LEOPARD) ca->sndlen = uio->uio_resid; #else @@ -7413,15 +7454,19 @@ sctp_sendall(struct sctp_inpcb *inp, struct uio *uio, struct mbuf *m, #else ca->sndlen = uio->uio_resid; #endif -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_UNLOCK(SCTP_INP_SO(inp), 0); #endif ca->m = sctp_copy_out_all(uio, ca->sndlen); -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_LOCK(SCTP_INP_SO(inp), 0); #endif if (ca->m == NULL) { SCTP_FREE(ca, SCTP_M_COPYAL); + sctp_m_freem(m); + SCTP_INP_WLOCK(inp); + inp->sctp_flags &= ~SCTP_PCB_FLAGS_SND_ITERATOR_UP; + SCTP_INP_WUNLOCK(inp); SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_OUTPUT, ENOMEM); return (ENOMEM); } @@ -7434,14 +7479,15 @@ sctp_sendall(struct sctp_inpcb *inp, struct uio *uio, struct mbuf *m, ca->sndlen += SCTP_BUF_LEN(mat); } } - inp->sctp_flags |= SCTP_PCB_FLAGS_SND_ITERATOR_UP; ret = sctp_initiate_iterator(NULL, sctp_sendall_iterator, NULL, SCTP_PCB_ANY_FLAGS, SCTP_PCB_ANY_FEATURES, SCTP_ASOC_ANY_STATE, (void *)ca, 0, sctp_sendall_completes, inp, 1); if (ret) { + SCTP_INP_WLOCK(inp); inp->sctp_flags &= ~SCTP_PCB_FLAGS_SND_ITERATOR_UP; + SCTP_INP_WUNLOCK(inp); SCTP_FREE(ca, SCTP_M_COPYAL); SCTP_LTRACE_ERR_RET_PKT(m, inp, NULL, NULL, SCTP_FROM_SCTP_OUTPUT, EFAULT); return (EFAULT); @@ -7449,7 +7495,6 @@ sctp_sendall(struct sctp_inpcb *inp, struct uio *uio, struct mbuf *m, return (0); } - void sctp_toss_old_cookies(struct sctp_tcb *stcb, struct sctp_association *asoc) { @@ -7497,7 +7542,6 @@ sctp_toss_old_asconf(struct sctp_tcb *stcb) } } - static void sctp_clean_up_datalist(struct sctp_tcb *stcb, struct sctp_association *asoc, @@ -7591,11 +7635,7 @@ sctp_clean_up_datalist(struct sctp_tcb *stcb, } static void -sctp_clean_up_ctl(struct sctp_tcb *stcb, struct sctp_association *asoc, int so_locked -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - SCTP_UNUSED -#endif -) +sctp_clean_up_ctl(struct sctp_tcb *stcb, struct sctp_association *asoc, int so_locked) { struct sctp_tmit_chunk *chk, *nchk; @@ -7692,17 +7732,14 @@ sctp_can_we_split_this(struct sctp_tcb *stcb, uint32_t length, static uint32_t sctp_move_to_outqueue(struct sctp_tcb *stcb, + struct sctp_nets *net, struct sctp_stream_out *strq, uint32_t space_left, uint32_t frag_point, int *giveup, int eeor_mode, int *bail, - int so_locked -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - SCTP_UNUSED -#endif - ) + int so_locked) { /* Move from the stream to the send_queue keeping track of the total */ struct sctp_association *asoc; @@ -7760,13 +7797,13 @@ one_more_time: sp->put_last_out, send_lock_up); } - if ((TAILQ_NEXT(sp, next) == NULL) && (send_lock_up == 0)) { + if (send_lock_up == 0) { SCTP_TCB_SEND_LOCK(stcb); send_lock_up = 1; } atomic_subtract_int(&asoc->stream_queue_cnt, 1); TAILQ_REMOVE(&strq->outqueue, sp, next); - stcb->asoc.ss_functions.sctp_ss_remove_from_stream(stcb, asoc, strq, sp, send_lock_up); + stcb->asoc.ss_functions.sctp_ss_remove_from_stream(stcb, asoc, strq, sp); if ((strq->state == SCTP_STREAM_RESET_PENDING) && (strq->chunks_on_queues == 0) && TAILQ_EMPTY(&strq->outqueue)) { @@ -7961,7 +7998,6 @@ re_look: sp->tail_mbuf = sp->data = NULL; sp->length = 0; #endif - } sctp_m_free(m); m = sp->data; @@ -8101,7 +8137,8 @@ re_look: sctp_auth_key_acquire(stcb, chk->auth_keyid); chk->holds_key_ref = 1; } -#if defined(__FreeBSD__) || defined(__Panda__) + stcb->asoc.ss_functions.sctp_ss_scheduled(stcb, net, asoc, strq, to_move); +#if defined(__FreeBSD__) && !defined(__Userspace__) chk->rec.data.tsn = atomic_fetchadd_int(&asoc->sending_seq, 1); #else chk->rec.data.tsn = asoc->sending_seq++; @@ -8188,13 +8225,13 @@ re_look: sp->put_last_out, send_lock_up); } - if ((send_lock_up == 0) && (TAILQ_NEXT(sp, next) == NULL)) { + if (send_lock_up == 0) { SCTP_TCB_SEND_LOCK(stcb); send_lock_up = 1; } atomic_subtract_int(&asoc->stream_queue_cnt, 1); TAILQ_REMOVE(&strq->outqueue, sp, next); - stcb->asoc.ss_functions.sctp_ss_remove_from_stream(stcb, asoc, strq, sp, send_lock_up); + stcb->asoc.ss_functions.sctp_ss_remove_from_stream(stcb, asoc, strq, sp); if ((strq->state == SCTP_STREAM_RESET_PENDING) && (strq->chunks_on_queues == 0) && TAILQ_EMPTY(&strq->outqueue)) { @@ -8221,14 +8258,10 @@ out_of: return (to_move); } - static void -sctp_fill_outqueue(struct sctp_tcb *stcb, - struct sctp_nets *net, int frag_point, int eeor_mode, int *quit_now, int so_locked -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - SCTP_UNUSED -#endif -) +sctp_fill_outqueue(struct sctp_tcb *stcb, struct sctp_nets *net, + uint32_t frag_point, int eeor_mode, int *quit_now, + int so_locked) { struct sctp_association *asoc; struct sctp_stream_out *strq; @@ -8268,15 +8301,19 @@ sctp_fill_outqueue(struct sctp_tcb *stcb, giveup = 0; bail = 0; while ((space_left > 0) && (strq != NULL)) { - moved = sctp_move_to_outqueue(stcb, strq, space_left, frag_point, - &giveup, eeor_mode, &bail, so_locked); - stcb->asoc.ss_functions.sctp_ss_scheduled(stcb, net, asoc, strq, moved); + moved = sctp_move_to_outqueue(stcb, net, strq, space_left, + frag_point, &giveup, eeor_mode, + &bail, so_locked); if ((giveup != 0) || (bail != 0)) { break; } strq = stcb->asoc.ss_functions.sctp_ss_select_stream(stcb, net, asoc); total_moved += moved; - space_left -= moved; + if (space_left >= moved) { + space_left -= moved; + } else { + space_left = 0; + } if (space_left >= SCTP_DATA_CHUNK_OVERHEAD(stcb)) { space_left -= SCTP_DATA_CHUNK_OVERHEAD(stcb); } else { @@ -8343,16 +8380,13 @@ sctp_move_chunks_from_net(struct sctp_tcb *stcb, struct sctp_nets *net) int sctp_med_chunk_output(struct sctp_inpcb *inp, - struct sctp_tcb *stcb, - struct sctp_association *asoc, - int *num_out, - int *reason_code, - int control_only, int from_where, - struct timeval *now, int *now_filled, int frag_point, int so_locked -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - SCTP_UNUSED -#endif - ) + struct sctp_tcb *stcb, + struct sctp_association *asoc, + int *num_out, + int *reason_code, + int control_only, int from_where, + struct timeval *now, int *now_filled, + uint32_t frag_point, int so_locked) { /** * Ok this is the generic chunk service queue. we must do the @@ -8389,7 +8423,7 @@ sctp_med_chunk_output(struct sctp_inpcb *inp, the destination. */ int quit_now = 0; -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) if (so_locked) { sctp_lock_assert(SCTP_INP_SO(inp)); } else { @@ -8472,7 +8506,6 @@ sctp_med_chunk_output(struct sctp_inpcb *inp, break; } } - } if ((no_data_chunks == 0) && (skip_fill_up == 0) && @@ -8560,7 +8593,7 @@ sctp_med_chunk_output(struct sctp_inpcb *inp, } old_start_at = NULL; again_one_more_time: - for (net = start_at ; net != NULL; net = TAILQ_NEXT(net, sctp_next)) { + for (net = start_at; net != NULL; net = TAILQ_NEXT(net, sctp_next)) { /* how much can we send? */ /* SCTPDBG("Examine for sending net:%x\n", (uint32_t)net); */ if (old_start_at && (old_start_at == net)) { @@ -8762,7 +8795,7 @@ again_one_more_time: inp->sctp_lport, stcb->rport, htonl(stcb->asoc.peer_vtag), net->port, NULL, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) 0, 0, #endif so_locked))) { @@ -8961,7 +8994,7 @@ again_one_more_time: /* turn off the timer */ if (SCTP_OS_TIMER_PENDING(&stcb->asoc.dack_timer.timer)) { sctp_timer_stop(SCTP_TIMER_TYPE_RECV, - inp, stcb, net, + inp, stcb, NULL, SCTP_FROM_SCTP_OUTPUT + SCTP_LOC_1); } } @@ -9033,7 +9066,7 @@ again_one_more_time: inp->sctp_lport, stcb->rport, htonl(stcb->asoc.peer_vtag), net->port, NULL, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) 0, 0, #endif so_locked))) { @@ -9375,7 +9408,7 @@ again_one_more_time: inp->sctp_lport, stcb->rport, htonl(stcb->asoc.peer_vtag), net->port, NULL, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) 0, 0, #endif so_locked))) { @@ -9402,7 +9435,7 @@ again_one_more_time: * the top of the for, but just to make sure * I will reset these again here. */ - ctl_cnt = bundle_at = 0; + ctl_cnt = 0; continue; /* This takes us back to the for() for the nets. */ } else { asoc->ifp_had_enobuf = 0; @@ -9716,7 +9749,6 @@ sctp_send_cookie_ack(struct sctp_tcb *stcb) return; } - void sctp_send_shutdown_ack(struct sctp_tcb *stcb, struct sctp_nets *net) { @@ -9967,16 +9999,11 @@ sctp_send_asconf_ack(struct sctp_tcb *stcb) return; } - static int sctp_chunk_retransmission(struct sctp_inpcb *inp, struct sctp_tcb *stcb, struct sctp_association *asoc, - int *cnt_out, struct timeval *now, int *now_filled, int *fr_done, int so_locked -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - SCTP_UNUSED -#endif - ) + int *cnt_out, struct timeval *now, int *now_filled, int *fr_done, int so_locked) { /*- * send out one MTU of retransmission. If fast_retransmit is @@ -10005,7 +10032,7 @@ sctp_chunk_retransmission(struct sctp_inpcb *inp, int data_auth_reqd = 0; uint32_t dmtu = 0; -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) if (so_locked) { sctp_lock_assert(SCTP_INP_SO(inp)); } else { @@ -10013,7 +10040,7 @@ sctp_chunk_retransmission(struct sctp_inpcb *inp, } #endif SCTP_TCB_LOCK_ASSERT(stcb); - tmr_started = ctl_cnt = bundle_at = error = 0; + tmr_started = ctl_cnt = 0; no_fragmentflg = 1; fwd_tsn = 0; *cnt_out = 0; @@ -10086,7 +10113,7 @@ sctp_chunk_retransmission(struct sctp_inpcb *inp, no_fragmentflg, 0, 0, inp->sctp_lport, stcb->rport, htonl(stcb->asoc.peer_vtag), chk->whoTo->port, NULL, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) 0, 0, #endif so_locked))) { @@ -10149,13 +10176,13 @@ sctp_chunk_retransmission(struct sctp_inpcb *inp, struct mbuf *op_err; char msg[SCTP_DIAG_INFO_LEN]; - snprintf(msg, sizeof(msg), "TSN %8.8x retransmitted %d times, giving up", - chk->rec.data.tsn, chk->snd_count); + SCTP_SNPRINTF(msg, sizeof(msg), "TSN %8.8x retransmitted %d times, giving up", + chk->rec.data.tsn, chk->snd_count); op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code), msg); atomic_add_int(&stcb->asoc.refcnt, 1); sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, - so_locked); + false, so_locked); SCTP_TCB_LOCK(stcb); atomic_subtract_int(&stcb->asoc.refcnt, 1); return (SCTP_RETRAN_EXIT); @@ -10367,7 +10394,7 @@ sctp_chunk_retransmission(struct sctp_inpcb *inp, no_fragmentflg, 0, 0, inp->sctp_lport, stcb->rport, htonl(stcb->asoc.peer_vtag), net->port, NULL, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) 0, 0, #endif so_locked))) { @@ -10436,10 +10463,8 @@ sctp_chunk_retransmission(struct sctp_inpcb *inp, * also double the output queue size, since this * get shrunk when we free by this amount. */ - atomic_add_int(&((asoc)->total_output_queue_size),data_list[i]->book_size); + atomic_add_int(&((asoc)->total_output_queue_size), data_list[i]->book_size); data_list[i]->book_size *= 2; - - } else { if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOG_RWND_ENABLE) { sctp_log_rwnd(SCTP_DECREASE_PEER_RWND, @@ -10477,7 +10502,7 @@ sctp_chunk_retransmission(struct sctp_inpcb *inp, * t3-expiring. */ sctp_timer_stop(SCTP_TIMER_TYPE_SEND, inp, stcb, net, - SCTP_FROM_SCTP_OUTPUT + SCTP_LOC_2); + SCTP_FROM_SCTP_OUTPUT + SCTP_LOC_2); sctp_timer_start(SCTP_TIMER_TYPE_SEND, inp, stcb, net); } } @@ -10536,11 +10561,7 @@ void sctp_chunk_output(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_where, - int so_locked -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - SCTP_UNUSED -#endif - ) + int so_locked) { /*- * Ok this is the generic chunk service queue. we must do the @@ -10562,12 +10583,12 @@ sctp_chunk_output(struct sctp_inpcb *inp, struct timeval now; int now_filled = 0; int nagle_on; - int frag_point = sctp_get_frag_point(stcb, &stcb->asoc); + uint32_t frag_point = sctp_get_frag_point(stcb); int un_sent = 0; int fr_done; unsigned int tot_frs = 0; -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) if (so_locked) { sctp_lock_assert(SCTP_INP_SO(inp)); } else { @@ -10603,7 +10624,8 @@ do_it_again: */ if (SCTP_OS_TIMER_PENDING(&stcb->asoc.dack_timer.timer)) { sctp_send_sack(stcb, so_locked); - (void)SCTP_OS_TIMER_STOP(&stcb->asoc.dack_timer.timer); + sctp_timer_stop(SCTP_TIMER_TYPE_RECV, stcb->sctp_ep, stcb, NULL, + SCTP_FROM_SCTP_OUTPUT + SCTP_LOC_3); } while (asoc->sent_queue_retran_cnt) { /*- @@ -10617,8 +10639,8 @@ do_it_again: * and then the next call with get the retran's. */ (void)sctp_med_chunk_output(inp, stcb, asoc, &num_out, &reason_code, 1, - from_where, - &now, &now_filled, frag_point, so_locked); + from_where, + &now, &now_filled, frag_point, so_locked); return; } else if (from_where != SCTP_OUTPUT_FROM_HB_TMR) { /* if its not from a HB then do it */ @@ -10642,8 +10664,8 @@ do_it_again: * if queued too. */ (void)sctp_med_chunk_output(inp, stcb, asoc, &num_out, &reason_code, 1, - from_where, - &now, &now_filled, frag_point, so_locked); + from_where, + &now, &now_filled, frag_point, so_locked); #ifdef SCTP_AUDITING_ENABLED sctp_auditing(8, inp, stcb, NULL); #endif @@ -10670,7 +10692,7 @@ do_it_again: #endif /* Push out any control */ (void)sctp_med_chunk_output(inp, stcb, asoc, &num_out, &reason_code, 1, from_where, - &now, &now_filled, frag_point, so_locked); + &now, &now_filled, frag_point, so_locked); return; } if ((asoc->fr_max_burst > 0) && (tot_frs >= asoc->fr_max_burst)) { @@ -10722,13 +10744,12 @@ do_it_again: } } } - } burst_cnt = 0; do { error = sctp_med_chunk_output(inp, stcb, asoc, &num_out, - &reason_code, 0, from_where, - &now, &now_filled, frag_point, so_locked); + &reason_code, 0, from_where, + &now, &now_filled, frag_point, so_locked); if (error) { SCTPDBG(SCTP_DEBUG_OUTPUT1, "Error %d was returned from med-c-op\n", error); if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOG_MAXBURST_ENABLE) { @@ -10812,27 +10833,18 @@ do_it_again: return; } - int sctp_output( struct sctp_inpcb *inp, -#if defined(__Panda__) - pakhandle_type m, -#else struct mbuf *m, -#endif struct sockaddr *addr, -#if defined(__Panda__) - pakhandle_type control, -#else struct mbuf *control, -#endif -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 +#if defined(__FreeBSD__) && !defined(__Userspace__) struct thread *p, -#elif defined(__Windows__) +#elif defined(_WIN32) && !defined(__Userspace__) PKTHREAD p, #else -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) struct proc *p SCTP_UNUSED, #else struct proc *p, @@ -10854,7 +10866,7 @@ sctp_output( (struct uio *)NULL, m, control, -#if defined(__APPLE__) || defined(__Panda__) +#if defined(__APPLE__) && !defined(__Userspace__) flags #else flags, p @@ -11079,11 +11091,7 @@ sctp_fill_in_rest: } void -sctp_send_sack(struct sctp_tcb *stcb, int so_locked -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - SCTP_UNUSED -#endif -) +sctp_send_sack(struct sctp_tcb *stcb, int so_locked) { /*- * Queue up a SACK or NR-SACK in the control queue. @@ -11149,7 +11157,7 @@ sctp_send_sack(struct sctp_tcb *stcb, int so_locked if (stcb->asoc.delayed_ack) { sctp_timer_stop(SCTP_TIMER_TYPE_RECV, stcb->sctp_ep, stcb, NULL, - SCTP_FROM_SCTP_OUTPUT + SCTP_LOC_3); + SCTP_FROM_SCTP_OUTPUT + SCTP_LOC_4); sctp_timer_start(SCTP_TIMER_TYPE_RECV, stcb->sctp_ep, stcb, NULL); } else { @@ -11218,7 +11226,7 @@ sctp_send_sack(struct sctp_tcb *stcb, int so_locked if (stcb->asoc.delayed_ack) { sctp_timer_stop(SCTP_TIMER_TYPE_RECV, stcb->sctp_ep, stcb, NULL, - SCTP_FROM_SCTP_OUTPUT + SCTP_LOC_4); + SCTP_FROM_SCTP_OUTPUT + SCTP_LOC_5); sctp_timer_start(SCTP_TIMER_TYPE_RECV, stcb->sctp_ep, stcb, NULL); } else { @@ -11264,7 +11272,7 @@ sctp_send_sack(struct sctp_tcb *stcb, int so_locked if (highest_tsn > asoc->mapping_array_base_tsn) { siz = (((highest_tsn - asoc->mapping_array_base_tsn) + 1) + 7) / 8; } else { - siz = (((MAX_TSN - highest_tsn) + 1) + highest_tsn + 7) / 8; + siz = (((MAX_TSN - asoc->mapping_array_base_tsn) + 1) + highest_tsn + 7) / 8; } } else { sack = NULL; @@ -11348,7 +11356,6 @@ sctp_send_sack(struct sctp_tcb *stcb, int so_locked } if ((type == SCTP_NR_SELECTIVE_ACK) && (limit_reached == 0)) { - mergeable = 0; if (asoc->highest_tsn_inside_nr_map > asoc->mapping_array_base_tsn) { @@ -11475,11 +11482,7 @@ sctp_send_sack(struct sctp_tcb *stcb, int so_locked } void -sctp_send_abort_tcb(struct sctp_tcb *stcb, struct mbuf *operr, int so_locked -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - SCTP_UNUSED -#endif - ) +sctp_send_abort_tcb(struct sctp_tcb *stcb, struct mbuf *operr, int so_locked) { struct mbuf *m_abort, *m, *m_last; struct mbuf *m_out, *m_end = NULL; @@ -11491,7 +11494,7 @@ sctp_send_abort_tcb(struct sctp_tcb *stcb, struct mbuf *operr, int so_locked int error; uint16_t cause_len, chunk_len, padding_len; -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) if (so_locked) { sctp_lock_assert(SCTP_INP_SO(stcb->sctp_ep)); } else { @@ -11572,7 +11575,7 @@ sctp_send_abort_tcb(struct sctp_tcb *stcb, struct mbuf *operr, int so_locked m_out, auth_offset, auth, stcb->asoc.authinfo.active_keyid, 1, 0, 0, stcb->sctp_ep->sctp_lport, stcb->rport, htonl(vtag), stcb->asoc.primary_destination->port, NULL, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) 0, 0, #endif so_locked))) { @@ -11622,7 +11625,7 @@ sctp_send_shutdown_complete(struct sctp_tcb *stcb, stcb->sctp_ep->sctp_lport, stcb->rport, htonl(vtag), net->port, NULL, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) 0, 0, #endif SCTP_SO_NOT_LOCKED))) { @@ -11638,7 +11641,7 @@ sctp_send_shutdown_complete(struct sctp_tcb *stcb, return; } -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) static void sctp_send_resp_msg(struct sockaddr *src, struct sockaddr *dst, struct sctphdr *sh, uint32_t vtag, @@ -11653,11 +11656,7 @@ sctp_send_resp_msg(struct sockaddr *src, struct sockaddr *dst, uint32_t vrf_id SCTP_UNUSED, uint16_t port) #endif { -#ifdef __Panda__ - pakhandle_type o_pak; -#else struct mbuf *o_pak; -#endif struct mbuf *mout; struct sctphdr *shout; struct sctp_chunkhdr *ch; @@ -11666,7 +11665,7 @@ sctp_send_resp_msg(struct sockaddr *src, struct sockaddr *dst, #endif int ret, len, cause_len, padding_len; #ifdef INET -#if defined(__APPLE__) || defined(__Panda__) +#if defined(__APPLE__) && !defined(__Userspace__) sctp_route_t ro; #endif struct sockaddr_in *src_sin, *dst_sin; @@ -11721,7 +11720,7 @@ sctp_send_resp_msg(struct sockaddr *src, struct sockaddr *dst, len += sizeof(struct udphdr); } #endif -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #if defined(APPLE_LEOPARD) || defined(APPLE_SNOWLEOPARD) mout = sctp_get_mbuf_for_msg(len + max_linkhdr, 1, M_NOWAIT, 1, MT_DATA); #else @@ -11736,7 +11735,7 @@ sctp_send_resp_msg(struct sockaddr *src, struct sockaddr *dst, } return; } -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #if defined(APPLE_LEOPARD) || defined(APPLE_SNOWLEOPARD) SCTP_BUF_RESV_UF(mout, max_linkhdr); #else @@ -11747,7 +11746,7 @@ sctp_send_resp_msg(struct sockaddr *src, struct sockaddr *dst, #endif SCTP_BUF_LEN(mout) = len; SCTP_BUF_NEXT(mout) = cause; -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) M_SETFIB(mout, fibnum); mout->m_pkthdr.flowid = mflowid; M_HASHTYPE_SET(mout, mflowtype); @@ -11767,18 +11766,16 @@ sctp_send_resp_msg(struct sockaddr *src, struct sockaddr *dst, ip->ip_v = IPVERSION; ip->ip_hl = (sizeof(struct ip) >> 2); ip->ip_tos = 0; -#if defined(__FreeBSD__) -#if __FreeBSD_version >= 1000000 +#if defined(__FreeBSD__) && !defined(__Userspace__) ip->ip_off = htons(IP_DF); -#else - ip->ip_off = IP_DF; -#endif -#elif defined(WITH_CONVERT_IP_OFF) || defined(__APPLE__) || defined(__Userspace_os_Darwin) +#elif defined(WITH_CONVERT_IP_OFF) || defined(__APPLE__) ip->ip_off = IP_DF; #else ip->ip_off = htons(IP_DF); #endif -#if defined(__FreeBSD__) +#if defined(__Userspace__) + ip->ip_id = htons(ip_id++); +#elif defined(__FreeBSD__) ip_fillid(ip); #elif defined(__APPLE__) #if RANDOM_IP_ID @@ -11786,8 +11783,6 @@ sctp_send_resp_msg(struct sockaddr *src, struct sockaddr *dst, #else ip->ip_id = htons(ip_id++); #endif -#elif defined(__Userspace__) - ip->ip_id = htons(ip_id++); #else ip->ip_id = ip_id++; #endif @@ -11810,7 +11805,7 @@ sctp_send_resp_msg(struct sockaddr *src, struct sockaddr *dst, dst_sin6 = (struct sockaddr_in6 *)dst; ip6 = mtod(mout, struct ip6_hdr *); ip6->ip6_flow = htonl(0x60000000); -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (V_ip6_auto_flowlabel) { ip6->ip6_flow |= (htonl(ip6_randomflowlabel()) & IPV6_FLOWLABEL_MASK); } @@ -11884,16 +11879,13 @@ sctp_send_resp_msg(struct sockaddr *src, struct sockaddr *dst, switch (dst->sa_family) { #ifdef INET case AF_INET: -#if defined(__APPLE__) || defined(__Panda__) +#if defined(__APPLE__) && !defined(__Userspace__) /* zap the stack pointer to the route */ memset(&ro, 0, sizeof(sctp_route_t)); -#if defined(__Panda__) - ro._l_addr.sa.sa_family = AF_INET; -#endif #endif if (port) { -#if !defined(__Windows__) && !defined(__Userspace__) -#if defined(__FreeBSD__) && ((__FreeBSD_version > 803000 && __FreeBSD_version < 900000) || __FreeBSD_version > 900000) +#if !defined(_WIN32) && !defined(__Userspace__) +#if defined(__FreeBSD__) if (V_udp_cksum) { udp->uh_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP)); } else { @@ -11906,12 +11898,8 @@ sctp_send_resp_msg(struct sockaddr *src, struct sockaddr *dst, udp->uh_sum = 0; #endif } -#if defined(__FreeBSD__) -#if __FreeBSD_version >= 1000000 +#if defined(__FreeBSD__) && !defined(__Userspace__) ip->ip_len = htons(len); -#else - ip->ip_len = len; -#endif #elif defined(__APPLE__) || defined(__Userspace__) ip->ip_len = len; #else @@ -11920,8 +11908,8 @@ sctp_send_resp_msg(struct sockaddr *src, struct sockaddr *dst, if (port) { shout->checksum = sctp_calculate_cksum(mout, sizeof(struct ip) + sizeof(struct udphdr)); SCTP_STAT_INCR(sctps_sendswcrc); -#if !defined(__Windows__) && !defined(__Userspace__) -#if defined(__FreeBSD__) && ((__FreeBSD_version > 803000 && __FreeBSD_version < 900000) || __FreeBSD_version > 900000) +#if !defined(_WIN32) && !defined(__Userspace__) +#if defined(__FreeBSD__) if (V_udp_cksum) { SCTP_ENABLE_UDP_CSUM(o_pak); } @@ -11930,7 +11918,7 @@ sctp_send_resp_msg(struct sockaddr *src, struct sockaddr *dst, #endif #endif } else { -#if defined(__FreeBSD__) && __FreeBSD_version >= 800000 +#if defined(__FreeBSD__) && !defined(__Userspace__) mout->m_pkthdr.csum_flags = CSUM_SCTP; mout->m_pkthdr.csum_data = offsetof(struct sctphdr, checksum); SCTP_STAT_INCR(sctps_sendhwcrc); @@ -11944,7 +11932,7 @@ sctp_send_resp_msg(struct sockaddr *src, struct sockaddr *dst, sctp_packet_log(o_pak); } #endif -#if defined(__APPLE__) || defined(__Panda__) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_IP_OUTPUT(ret, o_pak, &ro, NULL, vrf_id); /* Free the route if we got one back */ if (ro.ro_rt) { @@ -11952,7 +11940,7 @@ sctp_send_resp_msg(struct sockaddr *src, struct sockaddr *dst, ro.ro_rt = NULL; } #else -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) SCTP_PROBE5(send, NULL, NULL, ip, NULL, shout); #endif SCTP_IP_OUTPUT(ret, o_pak, NULL, NULL, vrf_id); @@ -11965,20 +11953,18 @@ sctp_send_resp_msg(struct sockaddr *src, struct sockaddr *dst, if (port) { shout->checksum = sctp_calculate_cksum(mout, sizeof(struct ip6_hdr) + sizeof(struct udphdr)); SCTP_STAT_INCR(sctps_sendswcrc); -#if defined(__Windows__) +#if !defined(__Userspace__) +#if defined(_WIN32) udp->uh_sum = 0; -#elif !defined(__Userspace__) +#else if ((udp->uh_sum = in6_cksum(o_pak, IPPROTO_UDP, sizeof(struct ip6_hdr), len - sizeof(struct ip6_hdr))) == 0) { udp->uh_sum = 0xffff; } #endif - } else { -#if defined(__FreeBSD__) && __FreeBSD_version >= 900000 -#if __FreeBSD_version > 901000 - mout->m_pkthdr.csum_flags = CSUM_SCTP_IPV6; -#else - mout->m_pkthdr.csum_flags = CSUM_SCTP; #endif + } else { +#if defined(__FreeBSD__) && !defined(__Userspace__) + mout->m_pkthdr.csum_flags = CSUM_SCTP_IPV6; mout->m_pkthdr.csum_data = offsetof(struct sctphdr, checksum); SCTP_STAT_INCR(sctps_sendhwcrc); #else @@ -11991,7 +11977,7 @@ sctp_send_resp_msg(struct sockaddr *src, struct sockaddr *dst, sctp_packet_log(o_pak); } #endif -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) SCTP_PROBE5(send, NULL, NULL, ip6, NULL, shout); #endif SCTP_IP6_OUTPUT(ret, o_pak, NULL, NULL, NULL, vrf_id); @@ -12035,7 +12021,7 @@ sctp_send_resp_msg(struct sockaddr *src, struct sockaddr *dst, return; } SCTPDBG(SCTP_DEBUG_OUTPUT3, "return from send is %d\n", ret); -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (port) { UDPSTAT_INC(udps_opackets); } @@ -12052,24 +12038,20 @@ sctp_send_resp_msg(struct sockaddr *src, struct sockaddr *dst, void sctp_send_shutdown_complete2(struct sockaddr *src, struct sockaddr *dst, struct sctphdr *sh, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) uint8_t mflowtype, uint32_t mflowid, uint16_t fibnum, #endif uint32_t vrf_id, uint16_t port) { sctp_send_resp_msg(src, dst, sh, 0, SCTP_SHUTDOWN_COMPLETE, NULL, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) mflowtype, mflowid, fibnum, #endif vrf_id, port); } void -sctp_send_hb(struct sctp_tcb *stcb, struct sctp_nets *net,int so_locked -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - SCTP_UNUSED -#endif -) +sctp_send_hb(struct sctp_tcb *stcb, struct sctp_nets *net,int so_locked) { struct sctp_tmit_chunk *chk; struct sctp_heartbeat_chunk *hb; @@ -12130,7 +12112,7 @@ sctp_send_hb(struct sctp_tcb *stcb, struct sctp_nets *net,int so_locked /* Fill out hb parameter */ hb->heartbeat.hb_info.ph.param_type = htons(SCTP_HEARTBEAT_INFO); hb->heartbeat.hb_info.ph.param_length = htons(sizeof(struct sctp_heartbeat_info_param)); - hb->heartbeat.hb_info.time_value_1 = now.tv_sec; + hb->heartbeat.hb_info.time_value_1 = (uint32_t)now.tv_sec; hb->heartbeat.hb_info.time_value_2 = now.tv_usec; /* Did our user request this one, put it in */ hb->heartbeat.hb_info.addr_family = (uint8_t)net->ro._l_addr.sa.sa_family; @@ -12995,27 +12977,35 @@ sctp_send_str_reset_req(struct sctp_tcb *stcb, * initializing the new stuff. */ SCTP_TCB_SEND_LOCK(stcb); - stcb->asoc.ss_functions.sctp_ss_clear(stcb, &stcb->asoc, 0, 1); + stcb->asoc.ss_functions.sctp_ss_clear(stcb, &stcb->asoc, false); for (i = 0; i < stcb->asoc.streamoutcnt; i++) { TAILQ_INIT(&stcb->asoc.strmout[i].outqueue); + /* FIX ME FIX ME */ + /* This should be a SS_COPY operation FIX ME STREAM SCHEDULER EXPERT */ + stcb->asoc.ss_functions.sctp_ss_init_stream(stcb, &stcb->asoc.strmout[i], &oldstream[i]); stcb->asoc.strmout[i].chunks_on_queues = oldstream[i].chunks_on_queues; +#if defined(SCTP_DETAILED_STR_STATS) + for (j = 0; j < SCTP_PR_SCTP_MAX + 1; j++) { + stcb->asoc.strmout[i].abandoned_sent[j] = oldstream[i].abandoned_sent[j]; + stcb->asoc.strmout[i].abandoned_unsent[j] = oldstream[i].abandoned_unsent[j]; + } +#else + stcb->asoc.strmout[i].abandoned_sent[0] = oldstream[i].abandoned_sent[0]; + stcb->asoc.strmout[i].abandoned_unsent[0] = oldstream[i].abandoned_unsent[0]; +#endif stcb->asoc.strmout[i].next_mid_ordered = oldstream[i].next_mid_ordered; stcb->asoc.strmout[i].next_mid_unordered = oldstream[i].next_mid_unordered; stcb->asoc.strmout[i].last_msg_incomplete = oldstream[i].last_msg_incomplete; stcb->asoc.strmout[i].sid = i; stcb->asoc.strmout[i].state = oldstream[i].state; - /* FIX ME FIX ME */ - /* This should be a SS_COPY operation FIX ME STREAM SCHEDULER EXPERT */ - stcb->asoc.ss_functions.sctp_ss_init_stream(stcb, &stcb->asoc.strmout[i], &oldstream[i]); /* now anything on those queues? */ TAILQ_FOREACH_SAFE(sp, &oldstream[i].outqueue, next, nsp) { TAILQ_REMOVE(&oldstream[i].outqueue, sp, next); TAILQ_INSERT_TAIL(&stcb->asoc.strmout[i].outqueue, sp, next); } - } /* now the new streams */ - stcb->asoc.ss_functions.sctp_ss_init(stcb, &stcb->asoc, 1); + stcb->asoc.ss_functions.sctp_ss_init(stcb, &stcb->asoc); for (i = stcb->asoc.streamoutcnt; i < (stcb->asoc.streamoutcnt + adding_o); i++) { TAILQ_INIT(&stcb->asoc.strmout[i].outqueue); stcb->asoc.strmout[i].chunks_on_queues = 0; @@ -13077,7 +13067,7 @@ skip_stuff: void sctp_send_abort(struct mbuf *m, int iphlen, struct sockaddr *src, struct sockaddr *dst, struct sctphdr *sh, uint32_t vtag, struct mbuf *cause, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) uint8_t mflowtype, uint32_t mflowid, uint16_t fibnum, #endif uint32_t vrf_id, uint16_t port) @@ -13089,7 +13079,7 @@ sctp_send_abort(struct mbuf *m, int iphlen, struct sockaddr *src, struct sockadd return; } sctp_send_resp_msg(src, dst, sh, vtag, SCTP_ABORT_ASSOCIATION, cause, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) mflowtype, mflowid, fibnum, #endif vrf_id, port); @@ -13099,13 +13089,13 @@ sctp_send_abort(struct mbuf *m, int iphlen, struct sockaddr *src, struct sockadd void sctp_send_operr_to(struct sockaddr *src, struct sockaddr *dst, struct sctphdr *sh, uint32_t vtag, struct mbuf *cause, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) uint8_t mflowtype, uint32_t mflowid, uint16_t fibnum, #endif uint32_t vrf_id, uint16_t port) { sctp_send_resp_msg(src, dst, sh, vtag, SCTP_OPERATION_ERROR, cause, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) mflowtype, mflowid, fibnum, #endif vrf_id, port); @@ -13115,27 +13105,14 @@ sctp_send_operr_to(struct sockaddr *src, struct sockaddr *dst, static struct mbuf * sctp_copy_resume(struct uio *uio, int max_send_len, -#if (defined(__FreeBSD__) && __FreeBSD_version > 602000) || defined(__Userspace__) +#if defined(__FreeBSD__) || defined(__Userspace__) int user_marks_eor, #endif int *error, uint32_t *sndout, struct mbuf **new_tail) { -#if defined(__Panda__) - struct mbuf *m; - - m = m_uiotombuf(uio, M_WAITOK, max_send_len, 0, - (user_marks_eor ? M_EOR : 0)); - if (m == NULL) { - SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTP_OUTPUT, ENOBUFS); - *error = ENOBUFS; - } else { - *sndout = m_length(m, NULL); - *new_tail = m_last(m); - } - return (m); -#elif defined(__FreeBSD__) && __FreeBSD_version > 602000 || defined(__Userspace__) +#if defined(__FreeBSD__) || defined(__Userspace__) struct mbuf *m; m = m_uiotombuf(uio, M_WAITOK, max_send_len, 0, @@ -13152,7 +13129,7 @@ sctp_copy_resume(struct uio *uio, int left, cancpy, willcpy; struct mbuf *m, *head; -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #if defined(APPLE_LEOPARD) left = (int)min(uio->uio_resid, max_send_len); #else @@ -13218,17 +13195,7 @@ sctp_copy_one(struct sctp_stream_queue_pending *sp, struct uio *uio, int resv_upfront) { -#if defined(__Panda__) - sp->data = m_uiotombuf(uio, M_WAITOK, sp->length, - resv_upfront, 0); - if (sp->data == NULL) { - SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTP_OUTPUT, ENOBUFS); - return (ENOBUFS); - } - - sp->tail_mbuf = m_last(sp->data); - return (0); -#elif defined(__FreeBSD__) && __FreeBSD_version > 602000 || defined(__Userspace__) +#if defined(__FreeBSD__) || defined(__Userspace__) sp->data = m_uiotombuf(uio, M_WAITOK, sp->length, resv_upfront, 0); if (sp->data == NULL) { @@ -13293,8 +13260,6 @@ sctp_copy_one(struct sctp_stream_queue_pending *sp, #endif } - - static struct sctp_stream_queue_pending * sctp_copy_it_in(struct sctp_tcb *stcb, struct sctp_association *asoc, @@ -13343,7 +13308,7 @@ sctp_copy_it_in(struct sctp_tcb *stcb, (void)SCTP_GETTIME_TIMEVAL(&sp->ts); sp->sid = srcv->sinfo_stream; -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #if defined(APPLE_LEOPARD) sp->length = (uint32_t)min(uio->uio_resid, max_send_len); #else @@ -13352,7 +13317,7 @@ sctp_copy_it_in(struct sctp_tcb *stcb, #else sp->length = (uint32_t)min(uio->uio_resid, max_send_len); #endif -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #if defined(APPLE_LEOPARD) if ((sp->length == (uint32_t)uio->uio_resid) && #else @@ -13385,11 +13350,11 @@ sctp_copy_it_in(struct sctp_tcb *stcb, sctp_auth_key_acquire(stcb, sp->auth_keyid); sp->holds_key_ref = 1; } -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_UNLOCK(SCTP_INP_SO(stcb->sctp_ep), 0); #endif *error = sctp_copy_one(sp, uio, resv_in_first); -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_LOCK(SCTP_INP_SO(stcb->sctp_ep), 0); #endif skip_copy: @@ -13415,25 +13380,19 @@ out_now: return (sp); } - int sctp_sosend(struct socket *so, struct sockaddr *addr, struct uio *uio, -#ifdef __Panda__ - pakhandle_type top, - pakhandle_type icontrol, -#else struct mbuf *top, struct mbuf *control, -#endif -#if defined(__APPLE__) || defined(__Panda__) +#if defined(__APPLE__) && !defined(__Userspace__) int flags #else int flags, -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 +#if defined(__FreeBSD__) && !defined(__Userspace__) struct thread *p -#elif defined(__Windows__) +#elif defined(_WIN32) && !defined(__Userspace__) PKTHREAD p #else #if defined(__Userspace__) @@ -13447,10 +13406,7 @@ sctp_sosend(struct socket *so, #endif ) { -#ifdef __Panda__ - struct mbuf *control = NULL; -#endif -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) struct proc *p = current_proc(); #endif int error, use_sndinfo = 0; @@ -13460,12 +13416,6 @@ sctp_sosend(struct socket *so, struct sockaddr_in sin; #endif -#if defined(__APPLE__) - SCTP_SOCKET_LOCK(so, 1); -#endif -#ifdef __Panda__ - control = SCTP_HEADER_TO_CHAIN(icontrol); -#endif if (control) { /* process cmsg snd/rcv info (maybe a assoc-id) */ if (sctp_find_cmsg(SCTP_SNDRCV, (void *)&sndrcvninfo, control, @@ -13476,9 +13426,15 @@ sctp_sosend(struct socket *so, } addr_to_use = addr; #if defined(INET) && defined(INET6) - if ((addr) && (addr->sa_family == AF_INET6)) { + if ((addr != NULL) && (addr->sa_family == AF_INET6)) { struct sockaddr_in6 *sin6; +#ifdef HAVE_SA_LEN + if (addr->sa_len != sizeof(struct sockaddr_in6)) { + SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTP_OUTPUT, EINVAL); + return (EINVAL); + } +#endif sin6 = (struct sockaddr_in6 *)addr; if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { in6_sin6_2_sin(&sin, sin6); @@ -13486,43 +13442,36 @@ sctp_sosend(struct socket *so, } } #endif - error = sctp_lower_sosend(so, addr_to_use, uio, top, -#ifdef __Panda__ - icontrol, -#else - control, +#if defined(__APPLE__) && !defined(__Userspace__) + SCTP_SOCKET_LOCK(so, 1); #endif + error = sctp_lower_sosend(so, addr_to_use, uio, top, + control, flags, use_sndinfo ? &sndrcvninfo: NULL -#if !(defined(__Panda__) || defined(__Userspace__)) +#if !defined(__Userspace__) , p #endif ); -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_UNLOCK(so, 1); #endif return (error); } - int sctp_lower_sosend(struct socket *so, struct sockaddr *addr, struct uio *uio, -#ifdef __Panda__ - pakhandle_type i_pak, - pakhandle_type i_control, -#else struct mbuf *i_pak, struct mbuf *control, -#endif int flags, struct sctp_sndrcvinfo *srcv -#if !(defined( __Panda__) || defined(__Userspace__)) +#if !defined(__Userspace__) , -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 +#if defined(__FreeBSD__) struct thread *p -#elif defined(__Windows__) +#elif defined(_WIN32) PKTHREAD p #else struct proc *p @@ -13530,12 +13479,12 @@ sctp_lower_sosend(struct socket *so, #endif ) { - ssize_t sndlen = 0, max_len, local_add_more; - int error, len; - struct mbuf *top = NULL; -#ifdef __Panda__ - struct mbuf *control = NULL; +#if defined(__FreeBSD__) && !defined(__Userspace__) + struct epoch_tracker et; #endif + ssize_t sndlen = 0, max_len, local_add_more; + int error; + struct mbuf *top = NULL; int queue_only = 0, queue_only_for_init = 0; int free_cnt_applied = 0; int un_sent; @@ -13565,7 +13514,7 @@ sctp_lower_sosend(struct socket *so, stcb = NULL; asoc = NULL; -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) sctp_lock_assert(so); #endif t_inp = inp = (struct sctp_inpcb *)so->so_pcb; @@ -13584,7 +13533,7 @@ sctp_lower_sosend(struct socket *so, user_marks_eor = sctp_is_feature_on(inp, SCTP_PCB_FLAGS_EXPLICIT_EOR); atomic_add_int(&inp->total_sends, 1); if (uio) { -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #if defined(APPLE_LEOPARD) if (uio->uio_resid < 0) { #else @@ -13596,7 +13545,7 @@ sctp_lower_sosend(struct socket *so, SCTP_LTRACE_ERR_RET(inp, stcb, net, SCTP_FROM_SCTP_OUTPUT, EINVAL); return (EINVAL); } -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #if defined(APPLE_LEOPARD) sndlen = uio->uio_resid; #else @@ -13607,39 +13556,11 @@ sctp_lower_sosend(struct socket *so, #endif } else { top = SCTP_HEADER_TO_CHAIN(i_pak); -#ifdef __Panda__ - /*- - * app len indicates the datalen, dgsize for cases - * of SCTP_EOF/ABORT will not have the right len - */ - sndlen = SCTP_APP_DATA_LEN(i_pak); - /*- - * Set the particle len also to zero to match - * up with app len. We only have one particle - * if app len is zero for Panda. This is ensured - * in the socket lib - */ - if (sndlen == 0) { - SCTP_BUF_LEN(top) = 0; - } - /*- - * We delink the chain from header, but keep - * the header around as we will need it in - * EAGAIN case - */ - SCTP_DETACH_HEADER_FROM_CHAIN(i_pak); -#else sndlen = SCTP_HEADER_LEN(i_pak); -#endif } - SCTPDBG(SCTP_DEBUG_OUTPUT1, "Send called addr:%p send length %zu\n", - (void *)addr, + SCTPDBG(SCTP_DEBUG_OUTPUT1, "Send called addr:%p send length %zd\n", + (void *)addr, sndlen); -#ifdef __Panda__ - if (i_control) { - control = SCTP_HEADER_TO_CHAIN(i_control); - } -#endif if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) && SCTP_IS_LISTENING(inp)) { /* The listener can NOT send */ @@ -13713,7 +13634,7 @@ sctp_lower_sosend(struct socket *so, sinfo_flags = inp->def_send.sinfo_flags; sinfo_assoc_id = inp->def_send.sinfo_assoc_id; } -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (flags & MSG_EOR) { sinfo_flags |= SCTP_EOR; } @@ -13775,7 +13696,6 @@ sctp_lower_sosend(struct socket *so, SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTP_OUTPUT, EINVAL); error = EINVAL; goto out_unlocked; - } if (((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) == 0) && (addr->sa_family == AF_INET6)) { @@ -13821,8 +13741,8 @@ sctp_lower_sosend(struct socket *so, if ((sinfo_flags & SCTP_ABORT) || ((sinfo_flags & SCTP_EOF) && (sndlen == 0))) { /*- - * User asks to abort a non-existant assoc, - * or EOF a non-existant assoc with no data + * User asks to abort a non-existent assoc, + * or EOF a non-existent assoc with no data */ SCTP_LTRACE_ERR_RET(inp, stcb, net, SCTP_FROM_SCTP_OUTPUT, ENOENT); error = ENOENT; @@ -13835,24 +13755,19 @@ sctp_lower_sosend(struct socket *so, panic("Error, should hold create lock and I don't?"); } #endif - stcb = sctp_aloc_assoc(inp, addr, &error, 0, vrf_id, - inp->sctp_ep.pre_open_stream_count, - inp->sctp_ep.port, -#if !(defined( __Panda__) || defined(__Userspace__)) - p, + stcb = sctp_aloc_assoc_connected(inp, addr, &error, 0, 0, vrf_id, + inp->sctp_ep.pre_open_stream_count, + inp->sctp_ep.port, +#if !defined(__Userspace__) + p, #else - (struct proc *)NULL, + (struct proc *)NULL, #endif - SCTP_INITIALIZE_AUTH_PARAMS); + SCTP_INITIALIZE_AUTH_PARAMS); if (stcb == NULL) { /* Error is setup for us in the call */ goto out_unlocked; } - if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) { - stcb->sctp_ep->sctp_flags |= SCTP_PCB_FLAGS_CONNECTED; - /* Set the connected flag so we can queue data */ - soisconnecting(so); - } hold_tcblock = 1; if (create_lock_applied) { SCTP_ASOC_CREATE_UNLOCK(inp); @@ -13868,8 +13783,8 @@ sctp_lower_sosend(struct socket *so, if (control) { if (sctp_process_cmsgs_for_init(stcb, control, &error)) { - sctp_free_assoc(inp, stcb, SCTP_PCBFREE_FORCE, - SCTP_FROM_SCTP_OUTPUT + SCTP_LOC_5); + sctp_free_assoc(inp, stcb, SCTP_NORMAL_PROC, + SCTP_FROM_SCTP_OUTPUT + SCTP_LOC_6); hold_tcblock = 0; stcb = NULL; goto out_unlocked; @@ -13889,7 +13804,7 @@ sctp_lower_sosend(struct socket *so, if (srcv == NULL) { srcv = (struct sctp_sndrcvinfo *)&asoc->def_send; sinfo_flags = srcv->sinfo_flags; -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (flags & MSG_EOR) { sinfo_flags |= SCTP_EOR; } @@ -13934,7 +13849,7 @@ sctp_lower_sosend(struct socket *so, } #endif if (SCTP_SO_IS_NBIO(so) -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 +#if defined(__FreeBSD__) && !defined(__Userspace__) || (flags & (MSG_NBIO | MSG_DONTWAIT)) != 0 #endif ) { @@ -13967,7 +13882,7 @@ sctp_lower_sosend(struct socket *so, SCTP_TCB_UNLOCK(stcb); hold_tcblock = 0; } else { - atomic_add_int(&stcb->asoc.sb_send_resv, sndlen); + atomic_add_int(&stcb->asoc.sb_send_resv, (int)sndlen); } local_soresv = sndlen; if (stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) { @@ -14021,12 +13936,10 @@ sctp_lower_sosend(struct socket *so, } } /* Ok, we will attempt a msgsnd :> */ -#if !(defined(__Panda__) || defined(__Windows__) || defined(__Userspace__)) +#if !(defined(_WIN32) || defined(__Userspace__)) if (p) { -#if defined(__FreeBSD__) && __FreeBSD_version >= 603000 +#if defined(__FreeBSD__) p->td_ru.ru_msgsnd++; -#elif defined(__FreeBSD__) && __FreeBSD_version >= 500000 - p->td_proc->p_stats->p_ru.ru_msgsnd++; #else p->p_stats->p_ru.ru_msgsnd++; #endif @@ -14091,11 +14004,11 @@ sctp_lower_sosend(struct socket *so, ph++; SCTP_BUF_LEN(mm) = (int)(tot_out + sizeof(struct sctp_paramhdr)); if (top == NULL) { -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_UNLOCK(so, 0); #endif error = uiomove((caddr_t)ph, (int)tot_out, uio); -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_LOCK(so, 0); #endif if (error) { @@ -14116,10 +14029,16 @@ sctp_lower_sosend(struct socket *so, if (hold_tcblock == 0) { SCTP_TCB_LOCK(stcb); } - atomic_add_int(&stcb->asoc.refcnt, -1); + atomic_subtract_int(&stcb->asoc.refcnt, 1); free_cnt_applied = 0; /* release this lock, otherwise we hang on ourselves */ - sctp_abort_an_association(stcb->sctp_ep, stcb, mm, SCTP_SO_LOCKED); +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_ENTER(et); +#endif + sctp_abort_an_association(stcb->sctp_ep, stcb, mm, false, SCTP_SO_LOCKED); +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_EXIT(et); +#endif /* now relock the stcb so everything is sane */ hold_tcblock = 0; stcb = NULL; @@ -14178,7 +14097,6 @@ sctp_lower_sosend(struct socket *so, */ local_add_more = sndlen; } - len = 0; if (non_blocking) { goto skip_preblock; } @@ -14202,7 +14120,7 @@ sctp_lower_sosend(struct socket *so, sctp_log_block(SCTP_BLOCK_LOG_INTO_BLKA, asoc, sndlen); } be.error = 0; -#if !defined(__Panda__) && !defined(__Windows__) +#if !(defined(_WIN32) && !defined(__Userspace__)) stcb->block_entry = &be; #endif error = sbwait(&so->so_snd); @@ -14240,7 +14158,7 @@ skip_preblock: if (stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) { goto out_unlocked; } -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) error = sblock(&so->so_snd, SBLOCKWAIT(flags)); #endif /* sndlen covers for mbuf case @@ -14270,16 +14188,17 @@ skip_preblock: error = EINVAL; goto out; } - SCTP_TCB_SEND_UNLOCK(stcb); - strm = &stcb->asoc.strmout[srcv->sinfo_stream]; if (strm->last_msg_incomplete == 0) { do_a_copy_in: + SCTP_TCB_SEND_UNLOCK(stcb); sp = sctp_copy_it_in(stcb, asoc, srcv, uio, net, max_len, user_marks_eor, &error); if (error) { goto out; } SCTP_TCB_SEND_LOCK(stcb); + /* The out streams might be reallocated. */ + strm = &stcb->asoc.strmout[srcv->sinfo_stream]; if (sp->msg_is_complete) { strm->last_msg_incomplete = 0; asoc->stream_locked = 0; @@ -14299,13 +14218,11 @@ skip_preblock: if (sinfo_flags & SCTP_UNORDERED) { SCTP_STAT_INCR(sctps_sends_with_unord); } + sp->processing = 1; TAILQ_INSERT_TAIL(&strm->outqueue, sp, next); - stcb->asoc.ss_functions.sctp_ss_add_to_stream(stcb, asoc, strm, sp, 1); - SCTP_TCB_SEND_UNLOCK(stcb); + stcb->asoc.ss_functions.sctp_ss_add_to_stream(stcb, asoc, strm, sp); } else { - SCTP_TCB_SEND_LOCK(stcb); sp = TAILQ_LAST(&strm->outqueue, sctp_streamhead); - SCTP_TCB_SEND_UNLOCK(stcb); if (sp == NULL) { /* ???? Huh ??? last msg is gone */ #ifdef INVARIANTS @@ -14315,10 +14232,18 @@ skip_preblock: strm->last_msg_incomplete = 0; #endif goto do_a_copy_in; - + } + if (sp->processing) { + SCTP_TCB_SEND_UNLOCK(stcb); + SCTP_LTRACE_ERR_RET(inp, stcb, net, SCTP_FROM_SCTP_OUTPUT, EINVAL); + error = EINVAL; + goto out; + } else { + sp->processing = 1; } } -#if defined(__APPLE__) + SCTP_TCB_SEND_UNLOCK(stcb); +#if defined(__APPLE__) && !defined(__Userspace__) #if defined(APPLE_LEOPARD) while (uio->uio_resid > 0) { #else @@ -14338,7 +14263,7 @@ skip_preblock: if ((max_len > (ssize_t)SCTP_BASE_SYSCTL(sctp_add_more_threshold)) || (max_len && (SCTP_SB_LIMIT_SND(so) < SCTP_BASE_SYSCTL(sctp_add_more_threshold))) || -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #if defined(APPLE_LEOPARD) (uio->uio_resid && (uio->uio_resid <= max_len))) { #else @@ -14353,31 +14278,39 @@ skip_preblock: SCTP_TCB_UNLOCK(stcb); hold_tcblock = 0; } -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_UNLOCK(so, 0); #endif -#if (defined(__FreeBSD__) && __FreeBSD_version > 602000) || defined(__Userspace__) +#if defined(__FreeBSD__) || defined(__Userspace__) mm = sctp_copy_resume(uio, (int)max_len, user_marks_eor, &error, &sndout, &new_tail); #else mm = sctp_copy_resume(uio, (int)max_len, &error, &sndout, &new_tail); #endif -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_LOCK(so, 0); #endif if ((mm == NULL) || error) { if (mm) { sctp_m_freem(mm); } + SCTP_TCB_SEND_LOCK(stcb); + if (((stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) == 0) && + ((stcb->asoc.state & SCTP_STATE_WAS_ABORTED) == 0) && + (sp != NULL)) { + sp->processing = 0; + } + SCTP_TCB_SEND_UNLOCK(stcb); goto out; } /* Update the mbuf and count */ SCTP_TCB_SEND_LOCK(stcb); - if (stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) { + if ((stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) || + (stcb->asoc.state & SCTP_STATE_WAS_ABORTED)) { /* we need to get out. * Peer probably aborted. */ sctp_m_freem(mm); - if (stcb->asoc.state & SCTP_PCB_FLAGS_WAS_ABORTED) { + if (stcb->asoc.state & SCTP_STATE_WAS_ABORTED) { SCTP_LTRACE_ERR_RET(NULL, stcb, NULL, SCTP_FROM_SCTP_OUTPUT, ECONNRESET); error = ECONNRESET; } @@ -14395,13 +14328,12 @@ skip_preblock: } sctp_snd_sb_alloc(stcb, sndout); atomic_add_int(&sp->length, sndout); - len += sndout; if (sinfo_flags & SCTP_SACK_IMMEDIATELY) { sp->sinfo_flags |= SCTP_SACK_IMMEDIATELY; } /* Did we reach EOR? */ -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #if defined(APPLE_LEOPARD) if ((uio->uio_resid == 0) && #else @@ -14419,7 +14351,7 @@ skip_preblock: } SCTP_TCB_SEND_UNLOCK(stcb); } -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #if defined(APPLE_LEOPARD) if (uio->uio_resid == 0) { #else @@ -14453,6 +14385,11 @@ skip_preblock: /* wait for space now */ if (non_blocking) { /* Non-blocking io in place out */ + SCTP_TCB_SEND_LOCK(stcb); + if (sp != NULL) { + sp->processing = 0; + } + SCTP_TCB_SEND_UNLOCK(stcb); goto skip_out_eof; } /* What about the INIT, send it maybe */ @@ -14465,7 +14402,13 @@ skip_preblock: /* a collision took us forward? */ queue_only = 0; } else { +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_ENTER(et); +#endif sctp_send_initiate(inp, stcb, SCTP_SO_LOCKED); +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_EXIT(et); +#endif SCTP_SET_STATE(stcb, SCTP_STATE_COOKIE_WAIT); queue_only = 1; } @@ -14486,7 +14429,6 @@ skip_preblock: (stcb->asoc.total_flight > 0) && (stcb->asoc.stream_queue_cnt < SCTP_MAX_DATA_BUNDLING) && (un_sent < (int)(stcb->asoc.smallest_mtu - SCTP_MIN_OVERHEAD))) { - /*- * Ok, Nagle is set on and we have data outstanding. * Don't send anything and let SACKs drive out the @@ -14506,7 +14448,6 @@ skip_preblock: nagle_applies = 0; } if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_BLK_LOGGING_ENABLE) { - sctp_misc_ints(SCTP_CWNDLOG_PRESEND, queue_only_for_init, queue_only, nagle_applies, un_sent); sctp_misc_ints(SCTP_CWNDLOG_PRESEND, stcb->asoc.total_output_queue_size, @@ -14523,6 +14464,9 @@ skip_preblock: * the input via the net is happening * and I don't need to start output :-D */ +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_ENTER(et); +#endif if (hold_tcblock == 0) { if (SCTP_TCB_TRYLOCK(stcb)) { hold_tcblock = 1; @@ -14535,6 +14479,9 @@ skip_preblock: stcb, SCTP_OUTPUT_FROM_USR_SEND, SCTP_SO_LOCKED); } +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_EXIT(et); +#endif } if (hold_tcblock == 1) { SCTP_TCB_UNLOCK(stcb); @@ -14559,7 +14506,7 @@ skip_preblock: if (SCTP_SB_LIMIT_SND(so) <= (inqueue_bytes + min(SCTP_BASE_SYSCTL(sctp_add_more_threshold), SCTP_SB_LIMIT_SND(so)))) { if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_BLK_LOGGING_ENABLE) { -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #if defined(APPLE_LEOPARD) sctp_log_block(SCTP_BLOCK_LOG_INTO_BLK, asoc, uio->uio_resid); @@ -14573,10 +14520,10 @@ skip_preblock: #endif } be.error = 0; -#if !defined(__Panda__) && !defined(__Windows__) +#if !(defined(_WIN32) && !defined(__Userspace__)) stcb->block_entry = &be; #endif -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) sbunlock(&so->so_snd, 1); #endif error = sbwait(&so->so_snd); @@ -14591,10 +14538,17 @@ skip_preblock: } } SOCKBUF_UNLOCK(&so->so_snd); + SCTP_TCB_SEND_LOCK(stcb); + if (((stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) == 0) && + ((stcb->asoc.state & SCTP_STATE_WAS_ABORTED) == 0) && + (sp != NULL)) { + sp->processing = 0; + } + SCTP_TCB_SEND_UNLOCK(stcb); goto out_unlocked; } -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) error = sblock(&so->so_snd, SBLOCKWAIT(flags)); #endif if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_BLK_LOGGING_ENABLE) { @@ -14603,12 +14557,17 @@ skip_preblock: } } SOCKBUF_UNLOCK(&so->so_snd); - if (stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) { + SCTP_TCB_SEND_LOCK(stcb); + if ((stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) || + (stcb->asoc.state & SCTP_STATE_WAS_ABORTED)) { + SCTP_TCB_SEND_UNLOCK(stcb); goto out_unlocked; } + SCTP_TCB_SEND_UNLOCK(stcb); } SCTP_TCB_SEND_LOCK(stcb); - if (stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) { + if ((stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) || + (stcb->asoc.state & SCTP_STATE_WAS_ABORTED)) { SCTP_TCB_SEND_UNLOCK(stcb); goto out_unlocked; } @@ -14624,13 +14583,14 @@ skip_preblock: strm->last_msg_incomplete = 0; asoc->stream_locked = 0; } + sp->processing = 0; } else { SCTP_PRINTF("Huh no sp TSNH?\n"); strm->last_msg_incomplete = 0; asoc->stream_locked = 0; } SCTP_TCB_SEND_UNLOCK(stcb); -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #if defined(APPLE_LEOPARD) if (uio->uio_resid == 0) { #else @@ -14646,12 +14606,6 @@ skip_preblock: error = sctp_msg_append(stcb, net, top, srcv, 0); top = NULL; if (sinfo_flags & SCTP_EOF) { - /* - * This should only happen for Panda for the mbuf - * send case, which does NOT yet support EEOR mode. - * Thus, we can just set this flag to do the proper - * EOF handling. - */ got_all_of_the_send = 1; } } @@ -14695,7 +14649,7 @@ dataless_eof: sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN, stcb->sctp_ep, stcb, netp); sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb, - asoc->primary_destination); + NULL); } } else { /*- @@ -14727,22 +14681,28 @@ dataless_eof: abort_anyway: if (free_cnt_applied) { - atomic_add_int(&stcb->asoc.refcnt, -1); + atomic_subtract_int(&stcb->asoc.refcnt, 1); free_cnt_applied = 0; } - snprintf(msg, sizeof(msg), - "%s:%d at %s", __FILE__, __LINE__, __func__); + SCTP_SNPRINTF(msg, sizeof(msg), + "%s:%d at %s", __FILE__, __LINE__, __func__); op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code), msg); +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_ENTER(et); +#endif sctp_abort_an_association(stcb->sctp_ep, stcb, - op_err, SCTP_SO_LOCKED); + op_err, false, SCTP_SO_LOCKED); +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_EXIT(et); +#endif /* now relock the stcb so everything is sane */ hold_tcblock = 0; stcb = NULL; goto out; } sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb, - asoc->primary_destination); + NULL); sctp_feature_off(inp, SCTP_PCB_FLAGS_NODELAY); } } @@ -14760,7 +14720,13 @@ skip_out_eof: /* a collision took us forward? */ queue_only = 0; } else { +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_ENTER(et); +#endif sctp_send_initiate(inp, stcb, SCTP_SO_LOCKED); +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_EXIT(et); +#endif SCTP_SET_STATE(stcb, SCTP_STATE_COOKIE_WAIT); queue_only = 1; } @@ -14806,6 +14772,9 @@ skip_out_eof: stcb->asoc.total_flight, stcb->asoc.chunks_on_out_queue, stcb->asoc.total_flight_count); } +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_ENTER(et); +#endif if ((queue_only == 0) && (nagle_applies == 0) && (stcb->asoc.peers_rwnd && un_sent)) { /* we can attempt to send too. */ if (hold_tcblock == 0) { @@ -14827,30 +14796,34 @@ skip_out_eof: } sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_USR_SEND, SCTP_SO_LOCKED); } else if (some_on_control) { - int num_out, reason, frag_point; + int num_out, reason; /* Here we do control only */ if (hold_tcblock == 0) { hold_tcblock = 1; SCTP_TCB_LOCK(stcb); } - frag_point = sctp_get_frag_point(stcb, &stcb->asoc); (void)sctp_med_chunk_output(inp, stcb, &stcb->asoc, &num_out, - &reason, 1, 1, &now, &now_filled, frag_point, SCTP_SO_LOCKED); + &reason, 1, 1, &now, &now_filled, + sctp_get_frag_point(stcb), + SCTP_SO_LOCKED); } +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_EXIT(et); +#endif SCTPDBG(SCTP_DEBUG_OUTPUT1, "USR Send complete qo:%d prw:%d unsent:%d tf:%d cooq:%d toqs:%d err:%d\n", queue_only, stcb->asoc.peers_rwnd, un_sent, stcb->asoc.total_flight, stcb->asoc.chunks_on_out_queue, stcb->asoc.total_output_queue_size, error); out: -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) sbunlock(&so->so_snd, 1); #endif out_unlocked: if (local_soresv && stcb) { - atomic_subtract_int(&stcb->asoc.sb_send_resv, sndlen); + atomic_subtract_int(&stcb->asoc.sb_send_resv, (int)sndlen); } if (create_lock_applied) { SCTP_ASOC_CREATE_UNLOCK(inp); @@ -14859,10 +14832,10 @@ out_unlocked: SCTP_TCB_UNLOCK(stcb); } if (stcb && free_cnt_applied) { - atomic_add_int(&stcb->asoc.refcnt, -1); + atomic_subtract_int(&stcb->asoc.refcnt, 1); } #ifdef INVARIANTS -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (stcb) { if (mtx_owned(&stcb->tcb_mtx)) { panic("Leaving with tcb mtx owned?"); @@ -14872,33 +14845,6 @@ out_unlocked: } } #endif -#endif -#ifdef __Panda__ - /* - * Handle the EAGAIN/ENOMEM cases to reattach the pak header - * to particle when pak is passed in, so that caller - * can try again with this pak - * - * NOTE: For other cases, including success case, - * we simply want to return the header back to free - * pool - */ - if (top) { - if ((error == EAGAIN) || (error == ENOMEM)) { - SCTP_ATTACH_CHAIN(i_pak, top, sndlen); - top = NULL; - } else { - (void)SCTP_RELEASE_HEADER(i_pak); - } - } else { - /* This is to handle cases when top has - * been reset to NULL but pak might not - * be freed - */ - if (i_pak) { - (void)SCTP_RELEASE_HEADER(i_pak); - } - } #endif if (top) { sctp_m_freem(top); @@ -14909,7 +14855,6 @@ out_unlocked: return (error); } - /* * generate an AUTHentication chunk, if required */ @@ -14968,7 +14913,7 @@ sctp_add_auth_chunk(struct mbuf *m, struct mbuf **m_end, return (m); } -#if defined(__FreeBSD__) || defined(__APPLE__) +#if (defined(__FreeBSD__) || defined(__APPLE__)) && !defined(__Userspace__) #ifdef INET6 int sctp_v6src_match_nexthop(struct sockaddr_in6 *src6, sctp_route_t *ro) @@ -14977,7 +14922,11 @@ sctp_v6src_match_nexthop(struct sockaddr_in6 *src6, sctp_route_t *ro) struct nd_pfxrouter *pfxrtr = NULL; struct sockaddr_in6 gw6; +#if defined(__FreeBSD__) + if (ro == NULL || ro->ro_nh == NULL || src6->sin6_family != AF_INET6) +#else if (ro == NULL || ro->ro_rt == NULL || src6->sin6_family != AF_INET6) +#endif return (0); /* get prefix entry of address */ @@ -15016,10 +14965,16 @@ sctp_v6src_match_nexthop(struct sockaddr_in6 *src6, sctp_route_t *ro) SCTPDBG(SCTP_DEBUG_OUTPUT2, "prefix router is "); SCTPDBG_ADDR(SCTP_DEBUG_OUTPUT2, (struct sockaddr *)&gw6); SCTPDBG(SCTP_DEBUG_OUTPUT2, "installed router is "); - SCTPDBG_ADDR(SCTP_DEBUG_OUTPUT2, ro->ro_rt->rt_gateway); - if (sctp_cmpaddr((struct sockaddr *)&gw6, ro->ro_rt->rt_gateway)) { #if defined(__FreeBSD__) + SCTPDBG_ADDR(SCTP_DEBUG_OUTPUT2, &ro->ro_nh->gw_sa); +#else + SCTPDBG_ADDR(SCTP_DEBUG_OUTPUT2, ro->ro_rt->rt_gateway); +#endif +#if defined(__FreeBSD__) + if (sctp_cmpaddr((struct sockaddr *)&gw6, &ro->ro_nh->gw_sa)) { ND6_RUNLOCK(); +#else + if (sctp_cmpaddr((struct sockaddr *)&gw6, ro->ro_rt->rt_gateway)) { #endif SCTPDBG(SCTP_DEBUG_OUTPUT2, "pfxrouter is installed\n"); return (1); @@ -15041,7 +14996,11 @@ sctp_v4src_match_nexthop(struct sctp_ifa *sifa, sctp_route_t *ro) struct ifaddr *ifa; struct in_addr srcnetaddr, gwnetaddr; +#if defined(__FreeBSD__) + if (ro == NULL || ro->ro_nh == NULL || +#else if (ro == NULL || ro->ro_rt == NULL || +#endif sifa->address.sa.sa_family != AF_INET) { return (0); } @@ -15053,10 +15012,18 @@ sctp_v4src_match_nexthop(struct sctp_ifa *sifa, sctp_route_t *ro) SCTPDBG_ADDR(SCTP_DEBUG_OUTPUT2, &sifa->address.sa); SCTPDBG(SCTP_DEBUG_OUTPUT1, "network address is %x\n", srcnetaddr.s_addr); +#if defined(__FreeBSD__) + sin = &ro->ro_nh->gw4_sa; +#else sin = (struct sockaddr_in *)ro->ro_rt->rt_gateway; +#endif gwnetaddr.s_addr = (sin->sin_addr.s_addr & mask->sin_addr.s_addr); SCTPDBG(SCTP_DEBUG_OUTPUT1, "match_nexthop4: nexthop is "); +#if defined(__FreeBSD__) + SCTPDBG_ADDR(SCTP_DEBUG_OUTPUT2, &ro->ro_nh->gw_sa); +#else SCTPDBG_ADDR(SCTP_DEBUG_OUTPUT2, ro->ro_rt->rt_gateway); +#endif SCTPDBG(SCTP_DEBUG_OUTPUT1, "network address is %x\n", gwnetaddr.s_addr); if (srcnetaddr.s_addr == gwnetaddr.s_addr) { return (1); diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_output.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_output.h index cc5872725a..56858d880e 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_output.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_output.h @@ -32,9 +32,9 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.h 351654 2019-09-01 10:09:53Z tuexen $"); +__FBSDID("$FreeBSD$"); #endif #ifndef _NETINET_SCTP_OUTPUT_H_ @@ -44,45 +44,37 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_output.h 351654 2019-09-01 10:09:53Z t #if defined(_KERNEL) || defined(__Userspace__) - struct mbuf * sctp_add_addresses_to_i_ia(struct sctp_inpcb *inp, struct sctp_tcb *stcb, - struct sctp_scoping *scope, - struct mbuf *m_at, - int cnt_inits_to, - uint16_t *padding_len, uint16_t *chunk_len); - + struct sctp_scoping *scope, + struct mbuf *m_at, + int cnt_inits_to, + uint16_t *padding_len, uint16_t *chunk_len); int sctp_is_addr_restricted(struct sctp_tcb *, struct sctp_ifa *); - int sctp_is_address_in_scope(struct sctp_ifa *ifa, struct sctp_scoping *scope, - int do_update); + int do_update); int sctp_is_addr_in_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa); struct sctp_ifa * sctp_source_address_selection(struct sctp_inpcb *inp, - struct sctp_tcb *stcb, - sctp_route_t *ro, struct sctp_nets *net, - int non_asoc_addr_ok, uint32_t vrf_id); + struct sctp_tcb *stcb, + sctp_route_t *ro, struct sctp_nets *net, + int non_asoc_addr_ok, uint32_t vrf_id); #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Userspace__) -int -sctp_v6src_match_nexthop(struct sockaddr_in6 *src6, sctp_route_t *ro); -int -sctp_v4src_match_nexthop(struct sctp_ifa *sifa, sctp_route_t *ro); +int sctp_v6src_match_nexthop(struct sockaddr_in6 *src6, sctp_route_t *ro); + +int sctp_v4src_match_nexthop(struct sctp_ifa *sifa, sctp_route_t *ro); #endif -void sctp_send_initiate(struct sctp_inpcb *, struct sctp_tcb *, int -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - SCTP_UNUSED -#endif - ); +void sctp_send_initiate(struct sctp_inpcb *, struct sctp_tcb *, int); void sctp_send_initiate_ack(struct sctp_inpcb *, struct sctp_tcb *, @@ -90,31 +82,30 @@ sctp_send_initiate_ack(struct sctp_inpcb *, struct sctp_tcb *, int, int, struct sockaddr *, struct sockaddr *, struct sctphdr *, struct sctp_init_chunk *, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) uint8_t, uint32_t, #endif uint32_t, uint16_t); struct mbuf * sctp_arethere_unrecognized_parameters(struct mbuf *, int, int *, - struct sctp_chunkhdr *, int *, int *); + struct sctp_chunkhdr *, int *, int *); void sctp_queue_op_err(struct sctp_tcb *, struct mbuf *); int sctp_send_cookie_echo(struct mbuf *, int, int, struct sctp_tcb *, - struct sctp_nets *); + struct sctp_nets *); void sctp_send_cookie_ack(struct sctp_tcb *); void sctp_send_heartbeat_ack(struct sctp_tcb *, struct mbuf *, int, int, - struct sctp_nets *); + struct sctp_nets *); void sctp_remove_from_wheel(struct sctp_tcb *stcb, - struct sctp_association *asoc, - struct sctp_stream_out *strq, int holds_lock); - + struct sctp_association *asoc, + struct sctp_stream_out *strq, int holds_lock); void sctp_send_shutdown(struct sctp_tcb *, struct sctp_nets *); @@ -124,7 +115,7 @@ void sctp_send_shutdown_complete(struct sctp_tcb *, struct sctp_nets *, int); void sctp_send_shutdown_complete2(struct sockaddr *, struct sockaddr *, struct sctphdr *, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) uint8_t, uint32_t, uint16_t, #endif uint32_t, uint16_t); @@ -133,7 +124,7 @@ void sctp_send_asconf(struct sctp_tcb *, struct sctp_nets *, int addr_locked); void sctp_send_asconf_ack(struct sctp_tcb *); -int sctp_get_frag_point(struct sctp_tcb *, struct sctp_association *); +uint32_t sctp_get_frag_point(struct sctp_tcb *); void sctp_toss_old_cookies(struct sctp_tcb *, struct sctp_association *); @@ -143,16 +134,15 @@ void sctp_fix_ecn_echo(struct sctp_association *); void sctp_move_chunks_from_net(struct sctp_tcb *stcb, struct sctp_nets *net); - #define SCTP_DATA_CHUNK_OVERHEAD(stcb) ((stcb)->asoc.idata_supported ? \ - sizeof(struct sctp_idata_chunk) : \ - sizeof(struct sctp_data_chunk)) + sizeof(struct sctp_idata_chunk) : \ + sizeof(struct sctp_data_chunk)) -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 +#if defined(__FreeBSD__) && !defined(__Userspace__) int sctp_output(struct sctp_inpcb *, struct mbuf *, struct sockaddr *, struct mbuf *, struct thread *, int); -#elif defined(__Windows__) +#elif defined(_WIN32) && !defined(__Userspace__) sctp_output(struct sctp_inpcb *, struct mbuf *, struct sockaddr *, struct mbuf *, PKTHREAD, int); #else @@ -161,30 +151,15 @@ sctp_output(struct sctp_inpcb *, struct mbuf *, struct sockaddr *, #endif int sctp_output(struct sctp_inpcb *, -#if defined(__Panda__) - pakhandle_type, -#else struct mbuf *, -#endif struct sockaddr *, -#if defined(__Panda__) - pakhandle_type, -#else struct mbuf *, -#endif struct proc *, int); #endif -void sctp_chunk_output(struct sctp_inpcb *, struct sctp_tcb *, int, int -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - SCTP_UNUSED -#endif - ); -void sctp_send_abort_tcb(struct sctp_tcb *, struct mbuf *, int -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - SCTP_UNUSED -#endif - ); +void sctp_chunk_output(struct sctp_inpcb *, struct sctp_tcb *, int, int); + +void sctp_send_abort_tcb(struct sctp_tcb *, struct mbuf *, int); void send_forward_tsn(struct sctp_tcb *, struct sctp_association *); @@ -194,23 +169,19 @@ void sctp_send_hb(struct sctp_tcb *, struct sctp_nets *, int); void sctp_send_ecn_echo(struct sctp_tcb *, struct sctp_nets *, uint32_t); - void sctp_send_packet_dropped(struct sctp_tcb *, struct sctp_nets *, struct mbuf *, int, int, int); - - void sctp_send_cwr(struct sctp_tcb *, struct sctp_nets *, uint32_t, uint8_t); - void sctp_add_stream_reset_result(struct sctp_tmit_chunk *, uint32_t, uint32_t); void sctp_send_deferred_reset_response(struct sctp_tcb *, - struct sctp_stream_reset_list *, - int); + struct sctp_stream_reset_list *, + int); void sctp_add_stream_reset_result_tsn(struct sctp_tmit_chunk *, @@ -225,17 +196,18 @@ sctp_send_str_reset_req(struct sctp_tcb *, uint16_t , uint16_t *, void sctp_send_abort(struct mbuf *, int, struct sockaddr *, struct sockaddr *, struct sctphdr *, uint32_t, struct mbuf *, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) uint8_t, uint32_t, uint16_t, #endif uint32_t, uint16_t); -void sctp_send_operr_to(struct sockaddr *, struct sockaddr *, - struct sctphdr *, uint32_t, struct mbuf *, -#if defined(__FreeBSD__) - uint8_t, uint32_t, uint16_t, +void +sctp_send_operr_to(struct sockaddr *, struct sockaddr *, + struct sctphdr *, uint32_t, struct mbuf *, +#if defined(__FreeBSD__) && !defined(__Userspace__) + uint8_t, uint32_t, uint16_t, #endif - uint32_t, uint16_t); + uint32_t, uint16_t); #endif /* _KERNEL || __Userspace__ */ @@ -244,20 +216,15 @@ int sctp_sosend(struct socket *so, struct sockaddr *addr, struct uio *uio, -#ifdef __Panda__ - pakhandle_type top, - pakhandle_type control, -#else struct mbuf *top, struct mbuf *control, -#endif -#if defined(__APPLE__) || defined(__Panda__) +#if defined(__APPLE__) && !defined(__Userspace__) int flags #else int flags, -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 +#if defined(__FreeBSD__) && !defined(__Userspace__) struct thread *p -#elif defined(__Windows__) +#elif defined(_WIN32) && !defined(__Userspace__) PKTHREAD p #else #if defined(__Userspace__) diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_pcb.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_pcb.c index 02779e536c..28cb4976c7 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_pcb.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_pcb.c @@ -32,13 +32,13 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.c 356377 2020-01-05 14:06:40Z tuexen $"); +__FBSDID("$FreeBSD$"); #endif #include -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include #endif #include @@ -52,7 +52,7 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.c 356377 2020-01-05 14:06:40Z tuex #include #include #if defined(INET) || defined(INET6) -#if !defined(__Userspace_os_Windows) +#if !defined(_WIN32) #include #endif #endif @@ -63,7 +63,7 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.c 356377 2020-01-05 14:06:40Z tuex #include #endif #endif -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) #include #include #include @@ -71,21 +71,15 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.c 356377 2020-01-05 14:06:40Z tuex #if defined(__Userspace__) #include #include -#if !defined(__Userspace_os_Windows) +#if !defined(_WIN32) #include #endif #endif -#if defined(__APPLE__) -#define APPLE_FILE_NO 4 -#endif - -#if defined(__FreeBSD__) && __FreeBSD_version >= 801000 -VNET_DEFINE(struct sctp_base_info, system_base_info); -#else +#if !defined(__FreeBSD__) || defined(__Userspace__) struct sctp_base_info system_base_info; -#endif +#endif /* FIX: we don't handle multiple link local scopes */ /* "scopeless" replacement IN6_ARE_ADDR_EQUAL */ #ifdef INET6 @@ -93,7 +87,7 @@ int SCTP6_ARE_ADDR_EQUAL(struct sockaddr_in6 *a, struct sockaddr_in6 *b) { #ifdef SCTP_EMBEDDED_V6_SCOPE -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) struct in6_addr tmp_a, tmp_b; tmp_a = a->sin6_addr; @@ -256,7 +250,6 @@ sctp_allocate_vrf(int vrf_id) return (vrf); } - struct sctp_ifn * sctp_find_ifn(void *ifn, uint32_t ifn_index) { @@ -266,6 +259,7 @@ sctp_find_ifn(void *ifn, uint32_t ifn_index) /* We assume the lock is held for the addresses * if that's wrong problems could occur :-) */ + SCTP_IPI_ADDR_LOCK_ASSERT(); hash_ifn_head = &SCTP_BASE_INFO(vrf_ifn_hash)[(ifn_index & SCTP_BASE_INFO(vrf_ifn_hashmark))]; LIST_FOREACH(sctp_ifnp, hash_ifn_head, next_bucket) { if (sctp_ifnp->ifn_index == ifn_index) { @@ -278,7 +272,6 @@ sctp_find_ifn(void *ifn, uint32_t ifn_index) return (NULL); } - struct sctp_vrf * sctp_find_vrf(uint32_t vrf_id) { @@ -294,7 +287,6 @@ sctp_find_vrf(uint32_t vrf_id) return (NULL); } - void sctp_free_vrf(struct sctp_vrf *vrf) { @@ -310,7 +302,6 @@ sctp_free_vrf(struct sctp_vrf *vrf) } } - void sctp_free_ifn(struct sctp_ifn *sctp_ifnp) { @@ -324,7 +315,6 @@ sctp_free_ifn(struct sctp_ifn *sctp_ifnp) } } - void sctp_update_ifn_mtu(uint32_t ifn_index, uint32_t mtu) { @@ -336,7 +326,6 @@ sctp_update_ifn_mtu(uint32_t ifn_index, uint32_t mtu) } } - void sctp_free_ifa(struct sctp_ifa *sctp_ifap) { @@ -350,7 +339,6 @@ sctp_free_ifa(struct sctp_ifa *sctp_ifap) } } - static void sctp_delete_ifn(struct sctp_ifn *sctp_ifnp, int hold_addr_lock) { @@ -361,19 +349,20 @@ sctp_delete_ifn(struct sctp_ifn *sctp_ifnp, int hold_addr_lock) /* Not in the list.. sorry */ return; } - if (hold_addr_lock == 0) + if (hold_addr_lock == 0) { SCTP_IPI_ADDR_WLOCK(); + } else { + SCTP_IPI_ADDR_WLOCK_ASSERT(); + } LIST_REMOVE(sctp_ifnp, next_bucket); LIST_REMOVE(sctp_ifnp, next_ifn); - SCTP_DEREGISTER_INTERFACE(sctp_ifnp->ifn_index, - sctp_ifnp->registered_af); - if (hold_addr_lock == 0) + if (hold_addr_lock == 0) { SCTP_IPI_ADDR_WUNLOCK(); + } /* Take away the reference, and possibly free it */ sctp_free_ifn(sctp_ifnp); } - void sctp_mark_ifa_addr_down(uint32_t vrf_id, struct sockaddr *addr, const char *if_name, uint32_t ifn_index) @@ -386,7 +375,6 @@ sctp_mark_ifa_addr_down(uint32_t vrf_id, struct sockaddr *addr, if (vrf == NULL) { SCTPDBG(SCTP_DEBUG_PCB4, "Can't find vrf_id 0x%x\n", vrf_id); goto out; - } sctp_ifap = sctp_find_ifa_by_addr(addr, vrf->vrf_id, SCTP_ADDR_LOCKED); if (sctp_ifap == NULL) { @@ -417,7 +405,6 @@ sctp_mark_ifa_addr_down(uint32_t vrf_id, struct sockaddr *addr, SCTP_IPI_ADDR_RUNLOCK(); } - void sctp_mark_ifa_addr_up(uint32_t vrf_id, struct sockaddr *addr, const char *if_name, uint32_t ifn_index) @@ -430,7 +417,6 @@ sctp_mark_ifa_addr_up(uint32_t vrf_id, struct sockaddr *addr, if (vrf == NULL) { SCTPDBG(SCTP_DEBUG_PCB4, "Can't find vrf_id 0x%x\n", vrf_id); goto out; - } sctp_ifap = sctp_find_ifa_by_addr(addr, vrf->vrf_id, SCTP_ADDR_LOCKED); if (sctp_ifap == NULL) { @@ -461,7 +447,6 @@ sctp_mark_ifa_addr_up(uint32_t vrf_id, struct sockaddr *addr, SCTP_IPI_ADDR_RUNLOCK(); } - /*- * Add an ifa to an ifn. * Register the interface as necessary. @@ -494,12 +479,10 @@ sctp_add_ifa_to_ifn(struct sctp_ifn *sctp_ifnp, struct sctp_ifa *sctp_ifap) } if (sctp_ifnp->ifa_count == 1) { /* register the new interface */ - SCTP_REGISTER_INTERFACE(sctp_ifnp->ifn_index, ifa_af); sctp_ifnp->registered_af = ifa_af; } } - /*- * Remove an ifa from its ifn. * If no more addresses exist, remove the ifn too. Otherwise, re-register @@ -535,13 +518,9 @@ sctp_remove_ifa_from_ifn(struct sctp_ifa *sctp_ifap) /* re-register address family type, if needed */ if ((sctp_ifap->ifn_p->num_v6 == 0) && (sctp_ifap->ifn_p->registered_af == AF_INET6)) { - SCTP_DEREGISTER_INTERFACE(sctp_ifap->ifn_p->ifn_index, AF_INET6); - SCTP_REGISTER_INTERFACE(sctp_ifap->ifn_p->ifn_index, AF_INET); sctp_ifap->ifn_p->registered_af = AF_INET; } else if ((sctp_ifap->ifn_p->num_v4 == 0) && (sctp_ifap->ifn_p->registered_af == AF_INET)) { - SCTP_DEREGISTER_INTERFACE(sctp_ifap->ifn_p->ifn_index, AF_INET); - SCTP_REGISTER_INTERFACE(sctp_ifap->ifn_p->ifn_index, AF_INET6); sctp_ifap->ifn_p->registered_af = AF_INET6; } /* free the ifn refcount */ @@ -551,7 +530,6 @@ sctp_remove_ifa_from_ifn(struct sctp_ifa *sctp_ifap) } } - struct sctp_ifa * sctp_add_addr_to_vrf(uint32_t vrf_id, void *ifn, uint32_t ifn_index, uint32_t ifn_type, const char *if_name, void *ifa, @@ -559,8 +537,8 @@ sctp_add_addr_to_vrf(uint32_t vrf_id, void *ifn, uint32_t ifn_index, int dynamic_add) { struct sctp_vrf *vrf; - struct sctp_ifn *sctp_ifnp = NULL; - struct sctp_ifa *sctp_ifap = NULL; + struct sctp_ifn *sctp_ifnp, *new_sctp_ifnp; + struct sctp_ifa *sctp_ifap, *new_sctp_ifap; struct sctp_ifalist *hash_addr_head; struct sctp_ifnlist *hash_ifn_head; uint32_t hash_of_addr; @@ -570,6 +548,23 @@ sctp_add_addr_to_vrf(uint32_t vrf_id, void *ifn, uint32_t ifn_index, SCTPDBG(SCTP_DEBUG_PCB4, "vrf_id 0x%x: adding address: ", vrf_id); SCTPDBG_ADDR(SCTP_DEBUG_PCB4, addr); #endif + SCTP_MALLOC(new_sctp_ifnp, struct sctp_ifn *, + sizeof(struct sctp_ifn), SCTP_M_IFN); + if (new_sctp_ifnp == NULL) { +#ifdef INVARIANTS + panic("No memory for IFN"); +#endif + return (NULL); + } + SCTP_MALLOC(new_sctp_ifap, struct sctp_ifa *, sizeof(struct sctp_ifa), SCTP_M_IFA); + if (new_sctp_ifap == NULL) { +#ifdef INVARIANTS + panic("No memory for IFA"); +#endif + SCTP_FREE(new_sctp_ifnp, SCTP_M_IFN); + return (NULL); + } + SCTP_IPI_ADDR_WLOCK(); sctp_ifnp = sctp_find_ifn(ifn, ifn_index); if (sctp_ifnp) { @@ -580,6 +575,8 @@ sctp_add_addr_to_vrf(uint32_t vrf_id, void *ifn, uint32_t ifn_index, vrf = sctp_allocate_vrf(vrf_id); if (vrf == NULL) { SCTP_IPI_ADDR_WUNLOCK(); + SCTP_FREE(new_sctp_ifnp, SCTP_M_IFN); + SCTP_FREE(new_sctp_ifap, SCTP_M_IFA); return (NULL); } } @@ -588,15 +585,8 @@ sctp_add_addr_to_vrf(uint32_t vrf_id, void *ifn, uint32_t ifn_index, /* build one and add it, can't hold lock * until after malloc done though. */ - SCTP_IPI_ADDR_WUNLOCK(); - SCTP_MALLOC(sctp_ifnp, struct sctp_ifn *, - sizeof(struct sctp_ifn), SCTP_M_IFN); - if (sctp_ifnp == NULL) { -#ifdef INVARIANTS - panic("No memory for IFN"); -#endif - return (NULL); - } + sctp_ifnp = new_sctp_ifnp; + new_sctp_ifnp = NULL; memset(sctp_ifnp, 0, sizeof(struct sctp_ifn)); sctp_ifnp->ifn_index = ifn_index; sctp_ifnp->ifn_p = ifn; @@ -606,13 +596,12 @@ sctp_add_addr_to_vrf(uint32_t vrf_id, void *ifn, uint32_t ifn_index, atomic_add_int(&vrf->refcount, 1); sctp_ifnp->ifn_mtu = SCTP_GATHER_MTU_FROM_IFN_INFO(ifn, ifn_index, addr->sa_family); if (if_name != NULL) { - snprintf(sctp_ifnp->ifn_name, SCTP_IFNAMSIZ, "%s", if_name); + SCTP_SNPRINTF(sctp_ifnp->ifn_name, SCTP_IFNAMSIZ, "%s", if_name); } else { - snprintf(sctp_ifnp->ifn_name, SCTP_IFNAMSIZ, "%s", "unknown"); + SCTP_SNPRINTF(sctp_ifnp->ifn_name, SCTP_IFNAMSIZ, "%s", "unknown"); } hash_ifn_head = &SCTP_BASE_INFO(vrf_ifn_hash)[(ifn_index & SCTP_BASE_INFO(vrf_ifn_hashmark))]; LIST_INIT(&sctp_ifnp->ifalist); - SCTP_IPI_ADDR_WLOCK(); LIST_INSERT_HEAD(hash_ifn_head, sctp_ifnp, next_bucket); LIST_INSERT_HEAD(&vrf->ifnlist, sctp_ifnp, next_ifn); atomic_add_int(&SCTP_BASE_INFO(ipi_count_ifns), 1); @@ -639,6 +628,10 @@ sctp_add_addr_to_vrf(uint32_t vrf_id, void *ifn, uint32_t ifn_index, } exit_stage_left: SCTP_IPI_ADDR_WUNLOCK(); + if (new_sctp_ifnp != NULL) { + SCTP_FREE(new_sctp_ifnp, SCTP_M_IFN); + } + SCTP_FREE(new_sctp_ifap, SCTP_M_IFA); return (sctp_ifap); } else { if (sctp_ifap->ifn_p) { @@ -665,14 +658,7 @@ sctp_add_addr_to_vrf(uint32_t vrf_id, void *ifn, uint32_t ifn_index, goto exit_stage_left; } } - SCTP_IPI_ADDR_WUNLOCK(); - SCTP_MALLOC(sctp_ifap, struct sctp_ifa *, sizeof(struct sctp_ifa), SCTP_M_IFA); - if (sctp_ifap == NULL) { -#ifdef INVARIANTS - panic("No memory for IFA"); -#endif - return (NULL); - } + sctp_ifap = new_sctp_ifap; memset(sctp_ifap, 0, sizeof(struct sctp_ifa)); sctp_ifap->ifn_p = sctp_ifnp; atomic_add_int(&sctp_ifnp->refcount, 1); @@ -761,7 +747,6 @@ sctp_add_addr_to_vrf(uint32_t vrf_id, void *ifn, uint32_t ifn_index, (sctp_ifap->src_is_loop == 0)) { sctp_ifap->src_is_glob = 1; } - SCTP_IPI_ADDR_WLOCK(); hash_addr_head = &vrf->vrf_addr_hash[(hash_of_addr & vrf->vrf_addr_hashmark)]; LIST_INSERT_HEAD(hash_addr_head, sctp_ifap, next_bucket); sctp_ifap->refcount = 1; @@ -770,10 +755,13 @@ sctp_add_addr_to_vrf(uint32_t vrf_id, void *ifn, uint32_t ifn_index, vrf->total_ifa_count++; atomic_add_int(&SCTP_BASE_INFO(ipi_count_ifas), 1); if (new_ifn_af) { - SCTP_REGISTER_INTERFACE(ifn_index, new_ifn_af); sctp_ifnp->registered_af = new_ifn_af; } SCTP_IPI_ADDR_WUNLOCK(); + if (new_sctp_ifnp != NULL) { + SCTP_FREE(new_sctp_ifnp, SCTP_M_IFN); + } + if (dynamic_add) { /* Bump up the refcount so that when the timer * completes it will drop back down. @@ -838,8 +826,7 @@ sctp_del_addr_from_vrf(uint32_t vrf_id, struct sockaddr *addr, int valid = 0; /*- * The name has priority over the ifn_index - * if its given. We do this especially for - * panda who might recycle indexes fast. + * if its given. */ if (if_name) { if (strncmp(if_name, sctp_ifap->ifn_p->ifn_name, SCTP_IFNAMSIZ) == 0) { @@ -864,7 +851,7 @@ sctp_del_addr_from_vrf(uint32_t vrf_id, struct sockaddr *addr, } SCTPDBG(SCTP_DEBUG_PCB4, "Deleting ifa %p\n", (void *)sctp_ifap); sctp_ifap->localifa_flags &= SCTP_ADDR_VALID; - /* + /* * We don't set the flag. This means that the structure will * hang around in EP's that have bound specific to it until * they close. This gives us TCP like behavior if someone @@ -920,7 +907,6 @@ sctp_del_addr_from_vrf(uint32_t vrf_id, struct sockaddr *addr, return; } - static int sctp_does_stcb_own_this_addr(struct sctp_tcb *stcb, struct sockaddr *to) { @@ -990,7 +976,7 @@ sctp_does_stcb_own_this_addr(struct sctp_tcb *stcb, struct sockaddr *to) IN4_ISPRIVATE_ADDRESS(&sin->sin_addr)) { continue; } -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (prison_check_ip4(stcb->sctp_ep->ip_inp.inp.inp_cred, &sin->sin_addr) != 0) { continue; @@ -1012,7 +998,7 @@ sctp_does_stcb_own_this_addr(struct sctp_tcb *stcb, struct sockaddr *to) #endif sin6 = &sctp_ifa->address.sin6; rsin6 = (struct sockaddr_in6 *)to; -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (prison_check_ip6(stcb->sctp_ep->ip_inp.inp.inp_cred, &sin6->sin6_addr) != 0) { continue; @@ -1135,14 +1121,12 @@ sctp_does_stcb_own_this_addr(struct sctp_tcb *stcb, struct sockaddr *to) /* TSNH */ break; } - } } SCTP_IPI_ADDR_RUNLOCK(); return (0); } - static struct sctp_tcb * sctp_tcb_special_locate(struct sctp_inpcb **inp_p, struct sockaddr *from, struct sockaddr *to, struct sctp_nets **netp, uint32_t vrf_id) @@ -1217,7 +1201,7 @@ sctp_tcb_special_locate(struct sctp_inpcb **inp_p, struct sockaddr *from, SCTP_INP_RUNLOCK(inp); continue; } -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) switch (to->sa_family) { #ifdef INET case AF_INET: @@ -1276,7 +1260,6 @@ sctp_tcb_special_locate(struct sctp_inpcb **inp_p, struct sockaddr *from, int match = 0; LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) { - if (laddr->ifa == NULL) { SCTPDBG(SCTP_DEBUG_PCB1, "%s: NULL ifa\n", __func__); continue; @@ -1372,7 +1355,6 @@ sctp_tcb_special_locate(struct sctp_inpcb **inp_p, struct sockaddr *from, } /* Does this TCB have a matching address? */ TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { - if (net->ro._l_addr.sa.sa_family != from->sa_family) { /* not the same family, can't be a match */ continue; @@ -1451,7 +1433,6 @@ sctp_tcb_special_locate(struct sctp_inpcb **inp_p, struct sockaddr *from, return (NULL); } - /* * rules for use * @@ -1818,7 +1799,6 @@ null_return: return (NULL); } - /* * Find an association for a specific endpoint using the association id given * out in the COMM_UP notification @@ -1833,10 +1813,6 @@ sctp_findasoc_ep_asocid_locked(struct sctp_inpcb *inp, sctp_assoc_t asoc_id, int struct sctp_tcb *stcb; uint32_t id; - if (inp == NULL) { - SCTP_PRINTF("TSNH ep_associd\n"); - return (NULL); - } if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) { SCTP_PRINTF("TSNH ep_associd0\n"); return (NULL); @@ -1870,7 +1846,6 @@ sctp_findasoc_ep_asocid_locked(struct sctp_inpcb *inp, sctp_assoc_t asoc_id, int return (NULL); } - struct sctp_tcb * sctp_findassociation_ep_asocid(struct sctp_inpcb *inp, sctp_assoc_t asoc_id, int want_lock) { @@ -1882,7 +1857,6 @@ sctp_findassociation_ep_asocid(struct sctp_inpcb *inp, sctp_assoc_t asoc_id, int return (stcb); } - /* * Endpoint probe expects that the INP_INFO is locked. */ @@ -1958,7 +1932,7 @@ sctp_endpoint_probe(struct sockaddr *nam, struct sctppcbhead *head, SCTP_INP_RUNLOCK(inp); continue; } -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (prison_check_ip4(inp->ip_inp.inp.inp_cred, &sin->sin_addr) != 0) { SCTP_INP_RUNLOCK(inp); @@ -1974,7 +1948,7 @@ sctp_endpoint_probe(struct sockaddr *nam, struct sctppcbhead *head, SCTP_INP_RUNLOCK(inp); continue; } -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (prison_check_ip6(inp->ip_inp.inp.inp_cred, &sin6->sin6_addr) != 0) { SCTP_INP_RUNLOCK(inp); @@ -2091,7 +2065,7 @@ sctp_endpoint_probe(struct sockaddr *nam, struct sctppcbhead *head, switch (nam->sa_family) { #ifdef INET case AF_INET: -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) if (sin == NULL) { /* TSNH */ break; @@ -2130,7 +2104,6 @@ sctp_endpoint_probe(struct sockaddr *nam, struct sctppcbhead *head, return (NULL); } - static struct sctp_inpcb * sctp_isport_inuse(struct sctp_inpcb *inp, uint16_t lport, uint32_t vrf_id) { @@ -2191,7 +2164,6 @@ sctp_isport_inuse(struct sctp_inpcb *inp, uint16_t lport, uint32_t vrf_id) return (NULL); } - int sctp_swap_inpcb_for_listen(struct sctp_inpcb *inp) { @@ -2199,6 +2171,9 @@ sctp_swap_inpcb_for_listen(struct sctp_inpcb *inp) struct sctppcbhead *head; struct sctp_inpcb *tinp, *ninp; + SCTP_INP_INFO_WLOCK_ASSERT(); + SCTP_INP_WLOCK_ASSERT(inp); + if (sctp_is_feature_off(inp, SCTP_PCB_FLAGS_PORTREUSE)) { /* only works with port reuse on */ return (-1); @@ -2206,8 +2181,7 @@ sctp_swap_inpcb_for_listen(struct sctp_inpcb *inp) if ((inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) == 0) { return (0); } - SCTP_INP_RUNLOCK(inp); - SCTP_INP_INFO_WLOCK(); + SCTP_INP_WUNLOCK(inp); head = &SCTP_BASE_INFO(sctp_ephash)[SCTP_PCBHASH_ALLADDR(inp->sctp_lport, SCTP_BASE_INFO(hashmark))]; /* Kick out all non-listeners to the TCP hash */ @@ -2237,13 +2211,9 @@ sctp_swap_inpcb_for_listen(struct sctp_inpcb *inp) inp->sctp_flags &= ~SCTP_PCB_FLAGS_IN_TCPPOOL; head = &SCTP_BASE_INFO(sctp_ephash)[SCTP_PCBHASH_ALLADDR(inp->sctp_lport, SCTP_BASE_INFO(hashmark))]; LIST_INSERT_HEAD(head, inp, sctp_hash); - SCTP_INP_WUNLOCK(inp); - SCTP_INP_RLOCK(inp); - SCTP_INP_INFO_WUNLOCK(); return (0); } - struct sctp_inpcb * sctp_pcb_findep(struct sockaddr *nam, int find_tcp_pool, int have_lock, uint32_t vrf_id) @@ -2329,7 +2299,6 @@ sctp_pcb_findep(struct sockaddr *nam, int find_tcp_pool, int have_lock, return (inp); } - /* * Find an association for an endpoint with the pointer to whom you want to * send to and the endpoint pointer. The address can be IPv4 or IPv6. We may @@ -2381,7 +2350,6 @@ sctp_findassociation_addr_sa(struct sockaddr *from, struct sockaddr *to, return (stcb); } - /* * This routine will grub through the mbuf that is a INIT or INIT-ACK and * find all addresses that the sender has specified in any address list. Each @@ -2590,7 +2558,6 @@ sctp_findassoc_by_vtag(struct sockaddr *from, struct sockaddr *to, uint32_t vtag return (NULL); } - /* * Find an association with the pointer to the inbound IP packet. This can be * a IPv4 or IPv6 packet. @@ -2760,7 +2727,6 @@ sctp_findassociation_ep_asconf(struct mbuf *m, int offset, return (stcb); } - /* * allocate a sctp_inpcb and setup a temporary binding to a port/all * addresses. This way if we don't get a bind we by default pick a ephemeral @@ -2797,17 +2763,17 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id) memset(inp, 0, sizeof(*inp)); /* bump generations */ -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) inp->ip_inp.inp.inp_state = INPCB_STATE_INUSE; #endif /* setup socket pointers */ inp->sctp_socket = so; inp->ip_inp.inp.inp_socket = so; -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) inp->ip_inp.inp.inp_cred = crhold(so->so_cred); #endif #ifdef INET6 -#if !defined(__Userspace__) && !defined(__Windows__) +#if !defined(__Userspace__) && !defined(_WIN32) if (INP_SOCKAF(so) == AF_INET6) { if (MODULE_GLOBAL(ip6_auto_flowlabel)) { inp->ip_inp.inp.inp_flags |= IN6P_AUTOFLOWLABEL; @@ -2820,7 +2786,7 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id) #endif inp->sctp_associd_counter = 1; inp->partial_delivery_point = SCTP_SB_LIMIT_RCV(so) >> SCTP_PARTIAL_DELIVERY_SHIFT; - inp->sctp_frag_point = SCTP_DEFAULT_MAXSEGMENT; + inp->sctp_frag_point = 0; inp->max_cwnd = 0; inp->sctp_cmt_on_off = SCTP_BASE_SYSCTL(sctp_cmt_on_off); inp->ecn_supported = (uint8_t)SCTP_BASE_SYSCTL(sctp_ecn_enable); @@ -2832,7 +2798,7 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id) inp->pktdrop_supported = (uint8_t)SCTP_BASE_SYSCTL(sctp_pktdrop_enable); inp->idata_supported = 0; -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) inp->fibnum = so->so_fibnum; #else inp->fibnum = 0; @@ -2846,7 +2812,7 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id) /* init the small hash table we use to track asocid <-> tcb */ inp->sctp_asocidhash = SCTP_HASH_INIT(SCTP_STACK_VTAG_HASH_SIZE, &inp->hashasocidmark); if (inp->sctp_asocidhash == NULL) { -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) crfree(inp->ip_inp.inp.inp_cred); #endif SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp); @@ -2859,12 +2825,7 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id) so->so_pcb = (caddr_t)inp; -#if defined(__FreeBSD__) && __FreeBSD_version < 803000 - if ((SCTP_SO_TYPE(so) == SOCK_DGRAM) || - (SCTP_SO_TYPE(so) == SOCK_SEQPACKET)) { -#else if (SCTP_SO_TYPE(so) == SOCK_SEQPACKET) { -#endif /* UDP style socket */ inp->sctp_flags = (SCTP_PCB_FLAGS_UDPTYPE | SCTP_PCB_FLAGS_UNBOUND); @@ -2878,14 +2839,6 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id) SOCK_LOCK(so); SCTP_CLEAR_SO_NBIO(so); SOCK_UNLOCK(so); -#if defined(__Panda__) - } else if (SCTP_SO_TYPE(so) == SOCK_FASTSEQPACKET) { - inp->sctp_flags = (SCTP_PCB_FLAGS_UDPTYPE | - SCTP_PCB_FLAGS_UNBOUND); - } else if (SCTP_SO_TYPE(so) == SOCK_FASTSTREAM) { - inp->sctp_flags = (SCTP_PCB_FLAGS_TCPTYPE | - SCTP_PCB_FLAGS_UNBOUND); -#endif } else { /* * unsupported socket type (RAW, etc)- in case we missed it @@ -2893,7 +2846,7 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id) */ SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EOPNOTSUPP); so->so_pcb = NULL; -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) crfree(inp->ip_inp.inp.inp_cred); #endif SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp); @@ -2915,7 +2868,7 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id) SCTP_PRINTF("Out of SCTP-INPCB->hashinit - no resources\n"); SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, ENOBUFS); so->so_pcb = NULL; -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) crfree(inp->ip_inp.inp.inp_cred); #endif SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp); @@ -2929,7 +2882,7 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id) SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, ENOBUFS); so->so_pcb = NULL; SCTP_HASH_FREE(inp->sctp_tcbhash, inp->sctp_hashmark); -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) crfree(inp->ip_inp.inp.inp_cred); #endif SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp); @@ -2940,7 +2893,7 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id) #endif inp->def_vrf_id = vrf_id; -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #if defined(APPLE_LEOPARD) || defined(APPLE_SNOWLEOPARD) inp->ip_inp.inp.inpcb_mtx = lck_mtx_alloc_init(SCTP_BASE_INFO(sctbinfo).mtx_grp, SCTP_BASE_INFO(sctbinfo).mtx_attr); if (inp->ip_inp.inp.inpcb_mtx == NULL) { @@ -2963,8 +2916,9 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id) #endif SCTP_INP_INFO_WLOCK(); SCTP_INP_LOCK_INIT(inp); -#if defined(__FreeBSD__) - INP_LOCK_INIT(&inp->ip_inp.inp, "inp", "sctpinp"); +#if defined(__FreeBSD__) && !defined(__Userspace__) + rw_init_flags(&inp->ip_inp.inp.inp_lock, "sctpinp", + RW_RECURSE | RW_DUPOK); #endif SCTP_INP_READ_INIT(inp); SCTP_ASOC_CREATE_LOCK_INIT(inp); @@ -2973,7 +2927,7 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id) /* add it to the info area */ LIST_INSERT_HEAD(&SCTP_BASE_INFO(listhead), inp, sctp_list); -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) inp->ip_inp.inp.inp_pcbinfo = &SCTP_BASE_INFO(sctbinfo); #if defined(APPLE_LEOPARD) || defined(APPLE_SNOWLEOPARD) || defined(APPLE_LION) || defined(APPLE_MOUNTAINLION) LIST_INSERT_HEAD(SCTP_BASE_INFO(sctbinfo).listhead, &inp->ip_inp.inp, inp_list); @@ -3000,13 +2954,13 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id) m = &inp->sctp_ep; /* setup the base timeout information */ - m->sctp_timeoutticks[SCTP_TIMER_SEND] = SEC_TO_TICKS(SCTP_SEND_SEC); /* needed ? */ - m->sctp_timeoutticks[SCTP_TIMER_INIT] = SEC_TO_TICKS(SCTP_INIT_SEC); /* needed ? */ - m->sctp_timeoutticks[SCTP_TIMER_RECV] = MSEC_TO_TICKS(SCTP_BASE_SYSCTL(sctp_delayed_sack_time_default)); - m->sctp_timeoutticks[SCTP_TIMER_HEARTBEAT] = MSEC_TO_TICKS(SCTP_BASE_SYSCTL(sctp_heartbeat_interval_default)); - m->sctp_timeoutticks[SCTP_TIMER_PMTU] = SEC_TO_TICKS(SCTP_BASE_SYSCTL(sctp_pmtu_raise_time_default)); - m->sctp_timeoutticks[SCTP_TIMER_MAXSHUTDOWN] = SEC_TO_TICKS(SCTP_BASE_SYSCTL(sctp_shutdown_guard_time_default)); - m->sctp_timeoutticks[SCTP_TIMER_SIGNATURE] = SEC_TO_TICKS(SCTP_BASE_SYSCTL(sctp_secret_lifetime_default)); + m->sctp_timeoutticks[SCTP_TIMER_SEND] = sctp_secs_to_ticks(SCTP_SEND_SEC); /* needed ? */ + m->sctp_timeoutticks[SCTP_TIMER_INIT] = sctp_secs_to_ticks(SCTP_INIT_SEC); /* needed ? */ + m->sctp_timeoutticks[SCTP_TIMER_RECV] = sctp_msecs_to_ticks(SCTP_BASE_SYSCTL(sctp_delayed_sack_time_default)); + m->sctp_timeoutticks[SCTP_TIMER_HEARTBEAT] = sctp_msecs_to_ticks(SCTP_BASE_SYSCTL(sctp_heartbeat_interval_default)); + m->sctp_timeoutticks[SCTP_TIMER_PMTU] = sctp_secs_to_ticks(SCTP_BASE_SYSCTL(sctp_pmtu_raise_time_default)); + m->sctp_timeoutticks[SCTP_TIMER_MAXSHUTDOWN] = sctp_secs_to_ticks(SCTP_BASE_SYSCTL(sctp_shutdown_guard_time_default)); + m->sctp_timeoutticks[SCTP_TIMER_SIGNATURE] = sctp_secs_to_ticks(SCTP_BASE_SYSCTL(sctp_secret_lifetime_default)); /* all max/min max are in ms */ m->sctp_maxrto = SCTP_BASE_SYSCTL(sctp_rto_max_default); m->sctp_minrto = SCTP_BASE_SYSCTL(sctp_rto_min_default); @@ -3046,7 +3000,7 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id) /* Setup the initial secret */ (void)SCTP_GETTIME_TIMEVAL(&time); - m->time_of_secret_change = time.tv_sec; + m->time_of_secret_change = (unsigned int)time.tv_sec; for (i = 0; i < SCTP_NUMBER_OF_SECRETS; i++) { m->secret_key[0][i] = sctp_select_initial_TSN(m); @@ -3054,7 +3008,7 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id) sctp_timer_start(SCTP_TIMER_TYPE_NEWCOOKIE, inp, NULL, NULL); /* How long is a cookie good for ? */ - m->def_cookie_life = MSEC_TO_TICKS(SCTP_BASE_SYSCTL(sctp_valid_cookie_life_default)); + m->def_cookie_life = sctp_msecs_to_ticks(SCTP_BASE_SYSCTL(sctp_valid_cookie_life_default)); /* * Initialize authentication parameters */ @@ -3080,7 +3034,6 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id) return (error); } - void sctp_move_pcb_and_assoc(struct sctp_inpcb *old_inp, struct sctp_inpcb *new_inp, struct sctp_tcb *stcb) @@ -3098,6 +3051,25 @@ sctp_move_pcb_and_assoc(struct sctp_inpcb *old_inp, struct sctp_inpcb *new_inp, SCTP_TCB_LOCK(stcb); atomic_subtract_int(&stcb->asoc.refcnt, 1); +#if defined(__FreeBSD__) && !defined(__Userspace__) +#ifdef INET6 + if (old_inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) { + new_inp->ip_inp.inp.inp_flags |= old_inp->ip_inp.inp.inp_flags & INP_CONTROLOPTS; + if (old_inp->ip_inp.inp.in6p_outputopts) { + new_inp->ip_inp.inp.in6p_outputopts = ip6_copypktopts(old_inp->ip_inp.inp.in6p_outputopts, M_NOWAIT); + } + } +#endif +#if defined(INET) && defined(INET6) + else +#endif +#ifdef INET + { + new_inp->ip_inp.inp.inp_ip_tos = old_inp->ip_inp.inp.inp_ip_tos; + new_inp->ip_inp.inp.inp_ip_ttl = old_inp->ip_inp.inp.inp_ip_ttl; + } +#endif +#endif new_inp->sctp_ep.time_of_secret_change = old_inp->sctp_ep.time_of_secret_change; memcpy(new_inp->sctp_ep.secret_key, old_inp->sctp_ep.secret_key, @@ -3178,24 +3150,54 @@ sctp_move_pcb_and_assoc(struct sctp_inpcb *old_inp, struct sctp_inpcb *new_inp, } } } - /* Now any running timers need to be adjusted - * since we really don't care if they are running - * or not just blast in the new_inp into all of - * them. - */ - - stcb->asoc.dack_timer.ep = (void *)new_inp; - stcb->asoc.asconf_timer.ep = (void *)new_inp; - stcb->asoc.strreset_timer.ep = (void *)new_inp; - stcb->asoc.shut_guard_timer.ep = (void *)new_inp; - stcb->asoc.autoclose_timer.ep = (void *)new_inp; - stcb->asoc.delayed_event_timer.ep = (void *)new_inp; - stcb->asoc.delete_prim_timer.ep = (void *)new_inp; + /* Now any running timers need to be adjusted. */ + if (stcb->asoc.dack_timer.ep == old_inp) { + SCTP_INP_DECR_REF(old_inp); + stcb->asoc.dack_timer.ep = new_inp; + SCTP_INP_INCR_REF(new_inp); + } + if (stcb->asoc.asconf_timer.ep == old_inp) { + SCTP_INP_DECR_REF(old_inp); + stcb->asoc.asconf_timer.ep = new_inp; + SCTP_INP_INCR_REF(new_inp); + } + if (stcb->asoc.strreset_timer.ep == old_inp) { + SCTP_INP_DECR_REF(old_inp); + stcb->asoc.strreset_timer.ep = new_inp; + SCTP_INP_INCR_REF(new_inp); + } + if (stcb->asoc.shut_guard_timer.ep == old_inp) { + SCTP_INP_DECR_REF(old_inp); + stcb->asoc.shut_guard_timer.ep = new_inp; + SCTP_INP_INCR_REF(new_inp); + } + if (stcb->asoc.autoclose_timer.ep == old_inp) { + SCTP_INP_DECR_REF(old_inp); + stcb->asoc.autoclose_timer.ep = new_inp; + SCTP_INP_INCR_REF(new_inp); + } + if (stcb->asoc.delete_prim_timer.ep == old_inp) { + SCTP_INP_DECR_REF(old_inp); + stcb->asoc.delete_prim_timer.ep = new_inp; + SCTP_INP_INCR_REF(new_inp); + } /* now what about the nets? */ TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { - net->pmtu_timer.ep = (void *)new_inp; - net->hb_timer.ep = (void *)new_inp; - net->rxt_timer.ep = (void *)new_inp; + if (net->pmtu_timer.ep == old_inp) { + SCTP_INP_DECR_REF(old_inp); + net->pmtu_timer.ep = new_inp; + SCTP_INP_INCR_REF(new_inp); + } + if (net->hb_timer.ep == old_inp) { + SCTP_INP_DECR_REF(old_inp); + net->hb_timer.ep = new_inp; + SCTP_INP_INCR_REF(new_inp); + } + if (net->rxt_timer.ep == old_inp) { + SCTP_INP_DECR_REF(old_inp); + net->rxt_timer.ep = new_inp; + SCTP_INP_INCR_REF(new_inp); + } } SCTP_INP_WUNLOCK(new_inp); SCTP_INP_WUNLOCK(old_inp); @@ -3240,8 +3242,8 @@ sctp_remove_laddr(struct sctp_laddr *laddr) SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_laddr), laddr); SCTP_DECR_LADDR_COUNT(); } - #if !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__Userspace__)) + /* * Don't know why, but without this there is an unknown reference when * compiling NetBSD... hmm @@ -3249,24 +3251,28 @@ sctp_remove_laddr(struct sctp_laddr *laddr) extern void in6_sin6_2_sin(struct sockaddr_in *, struct sockaddr_in6 *sin6); #endif - -/* sctp_ifap is used to bypass normal local address validation checks */ +/* + * Bind the socket, with the PCB and global info locks held. Note, if a + * socket address is specified, the PCB lock may be dropped and re-acquired. + * + * sctp_ifap is used to bypass normal local address validation checks. + */ int -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 -sctp_inpcb_bind(struct socket *so, struct sockaddr *addr, - struct sctp_ifa *sctp_ifap, struct thread *p) -#elif defined(__Windows__) -sctp_inpcb_bind(struct socket *so, struct sockaddr *addr, - struct sctp_ifa *sctp_ifap, PKTHREAD p) +#if defined(__FreeBSD__) && !defined(__Userspace__) +sctp_inpcb_bind_locked(struct sctp_inpcb *inp, struct sockaddr *addr, + struct sctp_ifa *sctp_ifap, struct thread *td) +#elif defined(_WIN32) && !defined(__Userspace__) +sctp_inpcb_bind_locked(struct sctp_inpcb *inp, struct sockaddr *addr, + struct sctp_ifa *sctp_ifap, PKTHREAD p) #else -sctp_inpcb_bind(struct socket *so, struct sockaddr *addr, - struct sctp_ifa *sctp_ifap, struct proc *p) +sctp_inpcb_bind_locked(struct sctp_inpcb *inp, struct sockaddr *addr, + struct sctp_ifa *sctp_ifap, struct proc *p) #endif { /* bind a ep to a socket address */ struct sctppcbhead *head; - struct sctp_inpcb *inp, *inp_tmp; -#if defined(__FreeBSD__) || defined(__APPLE__) + struct sctp_inpcb *inp_tmp; +#if (defined(__FreeBSD__) || defined(__APPLE__)) && !defined(__Userspace__) struct inpcb *ip_inp; #endif int port_reuse_active = 0; @@ -3278,12 +3284,20 @@ sctp_inpcb_bind(struct socket *so, struct sockaddr *addr, int error; uint32_t vrf_id; +#if defined(__FreeBSD__) && !defined(__Userspace__) + KASSERT(td != NULL, ("%s: null thread", __func__)); + +#endif + error = 0; lport = 0; bindall = 1; - inp = (struct sctp_inpcb *)so->so_pcb; -#if defined(__FreeBSD__) || defined(__APPLE__) - ip_inp = (struct inpcb *)so->so_pcb; +#if (defined(__FreeBSD__) || defined(__APPLE__)) && !defined(__Userspace__) + ip_inp = &inp->ip_inp.inp; #endif + + SCTP_INP_INFO_WLOCK_ASSERT(); + SCTP_INP_WLOCK_ASSERT(inp); + #ifdef SCTP_DEBUG if (addr) { SCTPDBG(SCTP_DEBUG_PCB1, "Bind called port: %d\n", @@ -3293,16 +3307,11 @@ sctp_inpcb_bind(struct socket *so, struct sockaddr *addr, } #endif if ((inp->sctp_flags & SCTP_PCB_FLAGS_UNBOUND) == 0) { + error = EINVAL; /* already did a bind, subsequent binds NOT allowed ! */ - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL); - return (EINVAL); + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error); + goto out; } -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 -#ifdef INVARIANTS - if (p == NULL) - panic("null proc/thread"); -#endif -#endif if (addr != NULL) { switch (addr->sa_family) { #ifdef INET @@ -3312,26 +3321,28 @@ sctp_inpcb_bind(struct socket *so, struct sockaddr *addr, /* IPV6_V6ONLY socket? */ if (SCTP_IPV6_V6ONLY(inp)) { - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL); - return (EINVAL); + error = EINVAL; + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error); + goto out; } #ifdef HAVE_SA_LEN if (addr->sa_len != sizeof(*sin)) { - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL); - return (EINVAL); + error = EINVAL; + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error); + goto out; } #endif sin = (struct sockaddr_in *)addr; lport = sin->sin_port; -#if defined(__FreeBSD__) && __FreeBSD_version >= 800000 +#if defined(__FreeBSD__) && !defined(__Userspace__) /* * For LOOPBACK the prison_local_ip4() call will transmute the ip address * to the proper value. */ - if (p && (error = prison_local_ip4(p->td_ucred, &sin->sin_addr)) != 0) { + if ((error = prison_local_ip4(td->td_ucred, &sin->sin_addr)) != 0) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error); - return (error); + goto out; } #endif if (sin->sin_addr.s_addr != INADDR_ANY) { @@ -3347,23 +3358,23 @@ sctp_inpcb_bind(struct socket *so, struct sockaddr *addr, struct sockaddr_in6 *sin6; sin6 = (struct sockaddr_in6 *)addr; - #ifdef HAVE_SA_LEN if (addr->sa_len != sizeof(*sin6)) { - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL); - return (EINVAL); + error = EINVAL; + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error); + goto out; } #endif lport = sin6->sin6_port; -#if defined(__FreeBSD__) && __FreeBSD_version >= 800000 +#if defined(__FreeBSD__) && !defined(__Userspace__) /* * For LOOPBACK the prison_local_ip6() call will transmute the ipv6 address * to the proper value. */ - if (p && (error = prison_local_ip6(p->td_ucred, &sin6->sin6_addr, + if ((error = prison_local_ip6(td->td_ucred, &sin6->sin6_addr, (SCTP_IPV6_V6ONLY(inp) != 0))) != 0) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error); - return (error); + goto out; } #endif if (!IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) { @@ -3372,28 +3383,32 @@ sctp_inpcb_bind(struct socket *so, struct sockaddr *addr, /* KAME hack: embed scopeid */ #if defined(SCTP_KAME) if (sa6_embedscope(sin6, MODULE_GLOBAL(ip6_use_defzone)) != 0) { - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL); - return (EINVAL); + error = EINVAL; + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error); + goto out; } -#elif defined(__APPLE__) +#elif defined(__APPLE__) && !defined(__Userspace__) #if defined(APPLE_LEOPARD) || defined(APPLE_SNOWLEOPARD) if (in6_embedscope(&sin6->sin6_addr, sin6, ip_inp, NULL) != 0) { #else if (in6_embedscope(&sin6->sin6_addr, sin6, ip_inp, NULL, NULL) != 0) { #endif - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL); - return (EINVAL); + error = EINVAL; + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error); + goto out; } -#elif defined(__FreeBSD__) +#elif defined(__FreeBSD__) && !defined(__Userspace__) error = scope6_check_id(sin6, MODULE_GLOBAL(ip6_use_defzone)); if (error != 0) { + error = EINVAL; SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error); - return (error); + goto out; } #else if (in6_embedscope(&sin6->sin6_addr, sin6) != 0) { - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL); - return (EINVAL); + error = EINVAL; + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error); + goto out; } #endif #endif /* SCTP_EMBEDDED_V6_SCOPE */ @@ -3412,8 +3427,9 @@ sctp_inpcb_bind(struct socket *so, struct sockaddr *addr, #ifdef HAVE_SA_LEN if (addr->sa_len != sizeof(struct sockaddr_conn)) { - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL); - return (EINVAL); + error = EINVAL; + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error); + goto out; } #endif sconn = (struct sockaddr_conn *)addr; @@ -3425,58 +3441,36 @@ sctp_inpcb_bind(struct socket *so, struct sockaddr *addr, } #endif default: - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EAFNOSUPPORT); - return (EAFNOSUPPORT); + error = EAFNOSUPPORT; + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error); + goto out; } } - SCTP_INP_INFO_WLOCK(); - SCTP_INP_WLOCK(inp); /* Setup a vrf_id to be the default for the non-bind-all case. */ vrf_id = inp->def_vrf_id; - /* increase our count due to the unlock we do */ - SCTP_INP_INCR_REF(inp); if (lport) { /* * Did the caller specify a port? if so we must see if an ep * already has this one bound. */ /* got to be root to get at low ports */ -#if !defined(__Windows__) - if (ntohs(lport) < IPPORT_RESERVED) { - if ((p != NULL) && ((error = -#ifdef __FreeBSD__ -#if __FreeBSD_version > 602000 - priv_check(p, PRIV_NETINET_RESERVEDPORT) -#elif __FreeBSD_version >= 500000 - suser_cred(p->td_ucred, 0) +#if !(defined(_WIN32) && !defined(__Userspace__)) + if (ntohs(lport) < IPPORT_RESERVED && +#if defined(__FreeBSD__) && !defined(__Userspace__) + (error = priv_check(td, PRIV_NETINET_RESERVEDPORT)) != 0) { +#elif defined(__APPLE__) && !defined(__Userspace__) + (error = suser(p->p_ucred, &p->p_acflag)) != 0) { +#elif defined(__Userspace__) + /* TODO ensure uid is 0, etc... */ + 0) { #else - suser(p) -#endif -#elif defined(__APPLE__) - suser(p->p_ucred, &p->p_acflag) -#elif defined(__Userspace__) /* must be true to use raw socket */ - 1 -#else - suser(p, 0) -#endif - ) != 0)) { - SCTP_INP_DECR_REF(inp); - SCTP_INP_WUNLOCK(inp); - SCTP_INP_INFO_WUNLOCK(); - return (error); - } -#if defined(__Panda__) - if (!SCTP_IS_PRIVILEDGED(so)) { - SCTP_INP_DECR_REF(inp); - SCTP_INP_WUNLOCK(inp); - SCTP_INP_INFO_WUNLOCK(); - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EACCES); - return (EACCES); - } + (error = suser(p, 0)) != 0) { #endif + goto out; } -#endif /* __Windows__ */ +#endif + SCTP_INP_INCR_REF(inp); SCTP_INP_WUNLOCK(inp); if (bindall) { #ifdef SCTP_MVRF @@ -3503,10 +3497,11 @@ sctp_inpcb_bind(struct socket *so, struct sockaddr *addr, port_reuse_active = 1; goto continue_anyway; } + SCTP_INP_WLOCK(inp); SCTP_INP_DECR_REF(inp); - SCTP_INP_INFO_WUNLOCK(); - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EADDRINUSE); - return (EADDRINUSE); + error = EADDRINUSE; + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error); + goto out; } #ifdef SCTP_MVRF } @@ -3529,14 +3524,16 @@ sctp_inpcb_bind(struct socket *so, struct sockaddr *addr, port_reuse_active = 1; goto continue_anyway; } + SCTP_INP_WLOCK(inp); SCTP_INP_DECR_REF(inp); - SCTP_INP_INFO_WUNLOCK(); - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EADDRINUSE); - return (EADDRINUSE); + error = EADDRINUSE; + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error); + goto out; } } continue_anyway: SCTP_INP_WLOCK(inp); + SCTP_INP_DECR_REF(inp); if (bindall) { /* verify that no lport is not used by a singleton */ if ((port_reuse_active == 0) && @@ -3546,61 +3543,42 @@ sctp_inpcb_bind(struct socket *so, struct sockaddr *addr, (sctp_is_feature_on(inp_tmp, SCTP_PCB_FLAGS_PORTREUSE))) { port_reuse_active = 1; } else { - SCTP_INP_DECR_REF(inp); - SCTP_INP_WUNLOCK(inp); - SCTP_INP_INFO_WUNLOCK(); - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EADDRINUSE); - return (EADDRINUSE); + error = EADDRINUSE; + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error); + goto out; } } } } else { uint16_t first, last, candidate; uint16_t count; - int done; -#if defined(__Windows__) +#if defined(__Userspace__) + first = MODULE_GLOBAL(ipport_firstauto); + last = MODULE_GLOBAL(ipport_lastauto); +#elif defined(_WIN32) first = 1; last = 0xffff; -#else -#if defined(__Userspace__) - /* TODO ensure uid is 0, etc... */ #elif defined(__FreeBSD__) || defined(__APPLE__) if (ip_inp->inp_flags & INP_HIGHPORT) { first = MODULE_GLOBAL(ipport_hifirstauto); last = MODULE_GLOBAL(ipport_hilastauto); } else if (ip_inp->inp_flags & INP_LOWPORT) { - if (p && (error = -#ifdef __FreeBSD__ -#if __FreeBSD_version > 602000 - priv_check(p, PRIV_NETINET_RESERVEDPORT) -#elif __FreeBSD_version >= 500000 - suser_cred(p->td_ucred, 0) +#if defined(__FreeBSD__) + if ((error = priv_check(td, PRIV_NETINET_RESERVEDPORT)) != 0) { #else - suser(p) + if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) { #endif -#elif defined(__APPLE__) - suser(p->p_ucred, &p->p_acflag) -#else - suser(p, 0) -#endif - )) { - SCTP_INP_DECR_REF(inp); - SCTP_INP_WUNLOCK(inp); - SCTP_INP_INFO_WUNLOCK(); SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error); - return (error); + goto out; } first = MODULE_GLOBAL(ipport_lowfirstauto); last = MODULE_GLOBAL(ipport_lowlastauto); } else { -#endif first = MODULE_GLOBAL(ipport_firstauto); last = MODULE_GLOBAL(ipport_lastauto); -#if defined(__FreeBSD__) || defined(__APPLE__) } #endif -#endif /* __Windows__ */ if (first > last) { uint16_t temp; @@ -3611,8 +3589,7 @@ sctp_inpcb_bind(struct socket *so, struct sockaddr *addr, count = last - first + 1; /* number of candidates */ candidate = first + sctp_select_initial_TSN(&inp->sctp_ep) % (count); - done = 0; - while (!done) { + for (;;) { #ifdef SCTP_MVRF for (i = 0; i < inp->num_vrfs; i++) { if (sctp_isport_inuse(inp, htons(candidate), inp->m_vrf_ids[i]) != NULL) { @@ -3620,40 +3597,35 @@ sctp_inpcb_bind(struct socket *so, struct sockaddr *addr, } } if (i == inp->num_vrfs) { - done = 1; + lport = htons(candidate); + break; } #else if (sctp_isport_inuse(inp, htons(candidate), inp->def_vrf_id) == NULL) { - done = 1; + lport = htons(candidate); + break; } #endif - if (!done) { - if (--count == 0) { - SCTP_INP_DECR_REF(inp); - SCTP_INP_WUNLOCK(inp); - SCTP_INP_INFO_WUNLOCK(); - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EADDRINUSE); - return (EADDRINUSE); - } - if (candidate == last) - candidate = first; - else - candidate = candidate + 1; + if (--count == 0) { + error = EADDRINUSE; + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error); + goto out; } + if (candidate == last) + candidate = first; + else + candidate = candidate + 1; } - lport = htons(candidate); } - SCTP_INP_DECR_REF(inp); if (inp->sctp_flags & (SCTP_PCB_FLAGS_SOCKET_GONE | SCTP_PCB_FLAGS_SOCKET_ALLGONE)) { /* * this really should not happen. The guy did a non-blocking * bind and then did a close at the same time. */ - SCTP_INP_WUNLOCK(inp); - SCTP_INP_INFO_WUNLOCK(); - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL); - return (EINVAL); + error = EINVAL; + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error); + goto out; } /* ok we look clear to give out this port, so lets setup the binding */ if (bindall) { @@ -3739,27 +3711,25 @@ sctp_inpcb_bind(struct socket *so, struct sockaddr *addr, } else { /* Note for BSD we hit here always other * O/S's will pass things in via the - * sctp_ifap argument (Panda). + * sctp_ifap argument. */ ifa = sctp_find_ifa_by_addr(&store.sa, vrf_id, SCTP_ADDR_NOT_LOCKED); } if (ifa == NULL) { + error = EADDRNOTAVAIL; /* Can't find an interface with that address */ - SCTP_INP_WUNLOCK(inp); - SCTP_INP_INFO_WUNLOCK(); - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EADDRNOTAVAIL); - return (EADDRNOTAVAIL); + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error); + goto out; } #ifdef INET6 if (addr->sa_family == AF_INET6) { /* GAK, more FIXME IFA lock? */ if (ifa->localifa_flags & SCTP_ADDR_IFA_UNUSEABLE) { /* Can't bind a non-existent addr. */ - SCTP_INP_WUNLOCK(inp); - SCTP_INP_INFO_WUNLOCK(); - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL); - return (EINVAL); + error = EINVAL; + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error); + goto out; } } #endif @@ -3772,11 +3742,8 @@ sctp_inpcb_bind(struct socket *so, struct sockaddr *addr, /* add this address to the endpoint list */ error = sctp_insert_laddr(&inp->sctp_addr_list, ifa, 0); - if (error != 0) { - SCTP_INP_WUNLOCK(inp); - SCTP_INP_INFO_WUNLOCK(); - return (error); - } + if (error != 0) + goto out; inp->laddr_count++; } /* find the bucket */ @@ -3795,12 +3762,40 @@ sctp_inpcb_bind(struct socket *so, struct sockaddr *addr, inp->sctp_lport = lport; /* turn off just the unbound flag */ + KASSERT((inp->sctp_flags & SCTP_PCB_FLAGS_UNBOUND) != 0, + ("%s: inp %p is already bound", __func__, inp)); inp->sctp_flags &= ~SCTP_PCB_FLAGS_UNBOUND; - SCTP_INP_WUNLOCK(inp); - SCTP_INP_INFO_WUNLOCK(); - return (0); +out: + return (error); } +int +#if defined(__FreeBSD__) && !defined(__Userspace__) +sctp_inpcb_bind(struct socket *so, struct sockaddr *addr, + struct sctp_ifa *sctp_ifap, struct thread *td) +#elif defined(_WIN32) && !defined(__Userspace__) +sctp_inpcb_bind(struct socket *so, struct sockaddr *addr, + struct sctp_ifa *sctp_ifap, PKTHREAD p) +#else +sctp_inpcb_bind(struct socket *so, struct sockaddr *addr, + struct sctp_ifa *sctp_ifap, struct proc *p) +#endif +{ + struct sctp_inpcb *inp; + int error; + + inp = so->so_pcb; + SCTP_INP_INFO_WLOCK(); + SCTP_INP_WLOCK(inp); +#if defined(__FreeBSD__) && !defined(__Userspace__) + error = sctp_inpcb_bind_locked(inp, addr, sctp_ifap, td); +#else + error = sctp_inpcb_bind_locked(inp, addr, sctp_ifap, p); +#endif + SCTP_INP_WUNLOCK(inp); + SCTP_INP_INFO_WUNLOCK(); + return (error); +} static void sctp_iterator_inp_being_freed(struct sctp_inpcb *inp) @@ -3812,7 +3807,7 @@ sctp_iterator_inp_being_freed(struct sctp_inpcb *inp) * lock on the inp_info stuff. */ it = sctp_it_ctl.cur_it; -#if defined(__FreeBSD__) && __FreeBSD_version >= 801000 +#if defined(__FreeBSD__) && !defined(__Userspace__) if (it && (it->vn != curvnet)) { /* Its not looking at our VNET */ return; @@ -3843,7 +3838,7 @@ sctp_iterator_inp_being_freed(struct sctp_inpcb *inp) */ SCTP_IPI_ITERATOR_WQ_LOCK(); TAILQ_FOREACH_SAFE(it, &sctp_it_ctl.iteratorhead, sctp_nxt_itr, nit) { -#if defined(__FreeBSD__) && __FreeBSD_version >= 801000 +#if defined(__FreeBSD__) && !defined(__Userspace__) if (it->vn != curvnet) { continue; } @@ -3889,16 +3884,15 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from) struct socket *so; int being_refed = 0; struct sctp_queued_to_read *sq, *nsq; -#if !defined(__Panda__) && !defined(__Userspace__) -#if !defined(__FreeBSD__) || __FreeBSD_version < 500000 +#if !defined(__Userspace__) +#if !defined(__FreeBSD__) sctp_rtentry_t *rt; #endif #endif int cnt; sctp_sharedkey_t *shared_key, *nshared_key; - -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) sctp_lock_assert(SCTP_INP_SO(inp)); #endif #ifdef SCTP_LOG_CLOSING @@ -3908,30 +3902,25 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from) /* mark any iterators on the list or being processed */ sctp_iterator_inp_being_freed(inp); SCTP_ITERATOR_UNLOCK(); - so = inp->sctp_socket; - if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) { - /* been here before.. eeks.. get out of here */ - SCTP_PRINTF("This conflict in free SHOULD not be happening! from %d, imm %d\n", from, immediate); -#ifdef SCTP_LOG_CLOSING - sctp_log_closing(inp, NULL, 1); -#endif - return; - } + SCTP_ASOC_CREATE_LOCK(inp); SCTP_INP_INFO_WLOCK(); - SCTP_INP_WLOCK(inp); + so = inp->sctp_socket; + KASSERT((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) != 0, + ("%s: inp %p still has socket", __func__, inp)); + KASSERT((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) == 0, + ("%s: double free of inp %p", __func__, inp)); if (from == SCTP_CALLED_AFTER_CMPSET_OFCLOSE) { inp->sctp_flags &= ~SCTP_PCB_FLAGS_CLOSE_IP; /* socket is gone, so no more wakeups allowed */ inp->sctp_flags |= SCTP_PCB_FLAGS_DONT_WAKE; inp->sctp_flags &= ~SCTP_PCB_FLAGS_WAKEINPUT; inp->sctp_flags &= ~SCTP_PCB_FLAGS_WAKEOUTPUT; - } /* First time through we have the socket lock, after that no more. */ sctp_timer_stop(SCTP_TIMER_TYPE_NEWCOOKIE, inp, NULL, NULL, - SCTP_FROM_SCTP_PCB + SCTP_LOC_1); + SCTP_FROM_SCTP_PCB + SCTP_LOC_1); if (inp->control) { sctp_m_freem(inp->control); @@ -3951,6 +3940,7 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from) LIST_FOREACH_SAFE(asoc, &inp->sctp_asoc_list, sctp_tcblist, nasoc) { SCTP_TCB_LOCK(asoc); if (asoc->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) { + asoc->sctp_socket = NULL; /* Skip guys being freed */ cnt_in_sd++; if (asoc->asoc.state & SCTP_STATE_IN_ACCEPT_QUEUE) { @@ -4031,15 +4021,13 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from) sctp_send_shutdown(asoc, netp); sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN, asoc->sctp_ep, asoc, netp); - sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, asoc->sctp_ep, asoc, - asoc->asoc.primary_destination); + sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, asoc->sctp_ep, asoc, NULL); sctp_chunk_output(inp, asoc, SCTP_OUTPUT_FROM_SHUT_TMR, SCTP_SO_LOCKED); } } else { /* mark into shutdown pending */ SCTP_ADD_SUBSTATE(asoc, SCTP_STATE_SHUTDOWN_PENDING); - sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, asoc->sctp_ep, asoc, - asoc->asoc.primary_destination); + sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, asoc->sctp_ep, asoc, NULL); if ((*asoc->asoc.ss_functions.sctp_ss_is_user_msgs_incomplete)(asoc, &asoc->asoc)) { SCTP_ADD_SUBSTATE(asoc, SCTP_STATE_PARTIAL_MSG_LEFT); } @@ -4101,12 +4089,17 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from) cnt = 0; LIST_FOREACH_SAFE(asoc, &inp->sctp_asoc_list, sctp_tcblist, nasoc) { SCTP_TCB_LOCK(asoc); + if (immediate != SCTP_FREE_SHOULD_USE_GRACEFUL_CLOSE) { + /* Disconnect the socket please */ + asoc->sctp_socket = NULL; + SCTP_ADD_SUBSTATE(asoc, SCTP_STATE_CLOSED_SOCKET); + } if (asoc->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) { if (asoc->asoc.state & SCTP_STATE_IN_ACCEPT_QUEUE) { SCTP_CLEAR_SUBSTATE(asoc, SCTP_STATE_IN_ACCEPT_QUEUE); sctp_timer_start(SCTP_TIMER_TYPE_ASOCKILL, inp, asoc, NULL); } - cnt++; + cnt++; SCTP_TCB_UNLOCK(asoc); continue; } @@ -4135,7 +4128,6 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from) } if (cnt) { /* Ok we have someone out there that will kill us */ - (void)SCTP_OS_TIMER_STOP(&inp->sctp_ep.signature_change.timer); #ifdef SCTP_LOG_CLOSING sctp_log_closing(inp, NULL, 3); #endif @@ -4150,11 +4142,10 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from) being_refed++; if (SCTP_ASOC_CREATE_LOCK_CONTENDED(inp)) being_refed++; - + /* NOTE: 0 refcount also means no timers are referencing us. */ if ((inp->refcount) || (being_refed) || (inp->sctp_flags & SCTP_PCB_FLAGS_CLOSE_IP)) { - (void)SCTP_OS_TIMER_STOP(&inp->sctp_ep.signature_change.timer); #ifdef SCTP_LOG_CLOSING sctp_log_closing(inp, NULL, 4); #endif @@ -4173,30 +4164,15 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from) SCTP_INP_WUNLOCK(inp); SCTP_ASOC_CREATE_UNLOCK(inp); SCTP_INP_INFO_WUNLOCK(); - /* Now we release all locks. Since this INP - * cannot be found anymore except possibly by the - * kill timer that might be running. We call - * the drain function here. It should hit the case - * were it sees the ACTIVE flag cleared and exit - * out freeing us to proceed and destroy everything. - */ - if (from != SCTP_CALLED_FROM_INPKILL_TIMER) { - (void)SCTP_OS_TIMER_STOP_DRAIN(&inp->sctp_ep.signature_change.timer); - } else { - /* Probably un-needed */ - (void)SCTP_OS_TIMER_STOP(&inp->sctp_ep.signature_change.timer); - } #ifdef SCTP_LOG_CLOSING sctp_log_closing(inp, NULL, 5); #endif - -#if !(defined(__Panda__) || defined(__Windows__) || defined(__Userspace__)) -#if !defined(__FreeBSD__) || __FreeBSD_version < 500000 +#if !(defined(_WIN32) || defined(__Userspace__)) +#if !(defined(__FreeBSD__) && !defined(__Userspace__)) rt = ip_pcb->inp_route.ro_rt; #endif #endif - if ((inp->sctp_asocidhash) != NULL) { SCTP_HASH_FREE(inp->sctp_asocidhash, inp->hashasocidmark); inp->sctp_asocidhash = NULL; @@ -4227,33 +4203,21 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from) * macro here since le_next will get freed as part of the * sctp_free_assoc() call. */ -#ifndef __Panda__ if (ip_pcb->inp_options) { (void)sctp_m_free(ip_pcb->inp_options); ip_pcb->inp_options = 0; } -#endif - -#if !(defined(__Panda__) || defined(__Windows__) || defined(__Userspace__)) -#if !defined(__FreeBSD__) || __FreeBSD_version < 500000 +#if !(defined(_WIN32) || defined(__Userspace__)) +#if !defined(__FreeBSD__) if (rt) { RTFREE(rt); ip_pcb->inp_route.ro_rt = 0; } #endif -#if defined(__FreeBSD__) && __FreeBSD_version < 803000 -#ifdef INET - if (ip_pcb->inp_moptions) { - inp_freemoptions(ip_pcb->inp_moptions); - ip_pcb->inp_moptions = 0; - } #endif -#endif -#endif - #ifdef INET6 -#if !(defined(__Panda__) || defined(__Windows__) || defined(__Userspace__)) -#if defined(__FreeBSD__) || defined(__APPLE__) +#if !(defined(_WIN32) || defined(__Userspace__)) +#if (defined(__FreeBSD__) || defined(__APPLE__) && !defined(__Userspace__)) if (ip_pcb->inp_vflag & INP_IPV6) { #else if (inp->inp_vflag & INP_IPV6) { @@ -4262,11 +4226,7 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from) } #endif #endif /* INET6 */ -#if !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) || defined(__Userspace__)) - inp->inp_vflag = 0; -#else ip_pcb->inp_vflag = 0; -#endif /* free up authentication fields */ if (inp->sctp_ep.local_auth_chunks != NULL) sctp_free_chunklist(inp->sctp_ep.local_auth_chunks); @@ -4279,7 +4239,7 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from) /*sa_ignore FREED_MEMORY*/ } -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) inp->ip_inp.inp.inp_state = INPCB_STATE_DEAD; if (in_pcb_checkstate(&inp->ip_inp.inp, WNT_STOPUSING, 1) != WNT_STOPUSING) { #ifdef INVARIANTS @@ -4317,14 +4277,14 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from) inp->sctp_tcbhash = NULL; } /* Now we must put the ep memory back into the zone pool */ -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) crfree(inp->ip_inp.inp.inp_cred); INP_LOCK_DESTROY(&inp->ip_inp.inp); #endif SCTP_INP_LOCK_DESTROY(inp); SCTP_INP_READ_DESTROY(inp); SCTP_ASOC_CREATE_LOCK_DESTROY(inp); -#if !defined(__APPLE__) +#if !(defined(__APPLE__) && !defined(__Userspace__)) SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp); SCTP_DECR_EP_COUNT(); #else @@ -4332,7 +4292,6 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from) #endif } - struct sctp_nets * sctp_findnet(struct sctp_tcb *stcb, struct sockaddr *addr) { @@ -4345,13 +4304,9 @@ sctp_findnet(struct sctp_tcb *stcb, struct sockaddr *addr) return (NULL); } - int sctp_is_address_on_local_host(struct sockaddr *addr, uint32_t vrf_id) { -#ifdef __Panda__ - return (0); -#else struct sctp_ifa *sctp_ifa; sctp_ifa = sctp_find_ifa_by_addr(addr, vrf_id, SCTP_ADDR_NOT_LOCKED); if (sctp_ifa) { @@ -4359,7 +4314,6 @@ sctp_is_address_on_local_host(struct sockaddr *addr, uint32_t vrf_id) } else { return (0); } -#endif } /* @@ -4608,7 +4562,7 @@ sctp_add_remote_addr(struct sctp_tcb *stcb, struct sockaddr *newaddr, struct sockaddr_in6 *sin6; sin6 = (struct sockaddr_in6 *)&net->ro._l_addr; -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #if defined(APPLE_LEOPARD) || defined(APPLE_SNOWLEOPARD) (void)in6_embedscope(&sin6->sin6_addr, sin6, &stcb->sctp_ep->ip_inp.inp, NULL); #else @@ -4675,18 +4629,22 @@ sctp_add_remote_addr(struct sctp_tcb *stcb, struct sockaddr *newaddr, } else { imtu = 0; } - rmtu = SCTP_GATHER_MTU_FROM_ROUTE(net->ro._s_addr, &net->ro._l_addr.sa, net->ro.ro_rt); -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) + rmtu = SCTP_GATHER_MTU_FROM_ROUTE(net->ro._s_addr, &net->ro._l_addr.sa, net->ro.ro_nh); hcmtu = sctp_hc_get_mtu(&net->ro._l_addr, stcb->sctp_ep->fibnum); #else + rmtu = SCTP_GATHER_MTU_FROM_ROUTE(net->ro._s_addr, &net->ro._l_addr.sa, net->ro.ro_rt); hcmtu = 0; #endif net->mtu = sctp_min_mtu(hcmtu, rmtu, imtu); +#if defined(__FreeBSD__) && !defined(__Userspace__) +#else if (rmtu == 0) { /* Start things off to match mtu of interface please. */ SCTP_SET_MTU_OF_ROUTE(&net->ro._l_addr.sa, net->ro.ro_rt, net->mtu); } +#endif } } #endif @@ -4748,7 +4706,7 @@ sctp_add_remote_addr(struct sctp_tcb *stcb, struct sockaddr *newaddr, stcb->asoc.smallest_mtu = net->mtu; } if (stcb->asoc.smallest_mtu > net->mtu) { - sctp_pathmtu_adjustment(stcb, net->mtu); + sctp_pathmtu_adjustment(stcb, net->mtu, true); } #ifdef INET6 #ifdef SCTP_EMBEDDED_V6_SCOPE @@ -4775,7 +4733,7 @@ sctp_add_remote_addr(struct sctp_tcb *stcb, struct sockaddr *newaddr, */ net->find_pseudo_cumack = 1; net->find_rtx_pseudo_cumack = 1; -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) /* Choose an initial flowid. */ net->flowid = stcb->asoc.my_vtag ^ ntohs(stcb->rport) ^ @@ -4786,26 +4744,36 @@ sctp_add_remote_addr(struct sctp_tcb *stcb, struct sockaddr *newaddr, *netp = net; } netfirst = TAILQ_FIRST(&stcb->asoc.nets); +#if defined(__FreeBSD__) && !defined(__Userspace__) + if (net->ro.ro_nh == NULL) { +#else if (net->ro.ro_rt == NULL) { +#endif /* Since we have no route put it at the back */ TAILQ_INSERT_TAIL(&stcb->asoc.nets, net, sctp_next); } else if (netfirst == NULL) { /* We are the first one in the pool. */ TAILQ_INSERT_HEAD(&stcb->asoc.nets, net, sctp_next); +#if defined(__FreeBSD__) && !defined(__Userspace__) + } else if (netfirst->ro.ro_nh == NULL) { +#else } else if (netfirst->ro.ro_rt == NULL) { +#endif /* * First one has NO route. Place this one ahead of the first * one. */ TAILQ_INSERT_HEAD(&stcb->asoc.nets, net, sctp_next); -#ifndef __Panda__ +#if defined(__FreeBSD__) && !defined(__Userspace__) + } else if (net->ro.ro_nh->nh_ifp != netfirst->ro.ro_nh->nh_ifp) { +#else } else if (net->ro.ro_rt->rt_ifp != netfirst->ro.ro_rt->rt_ifp) { +#endif /* * This one has a different interface than the one at the * top of the list. Place it ahead. */ TAILQ_INSERT_HEAD(&stcb->asoc.nets, net, sctp_next); -#endif } else { /* * Ok we have the same interface as the first one. Move @@ -4821,34 +4789,39 @@ sctp_add_remote_addr(struct sctp_tcb *stcb, struct sockaddr *newaddr, /* End of the list */ TAILQ_INSERT_TAIL(&stcb->asoc.nets, net, sctp_next); break; +#if defined(__FreeBSD__) && !defined(__Userspace__) + } else if (netlook->ro.ro_nh == NULL) { +#else } else if (netlook->ro.ro_rt == NULL) { +#endif /* next one has NO route */ TAILQ_INSERT_BEFORE(netfirst, net, sctp_next); break; - } -#ifndef __Panda__ - else if (netlook->ro.ro_rt->rt_ifp != net->ro.ro_rt->rt_ifp) +#if defined(__FreeBSD__) && !defined(__Userspace__) + } else if (netlook->ro.ro_nh->nh_ifp != net->ro.ro_nh->nh_ifp) { #else - else + } else if (netlook->ro.ro_rt->rt_ifp != net->ro.ro_rt->rt_ifp) { #endif - { TAILQ_INSERT_AFTER(&stcb->asoc.nets, netlook, - net, sctp_next); + net, sctp_next); break; } -#ifndef __Panda__ /* Shift forward */ netfirst = netlook; -#endif } while (netlook != NULL); } /* got to have a primary set */ if (stcb->asoc.primary_destination == 0) { stcb->asoc.primary_destination = net; +#if defined(__FreeBSD__) && !defined(__Userspace__) + } else if ((stcb->asoc.primary_destination->ro.ro_nh == NULL) && + (net->ro.ro_nh) && +#else } else if ((stcb->asoc.primary_destination->ro.ro_rt == NULL) && - (net->ro.ro_rt) && - ((net->dest_state & SCTP_ADDR_UNCONFIRMED) == 0)) { + (net->ro.ro_rt) && +#endif + ((net->dest_state & SCTP_ADDR_UNCONFIRMED) == 0)) { /* No route to current primary adopt new primary */ stcb->asoc.primary_destination = net; } @@ -4869,7 +4842,6 @@ sctp_add_remote_addr(struct sctp_tcb *stcb, struct sockaddr *newaddr, return (0); } - static uint32_t sctp_aloc_a_assoc_id(struct sctp_inpcb *inp, struct sctp_tcb *stcb) { @@ -4906,21 +4878,21 @@ sctp_aloc_a_assoc_id(struct sctp_inpcb *inp, struct sctp_tcb *stcb) * careful to add all additional addresses once they are know right away or * else the assoc will be may experience a blackout scenario. */ -struct sctp_tcb * -sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockaddr *firstaddr, - int *error, uint32_t override_tag, uint32_t vrf_id, - uint16_t o_streams, uint16_t port, -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 - struct thread *p, -#elif defined(__Windows__) - PKTHREAD p, +static struct sctp_tcb * +sctp_aloc_assoc_locked(struct sctp_inpcb *inp, struct sockaddr *firstaddr, + int *error, uint32_t override_tag, uint32_t initial_tsn, + uint32_t vrf_id, uint16_t o_streams, uint16_t port, +#if defined(__FreeBSD__) && !defined(__Userspace__) + struct thread *p, +#elif defined(_WIN32) && !defined(__Userspace__) + PKTHREAD p, #else #if defined(__Userspace__) - /* __Userspace__ NULL proc is going to be passed here. See sctp_lower_sosend */ + /* __Userspace__ NULL proc is going to be passed here. See sctp_lower_sosend */ #endif - struct proc *p, + struct proc *p, #endif - int initialize_auth_params) + int initialize_auth_params) { /* note the p argument is only valid in unbound sockets */ @@ -4930,6 +4902,9 @@ sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockaddr *firstaddr, uint16_t rport; int err; + SCTP_INP_INFO_WLOCK_ASSERT(); + SCTP_INP_WLOCK_ASSERT(inp); + /* * Assumption made here: Caller has done a * sctp_findassociation_ep_addr(ep, addr's); to make sure the @@ -4946,7 +4921,11 @@ sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockaddr *firstaddr, *error = EINVAL; return (NULL); } - SCTP_INP_RLOCK(inp); + if (inp->sctp_flags & (SCTP_PCB_FLAGS_SOCKET_GONE | SCTP_PCB_FLAGS_SOCKET_ALLGONE)) { + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL); + *error = EINVAL; + return (NULL); + } if ((inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) && ((sctp_is_feature_off(inp, SCTP_PCB_FLAGS_PORTREUSE)) || (inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED))) { @@ -4956,7 +4935,6 @@ sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockaddr *firstaddr, * sctp_aloc_assoc.. or the one-2-many socket. If a peeled * off, or connected one does this.. its an error. */ - SCTP_INP_RUNLOCK(inp); SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL); *error = EINVAL; return (NULL); @@ -4965,7 +4943,6 @@ sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockaddr *firstaddr, (inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE)) { if ((inp->sctp_flags & SCTP_PCB_FLAGS_WAS_CONNECTED) || (inp->sctp_flags & SCTP_PCB_FLAGS_WAS_ABORTED)) { - SCTP_INP_RUNLOCK(inp); SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL); *error = EINVAL; return (NULL); @@ -5011,9 +4988,16 @@ sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockaddr *firstaddr, if ((ntohs(sin->sin_port) == 0) || (sin->sin_addr.s_addr == INADDR_ANY) || (sin->sin_addr.s_addr == INADDR_BROADCAST) || - IN_MULTICAST(ntohl(sin->sin_addr.s_addr))) { + IN_MULTICAST(ntohl(sin->sin_addr.s_addr)) || +#if defined(__Userspace__) + (((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_CONN) != 0) || + (((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) != 0) && + (SCTP_IPV6_V6ONLY(inp) != 0)))) { +#else + (((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) != 0) && + (SCTP_IPV6_V6ONLY(inp) != 0))) { +#endif /* Invalid address */ - SCTP_INP_RUNLOCK(inp); SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL); *error = EINVAL; return (NULL); @@ -5030,9 +5014,9 @@ sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockaddr *firstaddr, sin6 = (struct sockaddr_in6 *)firstaddr; if ((ntohs(sin6->sin6_port) == 0) || IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr) || - IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) { + IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr) || + ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) == 0)) { /* Invalid address */ - SCTP_INP_RUNLOCK(inp); SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL); *error = EINVAL; return (NULL); @@ -5048,9 +5032,9 @@ sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockaddr *firstaddr, sconn = (struct sockaddr_conn *)firstaddr; if ((ntohs(sconn->sconn_port) == 0) || - (sconn->sconn_addr == NULL)) { + (sconn->sconn_addr == NULL) || + ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_CONN) == 0)) { /* Invalid address */ - SCTP_INP_RUNLOCK(inp); SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL); *error = EINVAL; return (NULL); @@ -5061,26 +5045,16 @@ sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockaddr *firstaddr, #endif default: /* not supported family type */ - SCTP_INP_RUNLOCK(inp); SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL); *error = EINVAL; return (NULL); } - SCTP_INP_RUNLOCK(inp); if (inp->sctp_flags & SCTP_PCB_FLAGS_UNBOUND) { /* * If you have not performed a bind, then we need to do the * ephemeral bind for you. */ - if ((err = sctp_inpcb_bind(inp->sctp_socket, - (struct sockaddr *)NULL, - (struct sctp_ifa *)NULL, -#ifndef __Panda__ - p -#else - (struct proc *)NULL -#endif - ))) { + if ((err = sctp_inpcb_bind_locked(inp, NULL, NULL, p))) { /* bind error, probably perm */ *error = err; return (NULL); @@ -5104,7 +5078,7 @@ sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockaddr *firstaddr, /* setup back pointer's */ stcb->sctp_ep = inp; stcb->sctp_socket = inp->sctp_socket; - if ((err = sctp_init_asoc(inp, stcb, override_tag, vrf_id, o_streams))) { + if ((err = sctp_init_asoc(inp, stcb, override_tag, initial_tsn, vrf_id, o_streams))) { /* failed */ SCTP_TCB_LOCK_DESTROY(stcb); SCTP_TCB_SEND_LOCK_DESTROY(stcb); @@ -5113,21 +5087,6 @@ sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockaddr *firstaddr, *error = err; return (NULL); } - /* and the port */ - SCTP_INP_INFO_WLOCK(); - SCTP_INP_WLOCK(inp); - if (inp->sctp_flags & (SCTP_PCB_FLAGS_SOCKET_GONE | SCTP_PCB_FLAGS_SOCKET_ALLGONE)) { - /* inpcb freed while alloc going on */ - SCTP_TCB_LOCK_DESTROY(stcb); - SCTP_TCB_SEND_LOCK_DESTROY(stcb); - SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_asoc), stcb); - SCTP_INP_WUNLOCK(inp); - SCTP_INP_INFO_WUNLOCK(); - SCTP_DECR_ASOC_COUNT(); - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL); - *error = EINVAL; - return (NULL); - } SCTP_TCB_LOCK(stcb); asoc->assoc_id = sctp_aloc_a_assoc_id(inp, stcb); @@ -5135,9 +5094,8 @@ sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockaddr *firstaddr, head = &SCTP_BASE_INFO(sctp_asochash)[SCTP_PCBHASH_ASOC(stcb->asoc.my_vtag, SCTP_BASE_INFO(hashasocmark))]; /* put it in the bucket in the vtag hash of assoc's for the system */ LIST_INSERT_HEAD(head, stcb, sctp_asocs); - SCTP_INP_INFO_WUNLOCK(); - if ((err = sctp_add_remote_addr(stcb, firstaddr, NULL, port, SCTP_DO_SETSCOPE, SCTP_ALLOC_ASOC))) { + if (sctp_add_remote_addr(stcb, firstaddr, NULL, port, SCTP_DO_SETSCOPE, SCTP_ALLOC_ASOC)) { /* failure.. memory error? */ if (asoc->strmout) { SCTP_FREE(asoc->strmout, SCTP_M_STRMO); @@ -5155,6 +5113,7 @@ sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockaddr *firstaddr, SCTP_TCB_UNLOCK(stcb); SCTP_TCB_LOCK_DESTROY(stcb); SCTP_TCB_SEND_LOCK_DESTROY(stcb); + LIST_REMOVE(stcb, sctp_asocs); LIST_REMOVE(stcb, sctp_tcbasocidhash); SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_asoc), stcb); SCTP_INP_WUNLOCK(inp); @@ -5168,7 +5127,6 @@ sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockaddr *firstaddr, SCTP_OS_TIMER_INIT(&asoc->asconf_timer.timer); SCTP_OS_TIMER_INIT(&asoc->shut_guard_timer.timer); SCTP_OS_TIMER_INIT(&asoc->autoclose_timer.timer); - SCTP_OS_TIMER_INIT(&asoc->delayed_event_timer.timer); SCTP_OS_TIMER_INIT(&asoc->delete_prim_timer.timer); LIST_INSERT_HEAD(&inp->sctp_asoc_list, stcb, sctp_tcblist); @@ -5181,17 +5139,76 @@ sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockaddr *firstaddr, if (initialize_auth_params == SCTP_INITIALIZE_AUTH_PARAMS) { sctp_initialize_auth_params(inp, stcb); } - SCTP_INP_WUNLOCK(inp); SCTPDBG(SCTP_DEBUG_PCB1, "Association %p now allocated\n", (void *)stcb); return (stcb); } +struct sctp_tcb * +sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockaddr *firstaddr, + int *error, uint32_t override_tag, uint32_t initial_tsn, + uint32_t vrf_id, uint16_t o_streams, uint16_t port, +#if defined(__FreeBSD__) && !defined(__Userspace__) + struct thread *p, +#elif defined(_WIN32) && !defined(__Userspace__) + PKTHREAD p, +#else + struct proc *p, +#endif + int initialize_auth_params) +{ + struct sctp_tcb *stcb; + + SCTP_INP_INFO_WLOCK(); + SCTP_INP_WLOCK(inp); + stcb = sctp_aloc_assoc_locked(inp, firstaddr, error, override_tag, + initial_tsn, vrf_id, o_streams, port, p, initialize_auth_params); + SCTP_INP_INFO_WUNLOCK(); + SCTP_INP_WUNLOCK(inp); + return (stcb); +} + +struct sctp_tcb * +sctp_aloc_assoc_connected(struct sctp_inpcb *inp, struct sockaddr *firstaddr, + int *error, uint32_t override_tag, uint32_t initial_tsn, + uint32_t vrf_id, uint16_t o_streams, uint16_t port, +#if defined(__FreeBSD__) && !defined(__Userspace__) + struct thread *p, +#elif defined(_WIN32) && !defined(__Userspace__) + PKTHREAD p, +#else + struct proc *p, +#endif + int initialize_auth_params) +{ + struct sctp_tcb *stcb; + + SCTP_INP_INFO_WLOCK(); + SCTP_INP_WLOCK(inp); + if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) && + SCTP_IS_LISTENING(inp)) { + SCTP_INP_INFO_WUNLOCK(); + SCTP_INP_WUNLOCK(inp); + *error = EINVAL; + return (NULL); + } + stcb = sctp_aloc_assoc_locked(inp, firstaddr, error, override_tag, + initial_tsn, vrf_id, o_streams, port, p, initialize_auth_params); + SCTP_INP_INFO_WUNLOCK(); + if (stcb != NULL && (inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE)) { + inp->sctp_flags |= SCTP_PCB_FLAGS_CONNECTED; + soisconnecting(inp->sctp_socket); + } + SCTP_INP_WUNLOCK(inp); + return (stcb); +} void sctp_remove_net(struct sctp_tcb *stcb, struct sctp_nets *net) { + struct sctp_inpcb *inp; struct sctp_association *asoc; + inp = stcb->sctp_ep; asoc = &stcb->asoc; asoc->numnets--; TAILQ_REMOVE(&asoc->nets, net, sctp_next); @@ -5235,10 +5252,19 @@ out: /* Clear net */ asoc->last_control_chunk_from = NULL; } + if (net == asoc->last_net_cmt_send_started) { + /* Clear net */ + asoc->last_net_cmt_send_started = NULL; + } if (net == stcb->asoc.alternate) { sctp_free_remote_addr(stcb->asoc.alternate); stcb->asoc.alternate = NULL; } + sctp_timer_stop(SCTP_TIMER_TYPE_PATHMTURAISE, inp, stcb, net, + SCTP_FROM_SCTP_PCB + SCTP_LOC_9); + sctp_timer_stop(SCTP_TIMER_TYPE_HEARTBEAT, inp, stcb, net, + SCTP_FROM_SCTP_PCB + SCTP_LOC_10); + net->dest_state |= SCTP_ADDR_BEING_DELETED; sctp_free_remote_addr(net); } @@ -5282,100 +5308,70 @@ sctp_del_remote_addr(struct sctp_tcb *stcb, struct sockaddr *remaddr) return (-2); } -void -sctp_delete_from_timewait(uint32_t tag, uint16_t lport, uint16_t rport) +static bool +sctp_is_in_timewait(uint32_t tag, uint16_t lport, uint16_t rport, uint32_t now) { struct sctpvtaghead *chain; struct sctp_tagblock *twait_block; - int found = 0; int i; + SCTP_INP_INFO_LOCK_ASSERT(); chain = &SCTP_BASE_INFO(vtag_timewait)[(tag % SCTP_STACK_VTAG_HASH_SIZE)]; LIST_FOREACH(twait_block, chain, sctp_nxt_tagblock) { for (i = 0; i < SCTP_NUMBER_IN_VTAG_BLOCK; i++) { - if ((twait_block->vtag_block[i].v_tag == tag) && - (twait_block->vtag_block[i].lport == lport) && - (twait_block->vtag_block[i].rport == rport)) { - twait_block->vtag_block[i].tv_sec_at_expire = 0; - twait_block->vtag_block[i].v_tag = 0; - twait_block->vtag_block[i].lport = 0; - twait_block->vtag_block[i].rport = 0; - found = 1; - break; - } - } - if (found) - break; - } -} - -int -sctp_is_in_timewait(uint32_t tag, uint16_t lport, uint16_t rport) -{ - struct sctpvtaghead *chain; - struct sctp_tagblock *twait_block; - int found = 0; - int i; - - SCTP_INP_INFO_WLOCK(); - chain = &SCTP_BASE_INFO(vtag_timewait)[(tag % SCTP_STACK_VTAG_HASH_SIZE)]; - LIST_FOREACH(twait_block, chain, sctp_nxt_tagblock) { - for (i = 0; i < SCTP_NUMBER_IN_VTAG_BLOCK; i++) { - if ((twait_block->vtag_block[i].v_tag == tag) && - (twait_block->vtag_block[i].lport == lport) && + if ((twait_block->vtag_block[i].tv_sec_at_expire >= now) && + (twait_block->vtag_block[i].v_tag == tag) && + (twait_block->vtag_block[i].lport == lport) && (twait_block->vtag_block[i].rport == rport)) { - found = 1; - break; + return (true); } } - if (found) - break; } - SCTP_INP_INFO_WUNLOCK(); - return (found); + return (false); } +static void +sctp_set_vtag_block(struct sctp_timewait *vtag_block, uint32_t time, + uint32_t tag, uint16_t lport, uint16_t rport) +{ + vtag_block->tv_sec_at_expire = time; + vtag_block->v_tag = tag; + vtag_block->lport = lport; + vtag_block->rport = rport; +} -void -sctp_add_vtag_to_timewait(uint32_t tag, uint32_t time, uint16_t lport, uint16_t rport) +static void +sctp_add_vtag_to_timewait(uint32_t tag, uint16_t lport, uint16_t rport) { struct sctpvtaghead *chain; struct sctp_tagblock *twait_block; struct timeval now; - int set, i; + uint32_t time; + int i; + bool set; - if (time == 0) { - /* Its disabled */ - return; - } + SCTP_INP_INFO_WLOCK_ASSERT(); (void)SCTP_GETTIME_TIMEVAL(&now); + time = (uint32_t)now.tv_sec + SCTP_BASE_SYSCTL(sctp_vtag_time_wait); chain = &SCTP_BASE_INFO(vtag_timewait)[(tag % SCTP_STACK_VTAG_HASH_SIZE)]; - set = 0; + set = false; LIST_FOREACH(twait_block, chain, sctp_nxt_tagblock) { /* Block(s) present, lets find space, and expire on the fly */ for (i = 0; i < SCTP_NUMBER_IN_VTAG_BLOCK; i++) { - if ((twait_block->vtag_block[i].v_tag == 0) && - !set) { - twait_block->vtag_block[i].tv_sec_at_expire = - now.tv_sec + time; - twait_block->vtag_block[i].v_tag = tag; - twait_block->vtag_block[i].lport = lport; - twait_block->vtag_block[i].rport = rport; - set = 1; - } else if ((twait_block->vtag_block[i].v_tag) && - ((long)twait_block->vtag_block[i].tv_sec_at_expire < now.tv_sec)) { - /* Audit expires this guy */ - twait_block->vtag_block[i].tv_sec_at_expire = 0; - twait_block->vtag_block[i].v_tag = 0; - twait_block->vtag_block[i].lport = 0; - twait_block->vtag_block[i].rport = 0; - if (set == 0) { - /* Reuse it for my new tag */ - twait_block->vtag_block[i].tv_sec_at_expire = now.tv_sec + time; - twait_block->vtag_block[i].v_tag = tag; - twait_block->vtag_block[i].lport = lport; - twait_block->vtag_block[i].rport = rport; - set = 1; + if ((twait_block->vtag_block[i].v_tag == 0) && !set) { + sctp_set_vtag_block(twait_block->vtag_block + i, time, tag, lport, rport); + set = true; + continue; + } + if ((twait_block->vtag_block[i].v_tag != 0) && + (twait_block->vtag_block[i].tv_sec_at_expire < (uint32_t)now.tv_sec)) { + if (set) { + /* Audit expires this guy */ + sctp_set_vtag_block(twait_block->vtag_block + i, 0, 0, 0, 0); + } else { + /* Reuse it for the new tag */ + sctp_set_vtag_block(twait_block->vtag_block + i, time, tag, lport, rport); + set = true; } } } @@ -5392,17 +5388,11 @@ sctp_add_vtag_to_timewait(uint32_t tag, uint32_t time, uint16_t lport, uint16_t SCTP_MALLOC(twait_block, struct sctp_tagblock *, sizeof(struct sctp_tagblock), SCTP_M_TIMW); if (twait_block == NULL) { -#ifdef INVARIANTS - panic("Can not alloc tagblock"); -#endif return; } memset(twait_block, 0, sizeof(struct sctp_tagblock)); LIST_INSERT_HEAD(chain, twait_block, sctp_nxt_tagblock); - twait_block->vtag_block[0].tv_sec_at_expire = now.tv_sec + time; - twait_block->vtag_block[0].v_tag = tag; - twait_block->vtag_block[0].lport = lport; - twait_block->vtag_block[0].rport = rport; + sctp_set_vtag_block(twait_block->vtag_block, time, tag, lport, rport); } } @@ -5447,10 +5437,6 @@ sctp_clean_up_stream(struct sctp_tcb *stcb, struct sctp_readhead *rh) } } -#ifdef __Panda__ -void panda_wakeup_socket(struct socket *so); -#endif - /*- * Free the association after un-hashing the remote port. This * function ALWAYS returns holding NO LOCK on the stcb. It DOES @@ -5476,7 +5462,7 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre struct socket *so; /* first, lets purge the entry from the hash table. */ -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) sctp_lock_assert(SCTP_INP_SO(inp)); #endif @@ -5490,17 +5476,18 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre /* there is no asoc, really TSNH :-0 */ return (1); } + SCTP_TCB_SEND_LOCK(stcb); if (stcb->asoc.alternate) { sctp_free_remote_addr(stcb->asoc.alternate); stcb->asoc.alternate = NULL; } -#if !defined(__APPLE__) /* TEMP: moved to below */ - /* TEMP CODE */ +#if !(defined(__APPLE__) && !defined(__Userspace__)) + /* TEMP CODE */ if (stcb->freed_from_where == 0) { /* Only record the first place free happened from */ stcb->freed_from_where = from_location; } - /* TEMP CODE */ + /* TEMP CODE */ #endif asoc = &stcb->asoc; @@ -5526,6 +5513,7 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre /* nope, reader or writer in the way */ sctp_timer_start(SCTP_TIMER_TYPE_ASOCKILL, inp, stcb, NULL); /* no asoc destroyed */ + SCTP_TCB_SEND_UNLOCK(stcb); SCTP_TCB_UNLOCK(stcb); #ifdef SCTP_LOG_CLOSING sctp_log_closing(inp, stcb, 8); @@ -5533,37 +5521,8 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre return (0); } } - /* now clean up any other timers */ - (void)SCTP_OS_TIMER_STOP(&asoc->dack_timer.timer); - asoc->dack_timer.self = NULL; - (void)SCTP_OS_TIMER_STOP(&asoc->strreset_timer.timer); - /*- - * For stream reset we don't blast this unless - * it is a str-reset timer, it might be the - * free-asoc timer which we DON'T want to - * disturb. - */ - if (asoc->strreset_timer.type == SCTP_TIMER_TYPE_STRRESET) - asoc->strreset_timer.self = NULL; - (void)SCTP_OS_TIMER_STOP(&asoc->asconf_timer.timer); - asoc->asconf_timer.self = NULL; - (void)SCTP_OS_TIMER_STOP(&asoc->autoclose_timer.timer); - asoc->autoclose_timer.self = NULL; - (void)SCTP_OS_TIMER_STOP(&asoc->shut_guard_timer.timer); - asoc->shut_guard_timer.self = NULL; - (void)SCTP_OS_TIMER_STOP(&asoc->delayed_event_timer.timer); - asoc->delayed_event_timer.self = NULL; - /* Mobility adaptation */ - (void)SCTP_OS_TIMER_STOP(&asoc->delete_prim_timer.timer); - asoc->delete_prim_timer.self = NULL; - TAILQ_FOREACH(net, &asoc->nets, sctp_next) { - (void)SCTP_OS_TIMER_STOP(&net->rxt_timer.timer); - net->rxt_timer.self = NULL; - (void)SCTP_OS_TIMER_STOP(&net->pmtu_timer.timer); - net->pmtu_timer.self = NULL; - (void)SCTP_OS_TIMER_STOP(&net->hb_timer.timer); - net->hb_timer.self = NULL; - } + /* Now clean up any other timers */ + sctp_stop_association_timers(stcb, false); /* Now the read queue needs to be cleaned up (only once) */ if ((stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) == 0) { SCTP_ADD_SUBSTATE(stcb, SCTP_STATE_ABOUT_TO_BE_FREED); @@ -5616,7 +5575,6 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre SCTP_CLEAR_SUBSTATE(stcb, SCTP_STATE_IN_ACCEPT_QUEUE); sctp_timer_start(SCTP_TIMER_TYPE_ASOCKILL, inp, stcb, NULL); } - SCTP_TCB_UNLOCK(stcb); if ((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) || (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE)) /* nothing around */ @@ -5626,6 +5584,8 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre sctp_sorwakeup(inp, so); sctp_sowwakeup(inp, so); } + SCTP_TCB_SEND_UNLOCK(stcb); + SCTP_TCB_UNLOCK(stcb); #ifdef SCTP_LOG_CLOSING sctp_log_closing(inp, stcb, 9); @@ -5654,10 +5614,12 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre if (from_inpcbfree == SCTP_NORMAL_PROC) { atomic_add_int(&stcb->asoc.refcnt, 1); + SCTP_TCB_SEND_UNLOCK(stcb); SCTP_TCB_UNLOCK(stcb); SCTP_INP_INFO_WLOCK(); SCTP_INP_WLOCK(inp); SCTP_TCB_LOCK(stcb); + SCTP_TCB_SEND_LOCK(stcb); } /* Double check the GONE flag */ if ((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) || @@ -5681,7 +5643,7 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre SS_ISCONFIRMING | SS_ISCONNECTED); so->so_state |= SS_ISDISCONNECTED; -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) socantrcvmore(so); #else socantrcvmore_locked(so); @@ -5699,7 +5661,7 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre */ /* re-increment the lock */ if (from_inpcbfree == SCTP_NORMAL_PROC) { - atomic_add_int(&stcb->asoc.refcnt, -1); + atomic_subtract_int(&stcb->asoc.refcnt, 1); } if (stcb->asoc.refcnt) { SCTP_CLEAR_SUBSTATE(stcb, SCTP_STATE_IN_ACCEPT_QUEUE); @@ -5708,6 +5670,7 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre SCTP_INP_INFO_WUNLOCK(); SCTP_INP_WUNLOCK(inp); } + SCTP_TCB_SEND_UNLOCK(stcb); SCTP_TCB_UNLOCK(stcb); return (0); } @@ -5718,6 +5681,9 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre if (stcb->asoc.in_asocid_hash) { LIST_REMOVE(stcb, sctp_tcbasocidhash); } + if (inp->sctp_socket == NULL) { + stcb->sctp_socket = NULL; + } /* Now lets remove it from the list of ALL associations in the EP */ LIST_REMOVE(stcb, sctp_tcblist); if (from_inpcbfree == SCTP_NORMAL_PROC) { @@ -5726,32 +5692,18 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre } /* pull from vtag hash */ LIST_REMOVE(stcb, sctp_asocs); - sctp_add_vtag_to_timewait(asoc->my_vtag, SCTP_BASE_SYSCTL(sctp_vtag_time_wait), - inp->sctp_lport, stcb->rport); + sctp_add_vtag_to_timewait(asoc->my_vtag, inp->sctp_lport, stcb->rport); /* Now restop the timers to be sure * this is paranoia at is finest! */ - (void)SCTP_OS_TIMER_STOP(&asoc->strreset_timer.timer); - (void)SCTP_OS_TIMER_STOP(&asoc->dack_timer.timer); - (void)SCTP_OS_TIMER_STOP(&asoc->strreset_timer.timer); - (void)SCTP_OS_TIMER_STOP(&asoc->asconf_timer.timer); - (void)SCTP_OS_TIMER_STOP(&asoc->shut_guard_timer.timer); - (void)SCTP_OS_TIMER_STOP(&asoc->autoclose_timer.timer); - (void)SCTP_OS_TIMER_STOP(&asoc->delayed_event_timer.timer); - TAILQ_FOREACH(net, &asoc->nets, sctp_next) { - (void)SCTP_OS_TIMER_STOP(&net->rxt_timer.timer); - (void)SCTP_OS_TIMER_STOP(&net->pmtu_timer.timer); - (void)SCTP_OS_TIMER_STOP(&net->hb_timer.timer); - } + sctp_stop_association_timers(stcb, true); - asoc->strreset_timer.type = SCTP_TIMER_TYPE_NONE; /* * The chunk lists and such SHOULD be empty but we check them just * in case. */ /* anything on the wheel needs to be removed */ - SCTP_TCB_SEND_LOCK(stcb); for (i = 0; i < asoc->streamoutcnt; i++) { struct sctp_stream_out *outs; @@ -5760,7 +5712,7 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre TAILQ_FOREACH_SAFE(sp, &outs->outqueue, next, nsp) { atomic_subtract_int(&asoc->stream_queue_cnt, 1); TAILQ_REMOVE(&outs->outqueue, sp, next); - stcb->asoc.ss_functions.sctp_ss_remove_from_stream(stcb, asoc, outs, sp, 1); + stcb->asoc.ss_functions.sctp_ss_remove_from_stream(stcb, asoc, outs, sp); sctp_free_spbufspace(stcb, asoc, sp); if (sp->data) { if (so) { @@ -5782,7 +5734,6 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre sctp_free_a_strmoq(stcb, sp, SCTP_SO_LOCKED); } } - SCTP_TCB_SEND_UNLOCK(stcb); /*sa_ignore FREED_MEMORY*/ TAILQ_FOREACH_SAFE(strrst, &asoc->resetHead, next_resp, nstrrst) { TAILQ_REMOVE(&asoc->resetHead, strrst, next_resp); @@ -5984,6 +5935,7 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre /* Insert new items here :> */ /* Get rid of LOCK */ + SCTP_TCB_SEND_UNLOCK(stcb); SCTP_TCB_UNLOCK(stcb); SCTP_TCB_LOCK_DESTROY(stcb); SCTP_TCB_SEND_LOCK_DESTROY(stcb); @@ -5991,7 +5943,8 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre SCTP_INP_INFO_WUNLOCK(); SCTP_INP_RLOCK(inp); } -#if defined(__APPLE__) /* TEMP CODE */ +#if defined(__APPLE__) && !defined(__Userspace__) + /* TEMP CODE */ stcb->freed_from_where = from_location; #endif #ifdef SCTP_TRACK_FREED_ASOCS @@ -6024,16 +5977,12 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre SCTP_FREE_SHOULD_USE_GRACEFUL_CLOSE, SCTP_CALLED_DIRECTLY_NOCMPSET); SCTP_INP_DECR_REF(inp); - goto out_of; } else { /* The socket is still open. */ SCTP_INP_DECR_REF(inp); + SCTP_INP_RUNLOCK(inp); } } - if (from_inpcbfree == SCTP_NORMAL_PROC) { - SCTP_INP_RUNLOCK(inp); - } - out_of: /* destroyed the asoc */ #ifdef SCTP_LOG_CLOSING sctp_log_closing(inp, NULL, 11); @@ -6041,8 +5990,6 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre return (1); } - - /* * determine if a destination is "reachable" based upon the addresses bound * to the current endpoint (e.g. only v4 or v6 currently bound) @@ -6082,20 +6029,12 @@ sctp_destination_is_reachable(struct sctp_tcb *stcb, struct sockaddr *destaddr) switch (destaddr->sa_family) { #ifdef INET6 case AF_INET6: -#if !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) || defined(__Userspace__)) - answer = inp->inp_vflag & INP_IPV6; -#else answer = inp->ip_inp.inp.inp_vflag & INP_IPV6; -#endif break; #endif #ifdef INET case AF_INET: -#if !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) || defined(__Userspace__)) - answer = inp->inp_vflag & INP_IPV4; -#else answer = inp->ip_inp.inp.inp_vflag & INP_IPV4; -#endif break; #endif #if defined(__Userspace__) @@ -6120,11 +6059,7 @@ sctp_update_ep_vflag(struct sctp_inpcb *inp) struct sctp_laddr *laddr; /* first clear the flag */ -#if !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) || defined(__Userspace__)) - inp->inp_vflag = 0; -#else inp->ip_inp.inp.inp_vflag = 0; -#endif /* set the flag based on addresses on the ep list */ LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) { if (laddr->ifa == NULL) { @@ -6139,20 +6074,12 @@ sctp_update_ep_vflag(struct sctp_inpcb *inp) switch (laddr->ifa->address.sa.sa_family) { #ifdef INET6 case AF_INET6: -#if !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) || defined(__Userspace__)) - inp->inp_vflag |= INP_IPV6; -#else inp->ip_inp.inp.inp_vflag |= INP_IPV6; -#endif break; #endif #ifdef INET case AF_INET: -#if !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) || defined(__Userspace__)) - inp->inp_vflag |= INP_IPV4; -#else inp->ip_inp.inp.inp_vflag |= INP_IPV4; -#endif break; #endif #if defined(__Userspace__) @@ -6209,20 +6136,12 @@ sctp_add_local_addr_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa, uint32_t ac switch (ifa->address.sa.sa_family) { #ifdef INET6 case AF_INET6: -#if !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) || defined(__Userspace__)) - inp->inp_vflag |= INP_IPV6; -#else inp->ip_inp.inp.inp_vflag |= INP_IPV6; -#endif break; #endif #ifdef INET case AF_INET: -#if !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) || defined(__Userspace__)) - inp->inp_vflag |= INP_IPV4; -#else inp->ip_inp.inp.inp_vflag |= INP_IPV4; -#endif break; #endif #if defined(__Userspace__) @@ -6240,7 +6159,6 @@ sctp_add_local_addr_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa, uint32_t ac return; } - /* * select a new (hopefully reachable) destination net (should only be used * when we deleted an ep addr that is the only usable source address to reach @@ -6264,7 +6182,6 @@ sctp_select_primary_destination(struct sctp_tcb *stcb) /* I can't there from here! ...we're gonna die shortly... */ } - /* * Delete the address from the endpoint local address list. There is nothing * to be done if we are bound to all addresses @@ -6316,6 +6233,9 @@ sctp_del_local_addr_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa) TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { if (net->ro._s_addr == laddr->ifa) { /* Yep, purge src address selected */ +#if defined(__FreeBSD__) && !defined(__Userspace__) + RO_NHFREE(&net->ro); +#else sctp_rtentry_t *rt; /* delete this address if cached */ @@ -6324,6 +6244,7 @@ sctp_del_local_addr_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa) RTFREE(rt); net->ro.ro_rt = NULL; } +#endif sctp_free_ifa(net->ro._s_addr); net->ro._s_addr = NULL; net->src_addr_selected = 0; @@ -6419,20 +6340,17 @@ sctp_del_local_addr_restricted(struct sctp_tcb *stcb, struct sctp_ifa *ifa) return; } -#if defined(__FreeBSD__) -/* - * Temporarily remove for __APPLE__ until we use the Tiger equivalents - */ +#if defined(__FreeBSD__) && !defined(__Userspace__) /* sysctl */ static int sctp_max_number_of_assoc = SCTP_MAX_NUM_OF_ASOC; static int sctp_scale_up_for_address = SCTP_SCALE_FOR_ADDR; -#endif /* FreeBSD || APPLE */ +#endif - - -#if defined(__FreeBSD__) && defined(SCTP_MCORE_INPUT) && defined(SMP) +#if defined(__FreeBSD__) && !defined(__Userspace__) +#if defined(SCTP_MCORE_INPUT) && defined(SMP) struct sctp_mcore_ctrl *sctp_mcore_workers = NULL; int *sctp_cpuarry = NULL; + void sctp_queue_to_mcore(struct mbuf *m, int off, int cpu_to_use) { @@ -6440,6 +6358,7 @@ sctp_queue_to_mcore(struct mbuf *m, int off, int cpu_to_use) struct sctp_mcore_queue *qent; struct sctp_mcore_ctrl *wkq; int need_wake = 0; + if (sctp_mcore_workers == NULL) { /* Something went way bad during setup */ sctp_input_with_port(m, off, 0); @@ -6453,9 +6372,7 @@ sctp_queue_to_mcore(struct mbuf *m, int off, int cpu_to_use) sctp_input_with_port(m, off, 0); return; } -#if defined(__FreeBSD__) && __FreeBSD_version >= 801000 qent->vn = curvnet; -#endif qent->m = m; qent->off = off; qent->v6 = 0; @@ -6507,9 +6424,7 @@ sctp_mcore_thread(void *arg) if (qent) { TAILQ_REMOVE(&wkq->que, qent, next); SCTP_MCORE_QUNLOCK(wkq); -#if defined(__FreeBSD__) && __FreeBSD_version >= 801000 CURVNET_SET(qent->vn); -#endif m = qent->m; off = qent->off; v6 = qent->v6; @@ -6520,9 +6435,7 @@ sctp_mcore_thread(void *arg) SCTP_PRINTF("V6 not yet supported\n"); sctp_m_freem(m); } -#if defined(__FreeBSD__) && __FreeBSD_version >= 801000 CURVNET_RESTORE(); -#endif SCTP_MCORE_QLOCK(wkq); } wkq->running = 0; @@ -6576,30 +6489,21 @@ sctp_startup_mcore_threads(void) i++; } } - /* Now start them all */ CPU_FOREACH(cpu) { -#if __FreeBSD_version <= 701000 - (void)kthread_create(sctp_mcore_thread, - (void *)&sctp_mcore_workers[cpu], - &sctp_mcore_workers[cpu].thread_proc, - RFPROC, - SCTP_KTHREAD_PAGES, - SCTP_MCORE_NAME); - -#else (void)kproc_create(sctp_mcore_thread, (void *)&sctp_mcore_workers[cpu], &sctp_mcore_workers[cpu].thread_proc, - RFPROC, + 0, SCTP_KTHREAD_PAGES, SCTP_MCORE_NAME); -#endif - } } #endif -#if defined(__FreeBSD__) && __FreeBSD_cc_version >= 1400000 +#endif + +#if defined(__FreeBSD__) && !defined(__Userspace__) +#if defined(SCTP_NOT_YET) static struct mbuf * sctp_netisr_hdlr(struct mbuf *m, uintptr_t source) { @@ -6625,12 +6529,13 @@ sctp_netisr_hdlr(struct mbuf *m, uintptr_t source) tag = htonl(sh->v_tag); flowid = tag ^ ntohs(sh->dest_port) ^ ntohs(sh->src_port); m->m_pkthdr.flowid = flowid; -/* FIX ME */ + /* FIX ME */ m->m_flags |= M_FLOWID; return (m); } -#endif +#endif +#endif void #if defined(__Userspace__) sctp_pcb_init(int start_threads) @@ -6652,15 +6557,16 @@ sctp_pcb_init(void) SCTP_BASE_VAR(sctp_pcb_initialized) = 1; #if defined(SCTP_PROCESS_LEVEL_LOCKS) -#if !defined(__Userspace_os_Windows) +#if !defined(_WIN32) pthread_mutexattr_init(&SCTP_BASE_VAR(mtx_attr)); + pthread_rwlockattr_init(&SCTP_BASE_VAR(rwlock_attr)); #ifdef INVARIANTS pthread_mutexattr_settype(&SCTP_BASE_VAR(mtx_attr), PTHREAD_MUTEX_ERRORCHECK); #endif #endif #endif #if defined(SCTP_LOCAL_TRACE_BUF) -#if defined(__Windows__) +#if defined(_WIN32) && !defined(__Userspace__) if (SCTP_BASE_SYSCTL(sctp_log) != NULL) { memset(SCTP_BASE_SYSCTL(sctp_log), 0, sizeof(struct sctp_log)); } @@ -6668,16 +6574,24 @@ sctp_pcb_init(void) memset(&SCTP_BASE_SYSCTL(sctp_log), 0, sizeof(struct sctp_log)); #endif #endif -#if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT) +#if defined(__FreeBSD__) && !defined(__Userspace__) +#if defined(SMP) && defined(SCTP_USE_PERCPU_STAT) SCTP_MALLOC(SCTP_BASE_STATS, struct sctpstat *, ((mp_maxid+1) * sizeof(struct sctpstat)), SCTP_M_MCORE); +#endif #endif (void)SCTP_GETTIME_TIMEVAL(&tv); -#if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT) +#if defined(__FreeBSD__) && !defined(__Userspace__) +#if defined(SMP) && defined(SCTP_USE_PERCPU_STAT) memset(SCTP_BASE_STATS, 0, sizeof(struct sctpstat) * (mp_maxid+1)); SCTP_BASE_STATS[PCPU_GET(cpuid)].sctps_discontinuitytime.tv_sec = (uint32_t)tv.tv_sec; SCTP_BASE_STATS[PCPU_GET(cpuid)].sctps_discontinuitytime.tv_usec = (uint32_t)tv.tv_usec; +#else + memset(&SCTP_BASE_STATS, 0, sizeof(struct sctpstat)); + SCTP_BASE_STAT(sctps_discontinuitytime).tv_sec = (uint32_t)tv.tv_sec; + SCTP_BASE_STAT(sctps_discontinuitytime).tv_usec = (uint32_t)tv.tv_usec; +#endif #else memset(&SCTP_BASE_STATS, 0, sizeof(struct sctpstat)); SCTP_BASE_STAT(sctps_discontinuitytime).tv_sec = (uint32_t)tv.tv_sec; @@ -6685,7 +6599,7 @@ sctp_pcb_init(void) #endif /* init the empty list of (All) Endpoints */ LIST_INIT(&SCTP_BASE_INFO(listhead)); -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) LIST_INIT(&SCTP_BASE_INFO(inplisthead)); #if defined(APPLE_LEOPARD) || defined(APPLE_SNOWLEOPARD) || defined(APPLE_LION) || defined(APPLE_MOUNTAINLION) SCTP_BASE_INFO(sctbinfo).listhead = &SCTP_BASE_INFO(inplisthead); @@ -6708,21 +6622,11 @@ sctp_pcb_init(void) #endif #endif - /* init the hash table of endpoints */ -#if defined(__FreeBSD__) -#if defined(__FreeBSD_cc_version) && __FreeBSD_cc_version >= 440000 +#if defined(__FreeBSD__) && !defined(__Userspace__) TUNABLE_INT_FETCH("net.inet.sctp.tcbhashsize", &SCTP_BASE_SYSCTL(sctp_hashtblsize)); TUNABLE_INT_FETCH("net.inet.sctp.pcbhashsize", &SCTP_BASE_SYSCTL(sctp_pcbtblsize)); TUNABLE_INT_FETCH("net.inet.sctp.chunkscale", &SCTP_BASE_SYSCTL(sctp_chunkscale)); -#else - TUNABLE_INT_FETCH("net.inet.sctp.tcbhashsize", SCTP_TCBHASHSIZE, - SCTP_BASE_SYSCTL(sctp_hashtblsize)); - TUNABLE_INT_FETCH("net.inet.sctp.pcbhashsize", SCTP_PCBHASHSIZE, - SCTP_BASE_SYSCTL(sctp_pcbtblsize)); - TUNABLE_INT_FETCH("net.inet.sctp.chunkscale", SCTP_CHUNKQUEUE_SCALE, - SCTP_BASE_SYSCTL(sctp_chunkscale)); -#endif #endif SCTP_BASE_INFO(sctp_asochash) = SCTP_HASH_INIT((SCTP_BASE_SYSCTL(sctp_hashtblsize) * 31), &SCTP_BASE_INFO(hashasocmark)); @@ -6731,8 +6635,6 @@ sctp_pcb_init(void) SCTP_BASE_INFO(sctp_tcpephash) = SCTP_HASH_INIT(SCTP_BASE_SYSCTL(sctp_hashtblsize), &SCTP_BASE_INFO(hashtcpmark)); SCTP_BASE_INFO(hashtblsize) = SCTP_BASE_SYSCTL(sctp_hashtblsize); - - SCTP_BASE_INFO(sctp_vrfhash) = SCTP_HASH_INIT(SCTP_SIZE_OF_VRF_HASH, &SCTP_BASE_INFO(hashvrfmark)); @@ -6777,7 +6679,6 @@ sctp_pcb_init(void) sizeof(struct sctp_asconf_ack), (sctp_max_number_of_assoc * SCTP_BASE_SYSCTL(sctp_chunkscale))); - /* Master Lock INIT for info structure */ SCTP_INP_INFO_LOCK_INIT(); SCTP_STATLOG_INIT_LOCK(); @@ -6817,7 +6718,7 @@ sctp_pcb_init(void) LIST_INIT(&SCTP_BASE_INFO(vtag_timewait)[i]); } #if defined(SCTP_PROCESS_LEVEL_LOCKS) -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) InitializeConditionVariable(&sctp_it_ctl.iterator_wakeup); #else (void)pthread_cond_init(&sctp_it_ctl.iterator_wakeup, NULL); @@ -6825,19 +6726,19 @@ sctp_pcb_init(void) #endif sctp_startup_iterator(); -#if defined(__FreeBSD__) && defined(SCTP_MCORE_INPUT) && defined(SMP) +#if defined(__FreeBSD__) && !defined(__Userspace__) +#if defined(SCTP_MCORE_INPUT) && defined(SMP) sctp_startup_mcore_threads(); +#endif #endif -#ifndef __Panda__ /* * INIT the default VRF which for BSD is the only one, other O/S's * may have more. But initially they must start with one and then * add the VRF's as addresses are added. */ sctp_init_vrf_list(SCTP_DEFAULT_VRF); -#endif -#if defined(__FreeBSD__) && __FreeBSD_cc_version >= 1400000 +#if defined(__FreeBSD__) && !defined(__Userspace__) && defined(SCTP_NOT_YET) if (ip_register_flow_handler(sctp_netisr_hdlr, IPPROTO_SCTP)) { SCTP_PRINTF("***SCTP- Error can't register netisr handler***\n"); } @@ -6878,14 +6779,14 @@ sctp_pcb_finish(void) return; } SCTP_BASE_VAR(sctp_pcb_initialized) = 0; -#if !defined(__FreeBSD__) +#if !(defined(__FreeBSD__) && !defined(__Userspace__)) /* Notify the iterator to exit. */ SCTP_IPI_ITERATOR_WQ_LOCK(); sctp_it_ctl.iterator_flags |= SCTP_ITERATOR_MUST_EXIT; sctp_wakeup_iterator(); SCTP_IPI_ITERATOR_WQ_UNLOCK(); #endif -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #if !defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) && !defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION) in_pcbinfo_detach(&SCTP_BASE_INFO(sctbinfo)); #endif @@ -6898,7 +6799,7 @@ sctp_pcb_finish(void) thread_deallocate(sctp_it_ctl.thread_proc); SCTP_IPI_ITERATOR_WQ_UNLOCK(); #endif -#if defined(__Windows__) +#if defined(_WIN32) && !defined(__Userspace__) if (sctp_it_ctl.iterator_thread_obj != NULL) { NTSTATUS status = STATUS_SUCCESS; @@ -6912,8 +6813,8 @@ sctp_pcb_finish(void) } #endif #if defined(__Userspace__) - if (sctp_it_ctl.thread_proc) { -#if defined(__Userspace_os_Windows) + if (SCTP_BASE_VAR(iterator_thread_started)) { +#if defined(_WIN32) WaitForSingleObject(sctp_it_ctl.thread_proc, INFINITE); CloseHandle(sctp_it_ctl.thread_proc); sctp_it_ctl.thread_proc = NULL; @@ -6924,11 +6825,12 @@ sctp_pcb_finish(void) } #endif #if defined(SCTP_PROCESS_LEVEL_LOCKS) -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) DeleteConditionVariable(&sctp_it_ctl.iterator_wakeup); #else pthread_cond_destroy(&sctp_it_ctl.iterator_wakeup); pthread_mutexattr_destroy(&SCTP_BASE_VAR(mtx_attr)); + pthread_rwlockattr_destroy(&SCTP_BASE_VAR(rwlock_attr)); #endif #endif /* In FreeBSD the iterator thread never exits @@ -6936,17 +6838,17 @@ sctp_pcb_finish(void) * The only way FreeBSD reaches here is if we have VRF's * but we still add the ifdef to make it compile on old versions. */ -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) retry: #endif SCTP_IPI_ITERATOR_WQ_LOCK(); -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) /* * sctp_iterator_worker() might be working on an it entry without * holding the lock. We won't find it on the list either and * continue and free/destroy it. While holding the lock, spin, to * avoid the race condition as sctp_iterator_worker() will have to - * wait to re-aquire the lock. + * wait to re-acquire the lock. */ if (sctp_it_ctl.iterator_running != 0 || sctp_it_ctl.cur_it != NULL) { SCTP_IPI_ITERATOR_WQ_UNLOCK(); @@ -6957,7 +6859,7 @@ retry: } #endif TAILQ_FOREACH_SAFE(it, &sctp_it_ctl.iteratorhead, sctp_nxt_itr, nit) { -#if defined(__FreeBSD__) && __FreeBSD_version >= 801000 +#if defined(__FreeBSD__) && !defined(__Userspace__) if (it->vn != curvnet) { continue; } @@ -6969,7 +6871,7 @@ retry: SCTP_FREE(it,SCTP_M_ITER); } SCTP_IPI_ITERATOR_WQ_UNLOCK(); -#if defined(__FreeBSD__) && __FreeBSD_version >= 801000 +#if defined(__FreeBSD__) && !defined(__Userspace__) SCTP_ITERATOR_LOCK(); if ((sctp_it_ctl.cur_it) && (sctp_it_ctl.cur_it->vn == curvnet)) { @@ -6977,7 +6879,7 @@ retry: } SCTP_ITERATOR_UNLOCK(); #endif -#if !defined(__FreeBSD__) +#if !(defined(__FreeBSD__) && !defined(__Userspace__)) SCTP_IPI_ITERATOR_WQ_DESTROY(); SCTP_ITERATOR_LOCK_DESTROY(); #endif @@ -6997,6 +6899,7 @@ retry: * free the vrf/ifn/ifa lists and hashes (be sure address monitor * is destroyed first). */ + SCTP_IPI_ADDR_WLOCK(); vrf_bucket = &SCTP_BASE_INFO(sctp_vrfhash)[(SCTP_DEFAULT_VRFID & SCTP_BASE_INFO(hashvrfmark))]; LIST_FOREACH_SAFE(vrf, vrf_bucket, next_vrf, nvrf) { LIST_FOREACH_SAFE(ifn, &vrf->ifnlist, next_ifn, nifn) { @@ -7016,6 +6919,7 @@ retry: LIST_REMOVE(vrf, next_vrf); SCTP_FREE(vrf, SCTP_M_VRF); } + SCTP_IPI_ADDR_WUNLOCK(); /* free the vrf hashes */ SCTP_HASH_FREE(SCTP_BASE_INFO(sctp_vrfhash), SCTP_BASE_INFO(hashvrfmark)); SCTP_HASH_FREE(SCTP_BASE_INFO(vrf_ifn_hash), SCTP_BASE_INFO(vrf_ifn_hashmark)); @@ -7038,14 +6942,14 @@ retry: } /* free the locks and mutexes */ -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_TIMERQ_LOCK_DESTROY(); #endif #ifdef SCTP_PACKET_LOGGING SCTP_IP_PKTLOG_DESTROY(); #endif SCTP_IPI_ADDR_DESTROY(); -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_IPI_COUNT_DESTROY(); #endif SCTP_STATLOG_DESTROY(); @@ -7053,7 +6957,7 @@ retry: SCTP_WQ_ADDR_DESTROY(); -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #if defined(APPLE_LEOPARD) || defined(APPLE_SNOWLEOPARD) || defined(APPLE_LION) || defined(APPLE_MOUNTAINLION) lck_grp_attr_free(SCTP_BASE_INFO(sctbinfo).mtx_grp_attr); lck_grp_free(SCTP_BASE_INFO(sctbinfo).mtx_grp); @@ -7078,7 +6982,7 @@ retry: if (SCTP_BASE_INFO(sctp_tcpephash) != NULL) SCTP_HASH_FREE(SCTP_BASE_INFO(sctp_tcpephash), SCTP_BASE_INFO(hashtcpmark)); -#if defined(__Windows__) || defined(__FreeBSD__) || defined(__Userspace__) +#if defined(_WIN32) || defined(__FreeBSD__) || defined(__Userspace__) SCTP_ZONE_DESTROY(SCTP_BASE_INFO(ipi_zone_ep)); SCTP_ZONE_DESTROY(SCTP_BASE_INFO(ipi_zone_asoc)); SCTP_ZONE_DESTROY(SCTP_BASE_INFO(ipi_zone_laddr)); @@ -7089,12 +6993,13 @@ retry: SCTP_ZONE_DESTROY(SCTP_BASE_INFO(ipi_zone_asconf)); SCTP_ZONE_DESTROY(SCTP_BASE_INFO(ipi_zone_asconf_ack)); #endif -#if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT) +#if defined(__FreeBSD__) && !defined(__Userspace__) +#if defined(SMP) && defined(SCTP_USE_PERCPU_STAT) SCTP_FREE(SCTP_BASE_STATS, SCTP_M_MCORE); #endif +#endif } - int sctp_load_addresses_from_init(struct sctp_tcb *stcb, struct mbuf *m, int offset, int limit, @@ -7171,6 +7076,7 @@ sctp_load_addresses_from_init(struct sctp_tcb *stcb, struct mbuf *m, peer_supports_prsctp = 0; peer_supports_auth = 0; peer_supports_asconf = 0; + peer_supports_asconf_ack = 0; peer_supports_reconfig = 0; peer_supports_nrsack = 0; peer_supports_pktdrop = 0; @@ -7182,7 +7088,7 @@ sctp_load_addresses_from_init(struct sctp_tcb *stcb, struct mbuf *m, inp = stcb->sctp_ep; atomic_add_int(&stcb->asoc.refcnt, 1); stcb_tmp = sctp_findassociation_ep_addr(&inp, sa, &net_tmp, dst, stcb); - atomic_add_int(&stcb->asoc.refcnt, -1); + atomic_subtract_int(&stcb->asoc.refcnt, 1); if ((stcb_tmp == NULL && inp == stcb->sctp_ep) || inp == NULL) { /* we must add the source address */ @@ -7275,7 +7181,7 @@ sctp_load_addresses_from_init(struct sctp_tcb *stcb, struct mbuf *m, atomic_add_int(&stcb->asoc.refcnt, 1); stcb_tmp = sctp_findassociation_ep_addr(&inp, sa, &net, dst, stcb); - atomic_add_int(&stcb->asoc.refcnt, -1); + atomic_subtract_int(&stcb->asoc.refcnt, 1); if ((stcb_tmp == NULL && inp == stcb->sctp_ep) || inp == NULL) { @@ -7318,12 +7224,12 @@ sctp_load_addresses_from_init(struct sctp_tcb *stcb, struct mbuf *m, char msg[SCTP_DIAG_INFO_LEN]; /* in setup state we abort this guy */ - snprintf(msg, sizeof(msg), - "%s:%d at %s", __FILE__, __LINE__, __func__); + SCTP_SNPRINTF(msg, sizeof(msg), + "%s:%d at %s", __FILE__, __LINE__, __func__); op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code), msg); sctp_abort_an_association(stcb_tmp->sctp_ep, - stcb_tmp, op_err, + stcb_tmp, op_err, false, SCTP_SO_NOT_LOCKED); goto add_it_now; } @@ -7368,7 +7274,7 @@ sctp_load_addresses_from_init(struct sctp_tcb *stcb, struct mbuf *m, atomic_add_int(&stcb->asoc.refcnt, 1); stcb_tmp = sctp_findassociation_ep_addr(&inp, sa, &net, dst, stcb); - atomic_add_int(&stcb->asoc.refcnt, -1); + atomic_subtract_int(&stcb->asoc.refcnt, 1); if (stcb_tmp == NULL && (inp == stcb->sctp_ep || inp == NULL)) { /* @@ -7412,12 +7318,12 @@ sctp_load_addresses_from_init(struct sctp_tcb *stcb, struct mbuf *m, char msg[SCTP_DIAG_INFO_LEN]; /* in setup state we abort this guy */ - snprintf(msg, sizeof(msg), - "%s:%d at %s", __FILE__, __LINE__, __func__); + SCTP_SNPRINTF(msg, sizeof(msg), + "%s:%d at %s", __FILE__, __LINE__, __func__); op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code), msg); sctp_abort_an_association(stcb_tmp->sctp_ep, - stcb_tmp, op_err, + stcb_tmp, op_err, false, SCTP_SO_NOT_LOCKED); goto add_it_now6; } @@ -7557,7 +7463,6 @@ sctp_load_addresses_from_init(struct sctp_tcb *stcb, struct mbuf *m, default: /* one I have not learned yet */ break; - } } } else if (ptype == SCTP_RANDOM) { @@ -7640,7 +7545,6 @@ sctp_load_addresses_from_init(struct sctp_tcb *stcb, struct mbuf *m, saw_asconf = 1; if (chunks->chunk_types[i] == SCTP_ASCONF_ACK) saw_asconf_ack = 1; - } got_chklist = 1; } else if ((ptype == SCTP_HEARTBEAT_INFO) || @@ -7652,7 +7556,7 @@ sctp_load_addresses_from_init(struct sctp_tcb *stcb, struct mbuf *m, (ptype == SCTP_DEL_IP_ADDRESS) || (ptype == SCTP_ERROR_CAUSE_IND) || (ptype == SCTP_SUCCESS_REPORT)) { - /* don't care */ ; + /* don't care */ } else { if ((ptype & 0x8000) == 0x0000) { /* @@ -7672,7 +7576,7 @@ sctp_load_addresses_from_init(struct sctp_tcb *stcb, struct mbuf *m, break; } phdr = sctp_get_next_param(m, offset, ¶m_buf, - sizeof(param_buf)); + sizeof(param_buf)); } /* Now check to see if we need to purge any addresses */ TAILQ_FOREACH_SAFE(net, &stcb->asoc.nets, sctp_next, nnet) { @@ -7682,11 +7586,15 @@ sctp_load_addresses_from_init(struct sctp_tcb *stcb, struct mbuf *m, /* remove and free it */ stcb->asoc.numnets--; TAILQ_REMOVE(&stcb->asoc.nets, net, sctp_next); - sctp_free_remote_addr(net); + if (net == stcb->asoc.alternate) { + sctp_free_remote_addr(stcb->asoc.alternate); + stcb->asoc.alternate = NULL; + } if (net == stcb->asoc.primary_destination) { stcb->asoc.primary_destination = NULL; sctp_select_primary_destination(stcb); } + sctp_free_remote_addr(net); } } if ((stcb->asoc.ecn_supported == 1) && @@ -7812,24 +7720,15 @@ sctp_set_primary_addr(struct sctp_tcb *stcb, struct sockaddr *sa, } } -int +bool sctp_is_vtag_good(uint32_t tag, uint16_t lport, uint16_t rport, struct timeval *now) { - /* - * This function serves two purposes. It will see if a TAG can be - * re-used and return 1 for yes it is ok and 0 for don't use that - * tag. A secondary function it will do is purge out old tags that - * can be removed. - */ - struct sctpvtaghead *chain; - struct sctp_tagblock *twait_block; struct sctpasochead *head; struct sctp_tcb *stcb; - int i; - SCTP_INP_INFO_RLOCK(); - head = &SCTP_BASE_INFO(sctp_asochash)[SCTP_PCBHASH_ASOC(tag, - SCTP_BASE_INFO(hashasocmark))]; + SCTP_INP_INFO_LOCK_ASSERT(); + + head = &SCTP_BASE_INFO(sctp_asochash)[SCTP_PCBHASH_ASOC(tag, SCTP_BASE_INFO(hashasocmark))]; LIST_FOREACH(stcb, head, sctp_asocs) { /* We choose not to lock anything here. TCB's can't be * removed since we have the read lock, so they can't @@ -7848,40 +7747,11 @@ sctp_is_vtag_good(uint32_t tag, uint16_t lport, uint16_t rport, struct timeval * if (stcb->sctp_ep->sctp_lport != lport) { continue; } - /* Its a used tag set */ - SCTP_INP_INFO_RUNLOCK(); - return (0); + /* The tag is currently used, so don't use it. */ + return (false); } } - chain = &SCTP_BASE_INFO(vtag_timewait)[(tag % SCTP_STACK_VTAG_HASH_SIZE)]; - /* Now what about timed wait ? */ - LIST_FOREACH(twait_block, chain, sctp_nxt_tagblock) { - /* - * Block(s) are present, lets see if we have this tag in the - * list - */ - for (i = 0; i < SCTP_NUMBER_IN_VTAG_BLOCK; i++) { - if (twait_block->vtag_block[i].v_tag == 0) { - /* not used */ - continue; - } else if ((long)twait_block->vtag_block[i].tv_sec_at_expire < - now->tv_sec) { - /* Audit expires this guy */ - twait_block->vtag_block[i].tv_sec_at_expire = 0; - twait_block->vtag_block[i].v_tag = 0; - twait_block->vtag_block[i].lport = 0; - twait_block->vtag_block[i].rport = 0; - } else if ((twait_block->vtag_block[i].v_tag == tag) && - (twait_block->vtag_block[i].lport == lport) && - (twait_block->vtag_block[i].rport == rport)) { - /* Bad tag, sorry :< */ - SCTP_INP_INFO_RUNLOCK(); - return (0); - } - } - } - SCTP_INP_INFO_RUNLOCK(); - return (1); + return (!sctp_is_in_timewait(tag, lport, rport, (uint32_t)now->tv_sec)); } static void @@ -7913,7 +7783,7 @@ sctp_drain_mbufs(struct sctp_tcb *stcb) for (strmat = 0; strmat < asoc->streamincnt; strmat++) { TAILQ_FOREACH_SAFE(control, &asoc->strmin[strmat].inqueue, next_instrm, ncontrol) { #ifdef INVARIANTS - if (control->on_strm_q != SCTP_ON_ORDERED ) { + if (control->on_strm_q != SCTP_ON_ORDERED) { panic("Huh control: %p on_q: %d -- not ordered?", control, control->on_strm_q); } @@ -7973,7 +7843,7 @@ sctp_drain_mbufs(struct sctp_tcb *stcb) } TAILQ_FOREACH_SAFE(control, &asoc->strmin[strmat].uno_inqueue, next_instrm, ncontrol) { #ifdef INVARIANTS - if (control->on_strm_q != SCTP_ON_UNORDERED ) { + if (control->on_strm_q != SCTP_ON_UNORDERED) { panic("Huh control: %p on_q: %d -- not unordered?", control, control->on_strm_q); } @@ -8068,7 +7938,8 @@ sctp_drain_mbufs(struct sctp_tcb *stcb) * asoc->highest_tsn_inside_map? */ asoc->last_revoke_count = cnt; - (void)SCTP_OS_TIMER_STOP(&stcb->asoc.dack_timer.timer); + sctp_timer_stop(SCTP_TIMER_TYPE_RECV, stcb->sctp_ep, stcb, NULL, + SCTP_FROM_SCTP_PCB + SCTP_LOC_11); /*sa_ignore NO_NULL_CHK*/ sctp_send_sack(stcb, SCTP_SO_NOT_LOCKED); sctp_chunk_output(stcb->sctp_ep, stcb, SCTP_OUTPUT_FROM_DRAIN, SCTP_SO_NOT_LOCKED); @@ -8092,7 +7963,7 @@ sctp_drain() * is LOW on MBUF's and needs help. This is where reneging will * occur. We really hope this does NOT happen! */ -#if defined(__FreeBSD__) && __FreeBSD_version >= 801000 +#if defined(__FreeBSD__) && !defined(__Userspace__) VNET_ITERATOR_DECL(vnet_iter); #else struct sctp_inpcb *inp; @@ -8103,7 +7974,7 @@ sctp_drain() return; } #endif -#if defined(__FreeBSD__) && __FreeBSD_version >= 801000 +#if defined(__FreeBSD__) && !defined(__Userspace__) VNET_LIST_RLOCK_NOSLEEP(); VNET_FOREACH(vnet_iter) { CURVNET_SET(vnet_iter); @@ -8111,7 +7982,7 @@ sctp_drain() struct sctp_tcb *stcb; #endif -#if defined(__FreeBSD__) && __FreeBSD_version >= 801000 +#if defined(__FreeBSD__) && !defined(__Userspace__) SCTP_STAT_INCR(sctps_protocol_drain_calls); if (SCTP_BASE_SYSCTL(sctp_do_drain) == 0) { #ifdef VIMAGE @@ -8134,7 +8005,7 @@ sctp_drain() SCTP_INP_RUNLOCK(inp); } SCTP_INP_INFO_RUNLOCK(); -#if defined(__FreeBSD__) && __FreeBSD_version >= 801000 +#if defined(__FreeBSD__) && !defined(__Userspace__) CURVNET_RESTORE(); } VNET_LIST_RUNLOCK_NOSLEEP(); @@ -8194,7 +8065,7 @@ sctp_initiate_iterator(inp_func inpf, it->asoc_state = asoc_state; it->function_inp_end = inpe; it->no_chunk_output = chunk_output_off; -#if defined(__FreeBSD__) && __FreeBSD_version >= 801000 +#if defined(__FreeBSD__) && !defined(__Userspace__) it->vn = curvnet; #endif if (s_inp) { @@ -8210,7 +8081,6 @@ sctp_initiate_iterator(inp_func inpf, } SCTP_INP_INFO_RUNLOCK(); it->iterator_flags = SCTP_ITERATOR_DO_ALL_INP; - } SCTP_IPI_ITERATOR_WQ_LOCK(); if (SCTP_BASE_VAR(sctp_pcb_initialized) == 0) { diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_pcb.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_pcb.h index 551bbfb8e9..ece8c085d0 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_pcb.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_pcb.h @@ -32,9 +32,9 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.h 354018 2019-10-24 09:22:23Z tuexen $"); +__FBSDID("$FreeBSD$"); #endif #ifndef _NETINET_SCTP_PCB_H_ @@ -147,9 +147,8 @@ struct sctp_tagblock { struct sctp_timewait vtag_block[SCTP_NUMBER_IN_VTAG_BLOCK]; }; - struct sctp_epinfo { -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) #ifdef INET struct socket *udp4_tun_socket; #endif @@ -189,7 +188,7 @@ struct sctp_epinfo { struct sctppcbhead listhead; struct sctpladdr addr_wq; -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) struct inpcbhead inplisthead; struct inpcbinfo sctbinfo; #endif @@ -204,27 +203,19 @@ struct sctp_epinfo { sctp_zone_t ipi_zone_asconf; sctp_zone_t ipi_zone_asconf_ack; -#if defined(__FreeBSD__) && __FreeBSD_version >= 503000 -#if __FreeBSD_version <= 602000 - struct mtx ipi_ep_mtx; -#else +#if defined(__FreeBSD__) && !defined(__Userspace__) struct rwlock ipi_ep_mtx; -#endif struct mtx ipi_iterator_wq_mtx; -#if __FreeBSD_version <= 602000 - struct mtx ipi_addr_mtx; -#else struct rwlock ipi_addr_mtx; -#endif struct mtx ipi_pktlog_mtx; struct mtx wq_addr_mtx; #elif defined(SCTP_PROCESS_LEVEL_LOCKS) - userland_mutex_t ipi_ep_mtx; - userland_mutex_t ipi_addr_mtx; + userland_rwlock_t ipi_ep_mtx; + userland_rwlock_t ipi_addr_mtx; userland_mutex_t ipi_count_mtx; userland_mutex_t ipi_pktlog_mtx; userland_mutex_t wq_addr_mtx; -#elif defined(__APPLE__) +#elif defined(__APPLE__) && !defined(__Userspace__) #ifdef _KERN_LOCKS_H_ lck_mtx_t *ipi_addr_mtx; lck_mtx_t *ipi_count_mtx; @@ -235,13 +226,12 @@ struct sctp_epinfo { void *ipi_count_mtx; void *logging_mtx; #endif /* _KERN_LOCKS_H_ */ -#elif defined(__Windows__) +#elif defined(_WIN32) && !defined(__Userspace__) struct rwlock ipi_ep_lock; struct rwlock ipi_addr_lock; struct spinlock ipi_pktlog_mtx; struct rwlock wq_addr_mtx; #elif defined(__Userspace__) - /* TODO decide on __Userspace__ locks */ #endif uint32_t ipi_count_ep; @@ -286,14 +276,17 @@ struct sctp_epinfo { #endif }; - struct sctp_base_info { /* All static structures that * anchor the system must be here. */ struct sctp_epinfo sctppcbinfo; -#if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT) +#if defined(__FreeBSD__) && !defined(__Userspace__) +#if defined(SMP) && defined(SCTP_USE_PERCPU_STAT) struct sctpstat *sctpstat; +#else + struct sctpstat sctpstat; +#endif #else struct sctpstat sctpstat; #endif @@ -305,25 +298,28 @@ struct sctp_base_info { int packet_log_end; uint8_t packet_log_buffer[SCTP_PACKET_LOG_SIZE]; #endif -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) eventhandler_tag eh_tag; #endif -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) int sctp_main_timer_ticks; #endif #if defined(__Userspace__) userland_mutex_t timer_mtx; userland_thread_t timer_thread; int timer_thread_should_exit; -#if !defined(__Userspace_os_Windows) + int iterator_thread_started; + int timer_thread_started; +#if !defined(_WIN32) pthread_mutexattr_t mtx_attr; + pthread_rwlockattr_t rwlock_attr; #if defined(INET) || defined(INET6) int userspace_route; userland_thread_t recvthreadroute; #endif #endif #ifdef INET -#if defined(__Userspace_os_Windows) && !defined(__MINGW32__) +#if defined(_WIN32) && !defined(__MINGW32__) SOCKET userspace_rawsctp; SOCKET userspace_udpsctp; #else @@ -334,7 +330,7 @@ struct sctp_base_info { userland_thread_t recvthreadudp; #endif #ifdef INET6 -#if defined(__Userspace_os_Windows) && !defined(__MINGW32__) +#if defined(_WIN32) && !defined(__MINGW32__) SOCKET userspace_rawsctp6; SOCKET userspace_udpsctp6; #else @@ -361,11 +357,11 @@ struct sctp_pcb { uint32_t secret_key[SCTP_HOW_MANY_SECRETS][SCTP_NUMBER_OF_SECRETS]; unsigned int size_of_a_cookie; - unsigned int sctp_timeoutticks[SCTP_NUM_TMRS]; - unsigned int sctp_minrto; - unsigned int sctp_maxrto; - unsigned int initial_rto; - int initial_init_rto_max; + uint32_t sctp_timeoutticks[SCTP_NUM_TMRS]; + uint32_t sctp_minrto; + uint32_t sctp_maxrto; + uint32_t initial_rto; + uint32_t initial_init_rto_max; unsigned int sctp_sack_freq; uint32_t sctp_sws_sender; @@ -408,7 +404,7 @@ struct sctp_pcb { uint32_t def_cookie_life; /* defaults to 0 */ - int auto_close_time; + uint32_t auto_close_time; uint32_t initial_sequence_debug; uint32_t adaptation_layer_indicator; uint8_t adaptation_layer_indicator_provided; @@ -443,7 +439,6 @@ struct sctp_pcbtsn_rlog { }; #define SCTP_READ_LOG_SIZE 135 /* we choose the number to make a pcb a page */ - struct sctp_inpcb { /*- * put an inpcb in front of it all, kind of a waste but we need to @@ -454,8 +449,7 @@ struct sctp_inpcb { char align[(sizeof(struct inpcb) + SCTP_ALIGNM1) & ~SCTP_ALIGNM1]; } ip_inp; - -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) /* leave some space in case i386 inpcb is bigger than ppc */ uint8_t padding[128]; #endif @@ -464,7 +458,7 @@ struct sctp_inpcb { struct sctp_readhead read_queue; LIST_ENTRY(sctp_inpcb) sctp_list; /* lists all endpoints */ - /* hash of all endpoints for model */ + /* hash of all endpoints for model */ LIST_ENTRY(sctp_inpcb) sctp_hash; /* count of local addresses bound, 0 if bound all */ int laddr_count; @@ -488,7 +482,6 @@ struct sctp_inpcb { #ifdef SCTP_TRACK_FREED_ASOCS struct sctpasochead sctp_asoc_free_list; #endif - struct sctp_iterator *inp_starting_point_for_iterator; uint32_t sctp_frag_point; uint32_t partial_delivery_point; uint32_t sctp_context; @@ -512,26 +505,9 @@ struct sctp_inpcb { * they are candidates with sctp_sendm for * de-supporting. */ -#ifdef __Panda__ - pakhandle_type pak_to_read; - pakhandle_type pak_to_read_sendq; -#endif struct mbuf *pkt, *pkt_last; struct mbuf *control; -#if !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) || defined(__Userspace__)) -#ifndef INP_IPV6 -#define INP_IPV6 0x1 -#endif -#ifndef INP_IPV4 -#define INP_IPV4 0x2 -#endif - uint8_t inp_vflag; - /* TODO __Userspace__ where is our inp_vlag going to be? */ - uint8_t inp_ip_ttl; - uint8_t inp_ip_tos; /* defined as macro in user_inpcb.h */ - uint8_t inp_ip_resv; -#endif -#if defined(__FreeBSD__) && __FreeBSD_version >= 503000 +#if defined(__FreeBSD__) && !defined(__Userspace__) struct mtx inp_mtx; struct mtx inp_create_mtx; struct mtx inp_rdata_mtx; @@ -541,7 +517,7 @@ struct sctp_inpcb { userland_mutex_t inp_create_mtx; userland_mutex_t inp_rdata_mtx; int32_t refcount; -#elif defined(__APPLE__) +#elif defined(__APPLE__) && !defined(__Userspace__) #if defined(SCTP_APPLE_RWLOCK) lck_rw_t *inp_mtx; #else @@ -549,16 +525,15 @@ struct sctp_inpcb { #endif lck_mtx_t *inp_create_mtx; lck_mtx_t *inp_rdata_mtx; -#elif defined(__Windows__) +#elif defined(_WIN32) && !defined(__Userspace__) struct rwlock inp_lock; struct spinlock inp_create_lock; struct spinlock inp_rdata_lock; int32_t refcount; #elif defined(__Userspace__) - /* TODO decide on __Userspace__ locks */ int32_t refcount; #endif -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) int32_t refcount; uint32_t lock_caller1; @@ -602,7 +577,7 @@ struct sctp_inpcb { int (*recv_callback)(struct socket *, union sctp_sockstore, void *, size_t, struct sctp_rcvinfo, int, void *); uint32_t send_sb_threshold; - int (*send_callback)(struct socket *, uint32_t); + int (*send_callback)(struct socket *, uint32_t, void *); #endif }; @@ -610,8 +585,9 @@ struct sctp_inpcb { int register_recv_cb (struct socket *, int (*)(struct socket *, union sctp_sockstore, void *, size_t, struct sctp_rcvinfo, int, void *)); -int register_send_cb (struct socket *, uint32_t, int (*)(struct socket *, uint32_t)); +int register_send_cb (struct socket *, uint32_t, int (*)(struct socket *, uint32_t, void *)); int register_ulp_info (struct socket *, void *); +int retrieve_ulp_info (struct socket *, void **); #endif struct sctp_tcb { @@ -639,34 +615,30 @@ struct sctp_tcb { int freed_from_where; uint16_t rport; /* remote port in network format */ uint16_t resv; -#if defined(__FreeBSD__) && __FreeBSD_version >= 503000 +#if defined(__FreeBSD__) && !defined(__Userspace__) struct mtx tcb_mtx; struct mtx tcb_send_mtx; #elif defined(SCTP_PROCESS_LEVEL_LOCKS) userland_mutex_t tcb_mtx; userland_mutex_t tcb_send_mtx; -#elif defined(__APPLE__) +#elif defined(__APPLE__) && !defined(__Userspace__) lck_mtx_t* tcb_mtx; lck_mtx_t* tcb_send_mtx; -#elif defined(__Windows__) +#elif defined(_WIN32) && !defined(__Userspace__) struct spinlock tcb_lock; struct spinlock tcb_send_lock; #elif defined(__Userspace__) - /* TODO decide on __Userspace__ locks */ #endif -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) uint32_t caller1; uint32_t caller2; uint32_t caller3; #endif }; - -#if defined(__FreeBSD__) && __FreeBSD_version >= 503000 - +#if defined(__FreeBSD__) && !defined(__Userspace__) #include - -#elif defined(__APPLE__) +#elif defined(__APPLE__) && !defined(__Userspace__) /* * Apple MacOS X 10.4 "Tiger" */ @@ -677,7 +649,7 @@ struct sctp_tcb { #include -#elif defined(__Windows__) +#elif defined(_WIN32) && !defined(__Userspace__) #include @@ -692,15 +664,14 @@ struct sctp_tcb { #include #endif -/* TODO where to put non-_KERNEL things for __Userspace__? */ #if defined(_KERNEL) || defined(__Userspace__) /* Attention Julian, this is the extern that * goes with the base info. sctp_pcb.c has * the real definition. */ -#if defined(__FreeBSD__) && __FreeBSD_version >= 801000 -VNET_DECLARE(struct sctp_base_info, system_base_info) ; +#if defined(__FreeBSD__) && !defined(__Userspace__) +VNET_DECLARE(struct sctp_base_info, system_base_info); #else extern struct sctp_base_info system_base_info; #endif @@ -742,26 +713,35 @@ void sctp_update_ifn_mtu(uint32_t ifn_index, uint32_t mtu); void sctp_free_ifn(struct sctp_ifn *sctp_ifnp); void sctp_free_ifa(struct sctp_ifa *sctp_ifap); - void sctp_del_addr_from_vrf(uint32_t vrfid, struct sockaddr *addr, uint32_t ifn_index, const char *if_name); - - struct sctp_nets *sctp_findnet(struct sctp_tcb *, struct sockaddr *); struct sctp_inpcb *sctp_pcb_findep(struct sockaddr *, int, int, uint32_t); -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 -int sctp_inpcb_bind(struct socket *, struct sockaddr *, - struct sctp_ifa *,struct thread *); -#elif defined(__Windows__) -int sctp_inpcb_bind(struct socket *, struct sockaddr *, - struct sctp_ifa *,PKTHREAD); +#if defined(__FreeBSD__) && !defined(__Userspace__) +int +sctp_inpcb_bind(struct socket *, struct sockaddr *, + struct sctp_ifa *, struct thread *); +int +sctp_inpcb_bind_locked(struct sctp_inpcb *, struct sockaddr *, + struct sctp_ifa *, struct thread *); +#elif defined(_WIN32) && !defined(__Userspace__) +int +sctp_inpcb_bind(struct socket *, struct sockaddr *, + struct sctp_ifa *, PKTHREAD); +int +sctp_inpcb_bind_locked(struct sctp_inpcb *, struct sockaddr *, + struct sctp_ifa *, PKTHREAD); #else /* struct proc is a dummy for __Userspace__ */ -int sctp_inpcb_bind(struct socket *, struct sockaddr *, - struct sctp_ifa *, struct proc *); +int +sctp_inpcb_bind(struct socket *, struct sockaddr *, + struct sctp_ifa *, struct proc *); +int +sctp_inpcb_bind_locked(struct sctp_inpcb *, struct sockaddr *, + struct sctp_ifa *, struct proc *); #endif struct sctp_tcb * @@ -809,33 +789,34 @@ void sctp_inpcb_free(struct sctp_inpcb *, int, int); #define SCTP_DONT_INITIALIZE_AUTH_PARAMS 0 #define SCTP_INITIALIZE_AUTH_PARAMS 1 -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 +#if defined(__FreeBSD__) && !defined(__Userspace__) struct sctp_tcb * sctp_aloc_assoc(struct sctp_inpcb *, struct sockaddr *, - int *, uint32_t, uint32_t, uint16_t, uint16_t, struct thread *, - int); -#elif defined(__Windows__) + int *, uint32_t, uint32_t, uint32_t, uint16_t, uint16_t, + struct thread *, int); struct sctp_tcb * -sctp_aloc_assoc(struct sctp_inpcb *, struct sockaddr *, - int *, uint32_t, uint32_t, uint16_t, uint16_t, PKTHREAD, int); +sctp_aloc_assoc_connected(struct sctp_inpcb *, struct sockaddr *, + int *, uint32_t, uint32_t, uint32_t, uint16_t, uint16_t, + struct thread *, int); +#elif defined(_WIN32) && !defined(__Userspace__) +struct sctp_tcb * +sctp_aloc_assoc(struct sctp_inpcb *, struct sockaddr *, int *, uint32_t, + uint32_t, uint32_t, uint16_t, uint16_t, PKTHREAD, int); +struct sctp_tcb * +sctp_aloc_assoc_connected(struct sctp_inpcb *, struct sockaddr *, int *, uint32_t, + uint32_t, uint32_t, uint16_t, uint16_t, PKTHREAD, int); #else /* proc will be NULL for __Userspace__ */ struct sctp_tcb * -sctp_aloc_assoc(struct sctp_inpcb *, struct sockaddr *, - int *, uint32_t, uint32_t, uint16_t, uint16_t, struct proc *, - int); +sctp_aloc_assoc(struct sctp_inpcb *, struct sockaddr *, int *, uint32_t, + uint32_t, uint32_t, uint16_t, uint16_t, struct proc *, int); +struct sctp_tcb * +sctp_aloc_assoc_connected(struct sctp_inpcb *, struct sockaddr *, int *, uint32_t, + uint32_t, uint32_t, uint16_t, uint16_t, struct proc *, int); #endif int sctp_free_assoc(struct sctp_inpcb *, struct sctp_tcb *, int, int); - -void sctp_delete_from_timewait(uint32_t, uint16_t, uint16_t); - -int sctp_is_in_timewait(uint32_t tag, uint16_t lport, uint16_t rport); - -void -sctp_add_vtag_to_timewait(uint32_t tag, uint32_t time, uint16_t lport, uint16_t rport); - void sctp_add_local_addr_ep(struct sctp_inpcb *, struct sctp_ifa *, uint32_t); void sctp_del_local_addr_ep(struct sctp_inpcb *, struct sctp_ifa *); @@ -865,7 +846,8 @@ int sctp_set_primary_addr(struct sctp_tcb *, struct sockaddr *, struct sctp_nets *); -int sctp_is_vtag_good(uint32_t, uint16_t lport, uint16_t rport, struct timeval *); +bool +sctp_is_vtag_good(uint32_t, uint16_t lport, uint16_t rport, struct timeval *); /* void sctp_drain(void); */ @@ -889,10 +871,12 @@ sctp_initiate_iterator(inp_func inpf, end_func ef, struct sctp_inpcb *, uint8_t co_off); -#if defined(__FreeBSD__) && defined(SCTP_MCORE_INPUT) && defined(SMP) +#if defined(__FreeBSD__) && !defined(__Userspace__) +#if defined(SCTP_MCORE_INPUT) && defined(SMP) void sctp_queue_to_mcore(struct mbuf *m, int off, int cpu_to_use); +#endif #endif #endif /* _KERNEL */ diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_peeloff.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_peeloff.c index 8e81065a4d..548c3d82b2 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_peeloff.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_peeloff.c @@ -32,9 +32,9 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_peeloff.c 337708 2018-08-13 13:58:45Z tuexen $"); +__FBSDID("$FreeBSD$"); #endif #include @@ -49,10 +49,6 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_peeloff.c 337708 2018-08-13 13:58:45Z #include #include -#if defined(__APPLE__) -#define APPLE_FILE_NO 5 -#endif - int sctp_can_peel_off(struct socket *head, sctp_assoc_t assoc_id) { @@ -138,7 +134,6 @@ sctp_do_peeloff(struct socket *head, struct socket *so, sctp_assoc_t assoc_id) n_inp->sctp_context = inp->sctp_context; n_inp->max_cwnd = inp->max_cwnd; n_inp->local_strreset_support = inp->local_strreset_support; - n_inp->inp_starting_point_for_iterator = NULL; /* copy in the authentication parameters from the original endpoint */ if (n_inp->sctp_ep.local_hmacs) sctp_free_hmaclist(n_inp->sctp_ep.local_hmacs); @@ -164,7 +159,7 @@ sctp_do_peeloff(struct socket *head, struct socket *so, sctp_assoc_t assoc_id) atomic_add_int(&stcb->asoc.refcnt, 1); SCTP_TCB_UNLOCK(stcb); -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) sctp_pull_off_control_to_new_inp(inp, n_inp, stcb, SBL_WAIT); #else sctp_pull_off_control_to_new_inp(inp, n_inp, stcb, M_WAITOK); @@ -178,14 +173,6 @@ sctp_do_peeloff(struct socket *head, struct socket *so, sctp_assoc_t assoc_id) struct socket * sctp_get_peeloff(struct socket *head, sctp_assoc_t assoc_id, int *error) { -#if defined(__Userspace__) - /* if __Userspace__ chooses to originally not support peeloff, put it here... */ -#endif -#if defined(__Panda__) - SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTP_PEELOFF, EINVAL); - *error = EINVAL; - return (NULL); -#else struct socket *newso; struct sctp_inpcb *inp, *n_inp; struct sctp_tcb *stcb; @@ -205,18 +192,15 @@ sctp_get_peeloff(struct socket *head, sctp_assoc_t assoc_id, int *error) } atomic_add_int(&stcb->asoc.refcnt, 1); SCTP_TCB_UNLOCK(stcb); -#if defined(__FreeBSD__) && __FreeBSD_version >= 801000 +#if defined(__FreeBSD__) && !defined(__Userspace__) CURVNET_SET(head->so_vnet); #endif newso = sonewconn(head, SS_ISCONNECTED -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) , NULL -#elif defined(__Panda__) - /* place this socket in the assoc's vrf id */ - , NULL, stcb->asoc.vrf_id #endif ); -#if defined(__FreeBSD__) && __FreeBSD_version >= 801000 +#if defined(__FreeBSD__) && !defined(__Userspace__) CURVNET_RESTORE(); #endif if (newso == NULL) { @@ -227,7 +211,7 @@ sctp_get_peeloff(struct socket *head, sctp_assoc_t assoc_id, int *error) return (NULL); } -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) else { SCTP_SOCKET_LOCK(newso, 1); } @@ -288,7 +272,6 @@ sctp_get_peeloff(struct socket *head, sctp_assoc_t assoc_id, int *error) SOCK_UNLOCK(newso); /* We remove it right away */ -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) || defined(__Userspace__) #ifdef SCTP_LOCK_LOGGING if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) { sctp_log_lock(inp, (struct sctp_tcb *)NULL, SCTP_LOG_LOCK_SOCK); @@ -297,16 +280,6 @@ sctp_get_peeloff(struct socket *head, sctp_assoc_t assoc_id, int *error) TAILQ_REMOVE(&head->so_comp, newso, so_list); head->so_qlen--; SOCK_UNLOCK(head); -#else - newso = TAILQ_FIRST(&head->so_q); - if (soqremque(newso, 1) == 0) { - SCTP_PRINTF("soremque failed, peeloff-fails (invarients would panic)\n"); - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PEELOFF, ENOTCONN); - *error = ENOTCONN; - return (NULL); - - } -#endif /* * Now we must move it from one hash table to another and get the * stcb in the right place. @@ -318,13 +291,12 @@ sctp_get_peeloff(struct socket *head, sctp_assoc_t assoc_id, int *error) * And now the final hack. We move data in the pending side i.e. * head to the new socket buffer. Let the GRUBBING begin :-0 */ -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) sctp_pull_off_control_to_new_inp(inp, n_inp, stcb, SBL_WAIT); #else sctp_pull_off_control_to_new_inp(inp, n_inp, stcb, M_WAITOK); #endif atomic_subtract_int(&stcb->asoc.refcnt, 1); return (newso); -#endif } #endif diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_peeloff.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_peeloff.h index adefcded13..7e1c5eceeb 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_peeloff.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_peeloff.h @@ -32,7 +32,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include __FBSDID("$FreeBSD: head/sys/netinet/sctp_peeloff.h 309607 2016-12-06 10:21:25Z tuexen $"); #endif @@ -42,13 +42,13 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_peeloff.h 309607 2016-12-06 10:21:25Z #if defined(HAVE_SCTP_PEELOFF_SOCKOPT) /* socket option peeloff */ struct sctp_peeloff_opt { -#if !defined(__Windows__) +#if !(defined(_WIN32) && !defined(__Userspace__)) int s; #else HANDLE s; #endif sctp_assoc_t assoc_id; -#if !defined(__Windows__) +#if !(defined(_WIN32) && !defined(__Userspace__)) int new_sd; #else HANDLE new_sd; diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_process_lock.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_process_lock.h index ca66921202..bbc2845767 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_process_lock.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_process_lock.h @@ -53,13 +53,16 @@ * per socket level locking */ -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) /* Lock for INFO stuff */ #define SCTP_INP_INFO_LOCK_INIT() #define SCTP_INP_INFO_RLOCK() #define SCTP_INP_INFO_RUNLOCK() #define SCTP_INP_INFO_WLOCK() #define SCTP_INP_INFO_WUNLOCK() +#define SCTP_INP_INFO_LOCK_ASSERT() +#define SCTP_INP_INFO_RLOCK_ASSERT() +#define SCTP_INP_INFO_WLOCK_ASSERT() #define SCTP_INP_INFO_LOCK_DESTROY() #define SCTP_IPI_COUNT_INIT() #define SCTP_IPI_COUNT_DESTROY() @@ -69,6 +72,9 @@ #define SCTP_INP_INFO_RUNLOCK() #define SCTP_INP_INFO_WLOCK() #define SCTP_INP_INFO_WUNLOCK() +#define SCTP_INP_INFO_LOCK_ASSERT() +#define SCTP_INP_INFO_RLOCK_ASSERT() +#define SCTP_INP_INFO_WLOCK_ASSERT() #define SCTP_INP_INFO_LOCK_DESTROY() #define SCTP_IPI_COUNT_INIT() #define SCTP_IPI_COUNT_DESTROY() @@ -78,6 +84,7 @@ #define SCTP_TCB_SEND_LOCK_DESTROY(_tcb) #define SCTP_TCB_SEND_LOCK(_tcb) #define SCTP_TCB_SEND_UNLOCK(_tcb) +#define SCTP_TCB_SEND_LOCK_ASSERT(_tcb) /* Lock for INP */ #define SCTP_INP_LOCK_INIT(_inp) @@ -86,7 +93,9 @@ #define SCTP_INP_RLOCK(_inp) #define SCTP_INP_RUNLOCK(_inp) #define SCTP_INP_WLOCK(_inp) -#define SCTP_INP_WUNLOCK(_inep) +#define SCTP_INP_WUNLOCK(_inp) +#define SCTP_INP_RLOCK_ASSERT(_inp) +#define SCTP_INP_WLOCK_ASSERT(_inp) #define SCTP_INP_INCR_REF(_inp) #define SCTP_INP_DECR_REF(_inp) @@ -115,7 +124,7 @@ */ #define SCTP_IPI_COUNT_INIT() -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) #define SCTP_WQ_ADDR_INIT() \ InitializeCriticalSection(&SCTP_BASE_INFO(wq_addr_mtx)) #define SCTP_WQ_ADDR_DESTROY() \ @@ -124,8 +133,9 @@ EnterCriticalSection(&SCTP_BASE_INFO(wq_addr_mtx)) #define SCTP_WQ_ADDR_UNLOCK() \ LeaveCriticalSection(&SCTP_BASE_INFO(wq_addr_mtx)) +#define SCTP_WQ_ADDR_LOCK_ASSERT() - +#if WINVER < 0x0600 #define SCTP_INP_INFO_LOCK_INIT() \ InitializeCriticalSection(&SCTP_BASE_INFO(ipi_ep_mtx)) #define SCTP_INP_INFO_LOCK_DESTROY() \ @@ -140,6 +150,27 @@ LeaveCriticalSection(&SCTP_BASE_INFO(ipi_ep_mtx)) #define SCTP_INP_INFO_WUNLOCK() \ LeaveCriticalSection(&SCTP_BASE_INFO(ipi_ep_mtx)) +#define SCTP_INP_INFO_LOCK_ASSERT() +#define SCTP_INP_INFO_RLOCK_ASSERT() +#define SCTP_INP_INFO_WLOCK_ASSERT() +#else +#define SCTP_INP_INFO_LOCK_INIT() \ + InitializeSRWLock(&SCTP_BASE_INFO(ipi_ep_mtx)) +#define SCTP_INP_INFO_LOCK_DESTROY() +#define SCTP_INP_INFO_RLOCK() \ + AcquireSRWLockShared(&SCTP_BASE_INFO(ipi_ep_mtx)) +#define SCTP_INP_INFO_TRYLOCK() \ + TryAcquireSRWLockShared(&SCTP_BASE_INFO(ipi_ep_mtx)) +#define SCTP_INP_INFO_WLOCK() \ + AcquireSRWLockExclusive(&SCTP_BASE_INFO(ipi_ep_mtx)) +#define SCTP_INP_INFO_RUNLOCK() \ + ReleaseSRWLockShared(&SCTP_BASE_INFO(ipi_ep_mtx)) +#define SCTP_INP_INFO_WUNLOCK() \ + ReleaseSRWLockExclusive(&SCTP_BASE_INFO(ipi_ep_mtx)) +#define SCTP_INP_INFO_LOCK_ASSERT() +#define SCTP_INP_INFO_RLOCK_ASSERT() +#define SCTP_INP_INFO_WLOCK_ASSERT() +#endif #define SCTP_IP_PKTLOG_INIT() \ InitializeCriticalSection(&SCTP_BASE_INFO(ipi_pktlog_mtx)) @@ -185,6 +216,8 @@ #define SCTP_INP_WLOCK(_inp) \ EnterCriticalSection(&(_inp)->inp_mtx) #endif +#define SCTP_INP_RLOCK_ASSERT(_tcb) +#define SCTP_INP_WLOCK_ASSERT(_tcb) #define SCTP_TCB_SEND_LOCK_INIT(_tcb) \ InitializeCriticalSection(&(_tcb)->tcb_send_mtx) @@ -194,9 +227,10 @@ EnterCriticalSection(&(_tcb)->tcb_send_mtx) #define SCTP_TCB_SEND_UNLOCK(_tcb) \ LeaveCriticalSection(&(_tcb)->tcb_send_mtx) +#define SCTP_TCB_SEND_LOCK_ASSERT(_tcb) #define SCTP_INP_INCR_REF(_inp) atomic_add_int(&((_inp)->refcount), 1) -#define SCTP_INP_DECR_REF(_inp) atomic_add_int(&((_inp)->refcount), -1) +#define SCTP_INP_DECR_REF(_inp) atomic_subtract_int(&((_inp)->refcount), 1) #define SCTP_ASOC_CREATE_LOCK_INIT(_inp) \ InitializeCriticalSection(&(_inp)->inp_create_mtx) @@ -254,41 +288,46 @@ (void)pthread_mutex_destroy(&SCTP_BASE_INFO(wq_addr_mtx)) #ifdef INVARIANTS #define SCTP_WQ_ADDR_LOCK() \ - KASSERT(pthread_mutex_lock(&SCTP_BASE_INFO(wq_addr_mtx)) == 0, ("%s: wq_addr_mtx already locked", __func__)) + KASSERT(pthread_mutex_lock(&SCTP_BASE_INFO(wq_addr_mtx)) == 0, ("%s:%d: wq_addr_mtx already locked", __FILE__, __LINE__)) #define SCTP_WQ_ADDR_UNLOCK() \ - KASSERT(pthread_mutex_unlock(&SCTP_BASE_INFO(wq_addr_mtx)) == 0, ("%s: wq_addr_mtx not locked", __func__)) + KASSERT(pthread_mutex_unlock(&SCTP_BASE_INFO(wq_addr_mtx)) == 0, ("%s:%d: wq_addr_mtx not locked", __FILE__, __LINE__)) #else #define SCTP_WQ_ADDR_LOCK() \ (void)pthread_mutex_lock(&SCTP_BASE_INFO(wq_addr_mtx)) #define SCTP_WQ_ADDR_UNLOCK() \ (void)pthread_mutex_unlock(&SCTP_BASE_INFO(wq_addr_mtx)) #endif +#define SCTP_WQ_ADDR_LOCK_ASSERT() \ + KASSERT(pthread_mutex_trylock(&SCTP_BASE_INFO(wq_addr_mtx)) == EBUSY, ("%s:%d: wq_addr_mtx not locked", __FILE__, __LINE__)) #define SCTP_INP_INFO_LOCK_INIT() \ - (void)pthread_mutex_init(&SCTP_BASE_INFO(ipi_ep_mtx), &SCTP_BASE_VAR(mtx_attr)) + (void)pthread_rwlock_init(&SCTP_BASE_INFO(ipi_ep_mtx), &SCTP_BASE_VAR(rwlock_attr)) #define SCTP_INP_INFO_LOCK_DESTROY() \ - (void)pthread_mutex_destroy(&SCTP_BASE_INFO(ipi_ep_mtx)) + (void)pthread_rwlock_destroy(&SCTP_BASE_INFO(ipi_ep_mtx)) #ifdef INVARIANTS #define SCTP_INP_INFO_RLOCK() \ - KASSERT(pthread_mutex_lock(&SCTP_BASE_INFO(ipi_ep_mtx)) == 0, ("%s: ipi_ep_mtx already locked", __func__)) + KASSERT(pthread_rwlock_rdlock(&SCTP_BASE_INFO(ipi_ep_mtx)) == 0, ("%s%d: ipi_ep_mtx already locked", __FILE__, __LINE__)) #define SCTP_INP_INFO_WLOCK() \ - KASSERT(pthread_mutex_lock(&SCTP_BASE_INFO(ipi_ep_mtx)) == 0, ("%s: ipi_ep_mtx already locked", __func__)) + KASSERT(pthread_rwlock_wrlock(&SCTP_BASE_INFO(ipi_ep_mtx)) == 0, ("%s:%d: ipi_ep_mtx already locked", __FILE__, __LINE__)) #define SCTP_INP_INFO_RUNLOCK() \ - KASSERT(pthread_mutex_unlock(&SCTP_BASE_INFO(ipi_ep_mtx)) == 0, ("%s: ipi_ep_mtx not locked", __func__)) + KASSERT(pthread_rwlock_unlock(&SCTP_BASE_INFO(ipi_ep_mtx)) == 0, ("%s:%d: ipi_ep_mtx not locked", __FILE__, __LINE__)) #define SCTP_INP_INFO_WUNLOCK() \ - KASSERT(pthread_mutex_unlock(&SCTP_BASE_INFO(ipi_ep_mtx)) == 0, ("%s: ipi_ep_mtx not locked", __func__)) + KASSERT(pthread_rwlock_unlock(&SCTP_BASE_INFO(ipi_ep_mtx)) == 0, ("%s:%d: ipi_ep_mtx not locked", __FILE__, __LINE__)) #else #define SCTP_INP_INFO_RLOCK() \ - (void)pthread_mutex_lock(&SCTP_BASE_INFO(ipi_ep_mtx)) + (void)pthread_rwlock_rdlock(&SCTP_BASE_INFO(ipi_ep_mtx)) #define SCTP_INP_INFO_WLOCK() \ - (void)pthread_mutex_lock(&SCTP_BASE_INFO(ipi_ep_mtx)) + (void)pthread_rwlock_wrlock(&SCTP_BASE_INFO(ipi_ep_mtx)) #define SCTP_INP_INFO_RUNLOCK() \ - (void)pthread_mutex_unlock(&SCTP_BASE_INFO(ipi_ep_mtx)) + (void)pthread_rwlock_unlock(&SCTP_BASE_INFO(ipi_ep_mtx)) #define SCTP_INP_INFO_WUNLOCK() \ - (void)pthread_mutex_unlock(&SCTP_BASE_INFO(ipi_ep_mtx)) + (void)pthread_rwlock_unlock(&SCTP_BASE_INFO(ipi_ep_mtx)) #endif +#define SCTP_INP_INFO_LOCK_ASSERT() +#define SCTP_INP_INFO_RLOCK_ASSERT() +#define SCTP_INP_INFO_WLOCK_ASSERT() #define SCTP_INP_INFO_TRYLOCK() \ - (!(pthread_mutex_trylock(&SCTP_BASE_INFO(ipi_ep_mtx)))) + (!(pthread_rwlock_tryrdlock(&SCTP_BASE_INFO(ipi_ep_mtx)))) #define SCTP_IP_PKTLOG_INIT() \ (void)pthread_mutex_init(&SCTP_BASE_INFO(ipi_pktlog_mtx), &SCTP_BASE_VAR(mtx_attr)) @@ -296,9 +335,9 @@ (void)pthread_mutex_destroy(&SCTP_BASE_INFO(ipi_pktlog_mtx)) #ifdef INVARIANTS #define SCTP_IP_PKTLOG_LOCK() \ - KASSERT(pthread_mutex_lock(&SCTP_BASE_INFO(ipi_pktlog_mtx)) == 0, ("%s: ipi_pktlog_mtx already locked", __func__)) + KASSERT(pthread_mutex_lock(&SCTP_BASE_INFO(ipi_pktlog_mtx)) == 0, ("%s:%d: ipi_pktlog_mtx already locked", __FILE__, __LINE__)) #define SCTP_IP_PKTLOG_UNLOCK() \ - KASSERT(pthread_mutex_unlock(&SCTP_BASE_INFO(ipi_pktlog_mtx)) == 0, ("%s: ipi_pktlog_mtx not locked", __func__)) + KASSERT(pthread_mutex_unlock(&SCTP_BASE_INFO(ipi_pktlog_mtx)) == 0, ("%s:%d: ipi_pktlog_mtx not locked", __FILE__, __LINE__)) #else #define SCTP_IP_PKTLOG_LOCK() \ (void)pthread_mutex_lock(&SCTP_BASE_INFO(ipi_pktlog_mtx)) @@ -318,9 +357,9 @@ (void)pthread_mutex_destroy(&(_inp)->inp_rdata_mtx) #ifdef INVARIANTS #define SCTP_INP_READ_LOCK(_inp) \ - KASSERT(pthread_mutex_lock(&(_inp)->inp_rdata_mtx) == 0, ("%s: inp_rdata_mtx already locked", __func__)) + KASSERT(pthread_mutex_lock(&(_inp)->inp_rdata_mtx) == 0, ("%s:%d: inp_rdata_mtx already locked", __FILE__, __LINE__)) #define SCTP_INP_READ_UNLOCK(_inp) \ - KASSERT(pthread_mutex_unlock(&(_inp)->inp_rdata_mtx) == 0, ("%s: inp_rdata_mtx not locked", __func__)) + KASSERT(pthread_mutex_unlock(&(_inp)->inp_rdata_mtx) == 0, ("%s:%d: inp_rdata_mtx not locked", __FILE__, __LINE__)) #else #define SCTP_INP_READ_LOCK(_inp) \ (void)pthread_mutex_lock(&(_inp)->inp_rdata_mtx) @@ -334,26 +373,26 @@ (void)pthread_mutex_destroy(&(_inp)->inp_mtx) #ifdef INVARIANTS #ifdef SCTP_LOCK_LOGGING -#define SCTP_INP_RLOCK(_inp) do { \ - if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \ - sctp_log_lock(_inp, NULL, SCTP_LOG_LOCK_INP); \ - KASSERT(pthread_mutex_lock(&(_inp)->inp_mtx) == 0, ("%s: inp_mtx already locked", __func__)) \ +#define SCTP_INP_RLOCK(_inp) do { \ + if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \ + sctp_log_lock(_inp, NULL, SCTP_LOG_LOCK_INP); \ + KASSERT(pthread_mutex_lock(&(_inp)->inp_mtx) == 0, ("%s:%d: inp_mtx already locked", __FILE__, __LINE__)); \ } while (0) -#define SCTP_INP_WLOCK(_inp) do { \ - if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \ - sctp_log_lock(_inp, NULL, SCTP_LOG_LOCK_INP); \ - KASSERT(pthread_mutex_lock(&(_inp)->inp_mtx) == 0, ("%s: inp_mtx already locked", __func__)) +#define SCTP_INP_WLOCK(_inp) do { \ + if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \ + sctp_log_lock(_inp, NULL, SCTP_LOG_LOCK_INP); \ + KASSERT(pthread_mutex_lock(&(_inp)->inp_mtx) == 0, ("%s:%d: inp_mtx already locked", __FILE__, __LINE__)); \ } while (0) #else #define SCTP_INP_RLOCK(_inp) \ - KASSERT(pthread_mutex_lock(&(_inp)->inp_mtx) == 0, ("%s: inp_mtx already locked", __func__)) + KASSERT(pthread_mutex_lock(&(_inp)->inp_mtx) == 0, ("%s:%d: inp_mtx already locked", __FILE__, __LINE__)) #define SCTP_INP_WLOCK(_inp) \ - KASSERT(pthread_mutex_lock(&(_inp)->inp_mtx) == 0, ("%s: inp_mtx already locked", __func__)) + KASSERT(pthread_mutex_lock(&(_inp)->inp_mtx) == 0, ("%s:%d: inp_mtx already locked", __FILE__, __LINE__)) #endif #define SCTP_INP_RUNLOCK(_inp) \ - KASSERT(pthread_mutex_unlock(&(_inp)->inp_mtx) == 0, ("%s: inp_mtx not locked", __func__)) + KASSERT(pthread_mutex_unlock(&(_inp)->inp_mtx) == 0, ("%s:%d: inp_mtx not locked", __FILE__, __LINE__)) #define SCTP_INP_WUNLOCK(_inp) \ - KASSERT(pthread_mutex_unlock(&(_inp)->inp_mtx) == 0, ("%s: inp_mtx not locked", __func__)) + KASSERT(pthread_mutex_unlock(&(_inp)->inp_mtx) == 0, ("%s:%d: inp_mtx not locked", __FILE__, __LINE__)) #else #ifdef SCTP_LOCK_LOGGING #define SCTP_INP_RLOCK(_inp) do { \ @@ -377,8 +416,12 @@ #define SCTP_INP_WUNLOCK(_inp) \ (void)pthread_mutex_unlock(&(_inp)->inp_mtx) #endif +#define SCTP_INP_RLOCK_ASSERT(_inp) \ + KASSERT(pthread_mutex_trylock(&(_inp)->inp_mtx) == EBUSY, ("%s:%d: inp_mtx not locked", __FILE__, __LINE__)) +#define SCTP_INP_WLOCK_ASSERT(_inp) \ + KASSERT(pthread_mutex_trylock(&(_inp)->inp_mtx) == EBUSY, ("%s:%d: inp_mtx not locked", __FILE__, __LINE__)) #define SCTP_INP_INCR_REF(_inp) atomic_add_int(&((_inp)->refcount), 1) -#define SCTP_INP_DECR_REF(_inp) atomic_add_int(&((_inp)->refcount), -1) +#define SCTP_INP_DECR_REF(_inp) atomic_subtract_int(&((_inp)->refcount), 1) #define SCTP_TCB_SEND_LOCK_INIT(_tcb) \ (void)pthread_mutex_init(&(_tcb)->tcb_send_mtx, &SCTP_BASE_VAR(mtx_attr)) @@ -386,15 +429,17 @@ (void)pthread_mutex_destroy(&(_tcb)->tcb_send_mtx) #ifdef INVARIANTS #define SCTP_TCB_SEND_LOCK(_tcb) \ - KASSERT(pthread_mutex_lock(&(_tcb)->tcb_send_mtx) == 0, ("%s: tcb_send_mtx already locked", __func__)) + KASSERT(pthread_mutex_lock(&(_tcb)->tcb_send_mtx) == 0, ("%s:%d: tcb_send_mtx already locked", __FILE__, __LINE__)) #define SCTP_TCB_SEND_UNLOCK(_tcb) \ - KASSERT(pthread_mutex_unlock(&(_tcb)->tcb_send_mtx) == 0, ("%s: tcb_send_mtx not locked", __func__)) + KASSERT(pthread_mutex_unlock(&(_tcb)->tcb_send_mtx) == 0, ("%s:%d: tcb_send_mtx not locked", __FILE__, __LINE__)) #else #define SCTP_TCB_SEND_LOCK(_tcb) \ (void)pthread_mutex_lock(&(_tcb)->tcb_send_mtx) #define SCTP_TCB_SEND_UNLOCK(_tcb) \ (void)pthread_mutex_unlock(&(_tcb)->tcb_send_mtx) #endif +#define SCTP_TCB_SEND_LOCK_ASSERT(_tcb) \ + KASSERT(pthread_mutex_trylock(&(_tcb)->tcb_send_mtx) == EBUSY, ("%s:%d: tcb_send_mtx not locked", __FILE__, __LINE__)) #define SCTP_ASOC_CREATE_LOCK_INIT(_inp) \ (void)pthread_mutex_init(&(_inp)->inp_create_mtx, &SCTP_BASE_VAR(mtx_attr)) @@ -402,17 +447,17 @@ (void)pthread_mutex_destroy(&(_inp)->inp_create_mtx) #ifdef INVARIANTS #ifdef SCTP_LOCK_LOGGING -#define SCTP_ASOC_CREATE_LOCK(_inp) do { \ - if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \ - sctp_log_lock(_inp, NULL, SCTP_LOG_LOCK_CREATE); \ - KASSERT(pthread_mutex_lock(&(_inp)->inp_create_mtx) == 0, ("%s: inp_create_mtx already locked", __func__)) \ +#define SCTP_ASOC_CREATE_LOCK(_inp) do { \ + if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \ + sctp_log_lock(_inp, NULL, SCTP_LOG_LOCK_CREATE); \ + KASSERT(pthread_mutex_lock(&(_inp)->inp_create_mtx) == 0, ("%s:%d: inp_create_mtx already locked", __FILE__, __LINE__)); \ } while (0) #else #define SCTP_ASOC_CREATE_LOCK(_inp) \ - KASSERT(pthread_mutex_lock(&(_inp)->inp_create_mtx) == 0, ("%s: inp_create_mtx already locked", __func__)) + KASSERT(pthread_mutex_lock(&(_inp)->inp_create_mtx) == 0, ("%s:%d: inp_create_mtx already locked", __FILE__, __LINE__)) #endif #define SCTP_ASOC_CREATE_UNLOCK(_inp) \ - KASSERT(pthread_mutex_unlock(&(_inp)->inp_create_mtx) == 0, ("%s: inp_create_mtx not locked", __func__)) + KASSERT(pthread_mutex_unlock(&(_inp)->inp_create_mtx) == 0, ("%s:%d: inp_create_mtx not locked", __FILE__, __LINE__)) #else #ifdef SCTP_LOCK_LOGGING #define SCTP_ASOC_CREATE_LOCK(_inp) do { \ @@ -441,17 +486,17 @@ (void)pthread_mutex_destroy(&(_tcb)->tcb_mtx) #ifdef INVARIANTS #ifdef SCTP_LOCK_LOGGING -#define SCTP_TCB_LOCK(_tcb) do { \ - if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \ - sctp_log_lock(_tcb->sctp_ep, _tcb, SCTP_LOG_LOCK_TCB); \ - KASSERT(pthread_mutex_lock(&(_tcb)->tcb_mtx) == 0, ("%s: tcb_mtx already locked", __func__)) \ +#define SCTP_TCB_LOCK(_tcb) do { \ + if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \ + sctp_log_lock(_tcb->sctp_ep, _tcb, SCTP_LOG_LOCK_TCB); \ + KASSERT(pthread_mutex_lock(&(_tcb)->tcb_mtx) == 0, ("%s:%d: tcb_mtx already locked", __FILE__, __LINE__)) \ } while (0) #else #define SCTP_TCB_LOCK(_tcb) \ - KASSERT(pthread_mutex_lock(&(_tcb)->tcb_mtx) == 0, ("%s: tcb_mtx already locked", __func__)) + KASSERT(pthread_mutex_lock(&(_tcb)->tcb_mtx) == 0, ("%s:%d: tcb_mtx already locked", __FILE__, __LINE__)) #endif #define SCTP_TCB_UNLOCK(_tcb) \ - KASSERT(pthread_mutex_unlock(&(_tcb)->tcb_mtx) == 0, ("%s: tcb_mtx not locked", __func__)) + KASSERT(pthread_mutex_unlock(&(_tcb)->tcb_mtx) == 0, ("%s:%d: tcb_mtx not locked", __FILE__, __LINE__)) #else #ifdef SCTP_LOCK_LOGGING #define SCTP_TCB_LOCK(_tcb) do { \ @@ -466,7 +511,7 @@ #define SCTP_TCB_UNLOCK(_tcb) (void)pthread_mutex_unlock(&(_tcb)->tcb_mtx) #endif #define SCTP_TCB_LOCK_ASSERT(_tcb) \ - KASSERT(pthread_mutex_trylock(&(_tcb)->tcb_mtx) == EBUSY, ("%s: tcb_mtx not locked", __func__)) + KASSERT(pthread_mutex_trylock(&(_tcb)->tcb_mtx) == EBUSY, ("%s:%d: tcb_mtx not locked", __FILE__, __LINE__)) #define SCTP_TCB_TRYLOCK(_tcb) (!(pthread_mutex_trylock(&(_tcb)->tcb_mtx))) #endif @@ -484,7 +529,7 @@ /* socket locks */ -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) #define SOCKBUF_LOCK_ASSERT(_so_buf) #define SOCKBUF_LOCK(_so_buf) \ EnterCriticalSection(&(_so_buf)->sb_mtx) @@ -496,12 +541,12 @@ SOCKBUF_UNLOCK(&(_so)->so_rcv) #else #define SOCKBUF_LOCK_ASSERT(_so_buf) \ - KASSERT(pthread_mutex_trylock(SOCKBUF_MTX(_so_buf)) == EBUSY, ("%s: socket buffer not locked", __func__)) + KASSERT(pthread_mutex_trylock(SOCKBUF_MTX(_so_buf)) == EBUSY, ("%s:%d: socket buffer not locked", __FILE__, __LINE__)) #ifdef INVARIANTS #define SOCKBUF_LOCK(_so_buf) \ - KASSERT(pthread_mutex_lock(SOCKBUF_MTX(_so_buf)) == 0, ("%s: sockbuf_mtx already locked", __func__)) + KASSERT(pthread_mutex_lock(SOCKBUF_MTX(_so_buf)) == 0, ("%s:%d: sockbuf_mtx already locked", __FILE__, __LINE__)) #define SOCKBUF_UNLOCK(_so_buf) \ - KASSERT(pthread_mutex_unlock(SOCKBUF_MTX(_so_buf)) == 0, ("%s: sockbuf_mtx not locked", __func__)) + KASSERT(pthread_mutex_unlock(SOCKBUF_MTX(_so_buf)) == 0, ("%s:%d: sockbuf_mtx not locked", __FILE__, __LINE__)) #else #define SOCKBUF_LOCK(_so_buf) \ pthread_mutex_lock(SOCKBUF_MTX(_so_buf)) @@ -519,8 +564,9 @@ #define SCTP_STATLOG_UNLOCK() #define SCTP_STATLOG_DESTROY() -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) /* address list locks */ +#if WINVER < 0x0600 #define SCTP_IPI_ADDR_INIT() \ InitializeCriticalSection(&SCTP_BASE_INFO(ipi_addr_mtx)) #define SCTP_IPI_ADDR_DESTROY() \ @@ -533,7 +579,23 @@ EnterCriticalSection(&SCTP_BASE_INFO(ipi_addr_mtx)) #define SCTP_IPI_ADDR_WUNLOCK() \ LeaveCriticalSection(&SCTP_BASE_INFO(ipi_addr_mtx)) - +#define SCTP_IPI_ADDR_LOCK_ASSERT() +#define SCTP_IPI_ADDR_WLOCK_ASSERT() +#else +#define SCTP_IPI_ADDR_INIT() \ + InitializeSRWLock(&SCTP_BASE_INFO(ipi_addr_mtx)) +#define SCTP_IPI_ADDR_DESTROY() +#define SCTP_IPI_ADDR_RLOCK() \ + AcquireSRWLockShared(&SCTP_BASE_INFO(ipi_addr_mtx)) +#define SCTP_IPI_ADDR_RUNLOCK() \ + ReleaseSRWLockShared(&SCTP_BASE_INFO(ipi_addr_mtx)) +#define SCTP_IPI_ADDR_WLOCK() \ + AcquireSRWLockExclusive(&SCTP_BASE_INFO(ipi_addr_mtx)) +#define SCTP_IPI_ADDR_WUNLOCK() \ + ReleaseSRWLockExclusive(&SCTP_BASE_INFO(ipi_addr_mtx)) +#define SCTP_IPI_ADDR_LOCK_ASSERT() +#define SCTP_IPI_ADDR_WLOCK_ASSERT() +#endif /* iterator locks */ #define SCTP_ITERATOR_LOCK_INIT() \ @@ -554,31 +616,33 @@ #define SCTP_IPI_ITERATOR_WQ_UNLOCK() \ LeaveCriticalSection(&sctp_it_ctl.ipi_iterator_wq_mtx) -#else /* end of __Userspace_os_Windows */ +#else /* address list locks */ #define SCTP_IPI_ADDR_INIT() \ - (void)pthread_mutex_init(&SCTP_BASE_INFO(ipi_addr_mtx), &SCTP_BASE_VAR(mtx_attr)) + (void)pthread_rwlock_init(&SCTP_BASE_INFO(ipi_addr_mtx), &SCTP_BASE_VAR(rwlock_attr)) #define SCTP_IPI_ADDR_DESTROY() \ - (void)pthread_mutex_destroy(&SCTP_BASE_INFO(ipi_addr_mtx)) + (void)pthread_rwlock_destroy(&SCTP_BASE_INFO(ipi_addr_mtx)) #ifdef INVARIANTS #define SCTP_IPI_ADDR_RLOCK() \ - KASSERT(pthread_mutex_lock(&SCTP_BASE_INFO(ipi_addr_mtx)) == 0, ("%s: ipi_addr_mtx already locked", __func__)) + KASSERT(pthread_rwlock_rdlock(&SCTP_BASE_INFO(ipi_addr_mtx)) == 0, ("%s:%d: ipi_addr_mtx already locked", __FILE__, __LINE__)) #define SCTP_IPI_ADDR_RUNLOCK() \ - KASSERT(pthread_mutex_unlock(&SCTP_BASE_INFO(ipi_addr_mtx)) == 0, ("%s: ipi_addr_mtx not locked", __func__)) + KASSERT(pthread_rwlock_unlock(&SCTP_BASE_INFO(ipi_addr_mtx)) == 0, ("%s:%d: ipi_addr_mtx not locked", __FILE__, __LINE__)) #define SCTP_IPI_ADDR_WLOCK() \ - KASSERT(pthread_mutex_lock(&SCTP_BASE_INFO(ipi_addr_mtx)) == 0, ("%s: ipi_addr_mtx already locked", __func__)) + KASSERT(pthread_rwlock_wrlock(&SCTP_BASE_INFO(ipi_addr_mtx)) == 0, ("%s:%d: ipi_addr_mtx already locked", __FILE__, __LINE__)) #define SCTP_IPI_ADDR_WUNLOCK() \ - KASSERT(pthread_mutex_unlock(&SCTP_BASE_INFO(ipi_addr_mtx)) == 0, ("%s: ipi_addr_mtx not locked", __func__)) + KASSERT(pthread_rwlock_unlock(&SCTP_BASE_INFO(ipi_addr_mtx)) == 0, ("%s:%d: ipi_addr_mtx not locked", __FILE__, __LINE__)) #else #define SCTP_IPI_ADDR_RLOCK() \ - (void)pthread_mutex_lock(&SCTP_BASE_INFO(ipi_addr_mtx)) + (void)pthread_rwlock_rdlock(&SCTP_BASE_INFO(ipi_addr_mtx)) #define SCTP_IPI_ADDR_RUNLOCK() \ - (void)pthread_mutex_unlock(&SCTP_BASE_INFO(ipi_addr_mtx)) + (void)pthread_rwlock_unlock(&SCTP_BASE_INFO(ipi_addr_mtx)) #define SCTP_IPI_ADDR_WLOCK() \ - (void)pthread_mutex_lock(&SCTP_BASE_INFO(ipi_addr_mtx)) + (void)pthread_rwlock_wrlock(&SCTP_BASE_INFO(ipi_addr_mtx)) #define SCTP_IPI_ADDR_WUNLOCK() \ - (void)pthread_mutex_unlock(&SCTP_BASE_INFO(ipi_addr_mtx)) + (void)pthread_rwlock_unlock(&SCTP_BASE_INFO(ipi_addr_mtx)) #endif +#define SCTP_IPI_ADDR_LOCK_ASSERT() +#define SCTP_IPI_ADDR_WLOCK_ASSERT() /* iterator locks */ #define SCTP_ITERATOR_LOCK_INIT() \ @@ -587,9 +651,9 @@ (void)pthread_mutex_destroy(&sctp_it_ctl.it_mtx) #ifdef INVARIANTS #define SCTP_ITERATOR_LOCK() \ - KASSERT(pthread_mutex_lock(&sctp_it_ctl.it_mtx) == 0, ("%s: it_mtx already locked", __func__)) + KASSERT(pthread_mutex_lock(&sctp_it_ctl.it_mtx) == 0, ("%s:%d: it_mtx already locked", __FILE__, __LINE__)) #define SCTP_ITERATOR_UNLOCK() \ - KASSERT(pthread_mutex_unlock(&sctp_it_ctl.it_mtx) == 0, ("%s: it_mtx not locked", __func__)) + KASSERT(pthread_mutex_unlock(&sctp_it_ctl.it_mtx) == 0, ("%s:%d: it_mtx not locked", __FILE__, __LINE__)) #else #define SCTP_ITERATOR_LOCK() \ (void)pthread_mutex_lock(&sctp_it_ctl.it_mtx) @@ -603,9 +667,9 @@ (void)pthread_mutex_destroy(&sctp_it_ctl.ipi_iterator_wq_mtx) #ifdef INVARIANTS #define SCTP_IPI_ITERATOR_WQ_LOCK() \ - KASSERT(pthread_mutex_lock(&sctp_it_ctl.ipi_iterator_wq_mtx) == 0, ("%s: ipi_iterator_wq_mtx already locked", __func__)) + KASSERT(pthread_mutex_lock(&sctp_it_ctl.ipi_iterator_wq_mtx) == 0, ("%s:%d: ipi_iterator_wq_mtx already locked", __FILE__, __LINE__)) #define SCTP_IPI_ITERATOR_WQ_UNLOCK() \ - KASSERT(pthread_mutex_unlock(&sctp_it_ctl.ipi_iterator_wq_mtx) == 0, ("%s: ipi_iterator_wq_mtx not locked", __func__)) + KASSERT(pthread_mutex_unlock(&sctp_it_ctl.ipi_iterator_wq_mtx) == 0, ("%s:%d: ipi_iterator_wq_mtx not locked", __FILE__, __LINE__)) #else #define SCTP_IPI_ITERATOR_WQ_LOCK() \ (void)pthread_mutex_lock(&sctp_it_ctl.ipi_iterator_wq_mtx) diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_sha1.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_sha1.c index aba616069b..8472c3a1c0 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_sha1.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_sha1.c @@ -80,13 +80,31 @@ sctp_sha1_final(unsigned char *digest, struct sctp_sha1_context *ctx) { SHA1_Final(digest, &ctx->sha_ctx); } +#elif defined(SCTP_USE_MBEDTLS_SHA1) +void +sctp_sha1_init(struct sctp_sha1_context *ctx) +{ + mbedtls_sha1_init(&ctx->sha1_ctx); + mbedtls_sha1_starts_ret(&ctx->sha1_ctx); +} +void +sctp_sha1_update(struct sctp_sha1_context *ctx, const unsigned char *ptr, unsigned int siz) +{ + mbedtls_sha1_update_ret(&ctx->sha1_ctx, ptr, siz); +} + +void +sctp_sha1_final(unsigned char *digest, struct sctp_sha1_context *ctx) +{ + mbedtls_sha1_finish_ret(&ctx->sha1_ctx, digest); +} #else #include -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) && defined(__Userspace__) #include -#elif !defined(__Windows__) +#elif !(defined(_WIN32) && !defined(__Userspace__)) #include #endif diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_sha1.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_sha1.h index 6d6a05c10c..9ff4ff7bdc 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_sha1.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_sha1.h @@ -32,7 +32,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include __FBSDID("$FreeBSD$"); #endif @@ -43,18 +43,11 @@ __FBSDID("$FreeBSD$"); #include #if defined(SCTP_USE_NSS_SHA1) -#if defined(__Userspace_os_Darwin) -/* The NSS sources require __APPLE__ to be defined. - * XXX: Remove this ugly hack once the platform defines have been cleaned up. - */ -#define __APPLE__ -#endif #include -#if defined(__Userspace_os_Darwin) -#undef __APPLE__ -#endif #elif defined(SCTP_USE_OPENSSL_SHA1) #include +#elif defined(SCTP_USE_MBEDTLS_SHA1) +#include #endif struct sctp_sha1_context { @@ -62,6 +55,8 @@ struct sctp_sha1_context { struct PK11Context *pk11_ctx; #elif defined(SCTP_USE_OPENSSL_SHA1) SHA_CTX sha_ctx; +#elif defined(SCTP_USE_MBEDTLS_SHA1) + mbedtls_sha1_context sha1_ctx; #else unsigned int A; unsigned int B; @@ -83,7 +78,7 @@ struct sctp_sha1_context { #endif }; -#if (defined(__APPLE__) && defined(KERNEL)) +#if (defined(__APPLE__) && !defined(__Userspace__) && defined(KERNEL)) #ifndef _KERNEL #define _KERNEL #endif diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_ss_functions.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_ss_functions.c index 59ef9cdfa0..8db0f47ae0 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_ss_functions.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_ss_functions.c @@ -28,9 +28,9 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_ss_functions.c 345505 2019-03-25 16:40:54Z tuexen $"); +__FBSDID("$FreeBSD$"); #endif #include @@ -46,22 +46,20 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_ss_functions.c 345505 2019-03-25 16:40 static void sctp_ss_default_add(struct sctp_tcb *, struct sctp_association *, struct sctp_stream_out *, - struct sctp_stream_queue_pending *, int); + struct sctp_stream_queue_pending *); static void sctp_ss_default_remove(struct sctp_tcb *, struct sctp_association *, struct sctp_stream_out *, - struct sctp_stream_queue_pending *, int); + struct sctp_stream_queue_pending *); static void -sctp_ss_default_init(struct sctp_tcb *stcb, struct sctp_association *asoc, - int holds_lock) +sctp_ss_default_init(struct sctp_tcb *stcb, struct sctp_association *asoc) { uint16_t i; - if (holds_lock == 0) { - SCTP_TCB_SEND_LOCK(stcb); - } + SCTP_TCB_SEND_LOCK_ASSERT(stcb); + asoc->ss_data.locked_on_sending = NULL; asoc->ss_data.last_out_stream = NULL; TAILQ_INIT(&asoc->ss_data.out.wheel); @@ -71,36 +69,29 @@ sctp_ss_default_init(struct sctp_tcb *stcb, struct sctp_association *asoc, * been changed. We need to add all stream queues * to the wheel. */ - for (i = 0; i < stcb->asoc.streamoutcnt; i++) { - stcb->asoc.ss_functions.sctp_ss_add_to_stream(stcb, &stcb->asoc, - &stcb->asoc.strmout[i], - NULL, 1); - } - if (holds_lock == 0) { - SCTP_TCB_SEND_UNLOCK(stcb); + for (i = 0; i < asoc->streamoutcnt; i++) { + stcb->asoc.ss_functions.sctp_ss_add_to_stream(stcb, asoc, + &asoc->strmout[i], + NULL); } return; } static void sctp_ss_default_clear(struct sctp_tcb *stcb, struct sctp_association *asoc, - int clear_values SCTP_UNUSED, int holds_lock) + bool clear_values SCTP_UNUSED) { - if (holds_lock == 0) { - SCTP_TCB_SEND_LOCK(stcb); - } + SCTP_TCB_SEND_LOCK_ASSERT(stcb); + while (!TAILQ_EMPTY(&asoc->ss_data.out.wheel)) { struct sctp_stream_out *strq; strq = TAILQ_FIRST(&asoc->ss_data.out.wheel); - TAILQ_REMOVE(&asoc->ss_data.out.wheel, strq, ss_params.rr.next_spoke); - strq->ss_params.rr.next_spoke.tqe_next = NULL; - strq->ss_params.rr.next_spoke.tqe_prev = NULL; + KASSERT(strq->ss_params.scheduled, ("strq %p not scheduled", (void *)strq)); + TAILQ_REMOVE(&asoc->ss_data.out.wheel, strq, ss_params.ss.rr.next_spoke); + strq->ss_params.scheduled = false; } asoc->ss_data.last_out_stream = NULL; - if (holds_lock == 0) { - SCTP_TCB_SEND_UNLOCK(stcb); - } return; } @@ -115,97 +106,89 @@ sctp_ss_default_init_stream(struct sctp_tcb *stcb, struct sctp_stream_out *strq, stcb->asoc.ss_data.last_out_stream = strq; } } - strq->ss_params.rr.next_spoke.tqe_next = NULL; - strq->ss_params.rr.next_spoke.tqe_prev = NULL; + strq->ss_params.scheduled = false; return; } static void sctp_ss_default_add(struct sctp_tcb *stcb, struct sctp_association *asoc, struct sctp_stream_out *strq, - struct sctp_stream_queue_pending *sp SCTP_UNUSED, int holds_lock) + struct sctp_stream_queue_pending *sp SCTP_UNUSED) { - if (holds_lock == 0) { - SCTP_TCB_SEND_LOCK(stcb); - } + SCTP_TCB_SEND_LOCK_ASSERT(stcb); + /* Add to wheel if not already on it and stream queue not empty */ - if (!TAILQ_EMPTY(&strq->outqueue) && - (strq->ss_params.rr.next_spoke.tqe_next == NULL) && - (strq->ss_params.rr.next_spoke.tqe_prev == NULL)) { + if (!TAILQ_EMPTY(&strq->outqueue) && !strq->ss_params.scheduled) { TAILQ_INSERT_TAIL(&asoc->ss_data.out.wheel, - strq, ss_params.rr.next_spoke); - } - if (holds_lock == 0) { - SCTP_TCB_SEND_UNLOCK(stcb); + strq, ss_params.ss.rr.next_spoke); + strq->ss_params.scheduled = true; } return; } -static int +static bool sctp_ss_default_is_empty(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_association *asoc) { - if (TAILQ_EMPTY(&asoc->ss_data.out.wheel)) { - return (1); - } else { - return (0); - } + return (TAILQ_EMPTY(&asoc->ss_data.out.wheel)); } static void sctp_ss_default_remove(struct sctp_tcb *stcb, struct sctp_association *asoc, struct sctp_stream_out *strq, - struct sctp_stream_queue_pending *sp SCTP_UNUSED, int holds_lock) + struct sctp_stream_queue_pending *sp SCTP_UNUSED) { - if (holds_lock == 0) { - SCTP_TCB_SEND_LOCK(stcb); - } + SCTP_TCB_SEND_LOCK_ASSERT(stcb); + /* Remove from wheel if stream queue is empty and actually is on the wheel */ - if (TAILQ_EMPTY(&strq->outqueue) && - (strq->ss_params.rr.next_spoke.tqe_next != NULL || - strq->ss_params.rr.next_spoke.tqe_prev != NULL)) { + if (TAILQ_EMPTY(&strq->outqueue) && strq->ss_params.scheduled) { if (asoc->ss_data.last_out_stream == strq) { asoc->ss_data.last_out_stream = TAILQ_PREV(asoc->ss_data.last_out_stream, - sctpwheel_listhead, - ss_params.rr.next_spoke); + sctpwheel_listhead, + ss_params.ss.rr.next_spoke); if (asoc->ss_data.last_out_stream == NULL) { asoc->ss_data.last_out_stream = TAILQ_LAST(&asoc->ss_data.out.wheel, - sctpwheel_listhead); + sctpwheel_listhead); } if (asoc->ss_data.last_out_stream == strq) { asoc->ss_data.last_out_stream = NULL; } } - TAILQ_REMOVE(&asoc->ss_data.out.wheel, strq, ss_params.rr.next_spoke); - strq->ss_params.rr.next_spoke.tqe_next = NULL; - strq->ss_params.rr.next_spoke.tqe_prev = NULL; - } - if (holds_lock == 0) { - SCTP_TCB_SEND_UNLOCK(stcb); + if (asoc->ss_data.locked_on_sending == strq) { + asoc->ss_data.locked_on_sending = NULL; + } + TAILQ_REMOVE(&asoc->ss_data.out.wheel, strq, ss_params.ss.rr.next_spoke); + strq->ss_params.scheduled = false; } return; } - static struct sctp_stream_out * sctp_ss_default_select(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net, struct sctp_association *asoc) { struct sctp_stream_out *strq, *strqt; - if (asoc->ss_data.locked_on_sending) { + if (asoc->ss_data.locked_on_sending != NULL) { + KASSERT(asoc->ss_data.locked_on_sending->ss_params.scheduled, + ("locked_on_sending %p not scheduled", + (void *)asoc->ss_data.locked_on_sending)); return (asoc->ss_data.locked_on_sending); } strqt = asoc->ss_data.last_out_stream; + KASSERT(strqt == NULL || strqt->ss_params.scheduled, + ("last_out_stream %p not scheduled", (void *)strqt)); default_again: /* Find the next stream to use */ if (strqt == NULL) { strq = TAILQ_FIRST(&asoc->ss_data.out.wheel); } else { - strq = TAILQ_NEXT(strqt, ss_params.rr.next_spoke); + strq = TAILQ_NEXT(strqt, ss_params.ss.rr.next_spoke); if (strq == NULL) { strq = TAILQ_FIRST(&asoc->ss_data.out.wheel); } } + KASSERT(strq == NULL || strq->ss_params.scheduled, + ("strq %p not scheduled", (void *)strq)); /* If CMT is off, we must validate that * the stream in question has the first @@ -243,16 +226,18 @@ sctp_ss_default_scheduled(struct sctp_tcb *stcb, { struct sctp_stream_queue_pending *sp; + KASSERT(strq != NULL, ("strq is NULL")); + KASSERT(strq->ss_params.scheduled, ("strq %p is not scheduled", (void *)strq)); asoc->ss_data.last_out_stream = strq; - if (stcb->asoc.idata_supported == 0) { + if (asoc->idata_supported == 0) { sp = TAILQ_FIRST(&strq->outqueue); if ((sp != NULL) && (sp->some_taken == 1)) { - stcb->asoc.ss_data.locked_on_sending = strq; + asoc->ss_data.locked_on_sending = strq; } else { - stcb->asoc.ss_data.locked_on_sending = NULL; + asoc->ss_data.locked_on_sending = NULL; } } else { - stcb->asoc.ss_data.locked_on_sending = NULL; + asoc->ss_data.locked_on_sending = NULL; } return; } @@ -281,24 +266,24 @@ sctp_ss_default_set_value(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_associa return (-1); } -static int +static bool sctp_ss_default_is_user_msgs_incomplete(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_association *asoc) { struct sctp_stream_out *strq; struct sctp_stream_queue_pending *sp; if (asoc->stream_queue_cnt != 1) { - return (0); + return (false); } strq = asoc->ss_data.locked_on_sending; if (strq == NULL) { - return (0); + return (false); } sp = TAILQ_FIRST(&strq->outqueue); if (sp == NULL) { - return (0); + return (false); } - return (!sp->msg_is_complete); + return (sp->msg_is_complete == 0); } /* @@ -308,32 +293,27 @@ sctp_ss_default_is_user_msgs_incomplete(struct sctp_tcb *stcb SCTP_UNUSED, struc static void sctp_ss_rr_add(struct sctp_tcb *stcb, struct sctp_association *asoc, struct sctp_stream_out *strq, - struct sctp_stream_queue_pending *sp SCTP_UNUSED, int holds_lock) + struct sctp_stream_queue_pending *sp SCTP_UNUSED) { struct sctp_stream_out *strqt; - if (holds_lock == 0) { - SCTP_TCB_SEND_LOCK(stcb); - } - if (!TAILQ_EMPTY(&strq->outqueue) && - (strq->ss_params.rr.next_spoke.tqe_next == NULL) && - (strq->ss_params.rr.next_spoke.tqe_prev == NULL)) { + SCTP_TCB_SEND_LOCK_ASSERT(stcb); + + if (!TAILQ_EMPTY(&strq->outqueue) && !strq->ss_params.scheduled) { if (TAILQ_EMPTY(&asoc->ss_data.out.wheel)) { - TAILQ_INSERT_HEAD(&asoc->ss_data.out.wheel, strq, ss_params.rr.next_spoke); + TAILQ_INSERT_HEAD(&asoc->ss_data.out.wheel, strq, ss_params.ss.rr.next_spoke); } else { strqt = TAILQ_FIRST(&asoc->ss_data.out.wheel); while (strqt != NULL && (strqt->sid < strq->sid)) { - strqt = TAILQ_NEXT(strqt, ss_params.rr.next_spoke); + strqt = TAILQ_NEXT(strqt, ss_params.ss.rr.next_spoke); } if (strqt != NULL) { - TAILQ_INSERT_BEFORE(strqt, strq, ss_params.rr.next_spoke); + TAILQ_INSERT_BEFORE(strqt, strq, ss_params.ss.rr.next_spoke); } else { - TAILQ_INSERT_TAIL(&asoc->ss_data.out.wheel, strq, ss_params.rr.next_spoke); + TAILQ_INSERT_TAIL(&asoc->ss_data.out.wheel, strq, ss_params.ss.rr.next_spoke); } } - } - if (holds_lock == 0) { - SCTP_TCB_SEND_UNLOCK(stcb); + strq->ss_params.scheduled = true; } return; } @@ -357,16 +337,20 @@ sctp_ss_rrp_packet_done(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net struct sctp_stream_out *strq, *strqt; strqt = asoc->ss_data.last_out_stream; + KASSERT(strqt == NULL || strqt->ss_params.scheduled, + ("last_out_stream %p not scheduled", (void *)strqt)); rrp_again: /* Find the next stream to use */ if (strqt == NULL) { strq = TAILQ_FIRST(&asoc->ss_data.out.wheel); } else { - strq = TAILQ_NEXT(strqt, ss_params.rr.next_spoke); + strq = TAILQ_NEXT(strqt, ss_params.ss.rr.next_spoke); if (strq == NULL) { strq = TAILQ_FIRST(&asoc->ss_data.out.wheel); } } + KASSERT(strq == NULL || strq->ss_params.scheduled, + ("strq %p not scheduled", (void *)strq)); /* If CMT is off, we must validate that * the stream in question has the first @@ -396,34 +380,28 @@ rrp_again: return; } - /* * Priority algorithm. * Always prefers streams based on their priority id. */ static void sctp_ss_prio_clear(struct sctp_tcb *stcb, struct sctp_association *asoc, - int clear_values, int holds_lock) + bool clear_values) { - if (holds_lock == 0) { - SCTP_TCB_SEND_LOCK(stcb); - } + SCTP_TCB_SEND_LOCK_ASSERT(stcb); + while (!TAILQ_EMPTY(&asoc->ss_data.out.wheel)) { struct sctp_stream_out *strq; strq = TAILQ_FIRST(&asoc->ss_data.out.wheel); + KASSERT(strq->ss_params.scheduled, ("strq %p not scheduled", (void *)strq)); if (clear_values) { - strq->ss_params.prio.priority = 0; + strq->ss_params.ss.prio.priority = 0; } - TAILQ_REMOVE(&asoc->ss_data.out.wheel, strq, ss_params.prio.next_spoke); - strq->ss_params.prio.next_spoke.tqe_next = NULL; - strq->ss_params.prio.next_spoke.tqe_prev = NULL; - + TAILQ_REMOVE(&asoc->ss_data.out.wheel, strq, ss_params.ss.prio.next_spoke); + strq->ss_params.scheduled = false; } asoc->ss_data.last_out_stream = NULL; - if (holds_lock == 0) { - SCTP_TCB_SEND_UNLOCK(stcb); - } return; } @@ -438,79 +416,68 @@ sctp_ss_prio_init_stream(struct sctp_tcb *stcb, struct sctp_stream_out *strq, st stcb->asoc.ss_data.last_out_stream = strq; } } - strq->ss_params.prio.next_spoke.tqe_next = NULL; - strq->ss_params.prio.next_spoke.tqe_prev = NULL; + strq->ss_params.scheduled = false; if (with_strq != NULL) { - strq->ss_params.prio.priority = with_strq->ss_params.prio.priority; + strq->ss_params.ss.prio.priority = with_strq->ss_params.ss.prio.priority; } else { - strq->ss_params.prio.priority = 0; + strq->ss_params.ss.prio.priority = 0; } return; } static void sctp_ss_prio_add(struct sctp_tcb *stcb, struct sctp_association *asoc, - struct sctp_stream_out *strq, struct sctp_stream_queue_pending *sp SCTP_UNUSED, - int holds_lock) + struct sctp_stream_out *strq, struct sctp_stream_queue_pending *sp SCTP_UNUSED) { struct sctp_stream_out *strqt; - if (holds_lock == 0) { - SCTP_TCB_SEND_LOCK(stcb); - } + SCTP_TCB_SEND_LOCK_ASSERT(stcb); + /* Add to wheel if not already on it and stream queue not empty */ - if (!TAILQ_EMPTY(&strq->outqueue) && - (strq->ss_params.prio.next_spoke.tqe_next == NULL) && - (strq->ss_params.prio.next_spoke.tqe_prev == NULL)) { + if (!TAILQ_EMPTY(&strq->outqueue) && !strq->ss_params.scheduled) { if (TAILQ_EMPTY(&asoc->ss_data.out.wheel)) { - TAILQ_INSERT_HEAD(&asoc->ss_data.out.wheel, strq, ss_params.prio.next_spoke); + TAILQ_INSERT_HEAD(&asoc->ss_data.out.wheel, strq, ss_params.ss.prio.next_spoke); } else { strqt = TAILQ_FIRST(&asoc->ss_data.out.wheel); - while (strqt != NULL && strqt->ss_params.prio.priority < strq->ss_params.prio.priority) { - strqt = TAILQ_NEXT(strqt, ss_params.prio.next_spoke); + while (strqt != NULL && strqt->ss_params.ss.prio.priority < strq->ss_params.ss.prio.priority) { + strqt = TAILQ_NEXT(strqt, ss_params.ss.prio.next_spoke); } if (strqt != NULL) { - TAILQ_INSERT_BEFORE(strqt, strq, ss_params.prio.next_spoke); + TAILQ_INSERT_BEFORE(strqt, strq, ss_params.ss.prio.next_spoke); } else { - TAILQ_INSERT_TAIL(&asoc->ss_data.out.wheel, strq, ss_params.prio.next_spoke); + TAILQ_INSERT_TAIL(&asoc->ss_data.out.wheel, strq, ss_params.ss.prio.next_spoke); } } - } - if (holds_lock == 0) { - SCTP_TCB_SEND_UNLOCK(stcb); + strq->ss_params.scheduled = true; } return; } static void sctp_ss_prio_remove(struct sctp_tcb *stcb, struct sctp_association *asoc, - struct sctp_stream_out *strq, struct sctp_stream_queue_pending *sp SCTP_UNUSED, - int holds_lock) + struct sctp_stream_out *strq, struct sctp_stream_queue_pending *sp SCTP_UNUSED) { - if (holds_lock == 0) { - SCTP_TCB_SEND_LOCK(stcb); - } + SCTP_TCB_SEND_LOCK_ASSERT(stcb); + /* Remove from wheel if stream queue is empty and actually is on the wheel */ - if (TAILQ_EMPTY(&strq->outqueue) && - (strq->ss_params.prio.next_spoke.tqe_next != NULL || - strq->ss_params.prio.next_spoke.tqe_prev != NULL)) { + if (TAILQ_EMPTY(&strq->outqueue) && strq->ss_params.scheduled) { if (asoc->ss_data.last_out_stream == strq) { - asoc->ss_data.last_out_stream = TAILQ_PREV(asoc->ss_data.last_out_stream, sctpwheel_listhead, - ss_params.prio.next_spoke); + asoc->ss_data.last_out_stream = TAILQ_PREV(asoc->ss_data.last_out_stream, + sctpwheel_listhead, + ss_params.ss.prio.next_spoke); if (asoc->ss_data.last_out_stream == NULL) { asoc->ss_data.last_out_stream = TAILQ_LAST(&asoc->ss_data.out.wheel, - sctpwheel_listhead); + sctpwheel_listhead); } if (asoc->ss_data.last_out_stream == strq) { asoc->ss_data.last_out_stream = NULL; } } - TAILQ_REMOVE(&asoc->ss_data.out.wheel, strq, ss_params.prio.next_spoke); - strq->ss_params.prio.next_spoke.tqe_next = NULL; - strq->ss_params.prio.next_spoke.tqe_prev = NULL; - } - if (holds_lock == 0) { - SCTP_TCB_SEND_UNLOCK(stcb); + if (asoc->ss_data.locked_on_sending == strq) { + asoc->ss_data.locked_on_sending = NULL; + } + TAILQ_REMOVE(&asoc->ss_data.out.wheel, strq, ss_params.ss.prio.next_spoke); + strq->ss_params.scheduled = false; } return; } @@ -521,20 +488,30 @@ sctp_ss_prio_select(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net, { struct sctp_stream_out *strq, *strqt, *strqn; + if (asoc->ss_data.locked_on_sending != NULL) { + KASSERT(asoc->ss_data.locked_on_sending->ss_params.scheduled, + ("locked_on_sending %p not scheduled", + (void *)asoc->ss_data.locked_on_sending)); + return (asoc->ss_data.locked_on_sending); + } strqt = asoc->ss_data.last_out_stream; + KASSERT(strqt == NULL || strqt->ss_params.scheduled, + ("last_out_stream %p not scheduled", (void *)strqt)); prio_again: /* Find the next stream to use */ if (strqt == NULL) { strq = TAILQ_FIRST(&asoc->ss_data.out.wheel); } else { - strqn = TAILQ_NEXT(strqt, ss_params.prio.next_spoke); + strqn = TAILQ_NEXT(strqt, ss_params.ss.prio.next_spoke); if (strqn != NULL && - strqn->ss_params.prio.priority == strqt->ss_params.prio.priority) { + strqn->ss_params.ss.prio.priority == strqt->ss_params.ss.prio.priority) { strq = strqn; } else { strq = TAILQ_FIRST(&asoc->ss_data.out.wheel); } } + KASSERT(strq == NULL || strq->ss_params.scheduled, + ("strq %p not scheduled", (void *)strq)); /* If CMT is off, we must validate that * the stream in question has the first @@ -570,7 +547,7 @@ sctp_ss_prio_get_value(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_associatio if (strq == NULL) { return (-1); } - *value = strq->ss_params.prio.priority; + *value = strq->ss_params.ss.prio.priority; return (1); } @@ -581,38 +558,34 @@ sctp_ss_prio_set_value(struct sctp_tcb *stcb, struct sctp_association *asoc, if (strq == NULL) { return (-1); } - strq->ss_params.prio.priority = value; - sctp_ss_prio_remove(stcb, asoc, strq, NULL, 1); - sctp_ss_prio_add(stcb, asoc, strq, NULL, 1); + strq->ss_params.ss.prio.priority = value; + sctp_ss_prio_remove(stcb, asoc, strq, NULL); + sctp_ss_prio_add(stcb, asoc, strq, NULL); return (1); } /* * Fair bandwidth algorithm. - * Maintains an equal troughput per stream. + * Maintains an equal throughput per stream. */ static void sctp_ss_fb_clear(struct sctp_tcb *stcb, struct sctp_association *asoc, - int clear_values, int holds_lock) + bool clear_values) { - if (holds_lock == 0) { - SCTP_TCB_SEND_LOCK(stcb); - } + SCTP_TCB_SEND_LOCK_ASSERT(stcb); + while (!TAILQ_EMPTY(&asoc->ss_data.out.wheel)) { struct sctp_stream_out *strq; strq = TAILQ_FIRST(&asoc->ss_data.out.wheel); + KASSERT(strq->ss_params.scheduled, ("strq %p not scheduled", (void *)strq)); if (clear_values) { - strq->ss_params.fb.rounds = -1; + strq->ss_params.ss.fb.rounds = -1; } - TAILQ_REMOVE(&asoc->ss_data.out.wheel, strq, ss_params.fb.next_spoke); - strq->ss_params.fb.next_spoke.tqe_next = NULL; - strq->ss_params.fb.next_spoke.tqe_prev = NULL; + TAILQ_REMOVE(&asoc->ss_data.out.wheel, strq, ss_params.ss.fb.next_spoke); + strq->ss_params.scheduled = false; } asoc->ss_data.last_out_stream = NULL; - if (holds_lock == 0) { - SCTP_TCB_SEND_UNLOCK(stcb); - } return; } @@ -627,66 +600,55 @@ sctp_ss_fb_init_stream(struct sctp_tcb *stcb, struct sctp_stream_out *strq, stru stcb->asoc.ss_data.last_out_stream = strq; } } - strq->ss_params.fb.next_spoke.tqe_next = NULL; - strq->ss_params.fb.next_spoke.tqe_prev = NULL; + strq->ss_params.scheduled = false; if (with_strq != NULL) { - strq->ss_params.fb.rounds = with_strq->ss_params.fb.rounds; + strq->ss_params.ss.fb.rounds = with_strq->ss_params.ss.fb.rounds; } else { - strq->ss_params.fb.rounds = -1; + strq->ss_params.ss.fb.rounds = -1; } return; } static void sctp_ss_fb_add(struct sctp_tcb *stcb, struct sctp_association *asoc, - struct sctp_stream_out *strq, struct sctp_stream_queue_pending *sp SCTP_UNUSED, - int holds_lock) + struct sctp_stream_out *strq, struct sctp_stream_queue_pending *sp SCTP_UNUSED) { - if (holds_lock == 0) { - SCTP_TCB_SEND_LOCK(stcb); - } - if (!TAILQ_EMPTY(&strq->outqueue) && - (strq->ss_params.fb.next_spoke.tqe_next == NULL) && - (strq->ss_params.fb.next_spoke.tqe_prev == NULL)) { - if (strq->ss_params.fb.rounds < 0) - strq->ss_params.fb.rounds = TAILQ_FIRST(&strq->outqueue)->length; - TAILQ_INSERT_TAIL(&asoc->ss_data.out.wheel, strq, ss_params.fb.next_spoke); - } - if (holds_lock == 0) { - SCTP_TCB_SEND_UNLOCK(stcb); + SCTP_TCB_SEND_LOCK_ASSERT(stcb); + + if (!TAILQ_EMPTY(&strq->outqueue) && !strq->ss_params.scheduled) { + if (strq->ss_params.ss.fb.rounds < 0) + strq->ss_params.ss.fb.rounds = TAILQ_FIRST(&strq->outqueue)->length; + TAILQ_INSERT_TAIL(&asoc->ss_data.out.wheel, strq, ss_params.ss.fb.next_spoke); + strq->ss_params.scheduled = true; } return; } static void sctp_ss_fb_remove(struct sctp_tcb *stcb, struct sctp_association *asoc, - struct sctp_stream_out *strq, struct sctp_stream_queue_pending *sp SCTP_UNUSED, - int holds_lock) + struct sctp_stream_out *strq, struct sctp_stream_queue_pending *sp SCTP_UNUSED) { - if (holds_lock == 0) { - SCTP_TCB_SEND_LOCK(stcb); - } + SCTP_TCB_SEND_LOCK_ASSERT(stcb); + /* Remove from wheel if stream queue is empty and actually is on the wheel */ - if (TAILQ_EMPTY(&strq->outqueue) && - (strq->ss_params.fb.next_spoke.tqe_next != NULL || - strq->ss_params.fb.next_spoke.tqe_prev != NULL)) { + if (TAILQ_EMPTY(&strq->outqueue) && strq->ss_params.scheduled) { if (asoc->ss_data.last_out_stream == strq) { - asoc->ss_data.last_out_stream = TAILQ_PREV(asoc->ss_data.last_out_stream, sctpwheel_listhead, - ss_params.fb.next_spoke); + asoc->ss_data.last_out_stream = TAILQ_PREV(asoc->ss_data.last_out_stream, + sctpwheel_listhead, + ss_params.ss.fb.next_spoke); if (asoc->ss_data.last_out_stream == NULL) { asoc->ss_data.last_out_stream = TAILQ_LAST(&asoc->ss_data.out.wheel, - sctpwheel_listhead); + sctpwheel_listhead); } if (asoc->ss_data.last_out_stream == strq) { asoc->ss_data.last_out_stream = NULL; } } - TAILQ_REMOVE(&asoc->ss_data.out.wheel, strq, ss_params.fb.next_spoke); - strq->ss_params.fb.next_spoke.tqe_next = NULL; - strq->ss_params.fb.next_spoke.tqe_prev = NULL; - } - if (holds_lock == 0) { - SCTP_TCB_SEND_UNLOCK(stcb); + if (asoc->ss_data.locked_on_sending == strq) { + asoc->ss_data.locked_on_sending = NULL; + } + TAILQ_REMOVE(&asoc->ss_data.out.wheel, strq, ss_params.ss.fb.next_spoke); + strq->ss_params.scheduled = false; } return; } @@ -697,11 +659,17 @@ sctp_ss_fb_select(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net, { struct sctp_stream_out *strq = NULL, *strqt; + if (asoc->ss_data.locked_on_sending != NULL) { + KASSERT(asoc->ss_data.locked_on_sending->ss_params.scheduled, + ("locked_on_sending %p not scheduled", + (void *)asoc->ss_data.locked_on_sending)); + return (asoc->ss_data.locked_on_sending); + } if (asoc->ss_data.last_out_stream == NULL || TAILQ_FIRST(&asoc->ss_data.out.wheel) == TAILQ_LAST(&asoc->ss_data.out.wheel, sctpwheel_listhead)) { strqt = TAILQ_FIRST(&asoc->ss_data.out.wheel); } else { - strqt = TAILQ_NEXT(asoc->ss_data.last_out_stream, ss_params.fb.next_spoke); + strqt = TAILQ_NEXT(asoc->ss_data.last_out_stream, ss_params.ss.fb.next_spoke); } do { if ((strqt != NULL) && @@ -710,13 +678,14 @@ sctp_ss_fb_select(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net, (net == NULL || (TAILQ_FIRST(&strqt->outqueue) && TAILQ_FIRST(&strqt->outqueue)->net == NULL) || (net != NULL && TAILQ_FIRST(&strqt->outqueue) && TAILQ_FIRST(&strqt->outqueue)->net != NULL && TAILQ_FIRST(&strqt->outqueue)->net == net))))) { - if ((strqt->ss_params.fb.rounds >= 0) && (strq == NULL || - strqt->ss_params.fb.rounds < strq->ss_params.fb.rounds)) { + if ((strqt->ss_params.ss.fb.rounds >= 0) && + ((strq == NULL) || + (strqt->ss_params.ss.fb.rounds < strq->ss_params.ss.fb.rounds))) { strq = strqt; } } if (strqt != NULL) { - strqt = TAILQ_NEXT(strqt, ss_params.fb.next_spoke); + strqt = TAILQ_NEXT(strqt, ss_params.ss.fb.next_spoke); } else { strqt = TAILQ_FIRST(&asoc->ss_data.out.wheel); } @@ -733,26 +702,26 @@ sctp_ss_fb_scheduled(struct sctp_tcb *stcb, struct sctp_nets *net SCTP_UNUSED, struct sctp_stream_out *strqt; int subtract; - if (stcb->asoc.idata_supported == 0) { + if (asoc->idata_supported == 0) { sp = TAILQ_FIRST(&strq->outqueue); if ((sp != NULL) && (sp->some_taken == 1)) { - stcb->asoc.ss_data.locked_on_sending = strq; + asoc->ss_data.locked_on_sending = strq; } else { - stcb->asoc.ss_data.locked_on_sending = NULL; + asoc->ss_data.locked_on_sending = NULL; } } else { - stcb->asoc.ss_data.locked_on_sending = NULL; + asoc->ss_data.locked_on_sending = NULL; } - subtract = strq->ss_params.fb.rounds; - TAILQ_FOREACH(strqt, &asoc->ss_data.out.wheel, ss_params.fb.next_spoke) { - strqt->ss_params.fb.rounds -= subtract; - if (strqt->ss_params.fb.rounds < 0) - strqt->ss_params.fb.rounds = 0; + subtract = strq->ss_params.ss.fb.rounds; + TAILQ_FOREACH(strqt, &asoc->ss_data.out.wheel, ss_params.ss.fb.next_spoke) { + strqt->ss_params.ss.fb.rounds -= subtract; + if (strqt->ss_params.ss.fb.rounds < 0) + strqt->ss_params.ss.fb.rounds = 0; } if (TAILQ_FIRST(&strq->outqueue)) { - strq->ss_params.fb.rounds = TAILQ_FIRST(&strq->outqueue)->length; + strq->ss_params.ss.fb.rounds = TAILQ_FIRST(&strq->outqueue)->length; } else { - strq->ss_params.fb.rounds = -1; + strq->ss_params.ss.fb.rounds = -1; } asoc->ss_data.last_out_stream = strq; return; @@ -764,20 +733,18 @@ sctp_ss_fb_scheduled(struct sctp_tcb *stcb, struct sctp_nets *net SCTP_UNUSED, */ static void sctp_ss_fcfs_add(struct sctp_tcb *stcb, struct sctp_association *asoc, - struct sctp_stream_out *strq, struct sctp_stream_queue_pending *sp, - int holds_lock); + struct sctp_stream_out *strq SCTP_UNUSED, + struct sctp_stream_queue_pending *sp); static void -sctp_ss_fcfs_init(struct sctp_tcb *stcb, struct sctp_association *asoc, - int holds_lock) +sctp_ss_fcfs_init(struct sctp_tcb *stcb, struct sctp_association *asoc) { uint32_t x, n = 0, add_more = 1; struct sctp_stream_queue_pending *sp; uint16_t i; - if (holds_lock == 0) { - SCTP_TCB_SEND_LOCK(stcb); - } + SCTP_TCB_SEND_LOCK_ASSERT(stcb); + TAILQ_INIT(&asoc->ss_data.out.list); /* * If there is data in the stream queues already, @@ -788,8 +755,8 @@ sctp_ss_fcfs_init(struct sctp_tcb *stcb, struct sctp_association *asoc, */ while (add_more) { add_more = 0; - for (i = 0; i < stcb->asoc.streamoutcnt; i++) { - sp = TAILQ_FIRST(&stcb->asoc.strmout[i].outqueue); + for (i = 0; i < asoc->streamoutcnt; i++) { + sp = TAILQ_FIRST(&asoc->strmout[i].outqueue); x = 0; /* Find n. message in current stream queue */ while (sp != NULL && x < n) { @@ -797,38 +764,30 @@ sctp_ss_fcfs_init(struct sctp_tcb *stcb, struct sctp_association *asoc, x++; } if (sp != NULL) { - sctp_ss_fcfs_add(stcb, &stcb->asoc, &stcb->asoc.strmout[i], sp, 1); + sctp_ss_fcfs_add(stcb, asoc, &asoc->strmout[i], sp); add_more = 1; } } n++; } - if (holds_lock == 0) { - SCTP_TCB_SEND_UNLOCK(stcb); - } return; } static void sctp_ss_fcfs_clear(struct sctp_tcb *stcb, struct sctp_association *asoc, - int clear_values, int holds_lock) + bool clear_values SCTP_UNUSED) { struct sctp_stream_queue_pending *sp; - if (clear_values) { - if (holds_lock == 0) { - SCTP_TCB_SEND_LOCK(stcb); - } - while (!TAILQ_EMPTY(&asoc->ss_data.out.list)) { - sp = TAILQ_FIRST(&asoc->ss_data.out.list); - TAILQ_REMOVE(&asoc->ss_data.out.list, sp, ss_next); - sp->ss_next.tqe_next = NULL; - sp->ss_next.tqe_prev = NULL; - } - if (holds_lock == 0) { - SCTP_TCB_SEND_UNLOCK(stcb); - } + SCTP_TCB_SEND_LOCK_ASSERT(stcb); + + while (!TAILQ_EMPTY(&asoc->ss_data.out.list)) { + sp = TAILQ_FIRST(&asoc->ss_data.out.list); + KASSERT(sp->scheduled, ("sp %p not scheduled", (void *)sp)); + TAILQ_REMOVE(&asoc->ss_data.out.list, sp, ss_next); + sp->scheduled = false; } + asoc->ss_data.last_out_stream = NULL; return; } @@ -843,61 +802,42 @@ sctp_ss_fcfs_init_stream(struct sctp_tcb *stcb, struct sctp_stream_out *strq, st stcb->asoc.ss_data.last_out_stream = strq; } } - strq->ss_params.fb.next_spoke.tqe_next = NULL; - strq->ss_params.fb.next_spoke.tqe_prev = NULL; + strq->ss_params.scheduled = false; return; } static void sctp_ss_fcfs_add(struct sctp_tcb *stcb, struct sctp_association *asoc, - struct sctp_stream_out *strq SCTP_UNUSED, struct sctp_stream_queue_pending *sp, - int holds_lock) + struct sctp_stream_out *strq SCTP_UNUSED, struct sctp_stream_queue_pending *sp) { - if (holds_lock == 0) { - SCTP_TCB_SEND_LOCK(stcb); - } - if (sp && (sp->ss_next.tqe_next == NULL) && - (sp->ss_next.tqe_prev == NULL)) { + SCTP_TCB_SEND_LOCK_ASSERT(stcb); + + if (!sp->scheduled) { TAILQ_INSERT_TAIL(&asoc->ss_data.out.list, sp, ss_next); - } - if (holds_lock == 0) { - SCTP_TCB_SEND_UNLOCK(stcb); + sp->scheduled = true; } return; } -static int +static bool sctp_ss_fcfs_is_empty(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_association *asoc) { - if (TAILQ_EMPTY(&asoc->ss_data.out.list)) { - return (1); - } else { - return (0); - } + return (TAILQ_EMPTY(&asoc->ss_data.out.list)); } static void sctp_ss_fcfs_remove(struct sctp_tcb *stcb, struct sctp_association *asoc, - struct sctp_stream_out *strq SCTP_UNUSED, struct sctp_stream_queue_pending *sp, - int holds_lock) + struct sctp_stream_out *strq SCTP_UNUSED, struct sctp_stream_queue_pending *sp) { - if (holds_lock == 0) { - SCTP_TCB_SEND_LOCK(stcb); - } - if (sp && - ((sp->ss_next.tqe_next != NULL) || - (sp->ss_next.tqe_prev != NULL))) { + SCTP_TCB_SEND_LOCK_ASSERT(stcb); + + if (sp->scheduled) { TAILQ_REMOVE(&asoc->ss_data.out.list, sp, ss_next); - sp->ss_next.tqe_next = NULL; - sp->ss_next.tqe_prev = NULL; - } - if (holds_lock == 0) { - SCTP_TCB_SEND_UNLOCK(stcb); + sp->scheduled = false; } return; } - static struct sctp_stream_out * sctp_ss_fcfs_select(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net, struct sctp_association *asoc) @@ -905,6 +845,9 @@ sctp_ss_fcfs_select(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net, struct sctp_stream_out *strq; struct sctp_stream_queue_pending *sp; + if (asoc->ss_data.locked_on_sending) { + return (asoc->ss_data.locked_on_sending); + } sp = TAILQ_FIRST(&asoc->ss_data.out.list); default_again: if (sp != NULL) { @@ -937,10 +880,34 @@ default_again: return (strq); } +static void +sctp_ss_fcfs_scheduled(struct sctp_tcb *stcb, + struct sctp_nets *net SCTP_UNUSED, + struct sctp_association *asoc, + struct sctp_stream_out *strq, + int moved_how_much SCTP_UNUSED) +{ + struct sctp_stream_queue_pending *sp; + + KASSERT(strq != NULL, ("strq is NULL")); + asoc->ss_data.last_out_stream = strq; + if (asoc->idata_supported == 0) { + sp = TAILQ_FIRST(&strq->outqueue); + if ((sp != NULL) && (sp->some_taken == 1)) { + asoc->ss_data.locked_on_sending = strq; + } else { + asoc->ss_data.locked_on_sending = NULL; + } + } else { + asoc->ss_data.locked_on_sending = NULL; + } + return; +} + const struct sctp_ss_functions sctp_ss_functions[] = { /* SCTP_SS_DEFAULT */ { -#if defined(__Windows__) || defined(__Userspace_os_Windows) +#if defined(_WIN32) sctp_ss_default_init, sctp_ss_default_clear, sctp_ss_default_init_stream, @@ -970,7 +937,7 @@ const struct sctp_ss_functions sctp_ss_functions[] = { }, /* SCTP_SS_ROUND_ROBIN */ { -#if defined(__Windows__) || defined(__Userspace_os_Windows) +#if defined(_WIN32) sctp_ss_default_init, sctp_ss_default_clear, sctp_ss_default_init_stream, @@ -1000,7 +967,7 @@ const struct sctp_ss_functions sctp_ss_functions[] = { }, /* SCTP_SS_ROUND_ROBIN_PACKET */ { -#if defined(__Windows__) || defined(__Userspace_os_Windows) +#if defined(_WIN32) sctp_ss_default_init, sctp_ss_default_clear, sctp_ss_default_init_stream, @@ -1030,7 +997,7 @@ const struct sctp_ss_functions sctp_ss_functions[] = { }, /* SCTP_SS_PRIORITY */ { -#if defined(__Windows__) || defined(__Userspace_os_Windows) +#if defined(_WIN32) sctp_ss_default_init, sctp_ss_prio_clear, sctp_ss_prio_init_stream, @@ -1060,7 +1027,7 @@ const struct sctp_ss_functions sctp_ss_functions[] = { }, /* SCTP_SS_FAIR_BANDWITH */ { -#if defined(__Windows__) || defined(__Userspace_os_Windows) +#if defined(_WIN32) sctp_ss_default_init, sctp_ss_fb_clear, sctp_ss_fb_init_stream, @@ -1090,7 +1057,7 @@ const struct sctp_ss_functions sctp_ss_functions[] = { }, /* SCTP_SS_FIRST_COME */ { -#if defined(__Windows__) || defined(__Userspace_os_Windows) +#if defined(_WIN32) sctp_ss_fcfs_init, sctp_ss_fcfs_clear, sctp_ss_fcfs_init_stream, @@ -1098,7 +1065,7 @@ const struct sctp_ss_functions sctp_ss_functions[] = { sctp_ss_fcfs_is_empty, sctp_ss_fcfs_remove, sctp_ss_fcfs_select, - sctp_ss_default_scheduled, + sctp_ss_fcfs_scheduled, sctp_ss_default_packet_done, sctp_ss_default_get_value, sctp_ss_default_set_value, @@ -1111,7 +1078,7 @@ const struct sctp_ss_functions sctp_ss_functions[] = { .sctp_ss_is_empty = sctp_ss_fcfs_is_empty, .sctp_ss_remove_from_stream = sctp_ss_fcfs_remove, .sctp_ss_select_stream = sctp_ss_fcfs_select, - .sctp_ss_scheduled = sctp_ss_default_scheduled, + .sctp_ss_scheduled = sctp_ss_fcfs_scheduled, .sctp_ss_packet_done = sctp_ss_default_packet_done, .sctp_ss_get_value = sctp_ss_default_get_value, .sctp_ss_set_value = sctp_ss_default_set_value, diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_structs.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_structs.h index a7fd665f58..637172377a 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_structs.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_structs.h @@ -32,9 +32,9 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_structs.h 345467 2019-03-24 12:13:05Z tuexen $"); +__FBSDID("$FreeBSD$"); #endif #ifndef _NETINET_SCTP_STRUCTS_H_ @@ -55,7 +55,7 @@ struct sctp_timer { void *ep; void *tcb; void *net; -#if defined(__FreeBSD__) && __FreeBSD_version >= 800000 +#if defined(__FreeBSD__) && !defined(__Userspace__) void *vnet; #endif @@ -65,7 +65,6 @@ struct sctp_timer { uint32_t stopped_from; }; - struct sctp_foo_stuff { struct sctp_inpcb *inp; uint32_t lineno; @@ -73,7 +72,6 @@ struct sctp_foo_stuff { int updown; }; - /* * This is the information we track on each interface that we know about from * the distant end. @@ -113,13 +111,12 @@ typedef void (*asoc_func) (struct sctp_inpcb *, struct sctp_tcb *, void *ptr, typedef int (*inp_func) (struct sctp_inpcb *, void *ptr, uint32_t val); typedef void (*end_func) (void *ptr, uint32_t val); -#if defined(__FreeBSD__) && defined(SCTP_MCORE_INPUT) && defined(SMP) +#if defined(__FreeBSD__) && !defined(__Userspace__) +#if defined(SCTP_MCORE_INPUT) && defined(SMP) /* whats on the mcore control struct */ struct sctp_mcore_queue { TAILQ_ENTRY(sctp_mcore_queue) next; -#if defined(__FreeBSD__) && __FreeBSD_version >= 801000 struct vnet *vn; -#endif struct mbuf *m; int off; int v6; @@ -135,14 +132,12 @@ struct sctp_mcore_ctrl { int running; int cpuid; }; - - #endif - +#endif struct sctp_iterator { TAILQ_ENTRY(sctp_iterator) sctp_nxt_itr; -#if defined(__FreeBSD__) && __FreeBSD_version >= 801000 +#if defined(__FreeBSD__) && !defined(__Userspace__) struct vnet *vn; #endif struct sctp_timer tmr; @@ -166,7 +161,6 @@ struct sctp_iterator { #define SCTP_ITERATOR_DO_ALL_INP 0x00000001 #define SCTP_ITERATOR_DO_SINGLE_INP 0x00000002 - TAILQ_HEAD(sctpiterators, sctp_iterator); struct sctp_copy_all { @@ -184,10 +178,10 @@ struct sctp_asconf_iterator { }; struct iterator_control { -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) struct mtx ipi_iterator_wq_mtx; struct mtx it_mtx; -#elif defined(__APPLE__) +#elif defined(__APPLE__) && !defined(__Userspace__) lck_mtx_t *ipi_iterator_wq_mtx; lck_mtx_t *it_mtx; #elif defined(SCTP_PROCESS_LEVEL_LOCKS) @@ -200,7 +194,7 @@ struct iterator_control { pthread_mutex_t it_mtx; pthread_cond_t iterator_wakeup; #endif -#elif defined(__Windows__) +#elif defined(_WIN32) && !defined(__Userspace__) struct spinlock it_lock; struct spinlock ipi_iterator_wq_lock; KEVENT iterator_wakeup[2]; @@ -208,7 +202,7 @@ struct iterator_control { #else void *it_mtx; #endif -#if !defined(__Windows__) +#if !(defined(_WIN32) && !defined(__Userspace__)) #if !defined(__Userspace__) SCTP_PROCESS_STRUCT thread_proc; #else @@ -220,7 +214,7 @@ struct iterator_control { uint32_t iterator_running; uint32_t iterator_flags; }; -#if !defined(__FreeBSD__) +#if !(defined(__FreeBSD__) && !defined(__Userspace__)) #define SCTP_ITERATOR_MUST_EXIT 0x00000001 #define SCTP_ITERATOR_EXITED 0x00000002 #endif @@ -228,28 +222,18 @@ struct iterator_control { #define SCTP_ITERATOR_STOP_CUR_INP 0x00000008 struct sctp_net_route { - sctp_rtentry_t *ro_rt; -#if defined(__FreeBSD__) -#if __FreeBSD_version < 1100093 -#if __FreeBSD_version >= 800000 - void *ro_lle; -#endif -#if __FreeBSD_version >= 900000 - void *ro_ia; - int ro_flags; -#endif -#else -#if __FreeBSD_version >= 1100116 +#if defined(__FreeBSD__) && !defined(__Userspace__) + struct nhop_object *ro_nh; struct llentry *ro_lle; -#endif char *ro_prepend; uint16_t ro_plen; uint16_t ro_flags; uint16_t ro_mtu; uint16_t spare; +#else + sctp_rtentry_t *ro_rt; #endif -#endif -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #if !defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) && !defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION) && !defined(APPLE_ELCAPITAN) struct llentry *ro_lle; #endif @@ -306,7 +290,6 @@ struct rtcc_cc { uint8_t last_inst_ind; /* Last saved inst indication */ }; - struct sctp_nets { TAILQ_ENTRY(sctp_nets) sctp_next; /* next link */ @@ -334,7 +317,7 @@ struct sctp_nets { int lastsa; int lastsv; uint64_t rtt; /* last measured rtt value in us */ - unsigned int RTO; + uint32_t RTO; /* This is used for SHUTDOWN/SHUTDOWN-ACK/SEND or INIT timers */ struct sctp_timer rxt_timer; @@ -443,13 +426,12 @@ struct sctp_nets { uint8_t last_hs_used; /* index into the last HS table entry we used */ uint8_t lan_type; uint8_t rto_needed; -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) uint32_t flowid; uint8_t flowtype; #endif }; - struct sctp_data_chunkrec { uint32_t tsn; /* the TSN of this transmit */ uint32_t mid; /* the message identifier of this transmit */ @@ -488,7 +470,6 @@ struct chk_id { uint8_t can_take_data; }; - struct sctp_tmit_chunk { union { struct sctp_data_chunkrec data; @@ -574,6 +555,7 @@ struct sctp_queued_to_read { /* sinfo structure Pluse more */ * the user is in the explict MSG_EOR mode * and wrote some data, but has not completed * sending. + * ss_next and scheduled are only used by the FCFS stream scheduler. */ struct sctp_stream_queue_pending { struct mbuf *data; @@ -597,6 +579,8 @@ struct sctp_stream_queue_pending { uint8_t sender_all_done; uint8_t put_last_out; uint8_t discard_rest; + uint8_t processing; + bool scheduled; }; /* @@ -616,6 +600,19 @@ struct sctp_stream_in { TAILQ_HEAD(sctpwheel_listhead, sctp_stream_out); TAILQ_HEAD(sctplist_listhead, sctp_stream_queue_pending); +/* + * This union holds all data necessary for + * different stream schedulers. + */ +struct scheduling_data { + struct sctp_stream_out *locked_on_sending; + /* circular looking for output selection */ + struct sctp_stream_out *last_out_stream; + union { + struct sctpwheel_listhead wheel; + struct sctplist_listhead list; + } out; +}; /* Round-robin schedulers */ struct ss_rr { @@ -639,28 +636,17 @@ struct ss_fb { int32_t rounds; }; -/* - * This union holds all data necessary for - * different stream schedulers. - */ -struct scheduling_data { - struct sctp_stream_out *locked_on_sending; - /* circular looking for output selection */ - struct sctp_stream_out *last_out_stream; - union { - struct sctpwheel_listhead wheel; - struct sctplist_listhead list; - } out; -}; - /* * This union holds all parameters per stream * necessary for different stream schedulers. */ -union scheduling_parameters { - struct ss_rr rr; - struct ss_prio prio; - struct ss_fb fb; +struct scheduling_parameters { + union { + struct ss_rr rr; + struct ss_prio prio; + struct ss_fb fb; + } ss; + bool scheduled; }; /* States for outgoing streams */ @@ -670,12 +656,10 @@ union scheduling_parameters { #define SCTP_STREAM_RESET_PENDING 0x03 #define SCTP_STREAM_RESET_IN_FLIGHT 0x04 -#define SCTP_MAX_STREAMS_AT_ONCE_RESET 200 - /* This struct is used to track the traffic on outbound streams */ struct sctp_stream_out { struct sctp_streamhead outqueue; - union scheduling_parameters ss_params; + struct scheduling_parameters ss_params; uint32_t chunks_on_queues; /* send queue and sent queue */ #if defined(SCTP_DETAILED_STR_STATS) uint32_t abandoned_unsent[SCTP_PR_SCTP_MAX + 1]; @@ -695,6 +679,8 @@ struct sctp_stream_out { uint8_t state; }; +#define SCTP_MAX_STREAMS_AT_ONCE_RESET 200 + /* used to keep track of the addresses yet to try to add/delete */ TAILQ_HEAD(sctp_asconf_addrhead, sctp_asconf_addr); struct sctp_asconf_addr { @@ -800,16 +786,15 @@ struct sctp_cc_functions { * for stream scheduling. */ struct sctp_ss_functions { - void (*sctp_ss_init)(struct sctp_tcb *stcb, struct sctp_association *asoc, - int holds_lock); + void (*sctp_ss_init)(struct sctp_tcb *stcb, struct sctp_association *asoc); void (*sctp_ss_clear)(struct sctp_tcb *stcb, struct sctp_association *asoc, - int clear_values, int holds_lock); + bool clear_values); void (*sctp_ss_init_stream)(struct sctp_tcb *stcb, struct sctp_stream_out *strq, struct sctp_stream_out *with_strq); void (*sctp_ss_add_to_stream)(struct sctp_tcb *stcb, struct sctp_association *asoc, - struct sctp_stream_out *strq, struct sctp_stream_queue_pending *sp, int holds_lock); - int (*sctp_ss_is_empty)(struct sctp_tcb *stcb, struct sctp_association *asoc); + struct sctp_stream_out *strq, struct sctp_stream_queue_pending *sp); + bool (*sctp_ss_is_empty)(struct sctp_tcb *stcb, struct sctp_association *asoc); void (*sctp_ss_remove_from_stream)(struct sctp_tcb *stcb, struct sctp_association *asoc, - struct sctp_stream_out *strq, struct sctp_stream_queue_pending *sp, int holds_lock); + struct sctp_stream_out *strq, struct sctp_stream_queue_pending *sp); struct sctp_stream_out* (*sctp_ss_select_stream)(struct sctp_tcb *stcb, struct sctp_nets *net, struct sctp_association *asoc); void (*sctp_ss_scheduled)(struct sctp_tcb *stcb, struct sctp_nets *net, @@ -820,7 +805,7 @@ struct sctp_ss_functions { struct sctp_stream_out *strq, uint16_t *value); int (*sctp_ss_set_value)(struct sctp_tcb *stcb, struct sctp_association *asoc, struct sctp_stream_out *strq, uint16_t value); - int (*sctp_ss_is_user_msgs_incomplete)(struct sctp_tcb *stcb, struct sctp_association *asoc); + bool (*sctp_ss_is_user_msgs_incomplete)(struct sctp_tcb *stcb, struct sctp_association *asoc); }; /* used to save ASCONF chunks for retransmission */ @@ -868,7 +853,6 @@ struct sctp_association { struct sctp_timer strreset_timer; /* stream reset */ struct sctp_timer shut_guard_timer; /* shutdown guard */ struct sctp_timer autoclose_timer; /* automatic close timer */ - struct sctp_timer delayed_event_timer; /* timer for delayed events */ struct sctp_timer delete_prim_timer; /* deleting primary dst */ /* list of restricted local addresses */ @@ -934,7 +918,6 @@ struct sctp_association { /* last place I got a control from */ struct sctp_nets *last_control_chunk_from; - /* * wait to the point the cum-ack passes req->send_reset_at_tsn for * any req on the list. @@ -998,7 +981,6 @@ struct sctp_association { /* Original seq number I used ??questionable to keep?? */ uint32_t init_seq_number; - /* The Advanced Peer Ack Point, as required by the PR-SCTP */ /* (A1 in Section 4.2) */ uint32_t advanced_peer_ack_point; @@ -1122,7 +1104,7 @@ struct sctp_association { uint32_t heart_beat_delay; /* autoclose */ - unsigned int sctp_autoclose_ticks; + uint32_t sctp_autoclose_ticks; /* how many preopen streams we have */ unsigned int pre_open_streams; @@ -1131,7 +1113,7 @@ struct sctp_association { unsigned int max_inbound_streams; /* the cookie life I award for any cookie, in seconds */ - unsigned int cookie_life; + uint32_t cookie_life; /* time to delay acks for */ unsigned int delayed_ack; unsigned int old_delayed_ack; @@ -1140,10 +1122,10 @@ struct sctp_association { unsigned int numduptsns; int dup_tsns[SCTP_MAX_DUP_TSNS]; - unsigned int initial_init_rto_max; /* initial RTO for INIT's */ - unsigned int initial_rto; /* initial send RTO */ - unsigned int minrto; /* per assoc RTO-MIN */ - unsigned int maxrto; /* per assoc RTO-MAX */ + uint32_t initial_init_rto_max; /* initial RTO for INIT's */ + uint32_t initial_rto; /* initial send RTO */ + uint32_t minrto; /* per assoc RTO-MIN */ + uint32_t maxrto; /* per assoc RTO-MAX */ /* authentication fields */ sctp_auth_chklist_t *local_auth_chunks; diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_sysctl.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_sysctl.c index ba911c3c57..bb49e17385 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_sysctl.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_sysctl.c @@ -32,9 +32,9 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_sysctl.c 356357 2020-01-04 20:33:12Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_sysctl.c 365071 2020-09-01 21:19:14Z mjg $"); #endif #include @@ -44,15 +44,15 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_sysctl.c 356357 2020-01-04 20:33:12Z t #include #include #include -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include #include #endif -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #include #endif -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) FEATURE(sctp, "Stream Control Transmission Protocol"); #endif @@ -74,7 +74,7 @@ sctp_init_sysctls() SCTP_BASE_SYSCTL(sctp_reconfig_enable) = SCTPCTL_RECONFIG_ENABLE_DEFAULT; SCTP_BASE_SYSCTL(sctp_nrsack_enable) = SCTPCTL_NRSACK_ENABLE_DEFAULT; SCTP_BASE_SYSCTL(sctp_pktdrop_enable) = SCTPCTL_PKTDROP_ENABLE_DEFAULT; -#if !(defined(__FreeBSD__) && __FreeBSD_version >= 800000) +#if !(defined(__FreeBSD__) && !defined(__Userspace__)) SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback) = SCTPCTL_LOOPBACK_NOCSUM_DEFAULT; #endif SCTP_BASE_SYSCTL(sctp_peer_chunk_oh) = SCTPCTL_PEER_CHKOH_DEFAULT; @@ -152,7 +152,7 @@ sctp_init_sysctls() SCTP_BASE_SYSCTL(sctp_sendall_limit) = SCTPCTL_SENDALL_LIMIT_DEFAULT; SCTP_BASE_SYSCTL(sctp_diag_info_code) = SCTPCTL_DIAG_INFO_CODE_DEFAULT; #if defined(SCTP_LOCAL_TRACE_BUF) -#if defined(__Windows__) +#if defined(_WIN32) && !defined(__Userspace__) /* On Windows, the resource for global variables is limited. */ MALLOC(SCTP_BASE_SYSCTL(sctp_log), struct sctp_log *, sizeof(struct sctp_log), M_SYSCTL, M_ZERO); #else @@ -165,18 +165,18 @@ sctp_init_sysctls() #if defined(SCTP_DEBUG) SCTP_BASE_SYSCTL(sctp_debug_on) = SCTPCTL_DEBUG_DEFAULT; #endif -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_BASE_SYSCTL(sctp_ignore_vmware_interfaces) = SCTPCTL_IGNORE_VMWARE_INTERFACES_DEFAULT; SCTP_BASE_SYSCTL(sctp_main_timer) = SCTPCTL_MAIN_TIMER_DEFAULT; SCTP_BASE_SYSCTL(sctp_addr_watchdog_limit) = SCTPCTL_ADDR_WATCHDOG_LIMIT_DEFAULT; SCTP_BASE_SYSCTL(sctp_vtag_watchdog_limit) = SCTPCTL_VTAG_WATCHDOG_LIMIT_DEFAULT; #endif -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_BASE_SYSCTL(sctp_output_unlocked) = SCTPCTL_OUTPUT_UNLOCKED_DEFAULT; #endif } +#if defined(_WIN32) && !defined(__Userspace__) -#if defined(__Windows__) void sctp_finish_sysctls() { @@ -189,7 +189,7 @@ sctp_finish_sysctls() } #endif -#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__Windows__) +#if !defined(__Userspace__) /* It returns an upper limit. No filtering is done here */ static unsigned int sctp_sysctl_number_of_addresses(struct sctp_inpcb *inp) @@ -329,7 +329,7 @@ sctp_sysctl_copy_out_local_addresses(struct sctp_inpcb *inp, struct sctp_tcb *st sin = &sctp_ifa->address.sin; if (sin->sin_addr.s_addr == 0) continue; -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (prison_check_ip4(inp->ip_inp.inp.inp_cred, &sin->sin_addr) != 0) { continue; @@ -350,7 +350,7 @@ sctp_sysctl_copy_out_local_addresses(struct sctp_inpcb *inp, struct sctp_tcb *st sin6 = &sctp_ifa->address.sin6; if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) continue; -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (prison_check_ip6(inp->ip_inp.inp.inp_cred, &sin6->sin6_addr) != 0) { continue; @@ -428,7 +428,7 @@ sctp_sysctl_copy_out_local_addresses(struct sctp_inpcb *inp, struct sctp_tcb *st /* * sysctl functions */ -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) static int sctp_sysctl_handle_assoclist SYSCTL_HANDLER_ARGS { @@ -458,7 +458,7 @@ sctp_sysctl_handle_assoclist(SYSCTL_HANDLER_ARGS) number_of_remote_addresses = 0; SCTP_INP_INFO_RLOCK(); -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) if (req->oldptr == USER_ADDR_NULL) { #else if (req->oldptr == NULL) { @@ -483,14 +483,14 @@ sctp_sysctl_handle_assoclist(SYSCTL_HANDLER_ARGS) (number_of_remote_addresses + number_of_associations) * sizeof(struct xsctp_raddr); /* request some more memory than needed */ -#if !defined(__Windows__) +#if !(defined(_WIN32) && !defined(__Userspace__)) req->oldidx = (n + n / 8); #else req->dataidx = (n + n / 8); #endif return (0); } -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) if (req->newptr != USER_ADDR_NULL) { #else if (req->newptr != NULL) { @@ -511,16 +511,12 @@ sctp_sysctl_handle_assoclist(SYSCTL_HANDLER_ARGS) xinpcb.last = 0; xinpcb.local_port = ntohs(inp->sctp_lport); xinpcb.flags = inp->sctp_flags; -#if defined(__FreeBSD__) && __FreeBSD_version < 1000048 - xinpcb.features = (uint32_t)inp->sctp_features; -#else xinpcb.features = inp->sctp_features; -#endif xinpcb.total_sends = inp->total_sends; xinpcb.total_recvs = inp->total_recvs; xinpcb.total_nospaces = inp->total_nospaces; xinpcb.fragmentation_point = inp->sctp_frag_point; -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) xinpcb.socket = (uintptr_t)inp->sctp_socket; #else xinpcb.socket = inp->sctp_socket; @@ -532,33 +528,16 @@ sctp_sysctl_handle_assoclist(SYSCTL_HANDLER_ARGS) xinpcb.qlen = 0; xinpcb.maxqlen = 0; } else { -#if defined(__FreeBSD__) && __FreeBSD_version >= 1200034 +#if defined(__FreeBSD__) && !defined(__Userspace__) xinpcb.qlen = so->sol_qlen; -#else - xinpcb.qlen = so->so_qlen; -#endif -#if defined(__FreeBSD__) && __FreeBSD_version > 1100096 -#if __FreeBSD_version >= 1200034 xinpcb.qlen_old = so->sol_qlen > USHRT_MAX ? USHRT_MAX : (uint16_t) so->sol_qlen; -#else - xinpcb.qlen_old = so->so_qlen > USHRT_MAX ? - USHRT_MAX : (uint16_t) so->so_qlen; -#endif -#endif -#if defined(__FreeBSD__) && __FreeBSD_version >= 1200034 xinpcb.maxqlen = so->sol_qlimit; -#else - xinpcb.maxqlen = so->so_qlimit; -#endif -#if defined(__FreeBSD__) && __FreeBSD_version > 1100096 -#if __FreeBSD_version >= 1200034 xinpcb.maxqlen_old = so->sol_qlimit > USHRT_MAX ? USHRT_MAX : (uint16_t) so->sol_qlimit; #else - xinpcb.maxqlen_old = so->so_qlimit > USHRT_MAX ? - USHRT_MAX : (uint16_t) so->so_qlimit; -#endif + xinpcb.qlen = so->so_qlen; + xinpcb.maxqlen = so->so_qlimit; #endif } SCTP_INP_INCR_REF(inp); @@ -587,16 +566,8 @@ sctp_sysctl_handle_assoclist(SYSCTL_HANDLER_ARGS) xstcb.primary_addr = stcb->asoc.primary_destination->ro._l_addr; xstcb.heartbeat_interval = stcb->asoc.heart_beat_delay; xstcb.state = (uint32_t)sctp_map_assoc_state(stcb->asoc.state); -#if defined(__FreeBSD__) -#if __FreeBSD_version >= 800000 - /* 7.0 does not support these */ xstcb.assoc_id = sctp_get_associd(stcb); xstcb.peers_rwnd = stcb->asoc.peers_rwnd; -#endif -#else - xstcb.assoc_id = sctp_get_associd(stcb); - xstcb.peers_rwnd = stcb->asoc.peers_rwnd; -#endif xstcb.in_streams = stcb->asoc.streamincnt; xstcb.out_streams = stcb->asoc.streamoutcnt; xstcb.max_nr_retrans = stcb->asoc.overall_error_count; @@ -648,8 +619,6 @@ sctp_sysctl_handle_assoclist(SYSCTL_HANDLER_ARGS) xraddr.cwnd = net->cwnd; xraddr.flight_size = net->flight_size; xraddr.mtu = net->mtu; -#if defined(__FreeBSD__) -#if __FreeBSD_version >= 800000 xraddr.rtt = net->rtt / 1000; xraddr.heartbeat_interval = net->heart_beat_delay; xraddr.ssthresh = net->ssthresh; @@ -661,20 +630,6 @@ sctp_sysctl_handle_assoclist(SYSCTL_HANDLER_ARGS) } else { xraddr.state = SCTP_INACTIVE; } -#endif -#else - xraddr.rtt = net->rtt / 1000; - xraddr.heartbeat_interval = net->heart_beat_delay; - xraddr.ssthresh = net->ssthresh; - xraddr.encaps_port = net->port; - if (net->dest_state & SCTP_ADDR_UNCONFIRMED) { - xraddr.state = SCTP_UNCONFIRMED; - } else if (net->dest_state & SCTP_ADDR_REACHABLE) { - xraddr.state = SCTP_ACTIVE; - } else { - xraddr.state = SCTP_INACTIVE; - } -#endif xraddr.start_time.tv_sec = (uint32_t)net->start_time.tv_sec; xraddr.start_time.tv_usec = (uint32_t)net->start_time.tv_usec; SCTP_INP_RUNLOCK(inp); @@ -721,7 +676,7 @@ skip: return (error); } -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) static int sctp_sysctl_handle_udp_tunneling SYSCTL_HANDLER_ARGS { @@ -738,22 +693,14 @@ sctp_sysctl_handle_udp_tunneling(SYSCTL_HANDLER_ARGS) old = SCTP_BASE_SYSCTL(sctp_udp_tunneling_port); SCTP_INP_INFO_RUNLOCK(); new = old; -#if defined(__FreeBSD__) && __FreeBSD_version >= 800056 && __FreeBSD_version < 1000100 -#ifdef VIMAGE - error = vnet_sysctl_handle_int(oidp, &new, 0, req); -#else error = sysctl_handle_int(oidp, &new, 0, req); -#endif -#else - error = sysctl_handle_int(oidp, &new, 0, req); -#endif if ((error == 0) && -#if defined (__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) (req->newptr != USER_ADDR_NULL)) { #else (req->newptr != NULL)) { #endif -#if defined(__Windows__) +#if defined(_WIN32) && !defined(__Userspace__) SCTP_INP_INFO_WLOCK(); sctp_over_udp_restart(); SCTP_INP_INFO_WUNLOCK(); @@ -780,8 +727,8 @@ sctp_sysctl_handle_udp_tunneling(SYSCTL_HANDLER_ARGS) } return (error); } +#if defined(__APPLE__) && !defined(__Userspace__) -#if defined(__APPLE__) int sctp_is_vmware_interface(struct ifnet *); static int @@ -814,7 +761,7 @@ sctp_sysctl_handle_vmware_interfaces SYSCTL_HANDLER_ARGS } #endif -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) static int sctp_sysctl_handle_auth SYSCTL_HANDLER_ARGS { @@ -828,17 +775,9 @@ sctp_sysctl_handle_auth(SYSCTL_HANDLER_ARGS) uint32_t new; new = SCTP_BASE_SYSCTL(sctp_auth_enable); -#if defined(__FreeBSD__) && __FreeBSD_version >= 800056 && __FreeBSD_version < 1000100 -#ifdef VIMAGE - error = vnet_sysctl_handle_int(oidp, &new, 0, req); -#else error = sysctl_handle_int(oidp, &new, 0, req); -#endif -#else - error = sysctl_handle_int(oidp, &new, 0, req); -#endif if ((error == 0) && -#if defined (__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) (req->newptr != USER_ADDR_NULL)) { #else (req->newptr != NULL)) { @@ -859,7 +798,7 @@ sctp_sysctl_handle_auth(SYSCTL_HANDLER_ARGS) return (error); } -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) static int sctp_sysctl_handle_asconf SYSCTL_HANDLER_ARGS { @@ -873,17 +812,9 @@ sctp_sysctl_handle_asconf(SYSCTL_HANDLER_ARGS) uint32_t new; new = SCTP_BASE_SYSCTL(sctp_asconf_enable); -#if defined(__FreeBSD__) && __FreeBSD_version >= 800056 && __FreeBSD_version < 1000100 -#ifdef VIMAGE - error = vnet_sysctl_handle_int(oidp, &new, 0, req); -#else error = sysctl_handle_int(oidp, &new, 0, req); -#endif -#else - error = sysctl_handle_int(oidp, &new, 0, req); -#endif if ((error == 0) && -#if defined (__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) (req->newptr != USER_ADDR_NULL)) { #else (req->newptr != NULL)) { @@ -904,7 +835,7 @@ sctp_sysctl_handle_asconf(SYSCTL_HANDLER_ARGS) return (error); } -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) static int sctp_sysctl_handle_stats SYSCTL_HANDLER_ARGS { @@ -915,7 +846,7 @@ sctp_sysctl_handle_stats(SYSCTL_HANDLER_ARGS) { #endif int error; -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) #if defined(SMP) && defined(SCTP_USE_PERCPU_STAT) struct sctpstat *sarry; struct sctpstat sb; @@ -924,7 +855,7 @@ sctp_sysctl_handle_stats(SYSCTL_HANDLER_ARGS) struct sctpstat sb_temp; #endif -#if defined (__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) if ((req->newptr != USER_ADDR_NULL) && #else if ((req->newptr != NULL) && @@ -932,7 +863,7 @@ sctp_sysctl_handle_stats(SYSCTL_HANDLER_ARGS) (req->newlen != sizeof(struct sctpstat))) { return (EINVAL); } -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) memset(&sb_temp, 0, sizeof(struct sctpstat)); if (req->newptr != NULL) { @@ -1089,7 +1020,7 @@ sctp_sysctl_handle_stats(SYSCTL_HANDLER_ARGS) } #if defined(SCTP_LOCAL_TRACE_BUF) -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) static int sctp_sysctl_handle_trace_log SYSCTL_HANDLER_ARGS { @@ -1101,7 +1032,7 @@ sctp_sysctl_handle_trace_log(SYSCTL_HANDLER_ARGS) #endif int error; -#if defined(__Windows__) +#if defined(_WIN32) && !defined(__Userspace__) error = SYSCTL_OUT(req, SCTP_BASE_SYSCTL(sctp_log), sizeof(struct sctp_log)); #else error = SYSCTL_OUT(req, &SCTP_BASE_SYSCTL(sctp_log), sizeof(struct sctp_log)); @@ -1109,7 +1040,7 @@ sctp_sysctl_handle_trace_log(SYSCTL_HANDLER_ARGS) return (error); } -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) static int sctp_sysctl_handle_trace_log_clear SYSCTL_HANDLER_ARGS { @@ -1120,7 +1051,7 @@ sctp_sysctl_handle_trace_log_clear(SYSCTL_HANDLER_ARGS) { #endif int error = 0; -#if defined(__Windows__) +#if defined(_WIN32) && !defined(__Userspace__) int value = 0; if (req->new_data == NULL) { @@ -1138,33 +1069,8 @@ sctp_sysctl_handle_trace_log_clear(SYSCTL_HANDLER_ARGS) } #endif -#if defined(__APPLE__) || defined(__FreeBSD__) +#if (defined(__APPLE__) || defined(__FreeBSD__)) && !defined(__Userspace__) #if defined(__FreeBSD__) -#if __FreeBSD_version >= 800056 && __FreeBSD_version < 1000100 -#ifdef VIMAGE -#define SCTP_UINT_SYSCTL(name, var_name, prefix) \ - static int \ - sctp_sysctl_handle_##mib_name(SYSCTL_HANDLER_ARGS) \ - { \ - int error; \ - uint32_t new; \ - \ - new = SCTP_BASE_SYSCTL(var_name); \ - error = vnet_sysctl_handle_int(oidp, &new, 0, req); \ - if ((error == 0) && (req->newptr != NULL)) { \ - if ((new < prefix##_MIN) || \ - (new > prefix##_MAX)) { \ - error = EINVAL; \ - } else { \ - SCTP_BASE_SYSCTL(var_name) = new; \ - } \ - } \ - return (error); \ - } \ - SYSCTL_PROC(_net_inet_sctp, OID_AUTO, mib_name, \ - CTLTYPE_UINT|CTLFLAG_RW, NULL, 0, \ - sctp_sysctl_handle_##mib_name, "UI", prefix##_DESC); -#else #define SCTP_UINT_SYSCTL(mib_name, var_name, prefix) \ static int \ sctp_sysctl_handle_##mib_name(SYSCTL_HANDLER_ARGS) \ @@ -1187,31 +1093,6 @@ sctp_sysctl_handle_trace_log_clear(SYSCTL_HANDLER_ARGS) SYSCTL_PROC(_net_inet_sctp, OID_AUTO, mib_name, \ CTLFLAG_VNET|CTLTYPE_UINT|CTLFLAG_RW, NULL, 0, \ sctp_sysctl_handle_##mib_name, "UI", prefix##_DESC); -#endif -#else -#define SCTP_UINT_SYSCTL(mib_name, var_name, prefix) \ - static int \ - sctp_sysctl_handle_##mib_name(SYSCTL_HANDLER_ARGS) \ - { \ - int error; \ - uint32_t new; \ - \ - new = SCTP_BASE_SYSCTL(var_name); \ - error = sysctl_handle_int(oidp, &new, 0, req); \ - if ((error == 0) && (req->newptr != NULL)) { \ - if ((new < prefix##_MIN) || \ - (new > prefix##_MAX)) { \ - error = EINVAL; \ - } else { \ - SCTP_BASE_SYSCTL(var_name) = new; \ - } \ - } \ - return (error); \ - } \ - SYSCTL_PROC(_net_inet_sctp, OID_AUTO, mib_name, \ - CTLFLAG_VNET|CTLTYPE_UINT|CTLFLAG_RW, NULL, 0, \ - sctp_sysctl_handle_##mib_name, "UI", prefix##_DESC); -#endif #else #define SCTP_UINT_SYSCTL(mib_name, var_name, prefix) \ static int \ @@ -1258,7 +1139,7 @@ SYSCTL_PROC(_net_inet_sctp, OID_AUTO, asconf_enable, CTLFLAG_VNET|CTLTYPE_UINT|C SCTP_UINT_SYSCTL(reconfig_enable, sctp_reconfig_enable, SCTPCTL_RECONFIG_ENABLE) SCTP_UINT_SYSCTL(nrsack_enable, sctp_nrsack_enable, SCTPCTL_NRSACK_ENABLE) SCTP_UINT_SYSCTL(pktdrop_enable, sctp_pktdrop_enable, SCTPCTL_PKTDROP_ENABLE) -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_UINT_SYSCTL(loopback_nocsum, sctp_no_csum_on_loopback, SCTPCTL_LOOPBACK_NOCSUM) #endif SCTP_UINT_SYSCTL(peer_chkoh, sctp_peer_chunk_oh, SCTPCTL_PEER_CHKOH) @@ -1330,14 +1211,14 @@ SCTP_UINT_SYSCTL(diag_info_code, sctp_diag_info_code, SCTPCTL_DIAG_INFO_CODE) #ifdef SCTP_DEBUG SCTP_UINT_SYSCTL(debug, sctp_debug_on, SCTPCTL_DEBUG) #endif -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_UINT_SYSCTL(main_timer, sctp_main_timer, SCTPCTL_MAIN_TIMER) SYSCTL_PROC(_net_inet_sctp, OID_AUTO, ignore_vmware_interfaces, CTLTYPE_UINT|CTLFLAG_RW, NULL, 0, sctp_sysctl_handle_vmware_interfaces, "IU", SCTPCTL_IGNORE_VMWARE_INTERFACES_DESC); SCTP_UINT_SYSCTL(addr_watchdog_limit, sctp_addr_watchdog_limit, SCTPCTL_ADDR_WATCHDOG_LIMIT) SCTP_UINT_SYSCTL(vtag_watchdog_limit, sctp_vtag_watchdog_limit, SCTPCTL_VTAG_WATCHDOG_LIMIT) #endif -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_UINT_SYSCTL(output_unlocked, sctp_output_unlocked, SCTPCTL_OUTPUT_UNLOCKED) #endif SYSCTL_PROC(_net_inet_sctp, OID_AUTO, stats, CTLFLAG_VNET|CTLTYPE_STRUCT|CTLFLAG_RW, @@ -1345,7 +1226,7 @@ SYSCTL_PROC(_net_inet_sctp, OID_AUTO, stats, CTLFLAG_VNET|CTLTYPE_STRUCT|CTLFLAG SYSCTL_PROC(_net_inet_sctp, OID_AUTO, assoclist, CTLFLAG_VNET|CTLTYPE_OPAQUE|CTLFLAG_RD, NULL, 0, sctp_sysctl_handle_assoclist, "S,xassoc", "List of active SCTP associations"); -#elif defined(__Windows__) +#elif defined(_WIN32) && !defined(__Userspace__) #define RANGECHK(var, min, max) \ if ((var) < (min)) { (var) = (min); } \ diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_sysctl.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_sysctl.h index 3957e619fa..006a11f31d 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_sysctl.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_sysctl.h @@ -32,9 +32,9 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_sysctl.h 356357 2020-01-04 20:33:12Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_sysctl.h 366750 2020-10-16 10:44:48Z tuexen $"); #endif #ifndef _NETINET_SCTP_SYSCTL_H_ @@ -56,7 +56,7 @@ struct sctp_sysctl { uint32_t sctp_nrsack_enable; uint32_t sctp_pktdrop_enable; uint32_t sctp_fr_max_burst_default; -#if !(defined(__FreeBSD__) && __FreeBSD_version >= 800000) +#if !(defined(__FreeBSD__) && !defined(__Userspace__)) uint32_t sctp_no_csum_on_loopback; #endif uint32_t sctp_peer_chunk_oh; @@ -113,7 +113,7 @@ struct sctp_sysctl { uint32_t sctp_use_dccc_ecn; uint32_t sctp_diag_info_code; #if defined(SCTP_LOCAL_TRACE_BUF) -#if defined(__Windows__) +#if defined(_WIN32) && !defined(__Userspace__) struct sctp_log *sctp_log; #else struct sctp_log sctp_log; @@ -129,13 +129,13 @@ struct sctp_sysctl { #if defined(SCTP_DEBUG) uint32_t sctp_debug_on; #endif -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) uint32_t sctp_ignore_vmware_interfaces; uint32_t sctp_main_timer; uint32_t sctp_addr_watchdog_limit; uint32_t sctp_vtag_watchdog_limit; #endif -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) uint32_t sctp_output_unlocked; #endif }; @@ -241,7 +241,6 @@ struct sctp_sysctl { #define SCTPCTL_FRMAXBURST_MAX 0xFFFFFFFF #define SCTPCTL_FRMAXBURST_DEFAULT SCTP_DEF_FRMAX_BURST - /* maxchunks: Default max chunks on queue per asoc */ #define SCTPCTL_MAXCHUNKS_DESC "Default max chunks on queue per asoc" #define SCTPCTL_MAXCHUNKS_MIN 0 @@ -344,10 +343,10 @@ struct sctp_sysctl { #define SCTPCTL_INIT_RTO_MAX_MAX 0xFFFFFFFF #define SCTPCTL_INIT_RTO_MAX_DEFAULT SCTP_RTO_UPPER_BOUND -/* valid_cookie_life: Default cookie lifetime in sec */ -#define SCTPCTL_VALID_COOKIE_LIFE_DESC "Default cookie lifetime in seconds" -#define SCTPCTL_VALID_COOKIE_LIFE_MIN 0 -#define SCTPCTL_VALID_COOKIE_LIFE_MAX 0xFFFFFFFF +/* valid_cookie_life: Default cookie lifetime in ms */ +#define SCTPCTL_VALID_COOKIE_LIFE_DESC "Default cookie lifetime in ms" +#define SCTPCTL_VALID_COOKIE_LIFE_MIN SCTP_MIN_COOKIE_LIFE +#define SCTPCTL_VALID_COOKIE_LIFE_MAX SCTP_MAX_COOKIE_LIFE #define SCTPCTL_VALID_COOKIE_LIFE_DEFAULT SCTP_DEFAULT_COOKIE_LIFE /* init_rtx_max: Default maximum number of retransmission for INIT chunks */ @@ -498,7 +497,7 @@ struct sctp_sysctl { #define SCTPCTL_UDP_TUNNELING_PORT_DESC "Set the SCTP/UDP tunneling port" #define SCTPCTL_UDP_TUNNELING_PORT_MIN 0 #define SCTPCTL_UDP_TUNNELING_PORT_MAX 65535 -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) #define SCTPCTL_UDP_TUNNELING_PORT_DEFAULT 0 #else #define SCTPCTL_UDP_TUNNELING_PORT_DEFAULT SCTP_OVER_UDP_TUNNELING_PORT @@ -585,7 +584,7 @@ struct sctp_sysctl { #define SCTPCTL_DEBUG_DEFAULT 0 #endif -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #define SCTPCTL_MAIN_TIMER_DESC "Main timer interval in ms" #define SCTPCTL_MAIN_TIMER_MIN 1 #define SCTPCTL_MAIN_TIMER_MAX 0xFFFFFFFF @@ -595,16 +594,12 @@ struct sctp_sysctl { #define SCTPCTL_IGNORE_VMWARE_INTERFACES_MIN 0 #define SCTPCTL_IGNORE_VMWARE_INTERFACES_MAX 1 #define SCTPCTL_IGNORE_VMWARE_INTERFACES_DEFAULT SCTPCTL_IGNORE_VMWARE_INTERFACES_MAX -#endif -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) #define SCTPCTL_OUTPUT_UNLOCKED_DESC "Unlock socket when sending packets down to IP" #define SCTPCTL_OUTPUT_UNLOCKED_MIN 0 #define SCTPCTL_OUTPUT_UNLOCKED_MAX 1 #define SCTPCTL_OUTPUT_UNLOCKED_DEFAULT SCTPCTL_OUTPUT_UNLOCKED_MIN -#endif -#if defined(__APPLE__) #define SCTPCTL_ADDR_WATCHDOG_LIMIT_DESC "Address watchdog limit" #define SCTPCTL_ADDR_WATCHDOG_LIMIT_MIN 0 #define SCTPCTL_ADDR_WATCHDOG_LIMIT_MAX 0xFFFFFFFF @@ -614,8 +609,8 @@ struct sctp_sysctl { #define SCTPCTL_VTAG_WATCHDOG_LIMIT_MIN 0 #define SCTPCTL_VTAG_WATCHDOG_LIMIT_MAX 0xFFFFFFFF #define SCTPCTL_VTAG_WATCHDOG_LIMIT_DEFAULT SCTPCTL_VTAG_WATCHDOG_LIMIT_MIN -#endif +#endif #if defined(_KERNEL) || defined(__Userspace__) #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Userspace__) #if defined(SYSCTL_DECL) @@ -624,7 +619,7 @@ SYSCTL_DECL(_net_inet_sctp); #endif void sctp_init_sysctls(void); -#if defined(__Windows__) +#if defined(_WIN32) && !defined(__Userspace__) void sctp_finish_sysctls(void); #endif diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_timer.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_timer.c index 98fafec11c..e9ccdf17a7 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_timer.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_timer.c @@ -32,16 +32,16 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_timer.c 338134 2018-08-21 13:25:32Z tuexen $"); +__FBSDID("$FreeBSD$"); #endif #define _IP_VHL #include #include #ifdef INET6 -#if defined(__Userspace_os_FreeBSD) +#if defined(__FreeBSD__) && defined(__Userspace__) #include #endif #endif @@ -57,15 +57,11 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_timer.c 338134 2018-08-21 13:25:32Z tu #include #include #if defined(INET) || defined(INET6) -#if !defined(__Userspace_os_Windows) +#if !(defined(_WIN32) && defined(__Userspace__)) #include #endif #endif -#if defined(__APPLE__) -#define APPLE_FILE_NO 6 -#endif - void sctp_audit_retranmission_queue(struct sctp_association *asoc) { @@ -168,15 +164,15 @@ sctp_threshold_management(struct sctp_inpcb *inp, struct sctp_tcb *stcb, op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code), "Association error counter exceeded"); inp->last_abort_code = SCTP_FROM_SCTP_TIMER + SCTP_LOC_2; - sctp_abort_an_association(inp, stcb, op_err, SCTP_SO_NOT_LOCKED); + sctp_abort_an_association(inp, stcb, op_err, true, SCTP_SO_NOT_LOCKED); return (1); } return (0); } /* - * sctp_find_alternate_net() returns a non-NULL pointer as long - * the argument net is non-NULL. + * sctp_find_alternate_net() returns a non-NULL pointer as long as there + * exists nets, which are not being deleted. */ struct sctp_nets * sctp_find_alternate_net(struct sctp_tcb *stcb, @@ -185,13 +181,13 @@ sctp_find_alternate_net(struct sctp_tcb *stcb, { /* Find and return an alternate network if possible */ struct sctp_nets *alt, *mnet, *min_errors_net = NULL , *max_cwnd_net = NULL; - int once; + bool looped; /* JRS 5/14/07 - Initialize min_errors to an impossible value. */ int min_errors = -1; uint32_t max_cwnd = 0; if (stcb->asoc.numnets == 1) { - /* No others but net */ + /* No selection can be made. */ return (TAILQ_FIRST(&stcb->asoc.nets)); } /* @@ -327,28 +323,29 @@ sctp_find_alternate_net(struct sctp_tcb *stcb, return (max_cwnd_net); } } - mnet = net; - once = 0; - - if (mnet == NULL) { - mnet = TAILQ_FIRST(&stcb->asoc.nets); - if (mnet == NULL) { - return (NULL); - } + /* Look for an alternate net, which is active. */ + if ((net != NULL) && ((net->dest_state & SCTP_ADDR_BEING_DELETED) == 0)) { + alt = TAILQ_NEXT(net, sctp_next); + } else { + alt = TAILQ_FIRST(&stcb->asoc.nets); } + looped = false; for (;;) { - alt = TAILQ_NEXT(mnet, sctp_next); if (alt == NULL) { - once++; - if (once > 1) { + if (!looped) { + alt = TAILQ_FIRST(&stcb->asoc.nets); + looped = true; + } + /* Definitely out of candidates. */ + if (alt == NULL) { break; } - alt = TAILQ_FIRST(&stcb->asoc.nets); - if (alt == NULL) { - return (NULL); - } } +#if defined(__FreeBSD__) && !defined(__Userspace__) + if (alt->ro.ro_nh == NULL) { +#else if (alt->ro.ro_rt == NULL) { +#endif if (alt->ro._s_addr) { sctp_free_ifa(alt->ro._s_addr); alt->ro._s_addr = NULL; @@ -356,44 +353,61 @@ sctp_find_alternate_net(struct sctp_tcb *stcb, alt->src_addr_selected = 0; } if (((alt->dest_state & SCTP_ADDR_REACHABLE) == SCTP_ADDR_REACHABLE) && +#if defined(__FreeBSD__) && !defined(__Userspace__) + (alt->ro.ro_nh != NULL) && +#else (alt->ro.ro_rt != NULL) && - (!(alt->dest_state & SCTP_ADDR_UNCONFIRMED))) { - /* Found a reachable address */ +#endif + (!(alt->dest_state & SCTP_ADDR_UNCONFIRMED)) && + (alt != net)) { + /* Found an alternate net, which is reachable. */ break; } - mnet = alt; + alt = TAILQ_NEXT(alt, sctp_next); } if (alt == NULL) { - /* Case where NO insv network exists (dormant state) */ - /* we rotate destinations */ - once = 0; - mnet = net; + /* + * In case no active alternate net has been found, look for + * an alternate net, which is confirmed. + */ + if ((net != NULL) && ((net->dest_state & SCTP_ADDR_BEING_DELETED) == 0)) { + alt = TAILQ_NEXT(net, sctp_next); + } else { + alt = TAILQ_FIRST(&stcb->asoc.nets); + } + looped = false; for (;;) { - if (mnet == NULL) { - return (TAILQ_FIRST(&stcb->asoc.nets)); - } - alt = TAILQ_NEXT(mnet, sctp_next); if (alt == NULL) { - once++; - if (once > 1) { - break; + if (!looped) { + alt = TAILQ_FIRST(&stcb->asoc.nets); + looped = true; } - alt = TAILQ_FIRST(&stcb->asoc.nets); + /* Definitely out of candidates. */ if (alt == NULL) { break; } } if ((!(alt->dest_state & SCTP_ADDR_UNCONFIRMED)) && (alt != net)) { - /* Found an alternate address */ + /* Found an alternate net, which is confirmed. */ break; } - mnet = alt; + alt = TAILQ_NEXT(alt, sctp_next); } } if (alt == NULL) { - return (net); + /* + * In case no confirmed alternate net has been found, just + * return net, if it is not being deleted. In the other case + * just return the first net. + */ + if ((net != NULL) && ((net->dest_state & SCTP_ADDR_BEING_DELETED) == 0)) { + alt = net; + } + if (alt == NULL) { + alt = TAILQ_FIRST(&stcb->asoc.nets); + } } return (alt); } @@ -495,7 +509,6 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb, uint32_t tsnlast, tsnfirst; int recovery_cnt = 0; - /* none in flight now */ audit_tf = 0; fir = 0; @@ -517,7 +530,7 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb, } tv.tv_sec = cur_rto / 1000000; tv.tv_usec = cur_rto % 1000000; -#ifndef __FreeBSD__ +#if !(defined(__FreeBSD__) && !defined(__Userspace__)) timersub(&now, &tv, &min_wait); #else min_wait = now; @@ -533,8 +546,8 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb, min_wait.tv_sec = min_wait.tv_usec = 0; } if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FR_LOGGING_ENABLE) { - sctp_log_fr(cur_rto, now.tv_sec, now.tv_usec, SCTP_FR_T3_MARK_TIME); - sctp_log_fr(0, min_wait.tv_sec, min_wait.tv_usec, SCTP_FR_T3_MARK_TIME); + sctp_log_fr(cur_rto, (uint32_t)now.tv_sec, now.tv_usec, SCTP_FR_T3_MARK_TIME); + sctp_log_fr(0, (uint32_t)min_wait.tv_sec, min_wait.tv_usec, SCTP_FR_T3_MARK_TIME); } /* * Our rwnd will be incorrect here since we are not adding back the @@ -581,7 +594,7 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb, /* validate its been outstanding long enough */ if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FR_LOGGING_ENABLE) { sctp_log_fr(chk->rec.data.tsn, - chk->sent_rcv_time.tv_sec, + (uint32_t)chk->sent_rcv_time.tv_sec, chk->sent_rcv_time.tv_usec, SCTP_FR_T3_MARK_TIME); } @@ -593,7 +606,7 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb, */ if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FR_LOGGING_ENABLE) { sctp_log_fr(0, - chk->sent_rcv_time.tv_sec, + (uint32_t)chk->sent_rcv_time.tv_sec, chk->sent_rcv_time.tv_usec, SCTP_FR_T3_STOPPED); } @@ -614,7 +627,7 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb, } if (stcb->asoc.prsctp_supported && PR_SCTP_TTL_ENABLED(chk->flags)) { /* Is it expired? */ -#ifndef __FreeBSD__ +#if !(defined(__FreeBSD__) && !defined(__Userspace__)) if (timercmp(&now, &chk->rec.data.timetodrop, >)) { #else if (timevalcmp(&now, &chk->rec.data.timetodrop, >)) { @@ -806,7 +819,6 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb, return (0); } - int sctp_t3rxt_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb, @@ -848,11 +860,11 @@ sctp_t3rxt_timer(struct sctp_inpcb *inp, if (net != stcb->asoc.primary_destination) { /* send a immediate HB if our RTO is stale */ struct timeval now; - unsigned int ms_goneby; + uint32_t ms_goneby; (void)SCTP_GETTIME_TIMEVAL(&now); if (net->last_sent_time.tv_sec) { - ms_goneby = (now.tv_sec - net->last_sent_time.tv_sec) * 1000; + ms_goneby = (uint32_t)(now.tv_sec - net->last_sent_time.tv_sec) * 1000; } else { ms_goneby = 0; } @@ -942,10 +954,14 @@ sctp_t3rxt_timer(struct sctp_inpcb *inp, net->src_addr_selected = 0; /* Force a route allocation too */ +#if defined(__FreeBSD__) && !defined(__Userspace__) + RO_NHFREE(&net->ro); +#else if (net->ro.ro_rt) { RTFREE(net->ro.ro_rt); net->ro.ro_rt = NULL; } +#endif /* Was it our primary? */ if ((stcb->asoc.primary_destination == net) && (alt != net)) { @@ -982,7 +998,12 @@ sctp_t3rxt_timer(struct sctp_inpcb *inp, /* C3. See if we need to send a Fwd-TSN */ if (SCTP_TSN_GT(stcb->asoc.advanced_peer_ack_point, stcb->asoc.last_acked_seq)) { send_forward_tsn(stcb, &stcb->asoc); - if (lchk) { + for (; lchk != NULL; lchk = TAILQ_NEXT(lchk, sctp_next)) { + if (lchk->whoTo != NULL) { + break; + } + } + if (lchk != NULL) { /* Assure a timer is up */ sctp_timer_start(SCTP_TIMER_TYPE_SEND, stcb->sctp_ep, stcb, lchk->whoTo); } @@ -1064,7 +1085,7 @@ sctp_cookie_timer(struct sctp_inpcb *inp, op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code), "Cookie timer expired, but no cookie"); inp->last_abort_code = SCTP_FROM_SCTP_TIMER + SCTP_LOC_3; - sctp_abort_an_association(inp, stcb, op_err, SCTP_SO_NOT_LOCKED); + sctp_abort_an_association(inp, stcb, op_err, false, SCTP_SO_NOT_LOCKED); } else { #ifdef INVARIANTS panic("Cookie timer expires in wrong state?"); @@ -1108,10 +1129,9 @@ sctp_cookie_timer(struct sctp_inpcb *inp, } int -sctp_strreset_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb, - struct sctp_nets *net) +sctp_strreset_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb) { - struct sctp_nets *alt; + struct sctp_nets *alt, *net; struct sctp_tmit_chunk *strrst = NULL, *chk = NULL; if (stcb->asoc.stream_reset_outstanding == 0) { @@ -1122,9 +1142,9 @@ sctp_strreset_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb, if (strrst == NULL) { return (0); } + net = strrst->whoTo; /* do threshold management */ - if (sctp_threshold_management(inp, stcb, strrst->whoTo, - stcb->asoc.max_send_times)) { + if (sctp_threshold_management(inp, stcb, net, stcb->asoc.max_send_times)) { /* Assoc is over */ return (1); } @@ -1132,9 +1152,8 @@ sctp_strreset_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb, * Cleared threshold management, now lets backoff the address * and select an alternate */ - sctp_backoff_on_timeout(stcb, strrst->whoTo, 1, 0, 0); - alt = sctp_find_alternate_net(stcb, strrst->whoTo, 0); - sctp_free_remote_addr(strrst->whoTo); + sctp_backoff_on_timeout(stcb, net, 1, 0, 0); + alt = sctp_find_alternate_net(stcb, net, 0); strrst->whoTo = alt; atomic_add_int(&alt->ref_count, 1); @@ -1159,6 +1178,8 @@ sctp_strreset_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb, */ sctp_move_chunks_from_net(stcb, net); } + sctp_free_remote_addr(net); + /* mark the retran info */ if (strrst->sent != SCTP_DATAGRAM_RESEND) sctp_ucount_incr(stcb->asoc.sent_queue_retran_cnt); @@ -1166,7 +1187,7 @@ sctp_strreset_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb, strrst->flags |= CHUNK_FLAGS_FRAGMENT_OK; /* restart the timer */ - sctp_timer_start(SCTP_TIMER_TYPE_STRRESET, inp, stcb, strrst->whoTo); + sctp_timer_start(SCTP_TIMER_TYPE_STRRESET, inp, stcb, alt); return (0); } @@ -1191,8 +1212,9 @@ sctp_asconf_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb, if (asconf == NULL) { return (0); } + net = asconf->whoTo; /* do threshold management */ - if (sctp_threshold_management(inp, stcb, asconf->whoTo, + if (sctp_threshold_management(inp, stcb, net, stcb->asoc.max_send_times)) { /* Assoc is over */ return (1); @@ -1205,17 +1227,16 @@ sctp_asconf_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb, * Mark this peer as ASCONF incapable and cleanup. */ SCTPDBG(SCTP_DEBUG_TIMER1, "asconf_timer: Peer has not responded to our repeated ASCONFs\n"); - sctp_asconf_cleanup(stcb, net); + sctp_asconf_cleanup(stcb); return (0); } /* * cleared threshold management, so now backoff the net and * select an alternate */ - sctp_backoff_on_timeout(stcb, asconf->whoTo, 1, 0, 0); - alt = sctp_find_alternate_net(stcb, asconf->whoTo, 0); + sctp_backoff_on_timeout(stcb, net, 1, 0, 0); + alt = sctp_find_alternate_net(stcb, net, 0); if (asconf->whoTo != alt) { - sctp_free_remote_addr(asconf->whoTo); asconf->whoTo = alt; atomic_add_int(&alt->ref_count, 1); } @@ -1252,6 +1273,8 @@ sctp_asconf_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb, */ sctp_move_chunks_from_net(stcb, net); } + sctp_free_remote_addr(net); + /* mark the retran info */ if (asconf->sent != SCTP_DATAGRAM_RESEND) sctp_ucount_incr(stcb->asoc.sent_queue_retran_cnt); @@ -1266,8 +1289,7 @@ sctp_asconf_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb, /* Mobility adaptation */ void -sctp_delete_prim_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb, - struct sctp_nets *net SCTP_UNUSED) +sctp_delete_prim_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb) { if (stcb->asoc.deleted_primary == NULL) { SCTPDBG(SCTP_DEBUG_ASCONF1, "delete_prim_timer: deleted_primary is not stored...\n"); @@ -1335,17 +1357,18 @@ sctp_shutdownack_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb, } static void -sctp_audit_stream_queues_for_size(struct sctp_inpcb *inp, - struct sctp_tcb *stcb) +sctp_audit_stream_queues_for_size(struct sctp_inpcb *inp, struct sctp_tcb *stcb) { struct sctp_stream_queue_pending *sp; unsigned int i, chks_in_queue = 0; int being_filled = 0; - /* - * This function is ONLY called when the send/sent queues are empty. - */ - if ((stcb == NULL) || (inp == NULL)) - return; + + KASSERT(inp != NULL, ("inp is NULL")); + KASSERT(stcb != NULL, ("stcb is NULL")); + + SCTP_TCB_SEND_LOCK(stcb); + KASSERT(TAILQ_EMPTY(&stcb->asoc.send_queue), ("send_queue not empty")); + KASSERT(TAILQ_EMPTY(&stcb->asoc.sent_queue), ("sent_queue not empty")); if (stcb->asoc.sent_queue_retran_cnt) { SCTP_PRINTF("Hmm, sent_queue_retran_cnt is non-zero %d\n", @@ -1354,7 +1377,7 @@ sctp_audit_stream_queues_for_size(struct sctp_inpcb *inp, } if (stcb->asoc.ss_functions.sctp_ss_is_empty(stcb, &stcb->asoc)) { /* No stream scheduler information, initialize scheduler */ - stcb->asoc.ss_functions.sctp_ss_init(stcb, &stcb->asoc, 0); + stcb->asoc.ss_functions.sctp_ss_init(stcb, &stcb->asoc); if (!stcb->asoc.ss_functions.sctp_ss_is_empty(stcb, &stcb->asoc)) { /* yep, we lost a stream or two */ SCTP_PRINTF("Found additional streams NOT managed by scheduler, corrected\n"); @@ -1377,6 +1400,7 @@ sctp_audit_stream_queues_for_size(struct sctp_inpcb *inp, SCTP_PRINTF("Hmm, stream queue cnt at %d I counted %d in stream out wheel\n", stcb->asoc.stream_queue_cnt, chks_in_queue); } + SCTP_TCB_SEND_UNLOCK(stcb); if (chks_in_queue) { /* call the output queue function */ sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_T3, SCTP_SO_NOT_LOCKED); @@ -1441,7 +1465,7 @@ sctp_heartbeat_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb, if ((net->last_sent_time.tv_sec > 0) || (net->last_sent_time.tv_usec > 0)) { -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) struct timeval diff; SCTP_GETTIME_TIMEVAL(&diff); @@ -1487,7 +1511,7 @@ sctp_pathmtu_timer(struct sctp_inpcb *inp, if (net->ro._l_addr.sa.sa_family == AF_INET6) { struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&net->ro._l_addr; /* KAME hack: embed scopeid */ -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #if defined(APPLE_LEOPARD) || defined(APPLE_SNOWLEOPARD) (void)in6_embedscope(&sin6->sin6_addr, sin6, NULL, NULL); #else @@ -1520,7 +1544,11 @@ sctp_pathmtu_timer(struct sctp_inpcb *inp, net->src_addr_selected = 1; } if (net->ro._s_addr) { +#if defined(__FreeBSD__) && !defined(__Userspace__) + mtu = SCTP_GATHER_MTU_FROM_ROUTE(net->ro._s_addr, &net->ro._s_addr.sa, net->ro.ro_nh); +#else mtu = SCTP_GATHER_MTU_FROM_ROUTE(net->ro._s_addr, &net->ro._s_addr.sa, net->ro.ro_rt); +#endif #if defined(INET) || defined(INET6) if (net->port) { mtu -= sizeof(struct udphdr); @@ -1538,16 +1566,14 @@ sctp_pathmtu_timer(struct sctp_inpcb *inp, } void -sctp_autoclose_timer(struct sctp_inpcb *inp, - struct sctp_tcb *stcb, - struct sctp_nets *net) +sctp_autoclose_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb) { struct timeval tn, *tim_touse; struct sctp_association *asoc; - int ticks_gone_by; + uint32_t ticks_gone_by; (void)SCTP_GETTIME_TIMEVAL(&tn); - if (stcb->asoc.sctp_autoclose_ticks && + if (stcb->asoc.sctp_autoclose_ticks > 0 && sctp_is_feature_on(inp, SCTP_PCB_FLAGS_AUTOCLOSE)) { /* Auto close is on */ asoc = &stcb->asoc; @@ -1559,9 +1585,8 @@ sctp_autoclose_timer(struct sctp_inpcb *inp, tim_touse = &asoc->time_last_sent; } /* Now has long enough transpired to autoclose? */ - ticks_gone_by = SEC_TO_TICKS(tn.tv_sec - tim_touse->tv_sec); - if ((ticks_gone_by > 0) && - (ticks_gone_by >= (int)asoc->sctp_autoclose_ticks)) { + ticks_gone_by = sctp_secs_to_ticks((uint32_t)(tn.tv_sec - tim_touse->tv_sec)); + if (ticks_gone_by >= asoc->sctp_autoclose_ticks) { /* * autoclose time has hit, call the output routine, * which should do nothing just to be SURE we don't @@ -1579,7 +1604,7 @@ sctp_autoclose_timer(struct sctp_inpcb *inp, */ if (SCTP_GET_STATE(stcb) != SCTP_STATE_SHUTDOWN_SENT) { /* only send SHUTDOWN 1st time thru */ - struct sctp_nets *netp; + struct sctp_nets *net; if ((SCTP_GET_STATE(stcb) == SCTP_STATE_OPEN) || (SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_RECEIVED)) { @@ -1588,17 +1613,15 @@ sctp_autoclose_timer(struct sctp_inpcb *inp, SCTP_SET_STATE(stcb, SCTP_STATE_SHUTDOWN_SENT); sctp_stop_timers_for_shutdown(stcb); if (stcb->asoc.alternate) { - netp = stcb->asoc.alternate; + net = stcb->asoc.alternate; } else { - netp = stcb->asoc.primary_destination; + net = stcb->asoc.primary_destination; } - sctp_send_shutdown(stcb, netp); + sctp_send_shutdown(stcb, net); sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN, - stcb->sctp_ep, stcb, - netp); + stcb->sctp_ep, stcb, net); sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, - stcb->sctp_ep, stcb, - netp); + stcb->sctp_ep, stcb, NULL); } } } else { @@ -1606,13 +1629,12 @@ sctp_autoclose_timer(struct sctp_inpcb *inp, * No auto close at this time, reset t-o to check * later */ - int tmp; + uint32_t tmp; /* fool the timer startup to use the time left */ tmp = asoc->sctp_autoclose_ticks; asoc->sctp_autoclose_ticks -= ticks_gone_by; - sctp_timer_start(SCTP_TIMER_TYPE_AUTOCLOSE, inp, stcb, - net); + sctp_timer_start(SCTP_TIMER_TYPE_AUTOCLOSE, inp, stcb, NULL); /* restore the real tick value */ asoc->sctp_autoclose_ticks = tmp; } diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_timer.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_timer.h index 822d5b4007..8cfbbca5da 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_timer.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_timer.h @@ -32,9 +32,9 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_timer.h 295709 2016-02-17 18:04:22Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_timer.h 365071 2020-09-01 21:19:14Z mjg $"); #endif #ifndef _NETINET_SCTP_TIMER_H_ @@ -46,18 +46,20 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_timer.h 295709 2016-02-17 18:04:22Z tu #define SCTP_RTT_VAR_SHIFT 2 struct sctp_nets * -sctp_find_alternate_net(struct sctp_tcb *, - struct sctp_nets *, int mode); +sctp_find_alternate_net(struct sctp_tcb *, struct sctp_nets *, int); int sctp_t3rxt_timer(struct sctp_inpcb *, struct sctp_tcb *, struct sctp_nets *); + int sctp_t1init_timer(struct sctp_inpcb *, struct sctp_tcb *, struct sctp_nets *); + int sctp_shutdown_timer(struct sctp_inpcb *, struct sctp_tcb *, struct sctp_nets *); + int sctp_heartbeat_timer(struct sctp_inpcb *, struct sctp_tcb *, struct sctp_nets *); @@ -74,32 +76,28 @@ int sctp_shutdownack_timer(struct sctp_inpcb *, struct sctp_tcb *, struct sctp_nets *); int -sctp_strreset_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb, - struct sctp_nets *net); +sctp_strreset_timer(struct sctp_inpcb *, struct sctp_tcb *); int sctp_asconf_timer(struct sctp_inpcb *, struct sctp_tcb *, struct sctp_nets *); void -sctp_delete_prim_timer(struct sctp_inpcb *, struct sctp_tcb *, - struct sctp_nets *); +sctp_delete_prim_timer(struct sctp_inpcb *, struct sctp_tcb *); void -sctp_autoclose_timer(struct sctp_inpcb *, struct sctp_tcb *, - struct sctp_nets *net); +sctp_autoclose_timer(struct sctp_inpcb *, struct sctp_tcb *); void sctp_audit_retranmission_queue(struct sctp_association *); void sctp_iterator_timer(struct sctp_iterator *it); -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #if defined(APPLE_LEOPARD) || defined(APPLE_SNOWLEOPARD) || defined(APPLE_LION) || defined(APPLE_MOUNTAINLION) void sctp_slowtimo(void); #else void sctp_gc(struct inpcbinfo *); #endif #endif - #endif #endif diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_uio.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_uio.h index ecc74cc494..18956f1a14 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_uio.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_uio.h @@ -32,29 +32,28 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_uio.h 336511 2018-07-19 20:16:33Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_uio.h 365071 2020-09-01 21:19:14Z mjg $"); #endif #ifndef _NETINET_SCTP_UIO_H_ #define _NETINET_SCTP_UIO_H_ -#if (defined(__APPLE__) && defined(KERNEL)) +#if (defined(__APPLE__) && !defined(__Userspace__) && defined(KERNEL)) #ifndef _KERNEL #define _KERNEL #endif #endif - -#if !(defined(__Windows__)) && !defined(__Userspace_os_Windows) -#if ! defined(_KERNEL) +#if !defined(_WIN32) +#if !defined(_KERNEL) #include #endif #include #include #include #endif -#if defined(__Windows__) +#if defined(_WIN32) && !defined(__Userspace__) #pragma warning(push) #pragma warning(disable: 4200) #if defined(_KERNEL) @@ -110,14 +109,8 @@ struct sctp_event_subscribe { * ancillary data structures */ struct sctp_initmsg { -#if defined(__FreeBSD__) && __FreeBSD_version < 800000 - /* This is a bug. Not fixed for ABI compatibility */ - uint32_t sinit_num_ostreams; - uint32_t sinit_max_instreams; -#else uint16_t sinit_num_ostreams; uint16_t sinit_max_instreams; -#endif uint16_t sinit_max_attempts; uint16_t sinit_max_init_timeo; }; @@ -135,7 +128,6 @@ struct sctp_initmsg { * all sendrcvinfo's need a verfid for SENDING only. */ - #define SCTP_ALIGN_RESV_PAD 92 #define SCTP_ALIGN_RESV_PAD_SHORT 76 @@ -143,9 +135,6 @@ struct sctp_sndrcvinfo { uint16_t sinfo_stream; uint16_t sinfo_ssn; uint16_t sinfo_flags; -#if defined(__FreeBSD__) && __FreeBSD_version < 800000 - uint16_t sinfo_pr_policy; -#endif uint32_t sinfo_ppid; uint32_t sinfo_context; uint32_t sinfo_timetolive; @@ -161,9 +150,6 @@ struct sctp_extrcvinfo { uint16_t sinfo_stream; uint16_t sinfo_ssn; uint16_t sinfo_flags; -#if defined(__FreeBSD__) && __FreeBSD_version < 800000 - uint16_t sinfo_pr_policy; -#endif uint32_t sinfo_ppid; uint32_t sinfo_context; uint32_t sinfo_timetolive; /* should have been sinfo_pr_value */ @@ -453,7 +439,6 @@ struct sctp_setadaption { uint32_t ssb_adaption_ind; }; - /* * Partial Delivery API event */ @@ -470,7 +455,6 @@ struct sctp_pdapi_event { /* indication values */ #define SCTP_PARTIAL_DELIVERY_ABORTED 0x0001 - /* * authentication key event */ @@ -490,7 +474,6 @@ struct sctp_authkey_event { #define SCTP_AUTH_NO_AUTH 0x0002 #define SCTP_AUTH_FREE_KEY 0x0003 - struct sctp_sender_dry_event { uint16_t sender_dry_type; uint16_t sender_dry_flags; @@ -498,7 +481,6 @@ struct sctp_sender_dry_event { sctp_assoc_t sender_dry_assoc_id; }; - /* * Stream reset event - subscribe to SCTP_STREAM_RESET_EVENT */ @@ -546,7 +528,6 @@ struct sctp_stream_change_event { #define SCTP_STREAM_CHANGE_DENIED 0x0004 #define SCTP_STREAM_CHANGE_FAILED 0x0008 - /* SCTP notification event */ struct sctp_tlv { uint16_t sn_type; @@ -662,10 +643,18 @@ struct sctp_setpeerprim { uint8_t sspp_padding[4]; }; +union sctp_sockstore { + struct sockaddr_in sin; + struct sockaddr_in6 sin6; +#if defined(__Userspace__) + struct sockaddr_conn sconn; +#endif + struct sockaddr sa; +}; + struct sctp_getaddresses { sctp_assoc_t sget_assoc_id; - /* addr is filled in for N * sockaddr_storage */ - struct sockaddr addr[1]; + union sctp_sockstore addr[]; }; struct sctp_status { @@ -1121,13 +1110,18 @@ struct sctpstat { #define SCTP_STAT_INCR(_x) SCTP_STAT_INCR_BY(_x,1) #define SCTP_STAT_DECR(_x) SCTP_STAT_DECR_BY(_x,1) -#if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT) +#if defined(__FreeBSD__) && !defined(__Userspace__) +#if defined(SMP) && defined(SCTP_USE_PERCPU_STAT) #define SCTP_STAT_INCR_BY(_x,_d) (SCTP_BASE_STATS[PCPU_GET(cpuid)]._x += _d) #define SCTP_STAT_DECR_BY(_x,_d) (SCTP_BASE_STATS[PCPU_GET(cpuid)]._x -= _d) #else #define SCTP_STAT_INCR_BY(_x,_d) atomic_add_int(&SCTP_BASE_STAT(_x), _d) #define SCTP_STAT_DECR_BY(_x,_d) atomic_subtract_int(&SCTP_BASE_STAT(_x), _d) #endif +#else +#define SCTP_STAT_INCR_BY(_x,_d) atomic_add_int(&SCTP_BASE_STAT(_x), _d) +#define SCTP_STAT_DECR_BY(_x,_d) atomic_subtract_int(&SCTP_BASE_STAT(_x), _d) +#endif /* The following macros are for handling MIB values, */ #define SCTP_STAT_INCR_COUNTER32(_x) SCTP_STAT_INCR(_x) #define SCTP_STAT_INCR_COUNTER64(_x) SCTP_STAT_INCR(_x) @@ -1136,24 +1130,14 @@ struct sctpstat { #define SCTP_STAT_DECR_COUNTER64(_x) SCTP_STAT_DECR(_x) #define SCTP_STAT_DECR_GAUGE32(_x) SCTP_STAT_DECR(_x) -union sctp_sockstore { - struct sockaddr_in sin; - struct sockaddr_in6 sin6; -#if defined(__Userspace__) - struct sockaddr_conn sconn; -#endif - struct sockaddr sa; -}; - - /***********************************/ /* And something for us old timers */ /***********************************/ -#ifndef __APPLE__ -#ifndef __Userspace__ +#if !(defined(__APPLE__) && !defined(__Userspace__)) +#if !defined(__Userspace__) #ifndef ntohll -#if defined(__Userspace_os_Linux) +#if defined(__linux__) #ifndef _BSD_SOURCE #define _BSD_SOURCE #endif @@ -1165,7 +1149,7 @@ union sctp_sockstore { #endif #ifndef htonll -#if defined(__Userspace_os_Linux) +#if defined(__linux__) #ifndef _BSD_SOURCE #define _BSD_SOURCE #endif @@ -1179,21 +1163,16 @@ union sctp_sockstore { #endif /***********************************/ - struct xsctp_inpcb { uint32_t last; uint32_t flags; -#if defined(__FreeBSD__) && __FreeBSD_version < 1000048 - uint32_t features; -#else uint64_t features; -#endif uint32_t total_sends; uint32_t total_recvs; uint32_t total_nospaces; uint32_t fragmentation_point; uint16_t local_port; -#if defined(__FreeBSD__) && __FreeBSD_version > 1100096 +#if defined(__FreeBSD__) && !defined(__Userspace__) uint16_t qlen_old; uint16_t maxqlen_old; #else @@ -1201,22 +1180,16 @@ struct xsctp_inpcb { uint16_t maxqlen; #endif uint16_t __spare16; -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) kvaddr_t socket; #else void *socket; #endif -#if defined(__FreeBSD__) && __FreeBSD_version > 1100096 +#if defined(__FreeBSD__) && !defined(__Userspace__) uint32_t qlen; uint32_t maxqlen; #endif -#if defined(__FreeBSD__) && __FreeBSD_version < 1000048 - uint32_t extra_padding[32]; /* future */ -#elif defined(__FreeBSD__) && (__FreeBSD_version < 1001517) - uint32_t extra_padding[31]; /* future */ -#else uint32_t extra_padding[26]; /* future */ -#endif }; struct xsctp_tcb { @@ -1245,18 +1218,9 @@ struct xsctp_tcb { uint16_t remote_port; /* sctpAssocEntry 4 */ struct sctp_timeval start_time; /* sctpAssocEntry 16 */ struct sctp_timeval discontinuity_time; /* sctpAssocEntry 17 */ -#if defined(__FreeBSD__) -#if __FreeBSD_version >= 800000 uint32_t peers_rwnd; sctp_assoc_t assoc_id; /* sctpAssocEntry 1 */ uint32_t extra_padding[32]; /* future */ -#else -#endif -#else - uint32_t peers_rwnd; - sctp_assoc_t assoc_id; /* sctpAssocEntry 1 */ - uint32_t extra_padding[32]; /* future */ -#endif }; struct xsctp_laddr { @@ -1281,23 +1245,12 @@ struct xsctp_raddr { uint8_t heartbeat_enabled; /* sctpAssocLocalRemEntry 4 */ uint8_t potentially_failed; struct sctp_timeval start_time; /* sctpAssocLocalRemEntry 8 */ -#if defined(__FreeBSD__) -#if __FreeBSD_version >= 800000 uint32_t rtt; uint32_t heartbeat_interval; uint32_t ssthresh; uint16_t encaps_port; uint16_t state; uint32_t extra_padding[29]; /* future */ -#endif -#else - uint32_t rtt; - uint32_t heartbeat_interval; - uint32_t ssthresh; - uint16_t encaps_port; - uint16_t state; - uint32_t extra_padding[29]; /* future */ -#endif }; #define SCTP_MAX_LOGGING_SIZE 30000 @@ -1324,19 +1277,14 @@ int sctp_lower_sosend(struct socket *so, struct sockaddr *addr, struct uio *uio, -#if defined(__Panda__) - pakhandle_type i_pak, - pakhandle_type i_control, -#else struct mbuf *i_pak, struct mbuf *control, -#endif int flags, struct sctp_sndrcvinfo *srcv -#if !(defined(__Panda__) || defined(__Userspace__)) -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 +#if !defined(__Userspace__) +#if defined(__FreeBSD__) ,struct thread *p -#elif defined(__Windows__) +#elif defined(_WIN32) , PKTHREAD p #else ,struct proc *p @@ -1347,11 +1295,7 @@ sctp_lower_sosend(struct socket *so, int sctp_sorecvmsg(struct socket *so, struct uio *uio, -#if defined(__Panda__) - particletype **mp, -#else struct mbuf **mp, -#endif struct sockaddr *from, int fromlen, int *msg_flags, @@ -1365,45 +1309,6 @@ sctp_sorecvmsg(struct socket *so, #if !(defined(_KERNEL)) && !(defined(__Userspace__)) __BEGIN_DECLS -#if defined(__FreeBSD__) && __FreeBSD_version < 902000 -int sctp_peeloff __P((int, sctp_assoc_t)); -int sctp_bindx __P((int, struct sockaddr *, int, int)); -int sctp_connectx __P((int, const struct sockaddr *, int, sctp_assoc_t *)); -int sctp_getaddrlen __P((sa_family_t)); -int sctp_getpaddrs __P((int, sctp_assoc_t, struct sockaddr **)); -void sctp_freepaddrs __P((struct sockaddr *)); -int sctp_getladdrs __P((int, sctp_assoc_t, struct sockaddr **)); -void sctp_freeladdrs __P((struct sockaddr *)); -int sctp_opt_info __P((int, sctp_assoc_t, int, void *, socklen_t *)); - -/* deprecated */ -ssize_t sctp_sendmsg __P((int, const void *, size_t, const struct sockaddr *, - socklen_t, uint32_t, uint32_t, uint16_t, uint32_t, uint32_t)); - -/* deprecated */ -ssize_t sctp_send __P((int, const void *, size_t, - const struct sctp_sndrcvinfo *, int)); - -/* deprecated */ -ssize_t sctp_sendx __P((int, const void *, size_t, struct sockaddr *, - int, struct sctp_sndrcvinfo *, int)); - -/* deprecated */ -ssize_t sctp_sendmsgx __P((int sd, const void *, size_t, struct sockaddr *, - int, uint32_t, uint32_t, uint16_t, uint32_t, uint32_t)); - -sctp_assoc_t sctp_getassocid __P((int, struct sockaddr *)); - -/* deprecated */ -ssize_t sctp_recvmsg __P((int, void *, size_t, struct sockaddr *, socklen_t *, - struct sctp_sndrcvinfo *, int *)); - -ssize_t sctp_sendv __P((int, const struct iovec *, int, struct sockaddr *, - int, void *, socklen_t, unsigned int, int)); - -ssize_t sctp_recvv __P((int, const struct iovec *, int, struct sockaddr *, - socklen_t *, void *, socklen_t *, unsigned int *, int *)); -#else int sctp_peeloff(int, sctp_assoc_t); int sctp_bindx(int, struct sockaddr *, int, int); int sctp_connectx(int, const struct sockaddr *, int, sctp_assoc_t *); @@ -1441,7 +1346,6 @@ ssize_t sctp_sendv(int, const struct iovec *, int, struct sockaddr *, ssize_t sctp_recvv(int, const struct iovec *, int, struct sockaddr *, socklen_t *, void *, socklen_t *, unsigned int *, int *); -#endif __END_DECLS #endif /* !_KERNEL */ diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_userspace.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_userspace.c index 28922b6a17..41aff19e08 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_userspace.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_userspace.c @@ -32,24 +32,24 @@ #include #include #if !defined(__MINGW32__) -#pragma comment(lib, "IPHLPAPI.lib") +#pragma comment(lib, "iphlpapi.lib") #endif #endif #include -#if defined(__Userspace_os_FreeBSD) +#if defined(__FreeBSD__) #include #endif -#if defined(__Userspace_os_Linux) +#if defined(__linux__) #include #endif -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) /* Adapter to translate Unix thread start routines to Windows thread start * routines. */ #if defined(__MINGW32__) -#pragma GCC diagnostic push +#pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpedantic" #endif static DWORD WINAPI @@ -83,42 +83,61 @@ sctp_userspace_thread_create(userland_thread_t *thread, start_routine_t start_ro void sctp_userspace_set_threadname(const char *name) { -#if defined(__Userspace_os_Darwin) +#if defined(__APPLE__) pthread_setname_np(name); #endif -#if defined(__Userspace_os_Linux) +#if defined(__linux__) prctl(PR_SET_NAME, name); #endif -#if defined(__Userspace_os_FreeBSD) +#if defined(__FreeBSD__) pthread_set_name_np(pthread_self(), name); #endif } -#if !defined(_WIN32) && !defined(__Userspace_os_NaCl) +#if !defined(_WIN32) && !defined(__native_client__) int sctp_userspace_get_mtu_from_ifn(uint32_t if_index, int af) { +#if defined(INET) || defined(INET6) struct ifreq ifr; int fd; +#endif + int mtu; - memset(&ifr, 0, sizeof(struct ifreq)); - if (if_indextoname(if_index, ifr.ifr_name) != NULL) { - /* TODO can I use the raw socket here and not have to open a new one with each query? */ - if ((fd = socket(af, SOCK_DGRAM, 0)) < 0) - return (0); - if (ioctl(fd, SIOCGIFMTU, &ifr) < 0) { + switch (af) { +#if defined(INET) + case AF_INET: +#endif +#if defined(INET6) + case AF_INET6: +#endif +#if defined(INET) || defined(INET6) + memset(&ifr, 0, sizeof(struct ifreq)); + mtu = 0; + if (if_indextoname(if_index, ifr.ifr_name) != NULL) { + /* TODO can I use the raw socket here and not have to open a new one with each query? */ + if ((fd = socket(af, SOCK_DGRAM, 0)) < 0) { + break; + } + if (ioctl(fd, SIOCGIFMTU, &ifr) >= 0) { + mtu = ifr.ifr_mtu; + } close(fd); - return (0); } - close(fd); - return ifr.ifr_mtu; - } else { - return (0); + break; +#endif + case AF_CONN: + mtu = 1280; + break; + default: + mtu = 0; + break; } + return (mtu); } #endif -#if defined(__Userspace_os_NaCl) +#if defined(__native_client__) int sctp_userspace_get_mtu_from_ifn(uint32_t if_index, int af) { @@ -126,7 +145,7 @@ sctp_userspace_get_mtu_from_ifn(uint32_t if_index, int af) } #endif -#if defined(__Userspace_os_Darwin) || defined(__Userspace_os_DragonFly) || defined(__Userspace_os_Linux) || defined(__Userspace_os_NaCl) || defined(__Userspace_os_NetBSD) || defined(__Userspace_os_Windows) || defined(__Userspace_os_Fuchsia) +#if defined(__APPLE__) || defined(__DragonFly__) || defined(__linux__) || defined(__native_client__) || defined(__NetBSD__) || defined(_WIN32) || defined(__Fuchsia__) || defined(__EMSCRIPTEN__) int timingsafe_bcmp(const void *b1, const void *b2, size_t n) { @@ -143,51 +162,88 @@ timingsafe_bcmp(const void *b1, const void *b2, size_t n) int sctp_userspace_get_mtu_from_ifn(uint32_t if_index, int af) { +#if defined(INET) || defined(INET6) PIP_ADAPTER_ADDRESSES pAdapterAddrs, pAdapt; DWORD AdapterAddrsSize, Err; - int ret; +#endif + int mtu; - ret = 0; - AdapterAddrsSize = 0; - pAdapterAddrs = NULL; - if ((Err = GetAdaptersAddresses(AF_UNSPEC, 0, NULL, NULL, &AdapterAddrsSize)) != 0) { - if ((Err != ERROR_BUFFER_OVERFLOW) && (Err != ERROR_INSUFFICIENT_BUFFER)) { - SCTPDBG(SCTP_DEBUG_USR, "GetAdaptersAddresses() sizing failed with error code %d, AdapterAddrsSize = %d\n", Err, AdapterAddrsSize); - ret = -1; + switch (af) { +#if defined(INET) + case AF_INET: +#endif +#if defined(INET6) + case AF_INET6: +#endif +#if defined(INET) || defined(INET6) + mtu = 0; + AdapterAddrsSize = 0; + pAdapterAddrs = NULL; + if ((Err = GetAdaptersAddresses(AF_UNSPEC, 0, NULL, NULL, &AdapterAddrsSize)) != 0) { + if ((Err != ERROR_BUFFER_OVERFLOW) && (Err != ERROR_INSUFFICIENT_BUFFER)) { + SCTPDBG(SCTP_DEBUG_USR, "GetAdaptersAddresses() sizing failed with error code %d, AdapterAddrsSize = %d\n", Err, AdapterAddrsSize); + mtu = -1; + goto cleanup; + } + } + if ((pAdapterAddrs = (PIP_ADAPTER_ADDRESSES) GlobalAlloc(GPTR, AdapterAddrsSize)) == NULL) { + SCTPDBG(SCTP_DEBUG_USR, "Memory allocation error!\n"); + mtu = -1; goto cleanup; } - } - if ((pAdapterAddrs = (PIP_ADAPTER_ADDRESSES) GlobalAlloc(GPTR, AdapterAddrsSize)) == NULL) { - SCTPDBG(SCTP_DEBUG_USR, "Memory allocation error!\n"); - ret = -1; - goto cleanup; - } - if ((Err = GetAdaptersAddresses(AF_UNSPEC, 0, NULL, pAdapterAddrs, &AdapterAddrsSize)) != ERROR_SUCCESS) { - SCTPDBG(SCTP_DEBUG_USR, "GetAdaptersAddresses() failed with error code %d\n", Err); - ret = -1; - goto cleanup; - } - for (pAdapt = pAdapterAddrs; pAdapt; pAdapt = pAdapt->Next) { - if (pAdapt->IfIndex == if_index) { - ret = pAdapt->Mtu; - break; + if ((Err = GetAdaptersAddresses(AF_UNSPEC, 0, NULL, pAdapterAddrs, &AdapterAddrsSize)) != ERROR_SUCCESS) { + SCTPDBG(SCTP_DEBUG_USR, "GetAdaptersAddresses() failed with error code %d\n", Err); + mtu = -1; + goto cleanup; } + for (pAdapt = pAdapterAddrs; pAdapt; pAdapt = pAdapt->Next) { + if (pAdapt->IfIndex == if_index) { + mtu = pAdapt->Mtu; + break; + } + } + cleanup: + if (pAdapterAddrs != NULL) { + GlobalFree(pAdapterAddrs); + } + break; +#endif + case AF_CONN: + mtu = 1280; + break; + default: + mtu = 0; + break; } -cleanup: - if (pAdapterAddrs != NULL) { - GlobalFree(pAdapterAddrs); - } - return (ret); + return (mtu); } void getwintimeofday(struct timeval *tv) { - struct timeb tb; + FILETIME filetime; + ULARGE_INTEGER ularge; - ftime(&tb); - tv->tv_sec = (long)tb.time; - tv->tv_usec = (long)(tb.millitm) * 1000L; + GetSystemTimeAsFileTime(&filetime); + ularge.LowPart = filetime.dwLowDateTime; + ularge.HighPart = filetime.dwHighDateTime; + /* Change base from Jan 1 1601 00:00:00 to Jan 1 1970 00:00:00 */ +#if defined(__MINGW32__) + ularge.QuadPart -= 116444736000000000ULL; +#else + ularge.QuadPart -= 116444736000000000UI64; +#endif + /* + * ularge.QuadPart is now the number of 100-nanosecond intervals + * since Jan 1 1970 00:00:00. + */ +#if defined(__MINGW32__) + tv->tv_sec = (long)(ularge.QuadPart / 10000000ULL); + tv->tv_usec = (long)((ularge.QuadPart % 10000000ULL) / 10ULL); +#else + tv->tv_sec = (long)(ularge.QuadPart / 10000000UI64); + tv->tv_usec = (long)((ularge.QuadPart % 10000000UI64) / 10UI64); +#endif } int diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_usrreq.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_usrreq.c index 6a19f62aa0..1756bf411c 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_usrreq.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_usrreq.c @@ -32,13 +32,13 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_usrreq.c 356270 2020-01-02 13:55:10Z tuexen $"); +__FBSDID("$FreeBSD$"); #endif #include -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include #endif #include @@ -61,78 +61,56 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_usrreq.c 356270 2020-01-02 13:55:10Z t #else #include #endif -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) #include #endif - #if defined(HAVE_SCTP_PEELOFF_SOCKOPT) #include #endif /* HAVE_SCTP_PEELOFF_SOCKOPT */ -#if defined(__APPLE__) -#define APPLE_FILE_NO 7 -#endif - extern const struct sctp_cc_functions sctp_cc_functions[]; extern const struct sctp_ss_functions sctp_ss_functions[]; -void #if defined(__Userspace__) +void sctp_init(uint16_t port, int (*conn_output)(void *addr, void *buffer, size_t length, uint8_t tos, uint8_t set_df), void (*debug_printf)(const char *format, ...), int start_threads) #elif defined(__APPLE__) && (!defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) &&!defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION)) +void sctp_init(struct protosw *pp SCTP_UNUSED, struct domain *dp SCTP_UNUSED) +#elif defined(__FreeBSD__) +static void +sctp_init(void *arg SCTP_UNUSED) #else +void sctp_init(void) #endif { -#if !defined(__Panda__) && !defined(__Userspace__) +#if !defined(__Userspace__) u_long sb_max_adj; +#else + init_random(); #endif /* Initialize and modify the sysctled variables */ sctp_init_sysctls(); #if defined(__Userspace__) -#if defined(__Userspace_os_Windows) || defined(__Userspace_os_NaCl) -#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - srand(0); -#else - srand((unsigned int)time(NULL)); -#endif -#else -#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - srandom(0); -#else - srandom(getpid()); /* so inp->sctp_ep.random_numbers are truly random... */ -#endif -#endif -#endif -#if defined(__Panda__) - sctp_sendspace = SB_MAX; - sctp_recvspace = SB_MAX; - -#elif defined(__Userspace__) SCTP_BASE_SYSCTL(sctp_udp_tunneling_port) = port; #else -#if !defined(__APPLE__) - if ((nmbclusters / 8) > SCTP_ASOC_MAX_CHUNKS_ON_QUEUE) - SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue) = (nmbclusters / 8); -#endif - /* - * Allow a user to take no more than 1/2 the number of clusters or - * the SB_MAX whichever is smaller for the send window. - */ -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) sb_max_adj = (u_long)((u_quad_t) (sb_max) * MCLBYTES / (MSIZE + MCLBYTES)); -#else - sb_max_adj = (u_long)((u_quad_t) (SB_MAX) * MCLBYTES / (MSIZE + MCLBYTES)); -#endif -#if defined(__APPLE__) SCTP_BASE_SYSCTL(sctp_sendspace) = sb_max_adj; #else + if ((nmbclusters / 8) > SCTP_ASOC_MAX_CHUNKS_ON_QUEUE) + SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue) = (nmbclusters / 8); + /* + * Allow a user to take no more than 1/2 the number of clusters or + * the SB_MAX, whichever is smaller, for the send window. + */ + sb_max_adj = (u_long)((u_quad_t) (SB_MAX) * MCLBYTES / (MSIZE + MCLBYTES)); SCTP_BASE_SYSCTL(sctp_sendspace) = min(sb_max_adj, - (((uint32_t)nmbclusters / 2) * SCTP_DEFAULT_MAXSEGMENT)); + (((uint32_t)nmbclusters / 2) * MCLBYTES)); #endif /* * Now for the recv window, should we take the same amount? or @@ -144,7 +122,7 @@ sctp_init(void) SCTP_BASE_VAR(first_time) = 0; SCTP_BASE_VAR(sctp_pcb_initialized) = 0; #if defined(__Userspace__) -#if !defined(__Userspace_os_Windows) +#if !defined(_WIN32) #if defined(INET) || defined(INET6) SCTP_BASE_VAR(userspace_route) = -1; #endif @@ -161,11 +139,14 @@ sctp_init(void) SCTP_BASE_VAR(conn_output) = conn_output; SCTP_BASE_VAR(debug_printf) = debug_printf; SCTP_BASE_VAR(crc32c_offloaded) = 0; + SCTP_BASE_VAR(iterator_thread_started) = 0; + SCTP_BASE_VAR(timer_thread_started) = 0; #endif #if defined(__Userspace__) sctp_pcb_init(start_threads); - if (start_threads) - sctp_start_timer(); + if (start_threads) { + sctp_start_timer_thread(); + } #else sctp_pcb_init(); #endif @@ -174,22 +155,24 @@ sctp_init(void) SCTP_BASE_VAR(packet_log_end) = 0; memset(&SCTP_BASE_VAR(packet_log_buffer), 0, SCTP_PACKET_LOG_SIZE); #endif -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_BASE_VAR(sctp_main_timer_ticks) = 0; sctp_start_main_timer(); timeout(sctp_delayed_startup, NULL, 1); #endif -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) SCTP_BASE_VAR(eh_tag) = EVENTHANDLER_REGISTER(rt_addrmsg, sctp_addr_change_event_handler, NULL, EVENTHANDLER_PRI_FIRST); #endif } +#if defined(__FreeBSD__) && !defined(__Userspace__) +VNET_SYSINIT(sctp_init, SI_SUB_PROTO_DOMAIN, SI_ORDER_THIRD, sctp_init, NULL); -#if defined(__FreeBSD__) #ifdef VIMAGE static void sctp_finish(void *unused __unused) { + EVENTHANDLER_DEREGISTER(rt_addrmsg, SCTP_BASE_VAR(eh_tag)); sctp_pcb_finish(); } VNET_SYSUNINIT(sctp, SI_SUB_PROTO_DOMAIN, SI_ORDER_FOURTH, sctp_finish, NULL); @@ -198,7 +181,7 @@ VNET_SYSUNINIT(sctp, SI_SUB_PROTO_DOMAIN, SI_ORDER_FOURTH, sctp_finish, NULL); void sctp_finish(void) { -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) untimeout(sctp_delayed_startup, NULL); sctp_over_udp_stop(); sctp_address_monitor_stop(); @@ -208,103 +191,80 @@ sctp_finish(void) #if defined(INET) || defined(INET6) recv_thread_destroy(); #endif -#if !defined(__Userspace_os_Windows) -#if defined(INET) || defined(INET6) - if (SCTP_BASE_VAR(userspace_route) != -1) { - pthread_join(SCTP_BASE_VAR(recvthreadroute), NULL); - } -#endif -#endif -#ifdef INET - if (SCTP_BASE_VAR(userspace_rawsctp) != -1) { -#if defined(__Userspace_os_Windows) - WaitForSingleObject(SCTP_BASE_VAR(recvthreadraw), INFINITE); - CloseHandle(SCTP_BASE_VAR(recvthreadraw)); -#else - pthread_join(SCTP_BASE_VAR(recvthreadraw), NULL); -#endif - } - if (SCTP_BASE_VAR(userspace_udpsctp) != -1) { -#if defined(__Userspace_os_Windows) - WaitForSingleObject(SCTP_BASE_VAR(recvthreadudp), INFINITE); - CloseHandle(SCTP_BASE_VAR(recvthreadudp)); -#else - pthread_join(SCTP_BASE_VAR(recvthreadudp), NULL); -#endif - } -#endif -#ifdef INET6 - if (SCTP_BASE_VAR(userspace_rawsctp6) != -1) { -#if defined(__Userspace_os_Windows) - WaitForSingleObject(SCTP_BASE_VAR(recvthreadraw6), INFINITE); - CloseHandle(SCTP_BASE_VAR(recvthreadraw6)); -#else - pthread_join(SCTP_BASE_VAR(recvthreadraw6), NULL); -#endif - } - if (SCTP_BASE_VAR(userspace_udpsctp6) != -1) { -#if defined(__Userspace_os_Windows) - WaitForSingleObject(SCTP_BASE_VAR(recvthreadudp6), INFINITE); - CloseHandle(SCTP_BASE_VAR(recvthreadudp6)); -#else - pthread_join(SCTP_BASE_VAR(recvthreadudp6), NULL); -#endif - } -#endif - atomic_cmpset_int(&SCTP_BASE_VAR(timer_thread_should_exit), 0, 1); -#if defined(__Userspace_os_Windows) - WaitForSingleObject(SCTP_BASE_VAR(timer_thread), INFINITE); - CloseHandle(SCTP_BASE_VAR(timer_thread)); -#else - pthread_join(SCTP_BASE_VAR(timer_thread), NULL); -#endif + sctp_stop_timer_thread(); #endif sctp_pcb_finish(); -#if defined(__Windows__) +#if defined(_WIN32) && !defined(__Userspace__) sctp_finish_sysctls(); #endif +#if defined(__Userspace__) + finish_random(); +#endif } #endif void -sctp_pathmtu_adjustment(struct sctp_tcb *stcb, uint16_t nxtsz) +sctp_pathmtu_adjustment(struct sctp_tcb *stcb, uint32_t mtu, bool resend) { + struct sctp_association *asoc; struct sctp_tmit_chunk *chk; - uint16_t overhead; + uint32_t overhead; - /* Adjust that too */ - stcb->asoc.smallest_mtu = nxtsz; - /* now off to subtract IP_DF flag if needed */ - overhead = IP_HDR_SIZE + sizeof(struct sctphdr); - if (sctp_auth_is_required_chunk(SCTP_DATA, stcb->asoc.peer_auth_chunks)) { - overhead += sctp_get_auth_chunk_len(stcb->asoc.peer_hmac_id); + asoc = &stcb->asoc; + KASSERT(mtu < asoc->smallest_mtu, + ("Currently only reducing association MTU %u supported (MTU %u)", + asoc->smallest_mtu, mtu)); + asoc->smallest_mtu = mtu; + if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) { + overhead = SCTP_MIN_OVERHEAD; + } else { +#if defined(__Userspace__) + if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_BOUND_CONN) { + overhead = sizeof(struct sctphdr); + } else { + overhead = SCTP_MIN_V4_OVERHEAD; + } +#else + overhead = SCTP_MIN_V4_OVERHEAD; +#endif } - TAILQ_FOREACH(chk, &stcb->asoc.send_queue, sctp_next) { - if ((chk->send_size + overhead) > nxtsz) { + if (asoc->idata_supported) { + if (sctp_auth_is_required_chunk(SCTP_IDATA, asoc->peer_auth_chunks)) { + overhead += sctp_get_auth_chunk_len(asoc->peer_hmac_id); + } + } else { + if (sctp_auth_is_required_chunk(SCTP_DATA, asoc->peer_auth_chunks)) { + overhead += sctp_get_auth_chunk_len(asoc->peer_hmac_id); + } + } + KASSERT(overhead % 4 == 0, + ("overhead (%u) not a multiple of 4", overhead)); + TAILQ_FOREACH(chk, &asoc->send_queue, sctp_next) { + if (((uint32_t)chk->send_size + overhead) > mtu) { chk->flags |= CHUNK_FLAGS_FRAGMENT_OK; } } - TAILQ_FOREACH(chk, &stcb->asoc.sent_queue, sctp_next) { - if ((chk->send_size + overhead) > nxtsz) { - /* - * For this guy we also mark for immediate resend - * since we sent to big of chunk - */ + TAILQ_FOREACH(chk, &asoc->sent_queue, sctp_next) { + if (((uint32_t)chk->send_size + overhead) > mtu) { chk->flags |= CHUNK_FLAGS_FRAGMENT_OK; - if (chk->sent < SCTP_DATAGRAM_RESEND) { + if (resend && chk->sent < SCTP_DATAGRAM_RESEND) { + /* + * If requested, mark the chunk for immediate + * resend, since we sent it being too big. + */ sctp_flight_size_decrease(chk); sctp_total_flight_decrease(stcb, chk); chk->sent = SCTP_DATAGRAM_RESEND; - sctp_ucount_incr(stcb->asoc.sent_queue_retran_cnt); + sctp_ucount_incr(asoc->sent_queue_retran_cnt); chk->rec.data.doing_fast_retransmit = 0; if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FLIGHT_LOGGING_ENABLE) { sctp_misc_ints(SCTP_FLIGHT_LOG_DOWN_PMTU, - chk->whoTo->flight_size, - chk->book_size, - (uint32_t)(uintptr_t)chk->whoTo, - chk->rec.data.tsn); + chk->whoTo->flight_size, + chk->book_size, + (uint32_t)(uintptr_t)chk->whoTo, + chk->rec.data.tsn); } - /* Clear any time so NO RTT is being done */ + /* Clear any time, so NO RTT is being done. */ if (chk->do_rtt == 1) { chk->do_rtt = 0; chk->whoTo->rto_needed = 1; @@ -325,7 +285,7 @@ sctp_notify(struct sctp_inpcb *inp, uint16_t ip_len, uint32_t next_mtu) { -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) struct socket *so; #endif int timer_stopped; @@ -342,9 +302,7 @@ sctp_notify(struct sctp_inpcb *inp, (icmp_code == ICMP_UNREACH_ISOLATED) || (icmp_code == ICMP_UNREACH_NET_PROHIB) || (icmp_code == ICMP_UNREACH_HOST_PROHIB) || -#if defined(__Panda__) - (icmp_code == ICMP_UNREACH_ADMIN)) { -#elif defined(__Userspace_os_NetBSD) +#if defined(__NetBSD__) (icmp_code == ICMP_UNREACH_ADMIN_PROHIBIT)) { #else (icmp_code == ICMP_UNREACH_FILTER_PROHIB)) { @@ -362,8 +320,8 @@ sctp_notify(struct sctp_inpcb *inp, } else if ((icmp_code == ICMP_UNREACH_PROTOCOL) || (icmp_code == ICMP_UNREACH_PORT)) { /* Treat it like an ABORT. */ - sctp_abort_notification(stcb, 1, 0, NULL, SCTP_SO_NOT_LOCKED); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) + sctp_abort_notification(stcb, true, false, 0, NULL, SCTP_SO_NOT_LOCKED); +#if defined(__APPLE__) && !defined(__Userspace__) so = SCTP_INP_SO(inp); atomic_add_int(&stcb->asoc.refcnt, 1); SCTP_TCB_UNLOCK(stcb); @@ -373,7 +331,7 @@ sctp_notify(struct sctp_inpcb *inp, #endif (void)sctp_free_assoc(inp, stcb, SCTP_NORMAL_PROC, SCTP_FROM_SCTP_USRREQ + SCTP_LOC_2); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_UNLOCK(so, 1); /* SCTP_TCB_UNLOCK(stcb); MT: I think this is not needed.*/ #endif @@ -407,7 +365,7 @@ sctp_notify(struct sctp_inpcb *inp, } if (net->mtu > next_mtu) { net->mtu = next_mtu; -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (net->port) { sctp_hc_set_mtu(&net->ro._l_addr, inp->fibnum, next_mtu + sizeof(struct udphdr)); } else { @@ -417,7 +375,7 @@ sctp_notify(struct sctp_inpcb *inp, } /* Update the association MTU */ if (stcb->asoc.smallest_mtu > next_mtu) { - sctp_pathmtu_adjustment(stcb, next_mtu); + sctp_pathmtu_adjustment(stcb, next_mtu, true); } /* Finally, start the PMTU timer if it was running before. */ if (timer_stopped) { @@ -430,19 +388,15 @@ sctp_notify(struct sctp_inpcb *inp, } #endif -#if !defined(__Panda__) && !defined(__Userspace__) -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) void -#else -void * -#endif #if defined(__APPLE__) && !defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) && !defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION) && !defined(APPLE_ELCAPITAN) sctp_ctlinput(int cmd, struct sockaddr *sa, void *vip, struct ifnet *ifp SCTP_UNUSED) #else sctp_ctlinput(int cmd, struct sockaddr *sa, void *vip) #endif { -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) struct ip *outer_ip; #endif struct ip *inner_ip; @@ -451,33 +405,25 @@ sctp_ctlinput(int cmd, struct sockaddr *sa, void *vip) struct sctp_inpcb *inp; struct sctp_tcb *stcb; struct sctp_nets *net; -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) struct sctp_init_chunk *ch; #endif struct sockaddr_in src, dst; if (sa->sa_family != AF_INET || ((struct sockaddr_in *)sa)->sin_addr.s_addr == INADDR_ANY) { -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) return; -#else - return (NULL); -#endif } if (PRC_IS_REDIRECT(cmd)) { vip = NULL; } else if ((unsigned)cmd >= PRC_NCMDS || inetctlerrmap[cmd] == 0) { -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) return; -#else - return (NULL); -#endif } if (vip != NULL) { inner_ip = (struct ip *)vip; icmp = (struct icmp *)((caddr_t)inner_ip - (sizeof(struct icmp) - sizeof(struct ip))); -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) outer_ip = (struct ip *)((caddr_t)icmp - sizeof(struct ip)); #endif sh = (struct sctphdr *)((caddr_t)inner_ip + (inner_ip->ip_hl << 2)); @@ -521,7 +467,7 @@ sctp_ctlinput(int cmd, struct sockaddr *sa, void *vip) return; } } else { -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (ntohs(outer_ip->ip_len) >= sizeof(struct ip) + 8 + (inner_ip->ip_hl << 2) + 20) { @@ -548,7 +494,7 @@ sctp_ctlinput(int cmd, struct sockaddr *sa, void *vip) sctp_notify(inp, stcb, net, icmp->icmp_type, icmp->icmp_code, -#if defined(__FreeBSD__) && __FreeBSD_version >= 1000000 +#if defined(__FreeBSD__) && !defined(__Userspace__) ntohs(inner_ip->ip_len), #else inner_ip->ip_len, @@ -573,16 +519,6 @@ sctp_ctlinput(int cmd, struct sockaddr *sa, void *vip) } #endif } else { -#if defined(__FreeBSD__) && __FreeBSD_version < 500000 - /* - * XXX must be fixed for 5.x and higher, leave for - * 4.x - */ - if (PRC_IS_REDIRECT(cmd) && (inp != NULL)) { - in_rtchange((struct inpcb *)inp, - inetctlerrmap[cmd]); - } -#endif if ((stcb == NULL) && (inp != NULL)) { /* reduce ref-count */ SCTP_INP_WLOCK(inp); @@ -594,16 +530,12 @@ sctp_ctlinput(int cmd, struct sockaddr *sa, void *vip) } } } -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) return; -#else - return (NULL); -#endif } #endif #endif -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) static int sctp_getcred(SYSCTL_HANDLER_ARGS) { @@ -618,14 +550,8 @@ sctp_getcred(SYSCTL_HANDLER_ARGS) /* FIX, for non-bsd is this right? */ vrf_id = SCTP_DEFAULT_VRFID; -#if __FreeBSD_version > 602000 error = priv_check(req->td, PRIV_NETINET_GETCRED); -#elif __FreeBSD_version >= 500000 - error = suser(req->td); -#else - error = suser(req->p); -#endif if (error) return (error); @@ -670,27 +596,30 @@ out: return (error); } -SYSCTL_PROC(_net_inet_sctp, OID_AUTO, getcred, CTLTYPE_OPAQUE | CTLFLAG_RW, - 0, 0, sctp_getcred, "S,ucred", "Get the ucred of a SCTP connection"); -#endif /* #if defined(__FreeBSD__) */ - +SYSCTL_PROC(_net_inet_sctp, OID_AUTO, getcred, + CTLTYPE_OPAQUE | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + 0, 0, sctp_getcred, "S,ucred", + "Get the ucred of a SCTP connection"); +#endif #ifdef INET -#if defined(__Panda__) || defined(__Windows__) || defined(__Userspace__) +#if defined(_WIN32) || defined(__Userspace__) int -#elif defined(__FreeBSD__) && __FreeBSD_version > 690000 +#elif defined(__FreeBSD__) static void #else static int #endif sctp_abort(struct socket *so) { +#if defined(__FreeBSD__) && !defined(__Userspace__) + struct epoch_tracker et; +#endif struct sctp_inpcb *inp; - uint32_t flags; inp = (struct sctp_inpcb *)so->so_pcb; if (inp == NULL) { -#if defined(__FreeBSD__) && __FreeBSD_version > 690000 +#if defined(__FreeBSD__) && !defined(__Userspace__) return; #else SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); @@ -698,16 +627,19 @@ sctp_abort(struct socket *so) #endif } - sctp_must_try_again: - flags = inp->sctp_flags; + SCTP_INP_WLOCK(inp); +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_ENTER(et); +#endif #ifdef SCTP_LOG_CLOSING sctp_log_closing(inp, NULL, 17); #endif - if (((flags & SCTP_PCB_FLAGS_SOCKET_GONE) == 0) && - (atomic_cmpset_int(&inp->sctp_flags, flags, (flags | SCTP_PCB_FLAGS_SOCKET_GONE | SCTP_PCB_FLAGS_CLOSE_IP)))) { + if (((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) == 0)) { + inp->sctp_flags |= SCTP_PCB_FLAGS_SOCKET_GONE | SCTP_PCB_FLAGS_CLOSE_IP; #ifdef SCTP_LOG_CLOSING sctp_log_closing(inp, NULL, 16); #endif + SCTP_INP_WUNLOCK(inp); sctp_inpcb_free(inp, SCTP_FREE_SHOULD_USE_ABORT, SCTP_CALLED_AFTER_CMPSET_OFCLOSE); SOCK_LOCK(so); @@ -717,7 +649,7 @@ sctp_abort(struct socket *so) */ SCTP_SB_CLEAR(so->so_rcv); -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) so->so_usecount--; #else /* Now null out the reference, we are completely detached. */ @@ -725,28 +657,25 @@ sctp_abort(struct socket *so) #endif SOCK_UNLOCK(so); } else { - flags = inp->sctp_flags; - if ((flags & SCTP_PCB_FLAGS_SOCKET_GONE) == 0) { - goto sctp_must_try_again; - } + SCTP_INP_WUNLOCK(inp); } -#if defined(__FreeBSD__) && __FreeBSD_version > 690000 - return; +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_EXIT(et); #else return (0); #endif } -#if defined(__Panda__) || defined(__Userspace__) +#if defined(__Userspace__) int #else static int #endif -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 -sctp_attach(struct socket *so, int proto SCTP_UNUSED, struct thread *p SCTP_UNUSED) -#elif defined(__Panda__) || defined(__Userspace__) +#if defined(__Userspace__) sctp_attach(struct socket *so, int proto SCTP_UNUSED, uint32_t vrf_id) -#elif defined(__Windows__) +#elif defined(__FreeBSD__) +sctp_attach(struct socket *so, int proto SCTP_UNUSED, struct thread *p SCTP_UNUSED) +#elif defined(_WIN32) sctp_attach(struct socket *so, int proto SCTP_UNUSED, PKTHREAD p SCTP_UNUSED) #else sctp_attach(struct socket *so, int proto SCTP_UNUSED, struct proc *p SCTP_UNUSED) @@ -755,7 +684,7 @@ sctp_attach(struct socket *so, int proto SCTP_UNUSED, struct proc *p SCTP_UNUSED struct sctp_inpcb *inp; struct inpcb *ip_inp; int error; -#if !defined(__Panda__) && !defined(__Userspace__) +#if !defined(__Userspace__) uint32_t vrf_id = SCTP_DEFAULT_VRFID; #endif @@ -784,18 +713,18 @@ sctp_attach(struct socket *so, int proto SCTP_UNUSED, struct proc *p SCTP_UNUSED return (0); } -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 -static int -sctp_bind(struct socket *so, struct sockaddr *addr, struct thread *p) -{ -#elif defined(__FreeBSD__) || defined(__APPLE__) -static int -sctp_bind(struct socket *so, struct sockaddr *addr, struct proc *p) { -#elif defined(__Panda__) || defined(__Userspace__) +#if defined(__Userspace__) int sctp_bind(struct socket *so, struct sockaddr *addr) { void *p = NULL; -#elif defined(__Windows__) +#elif defined(__FreeBSD__) +static int +sctp_bind(struct socket *so, struct sockaddr *addr, struct thread *p) +{ +#elif defined(__APPLE__) +static int +sctp_bind(struct socket *so, struct sockaddr *addr, struct proc *p) { +#elif defined(_WIN32) static int sctp_bind(struct socket *so, struct sockaddr *addr, PKTHREAD p) { #else @@ -887,12 +816,14 @@ sctpconn_bind(struct socket *so, struct sockaddr *addr) } #endif -#if (defined(__FreeBSD__) && __FreeBSD_version > 690000) || defined(__Windows__) || defined(__Userspace__) +#if defined(__FreeBSD__) || defined(_WIN32) || defined(__Userspace__) void sctp_close(struct socket *so) { +#if defined(__FreeBSD__) && !defined(__Userspace__) + struct epoch_tracker et; +#endif struct sctp_inpcb *inp; - uint32_t flags; inp = (struct sctp_inpcb *)so->so_pcb; if (inp == NULL) @@ -901,13 +832,15 @@ sctp_close(struct socket *so) /* Inform all the lower layer assoc that we * are done. */ - sctp_must_try_again: - flags = inp->sctp_flags; + SCTP_INP_WLOCK(inp); +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_ENTER(et); +#endif #ifdef SCTP_LOG_CLOSING sctp_log_closing(inp, NULL, 17); #endif - if (((flags & SCTP_PCB_FLAGS_SOCKET_GONE) == 0) && - (atomic_cmpset_int(&inp->sctp_flags, flags, (flags | SCTP_PCB_FLAGS_SOCKET_GONE | SCTP_PCB_FLAGS_CLOSE_IP)))) { + if ((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) == 0) { + inp->sctp_flags |= SCTP_PCB_FLAGS_SOCKET_GONE | SCTP_PCB_FLAGS_CLOSE_IP; #if defined(__Userspace__) if (((so->so_options & SCTP_SO_LINGER) && (so->so_linger == 0)) || (so->so_rcv.sb_cc > 0)) { @@ -918,12 +851,14 @@ sctp_close(struct socket *so) #ifdef SCTP_LOG_CLOSING sctp_log_closing(inp, NULL, 13); #endif + SCTP_INP_WUNLOCK(inp); sctp_inpcb_free(inp, SCTP_FREE_SHOULD_USE_ABORT, SCTP_CALLED_AFTER_CMPSET_OFCLOSE); } else { #ifdef SCTP_LOG_CLOSING sctp_log_closing(inp, NULL, 14); #endif + SCTP_INP_WUNLOCK(inp); sctp_inpcb_free(inp, SCTP_FREE_SHOULD_USE_GRACEFUL_CLOSE, SCTP_CALLED_AFTER_CMPSET_OFCLOSE); } @@ -937,23 +872,19 @@ sctp_close(struct socket *so) */ SCTP_SB_CLEAR(so->so_rcv); -#if !defined(__APPLE__) +#if !(defined(__APPLE__) && !defined(__Userspace__)) /* Now null out the reference, we are completely detached. */ so->so_pcb = NULL; #endif SOCK_UNLOCK(so); } else { - flags = inp->sctp_flags; - if ((flags & SCTP_PCB_FLAGS_SOCKET_GONE) == 0) { - goto sctp_must_try_again; - } + SCTP_INP_WUNLOCK(inp); } - return; +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_EXIT(et); +#endif } - #else - - int sctp_detach(struct socket *so) { @@ -962,7 +893,7 @@ sctp_detach(struct socket *so) inp = (struct sctp_inpcb *)so->so_pcb; if (inp == NULL) { -#if defined(__FreeBSD__) && __FreeBSD_version > 690000 +#if defined(__FreeBSD__) && !defined(__Userspace__) return; #else SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); @@ -1003,7 +934,7 @@ sctp_detach(struct socket *so) * here for the accounting/select. */ SCTP_SB_CLEAR(so->so_rcv); -#if !defined(__APPLE__) +#if !(defined(__APPLE__) && !defined(__Userspace__)) /* Now disconnect */ so->so_pcb = NULL; #endif @@ -1013,7 +944,7 @@ sctp_detach(struct socket *so) goto sctp_must_try_again; } } -#if defined(__FreeBSD__) && __FreeBSD_version > 690000 +#if defined(__FreeBSD__) && !defined(__Userspace__) return; #else return (0); @@ -1024,9 +955,9 @@ sctp_detach(struct socket *so) #if defined(__Userspace__) /* __Userspace__ is not calling sctp_sendm */ #endif -#if !(defined(__Panda__) || defined(__Windows__)) +#if !(defined(_WIN32) && !defined(__Userspace__)) int -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 +#if defined(__FreeBSD__) && !defined(__Userspace__) sctp_sendm(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, struct mbuf *control, struct thread *p); @@ -1035,9 +966,8 @@ sctp_sendm(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, struct mbuf *control, struct proc *p); #endif - int -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 +#if defined(__FreeBSD__) && !defined(__Userspace__) sctp_sendm(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, struct mbuf *control, struct thread *p) { @@ -1064,9 +994,22 @@ sctp_sendm(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, ((inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED) || (inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE))) { goto connected_type; - } else if (addr == NULL) { + } + + error = 0; + if (addr == NULL) { SCTP_LTRACE_ERR_RET_PKT(m, inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EDESTADDRREQ); error = EDESTADDRREQ; + } else if (addr->sa_family != AF_INET) { + SCTP_LTRACE_ERR_RET_PKT(m, inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EAFNOSUPPORT); + error = EAFNOSUPPORT; +#if defined(HAVE_SA_LEN) + } else if (addr->sa_len != sizeof(struct sockaddr_in)) { + SCTP_LTRACE_ERR_RET_PKT(m, inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); + error = EINVAL; +#endif + } + if (error != 0) { sctp_m_freem(m); if (control) { sctp_m_freem(control); @@ -1074,19 +1017,6 @@ sctp_sendm(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, } return (error); } -#ifdef INET6 - if (addr->sa_family != AF_INET) { - /* must be a v4 address! */ - SCTP_LTRACE_ERR_RET_PKT(m, inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EDESTADDRREQ); - sctp_m_freem(m); - if (control) { - sctp_m_freem(control); - control = NULL; - } - error = EDESTADDRREQ; - return (error); - } -#endif /* INET6 */ connected_type: /* now what about control */ if (control) { @@ -1104,7 +1034,7 @@ connected_type: inp->pkt_last = inp->pkt = m; } if ( -#if defined(__FreeBSD__) || defined(__APPLE__) +#if (defined(__FreeBSD__) || defined(__APPLE__)) && !defined(__Userspace__) /* FreeBSD uses a flag passed */ ((flags & PRUS_MORETOCOME) == 0) #else @@ -1120,9 +1050,18 @@ connected_type: * definitions) but this is not advisable. This code is used * by FreeBSD when sending a file with sendfile() though. */ +#if defined(__FreeBSD__) && !defined(__Userspace__) + struct epoch_tracker et; +#endif int ret; +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_ENTER(et); +#endif ret = sctp_output(inp, inp->pkt, addr, inp->control, p, flags); +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_EXIT(et); +#endif inp->pkt = NULL; inp->control = NULL; return (ret); @@ -1150,6 +1089,9 @@ sctp_disconnect(struct socket *so) SCTP_INP_RUNLOCK(inp); return (0); } else { +#if defined(__FreeBSD__) && !defined(__Userspace__) + struct epoch_tracker et; +#endif struct sctp_association *asoc; struct sctp_tcb *stcb; @@ -1167,6 +1109,9 @@ sctp_disconnect(struct socket *so) SCTP_INP_RUNLOCK(inp); return (0); } +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_ENTER(et); +#endif #if defined(__Userspace__) if (((so->so_options & SCTP_SO_LINGER) && (so->so_linger == 0)) || @@ -1192,6 +1137,9 @@ sctp_disconnect(struct socket *so) (void)sctp_free_assoc(inp, stcb, SCTP_NORMAL_PROC, SCTP_FROM_SCTP_USRREQ + SCTP_LOC_3); /* No unlock tcb assoc is gone */ +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_EXIT(et); +#endif return (0); } if (TAILQ_EMPTY(&asoc->send_queue) && @@ -1219,9 +1167,9 @@ sctp_disconnect(struct socket *so) } sctp_send_shutdown(stcb,netp); sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN, - stcb->sctp_ep, stcb, netp); + stcb->sctp_ep, stcb, netp); sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, - stcb->sctp_ep, stcb, netp); + stcb->sctp_ep, stcb, NULL); sctp_chunk_output(stcb->sctp_ep, stcb, SCTP_OUTPUT_FROM_T3, SCTP_SO_LOCKED); } } else { @@ -1235,16 +1183,8 @@ sctp_disconnect(struct socket *so) * we will allow user data to be sent first * and move to SHUTDOWN-PENDING */ - struct sctp_nets *netp; - if (stcb->asoc.alternate) { - netp = stcb->asoc.alternate; - } else { - netp = stcb->asoc.primary_destination; - } - SCTP_ADD_SUBSTATE(stcb, SCTP_STATE_SHUTDOWN_PENDING); - sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb, - netp); + sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb, NULL); if ((*asoc->ss_functions.sctp_ss_is_user_msgs_incomplete)(stcb, asoc)) { SCTP_ADD_SUBSTATE(stcb, SCTP_STATE_PARTIAL_MSG_LEFT); } @@ -1264,12 +1204,18 @@ sctp_disconnect(struct socket *so) SCTP_INP_RUNLOCK(inp); (void)sctp_free_assoc(inp, stcb, SCTP_NORMAL_PROC, SCTP_FROM_SCTP_USRREQ + SCTP_LOC_5); +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_EXIT(et); +#endif return (0); } else { sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_CLOSING, SCTP_SO_LOCKED); } } soisdisconnecting(so); +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_EXIT(et); +#endif SCTP_TCB_UNLOCK(stcb); SCTP_INP_RUNLOCK(inp); return (0); @@ -1283,7 +1229,7 @@ sctp_disconnect(struct socket *so) } } -#if defined(__FreeBSD__) || defined(__Windows__) || defined(__Userspace__) +#if defined(__FreeBSD__) || defined(_WIN32) || defined(__Userspace__) int sctp_flush(struct socket *so, int how) { @@ -1328,7 +1274,6 @@ sctp_flush(struct socket *so, int how) so->so_snd.sb_cc = 0; so->so_snd.sb_mbcnt = 0; so->so_snd.sb_mb = NULL; - } return (0); } @@ -1349,7 +1294,7 @@ sctp_shutdown(struct socket *so) if (!((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL))) { /* Restore the flags that the soshutdown took away. */ -#if (defined(__FreeBSD__) && __FreeBSD_version >= 502115) || defined(__Windows__) +#if (defined(__FreeBSD__) || defined(_WIN32)) && !defined(__Userspace__) SOCKBUF_LOCK(&so->so_rcv); so->so_rcv.sb_state &= ~SBS_CANTRCVMORE; SOCKBUF_UNLOCK(&so->so_rcv); @@ -1368,6 +1313,9 @@ sctp_shutdown(struct socket *so) * a SHUT_WR or SHUT_RDWR. * This means we put the shutdown flag against it. */ +#if defined(__FreeBSD__) && !defined(__Userspace__) + struct epoch_tracker et; +#endif struct sctp_tcb *stcb; struct sctp_association *asoc; struct sctp_nets *netp; @@ -1406,6 +1354,9 @@ sctp_shutdown(struct socket *so) SCTP_INP_RUNLOCK(inp); return (0); } +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_ENTER(et); +#endif if (stcb->asoc.alternate) { netp = stcb->asoc.alternate; } else { @@ -1443,15 +1394,21 @@ sctp_shutdown(struct socket *so) stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_USRREQ + SCTP_LOC_6; SCTP_INP_RUNLOCK(inp); sctp_abort_an_association(stcb->sctp_ep, stcb, - op_err, SCTP_SO_LOCKED); + op_err, false, SCTP_SO_LOCKED); +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_EXIT(et); +#endif return (0); } } - sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb, netp); + sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb, NULL); /* XXX: Why do this in the case where we have still data queued? */ sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_CLOSING, SCTP_SO_LOCKED); SCTP_TCB_UNLOCK(stcb); SCTP_INP_RUNLOCK(inp); +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_EXIT(et); +#endif return (0); } } @@ -1461,33 +1418,33 @@ sctp_shutdown(struct socket *so) * returns 0 on success, 1 on error */ static uint32_t -sctp_fill_user_address(struct sockaddr_storage *ss, struct sockaddr *sa) +sctp_fill_user_address(struct sockaddr *dst, struct sockaddr *src) { #ifdef INET6 #if defined(SCTP_EMBEDDED_V6_SCOPE) struct sockaddr_in6 lsa6; - sa = (struct sockaddr *)sctp_recover_scope((struct sockaddr_in6 *)sa, + src = (struct sockaddr *)sctp_recover_scope((struct sockaddr_in6 *)src, &lsa6); #endif #endif #ifdef HAVE_SA_LEN - memcpy(ss, sa, sa->sa_len); + memcpy(dst, src, src->sa_len); #else - switch (sa->sa_family) { + switch (src->sa_family) { #ifdef INET case AF_INET: - memcpy(ss, sa, sizeof(struct sockaddr_in)); + memcpy(dst, src, sizeof(struct sockaddr_in)); break; #endif #ifdef INET6 case AF_INET6: - memcpy(ss, sa, sizeof(struct sockaddr_in6)); + memcpy(dst, src, sizeof(struct sockaddr_in6)); break; #endif #if defined(__Userspace__) case AF_CONN: - memcpy(ss, sa, sizeof(struct sockaddr_conn)); + memcpy(dst, src, sizeof(struct sockaddr_conn)); break; #endif default: @@ -1498,17 +1455,12 @@ sctp_fill_user_address(struct sockaddr_storage *ss, struct sockaddr *sa) return (0); } - - -/* - * NOTE: assumes addr lock is held - */ static size_t sctp_fill_up_addresses_vrf(struct sctp_inpcb *inp, - struct sctp_tcb *stcb, - size_t limit, - struct sockaddr_storage *sas, - uint32_t vrf_id) + struct sctp_tcb *stcb, + size_t limit, + struct sockaddr *addr, + uint32_t vrf_id) { struct sctp_ifn *sctp_ifn; struct sctp_ifa *sctp_ifa; @@ -1525,8 +1477,9 @@ sctp_fill_up_addresses_vrf(struct sctp_inpcb *inp, #endif struct sctp_vrf *vrf; + SCTP_IPI_ADDR_LOCK_ASSERT(); actual = 0; - if (limit <= 0) + if (limit == 0) return (actual); if (stcb) { @@ -1613,7 +1566,7 @@ sctp_fill_up_addresses_vrf(struct sctp_inpcb *inp, * is one of those we must skip it. */ if (sctp_is_addr_restricted(stcb, - sctp_ifa)) { + sctp_ifa)) { continue; } } @@ -1631,7 +1584,7 @@ sctp_fill_up_addresses_vrf(struct sctp_inpcb *inp, */ continue; } -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (prison_check_ip4(inp->ip_inp.inp.inp_cred, &sin->sin_addr) != 0) { continue; @@ -1646,18 +1599,18 @@ sctp_fill_up_addresses_vrf(struct sctp_inpcb *inp, if (actual + sizeof(struct sockaddr_in6) > limit) { return (actual); } - in6_sin_2_v4mapsin6(sin, (struct sockaddr_in6 *)sas); - ((struct sockaddr_in6 *)sas)->sin6_port = inp->sctp_lport; - sas = (struct sockaddr_storage *)((caddr_t)sas + sizeof(struct sockaddr_in6)); + in6_sin_2_v4mapsin6(sin, (struct sockaddr_in6 *)addr); + ((struct sockaddr_in6 *)addr)->sin6_port = inp->sctp_lport; + addr = (struct sockaddr *)((caddr_t)addr + sizeof(struct sockaddr_in6)); actual += sizeof(struct sockaddr_in6); } else { #endif if (actual + sizeof(struct sockaddr_in) > limit) { return (actual); } - memcpy(sas, sin, sizeof(struct sockaddr_in)); - ((struct sockaddr_in *)sas)->sin_port = inp->sctp_lport; - sas = (struct sockaddr_storage *)((caddr_t)sas + sizeof(struct sockaddr_in)); + memcpy(addr, sin, sizeof(struct sockaddr_in)); + ((struct sockaddr_in *)addr)->sin_port = inp->sctp_lport; + addr = (struct sockaddr *)((caddr_t)addr + sizeof(struct sockaddr_in)); actual += sizeof(struct sockaddr_in); #ifdef INET6 } @@ -1683,7 +1636,7 @@ sctp_fill_up_addresses_vrf(struct sctp_inpcb *inp, */ continue; } -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (prison_check_ip6(inp->ip_inp.inp.inp_cred, &sin6->sin6_addr) != 0) { continue; @@ -1725,9 +1678,9 @@ sctp_fill_up_addresses_vrf(struct sctp_inpcb *inp, if (actual + sizeof(struct sockaddr_in6) > limit) { return (actual); } - memcpy(sas, sin6, sizeof(struct sockaddr_in6)); - ((struct sockaddr_in6 *)sas)->sin6_port = inp->sctp_lport; - sas = (struct sockaddr_storage *)((caddr_t)sas + sizeof(struct sockaddr_in6)); + memcpy(addr, sin6, sizeof(struct sockaddr_in6)); + ((struct sockaddr_in6 *)addr)->sin6_port = inp->sctp_lport; + addr = (struct sockaddr *)((caddr_t)addr + sizeof(struct sockaddr_in6)); actual += sizeof(struct sockaddr_in6); } else { continue; @@ -1740,9 +1693,9 @@ sctp_fill_up_addresses_vrf(struct sctp_inpcb *inp, if (actual + sizeof(struct sockaddr_conn) > limit) { return (actual); } - memcpy(sas, &sctp_ifa->address.sconn, sizeof(struct sockaddr_conn)); - ((struct sockaddr_conn *)sas)->sconn_port = inp->sctp_lport; - sas = (struct sockaddr_storage *)((caddr_t)sas + sizeof(struct sockaddr_conn)); + memcpy(addr, &sctp_ifa->address.sconn, sizeof(struct sockaddr_conn)); + ((struct sockaddr_conn *)addr)->sconn_port = inp->sctp_lport; + addr = (struct sockaddr *)((caddr_t)addr + sizeof(struct sockaddr_conn)); actual += sizeof(struct sockaddr_conn); } else { continue; @@ -1792,29 +1745,29 @@ sctp_fill_up_addresses_vrf(struct sctp_inpcb *inp, if (actual + sa_len > limit) { return (actual); } - if (sctp_fill_user_address(sas, &laddr->ifa->address.sa)) + if (sctp_fill_user_address(addr, &laddr->ifa->address.sa)) continue; switch (laddr->ifa->address.sa.sa_family) { #ifdef INET case AF_INET: - ((struct sockaddr_in *)sas)->sin_port = inp->sctp_lport; + ((struct sockaddr_in *)addr)->sin_port = inp->sctp_lport; break; #endif #ifdef INET6 case AF_INET6: - ((struct sockaddr_in6 *)sas)->sin6_port = inp->sctp_lport; + ((struct sockaddr_in6 *)addr)->sin6_port = inp->sctp_lport; break; #endif #if defined(__Userspace__) case AF_CONN: - ((struct sockaddr_conn *)sas)->sconn_port = inp->sctp_lport; + ((struct sockaddr_conn *)addr)->sconn_port = inp->sctp_lport; break; #endif default: /* TSNH */ break; } - sas = (struct sockaddr_storage *)((caddr_t)sas + sa_len); + addr = (struct sockaddr *)((caddr_t)addr + sa_len); actual += sa_len; } } @@ -1825,9 +1778,9 @@ static size_t sctp_fill_up_addresses(struct sctp_inpcb *inp, struct sctp_tcb *stcb, size_t limit, - struct sockaddr_storage *sas) + struct sockaddr *addr) { - size_t size = 0; + size_t size; #ifdef SCTP_MVRF uint32_t id; #endif @@ -1839,40 +1792,40 @@ sctp_fill_up_addresses(struct sctp_inpcb *inp, * in more than one VRF. */ /* fill up addresses for all VRFs on the endpoint */ + size = 0; for (id = 0; (id < inp->num_vrfs) && (size < limit); id++) { - size += sctp_fill_up_addresses_vrf(inp, stcb, limit, sas, - inp->m_vrf_ids[id]); - sas = (struct sockaddr_storage *)((caddr_t)sas + size); + size += sctp_fill_up_addresses_vrf(inp, stcb, limit, addr, + inp->m_vrf_ids[id]); + addr = (struct sockaddr *)((caddr_t)addr + size); } #else /* fill up addresses for the endpoint's default vrf */ - size = sctp_fill_up_addresses_vrf(inp, stcb, limit, sas, - inp->def_vrf_id); + size = sctp_fill_up_addresses_vrf(inp, stcb, limit, addr, + inp->def_vrf_id); #endif SCTP_IPI_ADDR_RUNLOCK(); return (size); } -/* - * NOTE: assumes addr lock is held - */ -static int -sctp_count_max_addresses_vrf(struct sctp_inpcb *inp, uint32_t vrf_id) +static size_t +sctp_max_size_addresses_vrf(struct sctp_inpcb *inp, uint32_t vrf_id) { - int cnt = 0; - struct sctp_vrf *vrf = NULL; + struct sctp_vrf *vrf; + size_t size; /* - * In both sub-set bound an bound_all cases we return the MAXIMUM - * number of addresses that you COULD get. In reality the sub-set - * bound may have an exclusion list for a given TCB OR in the - * bound-all case a TCB may NOT include the loopback or other + * In both sub-set bound an bound_all cases we return the size of + * the maximum number of addresses that you could get. In reality + * the sub-set bound may have an exclusion list for a given TCB or + * in the bound-all case a TCB may NOT include the loopback or other * addresses as well. */ + SCTP_IPI_ADDR_LOCK_ASSERT(); vrf = sctp_find_vrf(vrf_id); if (vrf == NULL) { return (0); } + size = 0; if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) { struct sctp_ifn *sctp_ifn; struct sctp_ifa *sctp_ifa; @@ -1885,22 +1838,22 @@ sctp_count_max_addresses_vrf(struct sctp_inpcb *inp, uint32_t vrf_id) case AF_INET: #ifdef INET6 if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_NEEDS_MAPPED_V4)) - cnt += sizeof(struct sockaddr_in6); + size += sizeof(struct sockaddr_in6); else - cnt += sizeof(struct sockaddr_in); + size += sizeof(struct sockaddr_in); #else - cnt += sizeof(struct sockaddr_in); + size += sizeof(struct sockaddr_in); #endif break; #endif #ifdef INET6 case AF_INET6: - cnt += sizeof(struct sockaddr_in6); + size += sizeof(struct sockaddr_in6); break; #endif #if defined(__Userspace__) case AF_CONN: - cnt += sizeof(struct sockaddr_conn); + size += sizeof(struct sockaddr_conn); break; #endif default: @@ -1917,22 +1870,22 @@ sctp_count_max_addresses_vrf(struct sctp_inpcb *inp, uint32_t vrf_id) case AF_INET: #ifdef INET6 if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_NEEDS_MAPPED_V4)) - cnt += sizeof(struct sockaddr_in6); + size += sizeof(struct sockaddr_in6); else - cnt += sizeof(struct sockaddr_in); + size += sizeof(struct sockaddr_in); #else - cnt += sizeof(struct sockaddr_in); + size += sizeof(struct sockaddr_in); #endif break; #endif #ifdef INET6 case AF_INET6: - cnt += sizeof(struct sockaddr_in6); + size += sizeof(struct sockaddr_in6); break; #endif #if defined(__Userspace__) case AF_CONN: - cnt += sizeof(struct sockaddr_conn); + size += sizeof(struct sockaddr_conn); break; #endif default: @@ -1940,13 +1893,13 @@ sctp_count_max_addresses_vrf(struct sctp_inpcb *inp, uint32_t vrf_id) } } } - return (cnt); + return (size); } -static int -sctp_count_max_addresses(struct sctp_inpcb *inp) +static size_t +sctp_max_size_addresses(struct sctp_inpcb *inp) { - int cnt = 0; + size_t size; #ifdef SCTP_MVRF int id; #endif @@ -1957,16 +1910,17 @@ sctp_count_max_addresses(struct sctp_inpcb *inp) * FIX ME: ?? this WILL count duplicate addresses if they appear * in more than one VRF. */ - /* count addresses for all VRFs on the endpoint */ + /* Maximum size of all addresses for all VRFs on the endpoint */ + size = 0; for (id = 0; id < inp->num_vrfs; id++) { - cnt += sctp_count_max_addresses_vrf(inp, inp->m_vrf_ids[id]); + size += sctp_max_size_addresses_vrf(inp, inp->m_vrf_ids[id]); } #else - /* count addresses for the endpoint's default VRF */ - cnt = sctp_count_max_addresses_vrf(inp, inp->def_vrf_id); + /* Maximum size of all addresses for the endpoint's default VRF */ + size = sctp_max_size_addresses_vrf(inp, inp->def_vrf_id); #endif SCTP_IPI_ADDR_RUNLOCK(); - return (cnt); + return (size); } static int @@ -2056,28 +2010,22 @@ sctp_do_connect_x(struct socket *so, struct sctp_inpcb *inp, void *optval, /* FIX ME: do we want to pass in a vrf on the connect call? */ vrf_id = inp->def_vrf_id; - /* We are GOOD to go */ - stcb = sctp_aloc_assoc(inp, sa, &error, 0, vrf_id, - inp->sctp_ep.pre_open_stream_count, - inp->sctp_ep.port, -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 - (struct thread *)p, -#elif defined(__Windows__) - (PKTHREAD)p, + stcb = sctp_aloc_assoc_connected(inp, sa, &error, 0, 0, vrf_id, + inp->sctp_ep.pre_open_stream_count, + inp->sctp_ep.port, +#if defined(__FreeBSD__) && !defined(__Userspace__) + (struct thread *)p, +#elif defined(_WIN32) && !defined(__Userspace__) + (PKTHREAD)p, #else - (struct proc *)p, + (struct proc *)p, #endif - SCTP_INITIALIZE_AUTH_PARAMS); + SCTP_INITIALIZE_AUTH_PARAMS); if (stcb == NULL) { /* Gak! no memory */ goto out_now; } - if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) { - stcb->sctp_ep->sctp_flags |= SCTP_PCB_FLAGS_CONNECTED; - /* Set the connected flag so we can queue data */ - soisconnecting(so); - } SCTP_SET_STATE(stcb, SCTP_STATE_COOKIE_WAIT); /* move to second address */ switch (sa->sa_family) { @@ -2142,7 +2090,6 @@ sctp_do_connect_x(struct socket *so, struct sctp_inpcb *inp, void *optval, } \ } - #define SCTP_CHECK_AND_CAST(destp, srcp, type, size) {\ if (size < sizeof(type)) { \ SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); \ @@ -2153,7 +2100,7 @@ sctp_do_connect_x(struct socket *so, struct sctp_inpcb *inp, void *optval, } \ } -#if defined(__Panda__) || defined(__Userspace__) +#if defined(__Userspace__) int #else static int @@ -2213,7 +2160,7 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, break; case SCTP_AUTOCLOSE: if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_AUTOCLOSE)) - val = TICKS_TO_SEC(inp->sctp_ep.auto_close_time); + val = sctp_ticks_to_secs(inp->sctp_ep.auto_close_time); else val = 0; break; @@ -2643,7 +2590,7 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) && (sack->sack_assoc_id == SCTP_FUTURE_ASSOC))) { SCTP_INP_RLOCK(inp); - sack->sack_delay = TICKS_TO_MSEC(inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_RECV]); + sack->sack_delay = sctp_ticks_to_msecs(inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_RECV]); sack->sack_freq = inp->sctp_ep.sctp_sack_freq; SCTP_INP_RUNLOCK(inp); } else { @@ -2677,20 +2624,6 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, } case SCTP_MAX_BURST: { -#if defined(__FreeBSD__) && __FreeBSD_version < 900000 - uint8_t *value; - - SCTP_CHECK_AND_CAST(value, optval, uint8_t, *optsize); - - SCTP_INP_RLOCK(inp); - if (inp->sctp_ep.max_burst < 256) { - *value = inp->sctp_ep.max_burst; - } else { - *value = 255; - } - SCTP_INP_RUNLOCK(inp); - *optsize = sizeof(uint8_t); -#else struct sctp_assoc_value *av; SCTP_CHECK_AND_CAST(av, optval, struct sctp_assoc_value, *optsize); @@ -2715,19 +2648,17 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, if (error == 0) { *optsize = sizeof(struct sctp_assoc_value); } -#endif break; } case SCTP_MAXSEG: { struct sctp_assoc_value *av; - int ovh; SCTP_CHECK_AND_CAST(av, optval, struct sctp_assoc_value, *optsize); SCTP_FIND_STCB(inp, stcb, av->assoc_id); if (stcb) { - av->assoc_value = sctp_get_frag_point(stcb, &stcb->asoc); + av->assoc_value = stcb->asoc.sctp_frag_point; SCTP_TCB_UNLOCK(stcb); } else { if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || @@ -2735,15 +2666,7 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) && (av->assoc_id == SCTP_FUTURE_ASSOC))) { SCTP_INP_RLOCK(inp); - if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) { - ovh = SCTP_MED_OVERHEAD; - } else { - ovh = SCTP_MED_V4_OVERHEAD; - } - if (inp->sctp_frag_point >= SCTP_DEFAULT_MAXSEGMENT) - av->assoc_value = 0; - else - av->assoc_value = inp->sctp_frag_point - ovh; + av->assoc_value = inp->sctp_frag_point; SCTP_INP_RUNLOCK(inp); } else { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); @@ -2830,7 +2753,7 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, SCTP_CHECK_AND_CAST(value, optval, uint32_t, *optsize); SCTP_INP_RLOCK(inp); - *value = sctp_count_max_addresses(inp); + *value = (uint32_t)sctp_max_size_addresses(inp); SCTP_INP_RUNLOCK(inp); *optsize = sizeof(uint32_t); break; @@ -2838,14 +2761,14 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, case SCTP_GET_REMOTE_ADDR_SIZE: { uint32_t *value; - size_t size; struct sctp_nets *net; + size_t size; SCTP_CHECK_AND_CAST(value, optval, uint32_t, *optsize); /* FIXME MT: change to sctp_assoc_value? */ - SCTP_FIND_STCB(inp, stcb, (sctp_assoc_t) *value); + SCTP_FIND_STCB(inp, stcb, (sctp_assoc_t)*value); - if (stcb) { + if (stcb != NULL) { size = 0; /* Count the sizes */ TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { @@ -2878,11 +2801,16 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, } } SCTP_TCB_UNLOCK(stcb); - *value = (uint32_t) size; + *value = (uint32_t)size; *optsize = sizeof(uint32_t); } else { - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOTCONN); - error = ENOTCONN; + if ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) && + ((sctp_assoc_t)*value <= SCTP_ALL_ASSOC)) { + error = EINVAL; + } else { + error = ENOENT; + } + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, error); } break; } @@ -2893,17 +2821,17 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, */ { size_t cpsz, left; - struct sockaddr_storage *sas; + struct sockaddr *addr; struct sctp_nets *net; struct sctp_getaddresses *saddr; SCTP_CHECK_AND_CAST(saddr, optval, struct sctp_getaddresses, *optsize); SCTP_FIND_STCB(inp, stcb, saddr->sget_assoc_id); - if (stcb) { - left = (*optsize) - sizeof(sctp_assoc_t); - *optsize = sizeof(sctp_assoc_t); - sas = (struct sockaddr_storage *)&saddr->addr[0]; + if (stcb != NULL) { + left = *optsize - offsetof(struct sctp_getaddresses, addr); + *optsize = offsetof(struct sctp_getaddresses, addr); + addr = &saddr->addr[0].sa; TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { switch (net->ro._l_addr.sa.sa_family) { @@ -2946,42 +2874,51 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, (net->ro._l_addr.sa.sa_family == AF_INET)) { /* Must map the address */ in6_sin_2_v4mapsin6(&net->ro._l_addr.sin, - (struct sockaddr_in6 *)sas); + (struct sockaddr_in6 *)addr); } else { - memcpy(sas, &net->ro._l_addr, cpsz); + memcpy(addr, &net->ro._l_addr, cpsz); } #else - memcpy(sas, &net->ro._l_addr, cpsz); + memcpy(addr, &net->ro._l_addr, cpsz); #endif - ((struct sockaddr_in *)sas)->sin_port = stcb->rport; + ((struct sockaddr_in *)addr)->sin_port = stcb->rport; - sas = (struct sockaddr_storage *)((caddr_t)sas + cpsz); + addr = (struct sockaddr *)((caddr_t)addr + cpsz); left -= cpsz; *optsize += cpsz; } SCTP_TCB_UNLOCK(stcb); } else { - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOENT); - error = ENOENT; + if ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) && + (saddr->sget_assoc_id <= SCTP_ALL_ASSOC)) { + error = EINVAL; + } else { + error = ENOENT; + } + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, error); } break; } case SCTP_GET_LOCAL_ADDRESSES: { size_t limit, actual; - struct sockaddr_storage *sas; struct sctp_getaddresses *saddr; SCTP_CHECK_AND_CAST(saddr, optval, struct sctp_getaddresses, *optsize); SCTP_FIND_STCB(inp, stcb, saddr->sget_assoc_id); - sas = (struct sockaddr_storage *)&saddr->addr[0]; - limit = *optsize - sizeof(sctp_assoc_t); - actual = sctp_fill_up_addresses(inp, stcb, limit, sas); - if (stcb) { + if ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) && + ((saddr->sget_assoc_id == SCTP_CURRENT_ASSOC) || + (saddr->sget_assoc_id == SCTP_ALL_ASSOC))) { + error = EINVAL; + } else { + limit = *optsize - offsetof(struct sctp_getaddresses, addr); + actual = sctp_fill_up_addresses(inp, stcb, limit, &saddr->addr[0].sa); + *optsize = offsetof(struct sctp_getaddresses, addr) + actual; + } + if (stcb != NULL) { SCTP_TCB_UNLOCK(stcb); } - *optsize = sizeof(sctp_assoc_t) + actual; break; } case SCTP_PEER_ADDR_PARAMS: @@ -3164,7 +3101,7 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, /* Use endpoint defaults */ SCTP_INP_RLOCK(inp); paddrp->spp_pathmaxrxt = inp->sctp_ep.def_net_failure; - paddrp->spp_hbinterval = TICKS_TO_MSEC(inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_HEARTBEAT]); + paddrp->spp_hbinterval = sctp_ticks_to_msecs(inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_HEARTBEAT]); paddrp->spp_assoc_id = SCTP_FUTURE_ASSOC; /* get inp's default */ if (inp->sctp_ep.default_dscp & 0x01) { @@ -3323,26 +3260,40 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, */ sstat->sstat_penddata = (stcb->asoc.cnt_on_reasm_queue + stcb->asoc.cnt_on_all_streams); - - sstat->sstat_instrms = stcb->asoc.streamincnt; sstat->sstat_outstrms = stcb->asoc.streamoutcnt; - sstat->sstat_fragmentation_point = sctp_get_frag_point(stcb, &stcb->asoc); + sstat->sstat_fragmentation_point = sctp_get_frag_point(stcb); net = stcb->asoc.primary_destination; if (net != NULL) { #ifdef HAVE_SA_LEN memcpy(&sstat->sstat_primary.spinfo_address, - &stcb->asoc.primary_destination->ro._l_addr, - ((struct sockaddr *)(&stcb->asoc.primary_destination->ro._l_addr))->sa_len); + &net->ro._l_addr, + ((struct sockaddr *)(&net->ro._l_addr))->sa_len); #else - if (stcb->asoc.primary_destination->ro._l_addr.sa.sa_family == AF_INET) { + switch (stcb->asoc.primary_destination->ro._l_addr.sa.sa_family) { +#if defined(INET) + case AF_INET: memcpy(&sstat->sstat_primary.spinfo_address, - &stcb->asoc.primary_destination->ro._l_addr, + &net->ro._l_addr, sizeof(struct sockaddr_in)); - } else { + break; +#endif +#if defined(INET6) + case AF_INET6: memcpy(&sstat->sstat_primary.spinfo_address, - &stcb->asoc.primary_destination->ro._l_addr, + &net->ro._l_addr, sizeof(struct sockaddr_in6)); + break; +#endif +#if defined(__Userspace__) + case AF_CONN: + memcpy(&sstat->sstat_primary.spinfo_address, + &net->ro._l_addr, + sizeof(struct sockaddr_conn)); + break; +#endif + default: + break; } #endif ((struct sockaddr_in *)&sstat->sstat_primary.spinfo_address)->sin_port = stcb->rport; @@ -3454,7 +3405,7 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, SCTP_FIND_STCB(inp, stcb, sasoc->sasoc_assoc_id); if (stcb) { - sasoc->sasoc_cookie_life = TICKS_TO_MSEC(stcb->asoc.cookie_life); + sasoc->sasoc_cookie_life = sctp_ticks_to_msecs(stcb->asoc.cookie_life); sasoc->sasoc_asocmaxrxt = stcb->asoc.max_send_times; sasoc->sasoc_number_peer_destinations = stcb->asoc.numnets; sasoc->sasoc_peer_rwnd = stcb->asoc.peers_rwnd; @@ -3466,11 +3417,11 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) && (sasoc->sasoc_assoc_id == SCTP_FUTURE_ASSOC))) { SCTP_INP_RLOCK(inp); - sasoc->sasoc_cookie_life = TICKS_TO_MSEC(inp->sctp_ep.def_cookie_life); + sasoc->sasoc_cookie_life = sctp_ticks_to_msecs(inp->sctp_ep.def_cookie_life); sasoc->sasoc_asocmaxrxt = inp->sctp_ep.max_send_times; sasoc->sasoc_number_peer_destinations = 0; sasoc->sasoc_peer_rwnd = 0; - sasoc->sasoc_local_rwnd = sbspace(&inp->sctp_socket->so_rcv); + sasoc->sasoc_local_rwnd = (uint32_t)sbspace(&inp->sctp_socket->so_rcv); SCTP_INP_RUNLOCK(inp); } else { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); @@ -3576,7 +3527,7 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, { struct sctp_hmacalgo *shmac; sctp_hmaclist_t *hmaclist; - uint32_t size; + size_t size; int i; SCTP_CHECK_AND_CAST(shmac, optval, struct sctp_hmacalgo, *optsize); @@ -3591,8 +3542,8 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, } /* is there room for all of the hmac ids? */ size = sizeof(*shmac) + (hmaclist->num_algo * - sizeof(shmac->shmac_idents[0])); - if ((size_t)(*optsize) < size) { + sizeof(shmac->shmac_idents[0])); + if (*optsize < size) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); error = EINVAL; SCTP_INP_RUNLOCK(inp); @@ -3817,43 +3768,27 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, break; } case SCTP_RECVRCVINFO: - { - int onoff; - if (*optsize < sizeof(int)) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); error = EINVAL; } else { SCTP_INP_RLOCK(inp); - onoff = sctp_is_feature_on(inp, SCTP_PCB_FLAGS_RECVRCVINFO); + *(int *)optval = sctp_is_feature_on(inp, SCTP_PCB_FLAGS_RECVRCVINFO); SCTP_INP_RUNLOCK(inp); - } - if (error == 0) { - /* return the option value */ - *(int *)optval = onoff; *optsize = sizeof(int); } break; - } case SCTP_RECVNXTINFO: - { - int onoff; - if (*optsize < sizeof(int)) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); error = EINVAL; } else { SCTP_INP_RLOCK(inp); - onoff = sctp_is_feature_on(inp, SCTP_PCB_FLAGS_RECVNXTINFO); + *(int *)optval = sctp_is_feature_on(inp, SCTP_PCB_FLAGS_RECVNXTINFO); SCTP_INP_RUNLOCK(inp); - } - if (error == 0) { - /* return the option value */ - *(int *)optval = onoff; *optsize = sizeof(int); } break; - } case SCTP_DEFAULT_SNDINFO: { struct sctp_sndinfo *info; @@ -4498,7 +4433,7 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, return (error); } -#if defined(__Panda__) || defined(__Userspace__) +#if defined(__Userspace__) int #else static int @@ -4587,7 +4522,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, * The value is in ticks. Note this does not effect * old associations, only new ones. */ - inp->sctp_ep.auto_close_time = SEC_TO_TICKS(*mopt); + inp->sctp_ep.auto_close_time = sctp_secs_to_ticks(*mopt); break; } SCTP_INP_WLOCK(inp); @@ -4834,10 +4769,10 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, SCTP_FIND_STCB(inp, stcb, av->assoc_id); if (stcb) { SCTP_TCB_SEND_LOCK(stcb); - stcb->asoc.ss_functions.sctp_ss_clear(stcb, &stcb->asoc, 1, 1); + stcb->asoc.ss_functions.sctp_ss_clear(stcb, &stcb->asoc, true); stcb->asoc.ss_functions = sctp_ss_functions[av->assoc_value]; stcb->asoc.stream_scheduling_module = av->assoc_value; - stcb->asoc.ss_functions.sctp_ss_init(stcb, &stcb->asoc, 1); + stcb->asoc.ss_functions.sctp_ss_init(stcb, &stcb->asoc); SCTP_TCB_SEND_UNLOCK(stcb); SCTP_TCB_UNLOCK(stcb); } else { @@ -4857,10 +4792,10 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) { SCTP_TCB_LOCK(stcb); SCTP_TCB_SEND_LOCK(stcb); - stcb->asoc.ss_functions.sctp_ss_clear(stcb, &stcb->asoc, 1, 1); + stcb->asoc.ss_functions.sctp_ss_clear(stcb, &stcb->asoc, true); stcb->asoc.ss_functions = sctp_ss_functions[av->assoc_value]; stcb->asoc.stream_scheduling_module = av->assoc_value; - stcb->asoc.ss_functions.sctp_ss_init(stcb, &stcb->asoc, 1); + stcb->asoc.ss_functions.sctp_ss_init(stcb, &stcb->asoc); SCTP_TCB_SEND_UNLOCK(stcb); SCTP_TCB_UNLOCK(stcb); } @@ -5089,10 +5024,12 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, SCTP_CHECK_AND_CAST(sack, optval, struct sctp_sack_info, optsize); SCTP_FIND_STCB(inp, stcb, sack->sack_assoc_id); if (sack->sack_delay) { - if (sack->sack_delay > SCTP_MAX_SACK_DELAY) - sack->sack_delay = SCTP_MAX_SACK_DELAY; - if (MSEC_TO_TICKS(sack->sack_delay) < 1) { - sack->sack_delay = TICKS_TO_MSEC(1); + if (sack->sack_delay > SCTP_MAX_SACK_DELAY) { + error = EINVAL; + if (stcb != NULL) { + SCTP_TCB_UNLOCK(stcb); + } + break; } } if (stcb) { @@ -5111,7 +5048,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, (sack->sack_assoc_id == SCTP_ALL_ASSOC)))) { SCTP_INP_WLOCK(inp); if (sack->sack_delay) { - inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_RECV] = MSEC_TO_TICKS(sack->sack_delay); + inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_RECV] = sctp_msecs_to_ticks(sack->sack_delay); } if (sack->sack_freq) { inp->sctp_ep.sctp_sack_freq = sack->sack_freq; @@ -5165,7 +5102,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, if (sca->sca_keylength == 0) { size = optsize - sizeof(struct sctp_authkey); } else { - if (sca->sca_keylength + sizeof(struct sctp_authkey) <= optsize) { + if (sca->sca_keylength + sizeof(struct sctp_authkey) <= optsize) { size = sca->sca_keylength; } else { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); @@ -5494,7 +5431,6 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, } SCTP_INP_RUNLOCK(inp); } - } break; } @@ -5733,7 +5669,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, break; } /* Do any streams have data queued? */ - for ( i = 0; i< stcb->asoc.streamoutcnt; i++) { + for (i = 0; i < stcb->asoc.streamoutcnt; i++) { if (!TAILQ_EMPTY(&stcb->asoc.strmout[i].outqueue)) { goto busy_out; } @@ -5811,15 +5747,6 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, } case SCTP_MAX_BURST: { -#if defined(__FreeBSD__) && __FreeBSD_version < 900000 - uint8_t *burst; - - SCTP_CHECK_AND_CAST(burst, optval, uint8_t, optsize); - - SCTP_INP_WLOCK(inp); - inp->sctp_ep.max_burst = *burst; - SCTP_INP_WUNLOCK(inp); -#else struct sctp_assoc_value *av; SCTP_CHECK_AND_CAST(av, optval, struct sctp_assoc_value, optsize); @@ -5850,28 +5777,17 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, SCTP_INP_RUNLOCK(inp); } } -#endif break; } case SCTP_MAXSEG: { struct sctp_assoc_value *av; - int ovh; SCTP_CHECK_AND_CAST(av, optval, struct sctp_assoc_value, optsize); SCTP_FIND_STCB(inp, stcb, av->assoc_id); - if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) { - ovh = SCTP_MED_OVERHEAD; - } else { - ovh = SCTP_MED_V4_OVERHEAD; - } if (stcb) { - if (av->assoc_value) { - stcb->asoc.sctp_frag_point = (av->assoc_value + ovh); - } else { - stcb->asoc.sctp_frag_point = SCTP_DEFAULT_MAXSEGMENT; - } + stcb->asoc.sctp_frag_point = av->assoc_value; SCTP_TCB_UNLOCK(stcb); } else { if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || @@ -5879,12 +5795,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) && (av->assoc_id == SCTP_FUTURE_ASSOC))) { SCTP_INP_WLOCK(inp); - /* FIXME MT: I think this is not in tune with the API ID */ - if (av->assoc_value) { - inp->sctp_frag_point = (av->assoc_value + ovh); - } else { - inp->sctp_frag_point = SCTP_DEFAULT_MAXSEGMENT; - } + inp->sctp_frag_point = av->assoc_value; SCTP_INP_WUNLOCK(inp); } else { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); @@ -6152,8 +6063,8 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, if ((stcb != NULL) && (net == NULL)) { #ifdef INET if (addr->sa_family == AF_INET) { - struct sockaddr_in *sin; + sin = (struct sockaddr_in *)addr; if (sin->sin_addr.s_addr != INADDR_ANY) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); @@ -6211,6 +6122,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, return (EINVAL); } if ((paddrp->spp_flags & SPP_PMTUD_DISABLE) && + (paddrp->spp_pathmtu > 0) && ((paddrp->spp_pathmtu < SCTP_SMALLEST_PMTU) || (paddrp->spp_pathmtu > SCTP_LARGEST_PMTU))) { if (stcb) @@ -6255,28 +6167,30 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, SCTP_FROM_SCTP_USRREQ + SCTP_LOC_11); } net->dest_state |= SCTP_ADDR_NO_PMTUD; - net->mtu = paddrp->spp_pathmtu; - switch (net->ro._l_addr.sa.sa_family) { + if (paddrp->spp_pathmtu > 0) { + net->mtu = paddrp->spp_pathmtu; + switch (net->ro._l_addr.sa.sa_family) { #ifdef INET - case AF_INET: - net->mtu += SCTP_MIN_V4_OVERHEAD; - break; + case AF_INET: + net->mtu += SCTP_MIN_V4_OVERHEAD; + break; #endif #ifdef INET6 - case AF_INET6: - net->mtu += SCTP_MIN_OVERHEAD; - break; + case AF_INET6: + net->mtu += SCTP_MIN_OVERHEAD; + break; #endif #if defined(__Userspace__) - case AF_CONN: - net->mtu += sizeof(struct sctphdr); - break; + case AF_CONN: + net->mtu += sizeof(struct sctphdr); + break; #endif - default: - break; - } - if (net->mtu < stcb->asoc.smallest_mtu) { - sctp_pathmtu_adjustment(stcb, net->mtu); + default: + break; + } + if (net->mtu < stcb->asoc.smallest_mtu) { + sctp_pathmtu_adjustment(stcb, net->mtu, true); + } } } if (paddrp->spp_flags & SPP_PMTUD_ENABLE) { @@ -6285,7 +6199,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, } net->dest_state &= ~SCTP_ADDR_NO_PMTUD; } - if (paddrp->spp_pathmaxrxt) { + if (paddrp->spp_pathmaxrxt > 0) { if (net->dest_state & SCTP_ADDR_PF) { if (net->error_count > paddrp->spp_pathmaxrxt) { net->dest_state &= ~SCTP_ADDR_PF; @@ -6328,7 +6242,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, #endif } else { /************************ASSOC ONLY -- NO NET SPECIFIC SET ******************/ - if (paddrp->spp_pathmaxrxt != 0) { + if (paddrp->spp_pathmaxrxt > 0) { stcb->asoc.def_net_failure = paddrp->spp_pathmaxrxt; TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { if (net->dest_state & SCTP_ADDR_PF) { @@ -6360,7 +6274,6 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, net->failure_threshold = paddrp->spp_pathmaxrxt; } } - if (paddrp->spp_flags & SPP_HB_ENABLE) { if (paddrp->spp_hbinterval != 0) { stcb->asoc.heart_beat_delay = paddrp->spp_hbinterval; @@ -6403,31 +6316,35 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, SCTP_FROM_SCTP_USRREQ + SCTP_LOC_16); } net->dest_state |= SCTP_ADDR_NO_PMTUD; - net->mtu = paddrp->spp_pathmtu; - switch (net->ro._l_addr.sa.sa_family) { + if (paddrp->spp_pathmtu > 0) { + net->mtu = paddrp->spp_pathmtu; + switch (net->ro._l_addr.sa.sa_family) { #ifdef INET - case AF_INET: - net->mtu += SCTP_MIN_V4_OVERHEAD; - break; + case AF_INET: + net->mtu += SCTP_MIN_V4_OVERHEAD; + break; #endif #ifdef INET6 - case AF_INET6: - net->mtu += SCTP_MIN_OVERHEAD; - break; + case AF_INET6: + net->mtu += SCTP_MIN_OVERHEAD; + break; #endif #if defined(__Userspace__) - case AF_CONN: - net->mtu += sizeof(struct sctphdr); - break; + case AF_CONN: + net->mtu += sizeof(struct sctphdr); + break; #endif - default: - break; - } - if (net->mtu < stcb->asoc.smallest_mtu) { - sctp_pathmtu_adjustment(stcb, net->mtu); + default: + break; + } + if (net->mtu < stcb->asoc.smallest_mtu) { + sctp_pathmtu_adjustment(stcb, net->mtu, true); + } } } - stcb->asoc.default_mtu = paddrp->spp_pathmtu; + if (paddrp->spp_pathmtu > 0) { + stcb->asoc.default_mtu = paddrp->spp_pathmtu; + } sctp_stcb_feature_on(inp, stcb, SCTP_PCB_FLAGS_DO_NOT_PMTUD); } if (paddrp->spp_flags & SPP_PMTUD_ENABLE) { @@ -6473,7 +6390,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, * For the TOS/FLOWLABEL stuff you set it * with the options on the socket */ - if (paddrp->spp_pathmaxrxt != 0) { + if (paddrp->spp_pathmaxrxt > 0) { inp->sctp_ep.def_net_failure = paddrp->spp_pathmaxrxt; } @@ -6482,14 +6399,14 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, else if (paddrp->spp_hbinterval != 0) { if (paddrp->spp_hbinterval > SCTP_MAX_HB_INTERVAL) paddrp->spp_hbinterval= SCTP_MAX_HB_INTERVAL; - inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_HEARTBEAT] = MSEC_TO_TICKS(paddrp->spp_hbinterval); + inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_HEARTBEAT] = sctp_msecs_to_ticks(paddrp->spp_hbinterval); } if (paddrp->spp_flags & SPP_HB_ENABLE) { if (paddrp->spp_flags & SPP_HB_TIME_IS_ZERO) { inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_HEARTBEAT] = 0; } else if (paddrp->spp_hbinterval) { - inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_HEARTBEAT] = MSEC_TO_TICKS(paddrp->spp_hbinterval); + inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_HEARTBEAT] = sctp_msecs_to_ticks(paddrp->spp_hbinterval); } sctp_feature_off(inp, SCTP_PCB_FLAGS_DONOT_HEARTBEAT); } else if (paddrp->spp_flags & SPP_HB_DISABLE) { @@ -6499,7 +6416,9 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, inp->sctp_ep.default_mtu = 0; sctp_feature_off(inp, SCTP_PCB_FLAGS_DO_NOT_PMTUD); } else if (paddrp->spp_flags & SPP_PMTUD_DISABLE) { - inp->sctp_ep.default_mtu = paddrp->spp_pathmtu; + if (paddrp->spp_pathmtu > 0) { + inp->sctp_ep.default_mtu = paddrp->spp_pathmtu; + } sctp_feature_on(inp, SCTP_PCB_FLAGS_DO_NOT_PMTUD); } if (paddrp->spp_flags & SPP_DSCP) { @@ -6592,19 +6511,21 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, SCTP_CHECK_AND_CAST(sasoc, optval, struct sctp_assocparams, optsize); SCTP_FIND_STCB(inp, stcb, sasoc->sasoc_assoc_id); - if (sasoc->sasoc_cookie_life) { + if (sasoc->sasoc_cookie_life > 0) { /* boundary check the cookie life */ - if (sasoc->sasoc_cookie_life < 1000) - sasoc->sasoc_cookie_life = 1000; + if (sasoc->sasoc_cookie_life < SCTP_MIN_COOKIE_LIFE) { + sasoc->sasoc_cookie_life = SCTP_MIN_COOKIE_LIFE; + } if (sasoc->sasoc_cookie_life > SCTP_MAX_COOKIE_LIFE) { sasoc->sasoc_cookie_life = SCTP_MAX_COOKIE_LIFE; } } if (stcb) { - if (sasoc->sasoc_asocmaxrxt) + if (sasoc->sasoc_asocmaxrxt > 0) { stcb->asoc.max_send_times = sasoc->sasoc_asocmaxrxt; - if (sasoc->sasoc_cookie_life) { - stcb->asoc.cookie_life = MSEC_TO_TICKS(sasoc->sasoc_cookie_life); + } + if (sasoc->sasoc_cookie_life > 0) { + stcb->asoc.cookie_life = sctp_msecs_to_ticks(sasoc->sasoc_cookie_life); } SCTP_TCB_UNLOCK(stcb); } else { @@ -6613,10 +6534,11 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) && (sasoc->sasoc_assoc_id == SCTP_FUTURE_ASSOC))) { SCTP_INP_WLOCK(inp); - if (sasoc->sasoc_asocmaxrxt) + if (sasoc->sasoc_asocmaxrxt > 0) { inp->sctp_ep.max_send_times = sasoc->sasoc_asocmaxrxt; - if (sasoc->sasoc_cookie_life) { - inp->sctp_ep.def_cookie_life = MSEC_TO_TICKS(sasoc->sasoc_cookie_life); + } + if (sasoc->sasoc_cookie_life > 0) { + inp->sctp_ep.def_cookie_life = sctp_msecs_to_ticks(sasoc->sasoc_cookie_life); } SCTP_INP_WUNLOCK(inp); } else { @@ -6726,19 +6648,13 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, #ifdef SCTP_MVRF int i, fnd = 0; #endif -#if !defined(__Windows__) && !defined(__Userspace__) +#if !defined(_WIN32) && !defined(__Userspace__) #if defined(__APPLE__) struct proc *proc; #endif -#ifdef __FreeBSD__ -#if __FreeBSD_version > 602000 +#if defined(__FreeBSD__) error = priv_check(curthread, PRIV_NETINET_RESERVEDPORT); -#elif __FreeBSD_version >= 500000 - error = suser((struct thread *)p); -#else - error = suser(p); -#endif #elif defined(__APPLE__) proc = (struct proc *)p; if (p) { @@ -6832,7 +6748,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, error = EINVAL; goto out_of_it; } -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) } else { switch (addr->sa_family) { #ifdef INET @@ -6887,23 +6803,23 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, } case SCTP_BINDX_ADD_ADDR: { - struct sctp_getaddresses *addrs; -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 + struct sockaddr *sa; +#if defined(__FreeBSD__) && !defined(__Userspace__) struct thread *td; td = (struct thread *)p; #endif - SCTP_CHECK_AND_CAST(addrs, optval, struct sctp_getaddresses, - optsize); + SCTP_CHECK_AND_CAST(sa, optval, struct sockaddr, optsize); #ifdef INET - if (addrs->addr->sa_family == AF_INET) { - if (optsize < sizeof(struct sctp_getaddresses) - sizeof(struct sockaddr) + sizeof(struct sockaddr_in)) { + if (sa->sa_family == AF_INET) { + if (optsize < sizeof(struct sockaddr_in)) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); error = EINVAL; break; } -#if defined(__FreeBSD__) && __FreeBSD_version >= 800000 - if (td != NULL && (error = prison_local_ip4(td->td_ucred, &(((struct sockaddr_in *)(addrs->addr))->sin_addr)))) { +#if defined(__FreeBSD__) && !defined(__Userspace__) + if (td != NULL && + (error = prison_local_ip4(td->td_ucred, &(((struct sockaddr_in *)sa)->sin_addr)))) { SCTP_LTRACE_ERR_RET(inp, stcb, NULL, SCTP_FROM_SCTP_USRREQ, error); break; } @@ -6911,65 +6827,16 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, } else #endif #ifdef INET6 - if (addrs->addr->sa_family == AF_INET6) { - if (optsize < sizeof(struct sctp_getaddresses) - sizeof(struct sockaddr) + sizeof(struct sockaddr_in6)) { + if (sa->sa_family == AF_INET6) { + if (optsize < sizeof(struct sockaddr_in6)) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); error = EINVAL; break; } -#if defined(__FreeBSD__) && __FreeBSD_version >= 800000 - if (td != NULL && (error = prison_local_ip6(td->td_ucred, &(((struct sockaddr_in6 *)(addrs->addr))->sin6_addr), - (SCTP_IPV6_V6ONLY(inp) != 0))) != 0) { - SCTP_LTRACE_ERR_RET(inp, stcb, NULL, SCTP_FROM_SCTP_USRREQ, error); - break; - } -#endif - } else -#endif - { - error = EAFNOSUPPORT; - break; - } - sctp_bindx_add_address(so, inp, addrs->addr, - addrs->sget_assoc_id, vrf_id, - &error, p); - break; - } - case SCTP_BINDX_REM_ADDR: - { - struct sctp_getaddresses *addrs; -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 - struct thread *td; - td = (struct thread *)p; - -#endif - SCTP_CHECK_AND_CAST(addrs, optval, struct sctp_getaddresses, optsize); -#ifdef INET - if (addrs->addr->sa_family == AF_INET) { - if (optsize < sizeof(struct sctp_getaddresses) - sizeof(struct sockaddr) + sizeof(struct sockaddr_in)) { - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); - error = EINVAL; - break; - } -#if defined(__FreeBSD__) && __FreeBSD_version >= 800000 - if (td != NULL && (error = prison_local_ip4(td->td_ucred, &(((struct sockaddr_in *)(addrs->addr))->sin_addr)))) { - SCTP_LTRACE_ERR_RET(inp, stcb, NULL, SCTP_FROM_SCTP_USRREQ, error); - break; - } -#endif - } else -#endif -#ifdef INET6 - if (addrs->addr->sa_family == AF_INET6) { - if (optsize < sizeof(struct sctp_getaddresses) - sizeof(struct sockaddr) + sizeof(struct sockaddr_in6)) { - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); - error = EINVAL; - break; - } -#if defined(__FreeBSD__) && __FreeBSD_version >= 800000 +#if defined(__FreeBSD__) && !defined(__Userspace__) if (td != NULL && (error = prison_local_ip6(td->td_ucred, - &(((struct sockaddr_in6 *)(addrs->addr))->sin6_addr), + &(((struct sockaddr_in6 *)sa)->sin6_addr), (SCTP_IPV6_V6ONLY(inp) != 0))) != 0) { SCTP_LTRACE_ERR_RET(inp, stcb, NULL, SCTP_FROM_SCTP_USRREQ, error); break; @@ -6981,12 +6848,60 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, error = EAFNOSUPPORT; break; } - sctp_bindx_delete_address(inp, addrs->addr, - addrs->sget_assoc_id, vrf_id, - &error); + sctp_bindx_add_address(so, inp, sa, vrf_id, &error, p); break; } -#ifdef __APPLE__ + case SCTP_BINDX_REM_ADDR: + { + struct sockaddr *sa; +#if defined(__FreeBSD__) && !defined(__Userspace__) + struct thread *td; + td = (struct thread *)p; + +#endif + SCTP_CHECK_AND_CAST(sa, optval, struct sockaddr, optsize); +#ifdef INET + if (sa->sa_family == AF_INET) { + if (optsize < sizeof(struct sockaddr_in)) { + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); + error = EINVAL; + break; + } +#if defined(__FreeBSD__) && !defined(__Userspace__) + if (td != NULL && + (error = prison_local_ip4(td->td_ucred, &(((struct sockaddr_in *)sa)->sin_addr)))) { + SCTP_LTRACE_ERR_RET(inp, stcb, NULL, SCTP_FROM_SCTP_USRREQ, error); + break; + } +#endif + } else +#endif +#ifdef INET6 + if (sa->sa_family == AF_INET6) { + if (optsize < sizeof(struct sockaddr_in6)) { + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); + error = EINVAL; + break; + } +#if defined(__FreeBSD__) && !defined(__Userspace__) + if (td != NULL && + (error = prison_local_ip6(td->td_ucred, + &(((struct sockaddr_in6 *)sa)->sin6_addr), + (SCTP_IPV6_V6ONLY(inp) != 0))) != 0) { + SCTP_LTRACE_ERR_RET(inp, stcb, NULL, SCTP_FROM_SCTP_USRREQ, error); + break; + } +#endif + } else +#endif + { + error = EAFNOSUPPORT; + break; + } + sctp_bindx_delete_address(inp, sa, vrf_id, &error); + break; + } +#if defined(__APPLE__) && !defined(__Userspace__) case SCTP_LISTEN_FIX: /* only applies to one-to-many sockets */ if (inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) { @@ -6998,7 +6913,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, error = EINVAL; } break; -#endif /* __APPLE__ */ +#endif case SCTP_EVENT: { struct sctp_event *event; @@ -7302,8 +7217,8 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, if ((stcb != NULL) && (net == NULL)) { #ifdef INET if (addr->sa_family == AF_INET) { - struct sockaddr_in *sin; + sin = (struct sockaddr_in *)addr; if (sin->sin_addr.s_addr != INADDR_ANY) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); @@ -7483,8 +7398,8 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, if ((stcb != NULL) && (net == NULL)) { #ifdef INET if (addr->sa_family == AF_INET) { - struct sockaddr_in *sin; + sin = (struct sockaddr_in *)addr; if (sin->sin_addr.s_addr != INADDR_ANY) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); @@ -7827,17 +7742,18 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, return (error); } -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) int sctp_ctloutput(struct socket *so, struct sockopt *sopt) { - void *optval = NULL; - size_t optsize = 0; - void *p; - int error = 0; #if defined(__FreeBSD__) + struct epoch_tracker et; struct sctp_inpcb *inp; #endif + void *optval = NULL; + void *p; + size_t optsize = 0; + int error = 0; #if defined(__FreeBSD__) if ((sopt->sopt_level == SOL_SOCKET) && @@ -7884,13 +7800,19 @@ sctp_ctloutput(struct socket *so, struct sockopt *sopt) goto out; } } -#if (defined(__FreeBSD__) && __FreeBSD_version >= 500000) || defined(__Windows__) +#if defined(__FreeBSD__) || defined(_WIN32) p = (void *)sopt->sopt_td; #else p = (void *)sopt->sopt_p; #endif if (sopt->sopt_dir == SOPT_SET) { +#if defined(__FreeBSD__) + NET_EPOCH_ENTER(et); +#endif error = sctp_setopt(so, sopt->sopt_name, optval, optsize, p); +#if defined(__FreeBSD__) + NET_EPOCH_EXIT(et); +#endif } else if (sopt->sopt_dir == SOPT_GET) { error = sctp_getopt(so, sopt->sopt_name, optval, &optsize, p); } else { @@ -7909,21 +7831,20 @@ out: #endif #ifdef INET -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 -static int -sctp_connect(struct socket *so, struct sockaddr *addr, struct thread *p) -{ -#else -#if defined(__FreeBSD__) || defined(__APPLE__) -static int -sctp_connect(struct socket *so, struct sockaddr *addr, struct proc *p) -{ -#elif defined(__Panda__) || defined(__Userspace__) +#if defined(__Userspace__) int sctp_connect(struct socket *so, struct sockaddr *addr) { void *p = NULL; -#elif defined(__Windows__) +#elif defined(__FreeBSD__) +static int +sctp_connect(struct socket *so, struct sockaddr *addr, struct thread *p) +{ +#elif defined(__APPLE__) +static int +sctp_connect(struct socket *so, struct sockaddr *addr, struct proc *p) +{ +#elif defined(_WIN32) static int sctp_connect(struct socket *so, struct sockaddr *addr, PKTHREAD p) { @@ -7934,6 +7855,8 @@ sctp_connect(struct socket *so, struct mbuf *nam, struct proc *p) struct sockaddr *addr = mtod(nam, struct sockaddr *); #endif +#if defined(__FreeBSD__) && !defined(__Userspace__) + struct epoch_tracker et; #endif #ifdef SCTP_MVRF int i, fnd = 0; @@ -7956,14 +7879,14 @@ sctp_connect(struct socket *so, struct mbuf *nam, struct proc *p) } #if defined(__Userspace__) - /* TODO __Userspace__ falls into this code for IPv6 stuff at the moment... */ + /* TODO __Userspace__ falls into this code for IPv6 stuff at the moment... */ #endif -#if !defined(__Windows__) && !defined(__Userspace_os_Linux) && !defined(__Userspace_os_Windows) +#if !defined(_WIN32) && !defined(__linux__) && !defined(__EMSCRIPTEN__) switch (addr->sa_family) { #ifdef INET6 case AF_INET6: { -#if defined(__FreeBSD__) && __FreeBSD_version >= 800000 +#if defined(__FreeBSD__) && !defined(__Userspace__) struct sockaddr_in6 *sin6; #endif @@ -7971,7 +7894,7 @@ sctp_connect(struct socket *so, struct mbuf *nam, struct proc *p) SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); return (EINVAL); } -#if defined(__FreeBSD__) && __FreeBSD_version >= 800000 +#if defined(__FreeBSD__) && !defined(__Userspace__) sin6 = (struct sockaddr_in6 *)addr; if (p != NULL && (error = prison_remote_ip6(p->td_ucred, &sin6->sin6_addr)) != 0) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, error); @@ -7984,17 +7907,17 @@ sctp_connect(struct socket *so, struct mbuf *nam, struct proc *p) #ifdef INET case AF_INET: { -#if defined(__FreeBSD__) && __FreeBSD_version >= 800000 +#if defined(__FreeBSD__) && !defined(__Userspace__) struct sockaddr_in *sin; #endif -#if !defined(__Userspace_os_Windows) +#if !defined(_WIN32) if (addr->sa_len != sizeof(struct sockaddr_in)) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); return (EINVAL); } #endif -#if defined(__FreeBSD__) && __FreeBSD_version >= 800000 +#if defined(__FreeBSD__) && !defined(__Userspace__) sin = (struct sockaddr_in *)addr; if (p != NULL && (error = prison_remote_ip4(p->td_ucred, &sin->sin_addr)) != 0) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, error); @@ -8012,7 +7935,9 @@ sctp_connect(struct socket *so, struct mbuf *nam, struct proc *p) SCTP_INP_INCR_REF(inp); SCTP_ASOC_CREATE_LOCK(inp); create_lock_on = 1; - +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_ENTER(et); +#endif if ((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) || (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE)) { @@ -8098,29 +8023,26 @@ sctp_connect(struct socket *so, struct mbuf *nam, struct proc *p) } #endif /* We are GOOD to go */ - stcb = sctp_aloc_assoc(inp, addr, &error, 0, vrf_id, - inp->sctp_ep.pre_open_stream_count, - inp->sctp_ep.port, p, - SCTP_INITIALIZE_AUTH_PARAMS); + stcb = sctp_aloc_assoc_connected(inp, addr, &error, 0, 0, vrf_id, + inp->sctp_ep.pre_open_stream_count, + inp->sctp_ep.port, p, + SCTP_INITIALIZE_AUTH_PARAMS); if (stcb == NULL) { /* Gak! no memory */ goto out_now; } - if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) { - stcb->sctp_ep->sctp_flags |= SCTP_PCB_FLAGS_CONNECTED; - /* Set the connected flag so we can queue data */ - soisconnecting(so); - } SCTP_SET_STATE(stcb, SCTP_STATE_COOKIE_WAIT); (void)SCTP_GETTIME_TIMEVAL(&stcb->asoc.time_entered); sctp_send_initiate(inp, stcb, SCTP_SO_LOCKED); SCTP_TCB_UNLOCK(stcb); out_now: +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_EXIT(et); +#endif if (create_lock_on) { SCTP_ASOC_CREATE_UNLOCK(inp); } - SCTP_INP_DECR_REF(inp); return (error); } @@ -8263,19 +8185,14 @@ sctpconn_connect(struct socket *so, struct sockaddr *addr) } #endif /* We are GOOD to go */ - stcb = sctp_aloc_assoc(inp, addr, &error, 0, vrf_id, - inp->sctp_ep.pre_open_stream_count, - inp->sctp_ep.port, p, - SCTP_INITIALIZE_AUTH_PARAMS); + stcb = sctp_aloc_assoc_connected(inp, addr, &error, 0, 0, vrf_id, + inp->sctp_ep.pre_open_stream_count, + inp->sctp_ep.port, p, + SCTP_INITIALIZE_AUTH_PARAMS); if (stcb == NULL) { /* Gak! no memory */ goto out_now; } - if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) { - stcb->sctp_ep->sctp_flags |= SCTP_PCB_FLAGS_CONNECTED; - /* Set the connected flag so we can queue data */ - soisconnecting(so); - } SCTP_SET_STATE(stcb, SCTP_STATE_COOKIE_WAIT); (void)SCTP_GETTIME_TIMEVAL(&stcb->asoc.time_entered); @@ -8291,16 +8208,12 @@ sctpconn_connect(struct socket *so, struct sockaddr *addr) } #endif int -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 -#if __FreeBSD_version >= 700000 -sctp_listen(struct socket *so, int backlog, struct thread *p) -#else -sctp_listen(struct socket *so, struct thread *p) -#endif -#elif defined(__Windows__) -sctp_listen(struct socket *so, int backlog, PKTHREAD p) -#elif defined(__Userspace__) +#if defined(__Userspace__) sctp_listen(struct socket *so, int backlog, struct proc *p) +#elif defined(__FreeBSD__) +sctp_listen(struct socket *so, int backlog, struct thread *p) +#elif defined(_WIN32) +sctp_listen(struct socket *so, int backlog, PKTHREAD p) #else sctp_listen(struct socket *so, struct proc *p) #endif @@ -8429,20 +8342,12 @@ sctp_listen(struct socket *so, struct proc *p) } } } - SCTP_INP_RLOCK(inp); + SCTP_INP_INFO_WLOCK(); + SCTP_INP_WLOCK(inp); #ifdef SCTP_LOCK_LOGGING if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) { sctp_log_lock(inp, (struct sctp_tcb *)NULL, SCTP_LOG_LOCK_SOCK); } -#endif -#if (defined(__FreeBSD__) && __FreeBSD_version > 500000) || defined(__Userspace__) - SOCK_LOCK(so); - error = solisten_proto_check(so); - SOCK_UNLOCK(so); - if (error) { - SCTP_INP_RUNLOCK(inp); - return (error); - } #endif if ((sctp_is_feature_on(inp, SCTP_PCB_FLAGS_PORTREUSE)) && (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) { @@ -8453,47 +8358,57 @@ sctp_listen(struct socket *so, struct proc *p) * - We must then move the guy that was listener to the TCP Pool. */ if (sctp_swap_inpcb_for_listen(inp)) { - SCTP_INP_RUNLOCK(inp); - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EADDRINUSE); - return (EADDRINUSE); + error = EADDRINUSE; + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, error); + goto out; } } - +#if defined(__FreeBSD__) || defined(__Userspace__) + SOCK_LOCK(so); + error = solisten_proto_check(so); + if (error) { + SOCK_UNLOCK(so); + goto out; + } +#endif if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) && (inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED)) { - /* We are already connected AND the TCP model */ - SCTP_INP_RUNLOCK(inp); - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EADDRINUSE); - return (EADDRINUSE); + SOCK_UNLOCK(so); +#if defined(__FreeBSD__) && !defined(__Userspace__) + solisten_proto_abort(so); +#endif + error = EADDRINUSE; + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, error); + goto out; } - SCTP_INP_RUNLOCK(inp); if (inp->sctp_flags & SCTP_PCB_FLAGS_UNBOUND) { - /* We must do a bind. */ - if ((error = sctp_inpcb_bind(so, NULL, NULL, p))) { + if ((error = sctp_inpcb_bind_locked(inp, NULL, NULL, p))) { + SOCK_UNLOCK(so); +#if defined(__FreeBSD__) && !defined(__Userspace__) + solisten_proto_abort(so); +#endif /* bind error, probably perm */ - return (error); + goto out; } } - SCTP_INP_WLOCK(inp); -#if (defined(__FreeBSD__) && __FreeBSD_version > 500000) || defined(__Windows__) || defined(__Userspace__) -#if __FreeBSD_version >= 1200034 +#if defined(__FreeBSD__) && !defined(__Userspace__) if ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) == 0) { - SOCK_LOCK(so); solisten_proto(so, backlog); SOCK_UNLOCK(so); + inp->sctp_flags |= SCTP_PCB_FLAGS_ACCEPTING; + } else { + solisten_proto_abort(so); + SOCK_UNLOCK(so); + if (backlog > 0) { + inp->sctp_flags |= SCTP_PCB_FLAGS_ACCEPTING; + } else { + inp->sctp_flags &= ~SCTP_PCB_FLAGS_ACCEPTING; + } } -#elif __FreeBSD_version >= 700000 || defined(__Windows__) || defined(__Userspace__) - /* It appears for 7.0 and on, we must always call this. */ - SOCK_LOCK(so); +#elif defined(_WIN32) || defined(__Userspace__) solisten_proto(so, backlog); -#else - SOCK_LOCK(so); - if ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) == 0) { - solisten_proto(so); - } #endif -#endif -#if !defined(__FreeBSD__) || __FreeBSD_version < 1200034 +#if !(defined(__FreeBSD__) && !defined(__Userspace__)) if (inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) { /* remove the ACCEPTCONN flag for one-to-many sockets */ #if defined(__Userspace__) @@ -8503,17 +8418,15 @@ sctp_listen(struct socket *so, struct proc *p) #endif } SOCK_UNLOCK(so); -#endif -#if (defined(__FreeBSD__) && __FreeBSD_version >= 700000) || defined(__Windows__) || defined(__Userspace__) if (backlog > 0) { inp->sctp_flags |= SCTP_PCB_FLAGS_ACCEPTING; } else { inp->sctp_flags &= ~SCTP_PCB_FLAGS_ACCEPTING; } -#else - inp->sctp_flags |= SCTP_PCB_FLAGS_ACCEPTING; #endif +out: SCTP_INP_WUNLOCK(inp); + SCTP_INP_INFO_WUNLOCK(); return (error); } @@ -8526,9 +8439,9 @@ sctp_accept(struct socket *so, struct sockaddr **addr) struct sctp_inpcb *inp; union sctp_sockstore store; #ifdef INET6 -#ifdef SCTP_KAME +#if defined(SCTP_KAME) && defined(SCTP_EMBEDDED_V6_SCOPE) int error; -#endif /* SCTP_KAME */ +#endif #endif inp = (struct sctp_inpcb *)so->so_pcb; @@ -8566,7 +8479,7 @@ sctp_accept(struct socket *so, struct sockaddr **addr) #if defined(__Userspace__) /*__Userspace__ calling sowwakup_locked because of SOCKBUF_LOCK above. */ #endif -#if defined(__FreeBSD__) || defined(__Windows__) || defined(__Userspace__) +#if defined(__FreeBSD__) || defined(_WIN32) || defined(__Userspace__) sowwakeup_locked(inp->sctp_socket); #else #if defined(__APPLE__) @@ -8586,7 +8499,7 @@ sctp_accept(struct socket *so, struct sockaddr **addr) #if defined(__Userspace__) /*__Userspace__ calling sorwakup_locked because of SOCKBUF_LOCK above */ #endif -#if defined(__FreeBSD__) || defined(__Windows__) || defined(__Userspace__) +#if defined(__FreeBSD__) || defined(_WIN32) || defined(__Userspace__) sorwakeup_locked(inp->sctp_socket); #else #if defined(__APPLE__) @@ -8612,25 +8525,16 @@ sctp_accept(struct socket *so, struct sockaddr **addr) { struct sockaddr_in *sin; -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) || defined(__Userspace__) SCTP_MALLOC_SONAME(sin, struct sockaddr_in *, sizeof *sin); if (sin == NULL) return (ENOMEM); -#else - sin = (struct sockaddr_in *)addr; - memset(sin, 0, sizeof(*sin)); -#endif sin->sin_family = AF_INET; #ifdef HAVE_SIN_LEN sin->sin_len = sizeof(*sin); #endif sin->sin_port = store.sin.sin_port; sin->sin_addr = store.sin.sin_addr; -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) || defined(__Userspace__) *addr = (struct sockaddr *)sin; -#elif !defined(__Panda__) - SCTP_BUF_LEN(nam) = sizeof(*sin); -#endif break; } #endif @@ -8639,14 +8543,9 @@ sctp_accept(struct socket *so, struct sockaddr **addr) { struct sockaddr_in6 *sin6; -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) || defined(__Userspace__) SCTP_MALLOC_SONAME(sin6, struct sockaddr_in6 *, sizeof *sin6); if (sin6 == NULL) return (ENOMEM); -#else - sin6 = (struct sockaddr_in6 *)addr; - memset(sin6, 0, sizeof(*sin6)); -#endif sin6->sin6_family = AF_INET6; #ifdef HAVE_SIN6_LEN sin6->sin6_len = sizeof(*sin6); @@ -8670,11 +8569,7 @@ sctp_accept(struct socket *so, struct sockaddr **addr) sin6->sin6_scope_id = 0; /* XXX */ #endif /* SCTP_KAME */ #endif /* SCTP_EMBEDDED_V6_SCOPE */ -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) || defined(__Userspace__) *addr = (struct sockaddr *)sin6; -#elif !defined(__Panda__) - SCTP_BUF_LEN(nam) = sizeof(*sin6); -#endif break; } #endif @@ -8706,14 +8601,10 @@ sctp_accept(struct socket *so, struct sockaddr **addr) #ifdef INET int -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) sctp_ingetaddr(struct socket *so, struct sockaddr **addr) { struct sockaddr_in *sin; -#elif defined(__Panda__) -sctp_ingetaddr(struct socket *so, struct sockaddr *addr) -{ - struct sockaddr_in *sin = (struct sockaddr_in *)addr; #else sctp_ingetaddr(struct socket *so, struct mbuf *nam) { @@ -8726,12 +8617,10 @@ sctp_ingetaddr(struct socket *so, struct mbuf *nam) /* * Do the malloc first in case it blocks. */ -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) SCTP_MALLOC_SONAME(sin, struct sockaddr_in *, sizeof *sin); if (sin == NULL) return (ENOMEM); -#elif defined(__Panda__) - memset(sin, 0, sizeof(*sin)); #else SCTP_BUF_LEN(nam) = sizeof(*sin); memset(sin, 0, sizeof(*sin)); @@ -8742,7 +8631,7 @@ sctp_ingetaddr(struct socket *so, struct mbuf *nam) #endif inp = (struct sctp_inpcb *)so->so_pcb; if (!inp) { -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) SCTP_FREE_SONAME(sin); #endif SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); @@ -8813,7 +8702,7 @@ sctp_ingetaddr(struct socket *so, struct mbuf *nam) } } if (!fnd) { -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) SCTP_FREE_SONAME(sin); #endif SCTP_INP_RUNLOCK(inp); @@ -8822,21 +8711,17 @@ sctp_ingetaddr(struct socket *so, struct mbuf *nam) } } SCTP_INP_RUNLOCK(inp); -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) (*addr) = (struct sockaddr *)sin; #endif return (0); } int -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) sctp_peeraddr(struct socket *so, struct sockaddr **addr) { struct sockaddr_in *sin; -#elif defined(__Panda__) -sctp_peeraddr(struct socket *so, struct sockaddr *addr) -{ - struct sockaddr_in *sin = (struct sockaddr_in *)addr; #else sctp_peeraddr(struct socket *so, struct mbuf *nam) { @@ -8850,12 +8735,10 @@ sctp_peeraddr(struct socket *so, struct mbuf *nam) struct sctp_nets *net; /* Do the malloc first in case it blocks. */ -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) SCTP_MALLOC_SONAME(sin, struct sockaddr_in *, sizeof *sin); if (sin == NULL) return (ENOMEM); -#elif defined(__Panda__) - memset(sin, 0, sizeof(*sin)); #else SCTP_BUF_LEN(nam) = sizeof(*sin); memset(sin, 0, sizeof(*sin)); @@ -8869,7 +8752,7 @@ sctp_peeraddr(struct socket *so, struct mbuf *nam) if ((inp == NULL) || ((inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED) == 0)) { /* UDP type and listeners will drop out here */ -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) SCTP_FREE_SONAME(sin); #endif SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOTCONN); @@ -8882,7 +8765,7 @@ sctp_peeraddr(struct socket *so, struct mbuf *nam) } SCTP_INP_RUNLOCK(inp); if (stcb == NULL) { -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) SCTP_FREE_SONAME(sin); #endif SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); @@ -8901,19 +8784,19 @@ sctp_peeraddr(struct socket *so, struct mbuf *nam) SCTP_TCB_UNLOCK(stcb); if (!fnd) { /* No IPv4 address */ -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) SCTP_FREE_SONAME(sin); #endif SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOENT); return (ENOENT); } -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) (*addr) = (struct sockaddr *)sin; #endif return (0); } -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) struct pr_usrreqs sctp_usrreqs = { #if defined(__FreeBSD__) .pru_abort = sctp_abort, @@ -8922,15 +8805,10 @@ struct pr_usrreqs sctp_usrreqs = { .pru_bind = sctp_bind, .pru_connect = sctp_connect, .pru_control = in_control, -#if __FreeBSD_version >= 690000 .pru_close = sctp_close, .pru_detach = sctp_close, .pru_sopoll = sopoll_generic, .pru_flush = sctp_flush, -#else - .pru_detach = sctp_detach, - .pru_sopoll = sopoll, -#endif .pru_disconnect = sctp_disconnect, .pru_listen = sctp_listen, .pru_peeraddr = sctp_peeraddr, @@ -8960,7 +8838,7 @@ struct pr_usrreqs sctp_usrreqs = { .pru_sosend = sctp_sosend, .pru_soreceive = sctp_soreceive, .pru_sopoll = sopoll -#elif defined(__Windows__) +#elif defined(_WIN32) && !defined(__Userspace__) sctp_abort, sctp_accept, sctp_attach, @@ -8986,7 +8864,7 @@ struct pr_usrreqs sctp_usrreqs = { sctp_close #endif }; -#elif !defined(__Panda__) && !defined(__Userspace__) +#elif !defined(__Userspace__) int sctp_usrreq(so, req, m, nam, control) struct socket *so; @@ -8994,8 +8872,6 @@ sctp_usrreq(so, req, m, nam, control) struct mbuf *m, *nam, *control; { struct proc *p = curproc; - uint32_t vrf_id; - struct sctp_vrf *vrf; int error; int family; struct sctp_inpcb *inp = (struct sctp_inpcb *)so->so_pcb; @@ -9131,7 +9007,7 @@ register_recv_cb(struct socket *so, } int -register_send_cb(struct socket *so, uint32_t sb_threshold, int (*send_cb)(struct socket *sock, uint32_t sb_free)) +register_send_cb(struct socket *so, uint32_t sb_threshold, int (*send_cb)(struct socket *sock, uint32_t sb_free, void *ulp_info)) { struct sctp_inpcb *inp; @@ -9165,4 +9041,23 @@ register_ulp_info (struct socket *so, void *ulp_info) SCTP_INP_WUNLOCK(inp); return (1); } + +int +retrieve_ulp_info (struct socket *so, void **pulp_info) +{ + struct sctp_inpcb *inp; + + if (pulp_info == NULL) { + return (0); + } + + inp = (struct sctp_inpcb *) so->so_pcb; + if (inp == NULL) { + return (0); + } + SCTP_INP_RLOCK(inp); + *pulp_info = inp->ulp_info; + SCTP_INP_RUNLOCK(inp); + return (1); +} #endif diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_var.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_var.h index ead9e9cd61..1ce9f9aa93 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_var.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_var.h @@ -32,9 +32,9 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_var.h 317457 2017-04-26 19:26:40Z tuexen $"); +__FBSDID("$FreeBSD$"); #endif #ifndef _NETINET_SCTP_VAR_H_ @@ -44,11 +44,10 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_var.h 317457 2017-04-26 19:26:40Z tuex #if defined(_KERNEL) || defined(__Userspace__) -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) extern struct pr_usrreqs sctp_usrreqs; #endif - #define sctp_feature_on(inp, feature) (inp->sctp_features |= feature) #define sctp_feature_off(inp, feature) (inp->sctp_features &= ~feature) #define sctp_is_feature_on(inp, feature) ((inp->sctp_features & feature) == feature) @@ -186,18 +185,11 @@ extern struct pr_usrreqs sctp_usrreqs; } \ } -#if defined(__FreeBSD__) && __FreeBSD_version > 500000 - +#if defined(__FreeBSD__) && !defined(__Userspace__) #define sctp_free_remote_addr(__net) { \ if ((__net)) { \ if (SCTP_DECREMENT_AND_CHECK_REFCOUNT(&(__net)->ref_count)) { \ - (void)SCTP_OS_TIMER_STOP(&(__net)->rxt_timer.timer); \ - (void)SCTP_OS_TIMER_STOP(&(__net)->pmtu_timer.timer); \ - (void)SCTP_OS_TIMER_STOP(&(__net)->hb_timer.timer); \ - if ((__net)->ro.ro_rt) { \ - RTFREE((__net)->ro.ro_rt); \ - (__net)->ro.ro_rt = NULL; \ - } \ + RO_NHFREE(&(__net)->ro); \ if ((__net)->src_addr_selected) { \ sctp_free_ifa((__net)->ro._s_addr); \ (__net)->ro._s_addr = NULL; \ @@ -233,15 +225,10 @@ extern struct pr_usrreqs sctp_usrreqs; SCTP_BUF_TYPE(m) != MT_OOBDATA) \ atomic_add_int(&(sb)->sb_ctl,SCTP_BUF_LEN((m))); \ } - #else /* FreeBSD Version <= 500000 or non-FreeBSD */ - #define sctp_free_remote_addr(__net) { \ if ((__net)) { \ if (SCTP_DECREMENT_AND_CHECK_REFCOUNT(&(__net)->ref_count)) { \ - (void)SCTP_OS_TIMER_STOP(&(__net)->rxt_timer.timer); \ - (void)SCTP_OS_TIMER_STOP(&(__net)->pmtu_timer.timer); \ - (void)SCTP_OS_TIMER_STOP(&(__net)->hb_timer.timer); \ if ((__net)->ro.ro_rt) { \ RTFREE((__net)->ro.ro_rt); \ (__net)->ro.ro_rt = NULL; \ @@ -258,31 +245,6 @@ extern struct pr_usrreqs sctp_usrreqs; } \ } -#if defined(__Panda__) -#define sctp_sbfree(ctl, stcb, sb, m) { \ - if ((sb)->sb_cc >= (uint32_t)SCTP_BUF_LEN((m))) { \ - atomic_subtract_int(&(sb)->sb_cc, SCTP_BUF_LEN((m))); \ - } else { \ - (sb)->sb_cc = 0; \ - } \ - if (((ctl)->do_not_ref_stcb == 0) && stcb) { \ - if ((stcb)->asoc.sb_cc >= (uint32_t)SCTP_BUF_LEN((m))) { \ - atomic_subtract_int(&(stcb)->asoc.sb_cc, SCTP_BUF_LEN((m))); \ - } else { \ - (stcb)->asoc.sb_cc = 0; \ - } \ - } \ -} - -#define sctp_sballoc(stcb, sb, m) { \ - atomic_add_int(&(sb)->sb_cc, SCTP_BUF_LEN((m))); \ - if (stcb) { \ - atomic_add_int(&(stcb)->asoc.sb_cc, SCTP_BUF_LEN((m))); \ - } \ -} - -#else - #define sctp_sbfree(ctl, stcb, sb, m) { \ SCTP_SAVE_ATOMIC_DECREMENT(&(sb)->sb_cc, SCTP_BUF_LEN((m))); \ SCTP_SAVE_ATOMIC_DECREMENT(&(sb)->sb_mbcnt, MSIZE); \ @@ -301,7 +263,6 @@ extern struct pr_usrreqs sctp_usrreqs; } \ } #endif -#endif #define sctp_ucount_incr(val) { \ val++; \ @@ -402,23 +363,13 @@ struct sctp_inpcb; struct sctp_tcb; struct sctphdr; - -#if (defined(__FreeBSD__) && __FreeBSD_version > 690000) || defined(__Windows__) || defined(__Userspace__) +#if defined(__FreeBSD__) || defined(_WIN32) || defined(__Userspace__) void sctp_close(struct socket *so); #else int sctp_detach(struct socket *so); #endif int sctp_disconnect(struct socket *so); -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) -#if defined(__FreeBSD__) && __FreeBSD_version < 902000 -void sctp_ctlinput __P((int, struct sockaddr *, void *)); -int sctp_ctloutput __P((struct socket *, struct sockopt *)); -#ifdef INET -void sctp_input_with_port __P((struct mbuf *, int, uint16_t)); -void sctp_input __P((struct mbuf *, int)); -#endif -void sctp_pathmtu_adjustment __P((struct sctp_tcb *, uint16_t)); -#else +#if !defined(__Userspace__) #if defined(__APPLE__) && !defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) && !defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION) && !defined(APPLE_ELCAPITAN) void sctp_ctlinput(int, struct sockaddr *, void *, struct ifnet * SCTP_UNUSED); #else @@ -427,92 +378,67 @@ void sctp_ctlinput(int, struct sockaddr *, void *); int sctp_ctloutput(struct socket *, struct sockopt *); #ifdef INET void sctp_input_with_port(struct mbuf *, int, uint16_t); -#if defined(__FreeBSD__) && __FreeBSD_version >= 1100020 +#if defined(__FreeBSD__) && !defined(__Userspace__) int sctp_input(struct mbuf **, int *, int); #else void sctp_input(struct mbuf *, int); #endif #endif -void sctp_pathmtu_adjustment(struct sctp_tcb *, uint16_t); -#endif +void sctp_pathmtu_adjustment(struct sctp_tcb *, uint32_t, bool); #else -#if defined(__Panda__) -void sctp_input(pakhandle_type i_pak); -#elif defined(__Userspace__) -void sctp_pathmtu_adjustment(struct sctp_tcb *, uint16_t); +#if defined(__Userspace__) +void sctp_pathmtu_adjustment(struct sctp_tcb *, uint32_t, bool); #else void sctp_input(struct mbuf *,...); #endif void *sctp_ctlinput(int, struct sockaddr *, void *); int sctp_ctloutput(int, struct socket *, int, int, struct mbuf **); #endif -#if defined(__FreeBSD__) && __FreeBSD_version < 902000 -void sctp_drain __P((void)); -#else void sctp_drain(void); -#endif #if defined(__Userspace__) void sctp_init(uint16_t, int (*)(void *addr, void *buffer, size_t length, uint8_t tos, uint8_t set_df), void (*)(const char *, ...), int start_threads); -#elif defined(__FreeBSD__) && __FreeBSD_version < 902000 -void sctp_init __P((void)); #elif defined(__APPLE__) && (!defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) &&!defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION)) void sctp_init(struct protosw *pp, struct domain *dp); #else +#if !defined(__FreeBSD__) void sctp_init(void); +#endif void sctp_notify(struct sctp_inpcb *, struct sctp_tcb *, struct sctp_nets *, uint8_t, uint8_t, uint16_t, uint32_t); #endif -#if !defined(__FreeBSD__) +#if !defined(__FreeBSD__) && !defined(__Userspace__) void sctp_finish(void); #endif -#if defined(__FreeBSD__) || defined(__Windows__) || defined(__Userspace__) +#if defined(__FreeBSD__) || defined(_WIN32) || defined(__Userspace__) int sctp_flush(struct socket *, int); #endif -#if defined(__FreeBSD__) && __FreeBSD_version < 902000 -int sctp_shutdown __P((struct socket *)); -#else int sctp_shutdown(struct socket *); -#endif int sctp_bindx(struct socket *, int, struct sockaddr_storage *, int, int, struct proc *); /* can't use sctp_assoc_t here */ int sctp_peeloff(struct socket *, struct socket *, int, caddr_t, int *); -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) int sctp_ingetaddr(struct socket *, struct sockaddr **); -#elif defined(__Panda__) -int sctp_ingetaddr(struct socket *, struct sockaddr *); #else int sctp_ingetaddr(struct socket *, struct mbuf *); #endif -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) int sctp_peeraddr(struct socket *, struct sockaddr **); -#elif defined(__Panda__) -int sctp_peeraddr(struct socket *, struct sockaddr *); #else int sctp_peeraddr(struct socket *, struct mbuf *); #endif -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 -#if __FreeBSD_version >= 700000 +#if defined(__FreeBSD__) && !defined(__Userspace__) int sctp_listen(struct socket *, int, struct thread *); -#else -int sctp_listen(struct socket *, struct thread *); -#endif -#elif defined(__Windows__) +#elif defined(_WIN32) && !defined(__Userspace__) int sctp_listen(struct socket *, int, PKTHREAD); #elif defined(__Userspace__) int sctp_listen(struct socket *, int, struct proc *); #else int sctp_listen(struct socket *, struct proc *); #endif -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) || defined(__Userspace__) int sctp_accept(struct socket *, struct sockaddr **); -#elif defined(__Panda__) -int sctp_accept(struct socket *, struct sockaddr *, int *, void *, int *); -#else -int sctp_accept(struct socket *, struct mbuf *); -#endif #endif /* _KERNEL */ diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctputil.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctputil.c index 001a2b37d1..55d3a152e4 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctputil.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctputil.c @@ -32,9 +32,9 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include -__FBSDID("$FreeBSD: head/sys/netinet/sctputil.c 353518 2019-10-14 20:32:11Z tuexen $"); +__FBSDID("$FreeBSD$"); #endif #include @@ -58,7 +58,7 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctputil.c 353518 2019-10-14 20:32:11Z tuex #if defined(__Userspace__) #include #endif -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) #include #if defined(INET6) || defined(INET) #include @@ -71,11 +71,7 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctputil.c 353518 2019-10-14 20:32:11Z tuex #endif #endif -#if defined(__APPLE__) -#define APPLE_FILE_NO 8 -#endif - -#if defined(__Windows__) +#if defined(_WIN32) && !defined(__Userspace__) #if !defined(SCTP_LOCAL_TRACE_BUF) #include "eventrace_netinet.h" #include "sctputil.tmh" /* this is the file that will be auto generated */ @@ -274,7 +270,7 @@ sctp_log_mb(struct mbuf *m, int from) sctp_clog.x.mb.data = SCTP_BUF_AT(m, 0); if (SCTP_BUF_IS_EXTENDED(m)) { sctp_clog.x.mb.ext = SCTP_BUF_EXTEND_BASE(m); -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) /* APPLE does not use a ref_cnt, but a forward/backward ref queue */ #else sctp_clog.x.mb.refcnt = (uint8_t)(SCTP_BUF_EXTEND_REFCNT(m)); @@ -372,7 +368,7 @@ sctp_log_cwnd(struct sctp_tcb *stcb, struct sctp_nets *net, int augment, uint8_t #endif } -#ifndef __APPLE__ +#if !defined(__APPLE__) && !defined(__Userspace__) void sctp_log_lock(struct sctp_inpcb *inp, struct sctp_tcb *stcb, uint8_t from) { @@ -387,7 +383,7 @@ sctp_log_lock(struct sctp_inpcb *inp, struct sctp_tcb *stcb, uint8_t from) sctp_clog.x.lock.sock = (void *) NULL; } sctp_clog.x.lock.inp = (void *) inp; -#if (defined(__FreeBSD__) && __FreeBSD_version >= 503000) || (defined(__APPLE__)) +#if defined(__FreeBSD__) if (stcb) { sctp_clog.x.lock.tcb_lock = mtx_owned(&stcb->tcb_mtx); } else { @@ -400,15 +396,11 @@ sctp_log_lock(struct sctp_inpcb *inp, struct sctp_tcb *stcb, uint8_t from) sctp_clog.x.lock.inp_lock = SCTP_LOCK_UNKNOWN; sctp_clog.x.lock.create_lock = SCTP_LOCK_UNKNOWN; } -#if (defined(__FreeBSD__) && __FreeBSD_version <= 602000) - sctp_clog.x.lock.info_lock = mtx_owned(&SCTP_BASE_INFO(ipi_ep_mtx)); -#else sctp_clog.x.lock.info_lock = rw_wowned(&SCTP_BASE_INFO(ipi_ep_mtx)); -#endif if (inp && (inp->sctp_socket)) { - sctp_clog.x.lock.sock_lock = mtx_owned(&(inp->sctp_socket->so_rcv.sb_mtx)); - sctp_clog.x.lock.sockrcvbuf_lock = mtx_owned(&(inp->sctp_socket->so_rcv.sb_mtx)); - sctp_clog.x.lock.socksndbuf_lock = mtx_owned(&(inp->sctp_socket->so_snd.sb_mtx)); + sctp_clog.x.lock.sock_lock = mtx_owned(SOCK_MTX(inp->sctp_socket)); + sctp_clog.x.lock.sockrcvbuf_lock = mtx_owned(SOCKBUF_MTX(&inp->sctp_socket->so_rcv)); + sctp_clog.x.lock.socksndbuf_lock = mtx_owned(SOCKBUF_MTX(&inp->sctp_socket->so_snd)); } else { sctp_clog.x.lock.sock_lock = SCTP_LOCK_UNKNOWN; sctp_clog.x.lock.sockrcvbuf_lock = SCTP_LOCK_UNKNOWN; @@ -768,7 +760,6 @@ sctp_auditing(int from, struct sctp_inpcb *inp, struct sctp_tcb *stcb, stcb->asoc.total_flight, tot_out); /* now corrective action */ TAILQ_FOREACH(lnet, &stcb->asoc.nets, sctp_next) { - tot_out = 0; TAILQ_FOREACH(chk, &stcb->asoc.sent_queue, sctp_next) { if ((chk->whoTo == lnet) && @@ -803,6 +794,80 @@ sctp_audit_log(uint8_t ev, uint8_t fd) #endif +/* + * The conversion from time to ticks and vice versa is done by rounding + * upwards. This way we can test in the code the time to be positive and + * know that this corresponds to a positive number of ticks. + */ + +uint32_t +sctp_msecs_to_ticks(uint32_t msecs) +{ + uint64_t temp; + uint32_t ticks; + + if (hz == 1000) { + ticks = msecs; + } else { + temp = (((uint64_t)msecs * hz) + 999) / 1000; + if (temp > UINT32_MAX) { + ticks = UINT32_MAX; + } else { + ticks = (uint32_t)temp; + } + } + return (ticks); +} + +uint32_t +sctp_ticks_to_msecs(uint32_t ticks) +{ + uint64_t temp; + uint32_t msecs; + + if (hz == 1000) { + msecs = ticks; + } else { + temp = (((uint64_t)ticks * 1000) + (hz - 1)) / hz; + if (temp > UINT32_MAX) { + msecs = UINT32_MAX; + } else { + msecs = (uint32_t)temp; + } + } + return (msecs); +} + +uint32_t +sctp_secs_to_ticks(uint32_t secs) +{ + uint64_t temp; + uint32_t ticks; + + temp = (uint64_t)secs * hz; + if (temp > UINT32_MAX) { + ticks = UINT32_MAX; + } else { + ticks = (uint32_t)temp; + } + return (ticks); +} + +uint32_t +sctp_ticks_to_secs(uint32_t ticks) +{ + uint64_t temp; + uint32_t secs; + + temp = ((uint64_t)ticks + (hz - 1)) / hz; + if (temp > UINT32_MAX) { + secs = UINT32_MAX; + } else { + secs = (uint32_t)temp; + } + return (secs); +} + /* * sctp_stop_timers_for_shutdown() should be called * when entering the SHUTDOWN_SENT or SHUTDOWN_ACK_SENT @@ -811,19 +876,66 @@ sctp_audit_log(uint8_t ev, uint8_t fd) void sctp_stop_timers_for_shutdown(struct sctp_tcb *stcb) { - struct sctp_association *asoc; + struct sctp_inpcb *inp; struct sctp_nets *net; - asoc = &stcb->asoc; + inp = stcb->sctp_ep; - (void)SCTP_OS_TIMER_STOP(&asoc->dack_timer.timer); - (void)SCTP_OS_TIMER_STOP(&asoc->strreset_timer.timer); - (void)SCTP_OS_TIMER_STOP(&asoc->asconf_timer.timer); - (void)SCTP_OS_TIMER_STOP(&asoc->autoclose_timer.timer); - (void)SCTP_OS_TIMER_STOP(&asoc->delayed_event_timer.timer); - TAILQ_FOREACH(net, &asoc->nets, sctp_next) { - (void)SCTP_OS_TIMER_STOP(&net->pmtu_timer.timer); - (void)SCTP_OS_TIMER_STOP(&net->hb_timer.timer); + sctp_timer_stop(SCTP_TIMER_TYPE_RECV, inp, stcb, NULL, + SCTP_FROM_SCTPUTIL + SCTP_LOC_12); + sctp_timer_stop(SCTP_TIMER_TYPE_STRRESET, inp, stcb, NULL, + SCTP_FROM_SCTPUTIL + SCTP_LOC_13); + sctp_timer_stop(SCTP_TIMER_TYPE_ASCONF, inp, stcb, NULL, + SCTP_FROM_SCTPUTIL + SCTP_LOC_14); + sctp_timer_stop(SCTP_TIMER_TYPE_AUTOCLOSE, inp, stcb, NULL, + SCTP_FROM_SCTPUTIL + SCTP_LOC_15); + TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { + sctp_timer_stop(SCTP_TIMER_TYPE_PATHMTURAISE, inp, stcb, net, + SCTP_FROM_SCTPUTIL + SCTP_LOC_16); + sctp_timer_stop(SCTP_TIMER_TYPE_HEARTBEAT, inp, stcb, net, + SCTP_FROM_SCTPUTIL + SCTP_LOC_17); + } +} + +void +sctp_stop_association_timers(struct sctp_tcb *stcb, bool stop_assoc_kill_timer) +{ + struct sctp_inpcb *inp; + struct sctp_nets *net; + + inp = stcb->sctp_ep; + sctp_timer_stop(SCTP_TIMER_TYPE_RECV, inp, stcb, NULL, + SCTP_FROM_SCTPUTIL + SCTP_LOC_18); + sctp_timer_stop(SCTP_TIMER_TYPE_STRRESET, inp, stcb, NULL, + SCTP_FROM_SCTPUTIL + SCTP_LOC_19); + if (stop_assoc_kill_timer) { + sctp_timer_stop(SCTP_TIMER_TYPE_ASOCKILL, inp, stcb, NULL, + SCTP_FROM_SCTPUTIL + SCTP_LOC_20); + } + sctp_timer_stop(SCTP_TIMER_TYPE_ASCONF, inp, stcb, NULL, + SCTP_FROM_SCTPUTIL + SCTP_LOC_21); + sctp_timer_stop(SCTP_TIMER_TYPE_AUTOCLOSE, inp, stcb, NULL, + SCTP_FROM_SCTPUTIL + SCTP_LOC_22); + sctp_timer_stop(SCTP_TIMER_TYPE_SHUTDOWNGUARD, inp, stcb, NULL, + SCTP_FROM_SCTPUTIL + SCTP_LOC_23); + /* Mobility adaptation */ + sctp_timer_stop(SCTP_TIMER_TYPE_PRIM_DELETED, inp, stcb, NULL, + SCTP_FROM_SCTPUTIL + SCTP_LOC_24); + TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { + sctp_timer_stop(SCTP_TIMER_TYPE_SEND, inp, stcb, net, + SCTP_FROM_SCTPUTIL + SCTP_LOC_25); + sctp_timer_stop(SCTP_TIMER_TYPE_INIT, inp, stcb, net, + SCTP_FROM_SCTPUTIL + SCTP_LOC_26); + sctp_timer_stop(SCTP_TIMER_TYPE_SHUTDOWN, inp, stcb, net, + SCTP_FROM_SCTPUTIL + SCTP_LOC_27); + sctp_timer_stop(SCTP_TIMER_TYPE_COOKIE, inp, stcb, net, + SCTP_FROM_SCTPUTIL + SCTP_LOC_28); + sctp_timer_stop(SCTP_TIMER_TYPE_SHUTDOWNACK, inp, stcb, net, + SCTP_FROM_SCTPUTIL + SCTP_LOC_29); + sctp_timer_stop(SCTP_TIMER_TYPE_PATHMTURAISE, inp, stcb, net, + SCTP_FROM_SCTPUTIL + SCTP_LOC_30); + sctp_timer_stop(SCTP_TIMER_TYPE_HEARTBEAT, inp, stcb, net, + SCTP_FROM_SCTPUTIL + SCTP_LOC_31); } } @@ -846,7 +958,7 @@ static uint32_t sctp_mtu_sizes[] = { 2048, 4352, 4464, - 8166, + 8168, 17912, 32000, 65532 @@ -1030,7 +1142,8 @@ sctp_map_assoc_state(int kernel_state) int sctp_init_asoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, - uint32_t override_tag, uint32_t vrf_id, uint16_t o_strms) + uint32_t override_tag, uint32_t initial_tsn, uint32_t vrf_id, + uint16_t o_strms) { struct sctp_association *asoc; /* @@ -1054,12 +1167,11 @@ sctp_init_asoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, SCTP_SET_STATE(stcb, SCTP_STATE_INUSE); asoc->max_burst = inp->sctp_ep.max_burst; asoc->fr_max_burst = inp->sctp_ep.fr_max_burst; - asoc->heart_beat_delay = TICKS_TO_MSEC(inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_HEARTBEAT]); + asoc->heart_beat_delay = sctp_ticks_to_msecs(inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_HEARTBEAT]); asoc->cookie_life = inp->sctp_ep.def_cookie_life; asoc->sctp_cmt_on_off = inp->sctp_cmt_on_off; asoc->ecn_supported = inp->ecn_supported; asoc->prsctp_supported = inp->prsctp_supported; - asoc->idata_supported = inp->idata_supported; asoc->auth_supported = inp->auth_supported; asoc->asconf_supported = inp->asconf_supported; asoc->reconfig_supported = inp->reconfig_supported; @@ -1108,23 +1220,28 @@ sctp_init_asoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, #endif asoc->refcnt = 0; asoc->assoc_up_sent = 0; - asoc->asconf_seq_out = asoc->str_reset_seq_out = asoc->init_seq_number = asoc->sending_seq = - sctp_select_initial_TSN(&inp->sctp_ep); - asoc->asconf_seq_out_acked = asoc->asconf_seq_out - 1; + if (override_tag) { + asoc->init_seq_number = initial_tsn; + } else { + asoc->init_seq_number = sctp_select_initial_TSN(&inp->sctp_ep); + } + asoc->asconf_seq_out = asoc->init_seq_number; + asoc->str_reset_seq_out = asoc->init_seq_number; + asoc->sending_seq = asoc->init_seq_number; + asoc->asconf_seq_out_acked = asoc->init_seq_number - 1; /* we are optimisitic here */ asoc->peer_supports_nat = 0; asoc->sent_queue_retran_cnt = 0; /* for CMT */ - asoc->last_net_cmt_send_started = NULL; + asoc->last_net_cmt_send_started = NULL; - /* This will need to be adjusted */ asoc->last_acked_seq = asoc->init_seq_number - 1; - asoc->advanced_peer_ack_point = asoc->last_acked_seq; - asoc->asconf_seq_in = asoc->last_acked_seq; + asoc->advanced_peer_ack_point = asoc->init_seq_number - 1; + asoc->asconf_seq_in = asoc->init_seq_number - 1; /* here we are different, we hold the next one we expect */ - asoc->str_reset_seq_in = asoc->last_acked_seq + 1; + asoc->str_reset_seq_in = asoc->init_seq_number; asoc->initial_init_rto_max = inp->sctp_ep.initial_init_rto_max; asoc->initial_rto = inp->sctp_ep.initial_rto; @@ -1140,7 +1257,7 @@ sctp_init_asoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, asoc->context = inp->sctp_context; asoc->local_strreset_support = inp->local_strreset_support; asoc->def_send = inp->def_send; - asoc->delayed_ack = TICKS_TO_MSEC(inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_RECV]); + asoc->delayed_ack = sctp_ticks_to_msecs(inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_RECV]); asoc->sack_freq = inp->sctp_ep.sctp_sack_freq; asoc->pr_sctp_cnt = 0; asoc->total_output_queue_size = 0; @@ -1173,7 +1290,7 @@ sctp_init_asoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, asoc->my_rwnd = max(SCTP_SB_LIMIT_RCV(inp->sctp_socket), SCTP_MINIMAL_RWND); asoc->peers_rwnd = SCTP_SB_LIMIT_RCV(inp->sctp_socket); - asoc->smallest_mtu = inp->sctp_frag_point; + asoc->smallest_mtu = 0; asoc->minrto = inp->sctp_ep.sctp_minrto; asoc->maxrto = inp->sctp_ep.sctp_maxrto; @@ -1213,6 +1330,7 @@ sctp_init_asoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, SCTP_LTRACE_ERR_RET(NULL, stcb, NULL, SCTP_FROM_SCTPUTIL, ENOMEM); return (ENOMEM); } + SCTP_TCB_SEND_LOCK(stcb); for (i = 0; i < asoc->streamoutcnt; i++) { /* * inbound side must be set to 0xffff, also NOTE when we get @@ -1222,9 +1340,8 @@ sctp_init_asoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, * that were dropped must be notified to the upper layer as * failed to send. */ - asoc->strmout[i].next_mid_ordered = 0; - asoc->strmout[i].next_mid_unordered = 0; TAILQ_INIT(&asoc->strmout[i].outqueue); + asoc->ss_functions.sctp_ss_init_stream(stcb, &asoc->strmout[i], NULL); asoc->strmout[i].chunks_on_queues = 0; #if defined(SCTP_DETAILED_STR_STATS) for (j = 0; j < SCTP_PR_SCTP_MAX + 1; j++) { @@ -1235,12 +1352,14 @@ sctp_init_asoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, asoc->strmout[i].abandoned_sent[0] = 0; asoc->strmout[i].abandoned_unsent[0] = 0; #endif + asoc->strmout[i].next_mid_ordered = 0; + asoc->strmout[i].next_mid_unordered = 0; asoc->strmout[i].sid = i; asoc->strmout[i].last_msg_incomplete = 0; asoc->strmout[i].state = SCTP_STREAM_OPENING; - asoc->ss_functions.sctp_ss_init_stream(stcb, &asoc->strmout[i], NULL); } - asoc->ss_functions.sctp_ss_init(stcb, asoc, 0); + asoc->ss_functions.sctp_ss_init(stcb, asoc); + SCTP_TCB_SEND_UNLOCK(stcb); /* Now the mapping array */ asoc->mapping_array_size = SCTP_INITIAL_MAPPING_ARRAY; @@ -1368,15 +1487,20 @@ sctp_expand_mapping_array(struct sctp_association *asoc, uint32_t needed) return (0); } - static void sctp_iterator_work(struct sctp_iterator *it) { +#if defined(__FreeBSD__) && !defined(__Userspace__) + struct epoch_tracker et; +#endif + struct sctp_inpcb *tinp; int iteration_count = 0; int inp_skip = 0; int first_in = 1; - struct sctp_inpcb *tinp; +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_ENTER(et); +#endif SCTP_INP_INFO_RLOCK(); SCTP_ITERATOR_LOCK(); sctp_it_ctl.cur_it = it; @@ -1394,6 +1518,9 @@ done_with_iterator: (*it->function_atend) (it->pointer, it->val); } SCTP_FREE(it, SCTP_M_ITER); +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_EXIT(et); +#endif return; } select_a_new_ep: @@ -1413,6 +1540,7 @@ select_a_new_ep: } tinp = it->inp; it->inp = LIST_NEXT(it->inp, sctp_list); + it->stcb = NULL; SCTP_INP_RUNLOCK(tinp); if (it->inp == NULL) { goto done_with_iterator; @@ -1438,7 +1566,7 @@ select_a_new_ep: SCTP_INP_RUNLOCK(it->inp); goto no_stcb; } - while (it->stcb) { + while (it->stcb != NULL) { SCTP_TCB_LOCK(it->stcb); if (it->asoc_state && ((it->stcb->asoc.state & it->asoc_state) != it->asoc_state)) { /* not in the right state... keep looking */ @@ -1460,8 +1588,8 @@ select_a_new_ep: if (sctp_it_ctl.iterator_flags) { /* We won't be staying here */ SCTP_INP_DECR_REF(it->inp); - atomic_add_int(&it->stcb->asoc.refcnt, -1); -#if !defined(__FreeBSD__) + atomic_subtract_int(&it->stcb->asoc.refcnt, 1); +#if !(defined(__FreeBSD__) && !defined(__Userspace__)) if (sctp_it_ctl.iterator_flags & SCTP_ITERATOR_MUST_EXIT) { goto done_with_iterator; @@ -1485,19 +1613,29 @@ select_a_new_ep: SCTP_INP_RLOCK(it->inp); SCTP_INP_DECR_REF(it->inp); SCTP_TCB_LOCK(it->stcb); - atomic_add_int(&it->stcb->asoc.refcnt, -1); + atomic_subtract_int(&it->stcb->asoc.refcnt, 1); iteration_count = 0; } + KASSERT(it->inp == it->stcb->sctp_ep, + ("%s: stcb %p does not belong to inp %p, but inp %p", + __func__, it->stcb, it->inp, it->stcb->sctp_ep)); + SCTP_INP_RLOCK_ASSERT(it->inp); + SCTP_TCB_LOCK_ASSERT(it->stcb); /* run function on this one */ (*it->function_assoc)(it->inp, it->stcb, it->pointer, it->val); + SCTP_INP_RLOCK_ASSERT(it->inp); + SCTP_TCB_LOCK_ASSERT(it->stcb); /* * we lie here, it really needs to have its own type but * first I must verify that this won't effect things :-0 */ - if (it->no_chunk_output == 0) + if (it->no_chunk_output == 0) { sctp_chunk_output(it->inp, it->stcb, SCTP_OUTPUT_FROM_T3, SCTP_SO_NOT_LOCKED); + SCTP_INP_RLOCK_ASSERT(it->inp); + SCTP_TCB_LOCK_ASSERT(it->stcb); + } SCTP_TCB_UNLOCK(it->stcb); next_assoc: @@ -1520,6 +1658,7 @@ select_a_new_ep: } else { it->inp = LIST_NEXT(it->inp, sctp_list); } + it->stcb = NULL; if (it->inp == NULL) { goto done_with_iterator; } @@ -1529,24 +1668,23 @@ select_a_new_ep: void sctp_iterator_worker(void) { - struct sctp_iterator *it, *nit; + struct sctp_iterator *it; /* This function is called with the WQ lock in place */ - sctp_it_ctl.iterator_running = 1; - TAILQ_FOREACH_SAFE(it, &sctp_it_ctl.iteratorhead, sctp_nxt_itr, nit) { + while ((it = TAILQ_FIRST(&sctp_it_ctl.iteratorhead)) != NULL) { /* now lets work on this one */ TAILQ_REMOVE(&sctp_it_ctl.iteratorhead, it, sctp_nxt_itr); SCTP_IPI_ITERATOR_WQ_UNLOCK(); -#if defined(__FreeBSD__) && __FreeBSD_version >= 801000 +#if defined(__FreeBSD__) && !defined(__Userspace__) CURVNET_SET(it->vn); #endif sctp_iterator_work(it); -#if defined(__FreeBSD__) && __FreeBSD_version >= 801000 +#if defined(__FreeBSD__) && !defined(__Userspace__) CURVNET_RESTORE(); #endif SCTP_IPI_ITERATOR_WQ_LOCK(); -#if !defined(__FreeBSD__) +#if !defined(__FreeBSD__) && !defined(__Userspace__) if (sctp_it_ctl.iterator_flags & SCTP_ITERATOR_MUST_EXIT) { break; } @@ -1557,7 +1695,6 @@ sctp_iterator_worker(void) return; } - static void sctp_handle_addr_wq(void) { @@ -1612,31 +1749,67 @@ sctp_handle_addr_wq(void) } } +/*- + * The following table shows which pointers for the inp, stcb, or net are + * stored for each timer after it was started. + * + *|Name |Timer |inp |stcb|net | + *|-----------------------------|-----------------------------|----|----|----| + *|SCTP_TIMER_TYPE_SEND |net->rxt_timer |Yes |Yes |Yes | + *|SCTP_TIMER_TYPE_INIT |net->rxt_timer |Yes |Yes |Yes | + *|SCTP_TIMER_TYPE_RECV |stcb->asoc.dack_timer |Yes |Yes |No | + *|SCTP_TIMER_TYPE_SHUTDOWN |net->rxt_timer |Yes |Yes |Yes | + *|SCTP_TIMER_TYPE_HEARTBEAT |net->hb_timer |Yes |Yes |Yes | + *|SCTP_TIMER_TYPE_COOKIE |net->rxt_timer |Yes |Yes |Yes | + *|SCTP_TIMER_TYPE_NEWCOOKIE |inp->sctp_ep.signature_change|Yes |No |No | + *|SCTP_TIMER_TYPE_PATHMTURAISE |net->pmtu_timer |Yes |Yes |Yes | + *|SCTP_TIMER_TYPE_SHUTDOWNACK |net->rxt_timer |Yes |Yes |Yes | + *|SCTP_TIMER_TYPE_ASCONF |stcb->asoc.asconf_timer |Yes |Yes |Yes | + *|SCTP_TIMER_TYPE_SHUTDOWNGUARD|stcb->asoc.shut_guard_timer |Yes |Yes |No | + *|SCTP_TIMER_TYPE_AUTOCLOSE |stcb->asoc.autoclose_timer |Yes |Yes |No | + *|SCTP_TIMER_TYPE_STRRESET |stcb->asoc.strreset_timer |Yes |Yes |No | + *|SCTP_TIMER_TYPE_INPKILL |inp->sctp_ep.signature_change|Yes |No |No | + *|SCTP_TIMER_TYPE_ASOCKILL |stcb->asoc.strreset_timer |Yes |Yes |No | + *|SCTP_TIMER_TYPE_ADDR_WQ |SCTP_BASE_INFO(addr_wq_timer)|No |No |No | + *|SCTP_TIMER_TYPE_PRIM_DELETED |stcb->asoc.delete_prim_timer |Yes |Yes |No | + */ + void sctp_timeout_handler(void *t) { +#if defined(__FreeBSD__) && !defined(__Userspace__) + struct epoch_tracker et; +#endif + struct timeval tv; struct sctp_inpcb *inp; struct sctp_tcb *stcb; struct sctp_nets *net; struct sctp_timer *tmr; struct mbuf *op_err; -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) struct socket *so; #endif #if defined(__Userspace__) struct socket *upcall_socket = NULL; #endif - int did_output; int type; + int i, secret; + bool did_output, released_asoc_reference; + /* + * If inp, stcb or net are not NULL, then references to these were + * added when the timer was started, and must be released before this + * function returns. + */ tmr = (struct sctp_timer *)t; inp = (struct sctp_inpcb *)tmr->ep; stcb = (struct sctp_tcb *)tmr->tcb; net = (struct sctp_nets *)tmr->net; -#if defined(__FreeBSD__) && __FreeBSD_version >= 801000 +#if defined(__FreeBSD__) && !defined(__Userspace__) CURVNET_SET((struct vnet *)tmr->vnet); + NET_EPOCH_ENTER(et); #endif - did_output = 1; + released_asoc_reference = false; #ifdef SCTP_AUDITING_ENABLED sctp_audit_log(0xF0, (uint8_t) tmr->type); @@ -1644,123 +1817,68 @@ sctp_timeout_handler(void *t) #endif /* sanity checks... */ - if (tmr->self != (void *)tmr) { - /* - * SCTP_PRINTF("Stale SCTP timer fired (%p), ignoring...\n", - * (void *)tmr); - */ -#if defined(__FreeBSD__) && __FreeBSD_version >= 801000 - CURVNET_RESTORE(); -#endif - return; - } + KASSERT(tmr->self == NULL || tmr->self == tmr, + ("sctp_timeout_handler: tmr->self corrupted")); + KASSERT(SCTP_IS_TIMER_TYPE_VALID(tmr->type), + ("sctp_timeout_handler: invalid timer type %d", tmr->type)); + type = tmr->type; + KASSERT(stcb == NULL || stcb->sctp_ep == inp, + ("sctp_timeout_handler of type %d: inp = %p, stcb->sctp_ep %p", + type, stcb, stcb->sctp_ep)); tmr->stopped_from = 0xa001; - if (!SCTP_IS_TIMER_TYPE_VALID(tmr->type)) { - /* - * SCTP_PRINTF("SCTP timer fired with invalid type: 0x%x\n", - * tmr->type); - */ -#if defined(__FreeBSD__) && __FreeBSD_version >= 801000 - CURVNET_RESTORE(); -#endif - return; + if ((stcb != NULL) && (stcb->asoc.state == SCTP_STATE_EMPTY)) { + SCTPDBG(SCTP_DEBUG_TIMER2, + "Timer type %d handler exiting due to CLOSED association.\n", + type); + goto out_decr; } tmr->stopped_from = 0xa002; - if ((tmr->type != SCTP_TIMER_TYPE_ADDR_WQ) && (inp == NULL)) { -#if defined(__FreeBSD__) && __FreeBSD_version >= 801000 - CURVNET_RESTORE(); -#endif - return; - } - /* if this is an iterator timeout, get the struct and clear inp */ - tmr->stopped_from = 0xa003; - if (inp) { - SCTP_INP_INCR_REF(inp); - if ((inp->sctp_socket == NULL) && - ((tmr->type != SCTP_TIMER_TYPE_INPKILL) && - (tmr->type != SCTP_TIMER_TYPE_INIT) && - (tmr->type != SCTP_TIMER_TYPE_SEND) && - (tmr->type != SCTP_TIMER_TYPE_RECV) && - (tmr->type != SCTP_TIMER_TYPE_HEARTBEAT) && - (tmr->type != SCTP_TIMER_TYPE_SHUTDOWN) && - (tmr->type != SCTP_TIMER_TYPE_SHUTDOWNACK) && - (tmr->type != SCTP_TIMER_TYPE_SHUTDOWNGUARD) && - (tmr->type != SCTP_TIMER_TYPE_ASOCKILL))) { - SCTP_INP_DECR_REF(inp); -#if defined(__FreeBSD__) && __FreeBSD_version >= 801000 - CURVNET_RESTORE(); -#endif - return; - } - } - tmr->stopped_from = 0xa004; - if (stcb) { - atomic_add_int(&stcb->asoc.refcnt, 1); - if (stcb->asoc.state == 0) { - atomic_add_int(&stcb->asoc.refcnt, -1); - if (inp) { - SCTP_INP_DECR_REF(inp); - } -#if defined(__FreeBSD__) && __FreeBSD_version >= 801000 - CURVNET_RESTORE(); -#endif - return; - } - } - type = tmr->type; - tmr->stopped_from = 0xa005; - SCTPDBG(SCTP_DEBUG_TIMER1, "Timer type %d goes off\n", type); + SCTPDBG(SCTP_DEBUG_TIMER2, "Timer type %d goes off.\n", type); if (!SCTP_OS_TIMER_ACTIVE(&tmr->timer)) { - if (inp) { - SCTP_INP_DECR_REF(inp); - } - if (stcb) { - atomic_add_int(&stcb->asoc.refcnt, -1); - } -#if defined(__FreeBSD__) && __FreeBSD_version >= 801000 - CURVNET_RESTORE(); -#endif - return; + SCTPDBG(SCTP_DEBUG_TIMER2, + "Timer type %d handler exiting due to not being active.\n", + type); + goto out_decr; } - tmr->stopped_from = 0xa006; + tmr->stopped_from = 0xa003; if (stcb) { SCTP_TCB_LOCK(stcb); - atomic_add_int(&stcb->asoc.refcnt, -1); + /* + * Release reference so that association can be freed if + * necessary below. + * This is safe now that we have acquired the lock. + */ + atomic_subtract_int(&stcb->asoc.refcnt, 1); + released_asoc_reference = true; if ((type != SCTP_TIMER_TYPE_ASOCKILL) && - ((stcb->asoc.state == 0) || + ((stcb->asoc.state == SCTP_STATE_EMPTY) || (stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED))) { - SCTP_TCB_UNLOCK(stcb); - if (inp) { - SCTP_INP_DECR_REF(inp); - } -#if defined(__FreeBSD__) && __FreeBSD_version >= 801000 - CURVNET_RESTORE(); -#endif - return; + SCTPDBG(SCTP_DEBUG_TIMER2, + "Timer type %d handler exiting due to CLOSED association.\n", + type); + goto out; } } else if (inp != NULL) { - if (type != SCTP_TIMER_TYPE_INPKILL) { - SCTP_INP_WLOCK(inp); - } + SCTP_INP_WLOCK(inp); } else { SCTP_WQ_ADDR_LOCK(); } - /* record in stopped what t-o occurred */ - tmr->stopped_from = type; + /* Record in stopped_from which timeout occurred. */ + tmr->stopped_from = type; /* mark as being serviced now */ if (SCTP_OS_TIMER_PENDING(&tmr->timer)) { /* * Callout has been rescheduled. */ - goto get_out; + goto out; } if (!SCTP_OS_TIMER_ACTIVE(&tmr->timer)) { /* * Not active, so no action. */ - goto get_out; + goto out; } SCTP_OS_TIMER_DEACTIVATE(&tmr->timer); @@ -1776,13 +1894,10 @@ sctp_timeout_handler(void *t) #endif /* call the handler for the appropriate timer type */ switch (type) { - case SCTP_TIMER_TYPE_ADDR_WQ: - sctp_handle_addr_wq(); - break; case SCTP_TIMER_TYPE_SEND: - if ((stcb == NULL) || (inp == NULL)) { - break; - } + KASSERT(inp != NULL && stcb != NULL && net != NULL, + ("timeout of type %d: inp = %p, stcb = %p, net = %p", + type, inp, stcb, net)); SCTP_STAT_INCR(sctps_timodata); stcb->asoc.timodata++; stcb->asoc.num_send_timers_up--; @@ -1800,65 +1915,72 @@ sctp_timeout_handler(void *t) sctp_auditing(4, inp, stcb, net); #endif sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_T3, SCTP_SO_NOT_LOCKED); + did_output = true; if ((stcb->asoc.num_send_timers_up == 0) && (stcb->asoc.sent_queue_cnt > 0)) { struct sctp_tmit_chunk *chk; /* - * safeguard. If there on some on the sent queue + * Safeguard. If there on some on the sent queue * somewhere but no timers running something is * wrong... so we start a timer on the first chunk * on the send queue on whatever net it is sent to. */ - chk = TAILQ_FIRST(&stcb->asoc.sent_queue); - sctp_timer_start(SCTP_TIMER_TYPE_SEND, inp, stcb, - chk->whoTo); + TAILQ_FOREACH(chk, &stcb->asoc.sent_queue, sctp_next) { + if (chk->whoTo != NULL) { + break; + } + } + if (chk != NULL) { + sctp_timer_start(SCTP_TIMER_TYPE_SEND, stcb->sctp_ep, stcb, chk->whoTo); + } } break; case SCTP_TIMER_TYPE_INIT: - if ((stcb == NULL) || (inp == NULL)) { - break; - } + KASSERT(inp != NULL && stcb != NULL && net != NULL, + ("timeout of type %d: inp = %p, stcb = %p, net = %p", + type, inp, stcb, net)); SCTP_STAT_INCR(sctps_timoinit); stcb->asoc.timoinit++; if (sctp_t1init_timer(inp, stcb, net)) { /* no need to unlock on tcb its gone */ goto out_decr; } - /* We do output but not here */ - did_output = 0; + did_output = false; break; case SCTP_TIMER_TYPE_RECV: - if ((stcb == NULL) || (inp == NULL)) { - break; - } + KASSERT(inp != NULL && stcb != NULL && net == NULL, + ("timeout of type %d: inp = %p, stcb = %p, net = %p", + type, inp, stcb, net)); SCTP_STAT_INCR(sctps_timosack); stcb->asoc.timosack++; sctp_send_sack(stcb, SCTP_SO_NOT_LOCKED); #ifdef SCTP_AUDITING_ENABLED - sctp_auditing(4, inp, stcb, net); + sctp_auditing(4, inp, stcb, NULL); #endif sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_SACK_TMR, SCTP_SO_NOT_LOCKED); + did_output = true; break; case SCTP_TIMER_TYPE_SHUTDOWN: - if ((stcb == NULL) || (inp == NULL)) { - break; - } + KASSERT(inp != NULL && stcb != NULL && net != NULL, + ("timeout of type %d: inp = %p, stcb = %p, net = %p", + type, inp, stcb, net)); + SCTP_STAT_INCR(sctps_timoshutdown); + stcb->asoc.timoshutdown++; if (sctp_shutdown_timer(inp, stcb, net)) { /* no need to unlock on tcb its gone */ goto out_decr; } - SCTP_STAT_INCR(sctps_timoshutdown); - stcb->asoc.timoshutdown++; #ifdef SCTP_AUDITING_ENABLED sctp_auditing(4, inp, stcb, net); #endif sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_SHUT_TMR, SCTP_SO_NOT_LOCKED); + did_output = true; break; case SCTP_TIMER_TYPE_HEARTBEAT: - if ((stcb == NULL) || (inp == NULL) || (net == NULL)) { - break; - } + KASSERT(inp != NULL && stcb != NULL && net != NULL, + ("timeout of type %d: inp = %p, stcb = %p, net = %p", + type, inp, stcb, net)); SCTP_STAT_INCR(sctps_timoheartbeat); stcb->asoc.timoheartbeat++; if (sctp_heartbeat_timer(inp, stcb, net)) { @@ -1871,19 +1993,21 @@ sctp_timeout_handler(void *t) if (!(net->dest_state & SCTP_ADDR_NOHB)) { sctp_timer_start(SCTP_TIMER_TYPE_HEARTBEAT, inp, stcb, net); sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_HB_TMR, SCTP_SO_NOT_LOCKED); + did_output = true; + } else { + did_output = false; } break; case SCTP_TIMER_TYPE_COOKIE: - if ((stcb == NULL) || (inp == NULL)) { - break; - } - + KASSERT(inp != NULL && stcb != NULL && net != NULL, + ("timeout of type %d: inp = %p, stcb = %p, net = %p", + type, inp, stcb, net)); + SCTP_STAT_INCR(sctps_timocookie); + stcb->asoc.timocookie++; if (sctp_cookie_timer(inp, stcb, net)) { /* no need to unlock on tcb its gone */ goto out_decr; } - SCTP_STAT_INCR(sctps_timocookie); - stcb->asoc.timocookie++; #ifdef SCTP_AUDITING_ENABLED sctp_auditing(4, inp, stcb, net); #endif @@ -1892,45 +2016,42 @@ sctp_timeout_handler(void *t) * respect to where from in chunk_output. */ sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_T3, SCTP_SO_NOT_LOCKED); + did_output = true; break; case SCTP_TIMER_TYPE_NEWCOOKIE: - { - struct timeval tv; - int i, secret; - if (inp == NULL) { - break; - } - SCTP_STAT_INCR(sctps_timosecret); - (void)SCTP_GETTIME_TIMEVAL(&tv); - inp->sctp_ep.time_of_secret_change = tv.tv_sec; - inp->sctp_ep.last_secret_number = - inp->sctp_ep.current_secret_number; - inp->sctp_ep.current_secret_number++; - if (inp->sctp_ep.current_secret_number >= - SCTP_HOW_MANY_SECRETS) { - inp->sctp_ep.current_secret_number = 0; - } - secret = (int)inp->sctp_ep.current_secret_number; - for (i = 0; i < SCTP_NUMBER_OF_SECRETS; i++) { - inp->sctp_ep.secret_key[secret][i] = - sctp_select_initial_TSN(&inp->sctp_ep); - } - sctp_timer_start(SCTP_TIMER_TYPE_NEWCOOKIE, inp, stcb, net); + KASSERT(inp != NULL && stcb == NULL && net == NULL, + ("timeout of type %d: inp = %p, stcb = %p, net = %p", + type, inp, stcb, net)); + SCTP_STAT_INCR(sctps_timosecret); + (void)SCTP_GETTIME_TIMEVAL(&tv); + inp->sctp_ep.time_of_secret_change = (unsigned int)tv.tv_sec; + inp->sctp_ep.last_secret_number = + inp->sctp_ep.current_secret_number; + inp->sctp_ep.current_secret_number++; + if (inp->sctp_ep.current_secret_number >= + SCTP_HOW_MANY_SECRETS) { + inp->sctp_ep.current_secret_number = 0; } - did_output = 0; + secret = (int)inp->sctp_ep.current_secret_number; + for (i = 0; i < SCTP_NUMBER_OF_SECRETS; i++) { + inp->sctp_ep.secret_key[secret][i] = + sctp_select_initial_TSN(&inp->sctp_ep); + } + sctp_timer_start(SCTP_TIMER_TYPE_NEWCOOKIE, inp, NULL, NULL); + did_output = false; break; case SCTP_TIMER_TYPE_PATHMTURAISE: - if ((stcb == NULL) || (inp == NULL)) { - break; - } + KASSERT(inp != NULL && stcb != NULL && net != NULL, + ("timeout of type %d: inp = %p, stcb = %p, net = %p", + type, inp, stcb, net)); SCTP_STAT_INCR(sctps_timopathmtu); sctp_pathmtu_timer(inp, stcb, net); - did_output = 0; + did_output = false; break; case SCTP_TIMER_TYPE_SHUTDOWNACK: - if ((stcb == NULL) || (inp == NULL)) { - break; - } + KASSERT(inp != NULL && stcb != NULL && net != NULL, + ("timeout of type %d: inp = %p, stcb = %p, net = %p", + type, inp, stcb, net)); if (sctp_shutdownack_timer(inp, stcb, net)) { /* no need to unlock on tcb its gone */ goto out_decr; @@ -1941,70 +2062,86 @@ sctp_timeout_handler(void *t) sctp_auditing(4, inp, stcb, net); #endif sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_SHUT_ACK_TMR, SCTP_SO_NOT_LOCKED); - break; - case SCTP_TIMER_TYPE_SHUTDOWNGUARD: - if ((stcb == NULL) || (inp == NULL)) { - break; - } - SCTP_STAT_INCR(sctps_timoshutdownguard); - op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code), - "Shutdown guard timer expired"); - sctp_abort_an_association(inp, stcb, op_err, SCTP_SO_NOT_LOCKED); - /* no need to unlock on tcb its gone */ - goto out_decr; - - case SCTP_TIMER_TYPE_STRRESET: - if ((stcb == NULL) || (inp == NULL)) { - break; - } - if (sctp_strreset_timer(inp, stcb, net)) { - /* no need to unlock on tcb its gone */ - goto out_decr; - } - SCTP_STAT_INCR(sctps_timostrmrst); - sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_STRRST_TMR, SCTP_SO_NOT_LOCKED); + did_output = true; break; case SCTP_TIMER_TYPE_ASCONF: - if ((stcb == NULL) || (inp == NULL)) { - break; - } + KASSERT(inp != NULL && stcb != NULL && net != NULL, + ("timeout of type %d: inp = %p, stcb = %p, net = %p", + type, inp, stcb, net)); + SCTP_STAT_INCR(sctps_timoasconf); if (sctp_asconf_timer(inp, stcb, net)) { /* no need to unlock on tcb its gone */ goto out_decr; } - SCTP_STAT_INCR(sctps_timoasconf); #ifdef SCTP_AUDITING_ENABLED sctp_auditing(4, inp, stcb, net); #endif sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_ASCONF_TMR, SCTP_SO_NOT_LOCKED); + did_output = true; break; - case SCTP_TIMER_TYPE_PRIM_DELETED: - if ((stcb == NULL) || (inp == NULL)) { - break; - } - sctp_delete_prim_timer(inp, stcb, net); - SCTP_STAT_INCR(sctps_timodelprim); - break; - + case SCTP_TIMER_TYPE_SHUTDOWNGUARD: + KASSERT(inp != NULL && stcb != NULL && net == NULL, + ("timeout of type %d: inp = %p, stcb = %p, net = %p", + type, inp, stcb, net)); + SCTP_STAT_INCR(sctps_timoshutdownguard); + op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code), + "Shutdown guard timer expired"); + sctp_abort_an_association(inp, stcb, op_err, true, SCTP_SO_NOT_LOCKED); + /* no need to unlock on tcb its gone */ + goto out_decr; case SCTP_TIMER_TYPE_AUTOCLOSE: - if ((stcb == NULL) || (inp == NULL)) { - break; - } + KASSERT(inp != NULL && stcb != NULL && net == NULL, + ("timeout of type %d: inp = %p, stcb = %p, net = %p", + type, inp, stcb, net)); SCTP_STAT_INCR(sctps_timoautoclose); - sctp_autoclose_timer(inp, stcb, net); + sctp_autoclose_timer(inp, stcb); sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_AUTOCLOSE_TMR, SCTP_SO_NOT_LOCKED); - did_output = 0; + did_output = true; break; - case SCTP_TIMER_TYPE_ASOCKILL: - if ((stcb == NULL) || (inp == NULL)) { - break; + case SCTP_TIMER_TYPE_STRRESET: + KASSERT(inp != NULL && stcb != NULL && net == NULL, + ("timeout of type %d: inp = %p, stcb = %p, net = %p", + type, inp, stcb, net)); + SCTP_STAT_INCR(sctps_timostrmrst); + if (sctp_strreset_timer(inp, stcb)) { + /* no need to unlock on tcb its gone */ + goto out_decr; } + sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_STRRST_TMR, SCTP_SO_NOT_LOCKED); + did_output = true; + break; + case SCTP_TIMER_TYPE_INPKILL: + KASSERT(inp != NULL && stcb == NULL && net == NULL, + ("timeout of type %d: inp = %p, stcb = %p, net = %p", + type, inp, stcb, net)); + SCTP_STAT_INCR(sctps_timoinpkill); + /* + * special case, take away our increment since WE are the + * killer + */ + sctp_timer_stop(SCTP_TIMER_TYPE_INPKILL, inp, NULL, NULL, + SCTP_FROM_SCTPUTIL + SCTP_LOC_3); +#if defined(__APPLE__) && !defined(__Userspace__) + SCTP_SOCKET_LOCK(SCTP_INP_SO(inp), 1); +#endif + SCTP_INP_DECR_REF(inp); + SCTP_INP_WUNLOCK(inp); + sctp_inpcb_free(inp, SCTP_FREE_SHOULD_USE_ABORT, + SCTP_CALLED_FROM_INPKILL_TIMER); +#if defined(__APPLE__) && !defined(__Userspace__) + SCTP_SOCKET_UNLOCK(SCTP_INP_SO(inp), 1); +#endif + inp = NULL; + goto out_decr; + case SCTP_TIMER_TYPE_ASOCKILL: + KASSERT(inp != NULL && stcb != NULL && net == NULL, + ("timeout of type %d: inp = %p, stcb = %p, net = %p", + type, inp, stcb, net)); SCTP_STAT_INCR(sctps_timoassockill); /* Can we free it yet? */ - SCTP_INP_DECR_REF(inp); sctp_timer_stop(SCTP_TIMER_TYPE_ASOCKILL, inp, stcb, NULL, SCTP_FROM_SCTPUTIL + SCTP_LOC_1); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) so = SCTP_INP_SO(inp); atomic_add_int(&stcb->asoc.refcnt, 1); SCTP_TCB_UNLOCK(stcb); @@ -2014,7 +2151,7 @@ sctp_timeout_handler(void *t) #endif (void)sctp_free_assoc(inp, stcb, SCTP_NORMAL_PROC, SCTP_FROM_SCTPUTIL + SCTP_LOC_2); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_UNLOCK(so, 1); #endif /* @@ -2022,40 +2159,35 @@ sctp_timeout_handler(void *t) * duplicate unlock or unlock of a free mtx :-0 */ stcb = NULL; - goto out_no_decr; - case SCTP_TIMER_TYPE_INPKILL: - SCTP_STAT_INCR(sctps_timoinpkill); - if (inp == NULL) { - break; - } - /* - * special case, take away our increment since WE are the - * killer - */ - SCTP_INP_DECR_REF(inp); - sctp_timer_stop(SCTP_TIMER_TYPE_INPKILL, inp, NULL, NULL, - SCTP_FROM_SCTPUTIL + SCTP_LOC_3); -#if defined(__APPLE__) - SCTP_SOCKET_LOCK(SCTP_INP_SO(inp), 1); -#endif - sctp_inpcb_free(inp, SCTP_FREE_SHOULD_USE_ABORT, - SCTP_CALLED_FROM_INPKILL_TIMER); -#if defined(__APPLE__) - SCTP_SOCKET_UNLOCK(SCTP_INP_SO(inp), 1); -#endif - inp = NULL; - goto out_no_decr; - default: - SCTPDBG(SCTP_DEBUG_TIMER1, "sctp_timeout_handler:unknown timer %d\n", - type); + goto out_decr; + case SCTP_TIMER_TYPE_ADDR_WQ: + KASSERT(inp == NULL && stcb == NULL && net == NULL, + ("timeout of type %d: inp = %p, stcb = %p, net = %p", + type, inp, stcb, net)); + sctp_handle_addr_wq(); + did_output = true; break; + case SCTP_TIMER_TYPE_PRIM_DELETED: + KASSERT(inp != NULL && stcb != NULL && net == NULL, + ("timeout of type %d: inp = %p, stcb = %p, net = %p", + type, inp, stcb, net)); + SCTP_STAT_INCR(sctps_timodelprim); + sctp_delete_prim_timer(inp, stcb); + did_output = false; + break; + default: +#ifdef INVARIANTS + panic("Unknown timer type %d", type); +#else + goto out; +#endif } #ifdef SCTP_AUDITING_ENABLED sctp_audit_log(0xF1, (uint8_t) type); - if (inp) + if (inp != NULL) sctp_auditing(5, inp, stcb, net); #endif - if ((did_output) && stcb) { + if (did_output && (stcb != NULL)) { /* * Now we need to clean up the control chunk chain if an * ECNE is on it. It must be marked as UNSENT again so next @@ -2065,8 +2197,8 @@ sctp_timeout_handler(void *t) */ sctp_fix_ecn_echo(&stcb->asoc); } -get_out: - if (stcb) { +out: + if (stcb != NULL) { SCTP_TCB_UNLOCK(stcb); } else if (inp != NULL) { SCTP_INP_WUNLOCK(inp); @@ -2086,162 +2218,359 @@ out_decr: sorele(upcall_socket); } #endif - if (inp) { + /* These reference counts were incremented in sctp_timer_start(). */ + if (inp != NULL) { SCTP_INP_DECR_REF(inp); } - -out_no_decr: - SCTPDBG(SCTP_DEBUG_TIMER1, "Timer now complete (type = %d)\n", type); -#if defined(__FreeBSD__) && __FreeBSD_version >= 801000 + if ((stcb != NULL) && !released_asoc_reference) { + atomic_subtract_int(&stcb->asoc.refcnt, 1); + } + if (net != NULL) { + sctp_free_remote_addr(net); + } + SCTPDBG(SCTP_DEBUG_TIMER2, "Timer type %d handler finished.\n", type); +#if defined(__FreeBSD__) && !defined(__Userspace__) CURVNET_RESTORE(); + NET_EPOCH_EXIT(et); #endif } +/*- + * The following table shows which parameters must be provided + * when calling sctp_timer_start(). For parameters not being + * provided, NULL must be used. + * + * |Name |inp |stcb|net | + * |-----------------------------|----|----|----| + * |SCTP_TIMER_TYPE_SEND |Yes |Yes |Yes | + * |SCTP_TIMER_TYPE_INIT |Yes |Yes |Yes | + * |SCTP_TIMER_TYPE_RECV |Yes |Yes |No | + * |SCTP_TIMER_TYPE_SHUTDOWN |Yes |Yes |Yes | + * |SCTP_TIMER_TYPE_HEARTBEAT |Yes |Yes |Yes | + * |SCTP_TIMER_TYPE_COOKIE |Yes |Yes |Yes | + * |SCTP_TIMER_TYPE_NEWCOOKIE |Yes |No |No | + * |SCTP_TIMER_TYPE_PATHMTURAISE |Yes |Yes |Yes | + * |SCTP_TIMER_TYPE_SHUTDOWNACK |Yes |Yes |Yes | + * |SCTP_TIMER_TYPE_ASCONF |Yes |Yes |Yes | + * |SCTP_TIMER_TYPE_SHUTDOWNGUARD|Yes |Yes |No | + * |SCTP_TIMER_TYPE_AUTOCLOSE |Yes |Yes |No | + * |SCTP_TIMER_TYPE_STRRESET |Yes |Yes |Yes | + * |SCTP_TIMER_TYPE_INPKILL |Yes |No |No | + * |SCTP_TIMER_TYPE_ASOCKILL |Yes |Yes |No | + * |SCTP_TIMER_TYPE_ADDR_WQ |No |No |No | + * |SCTP_TIMER_TYPE_PRIM_DELETED |Yes |Yes |No | + * + */ + void sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb, struct sctp_nets *net) { - uint32_t to_ticks; struct sctp_timer *tmr; + uint32_t to_ticks; + uint32_t rndval, jitter; - if ((t_type != SCTP_TIMER_TYPE_ADDR_WQ) && (inp == NULL)) - return; - + KASSERT(stcb == NULL || stcb->sctp_ep == inp, + ("sctp_timer_start of type %d: inp = %p, stcb->sctp_ep %p", + t_type, stcb, stcb->sctp_ep)); tmr = NULL; - if (stcb) { + if (stcb != NULL) { SCTP_TCB_LOCK_ASSERT(stcb); + } else if (inp != NULL) { + SCTP_INP_WLOCK_ASSERT(inp); + } else { + SCTP_WQ_ADDR_LOCK_ASSERT(); + } + if (stcb != NULL) { + /* Don't restart timer on association that's about to be killed. */ + if ((stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) && + (t_type != SCTP_TIMER_TYPE_ASOCKILL)) { + SCTPDBG(SCTP_DEBUG_TIMER2, + "Timer type %d not started: inp=%p, stcb=%p, net=%p (stcb deleted).\n", + t_type, inp, stcb, net); + return; + } + /* Don't restart timer on net that's been removed. */ + if (net != NULL && (net->dest_state & SCTP_ADDR_BEING_DELETED)) { + SCTPDBG(SCTP_DEBUG_TIMER2, + "Timer type %d not started: inp=%p, stcb=%p, net=%p (net deleted).\n", + t_type, inp, stcb, net); + return; + } } switch (t_type) { - case SCTP_TIMER_TYPE_ADDR_WQ: - /* Only 1 tick away :-) */ - tmr = &SCTP_BASE_INFO(addr_wq_timer); - to_ticks = SCTP_ADDRESS_TICK_DELAY; - break; case SCTP_TIMER_TYPE_SEND: - /* Here we use the RTO timer */ - { - int rto_val; - - if ((stcb == NULL) || (net == NULL)) { - return; - } - tmr = &net->rxt_timer; - if (net->RTO == 0) { - rto_val = stcb->asoc.initial_rto; - } else { - rto_val = net->RTO; - } - to_ticks = MSEC_TO_TICKS(rto_val); + /* Here we use the RTO timer. */ + if ((inp == NULL) || (stcb == NULL) || (net == NULL)) { +#ifdef INVARIANTS + panic("sctp_timer_start of type %d: inp = %p, stcb = %p, net = %p", + t_type, inp, stcb, net); +#else + return; +#endif + } + tmr = &net->rxt_timer; + if (net->RTO == 0) { + to_ticks = sctp_msecs_to_ticks(stcb->asoc.initial_rto); + } else { + to_ticks = sctp_msecs_to_ticks(net->RTO); } break; case SCTP_TIMER_TYPE_INIT: /* * Here we use the INIT timer default usually about 1 - * minute. + * second. */ - if ((stcb == NULL) || (net == NULL)) { + if ((inp == NULL) || (stcb == NULL) || (net == NULL)) { +#ifdef INVARIANTS + panic("sctp_timer_start of type %d: inp = %p, stcb = %p, net = %p", + t_type, inp, stcb, net); +#else return; +#endif } tmr = &net->rxt_timer; if (net->RTO == 0) { - to_ticks = MSEC_TO_TICKS(stcb->asoc.initial_rto); + to_ticks = sctp_msecs_to_ticks(stcb->asoc.initial_rto); } else { - to_ticks = MSEC_TO_TICKS(net->RTO); + to_ticks = sctp_msecs_to_ticks(net->RTO); } break; case SCTP_TIMER_TYPE_RECV: /* - * Here we use the Delayed-Ack timer value from the inp + * Here we use the Delayed-Ack timer value from the inp, * ususually about 200ms. */ - if (stcb == NULL) { + if ((inp == NULL) || (stcb == NULL) || (net != NULL)) { +#ifdef INVARIANTS + panic("sctp_timer_start of type %d: inp = %p, stcb = %p, net = %p", + t_type, inp, stcb, net); +#else return; +#endif } tmr = &stcb->asoc.dack_timer; - to_ticks = MSEC_TO_TICKS(stcb->asoc.delayed_ack); + to_ticks = sctp_msecs_to_ticks(stcb->asoc.delayed_ack); break; case SCTP_TIMER_TYPE_SHUTDOWN: /* Here we use the RTO of the destination. */ - if ((stcb == NULL) || (net == NULL)) { + if ((inp == NULL) || (stcb == NULL) || (net == NULL)) { +#ifdef INVARIANTS + panic("sctp_timer_start of type %d: inp = %p, stcb = %p, net = %p", + t_type, inp, stcb, net); +#else return; - } - if (net->RTO == 0) { - to_ticks = MSEC_TO_TICKS(stcb->asoc.initial_rto); - } else { - to_ticks = MSEC_TO_TICKS(net->RTO); +#endif } tmr = &net->rxt_timer; + if (net->RTO == 0) { + to_ticks = sctp_msecs_to_ticks(stcb->asoc.initial_rto); + } else { + to_ticks = sctp_msecs_to_ticks(net->RTO); + } break; case SCTP_TIMER_TYPE_HEARTBEAT: /* - * the net is used here so that we can add in the RTO. Even + * The net is used here so that we can add in the RTO. Even * though we use a different timer. We also add the HB timer * PLUS a random jitter. */ - if ((stcb == NULL) || (net == NULL)) { + if ((inp == NULL) || (stcb == NULL) || (net == NULL)) { +#ifdef INVARIANTS + panic("sctp_timer_start of type %d: inp = %p, stcb = %p, net = %p", + t_type, inp, stcb, net); +#else return; - } else { - uint32_t rndval; - uint32_t jitter; - - if ((net->dest_state & SCTP_ADDR_NOHB) && - !(net->dest_state & SCTP_ADDR_UNCONFIRMED)) { - return; - } - if (net->RTO == 0) { - to_ticks = stcb->asoc.initial_rto; - } else { - to_ticks = net->RTO; - } - rndval = sctp_select_initial_TSN(&inp->sctp_ep); - jitter = rndval % to_ticks; - if (jitter >= (to_ticks >> 1)) { - to_ticks = to_ticks + (jitter - (to_ticks >> 1)); - } else { - to_ticks = to_ticks - jitter; - } - if (!(net->dest_state & SCTP_ADDR_UNCONFIRMED) && - !(net->dest_state & SCTP_ADDR_PF)) { - to_ticks += net->heart_beat_delay; - } - /* - * Now we must convert the to_ticks that are now in - * ms to ticks. - */ - to_ticks = MSEC_TO_TICKS(to_ticks); - tmr = &net->hb_timer; +#endif } + if ((net->dest_state & SCTP_ADDR_NOHB) && + !(net->dest_state & SCTP_ADDR_UNCONFIRMED)) { + SCTPDBG(SCTP_DEBUG_TIMER2, + "Timer type %d not started: inp=%p, stcb=%p, net=%p.\n", + t_type, inp, stcb, net); + return; + } + tmr = &net->hb_timer; + if (net->RTO == 0) { + to_ticks = stcb->asoc.initial_rto; + } else { + to_ticks = net->RTO; + } + rndval = sctp_select_initial_TSN(&inp->sctp_ep); + jitter = rndval % to_ticks; + if (to_ticks > 1) { + to_ticks >>= 1; + } + if (jitter < (UINT32_MAX - to_ticks)) { + to_ticks += jitter; + } else { + to_ticks = UINT32_MAX; + } + if (!(net->dest_state & SCTP_ADDR_UNCONFIRMED) && + !(net->dest_state & SCTP_ADDR_PF)) { + if (net->heart_beat_delay < (UINT32_MAX - to_ticks)) { + to_ticks += net->heart_beat_delay; + } else { + to_ticks = UINT32_MAX; + } + } + /* + * Now we must convert the to_ticks that are now in + * ms to ticks. + */ + to_ticks = sctp_msecs_to_ticks(to_ticks); break; case SCTP_TIMER_TYPE_COOKIE: /* * Here we can use the RTO timer from the network since one - * RTT was compelete. If a retran happened then we will be - * using the RTO initial value. + * RTT was complete. If a retransmission happened then we will + * be using the RTO initial value. */ - if ((stcb == NULL) || (net == NULL)) { + if ((inp == NULL) || (stcb == NULL) || (net == NULL)) { +#ifdef INVARIANTS + panic("sctp_timer_start of type %d: inp = %p, stcb = %p, net = %p", + t_type, inp, stcb, net); +#else return; - } - if (net->RTO == 0) { - to_ticks = MSEC_TO_TICKS(stcb->asoc.initial_rto); - } else { - to_ticks = MSEC_TO_TICKS(net->RTO); +#endif } tmr = &net->rxt_timer; + if (net->RTO == 0) { + to_ticks = sctp_msecs_to_ticks(stcb->asoc.initial_rto); + } else { + to_ticks = sctp_msecs_to_ticks(net->RTO); + } break; case SCTP_TIMER_TYPE_NEWCOOKIE: /* - * nothing needed but the endpoint here ususually about 60 + * Nothing needed but the endpoint here ususually about 60 * minutes. */ + if ((inp == NULL) || (stcb != NULL) || (net != NULL)) { +#ifdef INVARIANTS + panic("sctp_timer_start of type %d: inp = %p, stcb = %p, net = %p", + t_type, inp, stcb, net); +#else + return; +#endif + } tmr = &inp->sctp_ep.signature_change; to_ticks = inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_SIGNATURE]; break; - case SCTP_TIMER_TYPE_ASOCKILL: - if (stcb == NULL) { + case SCTP_TIMER_TYPE_PATHMTURAISE: + /* + * Here we use the value found in the EP for PMTUD, ususually + * about 10 minutes. + */ + if ((inp == NULL) || (stcb == NULL) || (net == NULL)) { +#ifdef INVARIANTS + panic("sctp_timer_start of type %d: inp = %p, stcb = %p, net = %p", + t_type, inp, stcb, net); +#else + return; +#endif + } + if (net->dest_state & SCTP_ADDR_NO_PMTUD) { + SCTPDBG(SCTP_DEBUG_TIMER2, + "Timer type %d not started: inp=%p, stcb=%p, net=%p.\n", + t_type, inp, stcb, net); return; } + tmr = &net->pmtu_timer; + to_ticks = inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_PMTU]; + break; + case SCTP_TIMER_TYPE_SHUTDOWNACK: + /* Here we use the RTO of the destination. */ + if ((inp == NULL) || (stcb == NULL) || (net == NULL)) { +#ifdef INVARIANTS + panic("sctp_timer_start of type %d: inp = %p, stcb = %p, net = %p", + t_type, inp, stcb, net); +#else + return; +#endif + } + tmr = &net->rxt_timer; + if (net->RTO == 0) { + to_ticks = sctp_msecs_to_ticks(stcb->asoc.initial_rto); + } else { + to_ticks = sctp_msecs_to_ticks(net->RTO); + } + break; + case SCTP_TIMER_TYPE_ASCONF: + /* + * Here the timer comes from the stcb but its value is from + * the net's RTO. + */ + if ((inp == NULL) || (stcb == NULL) || (net == NULL)) { +#ifdef INVARIANTS + panic("sctp_timer_start of type %d: inp = %p, stcb = %p, net = %p", + t_type, inp, stcb, net); +#else + return; +#endif + } + tmr = &stcb->asoc.asconf_timer; + if (net->RTO == 0) { + to_ticks = sctp_msecs_to_ticks(stcb->asoc.initial_rto); + } else { + to_ticks = sctp_msecs_to_ticks(net->RTO); + } + break; + case SCTP_TIMER_TYPE_SHUTDOWNGUARD: + /* + * Here we use the endpoints shutdown guard timer usually + * about 3 minutes. + */ + if ((inp == NULL) || (stcb == NULL) || (net != NULL)) { +#ifdef INVARIANTS + panic("sctp_timer_start of type %d: inp = %p, stcb = %p, net = %p", + t_type, inp, stcb, net); +#else + return; +#endif + } + tmr = &stcb->asoc.shut_guard_timer; + if (inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_MAXSHUTDOWN] == 0) { + if (stcb->asoc.maxrto < UINT32_MAX / 5) { + to_ticks = sctp_msecs_to_ticks(5 * stcb->asoc.maxrto); + } else { + to_ticks = sctp_msecs_to_ticks(UINT32_MAX); + } + } else { + to_ticks = inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_MAXSHUTDOWN]; + } + break; + case SCTP_TIMER_TYPE_AUTOCLOSE: + if ((inp == NULL) || (stcb == NULL) || (net != NULL)) { +#ifdef INVARIANTS + panic("sctp_timer_start of type %d: inp = %p, stcb = %p, net = %p", + t_type, inp, stcb, net); +#else + return; +#endif + } + tmr = &stcb->asoc.autoclose_timer; + to_ticks = stcb->asoc.sctp_autoclose_ticks; + break; + case SCTP_TIMER_TYPE_STRRESET: + /* + * Here the timer comes from the stcb but its value is from + * the net's RTO. + */ + if ((inp == NULL) || (stcb == NULL) || (net == NULL)) { +#ifdef INVARIANTS + panic("sctp_timer_start of type %d: inp = %p, stcb = %p, net = %p", + t_type, inp, stcb, net); +#else + return; +#endif + } tmr = &stcb->asoc.strreset_timer; - to_ticks = MSEC_TO_TICKS(SCTP_ASOC_KILL_TIMEOUT); + if (net->RTO == 0) { + to_ticks = sctp_msecs_to_ticks(stcb->asoc.initial_rto); + } else { + to_ticks = sctp_msecs_to_ticks(net->RTO); + } break; case SCTP_TIMER_TYPE_INPKILL: /* @@ -2249,120 +2578,74 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb, * timer since that has stopped and we are in the GONE * state. */ + if ((inp == NULL) || (stcb != NULL) || (net != NULL)) { +#ifdef INVARIANTS + panic("sctp_timer_start of type %d: inp = %p, stcb = %p, net = %p", + t_type, inp, stcb, net); +#else + return; +#endif + } tmr = &inp->sctp_ep.signature_change; - to_ticks = MSEC_TO_TICKS(SCTP_INP_KILL_TIMEOUT); + to_ticks = sctp_msecs_to_ticks(SCTP_INP_KILL_TIMEOUT); break; - case SCTP_TIMER_TYPE_PATHMTURAISE: - /* - * Here we use the value found in the EP for PMTU ususually - * about 10 minutes. - */ - if ((stcb == NULL) || (net == NULL)) { + case SCTP_TIMER_TYPE_ASOCKILL: + if ((inp == NULL) || (stcb == NULL) || (net != NULL)) { +#ifdef INVARIANTS + panic("sctp_timer_start of type %d: inp = %p, stcb = %p, net = %p", + t_type, inp, stcb, net); +#else return; - } - if (net->dest_state & SCTP_ADDR_NO_PMTUD) { - return; - } - to_ticks = inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_PMTU]; - tmr = &net->pmtu_timer; - break; - case SCTP_TIMER_TYPE_SHUTDOWNACK: - /* Here we use the RTO of the destination */ - if ((stcb == NULL) || (net == NULL)) { - return; - } - if (net->RTO == 0) { - to_ticks = MSEC_TO_TICKS(stcb->asoc.initial_rto); - } else { - to_ticks = MSEC_TO_TICKS(net->RTO); - } - tmr = &net->rxt_timer; - break; - case SCTP_TIMER_TYPE_SHUTDOWNGUARD: - /* - * Here we use the endpoints shutdown guard timer usually - * about 3 minutes. - */ - if (stcb == NULL) { - return; - } - if (inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_MAXSHUTDOWN] == 0) { - to_ticks = 5 * MSEC_TO_TICKS(stcb->asoc.maxrto); - } else { - to_ticks = inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_MAXSHUTDOWN]; - } - tmr = &stcb->asoc.shut_guard_timer; - break; - case SCTP_TIMER_TYPE_STRRESET: - /* - * Here the timer comes from the stcb but its value is from - * the net's RTO. - */ - if ((stcb == NULL) || (net == NULL)) { - return; - } - if (net->RTO == 0) { - to_ticks = MSEC_TO_TICKS(stcb->asoc.initial_rto); - } else { - to_ticks = MSEC_TO_TICKS(net->RTO); +#endif } tmr = &stcb->asoc.strreset_timer; + to_ticks = sctp_msecs_to_ticks(SCTP_ASOC_KILL_TIMEOUT); break; - case SCTP_TIMER_TYPE_ASCONF: - /* - * Here the timer comes from the stcb but its value is from - * the net's RTO. - */ - if ((stcb == NULL) || (net == NULL)) { + case SCTP_TIMER_TYPE_ADDR_WQ: + if ((inp != NULL) || (stcb != NULL) || (net != NULL)) { +#ifdef INVARIANTS + panic("sctp_timer_start of type %d: inp = %p, stcb = %p, net = %p", + t_type, inp, stcb, net); +#else return; +#endif } - if (net->RTO == 0) { - to_ticks = MSEC_TO_TICKS(stcb->asoc.initial_rto); - } else { - to_ticks = MSEC_TO_TICKS(net->RTO); - } - tmr = &stcb->asoc.asconf_timer; + /* Only 1 tick away :-) */ + tmr = &SCTP_BASE_INFO(addr_wq_timer); + to_ticks = SCTP_ADDRESS_TICK_DELAY; break; case SCTP_TIMER_TYPE_PRIM_DELETED: - if ((stcb == NULL) || (net != NULL)) { + if ((inp == NULL) || (stcb == NULL) || (net != NULL)) { +#ifdef INVARIANTS + panic("sctp_timer_start of type %d: inp = %p, stcb = %p, net = %p", + t_type, inp, stcb, net); +#else return; +#endif } - to_ticks = MSEC_TO_TICKS(stcb->asoc.initial_rto); tmr = &stcb->asoc.delete_prim_timer; - break; - case SCTP_TIMER_TYPE_AUTOCLOSE: - if (stcb == NULL) { - return; - } - if (stcb->asoc.sctp_autoclose_ticks == 0) { - /* - * Really an error since stcb is NOT set to - * autoclose - */ - return; - } - to_ticks = stcb->asoc.sctp_autoclose_ticks; - tmr = &stcb->asoc.autoclose_timer; + to_ticks = sctp_msecs_to_ticks(stcb->asoc.initial_rto); break; default: - SCTPDBG(SCTP_DEBUG_TIMER1, "%s: Unknown timer type %d\n", - __func__, t_type); - return; - break; - } - if ((to_ticks <= 0) || (tmr == NULL)) { - SCTPDBG(SCTP_DEBUG_TIMER1, "%s: %d:software error to_ticks:%d tmr:%p not set ??\n", - __func__, t_type, to_ticks, (void *)tmr); +#ifdef INVARIANTS + panic("Unknown timer type %d", t_type); +#else return; +#endif } + KASSERT(tmr != NULL, ("tmr is NULL for timer type %d", t_type)); + KASSERT(to_ticks > 0, ("to_ticks == 0 for timer type %d", t_type)); if (SCTP_OS_TIMER_PENDING(&tmr->timer)) { /* - * we do NOT allow you to have it already running. if it is - * we leave the current one up unchanged + * We do NOT allow you to have it already running. If it is, + * we leave the current one up unchanged. */ + SCTPDBG(SCTP_DEBUG_TIMER2, + "Timer type %d already running: inp=%p, stcb=%p, net=%p.\n", + t_type, inp, stcb, net); return; } - /* At this point we can proceed */ + /* At this point we can proceed. */ if (t_type == SCTP_TIMER_TYPE_SEND) { stcb->asoc.num_send_timers_up++; } @@ -2370,155 +2653,301 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb, tmr->type = t_type; tmr->ep = (void *)inp; tmr->tcb = (void *)stcb; - tmr->net = (void *)net; + if (t_type == SCTP_TIMER_TYPE_STRRESET) { + tmr->net = NULL; + } else { + tmr->net = (void *)net; + } tmr->self = (void *)tmr; -#if defined(__FreeBSD__) && __FreeBSD_version >= 800000 +#if defined(__FreeBSD__) && !defined(__Userspace__) tmr->vnet = (void *)curvnet; #endif -#ifndef __Panda__ tmr->ticks = sctp_get_tick_count(); -#endif - (void)SCTP_OS_TIMER_START(&tmr->timer, to_ticks, sctp_timeout_handler, tmr); + if (SCTP_OS_TIMER_START(&tmr->timer, to_ticks, sctp_timeout_handler, tmr) == 0) { + SCTPDBG(SCTP_DEBUG_TIMER2, + "Timer type %d started: ticks=%u, inp=%p, stcb=%p, net=%p.\n", + t_type, to_ticks, inp, stcb, net); + /* + * If this is a newly scheduled callout, as opposed to a + * rescheduled one, increment relevant reference counts. + */ + if (tmr->ep != NULL) { + SCTP_INP_INCR_REF(inp); + } + if (tmr->tcb != NULL) { + atomic_add_int(&stcb->asoc.refcnt, 1); + } + if (tmr->net != NULL) { + atomic_add_int(&net->ref_count, 1); + } + } else { + /* + * This should not happen, since we checked for pending + * above. + */ + SCTPDBG(SCTP_DEBUG_TIMER2, + "Timer type %d restarted: ticks=%u, inp=%p, stcb=%p, net=%p.\n", + t_type, to_ticks, inp, stcb, net); + } return; } +/*- + * The following table shows which parameters must be provided + * when calling sctp_timer_stop(). For parameters not being + * provided, NULL must be used. + * + * |Name |inp |stcb|net | + * |-----------------------------|----|----|----| + * |SCTP_TIMER_TYPE_SEND |Yes |Yes |Yes | + * |SCTP_TIMER_TYPE_INIT |Yes |Yes |Yes | + * |SCTP_TIMER_TYPE_RECV |Yes |Yes |No | + * |SCTP_TIMER_TYPE_SHUTDOWN |Yes |Yes |Yes | + * |SCTP_TIMER_TYPE_HEARTBEAT |Yes |Yes |Yes | + * |SCTP_TIMER_TYPE_COOKIE |Yes |Yes |Yes | + * |SCTP_TIMER_TYPE_NEWCOOKIE |Yes |No |No | + * |SCTP_TIMER_TYPE_PATHMTURAISE |Yes |Yes |Yes | + * |SCTP_TIMER_TYPE_SHUTDOWNACK |Yes |Yes |Yes | + * |SCTP_TIMER_TYPE_ASCONF |Yes |Yes |No | + * |SCTP_TIMER_TYPE_SHUTDOWNGUARD|Yes |Yes |No | + * |SCTP_TIMER_TYPE_AUTOCLOSE |Yes |Yes |No | + * |SCTP_TIMER_TYPE_STRRESET |Yes |Yes |No | + * |SCTP_TIMER_TYPE_INPKILL |Yes |No |No | + * |SCTP_TIMER_TYPE_ASOCKILL |Yes |Yes |No | + * |SCTP_TIMER_TYPE_ADDR_WQ |No |No |No | + * |SCTP_TIMER_TYPE_PRIM_DELETED |Yes |Yes |No | + * + */ + void sctp_timer_stop(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb, struct sctp_nets *net, uint32_t from) { struct sctp_timer *tmr; - if ((t_type != SCTP_TIMER_TYPE_ADDR_WQ) && - (inp == NULL)) - return; - - tmr = NULL; - if (stcb) { + KASSERT(stcb == NULL || stcb->sctp_ep == inp, + ("sctp_timer_stop of type %d: inp = %p, stcb->sctp_ep %p", + t_type, stcb, stcb->sctp_ep)); + if (stcb != NULL) { SCTP_TCB_LOCK_ASSERT(stcb); + } else if (inp != NULL) { + SCTP_INP_WLOCK_ASSERT(inp); + } else { + SCTP_WQ_ADDR_LOCK_ASSERT(); } + tmr = NULL; switch (t_type) { - case SCTP_TIMER_TYPE_ADDR_WQ: - tmr = &SCTP_BASE_INFO(addr_wq_timer); - break; case SCTP_TIMER_TYPE_SEND: - if ((stcb == NULL) || (net == NULL)) { + if ((inp == NULL) || (stcb == NULL) || (net == NULL)) { +#ifdef INVARIANTS + panic("sctp_timer_stop of type %d: inp = %p, stcb = %p, net = %p", + t_type, inp, stcb, net); +#else return; +#endif } tmr = &net->rxt_timer; break; case SCTP_TIMER_TYPE_INIT: - if ((stcb == NULL) || (net == NULL)) { + if ((inp == NULL) || (stcb == NULL) || (net == NULL)) { +#ifdef INVARIANTS + panic("sctp_timer_stop of type %d: inp = %p, stcb = %p, net = %p", + t_type, inp, stcb, net); +#else return; +#endif } tmr = &net->rxt_timer; break; case SCTP_TIMER_TYPE_RECV: - if (stcb == NULL) { + if ((inp == NULL) || (stcb == NULL) || (net != NULL)) { +#ifdef INVARIANTS + panic("sctp_timer_stop of type %d: inp = %p, stcb = %p, net = %p", + t_type, inp, stcb, net); +#else return; +#endif } tmr = &stcb->asoc.dack_timer; break; case SCTP_TIMER_TYPE_SHUTDOWN: - if ((stcb == NULL) || (net == NULL)) { + if ((inp == NULL) || (stcb == NULL) || (net == NULL)) { +#ifdef INVARIANTS + panic("sctp_timer_stop of type %d: inp = %p, stcb = %p, net = %p", + t_type, inp, stcb, net); +#else return; +#endif } tmr = &net->rxt_timer; break; case SCTP_TIMER_TYPE_HEARTBEAT: - if ((stcb == NULL) || (net == NULL)) { + if ((inp == NULL) || (stcb == NULL) || (net == NULL)) { +#ifdef INVARIANTS + panic("sctp_timer_stop of type %d: inp = %p, stcb = %p, net = %p", + t_type, inp, stcb, net); +#else return; +#endif } tmr = &net->hb_timer; break; case SCTP_TIMER_TYPE_COOKIE: - if ((stcb == NULL) || (net == NULL)) { + if ((inp == NULL) || (stcb == NULL) || (net == NULL)) { +#ifdef INVARIANTS + panic("sctp_timer_stop of type %d: inp = %p, stcb = %p, net = %p", + t_type, inp, stcb, net); +#else return; +#endif } tmr = &net->rxt_timer; break; case SCTP_TIMER_TYPE_NEWCOOKIE: - /* nothing needed but the endpoint here */ - tmr = &inp->sctp_ep.signature_change; - /* - * We re-use the newcookie timer for the INP kill timer. We - * must assure that we do not kill it by accident. - */ - break; - case SCTP_TIMER_TYPE_ASOCKILL: - /* - * Stop the asoc kill timer. - */ - if (stcb == NULL) { + if ((inp == NULL) || (stcb != NULL) || (net != NULL)) { +#ifdef INVARIANTS + panic("sctp_timer_stop of type %d: inp = %p, stcb = %p, net = %p", + t_type, inp, stcb, net); +#else return; +#endif + } + tmr = &inp->sctp_ep.signature_change; + break; + case SCTP_TIMER_TYPE_PATHMTURAISE: + if ((inp == NULL) || (stcb == NULL) || (net == NULL)) { +#ifdef INVARIANTS + panic("sctp_timer_stop of type %d: inp = %p, stcb = %p, net = %p", + t_type, inp, stcb, net); +#else + return; +#endif + } + tmr = &net->pmtu_timer; + break; + case SCTP_TIMER_TYPE_SHUTDOWNACK: + if ((inp == NULL) || (stcb == NULL) || (net == NULL)) { +#ifdef INVARIANTS + panic("sctp_timer_stop of type %d: inp = %p, stcb = %p, net = %p", + t_type, inp, stcb, net); +#else + return; +#endif + } + tmr = &net->rxt_timer; + break; + case SCTP_TIMER_TYPE_ASCONF: + if ((inp == NULL) || (stcb == NULL) || (net != NULL)) { +#ifdef INVARIANTS + panic("sctp_timer_stop of type %d: inp = %p, stcb = %p, net = %p", + t_type, inp, stcb, net); +#else + return; +#endif + } + tmr = &stcb->asoc.asconf_timer; + break; + case SCTP_TIMER_TYPE_SHUTDOWNGUARD: + if ((inp == NULL) || (stcb == NULL) || (net != NULL)) { +#ifdef INVARIANTS + panic("sctp_timer_stop of type %d: inp = %p, stcb = %p, net = %p", + t_type, inp, stcb, net); +#else + return; +#endif + } + tmr = &stcb->asoc.shut_guard_timer; + break; + case SCTP_TIMER_TYPE_AUTOCLOSE: + if ((inp == NULL) || (stcb == NULL) || (net != NULL)) { +#ifdef INVARIANTS + panic("sctp_timer_stop of type %d: inp = %p, stcb = %p, net = %p", + t_type, inp, stcb, net); +#else + return; +#endif + } + tmr = &stcb->asoc.autoclose_timer; + break; + case SCTP_TIMER_TYPE_STRRESET: + if ((inp == NULL) || (stcb == NULL) || (net != NULL)) { +#ifdef INVARIANTS + panic("sctp_timer_stop of type %d: inp = %p, stcb = %p, net = %p", + t_type, inp, stcb, net); +#else + return; +#endif } tmr = &stcb->asoc.strreset_timer; break; - case SCTP_TIMER_TYPE_INPKILL: /* * The inp is setup to die. We re-use the signature_chage * timer since that has stopped and we are in the GONE * state. */ + if ((inp == NULL) || (stcb != NULL) || (net != NULL)) { +#ifdef INVARIANTS + panic("sctp_timer_stop of type %d: inp = %p, stcb = %p, net = %p", + t_type, inp, stcb, net); +#else + return; +#endif + } tmr = &inp->sctp_ep.signature_change; break; - case SCTP_TIMER_TYPE_PATHMTURAISE: - if ((stcb == NULL) || (net == NULL)) { - return; - } - tmr = &net->pmtu_timer; - break; - case SCTP_TIMER_TYPE_SHUTDOWNACK: - if ((stcb == NULL) || (net == NULL)) { - return; - } - tmr = &net->rxt_timer; - break; - case SCTP_TIMER_TYPE_SHUTDOWNGUARD: - if (stcb == NULL) { - return; - } - tmr = &stcb->asoc.shut_guard_timer; - break; - case SCTP_TIMER_TYPE_STRRESET: - if (stcb == NULL) { + case SCTP_TIMER_TYPE_ASOCKILL: + if ((inp == NULL) || (stcb == NULL) || (net != NULL)) { +#ifdef INVARIANTS + panic("sctp_timer_stop of type %d: inp = %p, stcb = %p, net = %p", + t_type, inp, stcb, net); +#else return; +#endif } tmr = &stcb->asoc.strreset_timer; break; - case SCTP_TIMER_TYPE_ASCONF: - if (stcb == NULL) { + case SCTP_TIMER_TYPE_ADDR_WQ: + if ((inp != NULL) || (stcb != NULL) || (net != NULL)) { +#ifdef INVARIANTS + panic("sctp_timer_stop of type %d: inp = %p, stcb = %p, net = %p", + t_type, inp, stcb, net); +#else return; +#endif } - tmr = &stcb->asoc.asconf_timer; + tmr = &SCTP_BASE_INFO(addr_wq_timer); break; case SCTP_TIMER_TYPE_PRIM_DELETED: - if (stcb == NULL) { + if ((inp == NULL) || (stcb == NULL) || (net != NULL)) { +#ifdef INVARIANTS + panic("sctp_timer_stop of type %d: inp = %p, stcb = %p, net = %p", + t_type, inp, stcb, net); +#else return; +#endif } tmr = &stcb->asoc.delete_prim_timer; break; - case SCTP_TIMER_TYPE_AUTOCLOSE: - if (stcb == NULL) { - return; - } - tmr = &stcb->asoc.autoclose_timer; - break; default: - SCTPDBG(SCTP_DEBUG_TIMER1, "%s: Unknown timer type %d\n", - __func__, t_type); - break; - } - if (tmr == NULL) { +#ifdef INVARIANTS + panic("Unknown timer type %d", t_type); +#else return; +#endif } - if ((tmr->type != t_type) && tmr->type) { + KASSERT(tmr != NULL, ("tmr is NULL for timer type %d", t_type)); + if ((tmr->type != SCTP_TIMER_TYPE_NONE) && + (tmr->type != t_type)) { /* * Ok we have a timer that is under joint use. Cookie timer * per chance with the SEND timer. We therefore are NOT * running the timer that the caller wants stopped. So just * return. */ + SCTPDBG(SCTP_DEBUG_TIMER2, + "Shared timer type %d not running: inp=%p, stcb=%p, net=%p.\n", + t_type, inp, stcb, net); return; } if ((t_type == SCTP_TIMER_TYPE_SEND) && (stcb != NULL)) { @@ -2529,56 +2958,61 @@ sctp_timer_stop(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb, } tmr->self = NULL; tmr->stopped_from = from; - (void)SCTP_OS_TIMER_STOP(&tmr->timer); + if (SCTP_OS_TIMER_STOP(&tmr->timer) == 1) { + KASSERT(tmr->ep == inp, + ("sctp_timer_stop of type %d: inp = %p, tmr->inp = %p", + t_type, inp, tmr->ep)); + KASSERT(tmr->tcb == stcb, + ("sctp_timer_stop of type %d: stcb = %p, tmr->stcb = %p", + t_type, stcb, tmr->tcb)); + KASSERT(((t_type == SCTP_TIMER_TYPE_ASCONF) && (tmr->net != NULL)) || + ((t_type != SCTP_TIMER_TYPE_ASCONF) && (tmr->net == net)), + ("sctp_timer_stop of type %d: net = %p, tmr->net = %p", + t_type, net, tmr->net)); + SCTPDBG(SCTP_DEBUG_TIMER2, + "Timer type %d stopped: inp=%p, stcb=%p, net=%p.\n", + t_type, inp, stcb, net); + /* + * If the timer was actually stopped, decrement reference counts + * that were incremented in sctp_timer_start(). + */ + if (tmr->ep != NULL) { + SCTP_INP_DECR_REF(inp); + tmr->ep = NULL; + } + if (tmr->tcb != NULL) { + atomic_subtract_int(&stcb->asoc.refcnt, 1); + tmr->tcb = NULL; + } + if (tmr->net != NULL) { + /* + * Can't use net, since it doesn't work for + * SCTP_TIMER_TYPE_ASCONF. + */ + sctp_free_remote_addr((struct sctp_nets *)tmr->net); + tmr->net = NULL; + } + } else { + SCTPDBG(SCTP_DEBUG_TIMER2, + "Timer type %d not stopped: inp=%p, stcb=%p, net=%p.\n", + t_type, inp, stcb, net); + } return; } uint32_t sctp_calculate_len(struct mbuf *m) { - uint32_t tlen = 0; struct mbuf *at; + uint32_t tlen; - at = m; - while (at) { + tlen = 0; + for (at = m; at != NULL; at = SCTP_BUF_NEXT(at)) { tlen += SCTP_BUF_LEN(at); - at = SCTP_BUF_NEXT(at); } return (tlen); } -void -sctp_mtu_size_reset(struct sctp_inpcb *inp, - struct sctp_association *asoc, uint32_t mtu) -{ - /* - * Reset the P-MTU size on this association, this involves changing - * the asoc MTU, going through ANY chunk+overhead larger than mtu to - * allow the DF flag to be cleared. - */ - struct sctp_tmit_chunk *chk; - unsigned int eff_mtu, ovh; - - asoc->smallest_mtu = mtu; - if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) { - ovh = SCTP_MIN_OVERHEAD; - } else { - ovh = SCTP_MIN_V4_OVERHEAD; - } - eff_mtu = mtu - ovh; - TAILQ_FOREACH(chk, &asoc->send_queue, sctp_next) { - if (chk->send_size > eff_mtu) { - chk->flags |= CHUNK_FLAGS_FRAGMENT_OK; - } - } - TAILQ_FOREACH(chk, &asoc->sent_queue, sctp_next) { - if (chk->send_size > eff_mtu) { - chk->flags |= CHUNK_FLAGS_FRAGMENT_OK; - } - } -} - - /* * Given an association and starting time of the current RTT period, update * RTO in number of msecs. net should point to the current network. @@ -2609,7 +3043,7 @@ sctp_calculate_rto(struct sctp_tcb *stcb, (void)SCTP_GETTIME_TIMEVAL(&now); } if ((old->tv_sec > now.tv_sec) || - ((old->tv_sec == now.tv_sec) && (old->tv_sec > now.tv_sec))) { + ((old->tv_sec == now.tv_sec) && (old->tv_usec > now.tv_usec))) { /* The starting point is in the future. */ return (0); } @@ -2740,8 +3174,6 @@ sctp_m_getptr(struct mbuf *m, int off, int len, uint8_t * in_ptr) } } - - struct sctp_paramhdr * sctp_get_next_param(struct mbuf *m, int offset, @@ -2753,7 +3185,6 @@ sctp_get_next_param(struct mbuf *m, (uint8_t *) pull)); } - struct mbuf * sctp_add_pad_tombuf(struct mbuf *m, int padlen) { @@ -2805,11 +3236,8 @@ sctp_pad_lastmbuf(struct mbuf *m, int padval, struct mbuf *last_mbuf) static void sctp_notify_assoc_change(uint16_t state, struct sctp_tcb *stcb, - uint16_t error, struct sctp_abort_chunk *abort, uint8_t from_peer, int so_locked -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - SCTP_UNUSED -#endif - ) + uint16_t error, struct sctp_abort_chunk *abort, + bool from_peer, bool timedout, int so_locked) { struct mbuf *m_notify; struct sctp_assoc_change *sac; @@ -2817,10 +3245,14 @@ sctp_notify_assoc_change(uint16_t state, struct sctp_tcb *stcb, unsigned int notif_len; uint16_t abort_len; unsigned int i; -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) struct socket *so; #endif + KASSERT(abort == NULL || from_peer, + ("sctp_notify_assoc_change: ABORT chunk provided for local termination")); + KASSERT(!from_peer || !timedout, + ("sctp_notify_assoc_change: timeouts can only be local")); if (stcb == NULL) { return; } @@ -2860,9 +3292,13 @@ sctp_notify_assoc_change(uint16_t state, struct sctp_tcb *stcb, sac->sac_length = sizeof(struct sctp_assoc_change); sac->sac_state = state; sac->sac_error = error; - /* XXX verify these stream counts */ - sac->sac_outbound_streams = stcb->asoc.streamoutcnt; - sac->sac_inbound_streams = stcb->asoc.streamincnt; + if (state == SCTP_CANT_STR_ASSOC) { + sac->sac_outbound_streams = 0; + sac->sac_inbound_streams = 0; + } else { + sac->sac_outbound_streams = stcb->asoc.streamoutcnt; + sac->sac_inbound_streams = stcb->asoc.streamincnt; + } sac->sac_assoc_id = sctp_get_associd(stcb); if (notif_len > sizeof(struct sctp_assoc_change)) { if ((state == SCTP_COMM_UP) || (state == SCTP_RESTART)) { @@ -2924,8 +3360,7 @@ set_error: stcb->sctp_socket->so_error = ECONNRESET; } } else { - if ((SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_WAIT) || - (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_ECHOED)) { + if (timedout) { SCTP_LTRACE_ERR_RET(NULL, stcb, NULL, SCTP_FROM_SCTPUTIL, ETIMEDOUT); stcb->sctp_socket->so_error = ETIMEDOUT; } else { @@ -2936,7 +3371,7 @@ set_error: SOCK_UNLOCK(stcb->sctp_socket); } /* Wake ANY sleepers */ -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) so = SCTP_INP_SO(stcb->sctp_ep); if (!so_locked) { atomic_add_int(&stcb->asoc.refcnt, 1); @@ -2957,7 +3392,7 @@ set_error: } sorwakeup(stcb->sctp_socket); sowwakeup(stcb->sctp_socket); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) if (!so_locked) { SCTP_SOCKET_UNLOCK(so, 1); } @@ -2966,11 +3401,7 @@ set_error: static void sctp_notify_peer_addr_change(struct sctp_tcb *stcb, uint32_t state, - struct sockaddr *sa, uint32_t error, int so_locked -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - SCTP_UNUSED -#endif -) + struct sockaddr *sa, uint32_t error, int so_locked) { struct mbuf *m_notify; struct sctp_paddr_change *spc; @@ -3069,14 +3500,9 @@ sctp_notify_peer_addr_change(struct sctp_tcb *stcb, uint32_t state, so_locked); } - static void sctp_notify_send_failed(struct sctp_tcb *stcb, uint8_t sent, uint32_t error, - struct sctp_tmit_chunk *chk, int so_locked -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - SCTP_UNUSED -#endif - ) + struct sctp_tmit_chunk *chk, int so_locked) { struct mbuf *m_notify; struct sctp_send_failed *ssf; @@ -3205,14 +3631,9 @@ sctp_notify_send_failed(struct sctp_tcb *stcb, uint8_t sent, uint32_t error, so_locked); } - static void sctp_notify_send_failed2(struct sctp_tcb *stcb, uint32_t error, - struct sctp_stream_queue_pending *sp, int so_locked -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - SCTP_UNUSED -#endif - ) + struct sctp_stream_queue_pending *sp, int so_locked) { struct mbuf *m_notify; struct sctp_send_failed *ssf; @@ -3306,8 +3727,6 @@ sctp_notify_send_failed2(struct sctp_tcb *stcb, uint32_t error, &stcb->sctp_socket->so_rcv, 1, SCTP_READ_LOCK_NOT_HELD, so_locked); } - - static void sctp_notify_adaptation_layer(struct sctp_tcb *stcb) { @@ -3358,11 +3777,7 @@ sctp_notify_adaptation_layer(struct sctp_tcb *stcb) /* This always must be called with the read-queue LOCKED in the INP */ static void sctp_notify_partial_delivery_indication(struct sctp_tcb *stcb, uint32_t error, - uint32_t val, int so_locked -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - SCTP_UNUSED -#endif - ) + uint32_t val, int so_locked) { struct mbuf *m_notify; struct sctp_pdapi_event *pdapi; @@ -3424,7 +3839,7 @@ sctp_notify_partial_delivery_indication(struct sctp_tcb *stcb, uint32_t error, } if (stcb->sctp_ep && stcb->sctp_socket) { /* This should always be the case */ -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) struct socket *so; so = SCTP_INP_SO(stcb->sctp_ep); @@ -3441,7 +3856,7 @@ sctp_notify_partial_delivery_indication(struct sctp_tcb *stcb, uint32_t error, } #endif sctp_sorwakeup(stcb->sctp_ep, stcb->sctp_socket); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) if (!so_locked) { SCTP_SOCKET_UNLOCK(so, 1); } @@ -3463,7 +3878,7 @@ sctp_notify_shutdown_event(struct sctp_tcb *stcb) if ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) { /* mark socket closed for read/write and wakeup! */ -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) struct socket *so; so = SCTP_INP_SO(stcb->sctp_ep); @@ -3478,7 +3893,7 @@ sctp_notify_shutdown_event(struct sctp_tcb *stcb) } #endif socantsendmore(stcb->sctp_socket); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_UNLOCK(so, 1); #endif } @@ -3521,11 +3936,7 @@ sctp_notify_shutdown_event(struct sctp_tcb *stcb) static void sctp_notify_sender_dry_event(struct sctp_tcb *stcb, - int so_locked -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - SCTP_UNUSED -#endif - ) + int so_locked) { struct mbuf *m_notify; struct sctp_sender_dry_event *event; @@ -3570,7 +3981,6 @@ sctp_notify_sender_dry_event(struct sctp_tcb *stcb, &stcb->sctp_socket->so_rcv, 1, SCTP_READ_LOCK_NOT_HELD, so_locked); } - void sctp_notify_stream_reset_add(struct sctp_tcb *stcb, uint16_t numberin, uint16_t numberout, int flag) { @@ -3677,8 +4087,6 @@ sctp_notify_stream_reset_tsn(struct sctp_tcb *stcb, uint32_t sending_tsn, uint32 &stcb->sctp_socket->so_rcv, 1, SCTP_READ_LOCK_NOT_HELD, SCTP_SO_NOT_LOCKED); } - - static void sctp_notify_stream_reset(struct sctp_tcb *stcb, int number_entries, uint16_t * list, int flag) @@ -3743,7 +4151,6 @@ sctp_notify_stream_reset(struct sctp_tcb *stcb, &stcb->sctp_socket->so_rcv, 1, SCTP_READ_LOCK_NOT_HELD, SCTP_SO_NOT_LOCKED); } - static void sctp_notify_remote_error(struct sctp_tcb *stcb, uint16_t error, struct sctp_error_chunk *chunk) { @@ -3803,20 +4210,15 @@ sctp_notify_remote_error(struct sctp_tcb *stcb, uint16_t error, struct sctp_erro sctp_add_to_readq(stcb->sctp_ep, stcb, control, &stcb->sctp_socket->so_rcv, 1, - SCTP_READ_LOCK_NOT_HELD, SCTP_SO_NOT_LOCKED); + SCTP_READ_LOCK_NOT_HELD, SCTP_SO_NOT_LOCKED); } else { sctp_m_freem(m_notify); } } - void sctp_ulp_notify(uint32_t notification, struct sctp_tcb *stcb, - uint32_t error, void *data, int so_locked -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - SCTP_UNUSED -#endif - ) + uint32_t error, void *data, int so_locked) { if ((stcb == NULL) || (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) || @@ -3825,14 +4227,14 @@ sctp_ulp_notify(uint32_t notification, struct sctp_tcb *stcb, /* If the socket is gone we are out of here */ return; } -#if (defined(__FreeBSD__) && __FreeBSD_version > 500000) || defined(__Windows__) +#if (defined(__FreeBSD__) || defined(_WIN32)) && !defined(__Userspace__) if (stcb->sctp_socket->so_rcv.sb_state & SBS_CANTRCVMORE) { #else if (stcb->sctp_socket->so_state & SS_CANTRCVMORE) { #endif return; } -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) if (so_locked) { sctp_lock_assert(SCTP_INP_SO(stcb->sctp_ep)); } else { @@ -3851,7 +4253,7 @@ sctp_ulp_notify(uint32_t notification, struct sctp_tcb *stcb, switch (notification) { case SCTP_NOTIFY_ASSOC_UP: if (stcb->asoc.assoc_up_sent == 0) { - sctp_notify_assoc_change(SCTP_COMM_UP, stcb, error, NULL, 0, so_locked); + sctp_notify_assoc_change(SCTP_COMM_UP, stcb, error, NULL, false, false, so_locked); stcb->asoc.assoc_up_sent = 1; } if (stcb->asoc.adaptation_needed && (stcb->asoc.adaptation_sent == 0)) { @@ -3863,7 +4265,7 @@ sctp_ulp_notify(uint32_t notification, struct sctp_tcb *stcb, } break; case SCTP_NOTIFY_ASSOC_DOWN: - sctp_notify_assoc_change(SCTP_SHUTDOWN_COMP, stcb, error, NULL, 0, so_locked); + sctp_notify_assoc_change(SCTP_SHUTDOWN_COMP, stcb, error, NULL, false, false, so_locked); #if defined(__Userspace__) if (stcb->sctp_ep->recv_callback) { if (stcb->sctp_socket) { @@ -3931,21 +4333,29 @@ sctp_ulp_notify(uint32_t notification, struct sctp_tcb *stcb, case SCTP_NOTIFY_ASSOC_LOC_ABORTED: if ((SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_WAIT) || (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_ECHOED)) { - sctp_notify_assoc_change(SCTP_CANT_STR_ASSOC, stcb, error, data, 0, so_locked); + sctp_notify_assoc_change(SCTP_CANT_STR_ASSOC, stcb, error, data, false, false, so_locked); } else { - sctp_notify_assoc_change(SCTP_COMM_LOST, stcb, error, data, 0, so_locked); + sctp_notify_assoc_change(SCTP_COMM_LOST, stcb, error, data, false, false, so_locked); } break; case SCTP_NOTIFY_ASSOC_REM_ABORTED: if ((SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_WAIT) || (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_ECHOED)) { - sctp_notify_assoc_change(SCTP_CANT_STR_ASSOC, stcb, error, data, 1, so_locked); + sctp_notify_assoc_change(SCTP_CANT_STR_ASSOC, stcb, error, data, true, false, so_locked); } else { - sctp_notify_assoc_change(SCTP_COMM_LOST, stcb, error, data, 1, so_locked); + sctp_notify_assoc_change(SCTP_COMM_LOST, stcb, error, data, true, false, so_locked); + } + break; + case SCTP_NOTIFY_ASSOC_TIMEDOUT: + if ((SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_WAIT) || + (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_ECHOED)) { + sctp_notify_assoc_change(SCTP_CANT_STR_ASSOC, stcb, error, data, false, true, so_locked); + } else { + sctp_notify_assoc_change(SCTP_COMM_LOST, stcb, error, data, false, true, so_locked); } break; case SCTP_NOTIFY_ASSOC_RESTART: - sctp_notify_assoc_change(SCTP_RESTART, stcb, error, NULL, 0, so_locked); + sctp_notify_assoc_change(SCTP_RESTART, stcb, error, NULL, false, false, so_locked); if (stcb->asoc.auth_supported == 0) { sctp_ulp_notify(SCTP_NOTIFY_NO_PEER_AUTH, stcb, 0, NULL, so_locked); @@ -4017,11 +4427,7 @@ sctp_ulp_notify(uint32_t notification, struct sctp_tcb *stcb, } void -sctp_report_all_outbound(struct sctp_tcb *stcb, uint16_t error, int holds_lock, int so_locked -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - SCTP_UNUSED -#endif - ) +sctp_report_all_outbound(struct sctp_tcb *stcb, uint16_t error, int so_locked) { struct sctp_association *asoc; struct sctp_stream_out *outs; @@ -4037,7 +4443,7 @@ sctp_report_all_outbound(struct sctp_tcb *stcb, uint16_t error, int holds_lock, /* already being freed */ return; } -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) if (so_locked) { sctp_lock_assert(SCTP_INP_SO(stcb->sctp_ep)); } else { @@ -4050,9 +4456,6 @@ sctp_report_all_outbound(struct sctp_tcb *stcb, uint16_t error, int holds_lock, return; } /* now through all the gunk freeing chunks */ - if (holds_lock == 0) { - SCTP_TCB_SEND_LOCK(stcb); - } /* sent queue SHOULD be empty */ TAILQ_FOREACH_SAFE(chk, &asoc->sent_queue, sctp_next, nchk) { TAILQ_REMOVE(&asoc->sent_queue, chk, sctp_next); @@ -4108,7 +4511,7 @@ sctp_report_all_outbound(struct sctp_tcb *stcb, uint16_t error, int holds_lock, TAILQ_FOREACH_SAFE(sp, &outs->outqueue, next, nsp) { atomic_subtract_int(&asoc->stream_queue_cnt, 1); TAILQ_REMOVE(&outs->outqueue, sp, next); - stcb->asoc.ss_functions.sctp_ss_remove_from_stream(stcb, asoc, outs, sp, 1); + stcb->asoc.ss_functions.sctp_ss_remove_from_stream(stcb, asoc, outs, sp); sctp_free_spbufspace(stcb, asoc, sp); if (sp->data) { sctp_ulp_notify(SCTP_NOTIFY_SPECIAL_SP_FAIL, stcb, @@ -4129,24 +4532,17 @@ sctp_report_all_outbound(struct sctp_tcb *stcb, uint16_t error, int holds_lock, /*sa_ignore FREED_MEMORY*/ } } - - if (holds_lock == 0) { - SCTP_TCB_SEND_UNLOCK(stcb); - } } void -sctp_abort_notification(struct sctp_tcb *stcb, uint8_t from_peer, uint16_t error, - struct sctp_abort_chunk *abort, int so_locked -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - SCTP_UNUSED -#endif - ) +sctp_abort_notification(struct sctp_tcb *stcb, bool from_peer, bool timeout, + uint16_t error, struct sctp_abort_chunk *abort, + int so_locked) { if (stcb == NULL) { return; } -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) if (so_locked) { sctp_lock_assert(SCTP_INP_SO(stcb->sctp_ep)); } else { @@ -4163,12 +4559,19 @@ sctp_abort_notification(struct sctp_tcb *stcb, uint8_t from_peer, uint16_t error (stcb->asoc.state & SCTP_STATE_CLOSED_SOCKET)) { return; } + SCTP_TCB_SEND_LOCK(stcb); + SCTP_ADD_SUBSTATE(stcb, SCTP_STATE_WAS_ABORTED); /* Tell them we lost the asoc */ - sctp_report_all_outbound(stcb, error, 0, so_locked); + sctp_report_all_outbound(stcb, error, so_locked); + SCTP_TCB_SEND_UNLOCK(stcb); if (from_peer) { sctp_ulp_notify(SCTP_NOTIFY_ASSOC_REM_ABORTED, stcb, error, abort, so_locked); } else { - sctp_ulp_notify(SCTP_NOTIFY_ASSOC_LOC_ABORTED, stcb, error, abort, so_locked); + if (timeout) { + sctp_ulp_notify(SCTP_NOTIFY_ASSOC_TIMEDOUT, stcb, error, abort, so_locked); + } else { + sctp_ulp_notify(SCTP_NOTIFY_ASSOC_LOC_ABORTED, stcb, error, abort, so_locked); + } } } @@ -4177,32 +4580,41 @@ sctp_abort_association(struct sctp_inpcb *inp, struct sctp_tcb *stcb, struct mbuf *m, int iphlen, struct sockaddr *src, struct sockaddr *dst, struct sctphdr *sh, struct mbuf *op_err, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) uint8_t mflowtype, uint32_t mflowid, #endif uint32_t vrf_id, uint16_t port) { - uint32_t vtag; -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) struct socket *so; #endif + struct sctp_gen_error_cause* cause; + uint32_t vtag; + uint16_t cause_code; - vtag = 0; if (stcb != NULL) { vtag = stcb->asoc.peer_vtag; vrf_id = stcb->asoc.vrf_id; + if (op_err != NULL) { + /* Read the cause code from the error cause. */ + cause = mtod(op_err, struct sctp_gen_error_cause *); + cause_code = ntohs(cause->code); + } else { + cause_code = 0; + } + } else { + vtag = 0; } sctp_send_abort(m, iphlen, src, dst, sh, vtag, op_err, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) mflowtype, mflowid, inp->fibnum, #endif vrf_id, port); if (stcb != NULL) { /* We have a TCB to abort, send notification too */ - sctp_abort_notification(stcb, 0, 0, NULL, SCTP_SO_NOT_LOCKED); - SCTP_ADD_SUBSTATE(stcb, SCTP_STATE_WAS_ABORTED); + sctp_abort_notification(stcb, false, false, cause_code, NULL, SCTP_SO_NOT_LOCKED); /* Ok, now lets free it */ -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) so = SCTP_INP_SO(inp); atomic_add_int(&stcb->asoc.refcnt, 1); SCTP_TCB_UNLOCK(stcb); @@ -4217,7 +4629,7 @@ sctp_abort_association(struct sctp_inpcb *inp, struct sctp_tcb *stcb, } (void)sctp_free_assoc(inp, stcb, SCTP_NORMAL_PROC, SCTP_FROM_SCTPUTIL + SCTP_LOC_4); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_UNLOCK(so, 1); #endif } @@ -4286,21 +4698,18 @@ sctp_print_out_track_log(struct sctp_tcb *stcb) void sctp_abort_an_association(struct sctp_inpcb *inp, struct sctp_tcb *stcb, - struct mbuf *op_err, - int so_locked -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - SCTP_UNUSED -#endif -) + struct mbuf *op_err, bool timedout, int so_locked) { -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) struct socket *so; #endif + struct sctp_gen_error_cause* cause; + uint16_t cause_code; -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) so = SCTP_INP_SO(inp); #endif -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) if (so_locked) { sctp_lock_assert(SCTP_INP_SO(inp)); } else { @@ -4311,14 +4720,14 @@ sctp_abort_an_association(struct sctp_inpcb *inp, struct sctp_tcb *stcb, /* Got to have a TCB */ if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) { if (LIST_EMPTY(&inp->sctp_asoc_list)) { -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) if (!so_locked) { SCTP_SOCKET_LOCK(so, 1); } #endif sctp_inpcb_free(inp, SCTP_FREE_SHOULD_USE_ABORT, SCTP_CALLED_DIRECTLY_NOCMPSET); -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) if (!so_locked) { SCTP_SOCKET_UNLOCK(so, 1); } @@ -4326,8 +4735,13 @@ sctp_abort_an_association(struct sctp_inpcb *inp, struct sctp_tcb *stcb, } } return; + } + if (op_err != NULL) { + /* Read the cause code from the error cause. */ + cause = mtod(op_err, struct sctp_gen_error_cause *); + cause_code = ntohs(cause->code); } else { - SCTP_ADD_SUBSTATE(stcb, SCTP_STATE_WAS_ABORTED); + cause_code = 0; } /* notify the peer */ sctp_send_abort_tcb(stcb, op_err, so_locked); @@ -4338,13 +4752,13 @@ sctp_abort_an_association(struct sctp_inpcb *inp, struct sctp_tcb *stcb, } /* notify the ulp */ if ((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) == 0) { - sctp_abort_notification(stcb, 0, 0, NULL, so_locked); + sctp_abort_notification(stcb, false, timedout, cause_code, NULL, so_locked); } /* now free the asoc */ #ifdef SCTP_ASOCLOG_OF_TSNS sctp_print_out_track_log(stcb); #endif -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) if (!so_locked) { atomic_add_int(&stcb->asoc.refcnt, 1); SCTP_TCB_UNLOCK(stcb); @@ -4355,7 +4769,7 @@ sctp_abort_an_association(struct sctp_inpcb *inp, struct sctp_tcb *stcb, #endif (void)sctp_free_assoc(inp, stcb, SCTP_NORMAL_PROC, SCTP_FROM_SCTPUTIL + SCTP_LOC_5); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) if (!so_locked) { SCTP_SOCKET_UNLOCK(so, 1); } @@ -4367,7 +4781,7 @@ sctp_handle_ootb(struct mbuf *m, int iphlen, int offset, struct sockaddr *src, struct sockaddr *dst, struct sctphdr *sh, struct sctp_inpcb *inp, struct mbuf *cause, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) uint8_t mflowtype, uint32_t mflowid, uint16_t fibnum, #endif uint32_t vrf_id, uint16_t port) @@ -4380,12 +4794,12 @@ sctp_handle_ootb(struct mbuf *m, int iphlen, int offset, /* Generate a TO address for future reference */ if (inp && (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE)) { if (LIST_EMPTY(&inp->sctp_asoc_list)) { -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_LOCK(SCTP_INP_SO(inp), 1); #endif sctp_inpcb_free(inp, SCTP_FREE_SHOULD_USE_ABORT, SCTP_CALLED_DIRECTLY_NOCMPSET); -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_UNLOCK(SCTP_INP_SO(inp), 1); #endif } @@ -4417,7 +4831,7 @@ sctp_handle_ootb(struct mbuf *m, int iphlen, int offset, return; case SCTP_SHUTDOWN_ACK: sctp_send_shutdown_complete2(src, dst, sh, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) mflowtype, mflowid, fibnum, #endif vrf_id, port); @@ -4433,7 +4847,7 @@ sctp_handle_ootb(struct mbuf *m, int iphlen, int offset, ((SCTP_BASE_SYSCTL(sctp_blackhole) == 1) && (contains_init_chunk == 0))) { sctp_send_abort(m, iphlen, src, dst, sh, 0, cause, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) mflowtype, mflowid, fibnum, #endif vrf_id, port); @@ -4445,7 +4859,7 @@ sctp_handle_ootb(struct mbuf *m, int iphlen, int offset, * if there is return 1, else return 0. */ int -sctp_is_there_an_abort_here(struct mbuf *m, int iphlen, uint32_t * vtagfill) +sctp_is_there_an_abort_here(struct mbuf *m, int iphlen, uint32_t *vtag) { struct sctp_chunkhdr *ch; struct sctp_init_chunk *init_chk, chunk_buf; @@ -4466,12 +4880,13 @@ sctp_is_there_an_abort_here(struct mbuf *m, int iphlen, uint32_t * vtagfill) /* yep, tell them */ return (1); } - if (ch->chunk_type == SCTP_INITIATION) { + if ((ch->chunk_type == SCTP_INITIATION) || + (ch->chunk_type == SCTP_INITIATION_ACK)) { /* need to update the Vtag */ init_chk = (struct sctp_init_chunk *)sctp_m_getptr(m, - offset, sizeof(*init_chk), (uint8_t *) & chunk_buf); + offset, sizeof(struct sctp_init_chunk), (uint8_t *) & chunk_buf); if (init_chk != NULL) { - *vtagfill = ntohl(init_chk->init.initiate_tag); + *vtag = ntohl(init_chk->init.initiate_tag); } } /* Nope, move to the next chunk */ @@ -4620,7 +5035,7 @@ void sctp_print_address(struct sockaddr *sa) { #ifdef INET6 -#if defined(__FreeBSD__) && __FreeBSD_version >= 700000 +#if defined(__FreeBSD__) && !defined(__Userspace__) char ip6buf[INET6_ADDRSTRLEN]; #endif #endif @@ -4645,7 +5060,7 @@ sctp_print_address(struct sockaddr *sa) ntohs(sin6->sin6_port), sin6->sin6_scope_id); #else -#if defined(__FreeBSD__) && __FreeBSD_version >= 700000 +#if defined(__FreeBSD__) && !defined(__Userspace__) SCTP_PRINTF("IPv6 address: %s:port:%d scope:%u\n", ip6_sprintf(ip6buf, &sin6->sin6_addr), ntohs(sin6->sin6_port), @@ -4703,23 +5118,21 @@ sctp_pull_off_control_to_new_inp(struct sctp_inpcb *old_inp, struct sctp_queued_to_read *control, *nctl; struct sctp_readhead tmp_queue; struct mbuf *m; -#if defined(__FreeBSD__) || defined(__APPLE__) +#if (defined(__FreeBSD__) || defined(__APPLE__)) && !defined(__Userspace__) int error = 0; #endif old_so = old_inp->sctp_socket; new_so = new_inp->sctp_socket; TAILQ_INIT(&tmp_queue); -#if defined(__FreeBSD__) || defined(__APPLE__) -#if defined(__FreeBSD__) && __FreeBSD_version < 700000 - SOCKBUF_LOCK(&(old_so->so_rcv)); -#endif +#if (defined(__FreeBSD__) || defined(__APPLE__)) && !defined(__Userspace__) +#if defined(__FreeBSD__) + error = SOCK_IO_RECV_LOCK(old_so, waitflags); +#else error = sblock(&old_so->so_rcv, waitflags); -#if defined(__FreeBSD__) && __FreeBSD_version < 700000 - SOCKBUF_UNLOCK(&(old_so->so_rcv)); #endif if (error) { - /* Gak, can't get sblock, we have a problem. + /* Gak, can't get I/O lock, we have a problem. * data will be left stranded.. and we * don't dare look at it since the * other thread may be reading something. @@ -4754,19 +5167,12 @@ sctp_pull_off_control_to_new_inp(struct sctp_inpcb *old_inp, } } SCTP_INP_READ_UNLOCK(old_inp); - /* Remove the sb-lock on the old socket */ -#if defined(__FreeBSD__) && __FreeBSD_version < 700000 - SOCKBUF_LOCK(&(old_so->so_rcv)); -#endif -#if defined(__APPLE__) + /* Remove the recv-lock on the old socket */ +#if defined(__APPLE__) && !defined(__Userspace__) sbunlock(&old_so->so_rcv, 1); #endif - -#if defined(__FreeBSD__) - sbunlock(&old_so->so_rcv); -#endif -#if defined(__FreeBSD__) && __FreeBSD_version < 700000 - SOCKBUF_UNLOCK(&(old_so->so_rcv)); +#if defined(__FreeBSD__) && !defined(__Userspace__) + SOCK_IO_RECV_UNLOCK(old_so); #endif /* Now we move them over to the new socket buffer */ SCTP_INP_READ_LOCK(new_inp); @@ -4791,13 +5197,13 @@ void sctp_wakeup_the_read_socket(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int so_locked -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) +#if !(defined(__APPLE__) && !defined(__Userspace__)) SCTP_UNUSED #endif ) { if ((inp != NULL) && (inp->sctp_socket != NULL)) { -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) struct socket *so; so = SCTP_INP_SO(inp); @@ -4818,7 +5224,7 @@ sctp_wakeup_the_read_socket(struct sctp_inpcb *inp, } #endif sctp_sorwakeup(inp, inp->sctp_socket); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) if (!so_locked) { SCTP_SOCKET_UNLOCK(so, 1); } @@ -4932,11 +5338,7 @@ sctp_add_to_readq(struct sctp_inpcb *inp, struct sockbuf *sb, int end, int inp_read_lock_held, - int so_locked -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - SCTP_UNUSED -#endif - ) + int so_locked) { /* * Here we must place the control on the end of the socket read @@ -4952,7 +5354,7 @@ sctp_add_to_readq(struct sctp_inpcb *inp, #endif return; } -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) if (so_locked) { sctp_lock_assert(SCTP_INP_SO(inp)); } else { @@ -5119,7 +5521,6 @@ sctp_free_bufspace(struct sctp_tcb *stcb, struct sctp_association *asoc, stcb->sctp_socket->so_snd.sb_cc -= tp1->book_size; } else { stcb->sctp_socket->so_snd.sb_cc = 0; - } } } @@ -5128,11 +5529,7 @@ sctp_free_bufspace(struct sctp_tcb *stcb, struct sctp_association *asoc, int sctp_release_pr_sctp_chunk(struct sctp_tcb *stcb, struct sctp_tmit_chunk *tp1, - uint8_t sent, int so_locked -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - SCTP_UNUSED -#endif - ) + uint8_t sent, int so_locked) { struct sctp_stream_out *strq; struct sctp_tmit_chunk *chk = NULL, *tp2; @@ -5144,7 +5541,7 @@ sctp_release_pr_sctp_chunk(struct sctp_tcb *stcb, struct sctp_tmit_chunk *tp1, int notdone; int do_wakeup_routine = 0; -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) if (so_locked) { sctp_lock_assert(SCTP_INP_SO(stcb->sctp_ep)); } else { @@ -5301,7 +5698,7 @@ sctp_release_pr_sctp_chunk(struct sctp_tcb *stcb, struct sctp_tmit_chunk *tp1, chk->rec.data.context = sp->context; chk->flags = sp->act_flags; chk->whoTo = NULL; -#if defined(__FreeBSD__) || defined(__Panda__) +#if defined(__FreeBSD__) && !defined(__Userspace__) chk->rec.data.tsn = atomic_fetchadd_int(&stcb->asoc.sending_seq, 1); #else chk->rec.data.tsn = stcb->asoc.sending_seq++; @@ -5345,7 +5742,7 @@ sctp_release_pr_sctp_chunk(struct sctp_tcb *stcb, struct sctp_tmit_chunk *tp1, SCTP_TCB_SEND_UNLOCK(stcb); } if (do_wakeup_routine) { -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) struct socket *so; so = SCTP_INP_SO(stcb->sctp_ep); @@ -5363,7 +5760,7 @@ sctp_release_pr_sctp_chunk(struct sctp_tcb *stcb, struct sctp_tmit_chunk *tp1, } #endif sctp_sowwakeup(stcb->sctp_ep, stcb->sctp_socket); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) && !defined(__Userspace__) if (!so_locked) { SCTP_SOCKET_UNLOCK(so, 1); } @@ -5398,10 +5795,6 @@ sctp_find_ifa_in_ep(struct sctp_inpcb *inp, struct sockaddr *addr, if (((struct sockaddr_in *)addr)->sin_addr.s_addr == laddr->ifa->address.sin.sin_addr.s_addr) { /* found him. */ - if (holds_lock == 0) { - SCTP_INP_RUNLOCK(inp); - } - return (laddr->ifa); break; } } @@ -5411,10 +5804,6 @@ sctp_find_ifa_in_ep(struct sctp_inpcb *inp, struct sockaddr *addr, if (SCTP6_ARE_ADDR_EQUAL((struct sockaddr_in6 *)addr, &laddr->ifa->address.sin6)) { /* found him. */ - if (holds_lock == 0) { - SCTP_INP_RUNLOCK(inp); - } - return (laddr->ifa); break; } } @@ -5423,10 +5812,6 @@ sctp_find_ifa_in_ep(struct sctp_inpcb *inp, struct sockaddr *addr, if (addr->sa_family == AF_CONN) { if (((struct sockaddr_conn *)addr)->sconn_addr == laddr->ifa->address.sconn.sconn_addr) { /* found him. */ - if (holds_lock == 0) { - SCTP_INP_RUNLOCK(inp); - } - return (laddr->ifa); break; } } @@ -5435,7 +5820,11 @@ sctp_find_ifa_in_ep(struct sctp_inpcb *inp, struct sockaddr *addr, if (holds_lock == 0) { SCTP_INP_RUNLOCK(inp); } - return (NULL); + if (laddr != NULL) { + return (laddr->ifa); + } else { + return (NULL); + } } uint32_t @@ -5458,7 +5847,7 @@ sctp_get_ifa_hash_val(struct sockaddr *addr) uint32_t hash_of_addr; sin6 = (struct sockaddr_in6 *)addr; -#if !defined(__Windows__) && !defined(__Userspace_os_FreeBSD) && !defined(__Userspace_os_Darwin) && !defined(__Userspace_os_Windows) +#if !defined(_WIN32) && !(defined(__FreeBSD__) && defined(__Userspace__)) && !defined(__APPLE__) hash_of_addr = (sin6->sin6_addr.s6_addr32[0] + sin6->sin6_addr.s6_addr32[1] + sin6->sin6_addr.s6_addr32[2] + @@ -5498,8 +5887,11 @@ sctp_find_ifa_by_addr(struct sockaddr *addr, uint32_t vrf_id, int holds_lock) struct sctp_ifalist *hash_head; uint32_t hash_of_addr; - if (holds_lock == 0) + if (holds_lock == 0) { SCTP_IPI_ADDR_RLOCK(); + } else { + SCTP_IPI_ADDR_LOCK_ASSERT(); + } vrf = sctp_find_vrf(vrf_id); if (vrf == NULL) { @@ -5530,9 +5922,6 @@ sctp_find_ifa_by_addr(struct sockaddr *addr, uint32_t vrf_id, int holds_lock) if (((struct sockaddr_in *)addr)->sin_addr.s_addr == sctp_ifap->address.sin.sin_addr.s_addr) { /* found him. */ - if (holds_lock == 0) - SCTP_IPI_ADDR_RUNLOCK(); - return (sctp_ifap); break; } } @@ -5542,9 +5931,6 @@ sctp_find_ifa_by_addr(struct sockaddr *addr, uint32_t vrf_id, int holds_lock) if (SCTP6_ARE_ADDR_EQUAL((struct sockaddr_in6 *)addr, &sctp_ifap->address.sin6)) { /* found him. */ - if (holds_lock == 0) - SCTP_IPI_ADDR_RUNLOCK(); - return (sctp_ifap); break; } } @@ -5553,9 +5939,6 @@ sctp_find_ifa_by_addr(struct sockaddr *addr, uint32_t vrf_id, int holds_lock) if (addr->sa_family == AF_CONN) { if (((struct sockaddr_conn *)addr)->sconn_addr == sctp_ifap->address.sconn.sconn_addr) { /* found him. */ - if (holds_lock == 0) - SCTP_IPI_ADDR_RUNLOCK(); - return (sctp_ifap); break; } } @@ -5563,7 +5946,7 @@ sctp_find_ifa_by_addr(struct sockaddr *addr, uint32_t vrf_id, int holds_lock) } if (holds_lock == 0) SCTP_IPI_ADDR_RUNLOCK(); - return (NULL); + return (sctp_ifap); } static void @@ -5571,6 +5954,9 @@ sctp_user_rcvd(struct sctp_tcb *stcb, uint32_t *freed_so_far, int hold_rlock, uint32_t rwnd_req) { /* User pulled some data, do we need a rwnd update? */ +#if defined(__FreeBSD__) && !defined(__Userspace__) + struct epoch_tracker et; +#endif int r_unlocked = 0; uint32_t dif, rwnd; struct socket *so = NULL; @@ -5581,7 +5967,7 @@ sctp_user_rcvd(struct sctp_tcb *stcb, uint32_t *freed_so_far, int hold_rlock, atomic_add_int(&stcb->asoc.refcnt, 1); if ((SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_ACK_SENT) || - (stcb->asoc.state & (SCTP_STATE_ABOUT_TO_BE_FREED | SCTP_STATE_SHUTDOWN_RECEIVED))) { + (stcb->asoc.state & (SCTP_STATE_ABOUT_TO_BE_FREED | SCTP_STATE_SHUTDOWN_RECEIVED))) { /* Pre-check If we are freeing no update */ goto no_lock; } @@ -5626,11 +6012,17 @@ sctp_user_rcvd(struct sctp_tcb *stcb, uint32_t *freed_so_far, int hold_rlock, goto out; } SCTP_STAT_INCR(sctps_wu_sacks_sent); +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_ENTER(et); +#endif sctp_send_sack(stcb, SCTP_SO_LOCKED); sctp_chunk_output(stcb->sctp_ep, stcb, SCTP_OUTPUT_FROM_USR_RCVD, SCTP_SO_LOCKED); /* make sure no timer is running */ +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_EXIT(et); +#endif sctp_timer_stop(SCTP_TIMER_TYPE_RECV, stcb->sctp_ep, stcb, NULL, SCTP_FROM_SCTPUTIL + SCTP_LOC_6); SCTP_TCB_UNLOCK(stcb); @@ -5645,7 +6037,7 @@ sctp_user_rcvd(struct sctp_tcb *stcb, uint32_t *freed_so_far, int hold_rlock, SCTP_INP_DECR_REF(stcb->sctp_ep); no_lock: - atomic_add_int(&stcb->asoc.refcnt, -1); + atomic_subtract_int(&stcb->asoc.refcnt, 1); return; } @@ -5687,7 +6079,7 @@ sctp_sorecvmsg(struct socket *so, int hold_rlock = 0; ssize_t slen = 0; uint32_t held_length = 0; -#if defined(__FreeBSD__) && __FreeBSD_version >= 700000 +#if defined(__FreeBSD__) && !defined(__Userspace__) int sockbuf_lock = 0; #endif @@ -5703,7 +6095,7 @@ sctp_sorecvmsg(struct socket *so, } else { in_flags = 0; } -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #if defined(APPLE_LEOPARD) slen = uio->uio_resid; #else @@ -5723,7 +6115,7 @@ sctp_sorecvmsg(struct socket *so, return (EINVAL); } if ((in_flags & (MSG_DONTWAIT -#if defined(__FreeBSD__) && __FreeBSD_version > 500000 +#if defined(__FreeBSD__) && !defined(__Userspace__) | MSG_NBIO #endif )) || @@ -5742,7 +6134,7 @@ sctp_sorecvmsg(struct socket *so, rwnd_req = SCTP_MIN_RWND; in_eeor_mode = sctp_is_feature_on(inp, SCTP_PCB_FLAGS_EXPLICIT_EOR); if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_RECV_RWND_LOGGING_ENABLE) { -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #if defined(APPLE_LEOPARD) sctp_misc_ints(SCTP_SORECV_ENTER, rwnd_req, in_eeor_mode, so->so_rcv.sb_cc, uio->uio_resid); @@ -5755,12 +6147,12 @@ sctp_sorecvmsg(struct socket *so, rwnd_req, in_eeor_mode, so->so_rcv.sb_cc, (uint32_t)uio->uio_resid); #endif } -#if (defined(__FreeBSD__) && __FreeBSD_version < 700000) || defined(__Userspace__) +#if defined(__Userspace__) SOCKBUF_LOCK(&so->so_rcv); hold_sblock = 1; #endif if (SCTP_BASE_SYSCTL(sctp_logging_level) &SCTP_RECV_RWND_LOGGING_ENABLE) { -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #if defined(APPLE_LEOPARD) sctp_misc_ints(SCTP_SORECV_ENTERPL, rwnd_req, block_allowed, so->so_rcv.sb_cc, uio->uio_resid); @@ -5774,34 +6166,29 @@ sctp_sorecvmsg(struct socket *so, #endif } -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) error = sblock(&so->so_rcv, SBLOCKWAIT(in_flags)); #endif - -#if defined(__FreeBSD__) - error = sblock(&so->so_rcv, (block_allowed ? SBL_WAIT : 0)); +#if defined(__FreeBSD__) && !defined(__Userspace__) + error = SOCK_IO_RECV_LOCK(so, SBLOCKWAIT(in_flags)); #endif if (error) { goto release_unlocked; } -#if defined(__FreeBSD__) && __FreeBSD_version >= 700000 - sockbuf_lock = 1; +#if defined(__FreeBSD__) && !defined(__Userspace__) + sockbuf_lock = 1; #endif restart: -#if (defined(__FreeBSD__) && __FreeBSD_version < 700000) || defined(__Userspace__) +#if defined(__Userspace__) if (hold_sblock == 0) { SOCKBUF_LOCK(&so->so_rcv); hold_sblock = 1; } #endif -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) sbunlock(&so->so_rcv, 1); #endif -#if defined(__FreeBSD__) && __FreeBSD_version < 700000 - sbunlock(&so->so_rcv); -#endif - restart_nosblocks: if (hold_sblock == 0) { SOCKBUF_LOCK(&so->so_rcv); @@ -5811,7 +6198,7 @@ sctp_sorecvmsg(struct socket *so, (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE)) { goto out; } -#if (defined(__FreeBSD__) && __FreeBSD_version > 500000) || defined(__Windows__) +#if (defined(__FreeBSD__) || defined(_WIN32)) && !defined(__Userspace__) if ((so->so_rcv.sb_state & SBS_CANTRCVMORE) && (so->so_rcv.sb_cc == 0)) { #else if ((so->so_state & SS_CANTRCVMORE) && (so->so_rcv.sb_cc == 0)) { @@ -5879,11 +6266,8 @@ sctp_sorecvmsg(struct socket *so, SOCKBUF_UNLOCK(&so->so_rcv); hold_sblock = 0; } -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) error = sblock(&so->so_rcv, SBLOCKWAIT(in_flags)); -#endif -#if defined(__FreeBSD__) && __FreeBSD_version < 700000 - error = sblock(&so->so_rcv, (block_allowed ? M_WAITOK : 0)); #endif /* we possibly have data we can read */ /*sa_ignore FREED_MEMORY*/ @@ -6236,7 +6620,7 @@ sctp_sorecvmsg(struct socket *so, m = control->data; while (m) { /* Move out all we can */ -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #if defined(APPLE_LEOPARD) cp_len = uio->uio_resid; #else @@ -6254,12 +6638,12 @@ sctp_sorecvmsg(struct socket *so, SCTP_INP_READ_UNLOCK(inp); hold_rlock = 0; } -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_UNLOCK(so, 0); #endif if (cp_len > 0) error = uiomove(mtod(m, char *), (int)cp_len, uio); -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_LOCK(so, 0); #endif /* re-read */ @@ -6308,13 +6692,13 @@ sctp_sorecvmsg(struct socket *so, copied_so_far += cp_len; freed_so_far += (uint32_t)cp_len; freed_so_far += MSIZE; - atomic_subtract_int(&control->length, cp_len); + atomic_subtract_int(&control->length, (int)cp_len); control->data = sctp_m_free(m); m = control->data; /* been through it all, must hold sb lock ok to null tail */ if (control->data == NULL) { #ifdef INVARIANTS -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if ((control->end_added == 0) || (TAILQ_NEXT(control, next) == NULL)) { /* If the end is not added, OR the @@ -6345,10 +6729,10 @@ sctp_sorecvmsg(struct socket *so, if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_SB_LOGGING_ENABLE) { sctp_sblog(&so->so_rcv, control->do_not_ref_stcb?NULL:stcb, SCTP_LOG_SBFREE, (int)cp_len); } - atomic_subtract_int(&so->so_rcv.sb_cc, cp_len); + atomic_subtract_int(&so->so_rcv.sb_cc, (int)cp_len); if ((control->do_not_ref_stcb == 0) && stcb) { - atomic_subtract_int(&stcb->asoc.sb_cc, cp_len); + atomic_subtract_int(&stcb->asoc.sb_cc, (int)cp_len); } copied_so_far += cp_len; freed_so_far += (uint32_t)cp_len; @@ -6357,12 +6741,12 @@ sctp_sorecvmsg(struct socket *so, sctp_sblog(&so->so_rcv, control->do_not_ref_stcb?NULL:stcb, SCTP_LOG_SBRESULT, 0); } - atomic_subtract_int(&control->length, cp_len); + atomic_subtract_int(&control->length, (int)cp_len); } else { copied_so_far += cp_len; } } -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #if defined(APPLE_LEOPARD) if ((out_flags & MSG_EOR) || (uio->uio_resid == 0)) { #else @@ -6448,7 +6832,7 @@ sctp_sorecvmsg(struct socket *so, if (out_flags & MSG_EOR) { goto release; } -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #if defined(APPLE_LEOPARD) if ((uio->uio_resid == 0) || #else @@ -6470,10 +6854,11 @@ sctp_sorecvmsg(struct socket *so, goto release; } /* - * We need to wait for more data a few things: - We don't - * sbunlock() so we don't get someone else reading. - We - * must be sure to account for the case where what is added - * is NOT to our control when we wakeup. + * We need to wait for more data a few things: + * - We don't release the I/O lock so we don't get someone else + * reading. + * - We must be sure to account for the case where what is added + * is NOT to our control when we wakeup. */ /* Do we need to tell the transport a rwnd update might be @@ -6486,7 +6871,7 @@ sctp_sorecvmsg(struct socket *so, sctp_user_rcvd(stcb, &freed_so_far, hold_rlock, rwnd_req); } wait_some_more: -#if (defined(__FreeBSD__) && __FreeBSD_version > 500000) || defined(__Windows__) +#if (defined(__FreeBSD__) || defined(_WIN32)) && !defined(__Userspace__) if (so->so_rcv.sb_state & SBS_CANTRCVMORE) { goto release; } @@ -6511,13 +6896,13 @@ sctp_sorecvmsg(struct socket *so, (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_FRAG_INTERLEAVE))) { goto release; } -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) sbunlock(&so->so_rcv, 1); #endif if (so->so_rcv.sb_cc <= control->held_length) { error = sbwait(&so->so_rcv); if (error) { -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) goto release; #else goto release_unlocked; @@ -6525,7 +6910,7 @@ sctp_sorecvmsg(struct socket *so, } control->held_length = 0; } -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) error = sblock(&so->so_rcv, SBLOCKWAIT(in_flags)); #endif if (hold_sblock) { @@ -6597,7 +6982,7 @@ sctp_sorecvmsg(struct socket *so, if (control->spec_flags & M_NOTIFICATION) { out_flags |= MSG_NOTIFICATION; } -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #if defined(APPLE_LEOPARD) uio->uio_resid = control->length; #else @@ -6634,7 +7019,7 @@ sctp_sorecvmsg(struct socket *so, SCTP_INP_READ_UNLOCK(inp); hold_rlock = 0; } -#if (defined(__FreeBSD__) && __FreeBSD_version < 700000) || defined(__Userspace__) +#if defined(__Userspace__) if (hold_sblock == 0) { SOCKBUF_LOCK(&so->so_rcv); hold_sblock = 1; @@ -6645,15 +7030,13 @@ sctp_sorecvmsg(struct socket *so, hold_sblock = 0; } #endif -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) sbunlock(&so->so_rcv, 1); #endif -#if defined(__FreeBSD__) - sbunlock(&so->so_rcv); -#if defined(__FreeBSD__) && __FreeBSD_version >= 700000 +#if defined(__FreeBSD__) && !defined(__Userspace__) + SOCK_IO_RECV_UNLOCK(so); sockbuf_lock = 0; -#endif #endif release_unlocked: @@ -6686,9 +7069,9 @@ sctp_sorecvmsg(struct socket *so, if (hold_sblock) { SOCKBUF_UNLOCK(&so->so_rcv); } -#if defined(__FreeBSD__) && __FreeBSD_version >= 700000 +#if defined(__FreeBSD__) && !defined(__Userspace__) if (sockbuf_lock) { - sbunlock(&so->so_rcv); + SOCK_IO_RECV_UNLOCK(so); } #endif @@ -6709,13 +7092,13 @@ sctp_sorecvmsg(struct socket *so, } /* Save the value back for next time */ stcb->freed_by_sorcv_sincelast = freed_so_far; - atomic_add_int(&stcb->asoc.refcnt, -1); + atomic_subtract_int(&stcb->asoc.refcnt, 1); } if (SCTP_BASE_SYSCTL(sctp_logging_level) &SCTP_RECV_RWND_LOGGING_ENABLE) { if (stcb) { sctp_misc_ints(SCTP_SORECV_DONE, freed_so_far, -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #if defined(APPLE_LEOPARD) ((uio) ? (slen - uio->uio_resid) : slen), #else @@ -6729,7 +7112,7 @@ sctp_sorecvmsg(struct socket *so, } else { sctp_misc_ints(SCTP_SORECV_DONE, freed_so_far, -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) #if defined(APPLE_LEOPARD) ((uio) ? (slen - uio->uio_resid) : slen), #else @@ -6749,7 +7132,6 @@ sctp_sorecvmsg(struct socket *so, return (error); } - #ifdef SCTP_MBUF_LOGGING struct mbuf * sctp_m_free(struct mbuf *m) @@ -6778,7 +7160,7 @@ sctp_dynamic_set_primary(struct sockaddr *sa, uint32_t vrf_id) struct sctp_ifa *ifa; struct sctp_laddr *wi; - ifa = sctp_find_ifa_by_addr(sa, vrf_id, 0); + ifa = sctp_find_ifa_by_addr(sa, vrf_id, SCTP_ADDR_NOT_LOCKED); if (ifa == NULL) { SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTPUTIL, EADDRNOTAVAIL); return (EADDRNOTAVAIL); @@ -6817,7 +7199,6 @@ sctp_dynamic_set_primary(struct sockaddr *sa, uint32_t vrf_id) #if defined(__Userspace__) /* no sctp_soreceive for __Userspace__ now */ #endif - #if !defined(__Userspace__) int sctp_soreceive( struct socket *so, @@ -6859,7 +7240,7 @@ sctp_soreceive( struct socket *so, fromlen = 0; } -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_LOCK(so, 1); #endif if (filling_sinfo) { @@ -6891,7 +7272,7 @@ sctp_soreceive( struct socket *so, #else if (from) { #endif -#if (defined(__FreeBSD__) && __FreeBSD_version > 500000) || defined(__Windows__) +#if (defined(__FreeBSD__) || defined(_WIN32)) && !defined(__Userspace__) *psa = sodupsockaddr(from, M_NOWAIT); #else *psa = dup_sockaddr(from, mp0 == 0); @@ -6900,14 +7281,13 @@ sctp_soreceive( struct socket *so, *psa = NULL; } } -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) SCTP_SOCKET_UNLOCK(so, 1); #endif return (error); } - -#if (defined(__FreeBSD__) && __FreeBSD_version < 603000) || defined(__Windows__) +#if defined(_WIN32) && !defined(__Userspace__) /* * General routine to allocate a hash table with control of memory flags. * is in 7.0 and beyond for sure :-) @@ -6954,7 +7334,6 @@ sctp_hashinit_flags(int elements, struct malloc_type *type, return (hashtbl); } #endif - #else /* __Userspace__ ifdef above sctp_soreceive */ /* * __Userspace__ Defining sctp_hashinit_flags() and sctp_hashdestroy() for userland. @@ -7005,7 +7384,6 @@ sctp_hashinit_flags(int elements, struct malloc_type *type, return (hashtbl); } - void sctp_hashdestroy(void *vhashtbl, struct malloc_type *type, u_long hashmask) { @@ -7020,7 +7398,6 @@ sctp_hashdestroy(void *vhashtbl, struct malloc_type *type, u_long hashmask) FREE(hashtbl, type); } - void sctp_hashfreedestroy(void *vhashtbl, struct malloc_type *type, u_long hashmask) { @@ -7045,10 +7422,7 @@ sctp_hashfreedestroy(void *vhashtbl, struct malloc_type *type, u_long hashmask) FREE(hashtbl, type); } - #endif - - int sctp_connectx_helper_add(struct sctp_tcb *stcb, struct sockaddr *addr, int totaddr, int *error) @@ -7184,17 +7558,17 @@ sctp_connectx_helper_find(struct sctp_inpcb *inp, struct sockaddr *addr, { struct sockaddr_in6 *sin6; - sin6 = (struct sockaddr_in6 *)sa; - if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { - /* Must be non-mapped for connectx */ - return (EINVAL); - } incr = (unsigned int)sizeof(struct sockaddr_in6); #ifdef HAVE_SA_LEN if (sa->sa_len != incr) { return (EINVAL); } #endif + sin6 = (struct sockaddr_in6 *)sa; + if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { + /* Must be non-mapped for connectx */ + return (EINVAL); + } (*num_v6) += 1; break; } @@ -7225,16 +7599,24 @@ sctp_connectx_helper_find(struct sctp_inpcb *inp, struct sockaddr *addr, */ void sctp_bindx_add_address(struct socket *so, struct sctp_inpcb *inp, - struct sockaddr *sa, sctp_assoc_t assoc_id, - uint32_t vrf_id, int *error, void *p) + struct sockaddr *sa, uint32_t vrf_id, int *error, + void *p) { - struct sockaddr *addr_touse; #if defined(INET) && defined(INET6) struct sockaddr_in sin; #endif -#ifdef SCTP_MVRF - int i, fnd = 0; +#ifdef INET6 + struct sockaddr_in6 *sin6; #endif +#ifdef INET + struct sockaddr_in *sinp; +#endif + struct sockaddr *addr_to_use; + struct sctp_inpcb *lep; +#ifdef SCTP_MVRF + int i; +#endif + uint16_t port; /* see if we're bound all already! */ if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) { @@ -7246,23 +7628,18 @@ sctp_bindx_add_address(struct socket *so, struct sctp_inpcb *inp, /* Is the VRF one we have */ for (i = 0; i < inp->num_vrfs; i++) { if (vrf_id == inp->m_vrf_ids[i]) { - fnd = 1; break; } } - if (!fnd) { + if (i == inp->num_vrfs) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTPUTIL, EINVAL); *error = EINVAL; return; } #endif - addr_touse = sa; + switch (sa->sa_family) { #ifdef INET6 - if (sa->sa_family == AF_INET6) { -#ifdef INET - struct sockaddr_in6 *sin6; - -#endif + case AF_INET6: #ifdef HAVE_SA_LEN if (sa->sa_len != sizeof(struct sockaddr_in6)) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTPUTIL, EINVAL); @@ -7276,8 +7653,9 @@ sctp_bindx_add_address(struct socket *so, struct sctp_inpcb *inp, *error = EINVAL; return; } + sin6 = (struct sockaddr_in6 *)sa; + port = sin6->sin6_port; #ifdef INET - sin6 = (struct sockaddr_in6 *)addr_touse; if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) && SCTP_IPV6_V6ONLY(inp)) { @@ -7287,13 +7665,17 @@ sctp_bindx_add_address(struct socket *so, struct sctp_inpcb *inp, return; } in6_sin6_2_sin(&sin, sin6); - addr_touse = (struct sockaddr *)&sin; + addr_to_use = (struct sockaddr *)&sin; + } else { + addr_to_use = sa; } +#else + addr_to_use = sa; #endif - } + break; #endif #ifdef INET - if (sa->sa_family == AF_INET) { + case AF_INET: #ifdef HAVE_SA_LEN if (sa->sa_len != sizeof(struct sockaddr_in)) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTPUTIL, EINVAL); @@ -7308,10 +7690,18 @@ sctp_bindx_add_address(struct socket *so, struct sctp_inpcb *inp, *error = EINVAL; return; } - } + sinp = (struct sockaddr_in *)sa; + port = sinp->sin_port; + addr_to_use = sa; + break; #endif + default: + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTPUTIL, EINVAL); + *error = EINVAL; + return; + } if (inp->sctp_flags & SCTP_PCB_FLAGS_UNBOUND) { -#if !(defined(__Panda__) || defined(__Windows__) || defined(__Userspace__)) +#if !(defined(_WIN32) || defined(__Userspace__)) if (p == NULL) { /* Can't get proc for Net/Open BSD */ SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTPUTIL, EINVAL); @@ -7319,58 +7709,25 @@ sctp_bindx_add_address(struct socket *so, struct sctp_inpcb *inp, return; } #endif - *error = sctp_inpcb_bind(so, addr_touse, NULL, p); + *error = sctp_inpcb_bind(so, addr_to_use, NULL, p); return; } - /* - * No locks required here since bind and mgmt_ep_sa - * all do their own locking. If we do something for - * the FIX: below we may need to lock in that case. - */ - if (assoc_id == 0) { + /* Validate the incoming port. */ + if ((port != 0) && (port != inp->sctp_lport)) { + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTPUTIL, EINVAL); + *error = EINVAL; + return; + } + lep = sctp_pcb_findep(addr_to_use, 1, 0, vrf_id); + if (lep == NULL) { /* add the address */ - struct sctp_inpcb *lep; - struct sockaddr_in *lsin = (struct sockaddr_in *)addr_touse; - - /* validate the incoming port */ - if ((lsin->sin_port != 0) && - (lsin->sin_port != inp->sctp_lport)) { - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTPUTIL, EINVAL); - *error = EINVAL; - return; - } else { - /* user specified 0 port, set it to existing port */ - lsin->sin_port = inp->sctp_lport; - } - - lep = sctp_pcb_findep(addr_touse, 1, 0, vrf_id); - if (lep != NULL) { - /* - * We must decrement the refcount - * since we have the ep already and - * are binding. No remove going on - * here. - */ - SCTP_INP_DECR_REF(lep); - } - if (lep == inp) { - /* already bound to it.. ok */ - return; - } else if (lep == NULL) { - ((struct sockaddr_in *)addr_touse)->sin_port = 0; - *error = sctp_addr_mgmt_ep_sa(inp, addr_touse, - SCTP_ADD_IP_ADDRESS, - vrf_id, NULL); - } else { + *error = sctp_addr_mgmt_ep_sa(inp, addr_to_use, + SCTP_ADD_IP_ADDRESS, vrf_id); + } else { + if (lep != inp) { *error = EADDRINUSE; } - if (*error) - return; - } else { - /* - * FIX: decide whether we allow assoc based - * bindx - */ + SCTP_INP_DECR_REF(lep); } } @@ -7380,15 +7737,15 @@ sctp_bindx_add_address(struct socket *so, struct sctp_inpcb *inp, */ void sctp_bindx_delete_address(struct sctp_inpcb *inp, - struct sockaddr *sa, sctp_assoc_t assoc_id, - uint32_t vrf_id, int *error) + struct sockaddr *sa, uint32_t vrf_id, int *error) { - struct sockaddr *addr_touse; + struct sockaddr *addr_to_use; #if defined(INET) && defined(INET6) + struct sockaddr_in6 *sin6; struct sockaddr_in sin; #endif #ifdef SCTP_MVRF - int i, fnd = 0; + int i; #endif /* see if we're bound all already! */ @@ -7401,23 +7758,18 @@ sctp_bindx_delete_address(struct sctp_inpcb *inp, /* Is the VRF one we have */ for (i = 0; i < inp->num_vrfs; i++) { if (vrf_id == inp->m_vrf_ids[i]) { - fnd = 1; break; } } - if (!fnd) { + if (i == inp->num_vrfs) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTPUTIL, EINVAL); *error = EINVAL; return; } #endif - addr_touse = sa; + switch (sa->sa_family) { #ifdef INET6 - if (sa->sa_family == AF_INET6) { -#ifdef INET - struct sockaddr_in6 *sin6; -#endif - + case AF_INET6: #ifdef HAVE_SA_LEN if (sa->sa_len != sizeof(struct sockaddr_in6)) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTPUTIL, EINVAL); @@ -7432,7 +7784,7 @@ sctp_bindx_delete_address(struct sctp_inpcb *inp, return; } #ifdef INET - sin6 = (struct sockaddr_in6 *)addr_touse; + sin6 = (struct sockaddr_in6 *)sa; if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) && SCTP_IPV6_V6ONLY(inp)) { @@ -7442,13 +7794,17 @@ sctp_bindx_delete_address(struct sctp_inpcb *inp, return; } in6_sin6_2_sin(&sin, sin6); - addr_touse = (struct sockaddr *)&sin; + addr_to_use = (struct sockaddr *)&sin; + } else { + addr_to_use = sa; } +#else + addr_to_use = sa; #endif - } + break; #endif #ifdef INET - if (sa->sa_family == AF_INET) { + case AF_INET: #ifdef HAVE_SA_LEN if (sa->sa_len != sizeof(struct sockaddr_in)) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTPUTIL, EINVAL); @@ -7463,24 +7819,17 @@ sctp_bindx_delete_address(struct sctp_inpcb *inp, *error = EINVAL; return; } - } + addr_to_use = sa; + break; #endif - /* - * No lock required mgmt_ep_sa does its own locking. - * If the FIX: below is ever changed we may need to - * lock before calling association level binding. - */ - if (assoc_id == 0) { - /* delete the address */ - *error = sctp_addr_mgmt_ep_sa(inp, addr_touse, - SCTP_DEL_IP_ADDRESS, - vrf_id, NULL); - } else { - /* - * FIX: decide whether we allow assoc based - * bindx - */ + default: + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTPUTIL, EINVAL); + *error = EINVAL; + return; } + /* No lock required mgmt_ep_sa does its own locking. */ + *error = sctp_addr_mgmt_ep_sa(inp, addr_to_use, SCTP_DEL_IP_ADDRESS, + vrf_id); } /* @@ -7494,7 +7843,7 @@ sctp_local_addr_count(struct sctp_tcb *stcb) #if defined(INET) int ipv4_local_scope, ipv4_addr_legal; #endif -#if defined (INET6) +#if defined(INET6) int local_scope, site_scope, ipv6_addr_legal; #endif #if defined(__Userspace__) @@ -7550,7 +7899,7 @@ sctp_local_addr_count(struct sctp_tcb *stcb) /* skip unspecified addrs */ continue; } -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (prison_check_ip4(stcb->sctp_ep->ip_inp.inp.inp_cred, &sin->sin_addr) != 0) { continue; @@ -7579,7 +7928,7 @@ sctp_local_addr_count(struct sctp_tcb *stcb) if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) { continue; } -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (prison_check_ip6(stcb->sctp_ep->ip_inp.inp.inp_cred, &sin6->sin6_addr) != 0) { continue; @@ -7661,7 +8010,7 @@ sctp_log_trace(uint32_t subsys, const char *str SCTP_UNUSED, uint32_t a, uint32_ { uint32_t saveindex, newindex; -#if defined(__Windows__) +#if defined(_WIN32) && !defined(__Userspace__) if (SCTP_BASE_SYSCTL(sctp_log) == NULL) { return; } @@ -7708,8 +8057,7 @@ sctp_log_trace(uint32_t subsys, const char *str SCTP_UNUSED, uint32_t a, uint32_ } #endif -#if defined(__FreeBSD__) -#if __FreeBSD_version >= 800044 +#if defined(__FreeBSD__) && !defined(__Userspace__) static void sctp_recv_udp_tunneled_packet(struct mbuf *m, int off, struct inpcb *inp, const struct sockaddr *sa SCTP_UNUSED, void *ctx SCTP_UNUSED) @@ -7763,29 +8111,17 @@ sctp_recv_udp_tunneled_packet(struct mbuf *m, int off, struct inpcb *inp, * Since CSUM_DATA_VALID == CSUM_SCTP_VALID this would imply that * the HW also verified the SCTP checksum. Therefore, clear the bit. */ -#if __FreeBSD_version > 1000049 SCTPDBG(SCTP_DEBUG_CRCOFFLOAD, "sctp_recv_udp_tunneled_packet(): Packet of length %d received on %s with csum_flags 0x%b.\n", m->m_pkthdr.len, if_name(m->m_pkthdr.rcvif), (int)m->m_pkthdr.csum_flags, CSUM_BITS); -#else - SCTPDBG(SCTP_DEBUG_CRCOFFLOAD, - "sctp_recv_udp_tunneled_packet(): Packet of length %d received on %s with csum_flags 0x%x.\n", - m->m_pkthdr.len, - if_name(m->m_pkthdr.rcvif), - m->m_pkthdr.csum_flags); -#endif m->m_pkthdr.csum_flags &= ~CSUM_DATA_VALID; iph = mtod(m, struct ip *); switch (iph->ip_v) { #ifdef INET case IPVERSION: -#if __FreeBSD_version >= 1000000 iph->ip_len = htons(ntohs(iph->ip_len) - sizeof(struct udphdr)); -#else - iph->ip_len -= sizeof(struct udphdr); -#endif sctp_input_with_port(m, off, port); break; #endif @@ -7804,9 +8140,7 @@ sctp_recv_udp_tunneled_packet(struct mbuf *m, int off, struct inpcb *inp, out: m_freem(m); } -#endif -#if __FreeBSD_version >= 1100000 #ifdef INET static void sctp_recv_icmp_tunneled_packet(int cmd, struct sockaddr *sa, void *vip, void *ctx SCTP_UNUSED) @@ -7926,16 +8260,6 @@ sctp_recv_icmp_tunneled_packet(int cmd, struct sockaddr *sa, void *vip, void *ct } #endif } else { -#if defined(__FreeBSD__) && __FreeBSD_version < 500000 - /* - * XXX must be fixed for 5.x and higher, leave for - * 4.x - */ - if (PRC_IS_REDIRECT(cmd) && (inp != NULL)) { - in_rtchange((struct inpcb *)inp, - inetctlerrmap[cmd]); - } -#endif if ((stcb == NULL) && (inp != NULL)) { /* reduce ref-count */ SCTP_INP_WLOCK(inp); @@ -7997,7 +8321,7 @@ sctp_recv_icmp6_tunneled_packet(int cmd, struct sockaddr *sa, void *d, void *ctx #endif src.sin6_port = sh.src_port; src.sin6_addr = ip6cp->ip6c_ip6->ip6_src; -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (in6_setscope(&src.sin6_addr, ip6cp->ip6c_m->m_pkthdr.rcvif, NULL) != 0) { return; } @@ -8009,7 +8333,7 @@ sctp_recv_icmp6_tunneled_packet(int cmd, struct sockaddr *sa, void *d, void *ctx #endif dst.sin6_port = sh.dest_port; dst.sin6_addr = ip6cp->ip6c_ip6->ip6_dst; -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (in6_setscope(&dst.sin6_addr, ip6cp->ip6c_m->m_pkthdr.rcvif, NULL) != 0) { return; } @@ -8040,7 +8364,7 @@ sctp_recv_icmp6_tunneled_packet(int cmd, struct sockaddr *sa, void *d, void *ctx return; } } else { -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) if (ip6cp->ip6c_m->m_pkthdr.len >= ip6cp->ip6c_off + sizeof(struct udphdr) + sizeof(struct sctphdr) + @@ -8109,11 +8433,6 @@ sctp_recv_icmp6_tunneled_packet(int cmd, struct sockaddr *sa, void *d, void *ctx } #endif } else { -#if defined(__FreeBSD__) && __FreeBSD_version < 500000 - if (PRC_IS_REDIRECT(cmd) && (inp != NULL)) { - in6_rtchange(inp, inet6ctlerrmap[cmd]); - } -#endif if ((stcb == NULL) && (inp != NULL)) { /* reduce inp's ref-count */ SCTP_INP_WLOCK(inp); @@ -8126,13 +8445,12 @@ sctp_recv_icmp6_tunneled_packet(int cmd, struct sockaddr *sa, void *d, void *ctx } } #endif -#endif void sctp_over_udp_stop(void) { /* - * This function assumes sysctl caller holds sctp_sysctl_info_lock() for writting! + * This function assumes sysctl caller holds sctp_sysctl_info_lock() for writing! */ #ifdef INET if (SCTP_BASE_INFO(udp4_tun_socket) != NULL) { @@ -8151,7 +8469,6 @@ sctp_over_udp_stop(void) int sctp_over_udp_start(void) { -#if __FreeBSD_version >= 800044 uint16_t port; int ret; #ifdef INET @@ -8161,7 +8478,7 @@ sctp_over_udp_start(void) struct sockaddr_in6 sin6; #endif /* - * This function assumes sysctl caller holds sctp_sysctl_info_lock() for writting! + * This function assumes sysctl caller holds sctp_sysctl_info_lock() for writing! */ port = SCTP_BASE_SYSCTL(sctp_udp_tunneling_port); if (ntohs(port) == 0) { @@ -8190,9 +8507,7 @@ sctp_over_udp_start(void) /* Call the special UDP hook. */ if ((ret = udp_set_kernel_tunneling(SCTP_BASE_INFO(udp4_tun_socket), sctp_recv_udp_tunneled_packet, -#if __FreeBSD_version >= 1100000 sctp_recv_icmp_tunneled_packet, -#endif NULL))) { sctp_over_udp_stop(); return (ret); @@ -8218,9 +8533,7 @@ sctp_over_udp_start(void) /* Call the special UDP hook. */ if ((ret = udp_set_kernel_tunneling(SCTP_BASE_INFO(udp6_tun_socket), sctp_recv_udp_tunneled_packet, -#if __FreeBSD_version >= 1100000 sctp_recv_icmp6_tunneled_packet, -#endif NULL))) { sctp_over_udp_stop(); return (ret); @@ -8237,9 +8550,6 @@ sctp_over_udp_start(void) } #endif return (0); -#else - return (ENOTSUP); -#endif } #endif @@ -8277,7 +8587,7 @@ sctp_min_mtu(uint32_t mtu1, uint32_t mtu2, uint32_t mtu3) } } -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) void sctp_hc_set_mtu(union sctp_sockstore *addr, uint16_t fibnum, uint32_t mtu) { diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctputil.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctputil.h index 2b691cff70..2919086a84 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctputil.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctputil.h @@ -32,9 +32,9 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include -__FBSDID("$FreeBSD: head/sys/netinet/sctputil.h 352592 2019-09-22 10:40:15Z tuexen $"); +__FBSDID("$FreeBSD$"); #endif #ifndef _NETINET_SCTP_UTIL_H_ @@ -57,14 +57,13 @@ void sctp_m_freem(struct mbuf *m); #define sctp_m_freem m_freem #endif -#if defined(SCTP_LOCAL_TRACE_BUF) || defined(__APPLE__) +#if defined(SCTP_LOCAL_TRACE_BUF) void sctp_log_trace(uint32_t fr, const char *str SCTP_UNUSED, uint32_t a, uint32_t b, uint32_t c, uint32_t d, uint32_t e, uint32_t f); #endif #define sctp_get_associd(stcb) ((sctp_assoc_t)stcb->asoc.assoc_id) - /* * Function prototypes */ @@ -84,7 +83,7 @@ uint32_t sctp_select_initial_TSN(struct sctp_pcb *); uint32_t sctp_select_a_tag(struct sctp_inpcb *, uint16_t lport, uint16_t rport, int); -int sctp_init_asoc(struct sctp_inpcb *, struct sctp_tcb *, uint32_t, uint32_t, uint16_t); +int sctp_init_asoc(struct sctp_inpcb *, struct sctp_tcb *, uint32_t, uint32_t, uint32_t, uint16_t); void sctp_fill_random_store(struct sctp_pcb *); @@ -94,6 +93,14 @@ sctp_notify_stream_reset_add(struct sctp_tcb *stcb, uint16_t numberin, void sctp_notify_stream_reset_tsn(struct sctp_tcb *stcb, uint32_t sending_tsn, uint32_t recv_tsn, int flag); +/* + * NOTE: sctp_timer_start() will increment the reference count of any relevant + * structure the timer is referencing, in order to prevent a race condition + * between the timer executing and the structure being freed. + * + * When the timer fires or sctp_timer_stop() is called, these references are + * removed. + */ void sctp_timer_start(int, struct sctp_inpcb *, struct sctp_tcb *, struct sctp_nets *); @@ -105,13 +112,10 @@ sctp_timer_stop(int, struct sctp_inpcb *, struct sctp_tcb *, int sctp_dynamic_set_primary(struct sockaddr *sa, uint32_t vrf_id); -void -sctp_mtu_size_reset(struct sctp_inpcb *, struct sctp_association *, uint32_t); - void sctp_wakeup_the_read_socket(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int so_locked -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) +#if !(defined(__APPLE__) && !defined(__Userspace__)) SCTP_UNUSED #endif ); @@ -130,11 +134,7 @@ sctp_add_to_readq(struct sctp_inpcb *inp, struct sockbuf *sb, int end, int inpread_locked, - int so_locked -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - SCTP_UNUSED -#endif - ); + int so_locked); void sctp_iterator_worker(void); @@ -162,60 +162,45 @@ sctp_add_pad_tombuf(struct mbuf *, int); struct mbuf * sctp_pad_lastmbuf(struct mbuf *, int, struct mbuf *); -void sctp_ulp_notify(uint32_t, struct sctp_tcb *, uint32_t, void *, int -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - SCTP_UNUSED -#endif - ); +void sctp_ulp_notify(uint32_t, struct sctp_tcb *, uint32_t, void *, int); void sctp_pull_off_control_to_new_inp(struct sctp_inpcb *old_inp, struct sctp_inpcb *new_inp, struct sctp_tcb *stcb, int waitflags); - void sctp_stop_timers_for_shutdown(struct sctp_tcb *); -void sctp_report_all_outbound(struct sctp_tcb *, uint16_t, int, int -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - SCTP_UNUSED -#endif - ); +/* Stop all timers for association and remote addresses. */ +void sctp_stop_association_timers(struct sctp_tcb *, bool); + +void sctp_report_all_outbound(struct sctp_tcb *, uint16_t, int); int sctp_expand_mapping_array(struct sctp_association *, uint32_t); -void sctp_abort_notification(struct sctp_tcb *, uint8_t, uint16_t, - struct sctp_abort_chunk *, int -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - SCTP_UNUSED -#endif - ); +void sctp_abort_notification(struct sctp_tcb *, bool, bool, uint16_t, + struct sctp_abort_chunk *, int); /* We abort responding to an IP packet for some reason */ void sctp_abort_association(struct sctp_inpcb *, struct sctp_tcb *, struct mbuf *, int, struct sockaddr *, struct sockaddr *, struct sctphdr *, struct mbuf *, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) uint8_t, uint32_t, #endif uint32_t, uint16_t); - /* We choose to abort via user input */ void sctp_abort_an_association(struct sctp_inpcb *, struct sctp_tcb *, - struct mbuf *, int -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - SCTP_UNUSED -#endif -); + struct mbuf *, bool, int); void sctp_handle_ootb(struct mbuf *, int, int, struct sockaddr *, struct sockaddr *, struct sctphdr *, struct sctp_inpcb *, struct mbuf *, -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) uint8_t, uint32_t, uint16_t, #endif uint32_t, uint16_t); @@ -276,21 +261,16 @@ void sctp_print_address(struct sockaddr *); int sctp_release_pr_sctp_chunk(struct sctp_tcb *, struct sctp_tmit_chunk *, - uint8_t, int -#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - SCTP_UNUSED -#endif -); + uint8_t, int); struct mbuf *sctp_generate_cause(uint16_t, char *); struct mbuf *sctp_generate_no_user_data_cause(uint32_t); void sctp_bindx_add_address(struct socket *so, struct sctp_inpcb *inp, - struct sockaddr *sa, sctp_assoc_t assoc_id, - uint32_t vrf_id, int *error, void *p); -void sctp_bindx_delete_address(struct sctp_inpcb *inp, - struct sockaddr *sa, sctp_assoc_t assoc_id, - uint32_t vrf_id, int *error); + struct sockaddr *sa, uint32_t vrf_id, int *error, + void *p); +void sctp_bindx_delete_address(struct sctp_inpcb *inp, struct sockaddr *sa, + uint32_t vrf_id, int *error); int sctp_local_addr_count(struct sctp_tcb *stcb); @@ -352,11 +332,11 @@ do { \ } while (0) /* functions to start/stop udp tunneling */ -#if defined(__APPLE__) || defined(__FreeBSD__) +#if (defined(__APPLE__) || defined(__FreeBSD__)) && !defined(__Userspace__) void sctp_over_udp_stop(void); int sctp_over_udp_start(void); #endif -#if defined(__Windows__) +#if defined(_WIN32) && !defined(__Userspace__) void sctp_over_udp_restart(void); #endif @@ -378,7 +358,6 @@ void sctp_log_strm_del_alt(struct sctp_tcb *stcb, uint32_t, uint16_t, uint16_t, void sctp_log_nagle_event(struct sctp_tcb *stcb, int action); - #ifdef SCTP_MBUF_LOGGING void sctp_log_mb(struct mbuf *m, int from); @@ -412,7 +391,6 @@ void sctp_log_map(uint32_t, uint32_t, uint32_t, int); void sctp_print_mapping_array(struct sctp_association *asoc); void sctp_clr_stat_log(void); - #ifdef SCTP_AUDITING_ENABLED void sctp_auditing(int, struct sctp_inpcb *, struct sctp_tcb *, @@ -421,11 +399,16 @@ void sctp_audit_log(uint8_t, uint8_t); #endif uint32_t sctp_min_mtu(uint32_t, uint32_t, uint32_t); -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__Userspace__) void sctp_hc_set_mtu(union sctp_sockstore *, uint16_t, uint32_t); uint32_t sctp_hc_get_mtu(union sctp_sockstore *, uint16_t); #endif void sctp_set_state(struct sctp_tcb *, int); void sctp_add_substate(struct sctp_tcb *, int); +uint32_t sctp_ticks_to_msecs(uint32_t); +uint32_t sctp_msecs_to_ticks(uint32_t); +uint32_t sctp_ticks_to_secs(uint32_t); +uint32_t sctp_secs_to_ticks(uint32_t); + #endif /* _KERNEL */ #endif diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet6/sctp6_usrreq.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet6/sctp6_usrreq.c index 23b1813e7a..e08aef00f6 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet6/sctp6_usrreq.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet6/sctp6_usrreq.c @@ -32,14 +32,14 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include -__FBSDID("$FreeBSD: head/sys/netinet6/sctp6_usrreq.c 355264 2019-12-01 16:14:44Z tuexen $"); +__FBSDID("$FreeBSD$"); #endif #include #ifdef INET6 -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include #endif #include @@ -58,14 +58,11 @@ __FBSDID("$FreeBSD: head/sys/netinet6/sctp6_usrreq.c 355264 2019-12-01 16:14:44Z #include #include #include -#if !defined(__Userspace_os_Windows) +#if !defined(_WIN32) #include #include #endif -#if defined(__APPLE__) -#define APPLE_FILE_NO 9 -#endif -#if defined(__Panda__) || defined(__Userspace__) +#if defined(__Userspace__) int ip6_v6only=0; #endif #if defined(__Userspace__) @@ -73,7 +70,7 @@ int ip6_v6only=0; void in6_sin6_2_sin(struct sockaddr_in *sin, struct sockaddr_in6 *sin6) { -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) uint32_t temp; #endif memset(sin, 0, sizeof(*sin)); @@ -82,7 +79,7 @@ in6_sin6_2_sin(struct sockaddr_in *sin, struct sockaddr_in6 *sin6) #endif sin->sin_family = AF_INET; sin->sin_port = sin6->sin6_port; -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) temp = sin6->sin6_addr.s6_addr16[7]; temp = temp << 16; temp = temp | sin6->sin6_addr.s6_addr16[6]; @@ -108,20 +105,20 @@ void in6_sin_2_v4mapsin6(const struct sockaddr_in *sin, struct sockaddr_in6 *sin6) { memset(sin6, 0, sizeof(struct sockaddr_in6)); - sin6->sin6_family = AF_INET6; + sin6->sin6_family = AF_INET6; #ifdef HAVE_SIN6_LEN sin6->sin6_len = sizeof(struct sockaddr_in6); #endif sin6->sin6_port = sin->sin_port; -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) ((uint32_t *)&sin6->sin6_addr)[0] = 0; ((uint32_t *)&sin6->sin6_addr)[1] = 0; ((uint32_t *)&sin6->sin6_addr)[2] = htonl(0xffff); ((uint32_t *)&sin6->sin6_addr)[3] = sin->sin_addr.s_addr; #else - sin6->sin6_addr.s6_addr32[0] = 0; + sin6->sin6_addr.s6_addr32[0] = 0; sin6->sin6_addr.s6_addr32[1] = 0; - sin6->sin6_addr.s6_addr32[2] = htonl(0xffff); + sin6->sin6_addr.s6_addr32[2] = htonl(0xffff); sin6->sin6_addr.s6_addr32[3] = sin->sin_addr.s_addr; #endif } @@ -132,8 +129,6 @@ in6_sin_2_v4mapsin6(const struct sockaddr_in *sin, struct sockaddr_in6 *sin6) int #if defined(__APPLE__) || defined(__FreeBSD__) sctp6_input_with_port(struct mbuf **i_pak, int *offp, uint16_t port) -#elif defined( __Panda__) -sctp6_input(pakhandle_type *i_pak) #else sctp6_input(struct mbuf **i_pak, int *offp, int proto) #endif @@ -153,25 +148,16 @@ sctp6_input(struct mbuf **i_pak, int *offp, int proto) uint8_t mflowtype; uint16_t fibnum; #endif -#if !(defined(__APPLE__) || defined (__FreeBSD__)) +#if !(defined(__APPLE__) || defined(__FreeBSD__)) uint16_t port = 0; #endif -#if defined(__Panda__) - /* This is Evil, but its the only way to make panda work right. */ - iphlen = sizeof(struct ip6_hdr); -#else iphlen = *offp; -#endif if (SCTP_GET_PKT_VRFID(*i_pak, vrf_id)) { SCTP_RELEASE_PKT(*i_pak); return (IPPROTO_DONE); } m = SCTP_HEADER_TO_CHAIN(*i_pak); -#ifdef __Panda__ - SCTP_DETACH_HEADER_FROM_CHAIN(*i_pak); - (void)SCTP_RELEASE_HEADER(*i_pak); -#endif #ifdef SCTP_MBUF_LOGGING /* Log in any input mbufs */ if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { @@ -184,25 +170,11 @@ sctp6_input(struct mbuf **i_pak, int *offp, int proto) } #endif #if defined(__FreeBSD__) -#if __FreeBSD_version > 1000049 SCTPDBG(SCTP_DEBUG_CRCOFFLOAD, "sctp6_input(): Packet of length %d received on %s with csum_flags 0x%b.\n", m->m_pkthdr.len, if_name(m->m_pkthdr.rcvif), (int)m->m_pkthdr.csum_flags, CSUM_BITS); -#elif __FreeBSD_version >= 800000 - SCTPDBG(SCTP_DEBUG_CRCOFFLOAD, - "sctp6_input(): Packet of length %d received on %s with csum_flags 0x%x.\n", - m->m_pkthdr.len, - if_name(m->m_pkthdr.rcvif), - m->m_pkthdr.csum_flags); -#else - SCTPDBG(SCTP_DEBUG_CRCOFFLOAD, - "sctp6_input(): Packet of length %d received on %s with csum_flags 0x%x.\n", - m->m_pkthdr.len, - m->m_pkthdr.rcvif->if_xname, - m->m_pkthdr.csum_flags); -#endif #endif #if defined(__APPLE__) SCTPDBG(SCTP_DEBUG_CRCOFFLOAD, @@ -212,7 +184,7 @@ sctp6_input(struct mbuf **i_pak, int *offp, int proto) m->m_pkthdr.rcvif->if_unit, m->m_pkthdr.csum_flags); #endif -#if defined(__Windows__) +#if defined(_WIN32) && !defined(__Userspace__) SCTPDBG(SCTP_DEBUG_CRCOFFLOAD, "sctp6_input(): Packet of length %d received on %s with csum_flags 0x%x.\n", m->m_pkthdr.len, @@ -287,13 +259,14 @@ sctp6_input(struct mbuf **i_pak, int *offp, int proto) if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) { goto out; } - ecn_bits = ((ntohl(ip6->ip6_flow) >> 20) & 0x000000ff); -#if defined(__FreeBSD__) && __FreeBSD_version >= 800000 +#if defined(__FreeBSD__) + ecn_bits = IPV6_TRAFFIC_CLASS(ip6); if (m->m_pkthdr.csum_flags & CSUM_SCTP_VALID) { SCTP_STAT_INCR(sctps_recvhwcrc); compute_crc = 0; } else { #else + ecn_bits = ((ntohl(ip6->ip6_flow) >> 20) & 0x000000ff); if (SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback) && (IN6_ARE_ADDR_EQUAL(&src.sin6_addr, &dst.sin6_addr))) { SCTP_STAT_INCR(sctps_recvhwcrc); @@ -327,7 +300,6 @@ sctp6_input(struct mbuf **i_pak, int *offp) return (sctp6_input_with_port(i_pak, offp, 0)); } #endif - #if defined(__FreeBSD__) int sctp6_input(struct mbuf **i_pak, int *offp, int proto SCTP_UNUSED) @@ -344,7 +316,7 @@ sctp6_notify(struct sctp_inpcb *inp, uint8_t icmp6_code, uint32_t next_mtu) { -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) struct socket *so; #endif int timer_stopped; @@ -369,8 +341,8 @@ sctp6_notify(struct sctp_inpcb *inp, case ICMP6_PARAM_PROB: /* Treat it like an ABORT. */ if (icmp6_code == ICMP6_PARAMPROB_NEXTHEADER) { - sctp_abort_notification(stcb, 1, 0, NULL, SCTP_SO_NOT_LOCKED); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) + sctp_abort_notification(stcb, true, false, 0, NULL, SCTP_SO_NOT_LOCKED); +#if defined(__APPLE__) so = SCTP_INP_SO(inp); atomic_add_int(&stcb->asoc.refcnt, 1); SCTP_TCB_UNLOCK(stcb); @@ -380,7 +352,7 @@ sctp6_notify(struct sctp_inpcb *inp, #endif (void)sctp_free_assoc(inp, stcb, SCTP_NORMAL_PROC, SCTP_FROM_SCTP_USRREQ + SCTP_LOC_2); -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) +#if defined(__APPLE__) SCTP_SOCKET_UNLOCK(so, 1); #endif } else { @@ -415,7 +387,7 @@ sctp6_notify(struct sctp_inpcb *inp, } /* Update the association MTU */ if (stcb->asoc.smallest_mtu > next_mtu) { - sctp_pathmtu_adjustment(stcb, next_mtu); + sctp_pathmtu_adjustment(stcb, next_mtu, true); } /* Finally, start the PMTU timer if it was running before. */ if (timer_stopped) { @@ -595,11 +567,6 @@ sctp6_ctlinput(int cmd, struct sockaddr *pktdst, void *d) } #endif } else { -#if defined(__FreeBSD__) && __FreeBSD_version < 500000 - if (PRC_IS_REDIRECT(cmd) && (inp != NULL)) { - in6_rtchange(inp, inet6ctlerrmap[cmd]); - } -#endif if ((stcb == NULL) && (inp != NULL)) { /* reduce inp's ref-count */ SCTP_INP_WLOCK(inp); @@ -618,7 +585,7 @@ sctp6_ctlinput(int cmd, struct sockaddr *pktdst, void *d) * this routine can probably be collasped into the one in sctp_userreq.c * since they do the same thing and now we lookup with a sockaddr */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) static int sctp6_getcred(SYSCTL_HANDLER_ARGS) { @@ -630,16 +597,10 @@ sctp6_getcred(SYSCTL_HANDLER_ARGS) int error; uint32_t vrf_id; -#if defined(__FreeBSD__) || defined(__APPLE__) vrf_id = SCTP_DEFAULT_VRFID; -#else - vrf_id = panda_get_vrf_from_call(); /* from connectx call? */ -#endif -#if defined(__FreeBSD__) && __FreeBSD_version > 602000 +#if defined(__FreeBSD__) && !defined(__Userspace__) error = priv_check(req->td, PRIV_NETINET_GETCRED); -#elif defined(__FreeBSD__) && __FreeBSD_version >= 500000 - error = suser(req->td); #else error = suser(req->p); #endif @@ -694,34 +655,40 @@ out: return (error); } -SYSCTL_PROC(_net_inet6_sctp6, OID_AUTO, getcred, CTLTYPE_OPAQUE | CTLFLAG_RW, - 0, 0, - sctp6_getcred, "S,ucred", "Get the ucred of a SCTP6 connection"); - +SYSCTL_PROC(_net_inet6_sctp6, OID_AUTO, getcred, + CTLTYPE_OPAQUE | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + 0, 0, sctp6_getcred, "S,ucred", + "Get the ucred of a SCTP6 connection"); #endif /* This is the same as the sctp_abort() could be made common */ -#if (defined(__FreeBSD__) && __FreeBSD_version > 690000) || defined(__Windows__) -static void -#elif defined(__Panda__) || defined(__Userspace__) +#if defined(__Userspace__) int +#elif defined(__FreeBSD__) || defined(_WIN32) +static void #else static int #endif sctp6_abort(struct socket *so) { +#if defined(__FreeBSD__) && !defined(__Userspace__) + struct epoch_tracker et; +#endif struct sctp_inpcb *inp; uint32_t flags; inp = (struct sctp_inpcb *)so->so_pcb; if (inp == NULL) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, EINVAL); -#if (defined(__FreeBSD__) && __FreeBSD_version > 690000) || defined(__Windows__) +#if (defined(__FreeBSD__) || defined(_WIN32)) && !defined(__Userspace__) return; #else return (EINVAL); #endif } +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_ENTER(et); +#endif sctp_must_try_again: flags = inp->sctp_flags; #ifdef SCTP_LOG_CLOSING @@ -740,7 +707,7 @@ sctp6_abort(struct socket *so) * here for the accounting/select. */ SCTP_SB_CLEAR(so->so_rcv); -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) so->so_usecount--; #else /* Now null out the reference, we are completely detached. */ @@ -753,20 +720,21 @@ sctp6_abort(struct socket *so) goto sctp_must_try_again; } } -#if (defined(__FreeBSD__) && __FreeBSD_version > 690000) || defined(__Windows__) +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_EXIT(et); return; #else return (0); #endif } -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 -static int -sctp6_attach(struct socket *so, int proto SCTP_UNUSED, struct thread *p SCTP_UNUSED) -#elif defined(__Panda__) || defined(__Userspace__) +#if defined(__Userspace__) int sctp6_attach(struct socket *so, int proto SCTP_UNUSED, uint32_t vrf_id) -#elif defined(__Windows__) +#elif defined(__FreeBSD__) +static int +sctp6_attach(struct socket *so, int proto SCTP_UNUSED, struct thread *p SCTP_UNUSED) +#elif defined(_WIN32) static int sctp6_attach(struct socket *so, int proto SCTP_UNUSED, PKTHREAD p SCTP_UNUSED) #else @@ -776,7 +744,7 @@ sctp6_attach(struct socket *so, int proto SCTP_UNUSED, struct proc *p SCTP_UNUSE { int error; struct sctp_inpcb *inp; -#if !defined(__Panda__) && !defined(__Userspace__) +#if !defined(__Userspace__) uint32_t vrf_id = SCTP_DEFAULT_VRFID; #endif @@ -798,15 +766,9 @@ sctp6_attach(struct socket *so, int proto SCTP_UNUSED, struct proc *p SCTP_UNUSE SCTP_INP_WLOCK(inp); inp->sctp_flags |= SCTP_PCB_FLAGS_BOUND_V6; /* I'm v6! */ -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) || defined(__Userspace__) inp->ip_inp.inp.inp_vflag |= INP_IPV6; -#else - inp->inp_vflag |= INP_IPV6; -#endif -#if !defined(__Panda__) inp->ip_inp.inp.in6p_hops = -1; /* use kernel default */ inp->ip_inp.inp.in6p_cksum = -1; /* just to be sure */ -#endif #ifdef INET /* * XXX: ugly!! IPv4 TTL initialization is necessary for an IPv6 @@ -819,19 +781,19 @@ sctp6_attach(struct socket *so, int proto SCTP_UNUSED, struct proc *p SCTP_UNUSE return (0); } -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 -static int -sctp6_bind(struct socket *so, struct sockaddr *addr, struct thread *p) -{ -#elif defined(__FreeBSD__) || defined(__APPLE__) -static int -sctp6_bind(struct socket *so, struct sockaddr *addr, struct proc *p) -{ -#elif defined(__Panda__) || defined(__Userspace__) +#if defined(__Userspace__) int sctp6_bind(struct socket *so, struct sockaddr *addr, void * p) { -#elif defined(__Windows__) +#elif defined(__FreeBSD__) +static int +sctp6_bind(struct socket *so, struct sockaddr *addr, struct thread *p) +{ +#elif defined(__APPLE__) +static int +sctp6_bind(struct socket *so, struct sockaddr *addr, struct proc *p) +{ +#elif defined(_WIN32) static int sctp6_bind(struct socket *so, struct sockaddr *addr, PKTHREAD p) { @@ -852,7 +814,7 @@ sctp6_bind(struct socket *so, struct mbuf *nam, struct proc *p) return (EINVAL); } -#if !defined(__Windows__) +#if !(defined(_WIN32) && !defined(__Userspace__)) if (addr) { switch (addr->sa_family) { #ifdef INET @@ -881,27 +843,16 @@ sctp6_bind(struct socket *so, struct mbuf *nam, struct proc *p) } } #endif -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) || defined(__Userspace__) vflagsav = inp->ip_inp.inp.inp_vflag; inp->ip_inp.inp.inp_vflag &= ~INP_IPV4; inp->ip_inp.inp.inp_vflag |= INP_IPV6; -#else - vflagsav = inp->inp_vflag; - inp->inp_vflag &= ~INP_IPV4; - inp->inp_vflag |= INP_IPV6; -#endif if ((addr != NULL) && (SCTP_IPV6_V6ONLY(inp) == 0)) { switch (addr->sa_family) { #ifdef INET case AF_INET: /* binding v4 addr to v6 socket, so reset flags */ -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) || defined(__Userspace__) inp->ip_inp.inp.inp_vflag |= INP_IPV4; inp->ip_inp.inp.inp_vflag &= ~INP_IPV6; -#else - inp->inp_vflag |= INP_IPV4; - inp->inp_vflag &= ~INP_IPV6; -#endif break; #endif #ifdef INET6 @@ -912,24 +863,15 @@ sctp6_bind(struct socket *so, struct mbuf *nam, struct proc *p) sin6_p = (struct sockaddr_in6 *)addr; if (IN6_IS_ADDR_UNSPECIFIED(&sin6_p->sin6_addr)) { -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) || defined(__Userspace__) inp->ip_inp.inp.inp_vflag |= INP_IPV4; -#else - inp->inp_vflag |= INP_IPV4; -#endif } #ifdef INET if (IN6_IS_ADDR_V4MAPPED(&sin6_p->sin6_addr)) { struct sockaddr_in sin; in6_sin6_2_sin(&sin, sin6_p); -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) || defined(__Userspace__) inp->ip_inp.inp.inp_vflag |= INP_IPV4; inp->ip_inp.inp.inp_vflag &= ~INP_IPV6; -#else - inp->inp_vflag |= INP_IPV4; - inp->inp_vflag &= ~INP_IPV6; -#endif error = sctp_inpcb_bind(so, (struct sockaddr *)&sin, NULL, p); goto out; } @@ -965,16 +907,11 @@ sctp6_bind(struct socket *so, struct mbuf *nam, struct proc *p) error = sctp_inpcb_bind(so, addr, NULL, p); out: if (error != 0) -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) || defined(__Userspace__) inp->ip_inp.inp.inp_vflag = vflagsav; -#else - inp->inp_vflag = vflagsav; -#endif return (error); } - -#if (defined(__FreeBSD__) && __FreeBSD_version > 690000) || defined(__Windows__) || defined(__Userspace__) +#if defined(__FreeBSD__) || defined(_WIN32) || defined(__Userspace__) #if !defined(__Userspace__) static void #else @@ -988,9 +925,7 @@ sctp6_close(struct socket *so) /* This could be made common with sctp_detach() since they are identical */ #else -#if !defined(__Panda__) static -#endif int sctp6_detach(struct socket *so) { @@ -1004,7 +939,7 @@ sctp6_detach(struct socket *so) #endif -#if !defined(__Panda__) && !defined(__Userspace__) +#if !defined(__Userspace__) static #endif int @@ -1013,25 +948,22 @@ sctp6_disconnect(struct socket *so) return (sctp_disconnect(so)); } - int -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 +#if defined(__FreeBSD__) && !defined(__Userspace__) sctp_sendm(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, struct mbuf *control, struct thread *p); - #else sctp_sendm(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, struct mbuf *control, struct proc *p); - #endif -#if !defined(__Panda__) && !defined(__Windows__) && !defined(__Userspace__) -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 +#if !defined(_WIN32) && !defined(__Userspace__) +#if defined(__FreeBSD__) static int sctp6_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, struct mbuf *control, struct thread *p) { -#elif defined(__FreeBSD__) || defined(__APPLE__) +#elif defined(__APPLE__) static int sctp6_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, struct mbuf *control, struct proc *p) @@ -1077,6 +1009,46 @@ sctp6_send(struct socket *so, int flags, struct mbuf *m, struct mbuf *nam, SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, EDESTADDRREQ); return (EDESTADDRREQ); } + switch (addr->sa_family) { +#ifdef INET + case AF_INET: +#if defined(HAVE_SA_LEN) + if (addr->sa_len != sizeof(struct sockaddr_in)) { + if (control) { + SCTP_RELEASE_PKT(control); + control = NULL; + } + SCTP_RELEASE_PKT(m); + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, EINVAL); + return (EINVAL); + } +#endif + break; +#endif +#ifdef INET6 + case AF_INET6: +#if defined(HAVE_SA_LEN) + if (addr->sa_len != sizeof(struct sockaddr_in6)) { + if (control) { + SCTP_RELEASE_PKT(control); + control = NULL; + } + SCTP_RELEASE_PKT(m); + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, EINVAL); + return (EINVAL); + } +#endif + break; +#endif + default: + if (control) { + SCTP_RELEASE_PKT(control); + control = NULL; + } + SCTP_RELEASE_PKT(m); + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, EINVAL); + return (EINVAL); + } #ifdef INET sin6 = (struct sockaddr_in6 *)addr; if (SCTP_IPV6_V6ONLY(inp)) { @@ -1085,15 +1057,26 @@ sctp6_send(struct socket *so, int flags, struct mbuf *m, struct mbuf *nam, * v4 addr or v4-mapped addr */ if (addr->sa_family == AF_INET) { + if (control) { + SCTP_RELEASE_PKT(control); + control = NULL; + } + SCTP_RELEASE_PKT(m); SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, EINVAL); return (EINVAL); } if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { + if (control) { + SCTP_RELEASE_PKT(control); + control = NULL; + } + SCTP_RELEASE_PKT(m); SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, EINVAL); return (EINVAL); } } - if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { + if ((addr->sa_family == AF_INET6) && + IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { struct sockaddr_in sin; /* convert v4-mapped into v4 addr and send */ @@ -1119,7 +1102,7 @@ connected_type: inp->pkt_last = inp->pkt = m; } if ( -#if defined(__FreeBSD__) || defined(__APPLE__) +#if (defined(__FreeBSD__) || defined(__APPLE__)) && !defined(__Userspace__) /* FreeBSD and MacOSX uses a flag passed */ ((flags & PRUS_MORETOCOME) == 0) #else @@ -1134,9 +1117,18 @@ connected_type: * optionaly switch back to this code (by changing back the * defininitions but this is not advisable. */ +#if defined(__FreeBSD__) && !defined(__Userspace__) + struct epoch_tracker et; +#endif int ret; +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_ENTER(et); +#endif ret = sctp_output(inp, inp->pkt, addr, inp->control, p, flags); +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_EXIT(et); +#endif inp->pkt = NULL; inp->control = NULL; return (ret); @@ -1146,32 +1138,31 @@ connected_type: } #endif -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 -static int -sctp6_connect(struct socket *so, struct sockaddr *addr, struct thread *p) -{ -#elif defined(__FreeBSD__) || defined(__APPLE__) -static int -sctp6_connect(struct socket *so, struct sockaddr *addr, struct proc *p) -{ -#elif defined(__Panda__) -int -sctp6_connect(struct socket *so, struct sockaddr *addr, void *p) -{ -#elif defined(__Windows__) -static int -sctp6_connect(struct socket *so, struct sockaddr *addr, PKTHREAD p) -{ -#elif defined(__Userspace__) +#if defined(__Userspace__) int sctp6_connect(struct socket *so, struct sockaddr *addr) { void *p = NULL; +#elif defined(__FreeBSD__) +static int +sctp6_connect(struct socket *so, struct sockaddr *addr, struct thread *p) +{ +#elif defined(__APPLE__) +static int +sctp6_connect(struct socket *so, struct sockaddr *addr, struct proc *p) +{ +#elif defined(_WIN32) +static int +sctp6_connect(struct socket *so, struct sockaddr *addr, PKTHREAD p) +{ #else static int sctp6_connect(struct socket *so, struct mbuf *nam, struct proc *p) { struct sockaddr *addr = mtod(nam, struct sockaddr *); +#endif +#if defined(__FreeBSD__) && !defined(__Userspace__) + struct epoch_tracker et; #endif uint32_t vrf_id; int error = 0; @@ -1192,7 +1183,7 @@ sctp6_connect(struct socket *so, struct mbuf *nam, struct proc *p) SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, EINVAL); return (EINVAL); } -#if !defined(__Windows__) +#if !(defined(_WIN32) && !defined(__Userspace__)) switch (addr->sa_family) { #ifdef INET case AF_INET: @@ -1263,7 +1254,8 @@ sctp6_connect(struct socket *so, struct mbuf *nam, struct proc *p) return (EINVAL); } } - if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { + if ((addr->sa_family == AF_INET6) && + IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { /* convert v4-mapped into v4 addr */ in6_sin6_2_sin(&store.sin, sin6); addr = &store.sa; @@ -1297,36 +1289,33 @@ sctp6_connect(struct socket *so, struct mbuf *nam, struct proc *p) return (EALREADY); } /* We are GOOD to go */ - stcb = sctp_aloc_assoc(inp, addr, &error, 0, vrf_id, - inp->sctp_ep.pre_open_stream_count, - inp->sctp_ep.port, p, - SCTP_INITIALIZE_AUTH_PARAMS); + stcb = sctp_aloc_assoc_connected(inp, addr, &error, 0, 0, vrf_id, + inp->sctp_ep.pre_open_stream_count, + inp->sctp_ep.port, p, + SCTP_INITIALIZE_AUTH_PARAMS); SCTP_ASOC_CREATE_UNLOCK(inp); if (stcb == NULL) { /* Gak! no memory */ return (error); } - if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) { - stcb->sctp_ep->sctp_flags |= SCTP_PCB_FLAGS_CONNECTED; - /* Set the connected flag so we can queue data */ - soisconnecting(so); - } SCTP_SET_STATE(stcb, SCTP_STATE_COOKIE_WAIT); (void)SCTP_GETTIME_TIMEVAL(&stcb->asoc.time_entered); +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_ENTER(et); +#endif sctp_send_initiate(inp, stcb, SCTP_SO_LOCKED); SCTP_TCB_UNLOCK(stcb); +#if defined(__FreeBSD__) && !defined(__Userspace__) + NET_EPOCH_EXIT(et); +#endif return (error); } static int -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) sctp6_getaddr(struct socket *so, struct sockaddr **addr) { struct sockaddr_in6 *sin6; -#elif defined(__Panda__) -sctp6_getaddr(struct socket *so, struct sockaddr *addr) -{ - struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)addr; #else sctp6_getaddr(struct socket *so, struct mbuf *nam) { @@ -1336,19 +1325,17 @@ sctp6_getaddr(struct socket *so, struct mbuf *nam) uint32_t vrf_id; struct sctp_ifa *sctp_ifa; -#ifdef SCTP_KAME +#if defined(SCTP_KAME) && defined(SCTP_EMBEDDED_V6_SCOPE) int error; -#endif /* SCTP_KAME */ +#endif /* * Do the malloc first in case it blocks. */ -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) SCTP_MALLOC_SONAME(sin6, struct sockaddr_in6 *, sizeof(*sin6)); if (sin6 == NULL) return (ENOMEM); -#elif defined(__Panda__) - memset(sin6, 0, sizeof(*sin6)); #else SCTP_BUF_LEN(nam) = sizeof(*sin6); memset(sin6, 0, sizeof(*sin6)); @@ -1360,7 +1347,7 @@ sctp6_getaddr(struct socket *so, struct mbuf *nam) inp = (struct sctp_inpcb *)so->so_pcb; if (inp == NULL) { -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) SCTP_FREE_SONAME(sin6); #endif SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, ECONNRESET); @@ -1378,7 +1365,7 @@ sctp6_getaddr(struct socket *so, struct mbuf *nam) stcb = LIST_FIRST(&inp->sctp_asoc_list); if (stcb == NULL) { SCTP_INP_RUNLOCK(inp); -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) SCTP_FREE_SONAME(sin6); #endif SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, ENOENT); @@ -1400,7 +1387,7 @@ sctp6_getaddr(struct socket *so, struct mbuf *nam) if ((!fnd) || (sin_a6 == NULL)) { /* punt */ SCTP_INP_RUNLOCK(inp); -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) SCTP_FREE_SONAME(sin6); #endif SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, ENOENT); @@ -1431,7 +1418,7 @@ sctp6_getaddr(struct socket *so, struct mbuf *nam) } } if (!fnd) { -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) SCTP_FREE_SONAME(sin6); #endif SCTP_INP_RUNLOCK(inp); @@ -1455,21 +1442,17 @@ sctp6_getaddr(struct socket *so, struct mbuf *nam) sin6->sin6_scope_id = 0; /* XXX */ #endif /* SCTP_KAME */ #endif /* SCTP_EMBEDDED_V6_SCOPE */ -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) (*addr) = (struct sockaddr *)sin6; #endif return (0); } static int -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) sctp6_peeraddr(struct socket *so, struct sockaddr **addr) { struct sockaddr_in6 *sin6; -#elif defined(__Panda__) -sctp6_peeraddr(struct socket *so, struct sockaddr *addr) -{ - struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)addr; #else sctp6_peeraddr(struct socket *so, struct mbuf *nam) { @@ -1485,12 +1468,10 @@ sctp6_peeraddr(struct socket *so, struct mbuf *nam) #endif /* Do the malloc first in case it blocks. */ -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) SCTP_MALLOC_SONAME(sin6, struct sockaddr_in6 *, sizeof *sin6); if (sin6 == NULL) return (ENOMEM); -#elif defined(__Panda__) - memset(sin6, 0, sizeof(*sin6)); #else SCTP_BUF_LEN(nam) = sizeof(*sin6); memset(sin6, 0, sizeof(*sin6)); @@ -1504,7 +1485,7 @@ sctp6_peeraddr(struct socket *so, struct mbuf *nam) if ((inp == NULL) || ((inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED) == 0)) { /* UDP type and listeners will drop out here */ -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) SCTP_FREE_SONAME(sin6); #endif SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, ENOTCONN); @@ -1517,7 +1498,7 @@ sctp6_peeraddr(struct socket *so, struct mbuf *nam) } SCTP_INP_RUNLOCK(inp); if (stcb == NULL) { -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) SCTP_FREE_SONAME(sin6); #endif SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, ECONNRESET); @@ -1536,7 +1517,7 @@ sctp6_peeraddr(struct socket *so, struct mbuf *nam) SCTP_TCB_UNLOCK(stcb); if (!fnd) { /* No IPv4 address */ -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) SCTP_FREE_SONAME(sin6); #endif SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, ENOENT); @@ -1545,7 +1526,7 @@ sctp6_peeraddr(struct socket *so, struct mbuf *nam) #ifdef SCTP_EMBEDDED_V6_SCOPE #ifdef SCTP_KAME if ((error = sa6_recoverscope(sin6)) != 0) { -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) SCTP_FREE_SONAME(sin6); #endif SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, error); @@ -1555,21 +1536,16 @@ sctp6_peeraddr(struct socket *so, struct mbuf *nam) in6_recoverscope(sin6, &sin6->sin6_addr, NULL); #endif /* SCTP_KAME */ #endif /* SCTP_EMBEDDED_V6_SCOPE */ -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) *addr = (struct sockaddr *)sin6; #endif return (0); } -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) static int sctp6_in6getaddr(struct socket *so, struct sockaddr **nam) { -#elif defined(__Panda__) -int -sctp6_in6getaddr(struct socket *so, struct sockaddr *nam, uint32_t *namelen) -{ - struct sockaddr *addr = nam; #elif defined(__Userspace__) int sctp6_in6getaddr(struct socket *so, struct mbuf *nam) @@ -1597,7 +1573,7 @@ sctp6_in6getaddr(struct socket *so, struct mbuf *nam) error = sctp6_getaddr(so, nam); #ifdef INET if (error) { -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) struct sockaddr_in6 *sin6; #else struct sockaddr_in6 sin6; @@ -1608,7 +1584,7 @@ sctp6_in6getaddr(struct socket *so, struct mbuf *nam) if (error) { return (error); } -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) SCTP_MALLOC_SONAME(sin6, struct sockaddr_in6 *, sizeof *sin6); if (sin6 == NULL) { SCTP_FREE_SONAME(*nam); @@ -1623,23 +1599,14 @@ sctp6_in6getaddr(struct socket *so, struct mbuf *nam) memcpy(addr, &sin6, sizeof(struct sockaddr_in6)); #endif } -#endif -#if defined(__Panda__) - *namelen = nam->sa_len; #endif return (error); } - -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) static int sctp6_getpeeraddr(struct socket *so, struct sockaddr **nam) { -#elif defined(__Panda__) -int -sctp6_getpeeraddr(struct socket *so, struct sockaddr *nam, uint32_t *namelen) -{ - struct sockaddr *addr = (struct sockaddr *)nam; #elif defined(__Userspace__) int sctp6_getpeeraddr(struct socket *so, struct mbuf *nam) @@ -1669,7 +1636,7 @@ sctp6_getpeeraddr(struct socket *so, struct mbuf *nam) error = sctp6_peeraddr(so, nam); #ifdef INET if (error) { -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) struct sockaddr_in6 *sin6; #else struct sockaddr_in6 sin6; @@ -1680,7 +1647,7 @@ sctp6_getpeeraddr(struct socket *so, struct mbuf *nam) if (error) { return (error); } -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) SCTP_MALLOC_SONAME(sin6, struct sockaddr_in6 *, sizeof *sin6); if (sin6 == NULL) { SCTP_FREE_SONAME(*nam); @@ -1695,14 +1662,11 @@ sctp6_getpeeraddr(struct socket *so, struct mbuf *nam) memcpy(addr, &sin6, sizeof(struct sockaddr_in6)); #endif } -#endif -#if defined(__Panda__) - *namelen = nam->sa_len; #endif return (error); } -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) struct pr_usrreqs sctp6_usrreqs = { #if defined(__FreeBSD__) .pru_abort = sctp6_abort, @@ -1711,15 +1675,10 @@ struct pr_usrreqs sctp6_usrreqs = { .pru_bind = sctp6_bind, .pru_connect = sctp6_connect, .pru_control = in6_control, -#if __FreeBSD_version >= 690000 .pru_close = sctp6_close, .pru_detach = sctp6_close, .pru_sopoll = sopoll_generic, .pru_flush = sctp_flush, -#else - .pru_detach = sctp6_detach, - .pru_sopoll = sopoll, -#endif .pru_disconnect = sctp6_disconnect, .pru_listen = sctp_listen, .pru_peeraddr = sctp6_getpeeraddr, @@ -1728,7 +1687,7 @@ struct pr_usrreqs sctp6_usrreqs = { .pru_sockaddr = sctp6_in6getaddr, .pru_sosend = sctp_sosend, .pru_soreceive = sctp_soreceive -#elif defined(__APPLE__) +#elif defined(__APPLE__) && !defined(__Userspace__) .pru_abort = sctp6_abort, .pru_accept = sctp_accept, .pru_attach = sctp6_attach, @@ -1749,7 +1708,7 @@ struct pr_usrreqs sctp6_usrreqs = { .pru_sosend = sctp_sosend, .pru_soreceive = sctp_soreceive, .pru_sopoll = sopoll -#elif defined(__Windows__) +#elif defined(_WIN32) && !defined(__Userspace__) sctp6_abort, sctp_accept, sctp6_attach, @@ -1776,7 +1735,7 @@ struct pr_usrreqs sctp6_usrreqs = { #endif }; -#elif !defined(__Panda__) && !defined(__Userspace__) +#elif !defined(__Userspace__) int sctp6_usrreq(so, req, m, nam, control, p) struct socket *so; @@ -1784,22 +1743,22 @@ sctp6_usrreq(so, req, m, nam, control, p) struct mbuf *m, *nam, *control; struct proc *p; { - int s; - int error = 0; + int error; int family; - uint32_t vrf_id; + family = so->so_proto->pr_domain->dom_family; if (req == PRU_CONTROL) { switch (family) { case PF_INET: error = in_control(so, (long)m, (caddr_t)nam, - (struct ifnet *)control - ); + (struct ifnet *)control); + break; #ifdef INET6 case PF_INET6: error = in6_control(so, (long)m, (caddr_t)nam, (struct ifnet *)control, p); + break; #endif default: SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, EAFNOSUPPORT); @@ -1883,6 +1842,7 @@ sctp6_usrreq(so, req, m, nam, control, p) error = 0; break; default: + error = 0; break; } return (error); diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet6/sctp6_var.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet6/sctp6_var.h index e10453dae7..56a6c3af3d 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet6/sctp6_var.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/netinet6/sctp6_var.h @@ -32,7 +32,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) && !defined(__Userspace__) #include __FBSDID("$FreeBSD: head/sys/netinet6/sctp6_var.h 317457 2017-04-26 19:26:40Z tuexen $"); #endif @@ -49,40 +49,28 @@ extern void in6_sin_2_v4mapsin6(const struct sockaddr_in *, struct sockaddr_in6 #endif #if defined(_KERNEL) -#if defined(__FreeBSD__) || (__APPLE__) || defined(__Windows__) +#if !defined(__Userspace__) SYSCTL_DECL(_net_inet6_sctp6); extern struct pr_usrreqs sctp6_usrreqs; #else int sctp6_usrreq(struct socket *, int, struct mbuf *, struct mbuf *, struct mbuf *); #endif -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(__Userspace__) int sctp6_input(struct mbuf **, int *); int sctp6_input_with_port(struct mbuf **, int *, uint16_t); -#elif defined(__Panda__) -int sctp6_input (pakhandle_type *); -#elif defined(__FreeBSD__) && __FreeBSD_version < 902000 -int sctp6_input __P((struct mbuf **, int *, int)); -int sctp6_input_with_port __P((struct mbuf **, int *, uint16_t)); #else int sctp6_input(struct mbuf **, int *, int); int sctp6_input_with_port(struct mbuf **, int *, uint16_t); #endif -#if defined(__FreeBSD__) && __FreeBSD_version < 902000 -int sctp6_output -__P((struct sctp_inpcb *, struct mbuf *, struct sockaddr *, - struct mbuf *, struct proc *)); -void sctp6_ctlinput __P((int, struct sockaddr *, void *)); -#else int sctp6_output(struct sctp_inpcb *, struct mbuf *, struct sockaddr *, struct mbuf *, struct proc *); -#if defined(__APPLE__) && !defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) && !defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION) && !defined(APPLE_ELCAPITAN) +#if defined(__APPLE__) && !defined(__Userspace__) && !defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) && !defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION) && !defined(APPLE_ELCAPITAN) void sctp6_ctlinput(int, struct sockaddr *, void *, struct ifnet * SCTP_UNUSED); #else void sctp6_ctlinput(int, struct sockaddr *, void *); #endif -#endif -#if !(defined(__FreeBSD__) || defined(__APPLE__)) +#if !((defined(__FreeBSD__) || defined(__APPLE__)) && !defined(__Userspace__)) extern void in6_sin_2_v4mapsin6(struct sockaddr_in *, struct sockaddr_in6 *); extern void in6_sin6_2_sin(struct sockaddr_in *, struct sockaddr_in6 *); extern void in6_sin6_2_sin_in_sock(struct sockaddr *); diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_atomic.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_atomic.h index 77ea77b671..6a59587efc 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_atomic.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_atomic.h @@ -42,8 +42,8 @@ #include #include -#if defined(__Userspace_os_Darwin) || defined (__Userspace_os_Windows) -#if defined (__Userspace_os_Windows) +#if defined(__APPLE__) || defined(_WIN32) +#if defined(_WIN32) #define atomic_add_int(addr, val) InterlockedExchangeAdd((LPLONG)addr, (LONG)val) #define atomic_fetchadd_int(addr, val) InterlockedExchangeAdd((LPLONG)addr, (LONG)val) #define atomic_subtract_int(addr, val) InterlockedExchangeAdd((LPLONG)addr,-((LONG)val)) @@ -77,7 +77,7 @@ } \ } #endif -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) static void atomic_init(void) {} /* empty when we are not using atomic_mtx */ #else static inline void atomic_init(void) {} /* empty when we are not using atomic_mtx */ @@ -173,7 +173,7 @@ static inline void atomic_init() {} /* empty when we are not using atomic_mtx */ extern userland_mutex_t atomic_mtx; -#if defined (__Userspace_os_Windows) +#if defined(_WIN32) static inline void atomic_init() { InitializeCriticalSection(&atomic_mtx); } diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_environment.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_environment.c index cb77a220e6..1887718911 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_environment.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_environment.c @@ -30,18 +30,23 @@ /* __Userspace__ */ -#include -#if !defined (__Userspace_os_Windows) +#if defined(_WIN32) +#if !defined(_CRT_RAND_S) && !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION) +#define _CRT_RAND_S +#endif +#else #include #include #endif +#ifdef INVARIANTS +#include +#endif #include #include /* #include defines MIN */ #if !defined(MIN) #define MIN(arg1,arg2) ((arg1) < (arg2) ? (arg1) : (arg2)) #endif -#include #define uHZ 1000 @@ -64,50 +69,316 @@ userland_mutex_t atomic_mtx; * provide _some_ kind of randomness. This should only be used * inside other RNG's, like arc4random(9). */ -#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -static int -read_random_phony(void *buf, int count) +#if defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION) +#include + +void +init_random(void) { - memset(buf, 'A', count); - return (count); + return; } -#else -#if defined(__Userspace_os_FreeBSD) || defined(__Userspace_os_Darwin) -static int -read_random_phony(void *buf, int count) + +void +read_random(void *buf, size_t size) { - if (count >= 0) { - arc4random_buf(buf, count); + memset(buf, 'A', size); + return; +} + +void +finish_random(void) +{ + return; +} +/* This define can be used to optionally use OpenSSL's random number utility, + * which is capable of bypassing the chromium sandbox which normally would + * prevent opening files, including /dev/urandom. + */ +#elif defined(SCTP_USE_OPENSSL_RAND) +#include + +/* Requiring BoringSSL because it guarantees that RAND_bytes will succeed. */ +#ifndef OPENSSL_IS_BORINGSSL +#error Only BoringSSL is supported with SCTP_USE_OPENSSL_RAND. +#endif + +void +init_random(void) +{ + return; +} + +void +read_random(void *buf, size_t size) +{ + RAND_bytes((uint8_t *)buf, size); + return; +} + +void +finish_random(void) +{ + return; +} +#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__) || defined(__Bitrig__) +#include + +void +init_random(void) +{ + return; +} + +void +read_random(void *buf, size_t size) +{ + arc4random_buf(buf, size); + return; +} + +void +finish_random(void) +{ + return; +} +#elif defined(_WIN32) +#include + +void +init_random(void) +{ + return; +} + +void +read_random(void *buf, size_t size) +{ + unsigned int randval; + size_t position, remaining; + + position = 0; + while (position < size) { + if (rand_s(&randval) == 0) { + remaining = MIN(size - position, sizeof(unsigned int)); + memcpy((char *)buf + position, &randval, remaining); + position += sizeof(unsigned int); + } } - return (count); + return; } -#else -static int -read_random_phony(void *buf, int count) + +void +finish_random(void) { - uint32_t randval; - int size, i; - - /* srandom() is called in kern/init_main.c:proc0_post() */ - - /* Fill buf[] with random(9) output */ - for (i = 0; i < count; i+= (int)sizeof(uint32_t)) { - randval = random(); - size = MIN(count - i, (int)sizeof(uint32_t)); - memcpy(&((char *)buf)[i], &randval, (size_t)size); - } - - return (count); + return; } +#elif (defined(__ANDROID__) && (__ANDROID_API__ < 28)) || defined(__EMSCRIPTEN__) +#include + +static int fd = -1; + +void +init_random(void) +{ + fd = open("/dev/urandom", O_RDONLY); + return; +} + +void +read_random(void *buf, size_t size) +{ + size_t position; + ssize_t n; + + position = 0; + while (position < size) { + n = read(fd, (char *)buf + position, size - position); + if (n > 0) { + position += n; + } + } + return; +} + +void +finish_random(void) +{ + close(fd); + return; +} +#elif defined(__ANDROID__) && (__ANDROID_API__ >= 28) +#include + +void +init_random(void) +{ + return; +} + +void +read_random(void *buf, size_t size) +{ + size_t position; + ssize_t n; + + position = 0; + while (position < size) { + n = getrandom((char *)buf + position, size - position, 0); + if (n > 0) { + position += n; + } + } + return; +} + +void +finish_random(void) +{ + return; +} +#elif defined(__linux__) +#include +#include +#include + +#if defined(__has_feature) +#if __has_feature(memory_sanitizer) +void __msan_unpoison(void *, size_t); #endif #endif -static int (*read_func)(void *, int) = read_random_phony; +#ifdef __NR_getrandom +#if !defined(GRND_NONBLOCK) +#define GRND_NONBLOCK 1 +#endif +static int getrandom_available = 0; +#endif +static int fd = -1; -/* Userland-visible version of read_random */ -int -read_random(void *buf, int count) +void +init_random(void) { - return ((*read_func)(buf, count)); +#ifdef __NR_getrandom + char dummy; + ssize_t n = syscall(__NR_getrandom, &dummy, sizeof(dummy), GRND_NONBLOCK); + if (n > 0 || errno == EINTR || errno == EAGAIN) { + /* Either getrandom succeeded, was interrupted or is waiting for entropy; + * all of which mean the syscall is available. + */ + getrandom_available = 1; + } else { +#ifdef INVARIANTS + if (errno != ENOSYS) { + panic("getrandom syscall returned unexpected error: %d", errno); + } +#endif + /* If the syscall isn't available, fall back to /dev/urandom. */ +#endif + fd = open("/dev/urandom", O_RDONLY); +#ifdef __NR_getrandom + } +#endif + return; } +void +read_random(void *buf, size_t size) +{ + size_t position; + ssize_t n; + + position = 0; + while (position < size) { +#ifdef __NR_getrandom + if (getrandom_available) { + /* Using syscall directly because getrandom isn't present in glibc < 2.25. + */ + n = syscall(__NR_getrandom, (char *)buf + position, size - position, 0); + if (n > 0) { +#if defined(__has_feature) +#if __has_feature(memory_sanitizer) + /* Need to do this because MSan doesn't realize that syscall has + * initialized the output buffer. + */ + __msan_unpoison(buf + position, n); +#endif +#endif + position += n; + } else if (errno != EINTR && errno != EAGAIN) { +#ifdef INVARIANTS + panic("getrandom syscall returned unexpected error: %d", errno); +#endif + } + } else +#endif /* __NR_getrandom */ + { + n = read(fd, (char *)buf + position, size - position); + if (n > 0) { + position += n; + } + } + } + return; +} + +void +finish_random(void) +{ + if (fd != -1) { + close(fd); + } + return; +} +#elif defined(__Fuchsia__) +#include + +void +init_random(void) +{ + return; +} + +void +read_random(void *buf, size_t size) +{ + zx_cprng_draw(buf, size); + return; +} + +void +finish_random(void) +{ + return; +} +#elif defined(__native_client__) +#include + +void +init_random(void) +{ + return; +} + +void +read_random(void *buf, size_t size) +{ + size_t position; + size_t n; + + position = 0; + while (position < size) { + if (nacl_secure_random((char *)buf + position, size - position, &n) == 0) + position += n; + } + } + return; +} + +void +finish_random(void) +{ + return; +} +#else +#error "Unknown platform. Please provide platform specific RNG." +#endif diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_environment.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_environment.h index 2b40ceebd0..a545accba0 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_environment.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_environment.h @@ -33,12 +33,12 @@ /* __Userspace__ */ #include -#ifdef __Userspace_os_FreeBSD +#ifdef __FreeBSD__ #ifndef _SYS_MUTEX_H_ #include #endif #endif -#if defined (__Userspace_os_Windows) +#if defined(_WIN32) #include "netinet/sctp_os_userspace.h" #endif @@ -63,11 +63,13 @@ extern int ipport_firstauto, ipport_lastauto; extern int nmbclusters; #if !defined(_MSC_VER) && !defined(__MINGW32__) -#define min(a,b) ((a)>(b)?(b):(a)) -#define max(a,b) ((a)>(b)?(a):(b)) +#define min(a,b) (((a)>(b))?(b):(a)) +#define max(a,b) (((a)>(b))?(a):(b)) #endif -extern int read_random(void *buf, int count); +void init_random(void); +void read_random(void *, size_t); +void finish_random(void); /* errno's may differ per OS. errno.h now included in sctp_os_userspace.h */ /* Source: /usr/src/sys/sys/errno.h */ @@ -82,14 +84,18 @@ extern int read_random(void *buf, int count); /* Source ip_output.c. extern'd in ip_var.h */ extern u_short ip_id; -#if defined(__Userspace_os_Linux) +#if defined(__linux__) #define IPV6_VERSION 0x60 #endif #if defined(INVARIANTS) #include -static inline void +#if defined(_WIN32) +static inline void __declspec(noreturn) +#else +static inline void __attribute__((__noreturn__)) +#endif terminate_non_graceful(void) { abort(); } diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_inpcb.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_inpcb.h index 2ac818c702..2e6e9334ea 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_inpcb.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_inpcb.h @@ -10,7 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -54,7 +54,7 @@ LIST_HEAD(inpcbporthead, inpcbport); * the following structure. */ struct in_addr_4in6 { - u_int32_t ia46_pad32[3]; + uint32_t ia46_pad32[3]; struct in_addr ia46_addr4; }; @@ -63,8 +63,8 @@ struct in_addr_4in6 { * some extra padding to accomplish this. */ struct in_endpoints { - u_int16_t ie_fport; /* foreign port */ - u_int16_t ie_lport; /* local port */ + uint16_t ie_fport; /* foreign port */ + uint16_t ie_lport; /* local port */ /* protocol dependent part, local and foreign addr */ union { /* foreign host table entry */ @@ -87,9 +87,9 @@ struct in_endpoints { * references. */ struct in_conninfo { - u_int8_t inc_flags; - u_int8_t inc_len; - u_int16_t inc_pad; /* XXX alignment for in_endpoints */ + uint8_t inc_flags; + uint8_t inc_len; + uint16_t inc_pad; /* XXX alignment for in_endpoints */ /* protocol dependent part */ struct in_endpoints inc_ie; }; @@ -110,7 +110,7 @@ struct inpcb { struct inpcbinfo *inp_pcbinfo; /* PCB list info */ struct socket *inp_socket; /* back pointer to socket */ - u_int32_t inp_flow; + uint32_t inp_flow; int inp_flags; /* generic IP/datagram flags */ u_char inp_vflag; /* IP version flag (v4/v6) */ @@ -329,7 +329,6 @@ struct inpcbinfo { #define INP_CHECK_SOCKAF(so, af) (INP_SOCKAF(so) == af) -/* #ifdef _KERNEL */ extern int ipport_reservedhigh; extern int ipport_reservedlow; extern int ipport_lowfirstauto; @@ -370,6 +369,5 @@ void ipport_tick(void *xtp); */ void db_print_inpcb(struct inpcb *inp, const char *name, int indent); -/* #endif _KERNEL */ #endif /* !_NETINET_IN_PCB_H_ */ diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_ip6_var.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_ip6_var.h index f5e4a60e4f..b970fb8fa5 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_ip6_var.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_ip6_var.h @@ -39,7 +39,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -60,16 +60,16 @@ #ifndef _USER_IP6_VAR_H_ #define _USER_IP6_VAR_H_ -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) struct ip6_hdr { union { struct ip6_hdrctl { - u_int32_t ip6_un1_flow; /* 20 bits of flow-ID */ - u_int16_t ip6_un1_plen; /* payload length */ - u_int8_t ip6_un1_nxt; /* next header */ - u_int8_t ip6_un1_hlim; /* hop limit */ + uint32_t ip6_un1_flow; /* 20 bits of flow-ID */ + uint16_t ip6_un1_plen; /* payload length */ + uint8_t ip6_un1_nxt; /* next header */ + uint8_t ip6_un1_hlim; /* hop limit */ } ip6_un1; - u_int8_t ip6_un2_vfc; /* 4 bits version, top 4 bits class */ + uint8_t ip6_un2_vfc; /* 4 bits version, top 4 bits class */ } ip6_ctlun; struct in6_addr ip6_src; /* source address */ struct in6_addr ip6_dst; /* destination address */ @@ -84,18 +84,16 @@ struct ip6_hdr { #define IPV6_VERSION 0x60 #endif -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) #define s6_addr16 u.Word #endif -#if !defined(__Userspace_os_Windows) -#if !defined(__Userspace_os_Linux) +#if !defined(_WIN32) && !defined(__linux__) && !defined(__EMSCRIPTEN__) #define s6_addr8 __u6_addr.__u6_addr8 #define s6_addr16 __u6_addr.__u6_addr16 #define s6_addr32 __u6_addr.__u6_addr32 #endif -#endif -#if !defined(__Userspace_os_FreeBSD) && !defined(__Userspace_os_OpenBSD) && !defined(__Userspace_os_DragonFly) +#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__DragonFly__) struct route_in6 { struct rtentry *ro_rt; struct llentry *ro_lle; diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_ip_icmp.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_ip_icmp.h index f6fd5487e2..a993411a17 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_ip_icmp.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_ip_icmp.h @@ -10,7 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -40,8 +40,8 @@ * Internal of an ICMP Router Advertisement */ struct icmp_ra_addr { - u_int32_t ira_addr; - u_int32_t ira_preference; + uint32_t ira_addr; + uint32_t ira_preference; }; /* @@ -53,16 +53,16 @@ struct icmphdr { u_short icmp_cksum; /* ones complement cksum of struct */ }; -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) #pragma pack (push, 1) struct icmp6_hdr { - u_int8_t icmp6_type; - u_int8_t icmp6_code; - u_int16_t icmp6_cksum; + uint8_t icmp6_type; + uint8_t icmp6_code; + uint16_t icmp6_cksum; union { - u_int32_t icmp6_un_data32[1]; - u_int16_t icmp6_un_data16[2]; - u_int8_t icmp6_un_data8[4]; + uint32_t icmp6_un_data32[1]; + uint16_t icmp6_un_data16[2]; + uint8_t icmp6_un_data8[4]; } icmp6_dataun; }; #pragma pack(pop) @@ -98,7 +98,7 @@ struct icmp { struct ih_rtradv { u_char irt_num_addrs; u_char irt_wpa; - u_int16_t irt_lifetime; + uint16_t irt_lifetime; } ih_rtradv; } icmp_hun; #define icmp_pptr icmp_hun.ih_pptr @@ -126,7 +126,7 @@ struct icmp { /* options and then 64 bits of data */ } id_ip; struct icmp_ra_addr id_radv; - u_int32_t id_mask; + uint32_t id_mask; char id_data[1]; } icmp_dun; #define icmp_otime icmp_dun.id_ts.its_otime diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_malloc.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_malloc.h index 8d4fe82607..c588e094af 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_malloc.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_malloc.h @@ -12,7 +12,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -37,7 +37,7 @@ /*__Userspace__*/ #include #include -#if !defined (__Userspace_os_Windows) +#if !defined(_WIN32) #include #include #else @@ -200,67 +200,4 @@ Start copy: Copied code for __Userspace__ */ } \ } while (0); - -/* End copy: Copied code for __Userspace__ */ - -#if 0 -#ifdef _KERNEL -#define MALLOC_DEFINE(type, shortdesc, longdesc) \ - struct malloc_type type[1] = { \ - { NULL, 0, 0, 0, 0, 0, M_MAGIC, shortdesc, NULL, NULL, \ - NULL, 0, NULL, NULL, 0, 0 } \ - }; \ - SYSINIT(type##_init, SI_SUB_KMEM, SI_ORDER_SECOND, malloc_init, \ - type); \ - SYSUNINIT(type##_uninit, SI_SUB_KMEM, SI_ORDER_ANY, \ - malloc_uninit, type) - - -#define MALLOC_DECLARE(type) \ - extern struct malloc_type type[1] - -MALLOC_DECLARE(M_CACHE); -MALLOC_DECLARE(M_DEVBUF); -MALLOC_DECLARE(M_TEMP); - -MALLOC_DECLARE(M_IP6OPT); /* for INET6 */ -MALLOC_DECLARE(M_IP6NDP); /* for INET6 */ - -/* - * Deprecated macro versions of not-quite-malloc() and free(). - */ -#define MALLOC(space, cast, size, type, flags) \ - ((space) = (cast)malloc((u_long)(size), (type), (flags))) -#define FREE(addr, type) free((addr), (type)) - -/* - * XXX this should be declared in , but that tends to fail - * because is included in a header before the source file - * has a chance to include to get MALLOC_DECLARE() defined. - */ -MALLOC_DECLARE(M_IOV); - -extern struct mtx malloc_mtx; - -/* XXX struct malloc_type is unused for contig*(). */ -void contigfree(void *addr, unsigned long size, struct malloc_type *type); -void *contigmalloc(unsigned long size, struct malloc_type *type, int flags, - vm_paddr_t low, vm_paddr_t high, unsigned long alignment, - unsigned long boundary); -void free(void *addr, struct malloc_type *type); -void *malloc(unsigned long size, struct malloc_type *type, int flags); -void malloc_init(void *); -int malloc_last_fail(void); -void malloc_type_allocated(struct malloc_type *type, unsigned long size); -void malloc_type_freed(struct malloc_type *type, unsigned long size); -void malloc_uninit(void *); -void *realloc(void *addr, unsigned long size, struct malloc_type *type, - int flags); -void *reallocf(void *addr, unsigned long size, struct malloc_type *type, - int flags); - - -#endif /* _KERNEL */ -#endif - #endif /* !_SYS_MALLOC_H_ */ diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_mbuf.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_mbuf.c index a5037249d6..f95185f06e 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_mbuf.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_mbuf.c @@ -46,7 +46,6 @@ #include "user_atomic.h" #include "netinet/sctp_pcb.h" -struct mbstat mbstat; #define KIPC_MAX_LINKHDR 4 /* int: max length of link header (see sys/sysclt.h) */ #define KIPC_MAX_PROTOHDR 5 /* int: max length of network header (see sys/sysclt.h)*/ int max_linkhdr = KIPC_MAX_LINKHDR; @@ -81,8 +80,6 @@ static void mb_dtor_clust(void *, void *); static int mbuf_constructor_dup(struct mbuf *m, int pkthdr, short type) { int flags = pkthdr; - if (type == MT_NOINIT) - return (0); m->m_next = NULL; m->m_nextpkt = NULL; @@ -272,9 +269,9 @@ m_clget(struct mbuf *m, int how) mclust_ret = SCTP_ZONE_GET(zone_clust, char); #endif /*mclust_ret = umem_cache_alloc(zone_clust, UMEM_DEFAULT);*/ - if (NULL == mclust_ret) { - SCTPDBG(SCTP_DEBUG_USR, "Memory allocation failure in %s\n", __func__); - } + /* if (NULL == mclust_ret) { */ + SCTPDBG(SCTP_DEBUG_USR, "Memory allocation failure in %s\n", __func__); + /* } */ } #if USING_MBUF_CONSTRUCTOR @@ -290,7 +287,7 @@ struct mbuf * m_getm2(struct mbuf *m, int len, int how, short type, int flags, int allonebuf) { struct mbuf *mb, *nm = NULL, *mtail = NULL; - int size = 0, mbuf_threshold, space_needed = len; + int size, mbuf_threshold, space_needed = len; KASSERT(len >= 0, ("%s: len is < 0", __func__)); @@ -473,7 +470,7 @@ m_tag_free(struct m_tag *t) * XXX probably should be called m_tag_init, but that was already taken. */ static __inline void -m_tag_setup(struct m_tag *t, u_int32_t cookie, int type, int len) +m_tag_setup(struct m_tag *t, uint32_t cookie, int type, int len) { t->m_tag_id = type; @@ -507,7 +504,7 @@ mbuf_initialize(void *dummy) #else zone_mbuf = umem_cache_create(MBUF_MEM_NAME, MSIZE, 0, mb_ctor_mbuf, mb_dtor_mbuf, NULL, - NUULL, + NULL, NULL, 0); #endif /*zone_ext_refcnt = umem_cache_create(MBUF_EXTREFCNT_MEM_NAME, sizeof(u_int), 0, @@ -536,26 +533,6 @@ mbuf_initialize(void *dummy) * */ - - /* - * [Re]set counters and local statistics knobs. - * - */ - - mbstat.m_mbufs = 0; - mbstat.m_mclusts = 0; - mbstat.m_drain = 0; - mbstat.m_msize = MSIZE; - mbstat.m_mclbytes = MCLBYTES; - mbstat.m_minclsize = MINCLSIZE; - mbstat.m_mlen = MLEN; - mbstat.m_mhlen = MHLEN; - mbstat.m_numtypes = MT_NTYPES; - - mbstat.m_mcfail = mbstat.m_mpfail = 0; - mbstat.sf_iocnt = 0; - mbstat.sf_allocwait = mbstat.sf_allocfail = 0; - } @@ -598,13 +575,6 @@ mb_ctor_mbuf(void *mem, void *arg, int flgs) flags = args->flags; type = args->type; - /* - * The mbuf is initialized later. - * - */ - if (type == MT_NOINIT) - return (0); - m->m_next = NULL; m->m_nextpkt = NULL; m->m_len = 0; @@ -909,7 +879,6 @@ m_pullup(struct mbuf *n, int len) return (m); bad: m_freem(n); - mbstat.m_mpfail++; /* XXX: No consistency. */ return (NULL); } @@ -1045,16 +1014,14 @@ m_pulldown(struct mbuf *m, int off, int len, int *offp) * easy cases first. * we need to use m_copydata() to get data from m_next, 0>. */ - if ((off == 0 || offp) && M_TRAILINGSPACE(n) >= tlen - && writable) { + if ((off == 0 || offp) && (M_TRAILINGSPACE(n) >= tlen) && writable) { m_copydata(n->m_next, 0, tlen, mtod(n, caddr_t) + n->m_len); n->m_len += tlen; m_adj(n->m_next, tlen); goto ok; } - if ((off == 0 || offp) && M_LEADINGSPACE(n->m_next) >= hlen - && writable) { + if ((off == 0 || offp) && (M_LEADINGSPACE(n->m_next) >= hlen) && writable) { n->m_next->m_data -= hlen; n->m_next->m_len += hlen; memcpy( mtod(n->m_next, caddr_t), mtod(n, caddr_t) + off,hlen); @@ -1198,13 +1165,10 @@ m_copym(struct mbuf *m, int off0, int len, int wait) m = m->m_next; np = &n->m_next; } - if (top == NULL) - mbstat.m_mcfail++; /* XXX: No consistency. */ return (top); nospace: m_freem(top); - mbstat.m_mcfail++; /* XXX: No consistency. */ return (NULL); } @@ -1266,7 +1230,7 @@ m_tag_copy(struct m_tag *t, int how) /* Get a packet tag structure along with specified data following. */ struct m_tag * -m_tag_alloc(u_int32_t cookie, int type, int len, int wait) +m_tag_alloc(uint32_t cookie, int type, int len, int wait) { struct m_tag *t; diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_mbuf.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_mbuf.h index 9c5d0d7ef4..dc17250684 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_mbuf.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_mbuf.h @@ -110,7 +110,7 @@ void m_cat(struct mbuf *m, struct mbuf *n); void m_adj(struct mbuf *, int); void mb_free_ext(struct mbuf *); void m_freem(struct mbuf *); -struct m_tag *m_tag_alloc(u_int32_t, int, int, int); +struct m_tag *m_tag_alloc(uint32_t, int, int, int); struct mbuf *m_copym(struct mbuf *, int, int, int); void m_copyback(struct mbuf *, int, int, caddr_t); struct mbuf *m_pullup(struct mbuf *, int); @@ -125,38 +125,6 @@ void m_copydata(const struct mbuf *, int, int, caddr_t); #define MBUF_CLUSTER_MEM_NAME "mbuf_cluster" #define MBUF_EXTREFCNT_MEM_NAME "mbuf_ext_refcnt" -#define MT_NOINIT 255 /* Not a type but a flag to allocate - a non-initialized mbuf */ - -/* - * General mbuf allocator statistics structure. - * __Userspace__ mbstat may be useful for gathering statistics. - * In the kernel many of these statistics are no longer used as - * they track allocator statistics through kernel UMA's built in statistics mechanism. - */ -struct mbstat { - u_long m_mbufs; /* XXX */ - u_long m_mclusts; /* XXX */ - - u_long m_drain; /* times drained protocols for space */ - u_long m_mcfail; /* XXX: times m_copym failed */ - u_long m_mpfail; /* XXX: times m_pullup failed */ - u_long m_msize; /* length of an mbuf */ - u_long m_mclbytes; /* length of an mbuf cluster */ - u_long m_minclsize; /* min length of data to allocate a cluster */ - u_long m_mlen; /* length of data in an mbuf */ - u_long m_mhlen; /* length of data in a header mbuf */ - - /* Number of mbtypes (gives # elems in mbtypes[] array: */ - short m_numtypes; - - /* XXX: Sendfile stats should eventually move to their own struct */ - u_long sf_iocnt; /* times sendfile had to do disk I/O */ - u_long sf_allocfail; /* times sfbuf allocation failed */ - u_long sf_allocwait; /* times sfbuf allocation had to wait */ -}; - - /* * Mbufs are of a single size, MSIZE (sys/param.h), which includes overhead. * An mbuf may add a single "mbuf cluster" of size MCLBYTES (also in @@ -190,9 +158,9 @@ struct m_hdr { */ struct m_tag { SLIST_ENTRY(m_tag) m_tag_link; /* List of packet tags */ - u_int16_t m_tag_id; /* Tag ID */ - u_int16_t m_tag_len; /* Length of data */ - u_int32_t m_tag_cookie; /* ABI/Module ID */ + uint16_t m_tag_id; /* Tag ID */ + uint16_t m_tag_len; /* Length of data */ + uint32_t m_tag_cookie; /* ABI/Module ID */ void (*m_tag_free)(struct m_tag *); }; @@ -207,8 +175,8 @@ struct pkthdr { /* variables for hardware checksum */ int csum_flags; /* flags regarding checksum */ int csum_data; /* data field used by csum routines */ - u_int16_t tso_segsz; /* TSO segment size */ - u_int16_t ether_vtag; /* Ethernet 802.1p+q vlan tag */ + uint16_t tso_segsz; /* TSO segment size */ + uint16_t ether_vtag; /* Ethernet 802.1p+q vlan tag */ SLIST_HEAD(packet_tags, m_tag) tags; /* list of packet tags */ }; @@ -322,9 +290,6 @@ struct mbuf { #define MT_OOBDATA 15 /* expedited data */ #define MT_NTYPES 16 /* number of mbuf types for mbtypes[] */ -#define MT_NOINIT 255 /* Not a type but a flag to allocate - a non-initialized mbuf */ - /* * __Userspace__ flags like M_NOWAIT are defined in malloc.h * Flags like these are used in functions like uma_zalloc() @@ -352,9 +317,6 @@ void m_tag_free_default(struct m_tag *); extern int max_linkhdr; /* Largest link-level header */ extern int max_protohdr; /* Size of largest protocol layer header. See user_mbuf.c */ -extern struct mbstat mbstat; /* General mbuf stats/infos */ - - /* * Evaluate TRUE if it's safe to write to the mbuf m's data region (this can * be both the local data payload, or an external buffer area, depending on @@ -373,9 +335,9 @@ extern struct mbstat mbstat; /* General mbuf stats/infos */ * of checking writability of the mbuf data area rests solely with the caller. */ #define M_LEADINGSPACE(m) \ - ((m)->m_flags & M_EXT ? \ + (((m)->m_flags & M_EXT) ? \ (M_WRITABLE(m) ? (m)->m_data - (m)->m_ext.ext_buf : 0): \ - (m)->m_flags & M_PKTHDR ? (m)->m_data - (m)->m_pktdat : \ + ((m)->m_flags & M_PKTHDR)? (m)->m_data - (m)->m_pktdat : \ (m)->m_data - (m)->m_dat) /* @@ -385,7 +347,7 @@ extern struct mbstat mbstat; /* General mbuf stats/infos */ * of checking writability of the mbuf data area rests solely with the caller. */ #define M_TRAILINGSPACE(m) \ - ((m)->m_flags & M_EXT ? \ + (((m)->m_flags & M_EXT) ? \ (M_WRITABLE(m) ? (m)->m_ext.ext_buf + (m)->m_ext.ext_size \ - ((m)->m_data + (m)->m_len) : 0) : \ &(m)->m_dat[MLEN] - ((m)->m_data + (m)->m_len)) @@ -437,4 +399,9 @@ extern struct mbstat mbstat; /* General mbuf stats/infos */ (m)->m_data += (MHLEN - (len)) & ~(sizeof(long) - 1); \ } while (0) +#define M_SIZE(m) \ + (((m)->m_flags & M_EXT) ? (m)->m_ext.ext_size : \ + ((m)->m_flags & M_PKTHDR) ? MHLEN : \ + MLEN) + #endif diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_queue.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_queue.h index 44f8994902..fcd368bdd2 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_queue.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_queue.h @@ -10,7 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -144,8 +144,8 @@ struct name { \ #define SLIST_HEAD_INITIALIZER(head) \ { NULL } -#if defined (__Userspace_os_Windows) -#if defined (SLIST_ENTRY) +#if defined(_WIN32) +#if defined(SLIST_ENTRY) #undef SLIST_ENTRY #endif #endif diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_recv_thread.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_recv_thread.c index ae5e517daf..66be13d749 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_recv_thread.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_recv_thread.c @@ -30,12 +30,12 @@ #if defined(INET) || defined(INET6) #include -#if !defined(__Userspace_os_Windows) +#if !defined(_WIN32) #include #include #include #include -#if !defined(__Userspace_os_DragonFly) && !defined(__Userspace_os_FreeBSD) && !defined(__Userspace_os_NetBSD) +#if !defined(__DragonFly__) && !defined(__FreeBSD__) && !defined(__NetBSD__) #include #else #include @@ -46,7 +46,7 @@ #include #include #if 0 -#if defined(__Userspace_os_Linux) +#if defined(__linux__) #include #ifdef HAVE_LINUX_IF_ADDR_H #include @@ -56,23 +56,32 @@ #endif #endif #endif -#if defined(__Userspace_os_Darwin) || defined(__Userspace_os_DragonFly) || defined(__Userspace_os_FreeBSD) -#include +#if defined(HAVE_NET_ROUTE_H) +# include +#elif defined(__APPLE__) +/* Apple SDKs for iOS, tvOS, watchOS, etc. don't ship this header */ +# define RTM_NEWADDR 0xc +# define RTM_DELADDR 0xd +# define RTAX_IFA 5 +# define RTAX_MAX 8 #endif /* local macros and datatypes used to get IP addresses system independently */ -#if !defined(IP_PKTINFO ) && ! defined(IP_RECVDSTADDR) +#if !defined(IP_PKTINFO) && !defined(IP_RECVDSTADDR) # error "Can't determine socket option to use to get UDP IP" #endif void recv_thread_destroy(void); -#define MAXLEN_MBUF_CHAIN 32 /* What should this value be? */ + +#define MAXLEN_MBUF_CHAIN 128 + #define ROUNDUP(a, size) (((a) & ((size)-1)) ? (1 + ((a) | ((size)-1))) : (a)) -#if defined(__Userspace_os_Darwin) || defined(__Userspace_os_DragonFly) || defined(__Userspace_os_FreeBSD) + +#if defined(__APPLE__) || defined(__DragonFly__) || defined(__FreeBSD__) #define NEXT_SA(ap) ap = (struct sockaddr *) \ ((caddr_t) ap + (ap->sa_len ? ROUNDUP(ap->sa_len, sizeof (uint32_t)) : sizeof(uint32_t))) #endif -#if defined(__Userspace_os_Darwin) || defined(__Userspace_os_DragonFly) || defined(__Userspace_os_FreeBSD) +#if defined(__APPLE__) || defined(__DragonFly__) || defined(__FreeBSD__) static void sctp_get_rtaddrs(int addrs, struct sockaddr *sa, struct sockaddr **rti_info) { @@ -270,7 +279,8 @@ recv_function_raw(void *arg) int compute_crc = 1; struct sctp_chunkhdr *ch; struct sockaddr_in src, dst; -#if !defined(__Userspace_os_Windows) +#if !defined(_WIN32) + ssize_t res; unsigned int ncounter; struct msghdr msg; struct iovec recv_iovec[MAXLEN_MBUF_CHAIN]; @@ -305,7 +315,7 @@ recv_function_raw(void *arg) Have tried both sending and receiving */ recvmbuf[i] = sctp_get_mbuf_for_msg(iovlen, want_header, M_NOWAIT, want_ext, MT_DATA); -#if !defined(__Userspace_os_Windows) +#if !defined(_WIN32) recv_iovec[i].iov_base = (caddr_t)recvmbuf[i]->m_data; recv_iovec[i].iov_len = iovlen; #else @@ -314,7 +324,7 @@ recv_function_raw(void *arg) #endif } to_fill = 0; -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) flags = 0; ncounter = 0; fromlen = sizeof(struct sockaddr_in); @@ -337,14 +347,16 @@ recv_function_raw(void *arg) msg.msg_iovlen = MAXLEN_MBUF_CHAIN; msg.msg_control = NULL; msg.msg_controllen = 0; - ncounter = n = recvmsg(SCTP_BASE_VAR(userspace_rawsctp), &msg, 0); - if (n < 0) { + res = recvmsg(SCTP_BASE_VAR(userspace_rawsctp), &msg, 0); + if (res < 0) { if (errno == EAGAIN || errno == EINTR) { continue; } else { break; } } + ncounter = (unsigned int)res; + n = (int)res; #endif SCTP_HEADER_LEN(recvmbuf[0]) = n; /* length of total packet */ SCTP_STAT_INCR(sctps_recvpackets); @@ -368,13 +380,20 @@ recv_function_raw(void *arg) } while (ncounter > 0); } + offset = sizeof(struct ip) + sizeof(struct sctphdr) + sizeof(struct sctp_chunkhdr); + if (SCTP_BUF_LEN(recvmbuf[0]) < offset) { + if ((recvmbuf[0] = m_pullup(recvmbuf[0], offset)) == NULL) { + SCTP_STAT_INCR(sctps_hdrops); + continue; + } + } iphdr = mtod(recvmbuf[0], struct ip *); sh = (struct sctphdr *)((caddr_t)iphdr + sizeof(struct ip)); ch = (struct sctp_chunkhdr *)((caddr_t)sh + sizeof(struct sctphdr)); - offset = sizeof(struct ip) + sizeof(struct sctphdr); + offset -= sizeof(struct sctp_chunkhdr); if (iphdr->ip_tos != 0) { - ecn = iphdr->ip_tos & 0x02; + ecn = iphdr->ip_tos & 0x03; } dst.sin_family = AF_INET; @@ -430,7 +449,7 @@ recv_function_raw(void *arg) } /* free the array itself */ free(recvmbuf); - SCTPDBG(SCTP_DEBUG_USR, "%s: Exiting SCTP/IP4 rcv", __func__); + SCTPDBG(SCTP_DEBUG_USR, "%s: Exiting SCTP/IP4 rcv\n", __func__); return (NULL); } #endif @@ -440,8 +459,9 @@ static void * recv_function_raw6(void *arg) { struct mbuf **recvmbuf6; -#if !defined(__Userspace_os_Windows) - unsigned int ncounter = 0; +#if !defined(_WIN32) + ssize_t res; + unsigned int ncounter; struct iovec recv_iovec[MAXLEN_MBUF_CHAIN]; struct msghdr msg; struct cmsghdr *cmsgptr; @@ -482,7 +502,7 @@ recv_function_raw6(void *arg) Have tried both sending and receiving */ recvmbuf6[i] = sctp_get_mbuf_for_msg(iovlen, want_header, M_NOWAIT, want_ext, MT_DATA); -#if !defined(__Userspace_os_Windows) +#if !defined(_WIN32) recv_iovec[i].iov_base = (caddr_t)recvmbuf6[i]->m_data; recv_iovec[i].iov_len = iovlen; #else @@ -491,7 +511,7 @@ recv_function_raw6(void *arg) #endif } to_fill = 0; -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) ncounter = 0; memset(&from, 0, sizeof(struct sockaddr_in6)); nResult = WSAIoctl(SCTP_BASE_VAR(userspace_rawsctp6), SIO_GET_EXTENSION_FUNCTION_POINTER, @@ -528,15 +548,16 @@ recv_function_raw6(void *arg) msg.msg_control = (void *)cmsgbuf; msg.msg_controllen = (socklen_t)CMSG_SPACE(sizeof (struct in6_pktinfo)); msg.msg_flags = 0; - - ncounter = n = recvmsg(SCTP_BASE_VAR(userspace_rawsctp6), &msg, 0); - if (n < 0) { + res = recvmsg(SCTP_BASE_VAR(userspace_rawsctp6), &msg, 0); + if (res < 0) { if (errno == EAGAIN || errno == EINTR) { continue; } else { break; } } + ncounter = (unsigned int)res; + n = (int)res; #endif SCTP_HEADER_LEN(recvmbuf6[0]) = n; /* length of total packet */ SCTP_STAT_INCR(sctps_recvpackets); @@ -576,9 +597,16 @@ recv_function_raw6(void *arg) continue; } + offset = sizeof(struct sctphdr) + sizeof(struct sctp_chunkhdr); + if (SCTP_BUF_LEN(recvmbuf6[0]) < offset) { + if ((recvmbuf6[0] = m_pullup(recvmbuf6[0], offset)) == NULL) { + SCTP_STAT_INCR(sctps_hdrops); + continue; + } + } sh = mtod(recvmbuf6[0], struct sctphdr *); ch = (struct sctp_chunkhdr *)((caddr_t)sh + sizeof(struct sctphdr)); - offset = sizeof(struct sctphdr); + offset -= sizeof(struct sctp_chunkhdr); dst.sin6_family = AF_INET6; #ifdef HAVE_SIN6_LEN @@ -591,7 +619,8 @@ recv_function_raw6(void *arg) src.sin6_len = sizeof(struct sockaddr_in6); #endif src.sin6_port = sh->src_port; - if (memcmp(&src.sin6_addr, &dst.sin6_addr, sizeof(struct in6_addr)) == 0) { + if (SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback) && + (memcmp(&src.sin6_addr, &dst.sin6_addr, sizeof(struct in6_addr)) == 0)) { compute_crc = 0; SCTP_STAT_INCR(sctps_recvhwcrc); } else { @@ -615,7 +644,7 @@ recv_function_raw6(void *arg) } /* free the array itself */ free(recvmbuf6); - SCTPDBG(SCTP_DEBUG_USR, "%s: Exiting SCTP/IP6 rcv", __func__); + SCTPDBG(SCTP_DEBUG_USR, "%s: Exiting SCTP/IP6 rcv\n", __func__); return (NULL); } #endif @@ -643,7 +672,8 @@ recv_function_udp(void *arg) char cmsgbuf[CMSG_SPACE(sizeof(struct in_addr))]; #endif int compute_crc = 1; -#if !defined(__Userspace_os_Windows) +#if !defined(_WIN32) + ssize_t res; unsigned int ncounter; struct iovec iov[MAXLEN_MBUF_CHAIN]; struct msghdr msg; @@ -670,7 +700,7 @@ recv_function_udp(void *arg) Have tried both sending and receiving */ udprecvmbuf[i] = sctp_get_mbuf_for_msg(iovlen, want_header, M_NOWAIT, want_ext, MT_DATA); -#if !defined(__Userspace_os_Windows) +#if !defined(_WIN32) iov[i].iov_base = (caddr_t)udprecvmbuf[i]->m_data; iov[i].iov_len = iovlen; #else @@ -679,7 +709,7 @@ recv_function_udp(void *arg) #endif } to_fill = 0; -#if !defined(__Userspace_os_Windows) +#if !defined(_WIN32) memset(&msg, 0, sizeof(struct msghdr)); #else memset(&msg, 0, sizeof(WSAMSG)); @@ -688,7 +718,7 @@ recv_function_udp(void *arg) memset(&dst, 0, sizeof(struct sockaddr_in)); memset(cmsgbuf, 0, sizeof(cmsgbuf)); -#if !defined(__Userspace_os_Windows) +#if !defined(_WIN32) msg.msg_name = (void *)&src; msg.msg_namelen = sizeof(struct sockaddr_in); msg.msg_iov = iov; @@ -697,14 +727,16 @@ recv_function_udp(void *arg) msg.msg_controllen = sizeof(cmsgbuf); msg.msg_flags = 0; - ncounter = n = recvmsg(SCTP_BASE_VAR(userspace_udpsctp), &msg, 0); - if (n < 0) { + res = recvmsg(SCTP_BASE_VAR(userspace_udpsctp), &msg, 0); + if (res < 0) { if (errno == EAGAIN || errno == EINTR) { continue; } else { break; } } + ncounter = (unsigned int)res; + n = (int)res; #else nResult = WSAIoctl(SCTP_BASE_VAR(userspace_udpsctp), SIO_GET_EXTENSION_FUNCTION_POINTER, &WSARecvMsg_GUID, sizeof WSARecvMsg_GUID, @@ -789,14 +821,22 @@ recv_function_udp(void *arg) continue; } - /*offset = sizeof(struct sctphdr) + sizeof(struct sctp_chunkhdr);*/ + offset = sizeof(struct sctphdr) + sizeof(struct sctp_chunkhdr); + if (SCTP_BUF_LEN(udprecvmbuf[0]) < offset) { + if ((udprecvmbuf[0] = m_pullup(udprecvmbuf[0], offset)) == NULL) { + SCTP_STAT_INCR(sctps_hdrops); + continue; + } + } sh = mtod(udprecvmbuf[0], struct sctphdr *); ch = (struct sctp_chunkhdr *)((caddr_t)sh + sizeof(struct sctphdr)); - offset = sizeof(struct sctphdr); + offset -= sizeof(struct sctp_chunkhdr); + port = src.sin_port; src.sin_port = sh->src_port; dst.sin_port = sh->dest_port; - if (src.sin_addr.s_addr == dst.sin_addr.s_addr) { + if (SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback) && + (src.sin_addr.s_addr == dst.sin_addr.s_addr)) { compute_crc = 0; SCTP_STAT_INCR(sctps_recvhwcrc); } else { @@ -820,7 +860,7 @@ recv_function_udp(void *arg) } /* free the array itself */ free(udprecvmbuf); - SCTPDBG(SCTP_DEBUG_USR, "%s: Exiting SCTP/UDP/IP4 rcv", __func__); + SCTPDBG(SCTP_DEBUG_USR, "%s: Exiting SCTP/UDP/IP4 rcv\n", __func__); return (NULL); } #endif @@ -844,10 +884,11 @@ recv_function_udp6(void *arg) struct sctp_chunkhdr *ch; char cmsgbuf[CMSG_SPACE(sizeof (struct in6_pktinfo))]; int compute_crc = 1; -#if !defined(__Userspace_os_Windows) +#if !defined(_WIN32) struct iovec iov[MAXLEN_MBUF_CHAIN]; struct msghdr msg; struct cmsghdr *cmsgptr; + ssize_t res; unsigned int ncounter; #else GUID WSARecvMsg_GUID = WSAID_WSARECVMSG; @@ -870,7 +911,7 @@ recv_function_udp6(void *arg) Have tried both sending and receiving */ udprecvmbuf6[i] = sctp_get_mbuf_for_msg(iovlen, want_header, M_NOWAIT, want_ext, MT_DATA); -#if !defined(__Userspace_os_Windows) +#if !defined(_WIN32) iov[i].iov_base = (caddr_t)udprecvmbuf6[i]->m_data; iov[i].iov_len = iovlen; #else @@ -880,7 +921,7 @@ recv_function_udp6(void *arg) } to_fill = 0; -#if !defined(__Userspace_os_Windows) +#if !defined(_WIN32) memset(&msg, 0, sizeof(struct msghdr)); #else memset(&msg, 0, sizeof(WSAMSG)); @@ -889,7 +930,7 @@ recv_function_udp6(void *arg) memset(&dst, 0, sizeof(struct sockaddr_in6)); memset(cmsgbuf, 0, CMSG_SPACE(sizeof (struct in6_pktinfo))); -#if !defined(__Userspace_os_Windows) +#if !defined(_WIN32) msg.msg_name = (void *)&src; msg.msg_namelen = sizeof(struct sockaddr_in6); msg.msg_iov = iov; @@ -898,14 +939,16 @@ recv_function_udp6(void *arg) msg.msg_controllen = (socklen_t)CMSG_SPACE(sizeof (struct in6_pktinfo)); msg.msg_flags = 0; - ncounter = n = recvmsg(SCTP_BASE_VAR(userspace_udpsctp6), &msg, 0); - if (n < 0) { + res = recvmsg(SCTP_BASE_VAR(userspace_udpsctp6), &msg, 0); + if (res < 0) { if (errno == EAGAIN || errno == EINTR) { continue; } else { break; } } + ncounter = (unsigned int)res; + n = (int)res; #else nResult = WSAIoctl(SCTP_BASE_VAR(userspace_udpsctp6), SIO_GET_EXTENSION_FUNCTION_POINTER, &WSARecvMsg_GUID, sizeof WSARecvMsg_GUID, @@ -976,14 +1019,22 @@ recv_function_udp6(void *arg) continue; } + offset = sizeof(struct sctphdr) + sizeof(struct sctp_chunkhdr); + if (SCTP_BUF_LEN(udprecvmbuf6[0]) < offset) { + if ((udprecvmbuf6[0] = m_pullup(udprecvmbuf6[0], offset)) == NULL) { + SCTP_STAT_INCR(sctps_hdrops); + continue; + } + } sh = mtod(udprecvmbuf6[0], struct sctphdr *); ch = (struct sctp_chunkhdr *)((caddr_t)sh + sizeof(struct sctphdr)); - offset = sizeof(struct sctphdr); + offset -= sizeof(struct sctp_chunkhdr); port = src.sin6_port; src.sin6_port = sh->src_port; dst.sin6_port = sh->dest_port; - if ((memcmp(&src.sin6_addr, &dst.sin6_addr, sizeof(struct in6_addr)) == 0)) { + if (SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback) && + (memcmp(&src.sin6_addr, &dst.sin6_addr, sizeof(struct in6_addr)) == 0)) { compute_crc = 0; SCTP_STAT_INCR(sctps_recvhwcrc); } else { @@ -1007,12 +1058,12 @@ recv_function_udp6(void *arg) } /* free the array itself */ free(udprecvmbuf6); - SCTPDBG(SCTP_DEBUG_USR, "%s: Exiting SCTP/UDP/IP6 rcv", __func__); + SCTPDBG(SCTP_DEBUG_USR, "%s: Exiting SCTP/UDP/IP6 rcv\n", __func__); return (NULL); } #endif -#if defined (__Userspace_os_Windows) +#if defined(_WIN32) static void setReceiveBufferSize(SOCKET sfd, int new_size) #else @@ -1023,7 +1074,7 @@ setReceiveBufferSize(int sfd, int new_size) int ch = new_size; if (setsockopt (sfd, SOL_SOCKET, SO_RCVBUF, (void*)&ch, sizeof(ch)) < 0) { -#if defined (__Userspace_os_Windows) +#if defined(_WIN32) SCTPDBG(SCTP_DEBUG_USR, "Can't set recv-buffers size (errno = %d).\n", WSAGetLastError()); #else SCTPDBG(SCTP_DEBUG_USR, "Can't set recv-buffers size (errno = %d).\n", errno); @@ -1032,7 +1083,7 @@ setReceiveBufferSize(int sfd, int new_size) return; } -#if defined (__Userspace_os_Windows) +#if defined(_WIN32) static void setSendBufferSize(SOCKET sfd, int new_size) #else @@ -1043,7 +1094,7 @@ setSendBufferSize(int sfd, int new_size) int ch = new_size; if (setsockopt (sfd, SOL_SOCKET, SO_SNDBUF, (void*)&ch, sizeof(ch)) < 0) { -#if defined (__Userspace_os_Windows) +#if defined(_WIN32) SCTPDBG(SCTP_DEBUG_USR, "Can't set send-buffers size (errno = %d).\n", WSAGetLastError()); #else SCTPDBG(SCTP_DEBUG_USR, "Can't set send-buffers size (errno = %d).\n", errno); @@ -1066,7 +1117,7 @@ recv_thread_init(void) #if defined(INET) || defined(INET6) const int on = 1; #endif -#if !defined(__Userspace_os_Windows) +#if !defined(_WIN32) struct timeval timeout; memset(&timeout, 0, sizeof(struct timeval)); @@ -1075,7 +1126,7 @@ recv_thread_init(void) #else unsigned int timeout = SOCKET_TIMEOUT; /* Timeout in milliseconds */ #endif -#if defined(__Userspace_os_Darwin) || defined(__Userspace_os_DragonFly) || defined(__Userspace_os_FreeBSD) +#if defined(__APPLE__) || defined(__DragonFly__) || defined(__FreeBSD__) if (SCTP_BASE_VAR(userspace_route) == -1) { if ((SCTP_BASE_VAR(userspace_route) = socket(AF_ROUTE, SOCK_RAW, 0)) == -1) { SCTPDBG(SCTP_DEBUG_USR, "Can't create routing socket (errno = %d).\n", errno); @@ -1104,7 +1155,7 @@ recv_thread_init(void) if (SCTP_BASE_VAR(userspace_route) != -1) { if (setsockopt(SCTP_BASE_VAR(userspace_route), SOL_SOCKET, SO_RCVTIMEO,(const void*)&timeout, sizeof(struct timeval)) < 0) { SCTPDBG(SCTP_DEBUG_USR, "Can't set timeout on routing socket (errno = %d).\n", errno); -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) closesocket(SCTP_BASE_VAR(userspace_route)); #else close(SCTP_BASE_VAR(userspace_route)); @@ -1117,7 +1168,7 @@ recv_thread_init(void) #if defined(INET) if (SCTP_BASE_VAR(userspace_rawsctp) == -1) { if ((SCTP_BASE_VAR(userspace_rawsctp) = socket(AF_INET, SOCK_RAW, IPPROTO_SCTP)) == -1) { -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) SCTPDBG(SCTP_DEBUG_USR, "Can't create raw socket for IPv4 (errno = %d).\n", WSAGetLastError()); #else SCTPDBG(SCTP_DEBUG_USR, "Can't create raw socket for IPv4 (errno = %d).\n", errno); @@ -1125,7 +1176,7 @@ recv_thread_init(void) } else { /* complete setting up the raw SCTP socket */ if (setsockopt(SCTP_BASE_VAR(userspace_rawsctp), IPPROTO_IP, IP_HDRINCL,(const void*)&hdrincl, sizeof(int)) < 0) { -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) SCTPDBG(SCTP_DEBUG_USR, "Can't set IP_HDRINCL (errno = %d).\n", WSAGetLastError()); closesocket(SCTP_BASE_VAR(userspace_rawsctp)); #else @@ -1134,7 +1185,7 @@ recv_thread_init(void) #endif SCTP_BASE_VAR(userspace_rawsctp) = -1; } else if (setsockopt(SCTP_BASE_VAR(userspace_rawsctp), SOL_SOCKET, SO_RCVTIMEO, (const void *)&timeout, sizeof(timeout)) < 0) { -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) SCTPDBG(SCTP_DEBUG_USR, "Can't set timeout on socket for SCTP/IPv4 (errno = %d).\n", WSAGetLastError()); closesocket(SCTP_BASE_VAR(userspace_rawsctp)); #else @@ -1151,7 +1202,7 @@ recv_thread_init(void) addr_ipv4.sin_port = htons(0); addr_ipv4.sin_addr.s_addr = htonl(INADDR_ANY); if (bind(SCTP_BASE_VAR(userspace_rawsctp), (const struct sockaddr *)&addr_ipv4, sizeof(struct sockaddr_in)) < 0) { -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) SCTPDBG(SCTP_DEBUG_USR, "Can't bind socket for SCTP/IPv4 (errno = %d).\n", WSAGetLastError()); closesocket(SCTP_BASE_VAR(userspace_rawsctp)); #else @@ -1166,9 +1217,9 @@ recv_thread_init(void) } } } - if (SCTP_BASE_VAR(userspace_udpsctp) == -1) { + if ((SCTP_BASE_VAR(userspace_udpsctp) == -1) && (SCTP_BASE_SYSCTL(sctp_udp_tunneling_port) != 0)) { if ((SCTP_BASE_VAR(userspace_udpsctp) = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) { -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) SCTPDBG(SCTP_DEBUG_USR, "Can't create socket for SCTP/UDP/IPv4 (errno = %d).\n", WSAGetLastError()); #else SCTPDBG(SCTP_DEBUG_USR, "Can't create socket for SCTP/UDP/IPv4 (errno = %d).\n", errno); @@ -1179,7 +1230,7 @@ recv_thread_init(void) #else if (setsockopt(SCTP_BASE_VAR(userspace_udpsctp), IPPROTO_IP, IP_RECVDSTADDR, (const void *)&on, (int)sizeof(int)) < 0) { #endif -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) #if defined(IP_PKTINFO) SCTPDBG(SCTP_DEBUG_USR, "Can't set IP_PKTINFO on socket for SCTP/UDP/IPv4 (errno = %d).\n", WSAGetLastError()); #else @@ -1196,7 +1247,7 @@ recv_thread_init(void) #endif SCTP_BASE_VAR(userspace_udpsctp) = -1; } else if (setsockopt(SCTP_BASE_VAR(userspace_udpsctp), SOL_SOCKET, SO_RCVTIMEO, (const void *)&timeout, sizeof(timeout)) < 0) { -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) SCTPDBG(SCTP_DEBUG_USR, "Can't set timeout on socket for SCTP/UDP/IPv4 (errno = %d).\n", WSAGetLastError()); closesocket(SCTP_BASE_VAR(userspace_udpsctp)); #else @@ -1213,7 +1264,7 @@ recv_thread_init(void) addr_ipv4.sin_port = htons(SCTP_BASE_SYSCTL(sctp_udp_tunneling_port)); addr_ipv4.sin_addr.s_addr = htonl(INADDR_ANY); if (bind(SCTP_BASE_VAR(userspace_udpsctp), (const struct sockaddr *)&addr_ipv4, sizeof(struct sockaddr_in)) < 0) { -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) SCTPDBG(SCTP_DEBUG_USR, "Can't bind socket for SCTP/UDP/IPv4 (errno = %d).\n", WSAGetLastError()); closesocket(SCTP_BASE_VAR(userspace_udpsctp)); #else @@ -1232,7 +1283,7 @@ recv_thread_init(void) #if defined(INET6) if (SCTP_BASE_VAR(userspace_rawsctp6) == -1) { if ((SCTP_BASE_VAR(userspace_rawsctp6) = socket(AF_INET6, SOCK_RAW, IPPROTO_SCTP)) == -1) { -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) SCTPDBG(SCTP_DEBUG_USR, "Can't create socket for SCTP/IPv6 (errno = %d).\n", WSAGetLastError()); #else SCTPDBG(SCTP_DEBUG_USR, "Can't create socket for SCTP/IPv6 (errno = %d).\n", errno); @@ -1241,7 +1292,7 @@ recv_thread_init(void) /* complete setting up the raw SCTP socket */ #if defined(IPV6_RECVPKTINFO) if (setsockopt(SCTP_BASE_VAR(userspace_rawsctp6), IPPROTO_IPV6, IPV6_RECVPKTINFO, (const void *)&on, sizeof(on)) < 0) { -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) SCTPDBG(SCTP_DEBUG_USR, "Can't set IPV6_RECVPKTINFO on socket for SCTP/IPv6 (errno = %d).\n", WSAGetLastError()); closesocket(SCTP_BASE_VAR(userspace_rawsctp6)); #else @@ -1252,7 +1303,7 @@ recv_thread_init(void) } else { #else if (setsockopt(SCTP_BASE_VAR(userspace_rawsctp6), IPPROTO_IPV6, IPV6_PKTINFO,(const void*)&on, sizeof(on)) < 0) { -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) SCTPDBG(SCTP_DEBUG_USR, "Can't set IPV6_PKTINFO on socket for SCTP/IPv6 (errno = %d).\n", WSAGetLastError()); closesocket(SCTP_BASE_VAR(userspace_rawsctp6)); #else @@ -1263,14 +1314,14 @@ recv_thread_init(void) } else { #endif if (setsockopt(SCTP_BASE_VAR(userspace_rawsctp6), IPPROTO_IPV6, IPV6_V6ONLY, (const void*)&on, (socklen_t)sizeof(on)) < 0) { -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) SCTPDBG(SCTP_DEBUG_USR, "Can't set IPV6_V6ONLY on socket for SCTP/IPv6 (errno = %d).\n", WSAGetLastError()); #else SCTPDBG(SCTP_DEBUG_USR, "Can't set IPV6_V6ONLY on socket for SCTP/IPv6 (errno = %d).\n", errno); #endif } if (setsockopt(SCTP_BASE_VAR(userspace_rawsctp6), SOL_SOCKET, SO_RCVTIMEO, (const void *)&timeout, sizeof(timeout)) < 0) { -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) SCTPDBG(SCTP_DEBUG_USR, "Can't set timeout on socket for SCTP/IPv6 (errno = %d).\n", WSAGetLastError()); closesocket(SCTP_BASE_VAR(userspace_rawsctp6)); #else @@ -1287,7 +1338,7 @@ recv_thread_init(void) addr_ipv6.sin6_port = htons(0); addr_ipv6.sin6_addr = in6addr_any; if (bind(SCTP_BASE_VAR(userspace_rawsctp6), (const struct sockaddr *)&addr_ipv6, sizeof(struct sockaddr_in6)) < 0) { -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) SCTPDBG(SCTP_DEBUG_USR, "Can't bind socket for SCTP/IPv6 (errno = %d).\n", WSAGetLastError()); closesocket(SCTP_BASE_VAR(userspace_rawsctp6)); #else @@ -1303,9 +1354,9 @@ recv_thread_init(void) } } } - if (SCTP_BASE_VAR(userspace_udpsctp6) == -1) { + if ((SCTP_BASE_VAR(userspace_udpsctp6) == -1) && (SCTP_BASE_SYSCTL(sctp_udp_tunneling_port) != 0)) { if ((SCTP_BASE_VAR(userspace_udpsctp6) = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP)) == -1) { -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) SCTPDBG(SCTP_DEBUG_USR, "Can't create socket for SCTP/UDP/IPv6 (errno = %d).\n", WSAGetLastError()); #else SCTPDBG(SCTP_DEBUG_USR, "Can't create socket for SCTP/UDP/IPv6 (errno = %d).\n", errno); @@ -1313,7 +1364,7 @@ recv_thread_init(void) } #if defined(IPV6_RECVPKTINFO) if (setsockopt(SCTP_BASE_VAR(userspace_udpsctp6), IPPROTO_IPV6, IPV6_RECVPKTINFO, (const void *)&on, (int)sizeof(int)) < 0) { -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) SCTPDBG(SCTP_DEBUG_USR, "Can't set IPV6_RECVPKTINFO on socket for SCTP/UDP/IPv6 (errno = %d).\n", WSAGetLastError()); closesocket(SCTP_BASE_VAR(userspace_udpsctp6)); #else @@ -1324,7 +1375,7 @@ recv_thread_init(void) } else { #else if (setsockopt(SCTP_BASE_VAR(userspace_udpsctp6), IPPROTO_IPV6, IPV6_PKTINFO, (const void *)&on, (int)sizeof(int)) < 0) { -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) SCTPDBG(SCTP_DEBUG_USR, "Can't set IPV6_PKTINFO on socket for SCTP/UDP/IPv6 (errno = %d).\n", WSAGetLastError()); closesocket(SCTP_BASE_VAR(userspace_udpsctp6)); #else @@ -1335,14 +1386,14 @@ recv_thread_init(void) } else { #endif if (setsockopt(SCTP_BASE_VAR(userspace_udpsctp6), IPPROTO_IPV6, IPV6_V6ONLY, (const void *)&on, (socklen_t)sizeof(on)) < 0) { -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) SCTPDBG(SCTP_DEBUG_USR, "Can't set IPV6_V6ONLY on socket for SCTP/UDP/IPv6 (errno = %d).\n", WSAGetLastError()); #else SCTPDBG(SCTP_DEBUG_USR, "Can't set IPV6_V6ONLY on socket for SCTP/UDP/IPv6 (errno = %d).\n", errno); #endif } if (setsockopt(SCTP_BASE_VAR(userspace_udpsctp6), SOL_SOCKET, SO_RCVTIMEO, (const void *)&timeout, sizeof(timeout)) < 0) { -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) SCTPDBG(SCTP_DEBUG_USR, "Can't set timeout on socket for SCTP/UDP/IPv6 (errno = %d).\n", WSAGetLastError()); closesocket(SCTP_BASE_VAR(userspace_udpsctp6)); #else @@ -1359,7 +1410,7 @@ recv_thread_init(void) addr_ipv6.sin6_port = htons(SCTP_BASE_SYSCTL(sctp_udp_tunneling_port)); addr_ipv6.sin6_addr = in6addr_any; if (bind(SCTP_BASE_VAR(userspace_udpsctp6), (const struct sockaddr *)&addr_ipv6, sizeof(struct sockaddr_in6)) < 0) { -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) SCTPDBG(SCTP_DEBUG_USR, "Can't bind socket for SCTP/UDP/IPv6 (errno = %d).\n", WSAGetLastError()); closesocket(SCTP_BASE_VAR(userspace_udpsctp6)); #else @@ -1375,7 +1426,7 @@ recv_thread_init(void) } } #endif -#if defined(__Userspace_os_Darwin) || defined(__Userspace_os_DragonFly) || defined(__Userspace_os_FreeBSD) +#if defined(__APPLE__) || defined(__DragonFly__) || defined(__FreeBSD__) #if defined(INET) || defined(INET6) if (SCTP_BASE_VAR(userspace_route) != -1) { int rc; @@ -1394,7 +1445,7 @@ recv_thread_init(void) if ((rc = sctp_userspace_thread_create(&SCTP_BASE_VAR(recvthreadraw), &recv_function_raw))) { SCTPDBG(SCTP_DEBUG_USR, "Can't start SCTP/IPv4 recv thread (%d).\n", rc); -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) closesocket(SCTP_BASE_VAR(userspace_rawsctp)); #else close(SCTP_BASE_VAR(userspace_rawsctp)); @@ -1407,7 +1458,7 @@ recv_thread_init(void) if ((rc = sctp_userspace_thread_create(&SCTP_BASE_VAR(recvthreadudp), &recv_function_udp))) { SCTPDBG(SCTP_DEBUG_USR, "Can't start SCTP/UDP/IPv4 recv thread (%d).\n", rc); -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) closesocket(SCTP_BASE_VAR(userspace_udpsctp)); #else close(SCTP_BASE_VAR(userspace_udpsctp)); @@ -1422,7 +1473,7 @@ recv_thread_init(void) if ((rc = sctp_userspace_thread_create(&SCTP_BASE_VAR(recvthreadraw6), &recv_function_raw6))) { SCTPDBG(SCTP_DEBUG_USR, "Can't start SCTP/IPv6 recv thread (%d).\n", rc); -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) closesocket(SCTP_BASE_VAR(userspace_rawsctp6)); #else close(SCTP_BASE_VAR(userspace_rawsctp6)); @@ -1435,7 +1486,7 @@ recv_thread_init(void) if ((rc = sctp_userspace_thread_create(&SCTP_BASE_VAR(recvthreadudp6), &recv_function_udp6))) { SCTPDBG(SCTP_DEBUG_USR, "Can't start SCTP/UDP/IPv6 recv thread (%d).\n", rc); -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) closesocket(SCTP_BASE_VAR(userspace_udpsctp6)); #else close(SCTP_BASE_VAR(userspace_udpsctp6)); @@ -1449,42 +1500,63 @@ recv_thread_init(void) void recv_thread_destroy(void) { -#if defined(__Userspace_os_Darwin) || defined(__Userspace_os_DragonFly) || defined(__Userspace_os_FreeBSD) +#if defined(__APPLE__) || defined(__DragonFly__) || defined(__FreeBSD__) #if defined(INET) || defined(INET6) if (SCTP_BASE_VAR(userspace_route) != -1) { close(SCTP_BASE_VAR(userspace_route)); + pthread_join(SCTP_BASE_VAR(recvthreadroute), NULL); } #endif #endif #if defined(INET) if (SCTP_BASE_VAR(userspace_rawsctp) != -1) { -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) closesocket(SCTP_BASE_VAR(userspace_rawsctp)); + SCTP_BASE_VAR(userspace_rawsctp) = -1; + WaitForSingleObject(SCTP_BASE_VAR(recvthreadraw), INFINITE); + CloseHandle(SCTP_BASE_VAR(recvthreadraw)); #else close(SCTP_BASE_VAR(userspace_rawsctp)); + SCTP_BASE_VAR(userspace_rawsctp) = -1; + pthread_join(SCTP_BASE_VAR(recvthreadraw), NULL); #endif } if (SCTP_BASE_VAR(userspace_udpsctp) != -1) { -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) closesocket(SCTP_BASE_VAR(userspace_udpsctp)); + SCTP_BASE_VAR(userspace_udpsctp) = -1; + WaitForSingleObject(SCTP_BASE_VAR(recvthreadudp), INFINITE); + CloseHandle(SCTP_BASE_VAR(recvthreadudp)); #else close(SCTP_BASE_VAR(userspace_udpsctp)); + SCTP_BASE_VAR(userspace_udpsctp) = -1; + pthread_join(SCTP_BASE_VAR(recvthreadudp), NULL); #endif } #endif #if defined(INET6) if (SCTP_BASE_VAR(userspace_rawsctp6) != -1) { -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) closesocket(SCTP_BASE_VAR(userspace_rawsctp6)); + SCTP_BASE_VAR(userspace_rawsctp6) = -1; + WaitForSingleObject(SCTP_BASE_VAR(recvthreadraw6), INFINITE); + CloseHandle(SCTP_BASE_VAR(recvthreadraw6)); #else close(SCTP_BASE_VAR(userspace_rawsctp6)); + SCTP_BASE_VAR(userspace_rawsctp6) = -1; + pthread_join(SCTP_BASE_VAR(recvthreadraw6), NULL); #endif } if (SCTP_BASE_VAR(userspace_udpsctp6) != -1) { -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) + SCTP_BASE_VAR(userspace_udpsctp6) = -1; closesocket(SCTP_BASE_VAR(userspace_udpsctp6)); + WaitForSingleObject(SCTP_BASE_VAR(recvthreadudp6), INFINITE); + CloseHandle(SCTP_BASE_VAR(recvthreadudp6)); #else close(SCTP_BASE_VAR(userspace_udpsctp6)); + SCTP_BASE_VAR(userspace_udpsctp6) = -1; + pthread_join(SCTP_BASE_VAR(recvthreadudp6), NULL); #endif } #endif diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_route.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_route.h index 82b07d769a..4abf2eac98 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_route.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_route.h @@ -10,7 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_socket.c b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_socket.c index 146a6d9f95..5535e4e96b 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_socket.c +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_socket.c @@ -44,13 +44,13 @@ #ifdef INET6 #include #endif -#if defined(__Userspace_os_FreeBSD) +#if defined(__FreeBSD__) #include #endif -#if defined(__Userspace_os_Linux) +#if defined(__linux__) #define __FAVOR_BSD /* (on Ubuntu at least) enables UDP header field names like BSD in RFC 768 */ #endif -#if !defined (__Userspace_os_Windows) +#if !defined(_WIN32) #if defined INET || defined INET6 #include #endif @@ -79,7 +79,7 @@ extern int sctp_attach(struct socket *so, int proto, uint32_t vrf_id); extern int sctpconn_attach(struct socket *so, int proto, uint32_t vrf_id); static void init_sync(void) { -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) #if defined(INET) || defined(INET6) WSADATA wsaData; @@ -115,8 +115,8 @@ usrsctp_init(uint16_t port, void usrsctp_init_nothreads(uint16_t port, - int (*conn_output)(void *addr, void *buffer, size_t length, uint8_t tos, uint8_t set_df), - void (*debug_printf)(const char *format, ...)) + int (*conn_output)(void *addr, void *buffer, size_t length, uint8_t tos, uint8_t set_df), + void (*debug_printf)(const char *format, ...)) { init_sync(); sctp_init(port, conn_output, debug_printf, 0); @@ -169,28 +169,17 @@ socantsendmore(struct socket *so) int sbwait(struct sockbuf *sb) { -#if defined(__Userspace__) /* __Userspace__ */ - SOCKBUF_LOCK_ASSERT(sb); sb->sb_flags |= SB_WAIT; -#if defined (__Userspace_os_Windows) +#if defined(_WIN32) if (SleepConditionVariableCS(&(sb->sb_cond), &(sb->sb_mtx), INFINITE)) - return 0; + return (0); else - return -1; + return (-1); #else return (pthread_cond_wait(&(sb->sb_cond), &(sb->sb_mtx))); #endif - -#else - SOCKBUF_LOCK_ASSERT(sb); - - sb->sb_flags |= SB_WAIT; - return (msleep(&sb->sb_cc, &sb->sb_mtx, - (sb->sb_flags & SB_NOINTR) ? PSOCK : PSOCK | PCATCH, "sbwait", - sb->sb_timeo)); -#endif } @@ -394,7 +383,7 @@ void wakeup(void *ident, struct socket *so) { SOCK_LOCK(so); -#if defined (__Userspace_os_Windows) +#if defined(_WIN32) WakeAllConditionVariable(&(so)->timeo_cond); #else pthread_cond_broadcast(&(so)->timeo_cond); @@ -420,7 +409,7 @@ wakeup_one(void *ident) subsidiary sockets. */ ACCEPT_LOCK(); -#if defined (__Userspace_os_Windows) +#if defined(_WIN32) WakeAllConditionVariable(&accept_cond); #else pthread_cond_broadcast(&accept_cond); @@ -568,28 +557,6 @@ sonewconn(struct socket *head, int connstatus) } -/* From /src/sys/sys/sysproto.h */ -struct sctp_generic_sendmsg_args { - int sd; - caddr_t msg; - int mlen; - caddr_t to; - socklen_t tolen; /* was __socklen_t */ - struct sctp_sndrcvinfo * sinfo; - int flags; -}; - -struct sctp_generic_recvmsg_args { - int sd; - struct iovec *iov; - int iovlen; - struct sockaddr *from; - socklen_t *fromlenaddr; /* was __socklen_t */ - struct sctp_sndrcvinfo *sinfo; - int *msg_flags; -}; - - /* Source: /src/sys/gnu/fs/xfs/FreeBSD/xfs_ioctl.c */ @@ -774,11 +741,11 @@ userspace_sctp_sendmsg(struct socket *so, size_t len, struct sockaddr *to, socklen_t tolen, - u_int32_t ppid, - u_int32_t flags, - u_int16_t stream_no, - u_int32_t timetolive, - u_int32_t context) + uint32_t ppid, + uint32_t flags, + uint16_t stream_no, + uint32_t timetolive, + uint32_t context) { struct sctp_sndrcvinfo sndrcvinfo, *sinfo = &sndrcvinfo; struct uio auio; @@ -958,11 +925,11 @@ userspace_sctp_sendmbuf(struct socket *so, size_t len, struct sockaddr *to, socklen_t tolen, - u_int32_t ppid, - u_int32_t flags, - u_int16_t stream_no, - u_int32_t timetolive, - u_int32_t context) + uint32_t ppid, + uint32_t flags, + uint16_t stream_no, + uint32_t timetolive, + uint32_t context) { struct sctp_sndrcvinfo sndrcvinfo, *sinfo = &sndrcvinfo; @@ -1068,7 +1035,7 @@ userspace_sctp_recvmsg(struct socket *so, if (error) { if ((auio.uio_resid != ulen) && (error == EINTR || -#if !defined(__Userspace_os_NetBSD) +#if !defined(__NetBSD__) error == ERESTART || #endif error == EWOULDBLOCK)) { @@ -1161,7 +1128,7 @@ usrsctp_recvv(struct socket *so, if (errno) { if ((auio.uio_resid != ulen) && (errno == EINTR || -#if !defined(__Userspace_os_NetBSD) +#if !defined(__NetBSD__) errno == ERESTART || #endif errno == EWOULDBLOCK)) { @@ -1260,7 +1227,6 @@ out: -#if defined(__Userspace__) /* Taken from /src/sys/kern/uipc_socket.c * and modified for __Userspace__ * socreate returns a socket. The socket should be @@ -1331,74 +1297,6 @@ socreate(int dom, struct socket **aso, int type, int proto) *aso = so; return (0); } -#else -/* The kernel version for reference is below. The #else - should be removed once the __Userspace__ - version is tested. - * socreate returns a socket with a ref count of 1. The socket should be - * closed with soclose(). - */ -int -socreate(int dom, struct socket **aso, int type, int proto, - struct ucred *cred, struct thread *td) -{ - struct protosw *prp; - struct socket *so; - int error; - - if (proto) - prp = pffindproto(dom, proto, type); - else - prp = pffindtype(dom, type); - - if (prp == NULL || prp->pr_usrreqs->pru_attach == NULL || - prp->pr_usrreqs->pru_attach == pru_attach_notsupp) - return (EPROTONOSUPPORT); - - if (jailed(cred) && jail_socket_unixiproute_only && - prp->pr_domain->dom_family != PF_LOCAL && - prp->pr_domain->dom_family != PF_INET && - prp->pr_domain->dom_family != PF_ROUTE) { - return (EPROTONOSUPPORT); - } - - if (prp->pr_type != type) - return (EPROTOTYPE); - so = soalloc(); - if (so == NULL) - return (ENOBUFS); - - TAILQ_INIT(&so->so_incomp); - TAILQ_INIT(&so->so_comp); - so->so_type = type; - so->so_cred = crhold(cred); - so->so_proto = prp; -#ifdef MAC - mac_create_socket(cred, so); -#endif - knlist_init(&so->so_rcv.sb_sel.si_note, SOCKBUF_MTX(&so->so_rcv), - NULL, NULL, NULL); - knlist_init(&so->so_snd.sb_sel.si_note, SOCKBUF_MTX(&so->so_snd), - NULL, NULL, NULL); - so->so_count = 1; - /* - * Auto-sizing of socket buffers is managed by the protocols and - * the appropriate flags must be set in the pru_attach function. - */ - error = (*prp->pr_usrreqs->pru_attach)(so, proto, td); - if (error) { - KASSERT(so->so_count == 1, ("socreate: so_count %d", - so->so_count)); - so->so_count = 0; - sodealloc(so); - return (error); - } - *aso = so; - return (0); -} -#endif - - /* Taken from /src/sys/kern/uipc_syscalls.c @@ -1426,11 +1324,11 @@ struct socket * usrsctp_socket(int domain, int type, int protocol, int (*receive_cb)(struct socket *sock, union sctp_sockstore addr, void *data, size_t datalen, struct sctp_rcvinfo, int flags, void *ulp_info), - int (*send_cb)(struct socket *sock, uint32_t sb_free), + int (*send_cb)(struct socket *sock, uint32_t sb_free, void *ulp_info), uint32_t sb_threshold, void *ulp_info) { - struct socket *so; + struct socket *so = NULL; if ((protocol == IPPROTO_SCTP) && (SCTP_BASE_VAR(sctp_pcb_initialized) == 0)) { errno = EPROTONOSUPPORT; @@ -1493,7 +1391,6 @@ sbreserve(struct sockbuf *sb, u_long cc, struct socket *so) return (error); } -#if defined(__Userspace__) int soreserve(struct socket *so, u_long sndcc, u_long rcvcc) { @@ -1523,45 +1420,12 @@ soreserve(struct socket *so, u_long sndcc, u_long rcvcc) SOCKBUF_UNLOCK(&so->so_snd); return (ENOBUFS); } -#else /* kernel version for reference */ -int -soreserve(struct socket *so, u_long sndcc, u_long rcvcc) -{ - struct thread *td = curthread; - - SOCKBUF_LOCK(&so->so_snd); - SOCKBUF_LOCK(&so->so_rcv); - if (sbreserve_locked(&so->so_snd, sndcc, so, td) == 0) - goto bad; - if (sbreserve_locked(&so->so_rcv, rcvcc, so, td) == 0) - goto bad2; - if (so->so_rcv.sb_lowat == 0) - so->so_rcv.sb_lowat = 1; - if (so->so_snd.sb_lowat == 0) - so->so_snd.sb_lowat = MCLBYTES; - if (so->so_snd.sb_lowat > so->so_snd.sb_hiwat) - so->so_snd.sb_lowat = so->so_snd.sb_hiwat; - SOCKBUF_UNLOCK(&so->so_rcv); - SOCKBUF_UNLOCK(&so->so_snd); - return (0); -bad2: - sbrelease_locked(&so->so_snd, so); -bad: - SOCKBUF_UNLOCK(&so->so_rcv); - SOCKBUF_UNLOCK(&so->so_snd); - return (ENOBUFS); -} -#endif - - - /* Taken from /src/sys/kern/uipc_sockbuf.c * and modified for __Userspace__ */ -#if defined(__Userspace__) void sowakeup(struct socket *so, struct sockbuf *sb) { @@ -1571,7 +1435,7 @@ sowakeup(struct socket *so, struct sockbuf *sb) sb->sb_flags &= ~SB_SEL; if (sb->sb_flags & SB_WAIT) { sb->sb_flags &= ~SB_WAIT; -#if defined (__Userspace_os_Windows) +#if defined(_WIN32) WakeAllConditionVariable(&(sb)->sb_cond); #else pthread_cond_broadcast(&(sb)->sb_cond); @@ -1579,43 +1443,6 @@ sowakeup(struct socket *so, struct sockbuf *sb) } SOCKBUF_UNLOCK(sb); } -#else /* kernel version for reference */ -/* - * Wakeup processes waiting on a socket buffer. Do asynchronous notification - * via SIGIO if the socket has the SS_ASYNC flag set. - * - * Called with the socket buffer lock held; will release the lock by the end - * of the function. This allows the caller to acquire the socket buffer lock - * while testing for the need for various sorts of wakeup and hold it through - * to the point where it's no longer required. We currently hold the lock - * through calls out to other subsystems (with the exception of kqueue), and - * then release it to avoid lock order issues. It's not clear that's - * correct. - */ -void -sowakeup(struct socket *so, struct sockbuf *sb) -{ - - SOCKBUF_LOCK_ASSERT(sb); - - selwakeuppri(&sb->sb_sel, PSOCK); - sb->sb_flags &= ~SB_SEL; - if (sb->sb_flags & SB_WAIT) { - sb->sb_flags &= ~SB_WAIT; - wakeup(&sb->sb_cc); - } - KNOTE_LOCKED(&sb->sb_sel.si_note, 0); - SOCKBUF_UNLOCK(sb); - if ((so->so_state & SS_ASYNC) && so->so_sigio != NULL) - pgsigio(&so->so_sigio, SIGIO, 0); - if (sb->sb_flags & SB_UPCALL) - (*so->so_upcall)(so, so->so_upcallarg, M_NOWAIT); - if (sb->sb_flags & SB_AIO) - aio_swake(so, sb); - mtx_assert(SOCKBUF_MTX(sb), MA_NOTOWNED); -} -#endif - /* Taken from /src/sys/kern/uipc_socket.c @@ -1787,7 +1614,7 @@ user_accept(struct socket *head, struct sockaddr **name, socklen_t *namelen, st head->so_error = ECONNABORTED; break; } -#if defined (__Userspace_os_Windows) +#if defined(_WIN32) if (SleepConditionVariableCS(&accept_cond, &accept_mtx, INFINITE)) error = 0; else @@ -2051,7 +1878,7 @@ soconnect(struct socket *so, struct sockaddr *nam) * Otherwise, if connected, try to disconnect first. This allows * user to disconnect by connecting to, e.g., a null address. */ - if (so->so_state & (SS_ISCONNECTED|SS_ISCONNECTING) && (error = sodisconnect(so))) { + if (so->so_state & (SS_ISCONNECTED|SS_ISCONNECTING) && (sodisconnect(so) != 0)) { error = EISCONN; } else { /* @@ -2108,7 +1935,7 @@ int user_connect(struct socket *so, struct sockaddr *sa) SOCK_LOCK(so); while ((so->so_state & SS_ISCONNECTING) && so->so_error == 0) { -#if defined (__Userspace_os_Windows) +#if defined(_WIN32) if (SleepConditionVariableCS(SOCK_COND(so), SOCK_MTX(so), INFINITE)) error = 0; else @@ -2117,7 +1944,7 @@ int user_connect(struct socket *so, struct sockaddr *sa) error = pthread_cond_wait(SOCK_COND(so), SOCK_MTX(so)); #endif if (error) { -#if defined(__Userspace_os_NetBSD) +#if defined(__NetBSD__) if (error == EINTR) { #else if (error == EINTR || error == ERESTART) { @@ -2137,7 +1964,7 @@ bad: if (!interrupted) { so->so_state &= ~SS_ISCONNECTING; } -#if !defined(__Userspace_os_NetBSD) +#if !defined(__NetBSD__) if (error == ERESTART) { error = EINTR; } @@ -2247,7 +2074,7 @@ usrsctp_finish(void) return (-1); } sctp_finish(); -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) DeleteConditionVariable(&accept_cond); DeleteCriticalSection(&accept_mtx); #if defined(INET) || defined(INET6) @@ -2383,7 +2210,7 @@ usrsctp_getsockopt(struct socket *so, int level, int option_name, int *buf_size; buf_size = (int *)option_value; - *buf_size = so->so_rcv.sb_hiwat;; + *buf_size = so->so_rcv.sb_hiwat; *option_len = (socklen_t)sizeof(int); return (0); } @@ -2583,10 +2410,16 @@ usrsctp_set_ulpinfo(struct socket *so, void *ulp_info) return (register_ulp_info(so, ulp_info)); } + +int +usrsctp_get_ulpinfo(struct socket *so, void **pulp_info) +{ + return (retrieve_ulp_info(so, pulp_info)); +} + int usrsctp_bindx(struct socket *so, struct sockaddr *addrs, int addrcnt, int flags) { - struct sctp_getaddresses *gaddrs; struct sockaddr *sa; #ifdef INET struct sockaddr_in *sin; @@ -2595,9 +2428,9 @@ usrsctp_bindx(struct socket *so, struct sockaddr *addrs, int addrcnt, int flags) struct sockaddr_in6 *sin6; #endif int i; - size_t argsz; #if defined(INET) || defined(INET6) - uint16_t sport = 0; + uint16_t sport; + bool fix_port; #endif /* validate the flags */ @@ -2611,6 +2444,10 @@ usrsctp_bindx(struct socket *so, struct sockaddr *addrs, int addrcnt, int flags) errno = EINVAL; return (-1); } +#if defined(INET) || defined(INET6) + sport = 0; + fix_port = false; +#endif /* First pre-screen the addresses */ sa = addrs; for (i = 0; i < addrcnt; i++) { @@ -2635,6 +2472,7 @@ usrsctp_bindx(struct socket *so, struct sockaddr *addrs, int addrcnt, int flags) } else { /* save off the port */ sport = sin->sin_port; + fix_port = (i > 0); } } #ifndef HAVE_SA_LEN @@ -2662,6 +2500,7 @@ usrsctp_bindx(struct socket *so, struct sockaddr *addrs, int addrcnt, int flags) } else { /* save off the port */ sport = sin6->sin6_port; + fix_port = (i > 0); } } #ifndef HAVE_SA_LEN @@ -2678,41 +2517,30 @@ usrsctp_bindx(struct socket *so, struct sockaddr *addrs, int addrcnt, int flags) sa = (struct sockaddr *)((caddr_t)sa + sa->sa_len); #endif } - argsz = sizeof(struct sctp_getaddresses) + - sizeof(struct sockaddr_storage); - if ((gaddrs = (struct sctp_getaddresses *)malloc(argsz)) == NULL) { - errno = ENOMEM; - return (-1); - } sa = addrs; for (i = 0; i < addrcnt; i++) { #ifndef HAVE_SA_LEN size_t sa_len; + #endif - memset(gaddrs, 0, argsz); - gaddrs->sget_assoc_id = 0; #ifdef HAVE_SA_LEN - memcpy(gaddrs->addr, sa, sa->sa_len); #if defined(INET) || defined(INET6) - if ((i == 0) && (sport != 0)) { - switch (gaddrs->addr->sa_family) { + if (fix_port) { + switch (sa->sa_family) { #ifdef INET case AF_INET: - sin = (struct sockaddr_in *)gaddrs->addr; - sin->sin_port = sport; + ((struct sockaddr_in *)sa)->sin_port = sport; break; #endif #ifdef INET6 case AF_INET6: - sin6 = (struct sockaddr_in6 *)gaddrs->addr; - sin6->sin6_port = sport; + ((struct sockaddr_in6 *)sa)->sin6_port = sport; break; #endif } } #endif - if (usrsctp_setsockopt(so, IPPROTO_SCTP, flags, gaddrs, (socklen_t)argsz) != 0) { - free(gaddrs); + if (usrsctp_setsockopt(so, IPPROTO_SCTP, flags, sa, sa->sa_len) != 0) { return (-1); } sa = (struct sockaddr *)((caddr_t)sa + sa->sa_len); @@ -2732,38 +2560,33 @@ usrsctp_bindx(struct socket *so, struct sockaddr *addrs, int addrcnt, int flags) sa_len = 0; break; } - memcpy(gaddrs->addr, sa, sa_len); /* * Now, if there was a port mentioned, assure that the * first address has that port to make sure it fails or * succeeds correctly. */ #if defined(INET) || defined(INET6) - if ((i == 0) && (sport != 0)) { - switch (gaddrs->addr->sa_family) { + if (fix_port) { + switch (sa->sa_family) { #ifdef INET case AF_INET: - sin = (struct sockaddr_in *)gaddrs->addr; - sin->sin_port = sport; + ((struct sockaddr_in *)sa)->sin_port = sport; break; #endif #ifdef INET6 case AF_INET6: - sin6 = (struct sockaddr_in6 *)gaddrs->addr; - sin6->sin6_port = sport; + ((struct sockaddr_in6 *)sa)->sin6_port = sport; break; #endif } } #endif - if (usrsctp_setsockopt(so, IPPROTO_SCTP, flags, gaddrs, (socklen_t)argsz) != 0) { - free(gaddrs); + if (usrsctp_setsockopt(so, IPPROTO_SCTP, flags, sa, (socklen_t)sa_len) != 0) { return (-1); } sa = (struct sockaddr *)((caddr_t)sa + sa_len); #endif } - free(gaddrs); return (0); } @@ -2872,22 +2695,26 @@ usrsctp_getpaddrs(struct socket *so, sctp_assoc_t id, struct sockaddr **raddrs) { struct sctp_getaddresses *addrs; struct sockaddr *sa; - sctp_assoc_t asoc; caddr_t lim; socklen_t opt_len; + uint32_t size_of_addresses; int cnt; if (raddrs == NULL) { errno = EFAULT; return (-1); } - asoc = id; - opt_len = (socklen_t)sizeof(sctp_assoc_t); - if (usrsctp_getsockopt(so, IPPROTO_SCTP, SCTP_GET_REMOTE_ADDR_SIZE, &asoc, &opt_len) != 0) { - return (-1); + /* When calling getsockopt(), the value contains the assoc_id. */ + size_of_addresses = (uint32_t)id; + opt_len = (socklen_t)sizeof(uint32_t); + if (usrsctp_getsockopt(so, IPPROTO_SCTP, SCTP_GET_REMOTE_ADDR_SIZE, &size_of_addresses, &opt_len) != 0) { + if (errno == ENOENT) { + return (0); + } else { + return (-1); + } } - /* size required is returned in 'asoc' */ - opt_len = (socklen_t)((size_t)asoc + sizeof(struct sctp_getaddresses)); + opt_len = (socklen_t)((size_t)size_of_addresses + sizeof(struct sctp_getaddresses)); addrs = calloc(1, (size_t)opt_len); if (addrs == NULL) { errno = ENOMEM; @@ -2899,9 +2726,9 @@ usrsctp_getpaddrs(struct socket *so, sctp_assoc_t id, struct sockaddr **raddrs) free(addrs); return (-1); } - *raddrs = (struct sockaddr *)&addrs->addr[0]; + *raddrs = &addrs->addr[0].sa; cnt = 0; - sa = (struct sockaddr *)&addrs->addr[0]; + sa = &addrs->addr[0].sa; lim = (caddr_t)addrs + opt_len; #ifdef HAVE_SA_LEN while (((caddr_t)sa < lim) && (sa->sa_len > 0)) { @@ -2938,7 +2765,7 @@ usrsctp_freepaddrs(struct sockaddr *addrs) /* Take away the hidden association id */ void *fr_addr; - fr_addr = (void *)((caddr_t)addrs - sizeof(sctp_assoc_t)); + fr_addr = (void *)((caddr_t)addrs - offsetof(struct sctp_getaddresses, addr)); /* Now free it */ free(fr_addr); } @@ -2947,10 +2774,10 @@ int usrsctp_getladdrs(struct socket *so, sctp_assoc_t id, struct sockaddr **raddrs) { struct sctp_getaddresses *addrs; - caddr_t lim; struct sockaddr *sa; - size_t size_of_addresses; + caddr_t lim; socklen_t opt_len; + uint32_t size_of_addresses; int cnt; if (raddrs == NULL) { @@ -2958,18 +2785,11 @@ usrsctp_getladdrs(struct socket *so, sctp_assoc_t id, struct sockaddr **raddrs) return (-1); } size_of_addresses = 0; - opt_len = (socklen_t)sizeof(int); + opt_len = (socklen_t)sizeof(uint32_t); if (usrsctp_getsockopt(so, IPPROTO_SCTP, SCTP_GET_LOCAL_ADDR_SIZE, &size_of_addresses, &opt_len) != 0) { - errno = ENOMEM; return (-1); } - if (size_of_addresses == 0) { - errno = ENOTCONN; - return (-1); - } - opt_len = (socklen_t)(size_of_addresses + - sizeof(struct sockaddr_storage) + - sizeof(struct sctp_getaddresses)); + opt_len = (socklen_t)(size_of_addresses + sizeof(struct sctp_getaddresses)); addrs = calloc(1, (size_t)opt_len); if (addrs == NULL) { errno = ENOMEM; @@ -2979,12 +2799,15 @@ usrsctp_getladdrs(struct socket *so, sctp_assoc_t id, struct sockaddr **raddrs) /* Now lets get the array of addresses */ if (usrsctp_getsockopt(so, IPPROTO_SCTP, SCTP_GET_LOCAL_ADDRESSES, addrs, &opt_len) != 0) { free(addrs); - errno = ENOMEM; return (-1); } - *raddrs = (struct sockaddr *)&addrs->addr[0]; + if (size_of_addresses == 0) { + free(addrs); + return (0); + } + *raddrs = &addrs->addr[0].sa; cnt = 0; - sa = (struct sockaddr *)&addrs->addr[0]; + sa = &addrs->addr[0].sa; lim = (caddr_t)addrs + opt_len; #ifdef HAVE_SA_LEN while (((caddr_t)sa < lim) && (sa->sa_len > 0)) { @@ -3021,7 +2844,7 @@ usrsctp_freeladdrs(struct sockaddr *addrs) /* Take away the hidden association id */ void *fr_addr; - fr_addr = (void *)((caddr_t)addrs - sizeof(sctp_assoc_t)); + fr_addr = (void *)((caddr_t)addrs - offsetof(struct sctp_getaddresses, addr)); /* Now free it */ free(fr_addr); } @@ -3029,22 +2852,17 @@ usrsctp_freeladdrs(struct sockaddr *addrs) #ifdef INET void sctp_userspace_ip_output(int *result, struct mbuf *o_pak, - sctp_route_t *ro, void *stcb, + sctp_route_t *ro, void *inp, uint32_t vrf_id) { struct mbuf *m; struct mbuf *m_orig; int iovcnt; - int send_len; int len; - int send_count; struct ip *ip; struct udphdr *udp; -#if !defined (__Userspace_os_Windows) - int res; -#endif struct sockaddr_in dst; -#if defined (__Userspace_os_Windows) +#if defined(_WIN32) WSAMSG win_msg_hdr; DWORD win_sent_len; WSABUF send_iovec[MAXLEN_MBUF_CHAIN]; @@ -3090,7 +2908,7 @@ sctp_userspace_ip_output(int *result, struct mbuf *o_pak, SCTP_PRINTF("Why did the SCTP implementation did not choose a source address?\n"); } /* TODO need to worry about ro->ro_dst as in ip_output? */ -#if defined(__Userspace_os_Linux) || defined (__Userspace_os_Windows) || (defined(__Userspace_os_FreeBSD) && (__FreeBSD_version >= 1100030)) +#if defined(__linux__) || defined(_WIN32) || (defined(__FreeBSD__) && (__FreeBSD_version >= 1100030)) /* need to put certain fields into network order for Linux */ ip->ip_len = htons(ip->ip_len); #endif @@ -3113,17 +2931,13 @@ sctp_userspace_ip_output(int *result, struct mbuf *o_pak, m_adj(m, sizeof(struct ip) + sizeof(struct udphdr)); } - send_len = SCTP_HEADER_LEN(m); /* length of entire packet */ - send_count = 0; for (iovcnt = 0; m != NULL && iovcnt < MAXLEN_MBUF_CHAIN; m = m->m_next, iovcnt++) { -#if !defined (__Userspace_os_Windows) +#if !defined(_WIN32) send_iovec[iovcnt].iov_base = (caddr_t)m->m_data; send_iovec[iovcnt].iov_len = SCTP_BUF_LEN(m); - send_count += send_iovec[iovcnt].iov_len; #else send_iovec[iovcnt].buf = (caddr_t)m->m_data; send_iovec[iovcnt].len = SCTP_BUF_LEN(m); - send_count += send_iovec[iovcnt].len; #endif } @@ -3132,7 +2946,7 @@ sctp_userspace_ip_output(int *result, struct mbuf *o_pak, goto free_mbuf; } -#if !defined (__Userspace_os_Windows) +#if !defined(_WIN32) msg_hdr.msg_name = (struct sockaddr *) &dst; msg_hdr.msg_namelen = sizeof(struct sockaddr_in); msg_hdr.msg_iov = send_iovec; @@ -3142,12 +2956,12 @@ sctp_userspace_ip_output(int *result, struct mbuf *o_pak, msg_hdr.msg_flags = 0; if ((!use_udp_tunneling) && (SCTP_BASE_VAR(userspace_rawsctp) != -1)) { - if ((res = sendmsg(SCTP_BASE_VAR(userspace_rawsctp), &msg_hdr, MSG_DONTWAIT)) != send_len) { + if (sendmsg(SCTP_BASE_VAR(userspace_rawsctp), &msg_hdr, MSG_DONTWAIT) < 0) { *result = errno; } } if ((use_udp_tunneling) && (SCTP_BASE_VAR(userspace_udpsctp) != -1)) { - if ((res = sendmsg(SCTP_BASE_VAR(userspace_udpsctp), &msg_hdr, MSG_DONTWAIT)) != send_len) { + if (sendmsg(SCTP_BASE_VAR(userspace_udpsctp), &msg_hdr, MSG_DONTWAIT) < 0) { *result = errno; } } @@ -3164,15 +2978,11 @@ sctp_userspace_ip_output(int *result, struct mbuf *o_pak, if ((!use_udp_tunneling) && (SCTP_BASE_VAR(userspace_rawsctp) != -1)) { if (WSASendTo(SCTP_BASE_VAR(userspace_rawsctp), (LPWSABUF) send_iovec, iovcnt, &win_sent_len, win_msg_hdr.dwFlags, win_msg_hdr.name, (int) win_msg_hdr.namelen, NULL, NULL) != 0) { *result = WSAGetLastError(); - } else if ((int)win_sent_len != send_len) { - *result = WSAGetLastError(); } } if ((use_udp_tunneling) && (SCTP_BASE_VAR(userspace_udpsctp) != -1)) { if (WSASendTo(SCTP_BASE_VAR(userspace_udpsctp), (LPWSABUF) send_iovec, iovcnt, &win_sent_len, win_msg_hdr.dwFlags, win_msg_hdr.name, (int) win_msg_hdr.namelen, NULL, NULL) != 0) { *result = WSAGetLastError(); - } else if ((int)win_sent_len != send_len) { - *result = WSAGetLastError(); } } #endif @@ -3181,24 +2991,19 @@ free_mbuf: } #endif -#if defined (INET6) +#if defined(INET6) void sctp_userspace_ip6_output(int *result, struct mbuf *o_pak, - struct route_in6 *ro, void *stcb, + struct route_in6 *ro, void *inp, uint32_t vrf_id) { struct mbuf *m; struct mbuf *m_orig; int iovcnt; - int send_len; int len; - int send_count; struct ip6_hdr *ip6; struct udphdr *udp; -#if !defined (__Userspace_os_Windows) - int res; -#endif struct sockaddr_in6 dst; -#if defined (__Userspace_os_Windows) +#if defined(_WIN32) WSAMSG win_msg_hdr; DWORD win_sent_len; WSABUF send_iovec[MAXLEN_MBUF_CHAIN]; @@ -3265,20 +3070,16 @@ void sctp_userspace_ip6_output(int *result, struct mbuf *o_pak, if (use_udp_tunneling) { m_adj(m, sizeof(struct ip6_hdr) + sizeof(struct udphdr)); } else { - m_adj(m, sizeof(struct ip6_hdr)); + m_adj(m, sizeof(struct ip6_hdr)); } - send_len = SCTP_HEADER_LEN(m); /* length of entire packet */ - send_count = 0; for (iovcnt = 0; m != NULL && iovcnt < MAXLEN_MBUF_CHAIN; m = m->m_next, iovcnt++) { -#if !defined (__Userspace_os_Windows) +#if !defined(_WIN32) send_iovec[iovcnt].iov_base = (caddr_t)m->m_data; send_iovec[iovcnt].iov_len = SCTP_BUF_LEN(m); - send_count += send_iovec[iovcnt].iov_len; #else send_iovec[iovcnt].buf = (caddr_t)m->m_data; send_iovec[iovcnt].len = SCTP_BUF_LEN(m); - send_count += send_iovec[iovcnt].len; #endif } if (m != NULL) { @@ -3286,7 +3087,7 @@ void sctp_userspace_ip6_output(int *result, struct mbuf *o_pak, goto free_mbuf; } -#if !defined (__Userspace_os_Windows) +#if !defined(_WIN32) msg_hdr.msg_name = (struct sockaddr *) &dst; msg_hdr.msg_namelen = sizeof(struct sockaddr_in6); msg_hdr.msg_iov = send_iovec; @@ -3296,12 +3097,12 @@ void sctp_userspace_ip6_output(int *result, struct mbuf *o_pak, msg_hdr.msg_flags = 0; if ((!use_udp_tunneling) && (SCTP_BASE_VAR(userspace_rawsctp6) != -1)) { - if ((res = sendmsg(SCTP_BASE_VAR(userspace_rawsctp6), &msg_hdr, MSG_DONTWAIT)) != send_len) { + if (sendmsg(SCTP_BASE_VAR(userspace_rawsctp6), &msg_hdr, MSG_DONTWAIT)< 0) { *result = errno; } } if ((use_udp_tunneling) && (SCTP_BASE_VAR(userspace_udpsctp6) != -1)) { - if ((res = sendmsg(SCTP_BASE_VAR(userspace_udpsctp6), &msg_hdr, MSG_DONTWAIT)) != send_len) { + if (sendmsg(SCTP_BASE_VAR(userspace_udpsctp6), &msg_hdr, MSG_DONTWAIT) < 0) { *result = errno; } } @@ -3318,15 +3119,11 @@ void sctp_userspace_ip6_output(int *result, struct mbuf *o_pak, if ((!use_udp_tunneling) && (SCTP_BASE_VAR(userspace_rawsctp6) != -1)) { if (WSASendTo(SCTP_BASE_VAR(userspace_rawsctp6), (LPWSABUF) send_iovec, iovcnt, &win_sent_len, win_msg_hdr.dwFlags, win_msg_hdr.name, (int) win_msg_hdr.namelen, NULL, NULL) != 0) { *result = WSAGetLastError(); - } else if ((int)win_sent_len != send_len) { - *result = WSAGetLastError(); } } if ((use_udp_tunneling) && (SCTP_BASE_VAR(userspace_udpsctp6) != -1)) { if (WSASendTo(SCTP_BASE_VAR(userspace_udpsctp6), (LPWSABUF) send_iovec, iovcnt, &win_sent_len, win_msg_hdr.dwFlags, win_msg_hdr.name, (int) win_msg_hdr.namelen, NULL, NULL) != 0) { *result = WSAGetLastError(); - } else if ((int)win_sent_len != send_len) { - *result = WSAGetLastError(); } } #endif @@ -3405,21 +3202,30 @@ usrsctp_dumppacket(const void *buf, size_t len, int outbound) ftime(&tb); localtime_s(&t, &tb.time); #if defined(__MINGW32__) - snprintf(dump_buf, PREAMBLE_LENGTH + 1, PREAMBLE_FORMAT, - outbound ? 'O' : 'I', - t.tm_hour, t.tm_min, t.tm_sec, (long)(1000 * tb.millitm)); + if (snprintf(dump_buf, PREAMBLE_LENGTH + 1, PREAMBLE_FORMAT, + outbound ? 'O' : 'I', + t.tm_hour, t.tm_min, t.tm_sec, (long)(1000 * tb.millitm)) < 0) { + free(dump_buf); + return (NULL); + } #else - _snprintf_s(dump_buf, PREAMBLE_LENGTH + 1, PREAMBLE_LENGTH, PREAMBLE_FORMAT, - outbound ? 'O' : 'I', - t.tm_hour, t.tm_min, t.tm_sec, (long)(1000 * tb.millitm)); + if (_snprintf_s(dump_buf, PREAMBLE_LENGTH + 1, PREAMBLE_LENGTH, PREAMBLE_FORMAT, + outbound ? 'O' : 'I', + t.tm_hour, t.tm_min, t.tm_sec, (long)(1000 * tb.millitm)) < 0) { + free(dump_buf); + return (NULL); + } #endif #else gettimeofday(&tv, NULL); sec = (time_t)tv.tv_sec; localtime_r((const time_t *)&sec, &t); - snprintf(dump_buf, PREAMBLE_LENGTH + 1, PREAMBLE_FORMAT, - outbound ? 'O' : 'I', - t.tm_hour, t.tm_min, t.tm_sec, (long)tv.tv_usec); + if (snprintf(dump_buf, PREAMBLE_LENGTH + 1, PREAMBLE_FORMAT, + outbound ? 'O' : 'I', + t.tm_hour, t.tm_min, t.tm_sec, (long)tv.tv_usec) < 0) { + free(dump_buf); + return (NULL); + } #endif pos += PREAMBLE_LENGTH; #if defined(_WIN32) && !defined(__MINGW32__) @@ -3482,9 +3288,10 @@ void usrsctp_conninput(void *addr, const void *buffer, size_t length, uint8_t ecn_bits) { struct sockaddr_conn src, dst; - struct mbuf *m; + struct mbuf *m, *mm; struct sctphdr *sh; struct sctp_chunkhdr *ch; + int remaining, offset; SCTP_STAT_INCR(sctps_recvpackets); SCTP_STAT_INCR_COUNTER64(sctps_inpackets); @@ -3503,18 +3310,30 @@ usrsctp_conninput(void *addr, const void *buffer, size_t length, uint8_t ecn_bit if ((m = sctp_get_mbuf_for_msg((unsigned int)length, 1, M_NOWAIT, 0, MT_DATA)) == NULL) { return; } + /* Set the lengths fields of the mbuf chain. + * This is expected by m_copyback(). + */ + remaining = (int)length; + for (mm = m; mm != NULL; mm = mm->m_next) { + mm->m_len = min((int)M_SIZE(mm), remaining); + m->m_pkthdr.len += mm->m_len; + remaining -= mm->m_len; + } + KASSERT(remaining == 0, ("usrsctp_conninput: %zu bytes left", remaining)); m_copyback(m, 0, (int)length, (caddr_t)buffer); - if (SCTP_BUF_LEN(m) < (int)(sizeof(struct sctphdr) + sizeof(struct sctp_chunkhdr))) { - if ((m = m_pullup(m, sizeof(struct sctphdr) + sizeof(struct sctp_chunkhdr))) == NULL) { + offset = sizeof(struct sctphdr) + sizeof(struct sctp_chunkhdr); + if (SCTP_BUF_LEN(m) < offset) { + if ((m = m_pullup(m, offset)) == NULL) { SCTP_STAT_INCR(sctps_hdrops); return; } } - sh = mtod(m, struct sctphdr *);; + sh = mtod(m, struct sctphdr *); ch = (struct sctp_chunkhdr *)((caddr_t)sh + sizeof(struct sctphdr)); + offset -= sizeof(struct sctp_chunkhdr); src.sconn_port = sh->src_port; dst.sconn_port = sh->dest_port; - sctp_common_input_processing(&m, 0, sizeof(struct sctphdr), (int)length, + sctp_common_input_processing(&m, 0, offset, (int)length, (struct sockaddr *)&src, (struct sockaddr *)&dst, sh, ch, @@ -3527,9 +3346,9 @@ usrsctp_conninput(void *addr, const void *buffer, size_t length, uint8_t ecn_bit return; } -void usrsctp_handle_timers(uint32_t delta) +void usrsctp_handle_timers(uint32_t elapsed_milliseconds) { - sctp_handle_tick(delta); + sctp_handle_tick(sctp_msecs_to_ticks(elapsed_milliseconds)); } int diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_socketvar.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_socketvar.h index cd235fafef..e8eccc7fb1 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_socketvar.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_socketvar.h @@ -10,7 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -33,7 +33,7 @@ #ifndef _USER_SOCKETVAR_H_ #define _USER_SOCKETVAR_H_ -#if defined(__Userspace_os_Darwin) +#if defined(__APPLE__) #include #include #endif @@ -42,7 +42,7 @@ /* #include was 0 byte file */ /* #include was 0 byte file */ /* #include */ /*__Userspace__ alternative?*/ -#if !defined(__Userspace_os_DragonFly) && !defined(__Userspace_os_FreeBSD) && !defined(__Userspace_os_NetBSD) && !defined(__Userspace_os_Windows) && !defined(__Userspace_os_NaCl) +#if !defined(__DragonFly__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(_WIN32) && !defined(__native_client__) #include #endif #define SOCK_MAXADDRLEN 255 @@ -54,16 +54,16 @@ #define SS_CANTRCVMORE 0x020 #define SS_CANTSENDMORE 0x010 -#if defined(__Userspace_os_Darwin) || defined(__Userspace_os_DragonFly) || defined(__Userspace_os_FreeBSD) || defined(__Userspace_os_OpenBSD) || defined (__Userspace_os_Windows) || defined(__Userspace_os_NaCl) +#if defined(__APPLE__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(_WIN32) || defined(__native_client__) #define UIO_MAXIOV 1024 #define ERESTART (-1) #endif -#if !defined(__Userspace_os_Darwin) && !defined(__Userspace_os_NetBSD) && !defined(__Userspace_os_OpenBSD) +#if !defined(__APPLE__) && !defined(__NetBSD__) && !defined(__OpenBSD__) enum uio_rw { UIO_READ, UIO_WRITE }; #endif -#if !defined(__Userspace_os_NetBSD) && !defined(__Userspace_os_OpenBSD) +#if !defined(__NetBSD__) && !defined(__OpenBSD__) /* Segment flag values. */ enum uio_seg { UIO_USERSPACE, /* from user data space */ @@ -100,7 +100,7 @@ struct uio { * handle on protocol and pointer to protocol * private data and error information. */ -#if defined (__Userspace_os_Windows) +#if defined(_WIN32) #define AF_ROUTE 17 #if !defined(__MINGW32__) typedef __int32 pid_t; @@ -237,7 +237,7 @@ struct socket { * avoid defining a lock order between listen and accept sockets * until such time as it proves to be a good idea. */ -#if defined(__Userspace_os_Windows) +#if defined(_WIN32) extern userland_mutex_t accept_mtx; extern userland_cond_t accept_cond; #define ACCEPT_LOCK_ASSERT() @@ -272,7 +272,7 @@ extern userland_cond_t accept_cond; * buffer. */ #define SOCKBUF_MTX(_sb) (&(_sb)->sb_mtx) -#if defined (__Userspace_os_Windows) +#if defined(_WIN32) #define SOCKBUF_LOCK_INIT(_sb, _name) \ InitializeCriticalSection(SOCKBUF_MTX(_sb)) #define SOCKBUF_LOCK_DESTROY(_sb) DeleteCriticalSection(SOCKBUF_MTX(_sb)) @@ -373,340 +373,6 @@ extern userland_cond_t accept_cond; #define SCTP_EVENT_WRITE 0x0002 /* socket is writeable */ #define SCTP_EVENT_ERROR 0x0004 /* socket has an error state */ -/* - * Externalized form of struct socket used by the sysctl(3) interface. - */ -struct xsocket { - size_t xso_len; /* length of this structure */ - struct socket *xso_so; /* makes a convenient handle sometimes */ - short so_type; - short so_options; - short so_linger; - short so_state; - caddr_t so_pcb; /* another convenient handle */ - int xso_protocol; - int xso_family; - u_short so_qlen; - u_short so_incqlen; - u_short so_qlimit; - short so_timeo; - u_short so_error; - pid_t so_pgid; - u_long so_oobmark; - struct xsockbuf { - u_int sb_cc; - u_int sb_hiwat; - u_int sb_mbcnt; - u_int sb_mbmax; - int sb_lowat; - int sb_timeo; - short sb_flags; - } so_rcv, so_snd; - uid_t so_uid; /* XXX */ -}; - -#if defined(_KERNEL) - - -/* - * Macros for sockets and socket buffering. - */ - -/* - * Do we need to notify the other side when I/O is possible? - */ -#define sb_notify(sb) (((sb)->sb_flags & (SB_WAIT | SB_SEL | SB_ASYNC | \ - SB_UPCALL | SB_AIO | SB_KNOTE)) != 0) - -/* - * How much space is there in a socket buffer (so->so_snd or so->so_rcv)? - * This is problematical if the fields are unsigned, as the space might - * still be negative (cc > hiwat or mbcnt > mbmax). Should detect - * overflow and return 0. Should use "lmin" but it doesn't exist now. - */ -#define sbspace(sb) \ - ((long) imin((int)((sb)->sb_hiwat - (sb)->sb_cc), \ - (int)((sb)->sb_mbmax - (sb)->sb_mbcnt))) - -/* do we have to send all at once on a socket? */ -#define sosendallatonce(so) \ - ((so)->so_proto->pr_flags & PR_ATOMIC) - -/* can we read something from so? */ -#define soreadable(so) \ - ((so)->so_rcv.sb_cc >= (so)->so_rcv.sb_lowat || \ - ((so)->so_rcv.sb_state & SBS_CANTRCVMORE) || \ - !TAILQ_EMPTY(&(so)->so_comp) || (so)->so_error) - -/* can we write something to so? */ -#define sowriteable(so) \ - ((sbspace(&(so)->so_snd) >= (so)->so_snd.sb_lowat && \ - (((so)->so_state&SS_ISCONNECTED) || \ - ((so)->so_proto->pr_flags&PR_CONNREQUIRED)==0)) || \ - ((so)->so_snd.sb_state & SBS_CANTSENDMORE) || \ - (so)->so_error) - -/* adjust counters in sb reflecting allocation of m */ -#define sballoc(sb, m) { \ - (sb)->sb_cc += (m)->m_len; \ - if ((m)->m_type != MT_DATA && (m)->m_type != MT_OOBDATA) \ - (sb)->sb_ctl += (m)->m_len; \ - (sb)->sb_mbcnt += MSIZE; \ - if ((m)->m_flags & M_EXT) \ - (sb)->sb_mbcnt += (m)->m_ext.ext_size; \ -} - -/* adjust counters in sb reflecting freeing of m */ -#define sbfree(sb, m) { \ - (sb)->sb_cc -= (m)->m_len; \ - if ((m)->m_type != MT_DATA && (m)->m_type != MT_OOBDATA) \ - (sb)->sb_ctl -= (m)->m_len; \ - (sb)->sb_mbcnt -= MSIZE; \ - if ((m)->m_flags & M_EXT) \ - (sb)->sb_mbcnt -= (m)->m_ext.ext_size; \ - if ((sb)->sb_sndptr == (m)) { \ - (sb)->sb_sndptr = NULL; \ - (sb)->sb_sndptroff = 0; \ - } \ - if ((sb)->sb_sndptroff != 0) \ - (sb)->sb_sndptroff -= (m)->m_len; \ -} - -/* - * soref()/sorele() ref-count the socket structure. Note that you must - * still explicitly close the socket, but the last ref count will free - * the structure. - */ -#define soref(so) do { \ - SOCK_LOCK_ASSERT(so); \ - ++(so)->so_count; \ -} while (0) - -#define sorele(so) do { \ - ACCEPT_LOCK_ASSERT(); \ - SOCK_LOCK_ASSERT(so); \ - KASSERT((so)->so_count > 0, ("sorele")); \ - if (--(so)->so_count == 0) \ - sofree(so); \ - else { \ - SOCK_UNLOCK(so); \ - ACCEPT_UNLOCK(); \ - } \ -} while (0) - -#define sotryfree(so) do { \ - ACCEPT_LOCK_ASSERT(); \ - SOCK_LOCK_ASSERT(so); \ - if ((so)->so_count == 0) \ - sofree(so); \ - else { \ - SOCK_UNLOCK(so); \ - ACCEPT_UNLOCK(); \ - } \ -} while(0) - -/* - * In sorwakeup() and sowwakeup(), acquire the socket buffer lock to - * avoid a non-atomic test-and-wakeup. However, sowakeup is - * responsible for releasing the lock if it is called. We unlock only - * if we don't call into sowakeup. If any code is introduced that - * directly invokes the underlying sowakeup() primitives, it must - * maintain the same semantics. - */ -#define sorwakeup_locked(so) do { \ - SOCKBUF_LOCK_ASSERT(&(so)->so_rcv); \ - if (sb_notify(&(so)->so_rcv)) \ - sowakeup((so), &(so)->so_rcv); \ - else \ - SOCKBUF_UNLOCK(&(so)->so_rcv); \ -} while (0) - -#define sorwakeup(so) do { \ - SOCKBUF_LOCK(&(so)->so_rcv); \ - sorwakeup_locked(so); \ -} while (0) - -#define sowwakeup_locked(so) do { \ - SOCKBUF_LOCK_ASSERT(&(so)->so_snd); \ - if (sb_notify(&(so)->so_snd)) \ - sowakeup((so), &(so)->so_snd); \ - else \ - SOCKBUF_UNLOCK(&(so)->so_snd); \ -} while (0) - -#define sowwakeup(so) do { \ - SOCKBUF_LOCK(&(so)->so_snd); \ - sowwakeup_locked(so); \ -} while (0) - -/* - * Argument structure for sosetopt et seq. This is in the KERNEL - * section because it will never be visible to user code. - */ -enum sopt_dir { SOPT_GET, SOPT_SET }; -struct sockopt { - enum sopt_dir sopt_dir; /* is this a get or a set? */ - int sopt_level; /* second arg of [gs]etsockopt */ - int sopt_name; /* third arg of [gs]etsockopt */ - void *sopt_val; /* fourth arg of [gs]etsockopt */ - size_t sopt_valsize; /* (almost) fifth arg of [gs]etsockopt */ - struct thread *sopt_td; /* calling thread or null if kernel */ -}; - -struct accept_filter { - char accf_name[16]; - void (*accf_callback) - (struct socket *so, void *arg, int waitflag); - void * (*accf_create) - (struct socket *so, char *arg); - void (*accf_destroy) - (struct socket *so); - SLIST_ENTRY(accept_filter) accf_next; -}; - -extern int maxsockets; -extern u_long sb_max; -extern struct uma_zone *socket_zone; -extern so_gen_t so_gencnt; - -struct mbuf; -struct sockaddr; -struct ucred; -struct uio; - -/* - * From uipc_socket and friends - */ -int do_getopt_accept_filter(struct socket *so, struct sockopt *sopt); -int do_setopt_accept_filter(struct socket *so, struct sockopt *sopt); -int so_setsockopt(struct socket *so, int level, int optname, - void *optval, size_t optlen); -int sockargs(struct mbuf **mp, caddr_t buf, int buflen, int type); -int getsockaddr(struct sockaddr **namp, caddr_t uaddr, size_t len); -void sbappend(struct sockbuf *sb, struct mbuf *m); -void sbappend_locked(struct sockbuf *sb, struct mbuf *m); -void sbappendstream(struct sockbuf *sb, struct mbuf *m); -void sbappendstream_locked(struct sockbuf *sb, struct mbuf *m); -int sbappendaddr(struct sockbuf *sb, const struct sockaddr *asa, - struct mbuf *m0, struct mbuf *control); -int sbappendaddr_locked(struct sockbuf *sb, const struct sockaddr *asa, - struct mbuf *m0, struct mbuf *control); -int sbappendcontrol(struct sockbuf *sb, struct mbuf *m0, - struct mbuf *control); -int sbappendcontrol_locked(struct sockbuf *sb, struct mbuf *m0, - struct mbuf *control); -void sbappendrecord(struct sockbuf *sb, struct mbuf *m0); -void sbappendrecord_locked(struct sockbuf *sb, struct mbuf *m0); -void sbcheck(struct sockbuf *sb); -void sbcompress(struct sockbuf *sb, struct mbuf *m, struct mbuf *n); -struct mbuf * - sbcreatecontrol(caddr_t p, int size, int type, int level); -void sbdestroy(struct sockbuf *sb, struct socket *so); -void sbdrop(struct sockbuf *sb, int len); -void sbdrop_locked(struct sockbuf *sb, int len); -void sbdroprecord(struct sockbuf *sb); -void sbdroprecord_locked(struct sockbuf *sb); -void sbflush(struct sockbuf *sb); -void sbflush_locked(struct sockbuf *sb); -void sbrelease(struct sockbuf *sb, struct socket *so); -void sbrelease_locked(struct sockbuf *sb, struct socket *so); -int sbreserve(struct sockbuf *sb, u_long cc, struct socket *so, - struct thread *td); -int sbreserve_locked(struct sockbuf *sb, u_long cc, struct socket *so, - struct thread *td); -struct mbuf * - sbsndptr(struct sockbuf *sb, u_int off, u_int len, u_int *moff); -void sbtoxsockbuf(struct sockbuf *sb, struct xsockbuf *xsb); -int sbwait(struct sockbuf *sb); -int sblock(struct sockbuf *sb, int flags); -void sbunlock(struct sockbuf *sb); -void soabort(struct socket *so); -int soaccept(struct socket *so, struct sockaddr **nam); -int socheckuid(struct socket *so, uid_t uid); -int sobind(struct socket *so, struct sockaddr *nam, struct thread *td); -void socantrcvmore(struct socket *so); -void socantrcvmore_locked(struct socket *so); -void socantsendmore(struct socket *so); -void socantsendmore_locked(struct socket *so); -int soclose(struct socket *so); -int soconnect(struct socket *so, struct sockaddr *nam, struct thread *td); -int soconnect2(struct socket *so1, struct socket *so2); -int socow_setup(struct mbuf *m0, struct uio *uio); -int socreate(int dom, struct socket **aso, int type, int proto, - struct ucred *cred, struct thread *td); -int sodisconnect(struct socket *so); -struct sockaddr *sodupsockaddr(const struct sockaddr *sa, int mflags); -void sofree(struct socket *so); -int sogetopt(struct socket *so, struct sockopt *sopt); -void sohasoutofband(struct socket *so); -void soisconnected(struct socket *so); -void soisconnecting(struct socket *so); -void soisdisconnected(struct socket *so); -void soisdisconnecting(struct socket *so); -int solisten(struct socket *so, int backlog, struct thread *td); -void solisten_proto(struct socket *so, int backlog); -int solisten_proto_check(struct socket *so); -struct socket * - sonewconn(struct socket *head, int connstatus); -int sooptcopyin(struct sockopt *sopt, void *buf, size_t len, size_t minlen); -int sooptcopyout(struct sockopt *sopt, const void *buf, size_t len); - -/* XXX; prepare mbuf for (__FreeBSD__ < 3) routines. */ -int soopt_getm(struct sockopt *sopt, struct mbuf **mp); -int soopt_mcopyin(struct sockopt *sopt, struct mbuf *m); -int soopt_mcopyout(struct sockopt *sopt, struct mbuf *m); - -int sopoll(struct socket *so, int events, struct ucred *active_cred, - struct thread *td); -int sopoll_generic(struct socket *so, int events, - struct ucred *active_cred, struct thread *td); -int soreceive(struct socket *so, struct sockaddr **paddr, struct uio *uio, - struct mbuf **mp0, struct mbuf **controlp, int *flagsp); -int soreceive_generic(struct socket *so, struct sockaddr **paddr, - struct uio *uio, struct mbuf **mp0, struct mbuf **controlp, - int *flagsp); -int soreserve(struct socket *so, u_long sndcc, u_long rcvcc); -void sorflush(struct socket *so); -int sosend(struct socket *so, struct sockaddr *addr, struct uio *uio, - struct mbuf *top, struct mbuf *control, int flags, - struct thread *td); -int sosend_dgram(struct socket *so, struct sockaddr *addr, - struct uio *uio, struct mbuf *top, struct mbuf *control, - int flags, struct thread *td); -int sosend_generic(struct socket *so, struct sockaddr *addr, - struct uio *uio, struct mbuf *top, struct mbuf *control, - int flags, struct thread *td); -int sosetopt(struct socket *so, struct sockopt *sopt); -int soshutdown(struct socket *so, int how); -void sotoxsocket(struct socket *so, struct xsocket *xso); -void sowakeup(struct socket *so, struct sockbuf *sb); - -#ifdef SOCKBUF_DEBUG -void sblastrecordchk(struct sockbuf *, const char *, int); -#define SBLASTRECORDCHK(sb) sblastrecordchk((sb), __FILE__, __LINE__) - -void sblastmbufchk(struct sockbuf *, const char *, int); -#define SBLASTMBUFCHK(sb) sblastmbufchk((sb), __FILE__, __LINE__) -#else -#define SBLASTRECORDCHK(sb) /* nothing */ -#define SBLASTMBUFCHK(sb) /* nothing */ -#endif /* SOCKBUF_DEBUG */ - -/* - * Accept filter functions (duh). - */ -int accept_filt_add(struct accept_filter *filt); -int accept_filt_del(char *name); -struct accept_filter *accept_filt_get(char *name); -#ifdef ACCEPT_FILTER_MOD -#ifdef SYSCTL_DECL -SYSCTL_DECL(_net_inet_accf); -#endif -int accept_filt_generic_mod_event(module_t mod, int event, void *data); -#endif - -#endif /* _KERNEL */ - /*-------------------------------------------------------------*/ /*-------------------------------------------------------------*/ @@ -717,7 +383,6 @@ int accept_filt_generic_mod_event(module_t mod, int event, void *data); * above into, avoiding having to port the entire thing at once... * For function prototypes, the full bodies are in user_socket.c . */ -#if defined(__Userspace__) /* ---------------------------------------------------------- */ /* --- function prototypes (implemented in user_socket.c) --- */ @@ -792,9 +457,7 @@ extern int sctp_listen(struct socket *so, int backlog, struct proc *p); extern void socantrcvmore_locked(struct socket *so); extern int sctp_bind(struct socket *so, struct sockaddr *addr); extern int sctp6_bind(struct socket *so, struct sockaddr *addr, void *proc); -#if defined(__Userspace__) extern int sctpconn_bind(struct socket *so, struct sockaddr *addr); -#endif extern int sctp_accept(struct socket *so, struct sockaddr **addr); extern int sctp_attach(struct socket *so, int proto, uint32_t vrf_id); extern int sctp6_attach(struct socket *so, int proto, uint32_t vrf_id); @@ -813,9 +476,7 @@ extern int soconnect(struct socket *so, struct sockaddr *nam); extern int sctp_disconnect(struct socket *so); extern int sctp_connect(struct socket *so, struct sockaddr *addr); extern int sctp6_connect(struct socket *so, struct sockaddr *addr); -#if defined(__Userspace__) extern int sctpconn_connect(struct socket *so, struct sockaddr *addr); -#endif extern void sctp_finish(void); /* ------------------------------------------------ */ @@ -863,8 +524,4 @@ extern void sctp_finish(void); sowwakeup_locked(so); \ } while (0) - - -#endif /* __Userspace__ */ - #endif /* !_SYS_SOCKETVAR_H_ */ diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_uma.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_uma.h index e20d2ada67..59d71fff42 100755 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_uma.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/user_uma.h @@ -83,14 +83,14 @@ struct uma_zone { /* Prototype */ uma_zone_t uma_zcreate(char *name, size_t size, uma_ctor ctor, uma_dtor dtor, - uma_init uminit, uma_fini fini, int align, u_int32_t flags); + uma_init uminit, uma_fini fini, int align, uint32_t flags); #define uma_zone_set_max(zone, number) /* stub TODO __Userspace__ */ uma_zone_t uma_zcreate(char *name, size_t size, uma_ctor ctor, uma_dtor dtor, - uma_init uminit, uma_fini fini, int align, u_int32_t flags) { + uma_init uminit, uma_fini fini, int align, uint32_t flags) { return NULL; /* stub TODO __Userspace__. Also place implementation in a separate .c file */ } #endif diff --git a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/usrsctp.h b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/usrsctp.h index 37d4828f08..e0c17c3a04 100644 --- a/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/usrsctp.h +++ b/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/usrsctplib/usrsctp.h @@ -64,19 +64,19 @@ extern "C" { #elif defined(SCTP_STDINT_INCLUDE) #include SCTP_STDINT_INCLUDE #else -#define uint8_t unsigned __int8 -#define uint16_t unsigned __int16 -#define uint32_t unsigned __int32 -#define uint64_t unsigned __int64 -#define int16_t __int16 -#define int32_t __int32 +typedef unsigned __int8 uint8_t; +typedef unsigned __int16 uint16_t; +typedef unsigned __int32 uint32_t; +typedef unsigned __int64 uint64_t; +typedef __int16 int16_t; +typedef __int32 int32_t; #endif #ifndef ssize_t #ifdef _WIN64 -#define ssize_t __int64 +typedef __int64 ssize_t; #elif defined _WIN32 -#define ssize_t int +typedef int ssize_t; #else #error "Unknown platform!" #endif @@ -281,12 +281,13 @@ struct sctp_assoc_change { #define SCTP_CANT_STR_ASSOC 0x0005 /* sac_info values */ -#define SCTP_ASSOC_SUPPORTS_PR 0x01 -#define SCTP_ASSOC_SUPPORTS_AUTH 0x02 -#define SCTP_ASSOC_SUPPORTS_ASCONF 0x03 -#define SCTP_ASSOC_SUPPORTS_MULTIBUF 0x04 -#define SCTP_ASSOC_SUPPORTS_RE_CONFIG 0x05 -#define SCTP_ASSOC_SUPPORTS_MAX 0x05 +#define SCTP_ASSOC_SUPPORTS_PR 0x01 +#define SCTP_ASSOC_SUPPORTS_AUTH 0x02 +#define SCTP_ASSOC_SUPPORTS_ASCONF 0x03 +#define SCTP_ASSOC_SUPPORTS_MULTIBUF 0x04 +#define SCTP_ASSOC_SUPPORTS_RE_CONFIG 0x05 +#define SCTP_ASSOC_SUPPORTS_INTERLEAVING 0x06 +#define SCTP_ASSOC_SUPPORTS_MAX 0x06 /* Address event */ struct sctp_paddr_change { @@ -903,7 +904,7 @@ struct socket * usrsctp_socket(int domain, int type, int protocol, int (*receive_cb)(struct socket *sock, union sctp_sockstore addr, void *data, size_t datalen, struct sctp_rcvinfo, int flags, void *ulp_info), - int (*send_cb)(struct socket *sock, uint32_t sb_free), + int (*send_cb)(struct socket *sock, uint32_t sb_free, void *ulp_info), uint32_t sb_threshold, void *ulp_info); @@ -1032,6 +1033,9 @@ usrsctp_deregister_address(void *); int usrsctp_set_ulpinfo(struct socket *, void *); +int +usrsctp_get_ulpinfo(struct socket *, void **); + int usrsctp_set_upcall(struct socket *so, void (*upcall)(struct socket *, void *, int), @@ -1042,7 +1046,7 @@ usrsctp_get_events(struct socket *so); void -usrsctp_handle_timers(uint32_t delta); +usrsctp_handle_timers(uint32_t elapsed_milliseconds); #define SCTP_DUMP_OUTBOUND 1 #define SCTP_DUMP_INBOUND 0 diff --git a/third-party/webrtc/webrtc b/third-party/webrtc/webrtc index b872384c79..73bf8cd601 160000 --- a/third-party/webrtc/webrtc +++ b/third-party/webrtc/webrtc @@ -1 +1 @@ -Subproject commit b872384c79f4f4efe869e2bcb91d2b92f9a5d03a +Subproject commit 73bf8cd601c83152211321a30e818dcdeec1bbfd