net/core: Convert sk_timer users 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 for all users of sk_timer.

Cc: "David S. Miller" <[email protected]>
Cc: Ralf Baechle <[email protected]>
Cc: Andrew Hendry <[email protected]>
Cc: Eric Dumazet <[email protected]>
Cc: Paolo Abeni <[email protected]>
Cc: David Howells <[email protected]>
Cc: Julia Lawall <[email protected]>
Cc: linzhang <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Kees Cook <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
This commit is contained in:
Kees Cook 2017-10-16 17:29:36 -07:00 • committed by David S. Miller
commit 99767f278c
6 changed files with 46 additions and 42 deletions

View file

@ -374,9 +374,11 @@ static void __x25_destroy_socket(struct sock *);
/*
* handler for deferred kills.
*/
static void x25_destroy_timer(unsigned long data)
static void x25_destroy_timer(struct timer_list *t)
{
x25_destroy_socket_from_timer((struct sock *)data);
struct sock *sk = from_timer(sk, t, sk_timer);
x25_destroy_socket_from_timer(sk);
}
/*
@ -413,7 +415,7 @@ static void __x25_destroy_socket(struct sock *sk)
if (sk_has_allocations(sk)) {
/* Defer: outstanding buffers */
sk->sk_timer.expires = jiffies + 10 * HZ;
sk->sk_timer.function = x25_destroy_timer;
sk->sk_timer.function = (TIMER_FUNC_TYPE)x25_destroy_timer;
add_timer(&sk->sk_timer);
} else {
/* drop last reference so sock_put will free */

View file

@ -26,17 +26,17 @@
#include <net/tcp_states.h>
#include <net/x25.h>
static void x25_heartbeat_expiry(unsigned long);
static void x25_timer_expiry(unsigned long);
static void x25_heartbeat_expiry(struct timer_list *t);
static void x25_timer_expiry(struct timer_list *t);
void x25_init_timers(struct sock *sk)
{
struct x25_sock *x25 = x25_sk(sk);
setup_timer(&x25->timer, x25_timer_expiry, (unsigned long)sk);
timer_setup(&x25->timer, x25_timer_expiry, 0);
/* initialized by sock_init_data */
sk->sk_timer.function = &x25_heartbeat_expiry;
sk->sk_timer.function = (TIMER_FUNC_TYPE)x25_heartbeat_expiry;
}
void x25_start_heartbeat(struct sock *sk)
@ -92,9 +92,9 @@ unsigned long x25_display_timer(struct sock *sk)
return x25->timer.expires - jiffies;
}
static void x25_heartbeat_expiry(unsigned long param)
static void x25_heartbeat_expiry(struct timer_list *t)
{
struct sock *sk = (struct sock *)param;
struct sock *sk = from_timer(sk, t, sk_timer);
bh_lock_sock(sk);
if (sock_owned_by_user(sk)) /* can currently only occur in state 3 */
@ -159,9 +159,10 @@ static inline void x25_do_timer_expiry(struct sock * sk)
}
}
static void x25_timer_expiry(unsigned long param)
static void x25_timer_expiry(struct timer_list *t)
{
struct sock *sk = (struct sock *)param;
struct x25_sock *x25 = from_timer(x25, t, timer);
struct sock *sk = &x25->sk;
bh_lock_sock(sk);
if (sock_owned_by_user(sk)) { /* can currently only occur in state 3 */