提交 64eb1e5f authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

Really update usrsctp

上级 99fe3bb1
# Changelog # Changelog
### 3.5.7 (WIP)
* Update `usrsctp` library.
### 3.5.6 ### 3.5.6
* `SeqManager.cpp`: Fix video lag after a long time. * `SeqManager.cpp`: Fix video lag after a long time.
......
...@@ -259,8 +259,9 @@ elseif (CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID MATCHES "Appl ...@@ -259,8 +259,9 @@ elseif (CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID MATCHES "Appl
endif () endif ()
if (sctp_build_fuzzer) if (sctp_build_fuzzer)
set(CMAKE_BUILD_TYPE "DEBUG")
add_definitions(-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION) add_definitions(-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=fuzzer-no-link") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O1 -fsanitize=fuzzer-no-link")
endif () endif ()
endif () endif ()
......
...@@ -263,6 +263,7 @@ main(int argc, char *argv[]) ...@@ -263,6 +263,7 @@ main(int argc, char *argv[])
{ {
struct sockaddr_in sin_s, sin_c; struct sockaddr_in sin_s, sin_c;
struct sockaddr_conn sconn; struct sockaddr_conn sconn;
struct sctp_paddrparams paddrparams;
#ifdef _WIN32 #ifdef _WIN32
SOCKET fd_c, fd_s; SOCKET fd_c, fd_s;
#else #else
...@@ -413,6 +414,17 @@ main(int argc, char *argv[]) ...@@ -413,6 +414,17 @@ main(int argc, char *argv[])
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
debug_printf("to %d.\n", cur_buf_size); debug_printf("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) { if ((s_l = usrsctp_socket(AF_CONN, SOCK_STREAM, IPPROTO_SCTP, receive_cb, NULL, 0, &fd_s)) == NULL) {
perror("usrsctp_socket"); perror("usrsctp_socket");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
......
...@@ -52,10 +52,24 @@ void ...@@ -52,10 +52,24 @@ void
debug_printf_stack(const char *format, ...) debug_printf_stack(const char *format, ...)
{ {
va_list ap; va_list ap;
char charbuf[1024];
static struct timeval time_main;
struct timeval time_now;
struct timeval time_delta;
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); va_start(ap, format);
vprintf(format, ap); //vfprintf(stderr, format, ap);
vsnprintf(charbuf, 1024, format, ap);
va_end(ap); va_end(ap);
fprintf(stderr, "[S][%u.%03u] %s", (unsigned int) time_delta.tv_sec, (unsigned int) time_delta.tv_usec / 1000, charbuf);
} }
static void static void
......
...@@ -43,6 +43,8 @@ set(includedir ${prefix}/include/usrsctp) ...@@ -43,6 +43,8 @@ set(includedir ${prefix}/include/usrsctp)
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}) set(CMAKE_REQUIRED_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_MACOSX_RPATH 1) set(CMAKE_MACOSX_RPATH 1)
include(CheckCCompilerFlag)
add_definitions(-D__Userspace__) add_definitions(-D__Userspace__)
add_definitions(-D__Userspace_os_${CMAKE_SYSTEM_NAME}) add_definitions(-D__Userspace_os_${CMAKE_SYSTEM_NAME})
add_definitions(-DSCTP_SIMPLE_ALLOCATOR) add_definitions(-DSCTP_SIMPLE_ALLOCATOR)
...@@ -53,11 +55,16 @@ add_definitions(-DSCTP_PROCESS_LEVEL_LOCKS) ...@@ -53,11 +55,16 @@ add_definitions(-DSCTP_PROCESS_LEVEL_LOCKS)
# OS DEPENDENT # OS DEPENDENT
################################################# #################################################
check_c_compiler_flag(-Wno-address-of-packed-member 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_packet_member) if (has_wno_address_of_packed_member)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-address-of-packed-member") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-address-of-packed-member")
endif () 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") if (CMAKE_SYSTEM_NAME MATCHES "Linux")
add_definitions(-D_GNU_SOURCE) add_definitions(-D_GNU_SOURCE)
endif () endif ()
...@@ -69,7 +76,6 @@ endif () ...@@ -69,7 +76,6 @@ endif ()
if (CMAKE_SYSTEM_NAME MATCHES "Darwin") if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_definitions(-U__APPLE__) add_definitions(-U__APPLE__)
add_definitions(-D__APPLE_USE_RFC_2292) add_definitions(-D__APPLE_USE_RFC_2292)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations")
endif () endif ()
if (CMAKE_SYSTEM_NAME MATCHES "DragonFly") if (CMAKE_SYSTEM_NAME MATCHES "DragonFly")
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#ifdef __FreeBSD__ #ifdef __FreeBSD__
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_asconf.c 357197 2020-01-28 10:09:05Z tuexen $"); __FBSDID("$FreeBSD: head/sys/netinet/sctp_asconf.c 359195 2020-03-21 16:12:19Z tuexen $");
#endif #endif
#include <netinet/sctp_os.h> #include <netinet/sctp_os.h>
...@@ -602,8 +602,7 @@ sctp_process_asconf_set_primary(struct sockaddr *src, ...@@ -602,8 +602,7 @@ sctp_process_asconf_set_primary(struct sockaddr *src,
sctp_move_chunks_from_net(stcb, sctp_move_chunks_from_net(stcb,
stcb->asoc.deleted_primary); stcb->asoc.deleted_primary);
} }
sctp_delete_prim_timer(stcb->sctp_ep, stcb, sctp_delete_prim_timer(stcb->sctp_ep, stcb);
stcb->asoc.deleted_primary);
} }
} else { } else {
/* couldn't set the requested primary address! */ /* couldn't set the requested primary address! */
...@@ -955,12 +954,12 @@ sctp_addr_match(struct sctp_paramhdr *ph, struct sockaddr *sa) ...@@ -955,12 +954,12 @@ sctp_addr_match(struct sctp_paramhdr *ph, struct sockaddr *sa)
* Cleanup for non-responded/OP ERR'd ASCONF * Cleanup for non-responded/OP ERR'd ASCONF
*/ */
void 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 * 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); SCTP_FROM_SCTP_ASCONF + SCTP_LOC_2);
stcb->asoc.asconf_seq_out_acked = stcb->asoc.asconf_seq_out; stcb->asoc.asconf_seq_out_acked = stcb->asoc.asconf_seq_out;
/* remove the old ASCONF on our outbound queue */ /* remove the old ASCONF on our outbound queue */
...@@ -1739,7 +1738,7 @@ sctp_handle_asconf_ack(struct mbuf *m, int offset, ...@@ -1739,7 +1738,7 @@ sctp_handle_asconf_ack(struct mbuf *m, int offset,
if (serial_num == asoc->asconf_seq_out - 1) { if (serial_num == asoc->asconf_seq_out - 1) {
/* stop our timer */ /* 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); SCTP_FROM_SCTP_ASCONF + SCTP_LOC_5);
} }
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#ifdef __FreeBSD__ #ifdef __FreeBSD__
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_asconf.h 324056 2017-09-27 13:05:23Z tuexen $"); __FBSDID("$FreeBSD: head/sys/netinet/sctp_asconf.h 359152 2020-03-19 21:01:16Z tuexen $");
#endif #endif
#ifndef _NETINET_SCTP_ASCONF_H_ #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 ...@@ -45,7 +45,7 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_asconf.h 324056 2017-09-27 13:05:23Z t
/* /*
* function prototypes * 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); extern struct mbuf *sctp_compose_asconf(struct sctp_tcb *, int *, int);
......
...@@ -1650,6 +1650,11 @@ sctp_handle_auth(struct sctp_tcb *stcb, struct sctp_auth_chunk *auth, ...@@ -1650,6 +1650,11 @@ sctp_handle_auth(struct sctp_tcb *stcb, struct sctp_auth_chunk *auth,
"SCTP AUTH Chunk: shared key %u, HMAC id %u\n", "SCTP AUTH Chunk: shared key %u, HMAC id %u\n",
shared_key_id, hmac_id); shared_key_id, hmac_id);
#if defined(__Userspace__)
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
return (0);
#endif
#endif
/* is the indicated HMAC supported? */ /* is the indicated HMAC supported? */
if (!sctp_auth_is_supported_hmac(stcb->asoc.local_hmacs, hmac_id)) { if (!sctp_auth_is_supported_hmac(stcb->asoc.local_hmacs, hmac_id)) {
struct mbuf *op_err; struct mbuf *op_err;
...@@ -1730,11 +1735,6 @@ sctp_handle_auth(struct sctp_tcb *stcb, struct sctp_auth_chunk *auth, ...@@ -1730,11 +1735,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, (void)sctp_compute_hmac_m(hmac_id, stcb->asoc.authinfo.recv_key,
m, offset, computed_digest); 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 */ /* compare the computed digest with the one in the AUTH chunk */
if (timingsafe_bcmp(digest, computed_digest, digestlen) != 0) { if (timingsafe_bcmp(digest, computed_digest, digestlen) != 0) {
SCTP_STAT_INCR(sctps_recvauthfailed); SCTP_STAT_INCR(sctps_recvauthfailed);
......
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
#include <netinet/sctp_callout.h> #include <netinet/sctp_callout.h>
#include <netinet/sctp_pcb.h> #include <netinet/sctp_pcb.h>
#endif #endif
#include <netinet/sctputil.h>
/* /*
* Callout/Timer routines for OS that doesn't have them * Callout/Timer routines for OS that doesn't have them
...@@ -210,7 +211,7 @@ user_sctp_timer_iterate(void *arg) ...@@ -210,7 +211,7 @@ user_sctp_timer_iterate(void *arg)
if (atomic_cmpset_int(&SCTP_BASE_VAR(timer_thread_should_exit), 1, 1)) { if (atomic_cmpset_int(&SCTP_BASE_VAR(timer_thread_should_exit), 1, 1)) {
break; break;
} }
sctp_handle_tick(MSEC_TO_TICKS(TIMEOUT_INTERVAL)); sctp_handle_tick(sctp_msecs_to_ticks(TIMEOUT_INTERVAL));
} }
return (NULL); return (NULL);
} }
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#ifdef __FreeBSD__ #ifdef __FreeBSD__
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_cc_functions.c 356660 2020-01-12 15:45:27Z tuexen $"); __FBSDID("$FreeBSD: head/sys/netinet/sctp_cc_functions.c 359405 2020-03-28 20:25:45Z tuexen $");
#endif #endif
#include <netinet/sctp_os.h> #include <netinet/sctp_os.h>
...@@ -2000,7 +2000,7 @@ measure_rtt(struct sctp_nets *net) ...@@ -2000,7 +2000,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->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) 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; 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; net->cc_mod.htcp_ca.maxRTT = srtt;
} }
} }
...@@ -2060,7 +2060,7 @@ htcp_beta_update(struct htcp *ca, uint32_t minRTT, uint32_t maxRTT) ...@@ -2060,7 +2060,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; ca->beta = (minRTT<<7)/maxRTT;
if (ca->beta < BETA_MIN) if (ca->beta < BETA_MIN)
ca->beta = BETA_MIN; ca->beta = BETA_MIN;
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#ifdef __FreeBSD__ #ifdef __FreeBSD__
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_constants.h 358169 2020-02-20 15:37:44Z tuexen $"); __FBSDID("$FreeBSD: head/sys/netinet/sctp_constants.h 359405 2020-03-28 20:25:45Z tuexen $");
#endif #endif
#ifndef _NETINET_SCTP_CONSTANTS_H_ #ifndef _NETINET_SCTP_CONSTANTS_H_
...@@ -593,16 +593,6 @@ extern void getwintimeofday(struct timeval *tv); ...@@ -593,16 +593,6 @@ extern void getwintimeofday(struct timeval *tv);
#endif #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 * Basically the minimum amount of time before I do a early FR. Making this
* value to low will cause duplicate retransmissions. * value to low will cause duplicate retransmissions.
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#ifdef __FreeBSD__ #ifdef __FreeBSD__
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_indata.c 357705 2020-02-09 22:05:41Z tuexen $"); __FBSDID("$FreeBSD: head/sys/netinet/sctp_indata.c 359152 2020-03-19 21:01:16Z tuexen $");
#endif #endif
#include <netinet/sctp_os.h> #include <netinet/sctp_os.h>
...@@ -4378,7 +4378,7 @@ again: ...@@ -4378,7 +4378,7 @@ again:
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN, sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN,
stcb->sctp_ep, stcb, netp); stcb->sctp_ep, stcb, netp);
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, 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) && } else if ((SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_RECEIVED) &&
(asoc->stream_queue_cnt == 0)) { (asoc->stream_queue_cnt == 0)) {
struct sctp_nets *netp; struct sctp_nets *netp;
...@@ -5094,7 +5094,7 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup, ...@@ -5094,7 +5094,7 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup,
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN, sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN,
stcb->sctp_ep, stcb, netp); stcb->sctp_ep, stcb, netp);
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD,
stcb->sctp_ep, stcb, netp); stcb->sctp_ep, stcb, NULL);
return; return;
} else if ((SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_RECEIVED) && } else if ((SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_RECEIVED) &&
(asoc->stream_queue_cnt == 0)) { (asoc->stream_queue_cnt == 0)) {
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#ifdef __FreeBSD__ #ifdef __FreeBSD__
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_input.c 355135 2019-11-27 19:32:29Z tuexen $"); __FBSDID("$FreeBSD: head/sys/netinet/sctp_input.c 359405 2020-03-28 20:25:45Z tuexen $");
#endif #endif
#include <netinet/sctp_os.h> #include <netinet/sctp_os.h>
...@@ -778,8 +778,7 @@ sctp_handle_heartbeat_ack(struct sctp_heartbeat_chunk *cp, ...@@ -778,8 +778,7 @@ sctp_handle_heartbeat_ack(struct sctp_heartbeat_chunk *cp,
sctp_move_chunks_from_net(stcb, sctp_move_chunks_from_net(stcb,
stcb->asoc.deleted_primary); stcb->asoc.deleted_primary);
} }
sctp_delete_prim_timer(stcb->sctp_ep, stcb, sctp_delete_prim_timer(stcb->sctp_ep, stcb);
stcb->asoc.deleted_primary);
} }
} }
} }
...@@ -895,7 +894,7 @@ sctp_handle_abort(struct sctp_abort_chunk *abort, ...@@ -895,7 +894,7 @@ sctp_handle_abort(struct sctp_abort_chunk *abort,
error = 0; error = 0;
} }
/* stop any receive timers */ /* 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); SCTP_FROM_SCTP_INPUT + SCTP_LOC_7);
/* notify user of the abort and clean up... */ /* notify user of the abort and clean up... */
sctp_abort_notification(stcb, 1, error, abort, SCTP_SO_NOT_LOCKED); sctp_abort_notification(stcb, 1, error, abort, SCTP_SO_NOT_LOCKED);
...@@ -1178,13 +1177,12 @@ sctp_handle_shutdown_ack(struct sctp_shutdown_ack_chunk *cp SCTP_UNUSED, ...@@ -1178,13 +1177,12 @@ sctp_handle_shutdown_ack(struct sctp_shutdown_ack_chunk *cp SCTP_UNUSED,
} }
static void static void
sctp_process_unrecog_chunk(struct sctp_tcb *stcb, uint8_t chunk_type, sctp_process_unrecog_chunk(struct sctp_tcb *stcb, uint8_t chunk_type)
struct sctp_nets *net)
{ {
switch (chunk_type) { switch (chunk_type) {
case SCTP_ASCONF_ACK: case SCTP_ASCONF_ACK:
case SCTP_ASCONF: case SCTP_ASCONF:
sctp_asconf_cleanup(stcb, net); sctp_asconf_cleanup(stcb);
break; break;
case SCTP_IFORWARD_CUM_TSN: case SCTP_IFORWARD_CUM_TSN:
case SCTP_FORWARD_CUM_TSN: case SCTP_FORWARD_CUM_TSN:
...@@ -1362,7 +1360,7 @@ sctp_handle_error(struct sctp_chunkhdr *ch, ...@@ -1362,7 +1360,7 @@ sctp_handle_error(struct sctp_chunkhdr *ch,
struct sctp_error_unrecognized_chunk *unrec_chunk; struct sctp_error_unrecognized_chunk *unrec_chunk;
unrec_chunk = (struct sctp_error_unrecognized_chunk *)cause; 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; break;
case SCTP_CAUSE_UNRECOG_PARAM: case SCTP_CAUSE_UNRECOG_PARAM:
...@@ -1731,7 +1729,7 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, ...@@ -1731,7 +1729,7 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset,
SCTP_SET_STATE(stcb, SCTP_STATE_OPEN); SCTP_SET_STATE(stcb, SCTP_STATE_OPEN);
if (asoc->state & SCTP_STATE_SHUTDOWN_PENDING) { if (asoc->state & SCTP_STATE_SHUTDOWN_PENDING) {
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, 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_STAT_INCR_GAUGE32(sctps_currestab);
sctp_stop_all_cookie_timers(stcb); sctp_stop_all_cookie_timers(stcb);
...@@ -1971,7 +1969,7 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, ...@@ -1971,7 +1969,7 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset,
SCTP_SET_STATE(stcb, SCTP_STATE_OPEN); SCTP_SET_STATE(stcb, SCTP_STATE_OPEN);
if (asoc->state & SCTP_STATE_SHUTDOWN_PENDING) { if (asoc->state & SCTP_STATE_SHUTDOWN_PENDING) {
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, 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_stop_all_cookie_timers(stcb);
sctp_toss_old_cookies(stcb, asoc); sctp_toss_old_cookies(stcb, asoc);
...@@ -2042,7 +2040,7 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, ...@@ -2042,7 +2040,7 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset,
if (asoc->state & SCTP_STATE_SHUTDOWN_PENDING) { if (asoc->state & SCTP_STATE_SHUTDOWN_PENDING) {
SCTP_SET_STATE(stcb, SCTP_STATE_OPEN); SCTP_SET_STATE(stcb, SCTP_STATE_OPEN);
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, 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) { } else if (SCTP_GET_STATE(stcb) != SCTP_STATE_SHUTDOWN_SENT) {
/* move to OPEN state, if not in SHUTDOWN_SENT */ /* move to OPEN state, if not in SHUTDOWN_SENT */
...@@ -2471,7 +2469,7 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset, ...@@ -2471,7 +2469,7 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset,
SCTP_SET_STATE(stcb, SCTP_STATE_OPEN); SCTP_SET_STATE(stcb, SCTP_STATE_OPEN);
if (asoc->state & SCTP_STATE_SHUTDOWN_PENDING) { if (asoc->state & SCTP_STATE_SHUTDOWN_PENDING) {
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, 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_stop_all_cookie_timers(stcb);
SCTP_STAT_INCR_COUNTER32(sctps_passiveestab); SCTP_STAT_INCR_COUNTER32(sctps_passiveestab);
...@@ -2726,7 +2724,7 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset, ...@@ -2726,7 +2724,7 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset,
*/ */
(void)SCTP_GETTIME_TIMEVAL(&now); (void)SCTP_GETTIME_TIMEVAL(&now);
/* Expire time is in Ticks, so we convert to seconds */ /* 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_sec = cookie->time_entered.tv_sec + sctp_ticks_to_secs(cookie->cookie_life);
time_expires.tv_usec = cookie->time_entered.tv_usec; time_expires.tv_usec = cookie->time_entered.tv_usec;
#ifndef __FreeBSD__ #ifndef __FreeBSD__
if (timercmp(&now, &time_expires, >)) if (timercmp(&now, &time_expires, >))
...@@ -3166,7 +3164,7 @@ sctp_handle_cookie_ack(struct sctp_cookie_ack_chunk *cp SCTP_UNUSED, ...@@ -3166,7 +3164,7 @@ sctp_handle_cookie_ack(struct sctp_cookie_ack_chunk *cp SCTP_UNUSED,
sctp_start_net_timers(stcb); sctp_start_net_timers(stcb);
if (asoc->state & SCTP_STATE_SHUTDOWN_PENDING) { if (asoc->state & SCTP_STATE_SHUTDOWN_PENDING) {
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD,
stcb->sctp_ep, stcb, asoc->primary_destination); stcb->sctp_ep, stcb, NULL);
} }
/* update RTO */ /* update RTO */
...@@ -3838,7 +3836,7 @@ sctp_clean_up_stream_reset(struct sctp_tcb *stcb) ...@@ -3838,7 +3836,7 @@ sctp_clean_up_stream_reset(struct sctp_tcb *stcb)
} }
asoc->str_reset = NULL; asoc->str_reset = NULL;
sctp_timer_stop(SCTP_TIMER_TYPE_STRRESET, stcb->sctp_ep, stcb, 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); TAILQ_REMOVE(&asoc->control_send_queue, chk, sctp_next);
asoc->ctrl_queue_cnt--; asoc->ctrl_queue_cnt--;
if (chk->data) { if (chk->data) {
......
...@@ -68,7 +68,7 @@ __FBSDID("$FreeBSD$"); ...@@ -68,7 +68,7 @@ __FBSDID("$FreeBSD$");
#define SCTP_WQ_ADDR_DESTROY() #define SCTP_WQ_ADDR_DESTROY()
#define SCTP_WQ_ADDR_LOCK() #define SCTP_WQ_ADDR_LOCK()
#define SCTP_WQ_ADDR_UNLOCK() #define SCTP_WQ_ADDR_UNLOCK()
#define SCTP_WQ_ADDR_LOCK_ASSERT()
#define SCTP_IPI_ADDR_INIT() #define SCTP_IPI_ADDR_INIT()
#define SCTP_IPI_ADDR_DESTROY() #define SCTP_IPI_ADDR_DESTROY()
...@@ -82,14 +82,11 @@ __FBSDID("$FreeBSD$"); ...@@ -82,14 +82,11 @@ __FBSDID("$FreeBSD$");
#define SCTP_IPI_ITERATOR_WQ_LOCK() #define SCTP_IPI_ITERATOR_WQ_LOCK()
#define SCTP_IPI_ITERATOR_WQ_UNLOCK() #define SCTP_IPI_ITERATOR_WQ_UNLOCK()
#define SCTP_IP_PKTLOG_INIT() #define SCTP_IP_PKTLOG_INIT()
#define SCTP_IP_PKTLOG_LOCK() #define SCTP_IP_PKTLOG_LOCK()
#define SCTP_IP_PKTLOG_UNLOCK() #define SCTP_IP_PKTLOG_UNLOCK()
#define SCTP_IP_PKTLOG_DESTROY() #define SCTP_IP_PKTLOG_DESTROY()
#define SCTP_INP_READ_INIT(_inp) #define SCTP_INP_READ_INIT(_inp)
#define SCTP_INP_READ_DESTROY(_inp) #define SCTP_INP_READ_DESTROY(_inp)
#define SCTP_INP_READ_LOCK(_inp) #define SCTP_INP_READ_LOCK(_inp)
...@@ -100,9 +97,10 @@ __FBSDID("$FreeBSD$"); ...@@ -100,9 +97,10 @@ __FBSDID("$FreeBSD$");
#define SCTP_INP_LOCK_DESTROY(_inp) #define SCTP_INP_LOCK_DESTROY(_inp)
#define SCTP_ASOC_CREATE_LOCK_DESTROY(_inp) #define SCTP_ASOC_CREATE_LOCK_DESTROY(_inp)
#define SCTP_INP_RLOCK(_inp) #define SCTP_INP_RLOCK(_inp)
#define SCTP_INP_WLOCK(_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 */ #define SCTP_INP_LOCK_CONTENDED(_inp) (0) /* Don't know if this is possible */
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#ifdef __FreeBSD__ #ifdef __FreeBSD__
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.c 358083 2020-02-18 21:25:17Z tuexen $"); __FBSDID("$FreeBSD: head/sys/netinet/sctp_output.c 359156 2020-03-19 23:07:52Z tuexen $");
#endif #endif
#include <netinet/sctp_os.h> #include <netinet/sctp_os.h>
...@@ -7222,7 +7222,7 @@ sctp_sendall_iterator(struct sctp_inpcb *inp, struct sctp_tcb *stcb, void *ptr, ...@@ -7222,7 +7222,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, sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN, stcb->sctp_ep, stcb,
net); net);
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb, sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb,
asoc->primary_destination); NULL);
added_control = 1; added_control = 1;
do_chunk_output = 0; do_chunk_output = 0;
} }
...@@ -7262,7 +7262,7 @@ sctp_sendall_iterator(struct sctp_inpcb *inp, struct sctp_tcb *stcb, void *ptr, ...@@ -7262,7 +7262,7 @@ sctp_sendall_iterator(struct sctp_inpcb *inp, struct sctp_tcb *stcb, void *ptr,
goto no_chunk_output; goto no_chunk_output;
} }
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb, sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb,
asoc->primary_destination); NULL);
} }
} }
...@@ -8961,7 +8961,7 @@ again_one_more_time: ...@@ -8961,7 +8961,7 @@ again_one_more_time:
/* turn off the timer */ /* turn off the timer */
if (SCTP_OS_TIMER_PENDING(&stcb->asoc.dack_timer.timer)) { if (SCTP_OS_TIMER_PENDING(&stcb->asoc.dack_timer.timer)) {
sctp_timer_stop(SCTP_TIMER_TYPE_RECV, sctp_timer_stop(SCTP_TIMER_TYPE_RECV,
inp, stcb, net, inp, stcb, NULL,
SCTP_FROM_SCTP_OUTPUT + SCTP_LOC_1); SCTP_FROM_SCTP_OUTPUT + SCTP_LOC_1);
} }
} }
...@@ -14128,7 +14128,7 @@ sctp_lower_sosend(struct socket *so, ...@@ -14128,7 +14128,7 @@ sctp_lower_sosend(struct socket *so,
#endif #endif
sctp_abort_an_association(stcb->sctp_ep, stcb, mm, SCTP_SO_LOCKED); sctp_abort_an_association(stcb->sctp_ep, stcb, mm, SCTP_SO_LOCKED);
#if defined(__FreeBSD__) #if defined(__FreeBSD__)
NET_EPOCH_EXIT(et); NET_EPOCH_EXIT(et);
#endif #endif
/* now relock the stcb so everything is sane */ /* now relock the stcb so everything is sane */
hold_tcblock = 0; hold_tcblock = 0;
...@@ -14717,7 +14717,7 @@ dataless_eof: ...@@ -14717,7 +14717,7 @@ dataless_eof:
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN, stcb->sctp_ep, stcb, sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN, stcb->sctp_ep, stcb,
netp); netp);
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb, sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb,
asoc->primary_destination); NULL);
} }
} else { } else {
/*- /*-
...@@ -14757,12 +14757,12 @@ dataless_eof: ...@@ -14757,12 +14757,12 @@ dataless_eof:
op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code), op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code),
msg); msg);
#if defined(__FreeBSD__) #if defined(__FreeBSD__)
NET_EPOCH_ENTER(et); NET_EPOCH_ENTER(et);
#endif #endif
sctp_abort_an_association(stcb->sctp_ep, stcb, sctp_abort_an_association(stcb->sctp_ep, stcb,
op_err, SCTP_SO_LOCKED); op_err, SCTP_SO_LOCKED);
#if defined(__FreeBSD__) #if defined(__FreeBSD__)
NET_EPOCH_EXIT(et); NET_EPOCH_EXIT(et);
#endif #endif
/* now relock the stcb so everything is sane */ /* now relock the stcb so everything is sane */
hold_tcblock = 0; hold_tcblock = 0;
...@@ -14770,7 +14770,7 @@ dataless_eof: ...@@ -14770,7 +14770,7 @@ dataless_eof:
goto out; goto out;
} }
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb, sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb,
asoc->primary_destination); NULL);
sctp_feature_off(inp, SCTP_PCB_FLAGS_NODELAY); sctp_feature_off(inp, SCTP_PCB_FLAGS_NODELAY);
} }
} }
...@@ -14788,7 +14788,13 @@ skip_out_eof: ...@@ -14788,7 +14788,13 @@ skip_out_eof:
/* a collision took us forward? */ /* a collision took us forward? */
queue_only = 0; queue_only = 0;
} else { } else {
#if defined(__FreeBSD__)
NET_EPOCH_ENTER(et);
#endif
sctp_send_initiate(inp, stcb, SCTP_SO_LOCKED); sctp_send_initiate(inp, stcb, SCTP_SO_LOCKED);
#if defined(__FreeBSD__)
NET_EPOCH_EXIT(et);
#endif
SCTP_SET_STATE(stcb, SCTP_STATE_COOKIE_WAIT); SCTP_SET_STATE(stcb, SCTP_STATE_COOKIE_WAIT);
queue_only = 1; queue_only = 1;
} }
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#ifdef __FreeBSD__ #ifdef __FreeBSD__
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.c 357830 2020-02-12 17:05:10Z tuexen $"); __FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.c 359405 2020-03-28 20:25:45Z tuexen $");
#endif #endif
#include <netinet/sctp_os.h> #include <netinet/sctp_os.h>
...@@ -3000,13 +3000,13 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id) ...@@ -3000,13 +3000,13 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id)
m = &inp->sctp_ep; m = &inp->sctp_ep;
/* setup the base timeout information */ /* setup the base timeout information */
m->sctp_timeoutticks[SCTP_TIMER_SEND] = SEC_TO_TICKS(SCTP_SEND_SEC); /* needed ? */ m->sctp_timeoutticks[SCTP_TIMER_SEND] = sctp_secs_to_ticks(SCTP_SEND_SEC); /* needed ? */
m->sctp_timeoutticks[SCTP_TIMER_INIT] = SEC_TO_TICKS(SCTP_INIT_SEC); /* needed ? */ m->sctp_timeoutticks[SCTP_TIMER_INIT] = sctp_secs_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_RECV] = sctp_msecs_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_HEARTBEAT] = sctp_msecs_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_PMTU] = sctp_secs_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_MAXSHUTDOWN] = sctp_secs_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_SIGNATURE] = sctp_secs_to_ticks(SCTP_BASE_SYSCTL(sctp_secret_lifetime_default));
/* all max/min max are in ms */ /* all max/min max are in ms */
m->sctp_maxrto = SCTP_BASE_SYSCTL(sctp_rto_max_default); m->sctp_maxrto = SCTP_BASE_SYSCTL(sctp_rto_max_default);
m->sctp_minrto = SCTP_BASE_SYSCTL(sctp_rto_min_default); m->sctp_minrto = SCTP_BASE_SYSCTL(sctp_rto_min_default);
...@@ -3054,7 +3054,7 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id) ...@@ -3054,7 +3054,7 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id)
sctp_timer_start(SCTP_TIMER_TYPE_NEWCOOKIE, inp, NULL, NULL); sctp_timer_start(SCTP_TIMER_TYPE_NEWCOOKIE, inp, NULL, NULL);
/* How long is a cookie good for ? */ /* 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 * Initialize authentication parameters
*/ */
...@@ -4030,15 +4030,13 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from) ...@@ -4030,15 +4030,13 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from)
sctp_send_shutdown(asoc, netp); sctp_send_shutdown(asoc, netp);
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN, asoc->sctp_ep, asoc, sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN, asoc->sctp_ep, asoc,
netp); netp);
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, asoc->sctp_ep, asoc, sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, asoc->sctp_ep, asoc, NULL);
asoc->asoc.primary_destination);
sctp_chunk_output(inp, asoc, SCTP_OUTPUT_FROM_SHUT_TMR, SCTP_SO_LOCKED); sctp_chunk_output(inp, asoc, SCTP_OUTPUT_FROM_SHUT_TMR, SCTP_SO_LOCKED);
} }
} else { } else {
/* mark into shutdown pending */ /* mark into shutdown pending */
SCTP_ADD_SUBSTATE(asoc, SCTP_STATE_SHUTDOWN_PENDING); SCTP_ADD_SUBSTATE(asoc, SCTP_STATE_SHUTDOWN_PENDING);
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, asoc->sctp_ep, asoc, sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, asoc->sctp_ep, asoc, NULL);
asoc->asoc.primary_destination);
if ((*asoc->asoc.ss_functions.sctp_ss_is_user_msgs_incomplete)(asoc, &asoc->asoc)) { if ((*asoc->asoc.ss_functions.sctp_ss_is_user_msgs_incomplete)(asoc, &asoc->asoc)) {
SCTP_ADD_SUBSTATE(asoc, SCTP_STATE_PARTIAL_MSG_LEFT); SCTP_ADD_SUBSTATE(asoc, SCTP_STATE_PARTIAL_MSG_LEFT);
} }
...@@ -5511,35 +5509,6 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre ...@@ -5511,35 +5509,6 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre
else else
so = inp->sctp_socket; so = inp->sctp_socket;
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) {
/*
* For TCP type we need special handling when we are
* connected. We also include the peel'ed off ones to.
*/
if (inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED) {
inp->sctp_flags &= ~SCTP_PCB_FLAGS_CONNECTED;
inp->sctp_flags |= SCTP_PCB_FLAGS_WAS_CONNECTED;
if (so) {
SOCKBUF_LOCK(&so->so_rcv);
so->so_state &= ~(SS_ISCONNECTING |
SS_ISDISCONNECTING |
SS_ISCONFIRMING |
SS_ISCONNECTED);
so->so_state |= SS_ISDISCONNECTED;
#if defined(__APPLE__)
socantrcvmore(so);
#else
socantrcvmore_locked(so);
#endif
socantsendmore(so);
sctp_sowwakeup(inp, so);
sctp_sorwakeup(inp, so);
SCTP_SOWAKEUP(so);
}
}
}
/* /*
* We used timer based freeing if a reader or writer is in the way. * We used timer based freeing if a reader or writer is in the way.
* So we first check if we are actually being called from a timer, * So we first check if we are actually being called from a timer,
...@@ -5665,6 +5634,35 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre ...@@ -5665,6 +5634,35 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre
/* nothing around */ /* nothing around */
so = NULL; so = NULL;
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) {
/*
* For TCP type we need special handling when we are
* connected. We also include the peel'ed off ones to.
*/
if (inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED) {
inp->sctp_flags &= ~SCTP_PCB_FLAGS_CONNECTED;
inp->sctp_flags |= SCTP_PCB_FLAGS_WAS_CONNECTED;
if (so) {
SOCKBUF_LOCK(&so->so_rcv);
so->so_state &= ~(SS_ISCONNECTING |
SS_ISDISCONNECTING |
SS_ISCONFIRMING |
SS_ISCONNECTED);
so->so_state |= SS_ISDISCONNECTED;
#if defined(__APPLE__)
socantrcvmore(so);
#else
socantrcvmore_locked(so);
#endif
socantsendmore(so);
sctp_sowwakeup(inp, so);
sctp_sorwakeup(inp, so);
SCTP_SOWAKEUP(so);
}
}
}
/* Make it invalid too, that way if its /* Make it invalid too, that way if its
* about to run it will abort and return. * about to run it will abort and return.
*/ */
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#ifdef __FreeBSD__ #ifdef __FreeBSD__
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.h 354018 2019-10-24 09:22:23Z tuexen $"); __FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.h 359379 2020-03-27 21:48:52Z tuexen $");
#endif #endif
#ifndef _NETINET_SCTP_PCB_H_ #ifndef _NETINET_SCTP_PCB_H_
...@@ -363,11 +363,11 @@ struct sctp_pcb { ...@@ -363,11 +363,11 @@ struct sctp_pcb {
uint32_t secret_key[SCTP_HOW_MANY_SECRETS][SCTP_NUMBER_OF_SECRETS]; uint32_t secret_key[SCTP_HOW_MANY_SECRETS][SCTP_NUMBER_OF_SECRETS];
unsigned int size_of_a_cookie; unsigned int size_of_a_cookie;
unsigned int sctp_timeoutticks[SCTP_NUM_TMRS]; uint32_t sctp_timeoutticks[SCTP_NUM_TMRS];
unsigned int sctp_minrto; uint32_t sctp_minrto;
unsigned int sctp_maxrto; uint32_t sctp_maxrto;
unsigned int initial_rto; uint32_t initial_rto;
int initial_init_rto_max; uint32_t initial_init_rto_max;
unsigned int sctp_sack_freq; unsigned int sctp_sack_freq;
uint32_t sctp_sws_sender; uint32_t sctp_sws_sender;
...@@ -410,7 +410,7 @@ struct sctp_pcb { ...@@ -410,7 +410,7 @@ struct sctp_pcb {
uint32_t def_cookie_life; uint32_t def_cookie_life;
/* defaults to 0 */ /* defaults to 0 */
int auto_close_time; uint32_t auto_close_time;
uint32_t initial_sequence_debug; uint32_t initial_sequence_debug;
uint32_t adaptation_layer_indicator; uint32_t adaptation_layer_indicator;
uint8_t adaptation_layer_indicator_provided; uint8_t adaptation_layer_indicator_provided;
......
...@@ -86,7 +86,9 @@ ...@@ -86,7 +86,9 @@
#define SCTP_INP_RLOCK(_inp) #define SCTP_INP_RLOCK(_inp)
#define SCTP_INP_RUNLOCK(_inp) #define SCTP_INP_RUNLOCK(_inp)
#define SCTP_INP_WLOCK(_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_INCR_REF(_inp)
#define SCTP_INP_DECR_REF(_inp) #define SCTP_INP_DECR_REF(_inp)
...@@ -124,7 +126,7 @@ ...@@ -124,7 +126,7 @@
EnterCriticalSection(&SCTP_BASE_INFO(wq_addr_mtx)) EnterCriticalSection(&SCTP_BASE_INFO(wq_addr_mtx))
#define SCTP_WQ_ADDR_UNLOCK() \ #define SCTP_WQ_ADDR_UNLOCK() \
LeaveCriticalSection(&SCTP_BASE_INFO(wq_addr_mtx)) LeaveCriticalSection(&SCTP_BASE_INFO(wq_addr_mtx))
#define SCTP_WQ_ADDR_LOCK_ASSERT()
#define SCTP_INP_INFO_LOCK_INIT() \ #define SCTP_INP_INFO_LOCK_INIT() \
InitializeCriticalSection(&SCTP_BASE_INFO(ipi_ep_mtx)) InitializeCriticalSection(&SCTP_BASE_INFO(ipi_ep_mtx))
...@@ -185,6 +187,8 @@ ...@@ -185,6 +187,8 @@
#define SCTP_INP_WLOCK(_inp) \ #define SCTP_INP_WLOCK(_inp) \
EnterCriticalSection(&(_inp)->inp_mtx) EnterCriticalSection(&(_inp)->inp_mtx)
#endif #endif
#define SCTP_INP_RLOCK_ASSERT(_tcb)
#define SCTP_INP_WLOCK_ASSERT(_tcb)
#define SCTP_TCB_SEND_LOCK_INIT(_tcb) \ #define SCTP_TCB_SEND_LOCK_INIT(_tcb) \
InitializeCriticalSection(&(_tcb)->tcb_send_mtx) InitializeCriticalSection(&(_tcb)->tcb_send_mtx)
...@@ -263,6 +267,8 @@ ...@@ -263,6 +267,8 @@
#define SCTP_WQ_ADDR_UNLOCK() \ #define SCTP_WQ_ADDR_UNLOCK() \
(void)pthread_mutex_unlock(&SCTP_BASE_INFO(wq_addr_mtx)) (void)pthread_mutex_unlock(&SCTP_BASE_INFO(wq_addr_mtx))
#endif #endif
#define SCTP_WQ_ADDR_LOCK_ASSERT() \
KASSERT(pthread_mutex_trylock(&SCTP_BASE_INFO(wq_addr_mtx)) == EBUSY, ("%s: wq_addr_mtx not locked", __func__))
#define SCTP_INP_INFO_LOCK_INIT() \ #define SCTP_INP_INFO_LOCK_INIT() \
(void)pthread_mutex_init(&SCTP_BASE_INFO(ipi_ep_mtx), &SCTP_BASE_VAR(mtx_attr)) (void)pthread_mutex_init(&SCTP_BASE_INFO(ipi_ep_mtx), &SCTP_BASE_VAR(mtx_attr))
...@@ -377,6 +383,10 @@ ...@@ -377,6 +383,10 @@
#define SCTP_INP_WUNLOCK(_inp) \ #define SCTP_INP_WUNLOCK(_inp) \
(void)pthread_mutex_unlock(&(_inp)->inp_mtx) (void)pthread_mutex_unlock(&(_inp)->inp_mtx)
#endif #endif
#define SCTP_INP_RLOCK_ASSERT(_inp) \
KASSERT(pthread_mutex_trylock(&(_inp)->inp_mtx) == EBUSY, ("%s: inp_mtx not locked", __func__))
#define SCTP_INP_WLOCK_ASSERT(_inp) \
KASSERT(pthread_mutex_trylock(&(_inp)->inp_mtx) == EBUSY, ("%s: inp_mtx not locked", __func__))
#define SCTP_INP_INCR_REF(_inp) atomic_add_int(&((_inp)->refcount), 1) #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_add_int(&((_inp)->refcount), -1)
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#ifdef __FreeBSD__ #ifdef __FreeBSD__
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_structs.h 357501 2020-02-04 14:01:07Z tuexen $"); __FBSDID("$FreeBSD: head/sys/netinet/sctp_structs.h 359379 2020-03-27 21:48:52Z tuexen $");
#endif #endif
#ifndef _NETINET_SCTP_STRUCTS_H_ #ifndef _NETINET_SCTP_STRUCTS_H_
...@@ -334,7 +334,7 @@ struct sctp_nets { ...@@ -334,7 +334,7 @@ struct sctp_nets {
int lastsa; int lastsa;
int lastsv; int lastsv;
uint64_t rtt; /* last measured rtt value in us */ 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 */ /* This is used for SHUTDOWN/SHUTDOWN-ACK/SEND or INIT timers */
struct sctp_timer rxt_timer; struct sctp_timer rxt_timer;
...@@ -1121,7 +1121,7 @@ struct sctp_association { ...@@ -1121,7 +1121,7 @@ struct sctp_association {
uint32_t heart_beat_delay; uint32_t heart_beat_delay;
/* autoclose */ /* autoclose */
unsigned int sctp_autoclose_ticks; uint32_t sctp_autoclose_ticks;
/* how many preopen streams we have */ /* how many preopen streams we have */
unsigned int pre_open_streams; unsigned int pre_open_streams;
...@@ -1130,7 +1130,7 @@ struct sctp_association { ...@@ -1130,7 +1130,7 @@ struct sctp_association {
unsigned int max_inbound_streams; unsigned int max_inbound_streams;
/* the cookie life I award for any cookie, in seconds */ /* the cookie life I award for any cookie, in seconds */
unsigned int cookie_life; uint32_t cookie_life;
/* time to delay acks for */ /* time to delay acks for */
unsigned int delayed_ack; unsigned int delayed_ack;
unsigned int old_delayed_ack; unsigned int old_delayed_ack;
...@@ -1139,10 +1139,10 @@ struct sctp_association { ...@@ -1139,10 +1139,10 @@ struct sctp_association {
unsigned int numduptsns; unsigned int numduptsns;
int dup_tsns[SCTP_MAX_DUP_TSNS]; int dup_tsns[SCTP_MAX_DUP_TSNS];
unsigned int initial_init_rto_max; /* initial RTO for INIT's */ uint32_t initial_init_rto_max; /* initial RTO for INIT's */
unsigned int initial_rto; /* initial send RTO */ uint32_t initial_rto; /* initial send RTO */
unsigned int minrto; /* per assoc RTO-MIN */ uint32_t minrto; /* per assoc RTO-MIN */
unsigned int maxrto; /* per assoc RTO-MAX */ uint32_t maxrto; /* per assoc RTO-MAX */
/* authentication fields */ /* authentication fields */
sctp_auth_chklist_t *local_auth_chunks; sctp_auth_chklist_t *local_auth_chunks;
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#ifdef __FreeBSD__ #ifdef __FreeBSD__
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_timer.c 338134 2018-08-21 13:25:32Z tuexen $"); __FBSDID("$FreeBSD: head/sys/netinet/sctp_timer.c 359405 2020-03-28 20:25:45Z tuexen $");
#endif #endif
#define _IP_VHL #define _IP_VHL
...@@ -1108,10 +1108,9 @@ sctp_cookie_timer(struct sctp_inpcb *inp, ...@@ -1108,10 +1108,9 @@ sctp_cookie_timer(struct sctp_inpcb *inp,
} }
int int
sctp_strreset_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb, sctp_strreset_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb)
struct sctp_nets *net)
{ {
struct sctp_nets *alt; struct sctp_nets *alt, *net;
struct sctp_tmit_chunk *strrst = NULL, *chk = NULL; struct sctp_tmit_chunk *strrst = NULL, *chk = NULL;
if (stcb->asoc.stream_reset_outstanding == 0) { if (stcb->asoc.stream_reset_outstanding == 0) {
...@@ -1122,9 +1121,9 @@ sctp_strreset_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb, ...@@ -1122,9 +1121,9 @@ sctp_strreset_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
if (strrst == NULL) { if (strrst == NULL) {
return (0); return (0);
} }
net = strrst->whoTo;
/* do threshold management */ /* do threshold management */
if (sctp_threshold_management(inp, stcb, strrst->whoTo, if (sctp_threshold_management(inp, stcb, net, stcb->asoc.max_send_times)) {
stcb->asoc.max_send_times)) {
/* Assoc is over */ /* Assoc is over */
return (1); return (1);
} }
...@@ -1132,9 +1131,8 @@ sctp_strreset_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb, ...@@ -1132,9 +1131,8 @@ sctp_strreset_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
* Cleared threshold management, now lets backoff the address * Cleared threshold management, now lets backoff the address
* and select an alternate * and select an alternate
*/ */
sctp_backoff_on_timeout(stcb, strrst->whoTo, 1, 0, 0); sctp_backoff_on_timeout(stcb, net, 1, 0, 0);
alt = sctp_find_alternate_net(stcb, strrst->whoTo, 0); alt = sctp_find_alternate_net(stcb, net, 0);
sctp_free_remote_addr(strrst->whoTo);
strrst->whoTo = alt; strrst->whoTo = alt;
atomic_add_int(&alt->ref_count, 1); atomic_add_int(&alt->ref_count, 1);
...@@ -1159,6 +1157,8 @@ sctp_strreset_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb, ...@@ -1159,6 +1157,8 @@ sctp_strreset_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
*/ */
sctp_move_chunks_from_net(stcb, net); sctp_move_chunks_from_net(stcb, net);
} }
sctp_free_remote_addr(net);
/* mark the retran info */ /* mark the retran info */
if (strrst->sent != SCTP_DATAGRAM_RESEND) if (strrst->sent != SCTP_DATAGRAM_RESEND)
sctp_ucount_incr(stcb->asoc.sent_queue_retran_cnt); sctp_ucount_incr(stcb->asoc.sent_queue_retran_cnt);
...@@ -1166,7 +1166,7 @@ sctp_strreset_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb, ...@@ -1166,7 +1166,7 @@ sctp_strreset_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
strrst->flags |= CHUNK_FLAGS_FRAGMENT_OK; strrst->flags |= CHUNK_FLAGS_FRAGMENT_OK;
/* restart the timer */ /* 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); return (0);
} }
...@@ -1191,8 +1191,9 @@ sctp_asconf_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb, ...@@ -1191,8 +1191,9 @@ sctp_asconf_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
if (asconf == NULL) { if (asconf == NULL) {
return (0); return (0);
} }
net = asconf->whoTo;
/* do threshold management */ /* do threshold management */
if (sctp_threshold_management(inp, stcb, asconf->whoTo, if (sctp_threshold_management(inp, stcb, net,
stcb->asoc.max_send_times)) { stcb->asoc.max_send_times)) {
/* Assoc is over */ /* Assoc is over */
return (1); return (1);
...@@ -1205,17 +1206,16 @@ sctp_asconf_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb, ...@@ -1205,17 +1206,16 @@ sctp_asconf_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
* Mark this peer as ASCONF incapable and cleanup. * Mark this peer as ASCONF incapable and cleanup.
*/ */
SCTPDBG(SCTP_DEBUG_TIMER1, "asconf_timer: Peer has not responded to our repeated ASCONFs\n"); 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); return (0);
} }
/* /*
* cleared threshold management, so now backoff the net and * cleared threshold management, so now backoff the net and
* select an alternate * select an alternate
*/ */
sctp_backoff_on_timeout(stcb, asconf->whoTo, 1, 0, 0); sctp_backoff_on_timeout(stcb, net, 1, 0, 0);
alt = sctp_find_alternate_net(stcb, asconf->whoTo, 0); alt = sctp_find_alternate_net(stcb, net, 0);
if (asconf->whoTo != alt) { if (asconf->whoTo != alt) {
sctp_free_remote_addr(asconf->whoTo);
asconf->whoTo = alt; asconf->whoTo = alt;
atomic_add_int(&alt->ref_count, 1); atomic_add_int(&alt->ref_count, 1);
} }
...@@ -1252,6 +1252,8 @@ sctp_asconf_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb, ...@@ -1252,6 +1252,8 @@ sctp_asconf_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
*/ */
sctp_move_chunks_from_net(stcb, net); sctp_move_chunks_from_net(stcb, net);
} }
sctp_free_remote_addr(net);
/* mark the retran info */ /* mark the retran info */
if (asconf->sent != SCTP_DATAGRAM_RESEND) if (asconf->sent != SCTP_DATAGRAM_RESEND)
sctp_ucount_incr(stcb->asoc.sent_queue_retran_cnt); sctp_ucount_incr(stcb->asoc.sent_queue_retran_cnt);
...@@ -1266,8 +1268,7 @@ sctp_asconf_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb, ...@@ -1266,8 +1268,7 @@ sctp_asconf_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
/* Mobility adaptation */ /* Mobility adaptation */
void void
sctp_delete_prim_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb, sctp_delete_prim_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb)
struct sctp_nets *net SCTP_UNUSED)
{ {
if (stcb->asoc.deleted_primary == NULL) { if (stcb->asoc.deleted_primary == NULL) {
SCTPDBG(SCTP_DEBUG_ASCONF1, "delete_prim_timer: deleted_primary is not stored...\n"); SCTPDBG(SCTP_DEBUG_ASCONF1, "delete_prim_timer: deleted_primary is not stored...\n");
...@@ -1538,16 +1539,14 @@ sctp_pathmtu_timer(struct sctp_inpcb *inp, ...@@ -1538,16 +1539,14 @@ sctp_pathmtu_timer(struct sctp_inpcb *inp,
} }
void void
sctp_autoclose_timer(struct sctp_inpcb *inp, sctp_autoclose_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb)
struct sctp_tcb *stcb,
struct sctp_nets *net)
{ {
struct timeval tn, *tim_touse; struct timeval tn, *tim_touse;
struct sctp_association *asoc; struct sctp_association *asoc;
int ticks_gone_by; uint32_t ticks_gone_by;
(void)SCTP_GETTIME_TIMEVAL(&tn); (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)) { sctp_is_feature_on(inp, SCTP_PCB_FLAGS_AUTOCLOSE)) {
/* Auto close is on */ /* Auto close is on */
asoc = &stcb->asoc; asoc = &stcb->asoc;
...@@ -1559,9 +1558,8 @@ sctp_autoclose_timer(struct sctp_inpcb *inp, ...@@ -1559,9 +1558,8 @@ sctp_autoclose_timer(struct sctp_inpcb *inp,
tim_touse = &asoc->time_last_sent; tim_touse = &asoc->time_last_sent;
} }
/* Now has long enough transpired to autoclose? */ /* Now has long enough transpired to autoclose? */
ticks_gone_by = SEC_TO_TICKS(tn.tv_sec - tim_touse->tv_sec); ticks_gone_by = sctp_secs_to_ticks((uint32_t)(tn.tv_sec - tim_touse->tv_sec));
if ((ticks_gone_by > 0) && if (ticks_gone_by >= asoc->sctp_autoclose_ticks) {
(ticks_gone_by >= (int)asoc->sctp_autoclose_ticks)) {
/* /*
* autoclose time has hit, call the output routine, * autoclose time has hit, call the output routine,
* which should do nothing just to be SURE we don't * which should do nothing just to be SURE we don't
...@@ -1579,7 +1577,7 @@ sctp_autoclose_timer(struct sctp_inpcb *inp, ...@@ -1579,7 +1577,7 @@ sctp_autoclose_timer(struct sctp_inpcb *inp,
*/ */
if (SCTP_GET_STATE(stcb) != SCTP_STATE_SHUTDOWN_SENT) { if (SCTP_GET_STATE(stcb) != SCTP_STATE_SHUTDOWN_SENT) {
/* only send SHUTDOWN 1st time thru */ /* only send SHUTDOWN 1st time thru */
struct sctp_nets *netp; struct sctp_nets *net;
if ((SCTP_GET_STATE(stcb) == SCTP_STATE_OPEN) || if ((SCTP_GET_STATE(stcb) == SCTP_STATE_OPEN) ||
(SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_RECEIVED)) { (SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
...@@ -1588,17 +1586,15 @@ sctp_autoclose_timer(struct sctp_inpcb *inp, ...@@ -1588,17 +1586,15 @@ sctp_autoclose_timer(struct sctp_inpcb *inp,
SCTP_SET_STATE(stcb, SCTP_STATE_SHUTDOWN_SENT); SCTP_SET_STATE(stcb, SCTP_STATE_SHUTDOWN_SENT);
sctp_stop_timers_for_shutdown(stcb); sctp_stop_timers_for_shutdown(stcb);
if (stcb->asoc.alternate) { if (stcb->asoc.alternate) {
netp = stcb->asoc.alternate; net = stcb->asoc.alternate;
} else { } 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, sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN,
stcb->sctp_ep, stcb, stcb->sctp_ep, stcb, net);
netp);
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD,
stcb->sctp_ep, stcb, stcb->sctp_ep, stcb, NULL);
netp);
} }
} }
} else { } else {
...@@ -1606,13 +1602,12 @@ sctp_autoclose_timer(struct sctp_inpcb *inp, ...@@ -1606,13 +1602,12 @@ sctp_autoclose_timer(struct sctp_inpcb *inp,
* No auto close at this time, reset t-o to check * No auto close at this time, reset t-o to check
* later * later
*/ */
int tmp; uint32_t tmp;
/* fool the timer startup to use the time left */ /* fool the timer startup to use the time left */
tmp = asoc->sctp_autoclose_ticks; tmp = asoc->sctp_autoclose_ticks;
asoc->sctp_autoclose_ticks -= ticks_gone_by; asoc->sctp_autoclose_ticks -= ticks_gone_by;
sctp_timer_start(SCTP_TIMER_TYPE_AUTOCLOSE, inp, stcb, sctp_timer_start(SCTP_TIMER_TYPE_AUTOCLOSE, inp, stcb, NULL);
net);
/* restore the real tick value */ /* restore the real tick value */
asoc->sctp_autoclose_ticks = tmp; asoc->sctp_autoclose_ticks = tmp;
} }
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#ifdef __FreeBSD__ #ifdef __FreeBSD__
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_timer.h 295709 2016-02-17 18:04:22Z tuexen $"); __FBSDID("$FreeBSD: head/sys/netinet/sctp_timer.h 359195 2020-03-21 16:12:19Z tuexen $");
#endif #endif
#ifndef _NETINET_SCTP_TIMER_H_ #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 ...@@ -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 #define SCTP_RTT_VAR_SHIFT 2
struct sctp_nets * struct sctp_nets *
sctp_find_alternate_net(struct sctp_tcb *, sctp_find_alternate_net(struct sctp_tcb *, struct sctp_nets *, int);
struct sctp_nets *, int mode);
int int
sctp_t3rxt_timer(struct sctp_inpcb *, struct sctp_tcb *, sctp_t3rxt_timer(struct sctp_inpcb *, struct sctp_tcb *,
struct sctp_nets *); struct sctp_nets *);
int int
sctp_t1init_timer(struct sctp_inpcb *, struct sctp_tcb *, sctp_t1init_timer(struct sctp_inpcb *, struct sctp_tcb *,
struct sctp_nets *); struct sctp_nets *);
int int
sctp_shutdown_timer(struct sctp_inpcb *, struct sctp_tcb *, sctp_shutdown_timer(struct sctp_inpcb *, struct sctp_tcb *,
struct sctp_nets *); struct sctp_nets *);
int int
sctp_heartbeat_timer(struct sctp_inpcb *, struct sctp_tcb *, sctp_heartbeat_timer(struct sctp_inpcb *, struct sctp_tcb *,
struct sctp_nets *); struct sctp_nets *);
...@@ -74,20 +76,17 @@ int ...@@ -74,20 +76,17 @@ int
sctp_shutdownack_timer(struct sctp_inpcb *, struct sctp_tcb *, sctp_shutdownack_timer(struct sctp_inpcb *, struct sctp_tcb *,
struct sctp_nets *); struct sctp_nets *);
int int
sctp_strreset_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb, sctp_strreset_timer(struct sctp_inpcb *, struct sctp_tcb *);
struct sctp_nets *net);
int int
sctp_asconf_timer(struct sctp_inpcb *, struct sctp_tcb *, sctp_asconf_timer(struct sctp_inpcb *, struct sctp_tcb *,
struct sctp_nets *); struct sctp_nets *);
void void
sctp_delete_prim_timer(struct sctp_inpcb *, struct sctp_tcb *, sctp_delete_prim_timer(struct sctp_inpcb *, struct sctp_tcb *);
struct sctp_nets *);
void void
sctp_autoclose_timer(struct sctp_inpcb *, struct sctp_tcb *, sctp_autoclose_timer(struct sctp_inpcb *, struct sctp_tcb *);
struct sctp_nets *net);
void sctp_audit_retranmission_queue(struct sctp_association *); void sctp_audit_retranmission_queue(struct sctp_association *);
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#ifdef __FreeBSD__ #ifdef __FreeBSD__
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_usrreq.c 358083 2020-02-18 21:25:17Z tuexen $"); __FBSDID("$FreeBSD: head/sys/netinet/sctp_usrreq.c 359410 2020-03-28 22:35:04Z tuexen $");
#endif #endif
#include <netinet/sctp_os.h> #include <netinet/sctp_os.h>
...@@ -675,8 +675,10 @@ out: ...@@ -675,8 +675,10 @@ out:
return (error); return (error);
} }
SYSCTL_PROC(_net_inet_sctp, OID_AUTO, getcred, CTLTYPE_OPAQUE | CTLFLAG_RW, SYSCTL_PROC(_net_inet_sctp, OID_AUTO, getcred,
0, 0, sctp_getcred, "S,ucred", "Get the ucred of a SCTP connection"); CTLTYPE_OPAQUE | CTLFLAG_RW | CTLFLAG_NEEDGIANT,
0, 0, sctp_getcred, "S,ucred",
"Get the ucred of a SCTP connection");
#endif /* #if defined(__FreeBSD__) */ #endif /* #if defined(__FreeBSD__) */
...@@ -1258,9 +1260,9 @@ sctp_disconnect(struct socket *so) ...@@ -1258,9 +1260,9 @@ sctp_disconnect(struct socket *so)
} }
sctp_send_shutdown(stcb,netp); sctp_send_shutdown(stcb,netp);
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN, sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN,
stcb->sctp_ep, stcb, netp); stcb->sctp_ep, stcb, netp);
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, 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); sctp_chunk_output(stcb->sctp_ep, stcb, SCTP_OUTPUT_FROM_T3, SCTP_SO_LOCKED);
} }
} else { } else {
...@@ -1274,16 +1276,8 @@ sctp_disconnect(struct socket *so) ...@@ -1274,16 +1276,8 @@ sctp_disconnect(struct socket *so)
* we will allow user data to be sent first * we will allow user data to be sent first
* and move to SHUTDOWN-PENDING * 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_ADD_SUBSTATE(stcb, SCTP_STATE_SHUTDOWN_PENDING);
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb, sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb, NULL);
netp);
if ((*asoc->ss_functions.sctp_ss_is_user_msgs_incomplete)(stcb, asoc)) { if ((*asoc->ss_functions.sctp_ss_is_user_msgs_incomplete)(stcb, asoc)) {
SCTP_ADD_SUBSTATE(stcb, SCTP_STATE_PARTIAL_MSG_LEFT); SCTP_ADD_SUBSTATE(stcb, SCTP_STATE_PARTIAL_MSG_LEFT);
} }
...@@ -1501,7 +1495,7 @@ sctp_shutdown(struct socket *so) ...@@ -1501,7 +1495,7 @@ sctp_shutdown(struct socket *so)
return (0); 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? */ /* 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_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_CLOSING, SCTP_SO_LOCKED);
SCTP_TCB_UNLOCK(stcb); SCTP_TCB_UNLOCK(stcb);
...@@ -2270,7 +2264,7 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, ...@@ -2270,7 +2264,7 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
break; break;
case SCTP_AUTOCLOSE: case SCTP_AUTOCLOSE:
if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_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 else
val = 0; val = 0;
break; break;
...@@ -2700,7 +2694,7 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, ...@@ -2700,7 +2694,7 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) && ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
(sack->sack_assoc_id == SCTP_FUTURE_ASSOC))) { (sack->sack_assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_RLOCK(inp); 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; sack->sack_freq = inp->sctp_ep.sctp_sack_freq;
SCTP_INP_RUNLOCK(inp); SCTP_INP_RUNLOCK(inp);
} else { } else {
...@@ -3221,7 +3215,7 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, ...@@ -3221,7 +3215,7 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
/* Use endpoint defaults */ /* Use endpoint defaults */
SCTP_INP_RLOCK(inp); SCTP_INP_RLOCK(inp);
paddrp->spp_pathmaxrxt = inp->sctp_ep.def_net_failure; 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; paddrp->spp_assoc_id = SCTP_FUTURE_ASSOC;
/* get inp's default */ /* get inp's default */
if (inp->sctp_ep.default_dscp & 0x01) { if (inp->sctp_ep.default_dscp & 0x01) {
...@@ -3389,17 +3383,33 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, ...@@ -3389,17 +3383,33 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
if (net != NULL) { if (net != NULL) {
#ifdef HAVE_SA_LEN #ifdef HAVE_SA_LEN
memcpy(&sstat->sstat_primary.spinfo_address, memcpy(&sstat->sstat_primary.spinfo_address,
&stcb->asoc.primary_destination->ro._l_addr, &net->ro._l_addr,
((struct sockaddr *)(&stcb->asoc.primary_destination->ro._l_addr))->sa_len); ((struct sockaddr *)(&net->ro._l_addr))->sa_len);
#else #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, memcpy(&sstat->sstat_primary.spinfo_address,
&stcb->asoc.primary_destination->ro._l_addr, &net->ro._l_addr,
sizeof(struct sockaddr_in)); sizeof(struct sockaddr_in));
} else { break;
#endif
#if defined(INET6)
case AF_INET6:
memcpy(&sstat->sstat_primary.spinfo_address, memcpy(&sstat->sstat_primary.spinfo_address,
&stcb->asoc.primary_destination->ro._l_addr, &net->ro._l_addr,
sizeof(struct sockaddr_in6)); 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 #endif
((struct sockaddr_in *)&sstat->sstat_primary.spinfo_address)->sin_port = stcb->rport; ((struct sockaddr_in *)&sstat->sstat_primary.spinfo_address)->sin_port = stcb->rport;
...@@ -3511,7 +3521,7 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, ...@@ -3511,7 +3521,7 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
SCTP_FIND_STCB(inp, stcb, sasoc->sasoc_assoc_id); SCTP_FIND_STCB(inp, stcb, sasoc->sasoc_assoc_id);
if (stcb) { 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_asocmaxrxt = stcb->asoc.max_send_times;
sasoc->sasoc_number_peer_destinations = stcb->asoc.numnets; sasoc->sasoc_number_peer_destinations = stcb->asoc.numnets;
sasoc->sasoc_peer_rwnd = stcb->asoc.peers_rwnd; sasoc->sasoc_peer_rwnd = stcb->asoc.peers_rwnd;
...@@ -3523,7 +3533,7 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, ...@@ -3523,7 +3533,7 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) && ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
(sasoc->sasoc_assoc_id == SCTP_FUTURE_ASSOC))) { (sasoc->sasoc_assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_RLOCK(inp); 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_asocmaxrxt = inp->sctp_ep.max_send_times;
sasoc->sasoc_number_peer_destinations = 0; sasoc->sasoc_number_peer_destinations = 0;
sasoc->sasoc_peer_rwnd = 0; sasoc->sasoc_peer_rwnd = 0;
...@@ -4644,7 +4654,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, ...@@ -4644,7 +4654,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
* The value is in ticks. Note this does not effect * The value is in ticks. Note this does not effect
* old associations, only new ones. * 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; break;
} }
SCTP_INP_WLOCK(inp); SCTP_INP_WLOCK(inp);
...@@ -5146,10 +5156,12 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, ...@@ -5146,10 +5156,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_CHECK_AND_CAST(sack, optval, struct sctp_sack_info, optsize);
SCTP_FIND_STCB(inp, stcb, sack->sack_assoc_id); SCTP_FIND_STCB(inp, stcb, sack->sack_assoc_id);
if (sack->sack_delay) { if (sack->sack_delay) {
if (sack->sack_delay > SCTP_MAX_SACK_DELAY) if (sack->sack_delay > SCTP_MAX_SACK_DELAY) {
sack->sack_delay = SCTP_MAX_SACK_DELAY; error = EINVAL;
if (MSEC_TO_TICKS(sack->sack_delay) < 1) { if (stcb != NULL) {
sack->sack_delay = TICKS_TO_MSEC(1); SCTP_TCB_UNLOCK(stcb);
}
break;
} }
} }
if (stcb) { if (stcb) {
...@@ -5168,7 +5180,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, ...@@ -5168,7 +5180,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
(sack->sack_assoc_id == SCTP_ALL_ASSOC)))) { (sack->sack_assoc_id == SCTP_ALL_ASSOC)))) {
SCTP_INP_WLOCK(inp); SCTP_INP_WLOCK(inp);
if (sack->sack_delay) { 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) { if (sack->sack_freq) {
inp->sctp_ep.sctp_sack_freq = sack->sack_freq; inp->sctp_ep.sctp_sack_freq = sack->sack_freq;
...@@ -5222,7 +5234,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, ...@@ -5222,7 +5234,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
if (sca->sca_keylength == 0) { if (sca->sca_keylength == 0) {
size = optsize - sizeof(struct sctp_authkey); size = optsize - sizeof(struct sctp_authkey);
} else { } else {
if (sca->sca_keylength + sizeof(struct sctp_authkey) <= optsize) { if (sca->sca_keylength + sizeof(struct sctp_authkey) <= optsize) {
size = sca->sca_keylength; size = sca->sca_keylength;
} else { } else {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
...@@ -6539,14 +6551,14 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, ...@@ -6539,14 +6551,14 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
else if (paddrp->spp_hbinterval != 0) { else if (paddrp->spp_hbinterval != 0) {
if (paddrp->spp_hbinterval > SCTP_MAX_HB_INTERVAL) if (paddrp->spp_hbinterval > SCTP_MAX_HB_INTERVAL)
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_ENABLE) {
if (paddrp->spp_flags & SPP_HB_TIME_IS_ZERO) { if (paddrp->spp_flags & SPP_HB_TIME_IS_ZERO) {
inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_HEARTBEAT] = 0; inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_HEARTBEAT] = 0;
} else if (paddrp->spp_hbinterval) { } 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); sctp_feature_off(inp, SCTP_PCB_FLAGS_DONOT_HEARTBEAT);
} else if (paddrp->spp_flags & SPP_HB_DISABLE) { } else if (paddrp->spp_flags & SPP_HB_DISABLE) {
...@@ -6661,7 +6673,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, ...@@ -6661,7 +6673,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
if (sasoc->sasoc_asocmaxrxt) if (sasoc->sasoc_asocmaxrxt)
stcb->asoc.max_send_times = sasoc->sasoc_asocmaxrxt; stcb->asoc.max_send_times = sasoc->sasoc_asocmaxrxt;
if (sasoc->sasoc_cookie_life) { if (sasoc->sasoc_cookie_life) {
stcb->asoc.cookie_life = MSEC_TO_TICKS(sasoc->sasoc_cookie_life); stcb->asoc.cookie_life = sctp_msecs_to_ticks(sasoc->sasoc_cookie_life);
} }
SCTP_TCB_UNLOCK(stcb); SCTP_TCB_UNLOCK(stcb);
} else { } else {
...@@ -6673,7 +6685,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, ...@@ -6673,7 +6685,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
if (sasoc->sasoc_asocmaxrxt) if (sasoc->sasoc_asocmaxrxt)
inp->sctp_ep.max_send_times = sasoc->sasoc_asocmaxrxt; inp->sctp_ep.max_send_times = sasoc->sasoc_asocmaxrxt;
if (sasoc->sasoc_cookie_life) { if (sasoc->sasoc_cookie_life) {
inp->sctp_ep.def_cookie_life = MSEC_TO_TICKS(sasoc->sasoc_cookie_life); inp->sctp_ep.def_cookie_life = sctp_msecs_to_ticks(sasoc->sasoc_cookie_life);
} }
SCTP_INP_WUNLOCK(inp); SCTP_INP_WUNLOCK(inp);
} else { } else {
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#ifdef __FreeBSD__ #ifdef __FreeBSD__
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctputil.h 357775 2020-02-11 20:02:20Z tuexen $"); __FBSDID("$FreeBSD: head/sys/netinet/sctputil.h 359405 2020-03-28 20:25:45Z tuexen $");
#endif #endif
#ifndef _NETINET_SCTP_UTIL_H_ #ifndef _NETINET_SCTP_UTIL_H_
...@@ -430,5 +430,10 @@ uint32_t sctp_hc_get_mtu(union sctp_sockstore *, uint16_t); ...@@ -430,5 +430,10 @@ uint32_t sctp_hc_get_mtu(union sctp_sockstore *, uint16_t);
#endif #endif
void sctp_set_state(struct sctp_tcb *, int); void sctp_set_state(struct sctp_tcb *, int);
void sctp_add_substate(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 /* _KERNEL */
#endif #endif
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论