Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
0b49f36e
Commit
0b49f36e
authored
Oct 01, 2003
by
Sridhar Samudrala
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[SCTP] Fix bugs in conversions between msecs and jiffies.
parent
3e94542b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
27 deletions
+33
-27
include/net/sctp/sctp.h
include/net/sctp/sctp.h
+3
-0
net/sctp/associola.c
net/sctp/associola.c
+6
-5
net/sctp/endpointola.c
net/sctp/endpointola.c
+2
-2
net/sctp/socket.c
net/sctp/socket.c
+21
-19
net/sctp/sysctl.c
net/sctp/sysctl.c
+1
-1
No files found.
include/net/sctp/sctp.h
View file @
0b49f36e
...
@@ -116,6 +116,9 @@
...
@@ -116,6 +116,9 @@
#define SCTP_STATIC static
#define SCTP_STATIC static
#endif
#endif
#define MSECS_TO_JIFFIES(msec) (msec * HZ / 1000)
#define JIFFIES_TO_MSECS(jiff) (jiff * 1000 / HZ)
/*
/*
* Function declarations.
* Function declarations.
*/
*/
...
...
net/sctp/associola.c
View file @
0b49f36e
...
@@ -141,9 +141,9 @@ struct sctp_association *sctp_association_init(struct sctp_association *asoc,
...
@@ -141,9 +141,9 @@ struct sctp_association *sctp_association_init(struct sctp_association *asoc,
* socket values.
* socket values.
*/
*/
asoc
->
max_retrans
=
sp
->
assocparams
.
sasoc_asocmaxrxt
;
asoc
->
max_retrans
=
sp
->
assocparams
.
sasoc_asocmaxrxt
;
asoc
->
rto_initial
=
sp
->
rtoinfo
.
srto_initial
*
HZ
/
1000
;
asoc
->
rto_initial
=
MSECS_TO_JIFFIES
(
sp
->
rtoinfo
.
srto_initial
)
;
asoc
->
rto_max
=
sp
->
rtoinfo
.
srto_max
*
HZ
/
1000
;
asoc
->
rto_max
=
MSECS_TO_JIFFIES
(
sp
->
rtoinfo
.
srto_max
)
;
asoc
->
rto_min
=
sp
->
rtoinfo
.
srto_min
*
HZ
/
1000
;
asoc
->
rto_min
=
MSECS_TO_JIFFIES
(
sp
->
rtoinfo
.
srto_min
)
;
asoc
->
overall_error_count
=
0
;
asoc
->
overall_error_count
=
0
;
...
@@ -168,7 +168,8 @@ struct sctp_association *sctp_association_init(struct sctp_association *asoc,
...
@@ -168,7 +168,8 @@ struct sctp_association *sctp_association_init(struct sctp_association *asoc,
asoc
->
c
.
sinit_num_ostreams
=
sp
->
initmsg
.
sinit_num_ostreams
;
asoc
->
c
.
sinit_num_ostreams
=
sp
->
initmsg
.
sinit_num_ostreams
;
asoc
->
max_init_attempts
=
sp
->
initmsg
.
sinit_max_attempts
;
asoc
->
max_init_attempts
=
sp
->
initmsg
.
sinit_max_attempts
;
asoc
->
max_init_timeo
=
sp
->
initmsg
.
sinit_max_init_timeo
*
HZ
/
1000
;
asoc
->
max_init_timeo
=
MSECS_TO_JIFFIES
(
sp
->
initmsg
.
sinit_max_init_timeo
);
/* Allocate storage for the ssnmap after the inbound and outbound
/* Allocate storage for the ssnmap after the inbound and outbound
* streams have been negotiated during Init.
* streams have been negotiated during Init.
...
@@ -500,7 +501,7 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc,
...
@@ -500,7 +501,7 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc,
/* Initialize the peer's heartbeat interval based on the
/* Initialize the peer's heartbeat interval based on the
* sock configured value.
* sock configured value.
*/
*/
peer
->
hb_interval
=
sp
->
paddrparam
.
spp_hbinterval
*
HZ
;
peer
->
hb_interval
=
MSECS_TO_JIFFIES
(
sp
->
paddrparam
.
spp_hbinterval
)
;
/* Set the path max_retrans. */
/* Set the path max_retrans. */
peer
->
max_retrans
=
asoc
->
max_retrans
;
peer
->
max_retrans
=
asoc
->
max_retrans
;
...
...
net/sctp/endpointola.c
View file @
0b49f36e
...
@@ -129,7 +129,7 @@ struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
...
@@ -129,7 +129,7 @@ struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
ep
->
timeouts
[
SCTP_EVENT_TIMEOUT_T1_INIT
]
=
ep
->
timeouts
[
SCTP_EVENT_TIMEOUT_T1_INIT
]
=
SCTP_DEFAULT_TIMEOUT_T1_INIT
;
SCTP_DEFAULT_TIMEOUT_T1_INIT
;
ep
->
timeouts
[
SCTP_EVENT_TIMEOUT_T2_SHUTDOWN
]
=
ep
->
timeouts
[
SCTP_EVENT_TIMEOUT_T2_SHUTDOWN
]
=
sp
->
rtoinfo
.
srto_initial
*
HZ
/
1000
;
MSECS_TO_JIFFIES
(
sp
->
rtoinfo
.
srto_initial
)
;
ep
->
timeouts
[
SCTP_EVENT_TIMEOUT_T3_RTX
]
=
0
;
ep
->
timeouts
[
SCTP_EVENT_TIMEOUT_T3_RTX
]
=
0
;
ep
->
timeouts
[
SCTP_EVENT_TIMEOUT_T4_RTO
]
=
0
;
ep
->
timeouts
[
SCTP_EVENT_TIMEOUT_T4_RTO
]
=
0
;
...
@@ -138,7 +138,7 @@ struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
...
@@ -138,7 +138,7 @@ struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
* recommended value of 5 times 'RTO.Max'.
* recommended value of 5 times 'RTO.Max'.
*/
*/
ep
->
timeouts
[
SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD
]
ep
->
timeouts
[
SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD
]
=
5
*
(
sp
->
rtoinfo
.
srto_max
*
HZ
/
1000
);
=
5
*
MSECS_TO_JIFFIES
(
sp
->
rtoinfo
.
srto_max
);
ep
->
timeouts
[
SCTP_EVENT_TIMEOUT_HEARTBEAT
]
=
ep
->
timeouts
[
SCTP_EVENT_TIMEOUT_HEARTBEAT
]
=
SCTP_DEFAULT_TIMEOUT_HEARTBEAT
;
SCTP_DEFAULT_TIMEOUT_HEARTBEAT
;
...
...
net/sctp/socket.c
View file @
0b49f36e
...
@@ -1171,8 +1171,8 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
...
@@ -1171,8 +1171,8 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
=
sinit
->
sinit_max_attempts
;
=
sinit
->
sinit_max_attempts
;
}
}
if
(
sinit
->
sinit_max_init_timeo
)
{
if
(
sinit
->
sinit_max_init_timeo
)
{
asoc
->
max_init_timeo
asoc
->
max_init_timeo
=
=
sinit
->
sinit_max_init_timeo
*
HZ
;
MSECS_TO_JIFFIES
(
sinit
->
sinit_max_init_timeo
)
;
}
}
}
}
...
@@ -1610,7 +1610,8 @@ static int sctp_setsockopt_peer_addr_params(struct sock *sk,
...
@@ -1610,7 +1610,8 @@ static int sctp_setsockopt_peer_addr_params(struct sock *sk,
*/
*/
if
(
params
.
spp_hbinterval
)
{
if
(
params
.
spp_hbinterval
)
{
trans
->
hb_allowed
=
1
;
trans
->
hb_allowed
=
1
;
trans
->
hb_interval
=
params
.
spp_hbinterval
*
HZ
/
1000
;
trans
->
hb_interval
=
MSECS_TO_JIFFIES
(
params
.
spp_hbinterval
);
}
else
}
else
trans
->
hb_allowed
=
0
;
trans
->
hb_allowed
=
0
;
}
}
...
@@ -1769,11 +1770,12 @@ static int sctp_setsockopt_rtoinfo(struct sock *sk, char *optval, int optlen) {
...
@@ -1769,11 +1770,12 @@ static int sctp_setsockopt_rtoinfo(struct sock *sk, char *optval, int optlen) {
if
(
asoc
)
{
if
(
asoc
)
{
if
(
rtoinfo
.
srto_initial
!=
0
)
if
(
rtoinfo
.
srto_initial
!=
0
)
asoc
->
rto_initial
=
rtoinfo
.
srto_initial
*
HZ
/
1000
;
asoc
->
rto_initial
=
MSECS_TO_JIFFIES
(
rtoinfo
.
srto_initial
);
if
(
rtoinfo
.
srto_max
!=
0
)
if
(
rtoinfo
.
srto_max
!=
0
)
asoc
->
rto_max
=
rtoinfo
.
srto_max
*
HZ
/
1000
;
asoc
->
rto_max
=
MSECS_TO_JIFFIES
(
rtoinfo
.
srto_max
)
;
if
(
rtoinfo
.
srto_min
!=
0
)
if
(
rtoinfo
.
srto_min
!=
0
)
asoc
->
rto_min
=
rtoinfo
.
srto_min
*
HZ
/
1000
;
asoc
->
rto_min
=
MSECS_TO_JIFFIES
(
rtoinfo
.
srto_min
)
;
}
else
{
}
else
{
/* If there is no association or the association-id = 0
/* If there is no association or the association-id = 0
* set the values to the endpoint.
* set the values to the endpoint.
...
@@ -2297,14 +2299,14 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk)
...
@@ -2297,14 +2299,14 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk)
sp
->
initmsg
.
sinit_num_ostreams
=
sctp_max_outstreams
;
sp
->
initmsg
.
sinit_num_ostreams
=
sctp_max_outstreams
;
sp
->
initmsg
.
sinit_max_instreams
=
sctp_max_instreams
;
sp
->
initmsg
.
sinit_max_instreams
=
sctp_max_instreams
;
sp
->
initmsg
.
sinit_max_attempts
=
sctp_max_retrans_init
;
sp
->
initmsg
.
sinit_max_attempts
=
sctp_max_retrans_init
;
sp
->
initmsg
.
sinit_max_init_timeo
=
(
sctp_rto_max
/
HZ
)
*
1000
;
sp
->
initmsg
.
sinit_max_init_timeo
=
JIFFIES_TO_MSECS
(
sctp_rto_max
)
;
/* Initialize default RTO related parameters. These parameters can
/* Initialize default RTO related parameters. These parameters can
* be modified for with the SCTP_RTOINFO socket option.
* be modified for with the SCTP_RTOINFO socket option.
*/
*/
sp
->
rtoinfo
.
srto_initial
=
(
sctp_rto_initial
/
HZ
)
*
1000
;
sp
->
rtoinfo
.
srto_initial
=
JIFFIES_TO_MSECS
(
sctp_rto_initial
)
;
sp
->
rtoinfo
.
srto_max
=
(
sctp_rto_max
/
HZ
)
*
1000
;
sp
->
rtoinfo
.
srto_max
=
JIFFIES_TO_MSECS
(
sctp_rto_max
)
;
sp
->
rtoinfo
.
srto_min
=
(
sctp_rto_min
/
HZ
)
*
1000
;
sp
->
rtoinfo
.
srto_min
=
JIFFIES_TO_MSECS
(
sctp_rto_min
)
;
/* Initialize default association related parameters. These parameters
/* Initialize default association related parameters. These parameters
* can be modified with the SCTP_ASSOCINFO socket option.
* can be modified with the SCTP_ASSOCINFO socket option.
...
@@ -2313,8 +2315,8 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk)
...
@@ -2313,8 +2315,8 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk)
sp
->
assocparams
.
sasoc_number_peer_destinations
=
0
;
sp
->
assocparams
.
sasoc_number_peer_destinations
=
0
;
sp
->
assocparams
.
sasoc_peer_rwnd
=
0
;
sp
->
assocparams
.
sasoc_peer_rwnd
=
0
;
sp
->
assocparams
.
sasoc_local_rwnd
=
0
;
sp
->
assocparams
.
sasoc_local_rwnd
=
0
;
sp
->
assocparams
.
sasoc_cookie_life
=
(
sctp_valid_cookie_life
/
HZ
)
sp
->
assocparams
.
sasoc_cookie_life
=
*
1000
;
JIFFIES_TO_MSECS
(
sctp_valid_cookie_life
)
;
/* Initialize default event subscriptions. By default, all the
/* Initialize default event subscriptions. By default, all the
* options are off.
* options are off.
...
@@ -2324,7 +2326,7 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk)
...
@@ -2324,7 +2326,7 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk)
/* Default Peer Address Parameters. These defaults can
/* Default Peer Address Parameters. These defaults can
* be modified via SCTP_PEER_ADDR_PARAMS
* be modified via SCTP_PEER_ADDR_PARAMS
*/
*/
sp
->
paddrparam
.
spp_hbinterval
=
(
sctp_hb_interval
/
HZ
)
*
1000
;
sp
->
paddrparam
.
spp_hbinterval
=
JIFFIES_TO_MSECS
(
sctp_hb_interval
)
;
sp
->
paddrparam
.
spp_pathmaxrxt
=
sctp_max_retrans_path
;
sp
->
paddrparam
.
spp_pathmaxrxt
=
sctp_max_retrans_path
;
/* If enabled no SCTP message fragmentation will be performed.
/* If enabled no SCTP message fragmentation will be performed.
...
@@ -2474,7 +2476,7 @@ static int sctp_getsockopt_sctp_status(struct sock *sk, int len, char *optval,
...
@@ -2474,7 +2476,7 @@ static int sctp_getsockopt_sctp_status(struct sock *sk, int len, char *optval,
status
.
sstat_primary
.
spinfo_state
=
transport
->
active
;
status
.
sstat_primary
.
spinfo_state
=
transport
->
active
;
status
.
sstat_primary
.
spinfo_cwnd
=
transport
->
cwnd
;
status
.
sstat_primary
.
spinfo_cwnd
=
transport
->
cwnd
;
status
.
sstat_primary
.
spinfo_srtt
=
transport
->
srtt
;
status
.
sstat_primary
.
spinfo_srtt
=
transport
->
srtt
;
status
.
sstat_primary
.
spinfo_rto
=
(
transport
->
rto
/
HZ
)
*
1000
;
status
.
sstat_primary
.
spinfo_rto
=
JIFFIES_TO_MSECS
(
transport
->
rto
)
;
status
.
sstat_primary
.
spinfo_mtu
=
transport
->
pmtu
;
status
.
sstat_primary
.
spinfo_mtu
=
transport
->
pmtu
;
if
(
put_user
(
len
,
optlen
))
{
if
(
put_user
(
len
,
optlen
))
{
...
@@ -2529,7 +2531,7 @@ static int sctp_getsockopt_peer_addr_info(struct sock *sk, int len,
...
@@ -2529,7 +2531,7 @@ static int sctp_getsockopt_peer_addr_info(struct sock *sk, int len,
pinfo
.
spinfo_state
=
transport
->
active
;
pinfo
.
spinfo_state
=
transport
->
active
;
pinfo
.
spinfo_cwnd
=
transport
->
cwnd
;
pinfo
.
spinfo_cwnd
=
transport
->
cwnd
;
pinfo
.
spinfo_srtt
=
transport
->
srtt
;
pinfo
.
spinfo_srtt
=
transport
->
srtt
;
pinfo
.
spinfo_rto
=
(
transport
->
rto
/
HZ
)
*
1000
;
pinfo
.
spinfo_rto
=
JIFFIES_TO_MSECS
(
transport
->
rto
)
;
pinfo
.
spinfo_mtu
=
transport
->
pmtu
;
pinfo
.
spinfo_mtu
=
transport
->
pmtu
;
if
(
put_user
(
len
,
optlen
))
{
if
(
put_user
(
len
,
optlen
))
{
...
@@ -2733,7 +2735,7 @@ static int sctp_getsockopt_peer_addr_params(struct sock *sk, int len,
...
@@ -2733,7 +2735,7 @@ static int sctp_getsockopt_peer_addr_params(struct sock *sk, int len,
if
(
!
trans
->
hb_allowed
)
if
(
!
trans
->
hb_allowed
)
params
.
spp_hbinterval
=
0
;
params
.
spp_hbinterval
=
0
;
else
else
params
.
spp_hbinterval
=
trans
->
hb_interval
*
1000
/
HZ
;
params
.
spp_hbinterval
=
JIFFIES_TO_MSECS
(
trans
->
hb_interval
)
;
/* spp_pathmaxrxt contains the maximum number of retransmissions
/* spp_pathmaxrxt contains the maximum number of retransmissions
* before this address shall be considered unreachable.
* before this address shall be considered unreachable.
...
@@ -3084,9 +3086,9 @@ static int sctp_getsockopt_rtoinfo(struct sock *sk, int len, char *optval,
...
@@ -3084,9 +3086,9 @@ static int sctp_getsockopt_rtoinfo(struct sock *sk, int len, char *optval,
/* Values corresponding to the specific association. */
/* Values corresponding to the specific association. */
if
(
asoc
)
{
if
(
asoc
)
{
rtoinfo
.
srto_initial
=
(
asoc
->
rto_initial
/
HZ
)
*
1000
;
rtoinfo
.
srto_initial
=
JIFFIES_TO_MSECS
(
asoc
->
rto_initial
)
;
rtoinfo
.
srto_max
=
(
asoc
->
rto_max
/
HZ
)
*
1000
;
rtoinfo
.
srto_max
=
JIFFIES_TO_MSECS
(
asoc
->
rto_max
)
;
rtoinfo
.
srto_min
=
(
asoc
->
rto_min
/
HZ
)
*
1000
;
rtoinfo
.
srto_min
=
JIFFIES_TO_MSECS
(
asoc
->
rto_min
)
;
}
else
{
}
else
{
/* Values corresponding to the endpoint. */
/* Values corresponding to the endpoint. */
struct
sctp_opt
*
sp
=
sctp_sk
(
sk
);
struct
sctp_opt
*
sp
=
sctp_sk
(
sk
);
...
...
net/sctp/sysctl.c
View file @
0b49f36e
...
@@ -44,7 +44,7 @@
...
@@ -44,7 +44,7 @@
#include <linux/sysctl.h>
#include <linux/sysctl.h>
static
ctl_handler
sctp_sysctl_jiffies_ms
;
static
ctl_handler
sctp_sysctl_jiffies_ms
;
static
long
rto_timer_min
=
0
;
static
long
rto_timer_min
=
1
;
static
long
rto_timer_max
=
86400000
;
/* One day */
static
long
rto_timer_max
=
86400000
;
/* One day */
static
ctl_table
sctp_table
[]
=
{
static
ctl_table
sctp_table
[]
=
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment