Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Kees Cook and committed by
David S. Miller
839a6094 7aa1402e

+20 -15
+5 -5
net/dccp/ccids/ccid2.c
··· 126 126 DCCPF_SEQ_WMAX)); 127 127 } 128 128 129 - static void ccid2_hc_tx_rto_expire(unsigned long data) 129 + static void ccid2_hc_tx_rto_expire(struct timer_list *t) 130 130 { 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; 133 133 const bool sender_was_blocked = ccid2_cwnd_network_limited(hc); 134 134 135 135 bh_lock_sock(sk); ··· 733 733 hc->tx_rpdupack = -1; 734 734 hc->tx_last_cong = hc->tx_lsndtime = hc->tx_cwnd_stamp = ccid2_jiffies32; 735 735 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); 738 738 INIT_LIST_HEAD(&hc->tx_av_chunks); 739 739 return 0; 740 740 }
+1
net/dccp/ccids/ccid2.h
··· 85 85 tx_rto; 86 86 u64 tx_rtt_seq:48; 87 87 struct timer_list tx_rtotimer; 88 + struct sock *sk; 88 89 89 90 /* Congestion Window validation (optional, RFC 2861) */ 90 91 u32 tx_cwnd_used,
+6 -5
net/dccp/ccids/ccid3.c
··· 195 195 } 196 196 } 197 197 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) 199 199 { 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; 202 202 unsigned long t_nfb = USEC_PER_SEC / 5; 203 203 204 204 bh_lock_sock(sk); ··· 505 505 506 506 hc->tx_state = TFRC_SSTATE_NO_SENT; 507 507 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); 510 511 return 0; 511 512 } 512 513
+1
net/dccp/ccids/ccid3.h
··· 106 106 u8 tx_last_win_count; 107 107 ktime_t tx_t_last_win_count; 108 108 struct timer_list tx_no_feedback_timer; 109 + struct sock *sk; 109 110 ktime_t tx_t_ld; 110 111 ktime_t tx_t_nom; 111 112 struct tfrc_tx_hist_entry *tx_hist;
+7 -5
net/dccp/timer.c
··· 234 234 bh_unlock_sock(sk); 235 235 } 236 236 237 - static void dccp_write_xmit_timer(unsigned long data) 237 + static void dccp_write_xmit_timer(struct timer_list *t) 238 238 { 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); 241 244 } 242 245 243 246 void dccp_init_xmit_timers(struct sock *sk) ··· 248 245 struct dccp_sock *dp = dccp_sk(sk); 249 246 250 247 tasklet_init(&dp->dccps_xmitlet, dccp_write_xmitlet, (unsigned long)sk); 251 - setup_timer(&dp->dccps_xmit_timer, dccp_write_xmit_timer, 252 - (unsigned long)sk); 248 + timer_setup(&dp->dccps_xmit_timer, dccp_write_xmit_timer, 0); 253 249 inet_csk_init_xmit_timers(sk, &dccp_write_timer, &dccp_delack_timer, 254 250 &dccp_keepalive_timer); 255 251 }