aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Borkmann <dborkman@redhat.com>2014-06-11 12:19:30 -0400
committerDavid S. Miller <davem@davemloft.net>2014-06-11 15:23:17 -0400
commite575235fc6026bb75e166ff68f84118c62d73f94 (patch)
tree299131847e629caa9201f9ba8066302864e0f22d
parentb82e8f31acc7d799638692e65ff017f3e1b6a43d (diff)
net: sctp: migrate most recently used transport to ktime
Be more precise in transport path selection and use ktime helpers instead of jiffies to compare and pick the better primary and secondary recently used transports. This also avoids any side-effects during a possible roll-over, and could lead to better path decision-making. Signed-off-by: Daniel Borkmann <dborkman@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/sctp/structs.h6
-rw-r--r--net/sctp/associola.c8
-rw-r--r--net/sctp/endpointola.c2
-rw-r--r--net/sctp/transport.c2
4 files changed, 10 insertions, 8 deletions
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index 0dfcc92600e8..f38588bf3462 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -838,10 +838,10 @@ struct sctp_transport {
838 unsigned long sackdelay; 838 unsigned long sackdelay;
839 __u32 sackfreq; 839 __u32 sackfreq;
840 840
841 /* When was the last time (in jiffies) that we heard from this 841 /* When was the last time that we heard from this transport? We use
842 * transport? We use this to pick new active and retran paths. 842 * this to pick new active and retran paths.
843 */ 843 */
844 unsigned long last_time_heard; 844 ktime_t last_time_heard;
845 845
846 /* Last time(in jiffies) when cwnd is reduced due to the congestion 846 /* Last time(in jiffies) when cwnd is reduced due to the congestion
847 * indication based on ECNE chunk. 847 * indication based on ECNE chunk.
diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index 9f1cc6f1535d..620c99e19e77 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -1036,7 +1036,7 @@ static void sctp_assoc_bh_rcv(struct work_struct *work)
1036 } 1036 }
1037 1037
1038 if (chunk->transport) 1038 if (chunk->transport)
1039 chunk->transport->last_time_heard = jiffies; 1039 chunk->transport->last_time_heard = ktime_get();
1040 1040
1041 /* Run through the state machine. */ 1041 /* Run through the state machine. */
1042 error = sctp_do_sm(net, SCTP_EVENT_T_CHUNK, subtype, 1042 error = sctp_do_sm(net, SCTP_EVENT_T_CHUNK, subtype,
@@ -1283,11 +1283,13 @@ static void sctp_select_active_and_retran_path(struct sctp_association *asoc)
1283 trans->state == SCTP_PF) 1283 trans->state == SCTP_PF)
1284 continue; 1284 continue;
1285 if (trans_pri == NULL || 1285 if (trans_pri == NULL ||
1286 trans->last_time_heard > trans_pri->last_time_heard) { 1286 ktime_after(trans->last_time_heard,
1287 trans_pri->last_time_heard)) {
1287 trans_sec = trans_pri; 1288 trans_sec = trans_pri;
1288 trans_pri = trans; 1289 trans_pri = trans;
1289 } else if (trans_sec == NULL || 1290 } else if (trans_sec == NULL ||
1290 trans->last_time_heard > trans_sec->last_time_heard) { 1291 ktime_after(trans->last_time_heard,
1292 trans_sec->last_time_heard)) {
1291 trans_sec = trans; 1293 trans_sec = trans;
1292 } 1294 }
1293 } 1295 }
diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c
index 3d9f429858dc..9da76ba4d10f 100644
--- a/net/sctp/endpointola.c
+++ b/net/sctp/endpointola.c
@@ -481,7 +481,7 @@ normal:
481 } 481 }
482 482
483 if (chunk->transport) 483 if (chunk->transport)
484 chunk->transport->last_time_heard = jiffies; 484 chunk->transport->last_time_heard = ktime_get();
485 485
486 error = sctp_do_sm(net, SCTP_EVENT_T_CHUNK, subtype, state, 486 error = sctp_do_sm(net, SCTP_EVENT_T_CHUNK, subtype, state,
487 ep, asoc, chunk, GFP_ATOMIC); 487 ep, asoc, chunk, GFP_ATOMIC);
diff --git a/net/sctp/transport.c b/net/sctp/transport.c
index 1d348d15b33d..7dd672fa651f 100644
--- a/net/sctp/transport.c
+++ b/net/sctp/transport.c
@@ -72,7 +72,7 @@ static struct sctp_transport *sctp_transport_init(struct net *net,
72 */ 72 */
73 peer->rto = msecs_to_jiffies(net->sctp.rto_initial); 73 peer->rto = msecs_to_jiffies(net->sctp.rto_initial);
74 74
75 peer->last_time_heard = jiffies; 75 peer->last_time_heard = ktime_get();
76 peer->last_time_ecne_reduced = jiffies; 76 peer->last_time_ecne_reduced = jiffies;
77 77
78 peer->param_flags = SPP_HB_DISABLE | 78 peer->param_flags = SPP_HB_DISABLE |