Skip to content

Commit 839a609

Browse files
keesdavem330
authored andcommitted
net: dccp: Convert timers to use timer_setup()
In preparation for unconditionally passing the struct timer_list pointer to all timer callbacks, switch to using the new timer_setup() and from_timer() to pass the timer pointer explicitly. Adds a pointer back to the sock. Cc: Gerrit Renker <gerrit@erg.abdn.ac.uk> Cc: "David S. Miller" <davem@davemloft.net> Cc: Soheil Hassas Yeganeh <soheil@google.com> Cc: Hannes Frederic Sowa <hannes@stressinduktion.org> Cc: Eric Dumazet <edumazet@google.com> Cc: dccp@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 7aa1402 commit 839a609

5 files changed

Lines changed: 20 additions & 15 deletions

File tree

‎net/dccp/ccids/ccid2.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ static void ccid2_change_l_seq_window(struct sock *sk, u64 val)
126126
DCCPF_SEQ_WMAX));
127127
}
128128

129-
static void ccid2_hc_tx_rto_expire(unsigned long data)
129+
static void ccid2_hc_tx_rto_expire(struct timer_list *t)
130130
{
131-
struct sock *sk = (struct sock *)data;
132-
struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk);
131+
struct ccid2_hc_tx_sock *hc = from_timer(hc, t, tx_rtotimer);
132+
struct sock *sk = hc->sk;
133133
const bool sender_was_blocked = ccid2_cwnd_network_limited(hc);
134134

135135
bh_lock_sock(sk);
@@ -733,8 +733,8 @@ static int ccid2_hc_tx_init(struct ccid *ccid, struct sock *sk)
733733
hc->tx_rpdupack = -1;
734734
hc->tx_last_cong = hc->tx_lsndtime = hc->tx_cwnd_stamp = ccid2_jiffies32;
735735
hc->tx_cwnd_used = 0;
736-
setup_timer(&hc->tx_rtotimer, ccid2_hc_tx_rto_expire,
737-
(unsigned long)sk);
736+
hc->sk = sk;
737+
timer_setup(&hc->tx_rtotimer, ccid2_hc_tx_rto_expire, 0);
738738
INIT_LIST_HEAD(&hc->tx_av_chunks);
739739
return 0;
740740
}

‎net/dccp/ccids/ccid2.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ struct ccid2_hc_tx_sock {
8585
tx_rto;
8686
u64 tx_rtt_seq:48;
8787
struct timer_list tx_rtotimer;
88+
struct sock *sk;
8889

8990
/* Congestion Window validation (optional, RFC 2861) */
9091
u32 tx_cwnd_used,

‎net/dccp/ccids/ccid3.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,10 @@ static inline void ccid3_hc_tx_update_win_count(struct ccid3_hc_tx_sock *hc,
195195
}
196196
}
197197

198-
static void ccid3_hc_tx_no_feedback_timer(unsigned long data)
198+
static void ccid3_hc_tx_no_feedback_timer(struct timer_list *t)
199199
{
200-
struct sock *sk = (struct sock *)data;
201-
struct ccid3_hc_tx_sock *hc = ccid3_hc_tx_sk(sk);
200+
struct ccid3_hc_tx_sock *hc = from_timer(hc, t, tx_no_feedback_timer);
201+
struct sock *sk = hc->sk;
202202
unsigned long t_nfb = USEC_PER_SEC / 5;
203203

204204
bh_lock_sock(sk);
@@ -505,8 +505,9 @@ static int ccid3_hc_tx_init(struct ccid *ccid, struct sock *sk)
505505

506506
hc->tx_state = TFRC_SSTATE_NO_SENT;
507507
hc->tx_hist = NULL;
508-
setup_timer(&hc->tx_no_feedback_timer,
509-
ccid3_hc_tx_no_feedback_timer, (unsigned long)sk);
508+
hc->sk = sk;
509+
timer_setup(&hc->tx_no_feedback_timer,
510+
ccid3_hc_tx_no_feedback_timer, 0);
510511
return 0;
511512
}
512513

‎net/dccp/ccids/ccid3.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ struct ccid3_hc_tx_sock {
106106
u8 tx_last_win_count;
107107
ktime_t tx_t_last_win_count;
108108
struct timer_list tx_no_feedback_timer;
109+
struct sock *sk;
109110
ktime_t tx_t_ld;
110111
ktime_t tx_t_nom;
111112
struct tfrc_tx_hist_entry *tx_hist;

‎net/dccp/timer.c‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,19 +234,21 @@ static void dccp_write_xmitlet(unsigned long data)
234234
bh_unlock_sock(sk);
235235
}
236236

237-
static void dccp_write_xmit_timer(unsigned long data)
237+
static void dccp_write_xmit_timer(struct timer_list *t)
238238
{
239-
dccp_write_xmitlet(data);
240-
sock_put((struct sock *)data);
239+
struct dccp_sock *dp = from_timer(dp, t, dccps_xmit_timer);
240+
struct sock *sk = &dp->dccps_inet_connection.icsk_inet.sk;
241+
242+
dccp_write_xmitlet((unsigned long)sk);
243+
sock_put(sk);
241244
}
242245

243246
void dccp_init_xmit_timers(struct sock *sk)
244247
{
245248
struct dccp_sock *dp = dccp_sk(sk);
246249

247250
tasklet_init(&dp->dccps_xmitlet, dccp_write_xmitlet, (unsigned long)sk);
248-
setup_timer(&dp->dccps_xmit_timer, dccp_write_xmit_timer,
249-
(unsigned long)sk);
251+
timer_setup(&dp->dccps_xmit_timer, dccp_write_xmit_timer, 0);
250252
inet_csk_init_xmit_timers(sk, &dccp_write_timer, &dccp_delack_timer,
251253
&dccp_keepalive_timer);
252254
}

0 commit comments

Comments
 (0)