Skip to content

Commit e575235

Browse files
Daniel Borkmanndavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b82e8f3 commit e575235

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

include/net/sctp/structs.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -838,10 +838,10 @@ struct sctp_transport {
838838
unsigned long sackdelay;
839839
__u32 sackfreq;
840840

841-
/* When was the last time (in jiffies) that we heard from this
842-
* transport? We use this to pick new active and retran paths.
841+
/* When was the last time that we heard from this transport? We use
842+
* this to pick new active and retran paths.
843843
*/
844-
unsigned long last_time_heard;
844+
ktime_t last_time_heard;
845845

846846
/* Last time(in jiffies) when cwnd is reduced due to the congestion
847847
* indication based on ECNE chunk.

net/sctp/associola.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ static void sctp_assoc_bh_rcv(struct work_struct *work)
10361036
}
10371037

10381038
if (chunk->transport)
1039-
chunk->transport->last_time_heard = jiffies;
1039+
chunk->transport->last_time_heard = ktime_get();
10401040

10411041
/* Run through the state machine. */
10421042
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)
12831283
trans->state == SCTP_PF)
12841284
continue;
12851285
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)) {
12871288
trans_sec = trans_pri;
12881289
trans_pri = trans;
12891290
} 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)) {
12911293
trans_sec = trans;
12921294
}
12931295
}

net/sctp/endpointola.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ static void sctp_endpoint_bh_rcv(struct work_struct *work)
481481
}
482482

483483
if (chunk->transport)
484-
chunk->transport->last_time_heard = jiffies;
484+
chunk->transport->last_time_heard = ktime_get();
485485

486486
error = sctp_do_sm(net, SCTP_EVENT_T_CHUNK, subtype, state,
487487
ep, asoc, chunk, GFP_ATOMIC);

net/sctp/transport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static struct sctp_transport *sctp_transport_init(struct net *net,
7272
*/
7373
peer->rto = msecs_to_jiffies(net->sctp.rto_initial);
7474

75-
peer->last_time_heard = jiffies;
75+
peer->last_time_heard = ktime_get();
7676
peer->last_time_ecne_reduced = jiffies;
7777

7878
peer->param_flags = SPP_HB_DISABLE |

0 commit comments

Comments
 (0)