Skip to content

Commit 47faa1e

Browse files
lxindavem330
authored andcommitted
sctp: remove the dead field of sctp_transport
After we use refcnt to check if transport is alive, the dead can be removed from sctp_transport. The traversal of transport_addr_list in procfs dump is using list_for_each_entry_rcu, no need to check if it has been freed. sctp_generate_t3_rtx_event and sctp_generate_heartbeat_event is protected by sock lock, it's not necessary to check dead, either. also, the timers are cancelled when sctp_transport_free() is called, that it doesn't wait for refcnt to reach 0 to cancel them. Signed-off-by: Xin Long <lucien.xin@gmail.com> Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent fba4c33 commit 47faa1e

File tree

4 files changed

+2
-21
lines changed

4 files changed

+2
-21
lines changed

include/net/sctp/structs.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,6 @@ struct sctp_transport {
756756

757757
/* Reference counting. */
758758
atomic_t refcnt;
759-
__u32 dead:1,
760759
/* RTO-Pending : A flag used to track if one of the DATA
761760
* chunks sent to this address is currently being
762761
* used to compute a RTT. If this flag is 0,
@@ -766,7 +765,7 @@ struct sctp_transport {
766765
* calculation completes (i.e. the DATA chunk
767766
* is SACK'd) clear this flag.
768767
*/
769-
rto_pending:1,
768+
__u32 rto_pending:1,
770769

771770
/*
772771
* hb_sent : a flag that signals that we have a pending

net/sctp/proc.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,6 @@ static void sctp_seq_dump_remote_addrs(struct seq_file *seq, struct sctp_associa
165165
list_for_each_entry_rcu(transport, &assoc->peer.transport_addr_list,
166166
transports) {
167167
addr = &transport->ipaddr;
168-
if (transport->dead)
169-
continue;
170168

171169
af = sctp_get_af_specific(addr->sa.sa_family);
172170
if (af->cmp_addr(addr, primary)) {
@@ -499,8 +497,6 @@ static int sctp_remaddr_seq_show(struct seq_file *seq, void *v)
499497

500498
list_for_each_entry_rcu(tsp, &assoc->peer.transport_addr_list,
501499
transports) {
502-
if (tsp->dead)
503-
continue;
504500
/*
505501
* The remote address (ADDR)
506502
*/

net/sctp/sm_sideeffect.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -259,12 +259,6 @@ void sctp_generate_t3_rtx_event(unsigned long peer)
259259
goto out_unlock;
260260
}
261261

262-
/* Is this transport really dead and just waiting around for
263-
* the timer to let go of the reference?
264-
*/
265-
if (transport->dead)
266-
goto out_unlock;
267-
268262
/* Run through the state machine. */
269263
error = sctp_do_sm(net, SCTP_EVENT_T_TIMEOUT,
270264
SCTP_ST_TIMEOUT(SCTP_EVENT_TIMEOUT_T3_RTX),
@@ -380,12 +374,6 @@ void sctp_generate_heartbeat_event(unsigned long data)
380374
goto out_unlock;
381375
}
382376

383-
/* Is this structure just waiting around for us to actually
384-
* get destroyed?
385-
*/
386-
if (transport->dead)
387-
goto out_unlock;
388-
389377
error = sctp_do_sm(net, SCTP_EVENT_T_TIMEOUT,
390378
SCTP_ST_TIMEOUT(SCTP_EVENT_TIMEOUT_HEARTBEAT),
391379
asoc->state, asoc->ep, asoc,

net/sctp/transport.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,6 @@ struct sctp_transport *sctp_transport_new(struct net *net,
132132
*/
133133
void sctp_transport_free(struct sctp_transport *transport)
134134
{
135-
transport->dead = 1;
136-
137135
/* Try to delete the heartbeat timer. */
138136
if (del_timer(&transport->hb_timer))
139137
sctp_transport_put(transport);
@@ -169,7 +167,7 @@ static void sctp_transport_destroy_rcu(struct rcu_head *head)
169167
*/
170168
static void sctp_transport_destroy(struct sctp_transport *transport)
171169
{
172-
if (unlikely(!transport->dead)) {
170+
if (unlikely(atomic_read(&transport->refcnt))) {
173171
WARN(1, "Attempt to destroy undead transport %p!\n", transport);
174172
return;
175173
}

0 commit comments

Comments
 (0)