Skip to content

Commit 31b102b

Browse files
keesdavem330
authored andcommitted
net: tipc: 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. Cc: Jon Maloy <jon.maloy@ericsson.com> Cc: Ying Xue <ying.xue@windriver.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: netdev@vger.kernel.org Cc: tipc-discussion@lists.sourceforge.net Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 1556770 commit 31b102b

5 files changed

Lines changed: 18 additions & 18 deletions

File tree

‎net/tipc/discover.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,9 @@ void tipc_disc_remove_dest(struct tipc_link_req *req)
224224
*
225225
* Called whenever a link setup request timer associated with a bearer expires.
226226
*/
227-
static void disc_timeout(unsigned long data)
227+
static void disc_timeout(struct timer_list *t)
228228
{
229-
struct tipc_link_req *req = (struct tipc_link_req *)data;
229+
struct tipc_link_req *req = from_timer(req, t, timer);
230230
struct sk_buff *skb;
231231
int max_delay;
232232

@@ -292,7 +292,7 @@ int tipc_disc_create(struct net *net, struct tipc_bearer *b,
292292
req->num_nodes = 0;
293293
req->timer_intv = TIPC_LINK_REQ_INIT;
294294
spin_lock_init(&req->lock);
295-
setup_timer(&req->timer, disc_timeout, (unsigned long)req);
295+
timer_setup(&req->timer, disc_timeout, 0);
296296
mod_timer(&req->timer, jiffies + req->timer_intv);
297297
b->link_req = req;
298298
*skb = skb_clone(req->buf, GFP_ATOMIC);

‎net/tipc/monitor.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -578,9 +578,9 @@ void tipc_mon_get_state(struct net *net, u32 addr,
578578
read_unlock_bh(&mon->lock);
579579
}
580580

581-
static void mon_timeout(unsigned long m)
581+
static void mon_timeout(struct timer_list *t)
582582
{
583-
struct tipc_monitor *mon = (void *)m;
583+
struct tipc_monitor *mon = from_timer(mon, t, timer);
584584
struct tipc_peer *self;
585585
int best_member_cnt = dom_size(mon->peer_cnt) - 1;
586586

@@ -623,7 +623,7 @@ int tipc_mon_create(struct net *net, int bearer_id)
623623
self->is_up = true;
624624
self->is_head = true;
625625
INIT_LIST_HEAD(&self->list);
626-
setup_timer(&mon->timer, mon_timeout, (unsigned long)mon);
626+
timer_setup(&mon->timer, mon_timeout, 0);
627627
mon->timer_intv = msecs_to_jiffies(MON_TIMEOUT + (tn->random & 0xffff));
628628
mod_timer(&mon->timer, jiffies + mon->timer_intv);
629629
return 0;

‎net/tipc/node.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ static void tipc_node_link_down(struct tipc_node *n, int bearer_id,
153153
bool delete);
154154
static void node_lost_contact(struct tipc_node *n, struct sk_buff_head *inputq);
155155
static void tipc_node_delete(struct tipc_node *node);
156-
static void tipc_node_timeout(unsigned long data);
156+
static void tipc_node_timeout(struct timer_list *t);
157157
static void tipc_node_fsm_evt(struct tipc_node *n, int evt);
158158
static struct tipc_node *tipc_node_find(struct net *net, u32 addr);
159159
static void tipc_node_put(struct tipc_node *node);
@@ -361,7 +361,7 @@ struct tipc_node *tipc_node_create(struct net *net, u32 addr, u16 capabilities)
361361
goto exit;
362362
}
363363
tipc_node_get(n);
364-
setup_timer(&n->timer, tipc_node_timeout, (unsigned long)n);
364+
timer_setup(&n->timer, tipc_node_timeout, 0);
365365
n->keepalive_intv = U32_MAX;
366366
hlist_add_head_rcu(&n->hash, &tn->node_htable[tipc_hashfn(addr)]);
367367
list_for_each_entry_rcu(temp_node, &tn->node_list, list) {
@@ -500,9 +500,9 @@ void tipc_node_remove_conn(struct net *net, u32 dnode, u32 port)
500500

501501
/* tipc_node_timeout - handle expiration of node timer
502502
*/
503-
static void tipc_node_timeout(unsigned long data)
503+
static void tipc_node_timeout(struct timer_list *t)
504504
{
505-
struct tipc_node *n = (struct tipc_node *)data;
505+
struct tipc_node *n = from_timer(n, t, timer);
506506
struct tipc_link_entry *le;
507507
struct sk_buff_head xmitq;
508508
int bearer_id;

‎net/tipc/socket.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ static void tipc_sock_destruct(struct sock *sk);
125125
static int tipc_release(struct socket *sock);
126126
static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags,
127127
bool kern);
128-
static void tipc_sk_timeout(unsigned long data);
128+
static void tipc_sk_timeout(struct timer_list *t);
129129
static int tipc_sk_publish(struct tipc_sock *tsk, uint scope,
130130
struct tipc_name_seq const *seq);
131131
static int tipc_sk_withdraw(struct tipc_sock *tsk, uint scope,
@@ -464,7 +464,7 @@ static int tipc_sk_create(struct net *net, struct socket *sock,
464464
NAMED_H_SIZE, 0);
465465

466466
msg_set_origport(msg, tsk->portid);
467-
setup_timer(&sk->sk_timer, tipc_sk_timeout, (unsigned long)tsk);
467+
timer_setup(&sk->sk_timer, tipc_sk_timeout, 0);
468468
sk->sk_shutdown = 0;
469469
sk->sk_backlog_rcv = tipc_sk_backlog_rcv;
470470
sk->sk_rcvbuf = sysctl_tipc_rmem[1];
@@ -2530,14 +2530,14 @@ static int tipc_shutdown(struct socket *sock, int how)
25302530
return res;
25312531
}
25322532

2533-
static void tipc_sk_timeout(unsigned long data)
2533+
static void tipc_sk_timeout(struct timer_list *t)
25342534
{
2535-
struct tipc_sock *tsk = (struct tipc_sock *)data;
2535+
struct sock *sk = from_timer(sk, t, sk_timer);
2536+
struct tipc_sock *tsk = tipc_sk(sk);
25362537
u32 peer_port = tsk_peer_port(tsk);
25372538
u32 peer_node = tsk_peer_node(tsk);
25382539
u32 own_node = tsk_own_node(tsk);
25392540
u32 own_port = tsk->portid;
2540-
struct sock *sk = &tsk->sk;
25412541
struct net *net = sock_net(sk);
25422542
struct sk_buff *skb = NULL;
25432543

‎net/tipc/subscr.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@ void tipc_subscrp_report_overlap(struct tipc_subscription *sub, u32 found_lower,
133133
node);
134134
}
135135

136-
static void tipc_subscrp_timeout(unsigned long data)
136+
static void tipc_subscrp_timeout(struct timer_list *t)
137137
{
138-
struct tipc_subscription *sub = (struct tipc_subscription *)data;
138+
struct tipc_subscription *sub = from_timer(sub, t, timer);
139139
struct tipc_subscriber *subscriber = sub->subscriber;
140140

141141
spin_lock_bh(&subscriber->lock);
@@ -303,7 +303,7 @@ static void tipc_subscrp_subscribe(struct net *net, struct tipc_subscr *s,
303303
tipc_subscrb_get(subscriber);
304304
spin_unlock_bh(&subscriber->lock);
305305

306-
setup_timer(&sub->timer, tipc_subscrp_timeout, (unsigned long)sub);
306+
timer_setup(&sub->timer, tipc_subscrp_timeout, 0);
307307
timeout = htohl(sub->evt.s.timeout, swap);
308308

309309
if (timeout != TIPC_WAIT_FOREVER)

0 commit comments

Comments
 (0)