Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
64eb1e5f
提交
64eb1e5f
authored
4月 05, 2020
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Really update usrsctp
上级
99fe3bb1
隐藏空白字符变更
内嵌
并排
正在显示
24 个修改的文件
包含
987 行增加
和
590 行删除
+987
-590
CHANGELOG.md
CHANGELOG.md
+5
-0
CMakeLists.txt
worker/deps/usrsctp/usrsctp/CMakeLists.txt
+2
-1
ekr_loop.c
worker/deps/usrsctp/usrsctp/programs/ekr_loop.c
+12
-0
programs_helper.c
worker/deps/usrsctp/usrsctp/programs/programs_helper.c
+15
-1
CMakeLists.txt
worker/deps/usrsctp/usrsctp/usrsctplib/CMakeLists.txt
+9
-3
sctp_asconf.c
worker/deps/usrsctp/usrsctp/usrsctplib/netinet/sctp_asconf.c
+5
-6
sctp_asconf.h
worker/deps/usrsctp/usrsctp/usrsctplib/netinet/sctp_asconf.h
+2
-2
sctp_auth.c
worker/deps/usrsctp/usrsctp/usrsctplib/netinet/sctp_auth.c
+5
-5
sctp_callout.c
...er/deps/usrsctp/usrsctp/usrsctplib/netinet/sctp_callout.c
+2
-1
sctp_cc_functions.c
...ps/usrsctp/usrsctp/usrsctplib/netinet/sctp_cc_functions.c
+3
-3
sctp_constants.h
.../deps/usrsctp/usrsctp/usrsctplib/netinet/sctp_constants.h
+1
-11
sctp_indata.c
worker/deps/usrsctp/usrsctp/usrsctplib/netinet/sctp_indata.c
+3
-3
sctp_input.c
worker/deps/usrsctp/usrsctp/usrsctplib/netinet/sctp_input.c
+13
-15
sctp_lock_userspace.h
.../usrsctp/usrsctp/usrsctplib/netinet/sctp_lock_userspace.h
+3
-5
sctp_output.c
worker/deps/usrsctp/usrsctp/usrsctplib/netinet/sctp_output.c
+15
-9
sctp_pcb.c
worker/deps/usrsctp/usrsctp/usrsctplib/netinet/sctp_pcb.c
+40
-42
sctp_pcb.h
worker/deps/usrsctp/usrsctp/usrsctplib/netinet/sctp_pcb.h
+7
-7
sctp_process_lock.h
...ps/usrsctp/usrsctp/usrsctplib/netinet/sctp_process_lock.h
+12
-2
sctp_structs.h
...er/deps/usrsctp/usrsctp/usrsctplib/netinet/sctp_structs.h
+8
-8
sctp_timer.c
worker/deps/usrsctp/usrsctp/usrsctplib/netinet/sctp_timer.c
+31
-36
sctp_timer.h
worker/deps/usrsctp/usrsctp/usrsctplib/netinet/sctp_timer.h
+8
-9
sctp_usrreq.c
worker/deps/usrsctp/usrsctp/usrsctplib/netinet/sctp_usrreq.c
+49
-37
sctputil.c
worker/deps/usrsctp/usrsctp/usrsctplib/netinet/sctputil.c
+731
-383
sctputil.h
worker/deps/usrsctp/usrsctp/usrsctplib/netinet/sctputil.h
+6
-1
没有找到文件。
CHANGELOG.md
浏览文件 @
64eb1e5f
# Changelog
### 3.5.7 (WIP)
*
Update
`usrsctp`
library.
### 3.5.6
*
`SeqManager.cpp`
: Fix video lag after a long time.
...
...
worker/deps/usrsctp/usrsctp/CMakeLists.txt
浏览文件 @
64eb1e5f
...
...
@@ -259,8 +259,9 @@ elseif (CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID MATCHES "Appl
endif
()
if
(
sctp_build_fuzzer
)
set
(
CMAKE_BUILD_TYPE
"DEBUG"
)
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
()
...
...
worker/deps/usrsctp/usrsctp/programs/ekr_loop.c
浏览文件 @
64eb1e5f
...
...
@@ -263,6 +263,7 @@ 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
...
...
@@ -413,6 +414,17 @@ main(int argc, char *argv[])
exit
(
EXIT_FAILURE
);
}
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
)
{
perror
(
"usrsctp_socket"
);
exit
(
EXIT_FAILURE
);
...
...
worker/deps/usrsctp/usrsctp/programs/programs_helper.c
浏览文件 @
64eb1e5f
...
...
@@ -52,10 +52,24 @@ 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
(
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
);
//vfprintf(stderr, format, ap);
vsnprintf
(
charbuf
,
1024
,
format
,
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
...
...
worker/deps/usrsctp/usrsctp/usrsctplib/CMakeLists.txt
浏览文件 @
64eb1e5f
...
...
@@ -43,6 +43,8 @@ set(includedir ${prefix}/include/usrsctp)
set
(
CMAKE_REQUIRED_INCLUDES
${
CMAKE_CURRENT_SOURCE_DIR
}
)
set
(
CMAKE_MACOSX_RPATH 1
)
include
(
CheckCCompilerFlag
)
add_definitions
(
-D__Userspace__
)
add_definitions
(
-D__Userspace_os_
${
CMAKE_SYSTEM_NAME
}
)
add_definitions
(
-DSCTP_SIMPLE_ALLOCATOR
)
...
...
@@ -53,11 +55,16 @@ add_definitions(-DSCTP_PROCESS_LEVEL_LOCKS)
# OS DEPENDENT
#################################################
check_c_compiler_flag
(
-Wno-address-of-packed-member has_wno_address_of_packe
t
_member
)
if
(
has_wno_address_of_packe
t
_member
)
check_c_compiler_flag
(
-Wno-address-of-packed-member has_wno_address_of_packe
d
_member
)
if
(
has_wno_address_of_packe
d
_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
()
...
...
@@ -69,7 +76,6 @@ endif ()
if
(
CMAKE_SYSTEM_NAME MATCHES
"Darwin"
)
add_definitions
(
-U__APPLE__
)
add_definitions
(
-D__APPLE_USE_RFC_2292
)
set
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
-Wno-deprecated-declarations"
)
endif
()
if
(
CMAKE_SYSTEM_NAME MATCHES
"DragonFly"
)
...
...
worker/deps/usrsctp/usrsctp/usrsctplib/netinet/sctp_asconf.c
浏览文件 @
64eb1e5f
...
...
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
__FBSDID
(
"$FreeBSD: head/sys/netinet/sctp_asconf.c 35
7197 2020-01-28 10:09:05
Z tuexen $"
);
__FBSDID
(
"$FreeBSD: head/sys/netinet/sctp_asconf.c 35
9195 2020-03-21 16:12:19
Z tuexen $"
);
#endif
#include <netinet/sctp_os.h>
...
...
@@ -602,8 +602,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! */
...
...
@@ -955,12 +954,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 */
...
...
@@ -1739,7 +1738,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
);
}
...
...
worker/deps/usrsctp/usrsctp/usrsctplib/netinet/sctp_asconf.h
浏览文件 @
64eb1e5f
...
...
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
__FBSDID
(
"$FreeBSD: head/sys/netinet/sctp_asconf.h 3
24056 2017-09-27 13:05:23
Z tuexen $"
);
__FBSDID
(
"$FreeBSD: head/sys/netinet/sctp_asconf.h 3
59152 2020-03-19 21:01:16
Z tuexen $"
);
#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
);
...
...
worker/deps/usrsctp/usrsctp/usrsctplib/netinet/sctp_auth.c
浏览文件 @
64eb1e5f
...
...
@@ -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
"
,
shared_key_id
,
hmac_id
);
#if defined(__Userspace__)
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
return
(
0
);
#endif
#endif
/* is the indicated HMAC supported? */
if
(
!
sctp_auth_is_supported_hmac
(
stcb
->
asoc
.
local_hmacs
,
hmac_id
))
{
struct
mbuf
*
op_err
;
...
...
@@ -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
,
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
);
...
...
worker/deps/usrsctp/usrsctp/usrsctplib/netinet/sctp_callout.c
浏览文件 @
64eb1e5f
...
...
@@ -54,6 +54,7 @@
#include <netinet/sctp_callout.h>
#include <netinet/sctp_pcb.h>
#endif
#include <netinet/sctputil.h>
/*
* Callout/Timer routines for OS that doesn't have them
...
...
@@ -210,7 +211,7 @@ 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
);
}
...
...
worker/deps/usrsctp/usrsctp/usrsctplib/netinet/sctp_cc_functions.c
浏览文件 @
64eb1e5f
...
...
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
__FBSDID
(
"$FreeBSD: head/sys/netinet/sctp_cc_functions.c 35
6660 2020-01-12 15:45:27
Z tuexen $"
);
__FBSDID
(
"$FreeBSD: head/sys/netinet/sctp_cc_functions.c 35
9405 2020-03-28 20:25:45
Z tuexen $"
);
#endif
#include <netinet/sctp_os.h>
...
...
@@ -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
->
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 +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
;
if
(
ca
->
beta
<
BETA_MIN
)
ca
->
beta
=
BETA_MIN
;
...
...
worker/deps/usrsctp/usrsctp/usrsctplib/netinet/sctp_constants.h
浏览文件 @
64eb1e5f
...
...
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
__FBSDID
(
"$FreeBSD: head/sys/netinet/sctp_constants.h 35
8169 2020-02-20 15:37:44
Z tuexen $"
);
__FBSDID
(
"$FreeBSD: head/sys/netinet/sctp_constants.h 35
9405 2020-03-28 20:25:45
Z tuexen $"
);
#endif
#ifndef _NETINET_SCTP_CONSTANTS_H_
...
...
@@ -593,16 +593,6 @@ extern void getwintimeofday(struct timeval *tv);
#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
* value to low will cause duplicate retransmissions.
...
...
worker/deps/usrsctp/usrsctp/usrsctplib/netinet/sctp_indata.c
浏览文件 @
64eb1e5f
...
...
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
__FBSDID
(
"$FreeBSD: head/sys/netinet/sctp_indata.c 35
7705 2020-02-09 22:05:41
Z tuexen $"
);
__FBSDID
(
"$FreeBSD: head/sys/netinet/sctp_indata.c 35
9152 2020-03-19 21:01:16
Z tuexen $"
);
#endif
#include <netinet/sctp_os.h>
...
...
@@ -4378,7 +4378,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
;
...
...
@@ -5094,7 +5094,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
))
{
...
...
worker/deps/usrsctp/usrsctp/usrsctplib/netinet/sctp_input.c
浏览文件 @
64eb1e5f
...
...
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
__FBSDID
(
"$FreeBSD: head/sys/netinet/sctp_input.c 35
5135 2019-11-27 19:32:29
Z tuexen $"
);
__FBSDID
(
"$FreeBSD: head/sys/netinet/sctp_input.c 35
9405 2020-03-28 20:25:45
Z tuexen $"
);
#endif
#include <netinet/sctp_os.h>
...
...
@@ -778,8 +778,7 @@ sctp_handle_heartbeat_ack(struct sctp_heartbeat_chunk *cp,
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
);
}
}
}
...
...
@@ -895,7 +894,7 @@ 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
);
...
...
@@ -1178,13 +1177,12 @@ sctp_handle_shutdown_ack(struct sctp_shutdown_ack_chunk *cp SCTP_UNUSED,
}
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
:
...
...
@@ -1362,7 +1360,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
:
...
...
@@ -1731,7 +1729,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_STAT_INCR_GAUGE32
(
sctps_currestab
);
sctp_stop_all_cookie_timers
(
stcb
);
...
...
@@ -1971,7 +1969,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
);
...
...
@@ -2042,7 +2040,7 @@ 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 */
...
...
@@ -2471,7 +2469,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
);
...
...
@@ -2726,7 +2724,7 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset,
*/
(
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_sec
=
cookie
->
time_entered
.
tv_sec
+
sctp_ticks_to_secs
(
cookie
->
cookie_life
);
time_expires
.
tv_usec
=
cookie
->
time_entered
.
tv_usec
;
#ifndef __FreeBSD__
if
(
timercmp
(
&
now
,
&
time_expires
,
>
))
...
...
@@ -3166,7 +3164,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 */
...
...
@@ -3838,7 +3836,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
)
{
...
...
worker/deps/usrsctp/usrsctp/usrsctplib/netinet/sctp_lock_userspace.h
浏览文件 @
64eb1e5f
...
...
@@ -68,7 +68,7 @@ __FBSDID("$FreeBSD$");
#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()
...
...
@@ -82,14 +82,11 @@ __FBSDID("$FreeBSD$");
#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 +97,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 */
...
...
worker/deps/usrsctp/usrsctp/usrsctplib/netinet/sctp_output.c
浏览文件 @
64eb1e5f
...
...
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
__FBSDID
(
"$FreeBSD: head/sys/netinet/sctp_output.c 35
8083 2020-02-18 21:25:17
Z tuexen $"
);
__FBSDID
(
"$FreeBSD: head/sys/netinet/sctp_output.c 35
9156 2020-03-19 23:07:52
Z tuexen $"
);
#endif
#include <netinet/sctp_os.h>
...
...
@@ -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
,
net
);
sctp_timer_start
(
SCTP_TIMER_TYPE_SHUTDOWNGUARD
,
stcb
->
sctp_ep
,
stcb
,
asoc
->
primary_destination
);
NULL
);
added_control
=
1
;
do_chunk_output
=
0
;
}
...
...
@@ -7262,7 +7262,7 @@ sctp_sendall_iterator(struct sctp_inpcb *inp, struct sctp_tcb *stcb, void *ptr,
goto
no_chunk_output
;
}
sctp_timer_start
(
SCTP_TIMER_TYPE_SHUTDOWNGUARD
,
stcb
->
sctp_ep
,
stcb
,
asoc
->
primary_destination
);
NULL
);
}
}
...
...
@@ -8961,7 +8961,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
);
}
}
...
...
@@ -14128,7 +14128,7 @@ sctp_lower_sosend(struct socket *so,
#endif
sctp_abort_an_association
(
stcb
->
sctp_ep
,
stcb
,
mm
,
SCTP_SO_LOCKED
);
#if defined(__FreeBSD__)
NET_EPOCH_EXIT
(
et
);
NET_EPOCH_EXIT
(
et
);
#endif
/* now relock the stcb so everything is sane */
hold_tcblock
=
0
;
...
...
@@ -14717,7 +14717,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
{
/*-
...
...
@@ -14757,12 +14757,12 @@ dataless_eof:
op_err
=
sctp_generate_cause
(
SCTP_BASE_SYSCTL
(
sctp_diag_info_code
),
msg
);
#if defined(__FreeBSD__)
NET_EPOCH_ENTER
(
et
);
NET_EPOCH_ENTER
(
et
);
#endif
sctp_abort_an_association
(
stcb
->
sctp_ep
,
stcb
,
op_err
,
SCTP_SO_LOCKED
);
#if defined(__FreeBSD__)
NET_EPOCH_EXIT
(
et
);
NET_EPOCH_EXIT
(
et
);
#endif
/* now relock the stcb so everything is sane */
hold_tcblock
=
0
;
...
...
@@ -14770,7 +14770,7 @@ dataless_eof:
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
);
}
}
...
...
@@ -14788,7 +14788,13 @@ skip_out_eof:
/* a collision took us forward? */
queue_only
=
0
;
}
else
{
#if defined(__FreeBSD__)
NET_EPOCH_ENTER
(
et
);
#endif
sctp_send_initiate
(
inp
,
stcb
,
SCTP_SO_LOCKED
);
#if defined(__FreeBSD__)
NET_EPOCH_EXIT
(
et
);
#endif
SCTP_SET_STATE
(
stcb
,
SCTP_STATE_COOKIE_WAIT
);
queue_only
=
1
;
}
...
...
worker/deps/usrsctp/usrsctp/usrsctplib/netinet/sctp_pcb.c
浏览文件 @
64eb1e5f
...
...
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
__FBSDID
(
"$FreeBSD: head/sys/netinet/sctp_pcb.c 35
7830 2020-02-12 17:05:10
Z tuexen $"
);
__FBSDID
(
"$FreeBSD: head/sys/netinet/sctp_pcb.c 35
9405 2020-03-28 20:25:45
Z tuexen $"
);
#endif
#include <netinet/sctp_os.h>
...
...
@@ -3000,13 +3000,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
);
...
...
@@ -3054,7 +3054,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
*/
...
...
@@ -4030,15 +4030,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
);
}
...
...
@@ -5511,35 +5509,6 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre
else
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.
* 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
/* nothing around */
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
* about to run it will abort and return.
*/
...
...
worker/deps/usrsctp/usrsctp/usrsctplib/netinet/sctp_pcb.h
浏览文件 @
64eb1e5f
...
...
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
__FBSDID
(
"$FreeBSD: head/sys/netinet/sctp_pcb.h 35
4018 2019-10-24 09:22:23
Z tuexen $"
);
__FBSDID
(
"$FreeBSD: head/sys/netinet/sctp_pcb.h 35
9379 2020-03-27 21:48:52
Z tuexen $"
);
#endif
#ifndef _NETINET_SCTP_PCB_H_
...
...
@@ -363,11 +363,11 @@ struct sctp_pcb {
uint32_t
secret_key
[
SCTP_HOW_MANY_SECRETS
][
SCTP_NUMBER_OF_SECRETS
];
unsigned
int
size_of_a_cookie
;
u
nsigned
in
t
sctp_timeoutticks
[
SCTP_NUM_TMRS
];
u
nsigned
in
t
sctp_minrto
;
u
nsigned
in
t
sctp_maxrto
;
u
nsigned
in
t
initial_rto
;
in
t
initial_init_rto_max
;
u
int32_
t
sctp_timeoutticks
[
SCTP_NUM_TMRS
];
u
int32_
t
sctp_minrto
;
u
int32_
t
sctp_maxrto
;
u
int32_
t
initial_rto
;
uint32_
t
initial_init_rto_max
;
unsigned
int
sctp_sack_freq
;
uint32_t
sctp_sws_sender
;
...
...
@@ -410,7 +410,7 @@ struct sctp_pcb {
uint32_t
def_cookie_life
;
/* defaults to 0 */
in
t
auto_close_time
;
uint32_
t
auto_close_time
;
uint32_t
initial_sequence_debug
;
uint32_t
adaptation_layer_indicator
;
uint8_t
adaptation_layer_indicator_provided
;
...
...
worker/deps/usrsctp/usrsctp/usrsctplib/netinet/sctp_process_lock.h
浏览文件 @
64eb1e5f
...
...
@@ -86,7 +86,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)
...
...
@@ -124,7 +126,7 @@
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()
#define SCTP_INP_INFO_LOCK_INIT() \
InitializeCriticalSection(&SCTP_BASE_INFO(ipi_ep_mtx))
...
...
@@ -185,6 +187,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)
...
...
@@ -263,6 +267,8 @@
#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: wq_addr_mtx not locked", __func__))
#define SCTP_INP_INFO_LOCK_INIT() \
(void)pthread_mutex_init(&SCTP_BASE_INFO(ipi_ep_mtx), &SCTP_BASE_VAR(mtx_attr))
...
...
@@ -377,6 +383,10 @@
#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: 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_DECR_REF(_inp) atomic_add_int(&((_inp)->refcount), -1)
...
...
worker/deps/usrsctp/usrsctp/usrsctplib/netinet/sctp_structs.h
浏览文件 @
64eb1e5f
...
...
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
__FBSDID
(
"$FreeBSD: head/sys/netinet/sctp_structs.h 35
7501 2020-02-04 14:01:07
Z tuexen $"
);
__FBSDID
(
"$FreeBSD: head/sys/netinet/sctp_structs.h 35
9379 2020-03-27 21:48:52
Z tuexen $"
);
#endif
#ifndef _NETINET_SCTP_STRUCTS_H_
...
...
@@ -334,7 +334,7 @@ struct sctp_nets {
int
lastsa
;
int
lastsv
;
uint64_t
rtt
;
/* last measured rtt value in us */
u
nsigned
in
t
RTO
;
u
int32_
t
RTO
;
/* This is used for SHUTDOWN/SHUTDOWN-ACK/SEND or INIT timers */
struct
sctp_timer
rxt_timer
;
...
...
@@ -1121,7 +1121,7 @@ struct sctp_association {
uint32_t
heart_beat_delay
;
/* autoclose */
u
nsigned
in
t
sctp_autoclose_ticks
;
u
int32_
t
sctp_autoclose_ticks
;
/* how many preopen streams we have */
unsigned
int
pre_open_streams
;
...
...
@@ -1130,7 +1130,7 @@ struct sctp_association {
unsigned
int
max_inbound_streams
;
/* the cookie life I award for any cookie, in seconds */
u
nsigned
in
t
cookie_life
;
u
int32_
t
cookie_life
;
/* time to delay acks for */
unsigned
int
delayed_ack
;
unsigned
int
old_delayed_ack
;
...
...
@@ -1139,10 +1139,10 @@ struct sctp_association {
unsigned
int
numduptsns
;
int
dup_tsns
[
SCTP_MAX_DUP_TSNS
];
u
nsigned
in
t
initial_init_rto_max
;
/* initial RTO for INIT's */
u
nsigned
in
t
initial_rto
;
/* initial send RTO */
u
nsigned
in
t
minrto
;
/* per assoc RTO-MIN */
u
nsigned
in
t
maxrto
;
/* per assoc RTO-MAX */
u
int32_
t
initial_init_rto_max
;
/* initial RTO for INIT's */
u
int32_
t
initial_rto
;
/* initial send RTO */
u
int32_
t
minrto
;
/* per assoc RTO-MIN */
u
int32_
t
maxrto
;
/* per assoc RTO-MAX */
/* authentication fields */
sctp_auth_chklist_t
*
local_auth_chunks
;
...
...
worker/deps/usrsctp/usrsctp/usrsctplib/netinet/sctp_timer.c
浏览文件 @
64eb1e5f
...
...
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
__FBSDID
(
"$FreeBSD: head/sys/netinet/sctp_timer.c 3
38134 2018-08-21 13:25:32
Z tuexen $"
);
__FBSDID
(
"$FreeBSD: head/sys/netinet/sctp_timer.c 3
59405 2020-03-28 20:25:45
Z tuexen $"
);
#endif
#define _IP_VHL
...
...
@@ -1108,10 +1108,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 +1121,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 +1131,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 +1157,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 +1166,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 +1191,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 +1206,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 +1252,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 +1268,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
"
);
...
...
@@ -1538,16 +1539,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
;
in
t
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 +1558,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 +1577,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
*
net
p
;
struct
sctp_nets
*
net
;
if
((
SCTP_GET_STATE
(
stcb
)
==
SCTP_STATE_OPEN
)
||
(
SCTP_GET_STATE
(
stcb
)
==
SCTP_STATE_SHUTDOWN_RECEIVED
))
{
...
...
@@ -1588,17 +1586,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
)
{
net
p
=
stcb
->
asoc
.
alternate
;
net
=
stcb
->
asoc
.
alternate
;
}
else
{
net
p
=
stcb
->
asoc
.
primary_destination
;
net
=
stcb
->
asoc
.
primary_destination
;
}
sctp_send_shutdown
(
stcb
,
net
p
);
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 +1602,12 @@ sctp_autoclose_timer(struct sctp_inpcb *inp,
* No auto close at this time, reset t-o to check
* later
*/
in
t
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
;
}
...
...
worker/deps/usrsctp/usrsctp/usrsctplib/netinet/sctp_timer.h
浏览文件 @
64eb1e5f
...
...
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
__FBSDID
(
"$FreeBSD: head/sys/netinet/sctp_timer.h
295709 2016-02-17 18:04:22
Z tuexen $"
);
__FBSDID
(
"$FreeBSD: head/sys/netinet/sctp_timer.h
359195 2020-03-21 16:12:19
Z tuexen $"
);
#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,20 +76,17 @@ 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
*
);
...
...
worker/deps/usrsctp/usrsctp/usrsctplib/netinet/sctp_usrreq.c
浏览文件 @
64eb1e5f
...
...
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
__FBSDID
(
"$FreeBSD: head/sys/netinet/sctp_usrreq.c 35
8083 2020-02-18 21:25:17
Z tuexen $"
);
__FBSDID
(
"$FreeBSD: head/sys/netinet/sctp_usrreq.c 35
9410 2020-03-28 22:35:04
Z tuexen $"
);
#endif
#include <netinet/sctp_os.h>
...
...
@@ -675,8 +675,10 @@ 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"
);
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
/* #if defined(__FreeBSD__) */
...
...
@@ -1258,9 +1260,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
{
...
...
@@ -1274,16 +1276,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
);
}
...
...
@@ -1501,7 +1495,7 @@ sctp_shutdown(struct socket *so)
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
);
...
...
@@ -2270,7 +2264,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
;
...
...
@@ -2700,7 +2694,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
{
...
...
@@ -3221,7 +3215,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
)
{
...
...
@@ -3389,17 +3383,33 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
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
;
...
...
@@ -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
);
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
;
...
...
@@ -3523,7 +3533,7 @@ 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
;
...
...
@@ -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
* 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
);
...
...
@@ -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_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
)
{
...
...
@@ -5168,7 +5180,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
;
...
...
@@ -5222,7 +5234,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
);
...
...
@@ -6539,14 +6551,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
)
{
...
...
@@ -6661,7 +6673,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
if
(
sasoc
->
sasoc_asocmaxrxt
)
stcb
->
asoc
.
max_send_times
=
sasoc
->
sasoc_asocmaxrxt
;
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
);
}
else
{
...
...
@@ -6673,7 +6685,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
if
(
sasoc
->
sasoc_asocmaxrxt
)
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
);
inp
->
sctp_ep
.
def_cookie_life
=
sctp_msecs_to_ticks
(
sasoc
->
sasoc_cookie_life
);
}
SCTP_INP_WUNLOCK
(
inp
);
}
else
{
...
...
worker/deps/usrsctp/usrsctp/usrsctplib/netinet/sctputil.c
浏览文件 @
64eb1e5f
...
...
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
__FBSDID
(
"$FreeBSD: head/sys/netinet/sctputil.c 35
8083 2020-02-18 21:25:17
Z tuexen $"
);
__FBSDID
(
"$FreeBSD: head/sys/netinet/sctputil.c 35
9405 2020-03-28 20:25:45
Z tuexen $"
);
#endif
#include <netinet/sctp_os.h>
...
...
@@ -803,6 +803,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
...
...
@@ -893,7 +967,7 @@ static uint32_t sctp_mtu_sizes[] = {
2048
,
4352
,
4464
,
816
6
,
816
8
,
17912
,
32000
,
65532
...
...
@@ -1101,7 +1175,7 @@ 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
;
...
...
@@ -1187,7 +1261,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
;
...
...
@@ -1667,12 +1741,38 @@ 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__)
struct
epoch_tracker
et
;
#endif
struct
timeval
tv
;
struct
sctp_inpcb
*
inp
;
struct
sctp_tcb
*
stcb
;
struct
sctp_nets
*
net
;
...
...
@@ -1686,6 +1786,7 @@ sctp_timeout_handler(void *t)
#endif
int
did_output
;
int
type
;
int
i
,
secret
;
tmr
=
(
struct
sctp_timer
*
)
t
;
inp
=
(
struct
sctp_inpcb
*
)
tmr
->
ep
;
...
...
@@ -1702,56 +1803,13 @@ 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
;
}
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
;
}
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
;
KASSERT
(
tmr
->
self
==
tmr
,
(
"tmr->self corrupted"
));
KASSERT
(
SCTP_IS_TIMER_TYPE_VALID
(
tmr
->
type
),
(
"Invalid timer type %d"
,
tmr
->
type
));
type
=
tmr
->
type
;
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
=
0xa00
4
;
tmr
->
stopped_from
=
0xa00
1
;
if
(
stcb
)
{
atomic_add_int
(
&
stcb
->
asoc
.
refcnt
,
1
);
if
(
stcb
->
asoc
.
state
==
0
)
{
...
...
@@ -1759,15 +1817,17 @@ sctp_timeout_handler(void *t)
if
(
inp
)
{
SCTP_INP_DECR_REF
(
inp
);
}
SCTPDBG
(
SCTP_DEBUG_TIMER2
,
"Timer type %d handler exiting due to CLOSED association.
\n
"
,
type
);
#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
);
tmr
->
stopped_from
=
0xa002
;
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
);
...
...
@@ -1775,13 +1835,16 @@ sctp_timeout_handler(void *t)
if
(
stcb
)
{
atomic_add_int
(
&
stcb
->
asoc
.
refcnt
,
-
1
);
}
SCTPDBG
(
SCTP_DEBUG_TIMER2
,
"Timer type %d handler exiting due to not being active.
\n
"
,
type
);
#if defined(__FreeBSD__) && __FreeBSD_version >= 801000
CURVNET_RESTORE
();
#endif
return
;
}
tmr
->
stopped_from
=
0xa006
;
tmr
->
stopped_from
=
0xa003
;
if
(
stcb
)
{
SCTP_TCB_LOCK
(
stcb
);
atomic_add_int
(
&
stcb
->
asoc
.
refcnt
,
-
1
);
...
...
@@ -1792,21 +1855,22 @@ sctp_timeout_handler(void *t)
if
(
inp
)
{
SCTP_INP_DECR_REF
(
inp
);
}
SCTPDBG
(
SCTP_DEBUG_TIMER2
,
"Timer type %d handler exiting due to CLOSED association.
\n
"
,
type
);
#if defined(__FreeBSD__) && __FreeBSD_version >= 801000
CURVNET_RESTORE
();
#endif
return
;
}
}
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
;
#if defined(__FreeBSD__)
NET_EPOCH_ENTER
(
et
);
#endif
...
...
@@ -1837,13 +1901,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
--
;
...
...
@@ -1877,9 +1938,9 @@ sctp_timeout_handler(void *t)
}
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
))
{
...
...
@@ -1890,36 +1951,36 @@ sctp_timeout_handler(void *t)
did_output
=
0
;
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
);
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
);
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
))
{
...
...
@@ -1935,16 +1996,15 @@ sctp_timeout_handler(void *t)
}
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
...
...
@@ -1955,43 +2015,39 @@ sctp_timeout_handler(void *t)
sctp_chunk_output
(
inp
,
stcb
,
SCTP_OUTPUT_FROM_T3
,
SCTP_SO_NOT_LOCKED
);
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
=
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
,
NULL
,
NULL
);
did_output
=
0
;
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
;
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
;
...
...
@@ -2003,61 +2059,77 @@ sctp_timeout_handler(void *t)
#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
);
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
);
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
,
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
;
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
);
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__)
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__)
SCTP_SOCKET_UNLOCK
(
SCTP_INP_SO
(
inp
),
1
);
#endif
inp
=
NULL
;
goto
out_no_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
);
...
...
@@ -2082,32 +2154,25 @@ sctp_timeout_handler(void *t)
*/
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
);
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
();
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
);
break
;
default:
#ifdef INVARIANTS
panic
(
"Unknown timer type %d"
,
type
);
#else
goto
get_out
;
#endif
}
#ifdef SCTP_AUDITING_ENABLED
sctp_audit_log
(
0xF1
,
(
uint8_t
)
type
);
...
...
@@ -2150,7 +2215,7 @@ out_decr:
}
out_no_decr:
SCTPDBG
(
SCTP_DEBUG_TIMER
1
,
"Timer now complete (type = %d)
\n
"
,
type
);
SCTPDBG
(
SCTP_DEBUG_TIMER
2
,
"Timer type %d handler finished.
\n
"
,
type
);
#if defined(__FreeBSD__)
#if __FreeBSD_version >= 801000
CURVNET_RESTORE
();
...
...
@@ -2159,276 +2224,408 @@ out_no_decr:
#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
;
if
((
t_type
!=
SCTP_TIMER_TYPE_ADDR_WQ
)
&&
(
inp
==
NULL
))
return
;
uint32_t
to_ticks
;
uint32_t
rndval
,
jitter
;
tmr
=
NULL
;
if
(
stcb
)
{
to_ticks
=
0
;
if
(
stcb
!=
NULL
)
{
SCTP_TCB_LOCK_ASSERT
(
stcb
);
}
else
if
(
inp
!=
NULL
)
{
SCTP_INP_WLOCK_ASSERT
(
inp
);
}
else
{
SCTP_WQ_ADDR_LOCK_ASSERT
();
}
/* Don't restart timer on net that's been removed. */
if
(
net
!=
NULL
&&
(
net
->
dest_state
&
SCTP_ADDR_BEING_DELETED
))
{
return
;
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
))
{
return
;
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
);
}
tmr
=
&
net
->
rxt_timer
;
break
;
case
SCTP_TIMER_TYPE_HEARTBEAT
:
/*
*
t
he net is used here so that we can add in the RTO. Even
*
T
he 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
;
#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
{
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
;
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
=
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 comp
elete. If a retran happened then we will be
* using the RTO initial value.
* RTT was comp
lete. 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
;
#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
);
}
tmr
=
&
net
->
rxt_timer
;
break
;
case
SCTP_TIMER_TYPE_NEWCOOKIE
:
/*
*
n
othing needed but the endpoint here ususually about 60
*
N
othing needed but the endpoint here ususually about 60
* minutes.
*/
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
)
{
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
);
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.
*/
tmr
=
&
inp
->
sctp_ep
.
signature_change
;
to_ticks
=
MSEC_TO_TICKS
(
SCTP_INP_KILL_TIMEOUT
)
;
to_ticks
=
inp
->
sctp_ep
.
sctp_timeoutticks
[
SCTP_TIMER_SIGNATURE
]
;
break
;
case
SCTP_TIMER_TYPE_PATHMTURAISE
:
/*
* Here we use the value found in the EP for PMTU ususually
* Here we use the value found in the EP for PMTU
D,
ususually
* about 10 minutes.
*/
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
}
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
;
}
to_ticks
=
inp
->
sctp_ep
.
sctp_timeoutticks
[
SCTP_TIMER_PMTU
];
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
((
stcb
==
NULL
)
||
(
net
==
NULL
))
{
/* 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
=
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_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
);
}
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
)
{
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
)
{
to_ticks
=
5
*
MSEC_TO_TICKS
(
stcb
->
asoc
.
maxrto
);
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
];
}
tmr
=
&
stcb
->
asoc
.
shut_guard_timer
;
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
((
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
=
&
stcb
->
asoc
.
strreset_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
);
}
tmr
=
&
stcb
->
asoc
.
strreset_timer
;
break
;
case
SCTP_TIMER_TYPE_
ASCONF
:
case
SCTP_TIMER_TYPE_
INPKILL
:
/*
* Here the timer comes from the stcb but its value is from
* the net's RTO.
* 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
((
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
}
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
;
tmr
=
&
inp
->
sctp_ep
.
signature_change
;
to_ticks
=
sctp_msecs_to_ticks
(
SCTP_INP_KILL_TIMEOUT
);
break
;
case
SCTP_TIMER_TYPE_PRIM_DELETED
:
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
;
#endif
}
t
o_ticks
=
MSEC_TO_TICKS
(
stcb
->
asoc
.
initial_rto
)
;
t
mr
=
&
stcb
->
asoc
.
delete_prim_timer
;
t
mr
=
&
stcb
->
asoc
.
strreset_timer
;
t
o_ticks
=
sctp_msecs_to_ticks
(
SCTP_ASOC_KILL_TIMEOUT
)
;
break
;
case
SCTP_TIMER_TYPE_AUTOCLOSE
:
if
(
stcb
==
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
(
stcb
->
asoc
.
sctp_autoclose_ticks
==
0
)
{
/*
* Really an error since stcb is NOT set to
* autoclose
*/
/* 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
((
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
}
t
o_ticks
=
stcb
->
asoc
.
sctp_autoclose_ticks
;
t
mr
=
&
stcb
->
asoc
.
autoclose_timer
;
t
mr
=
&
stcb
->
asoc
.
delete_prim_timer
;
t
o_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
++
;
}
...
...
@@ -2436,155 +2633,285 @@ 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__)
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
);
}
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
)
{
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
=
&
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.
*/
tmr
=
&
inp
->
sctp_ep
.
signature_change
;
break
;
case
SCTP_TIMER_TYPE_PATHMTURAISE
:
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
->
pmtu_timer
;
break
;
case
SCTP_TIMER_TYPE_SHUTDOWNACK
:
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_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
(
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
.
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
(
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
.
strreset_timer
;
break
;
case
SCTP_TIMER_TYPE_ASCONF
:
if
(
stcb
==
NULL
)
{
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
=
&
stcb
->
asoc
.
asconf_timer
;
tmr
=
&
inp
->
sctp_ep
.
signature_change
;
break
;
case
SCTP_TIMER_TYPE_PRIM_DELETED
:
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
.
delete_prim
_timer
;
tmr
=
&
stcb
->
asoc
.
strreset
_timer
;
break
;
case
SCTP_TIMER_TYPE_AUTOCLOSE
:
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
.
autoclose_timer
;
tmr
=
&
SCTP_BASE_INFO
(
addr_wq_timer
)
;
break
;
default:
SCTPDBG
(
SCTP_DEBUG_TIMER1
,
"%s: Unknown timer type %d
\n
"
,
__func__
,
t_type
);
case
SCTP_TIMER_TYPE_PRIM_DELETED
:
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
;
}
if
(
tmr
==
NULL
)
{
default:
#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
))
{
...
...
@@ -2595,7 +2922,28 @@ 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
);
tmr
->
ep
=
NULL
;
tmr
->
tcb
=
NULL
;
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
;
}
...
...
worker/deps/usrsctp/usrsctp/usrsctplib/netinet/sctputil.h
浏览文件 @
64eb1e5f
...
...
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
__FBSDID
(
"$FreeBSD: head/sys/netinet/sctputil.h 35
7775 2020-02-11 20:02:20
Z tuexen $"
);
__FBSDID
(
"$FreeBSD: head/sys/netinet/sctputil.h 35
9405 2020-03-28 20:25:45
Z tuexen $"
);
#endif
#ifndef _NETINET_SCTP_UTIL_H_
...
...
@@ -430,5 +430,10 @@ 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
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论