[DCCP]: Initialise write_xmit_timer also on passive sockets

The TX CCID needs the write_xmit_timer for delaying packet sends. Previously
this timer was only activated on active (connecting) sockets.

This patch initialises the write_xmit_timer in sync with the other timers, i.e.
the timer will be ready on any socket. This is used by applications with a
listening socket which start to stream after receiving an initiation by the
client. The write_xmit_timer is stopped when the application closes, as before.

Was tested to work and to remove the timer bug reported on dccp@vger.

Also moved timer initialisation into timer.c (static).

Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Acked-by: Ian McDonald <ian.mcdonald@jandi.co.nz>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by Gerrit Renker and committed by David S. Miller aabb601b c4e38f41

+26 -16
+1
net/dccp/dccp.h
··· 191 const enum dccp_pkt_type pkt_type); 192 193 extern void dccp_write_xmit(struct sock *sk, int block); 194 extern void dccp_write_space(struct sock *sk); 195 196 extern void dccp_init_xmit_timers(struct sock *sk);
··· 191 const enum dccp_pkt_type pkt_type); 192 193 extern void dccp_write_xmit(struct sock *sk, int block); 194 + extern void dccp_write_xmit_timer(unsigned long data); 195 extern void dccp_write_space(struct sock *sk); 196 197 extern void dccp_init_xmit_timers(struct sock *sk);
-16
net/dccp/output.c
··· 213 goto out; 214 } 215 216 - static void dccp_write_xmit_timer(unsigned long data) { 217 - struct sock *sk = (struct sock *)data; 218 - struct dccp_sock *dp = dccp_sk(sk); 219 - 220 - bh_lock_sock(sk); 221 - if (sock_owned_by_user(sk)) 222 - sk_reset_timer(sk, &dp->dccps_xmit_timer, jiffies+1); 223 - else 224 - dccp_write_xmit(sk, 0); 225 - bh_unlock_sock(sk); 226 - sock_put(sk); 227 - } 228 - 229 void dccp_write_xmit(struct sock *sk, int block) 230 { 231 struct dccp_sock *dp = dccp_sk(sk); ··· 421 dp->dccps_gar = dp->dccps_iss; 422 423 icsk->icsk_retransmits = 0; 424 - init_timer(&dp->dccps_xmit_timer); 425 - dp->dccps_xmit_timer.data = (unsigned long)sk; 426 - dp->dccps_xmit_timer.function = dccp_write_xmit_timer; 427 } 428 429 int dccp_connect(struct sock *sk)
··· 213 goto out; 214 } 215 216 void dccp_write_xmit(struct sock *sk, int block) 217 { 218 struct dccp_sock *dp = dccp_sk(sk); ··· 434 dp->dccps_gar = dp->dccps_iss; 435 436 icsk->icsk_retransmits = 0; 437 } 438 439 int dccp_connect(struct sock *sk)
+25
net/dccp/timer.c
··· 261 sock_put(sk); 262 } 263 264 void dccp_init_xmit_timers(struct sock *sk) 265 { 266 inet_csk_init_xmit_timers(sk, &dccp_write_timer, &dccp_delack_timer, 267 &dccp_keepalive_timer); 268 }
··· 261 sock_put(sk); 262 } 263 264 + /* Transmit-delay timer: used by the CCIDs to delay actual send time */ 265 + void dccp_write_xmit_timer(unsigned long data) 266 + { 267 + struct sock *sk = (struct sock *)data; 268 + struct dccp_sock *dp = dccp_sk(sk); 269 + 270 + bh_lock_sock(sk); 271 + if (sock_owned_by_user(sk)) 272 + sk_reset_timer(sk, &dp->dccps_xmit_timer, jiffies+1); 273 + else 274 + dccp_write_xmit(sk, 0); 275 + bh_unlock_sock(sk); 276 + sock_put(sk); 277 + } 278 + 279 + static void dccp_init_write_xmit_timer(struct sock *sk) 280 + { 281 + struct dccp_sock *dp = dccp_sk(sk); 282 + 283 + init_timer(&dp->dccps_xmit_timer); 284 + dp->dccps_xmit_timer.data = (unsigned long)sk; 285 + dp->dccps_xmit_timer.function = dccp_write_xmit_timer; 286 + } 287 + 288 void dccp_init_xmit_timers(struct sock *sk) 289 { 290 + dccp_init_write_xmit_timer(sk); 291 inet_csk_init_xmit_timers(sk, &dccp_write_timer, &dccp_delack_timer, 292 &dccp_keepalive_timer); 293 }