diff options
author | Kees Cook <keescook@chromium.org> | 2017-10-30 17:06:45 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-10-31 23:38:45 -0400 |
commit | 31b102bb501bea50ebc10f4aecf9d788305b8b87 (patch) | |
tree | f89a272ba7cd7bd71fe6ffdbb966d30e66cd12de | |
parent | 1556770a1a071435ba7e67c1bc809099dc1de849 (diff) |
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>
-rw-r--r-- | net/tipc/discover.c | 6 | ||||
-rw-r--r-- | net/tipc/monitor.c | 6 | ||||
-rw-r--r-- | net/tipc/node.c | 8 | ||||
-rw-r--r-- | net/tipc/socket.c | 10 | ||||
-rw-r--r-- | net/tipc/subscr.c | 6 |
5 files changed, 18 insertions, 18 deletions
diff --git a/net/tipc/discover.c b/net/tipc/discover.c index 02462d67d191..92e4828c6b09 100644 --- a/net/tipc/discover.c +++ b/net/tipc/discover.c | |||
@@ -224,9 +224,9 @@ void tipc_disc_remove_dest(struct tipc_link_req *req) | |||
224 | * | 224 | * |
225 | * Called whenever a link setup request timer associated with a bearer expires. | 225 | * Called whenever a link setup request timer associated with a bearer expires. |
226 | */ | 226 | */ |
227 | static void disc_timeout(unsigned long data) | 227 | static void disc_timeout(struct timer_list *t) |
228 | { | 228 | { |
229 | struct tipc_link_req *req = (struct tipc_link_req *)data; | 229 | struct tipc_link_req *req = from_timer(req, t, timer); |
230 | struct sk_buff *skb; | 230 | struct sk_buff *skb; |
231 | int max_delay; | 231 | int max_delay; |
232 | 232 | ||
@@ -292,7 +292,7 @@ int tipc_disc_create(struct net *net, struct tipc_bearer *b, | |||
292 | req->num_nodes = 0; | 292 | req->num_nodes = 0; |
293 | req->timer_intv = TIPC_LINK_REQ_INIT; | 293 | req->timer_intv = TIPC_LINK_REQ_INIT; |
294 | spin_lock_init(&req->lock); | 294 | spin_lock_init(&req->lock); |
295 | setup_timer(&req->timer, disc_timeout, (unsigned long)req); | 295 | timer_setup(&req->timer, disc_timeout, 0); |
296 | mod_timer(&req->timer, jiffies + req->timer_intv); | 296 | mod_timer(&req->timer, jiffies + req->timer_intv); |
297 | b->link_req = req; | 297 | b->link_req = req; |
298 | *skb = skb_clone(req->buf, GFP_ATOMIC); | 298 | *skb = skb_clone(req->buf, GFP_ATOMIC); |
diff --git a/net/tipc/monitor.c b/net/tipc/monitor.c index 9e109bb1a207..b9c32557d73c 100644 --- a/net/tipc/monitor.c +++ b/net/tipc/monitor.c | |||
@@ -578,9 +578,9 @@ void tipc_mon_get_state(struct net *net, u32 addr, | |||
578 | read_unlock_bh(&mon->lock); | 578 | read_unlock_bh(&mon->lock); |
579 | } | 579 | } |
580 | 580 | ||
581 | static void mon_timeout(unsigned long m) | 581 | static void mon_timeout(struct timer_list *t) |
582 | { | 582 | { |
583 | struct tipc_monitor *mon = (void *)m; | 583 | struct tipc_monitor *mon = from_timer(mon, t, timer); |
584 | struct tipc_peer *self; | 584 | struct tipc_peer *self; |
585 | int best_member_cnt = dom_size(mon->peer_cnt) - 1; | 585 | int best_member_cnt = dom_size(mon->peer_cnt) - 1; |
586 | 586 | ||
@@ -623,7 +623,7 @@ int tipc_mon_create(struct net *net, int bearer_id) | |||
623 | self->is_up = true; | 623 | self->is_up = true; |
624 | self->is_head = true; | 624 | self->is_head = true; |
625 | INIT_LIST_HEAD(&self->list); | 625 | INIT_LIST_HEAD(&self->list); |
626 | setup_timer(&mon->timer, mon_timeout, (unsigned long)mon); | 626 | timer_setup(&mon->timer, mon_timeout, 0); |
627 | mon->timer_intv = msecs_to_jiffies(MON_TIMEOUT + (tn->random & 0xffff)); | 627 | mon->timer_intv = msecs_to_jiffies(MON_TIMEOUT + (tn->random & 0xffff)); |
628 | mod_timer(&mon->timer, jiffies + mon->timer_intv); | 628 | mod_timer(&mon->timer, jiffies + mon->timer_intv); |
629 | return 0; | 629 | return 0; |
diff --git a/net/tipc/node.c b/net/tipc/node.c index 89f8ac73bf65..009a81631280 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c | |||
@@ -153,7 +153,7 @@ static void tipc_node_link_down(struct tipc_node *n, int bearer_id, | |||
153 | bool delete); | 153 | bool delete); |
154 | static void node_lost_contact(struct tipc_node *n, struct sk_buff_head *inputq); | 154 | static void node_lost_contact(struct tipc_node *n, struct sk_buff_head *inputq); |
155 | static void tipc_node_delete(struct tipc_node *node); | 155 | 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); |
157 | static void tipc_node_fsm_evt(struct tipc_node *n, int evt); | 157 | static void tipc_node_fsm_evt(struct tipc_node *n, int evt); |
158 | static struct tipc_node *tipc_node_find(struct net *net, u32 addr); | 158 | static struct tipc_node *tipc_node_find(struct net *net, u32 addr); |
159 | static void tipc_node_put(struct tipc_node *node); | 159 | 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) | |||
361 | goto exit; | 361 | goto exit; |
362 | } | 362 | } |
363 | tipc_node_get(n); | 363 | tipc_node_get(n); |
364 | setup_timer(&n->timer, tipc_node_timeout, (unsigned long)n); | 364 | timer_setup(&n->timer, tipc_node_timeout, 0); |
365 | n->keepalive_intv = U32_MAX; | 365 | n->keepalive_intv = U32_MAX; |
366 | hlist_add_head_rcu(&n->hash, &tn->node_htable[tipc_hashfn(addr)]); | 366 | hlist_add_head_rcu(&n->hash, &tn->node_htable[tipc_hashfn(addr)]); |
367 | list_for_each_entry_rcu(temp_node, &tn->node_list, list) { | 367 | 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) | |||
500 | 500 | ||
501 | /* tipc_node_timeout - handle expiration of node timer | 501 | /* tipc_node_timeout - handle expiration of node timer |
502 | */ | 502 | */ |
503 | static void tipc_node_timeout(unsigned long data) | 503 | static void tipc_node_timeout(struct timer_list *t) |
504 | { | 504 | { |
505 | struct tipc_node *n = (struct tipc_node *)data; | 505 | struct tipc_node *n = from_timer(n, t, timer); |
506 | struct tipc_link_entry *le; | 506 | struct tipc_link_entry *le; |
507 | struct sk_buff_head xmitq; | 507 | struct sk_buff_head xmitq; |
508 | int bearer_id; | 508 | int bearer_id; |
diff --git a/net/tipc/socket.c b/net/tipc/socket.c index ea61c32f6b80..5d18c0caa92b 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c | |||
@@ -125,7 +125,7 @@ static void tipc_sock_destruct(struct sock *sk); | |||
125 | static int tipc_release(struct socket *sock); | 125 | static int tipc_release(struct socket *sock); |
126 | static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags, | 126 | static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags, |
127 | bool kern); | 127 | bool kern); |
128 | static void tipc_sk_timeout(unsigned long data); | 128 | static void tipc_sk_timeout(struct timer_list *t); |
129 | static int tipc_sk_publish(struct tipc_sock *tsk, uint scope, | 129 | static int tipc_sk_publish(struct tipc_sock *tsk, uint scope, |
130 | struct tipc_name_seq const *seq); | 130 | struct tipc_name_seq const *seq); |
131 | static int tipc_sk_withdraw(struct tipc_sock *tsk, uint scope, | 131 | 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, | |||
464 | NAMED_H_SIZE, 0); | 464 | NAMED_H_SIZE, 0); |
465 | 465 | ||
466 | msg_set_origport(msg, tsk->portid); | 466 | 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); |
468 | sk->sk_shutdown = 0; | 468 | sk->sk_shutdown = 0; |
469 | sk->sk_backlog_rcv = tipc_sk_backlog_rcv; | 469 | sk->sk_backlog_rcv = tipc_sk_backlog_rcv; |
470 | sk->sk_rcvbuf = sysctl_tipc_rmem[1]; | 470 | sk->sk_rcvbuf = sysctl_tipc_rmem[1]; |
@@ -2530,14 +2530,14 @@ static int tipc_shutdown(struct socket *sock, int how) | |||
2530 | return res; | 2530 | return res; |
2531 | } | 2531 | } |
2532 | 2532 | ||
2533 | static void tipc_sk_timeout(unsigned long data) | 2533 | static void tipc_sk_timeout(struct timer_list *t) |
2534 | { | 2534 | { |
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); | ||
2536 | u32 peer_port = tsk_peer_port(tsk); | 2537 | u32 peer_port = tsk_peer_port(tsk); |
2537 | u32 peer_node = tsk_peer_node(tsk); | 2538 | u32 peer_node = tsk_peer_node(tsk); |
2538 | u32 own_node = tsk_own_node(tsk); | 2539 | u32 own_node = tsk_own_node(tsk); |
2539 | u32 own_port = tsk->portid; | 2540 | u32 own_port = tsk->portid; |
2540 | struct sock *sk = &tsk->sk; | ||
2541 | struct net *net = sock_net(sk); | 2541 | struct net *net = sock_net(sk); |
2542 | struct sk_buff *skb = NULL; | 2542 | struct sk_buff *skb = NULL; |
2543 | 2543 | ||
diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c index be3d9e3183dc..251065dfd8df 100644 --- a/net/tipc/subscr.c +++ b/net/tipc/subscr.c | |||
@@ -133,9 +133,9 @@ void tipc_subscrp_report_overlap(struct tipc_subscription *sub, u32 found_lower, | |||
133 | node); | 133 | node); |
134 | } | 134 | } |
135 | 135 | ||
136 | static void tipc_subscrp_timeout(unsigned long data) | 136 | static void tipc_subscrp_timeout(struct timer_list *t) |
137 | { | 137 | { |
138 | struct tipc_subscription *sub = (struct tipc_subscription *)data; | 138 | struct tipc_subscription *sub = from_timer(sub, t, timer); |
139 | struct tipc_subscriber *subscriber = sub->subscriber; | 139 | struct tipc_subscriber *subscriber = sub->subscriber; |
140 | 140 | ||
141 | spin_lock_bh(&subscriber->lock); | 141 | spin_lock_bh(&subscriber->lock); |
@@ -303,7 +303,7 @@ static void tipc_subscrp_subscribe(struct net *net, struct tipc_subscr *s, | |||
303 | tipc_subscrb_get(subscriber); | 303 | tipc_subscrb_get(subscriber); |
304 | spin_unlock_bh(&subscriber->lock); | 304 | spin_unlock_bh(&subscriber->lock); |
305 | 305 | ||
306 | setup_timer(&sub->timer, tipc_subscrp_timeout, (unsigned long)sub); | 306 | timer_setup(&sub->timer, tipc_subscrp_timeout, 0); |
307 | timeout = htohl(sub->evt.s.timeout, swap); | 307 | timeout = htohl(sub->evt.s.timeout, swap); |
308 | 308 | ||
309 | if (timeout != TIPC_WAIT_FOREVER) | 309 | if (timeout != TIPC_WAIT_FOREVER) |