Commit 47faa1e4c50ec26e6e75dcd1ce53f064bd45f729
Committed by
David S. Miller
1 parent
fba4c330c5
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>
Showing 4 changed files with 2 additions and 21 deletions Side-by-side Diff
include/net/sctp/structs.h
... | ... | @@ -756,7 +756,6 @@ |
756 | 756 | |
757 | 757 | /* Reference counting. */ |
758 | 758 | atomic_t refcnt; |
759 | - __u32 dead:1, | |
760 | 759 | /* RTO-Pending : A flag used to track if one of the DATA |
761 | 760 | * chunks sent to this address is currently being |
762 | 761 | * used to compute a RTT. If this flag is 0, |
... | ... | @@ -766,7 +765,7 @@ |
766 | 765 | * calculation completes (i.e. the DATA chunk |
767 | 766 | * is SACK'd) clear this flag. |
768 | 767 | */ |
769 | - rto_pending:1, | |
768 | + __u32 rto_pending:1, | |
770 | 769 | |
771 | 770 | /* |
772 | 771 | * hb_sent : a flag that signals that we have a pending |
net/sctp/proc.c
... | ... | @@ -165,8 +165,6 @@ |
165 | 165 | list_for_each_entry_rcu(transport, &assoc->peer.transport_addr_list, |
166 | 166 | transports) { |
167 | 167 | addr = &transport->ipaddr; |
168 | - if (transport->dead) | |
169 | - continue; | |
170 | 168 | |
171 | 169 | af = sctp_get_af_specific(addr->sa.sa_family); |
172 | 170 | if (af->cmp_addr(addr, primary)) { |
... | ... | @@ -499,8 +497,6 @@ |
499 | 497 | |
500 | 498 | list_for_each_entry_rcu(tsp, &assoc->peer.transport_addr_list, |
501 | 499 | transports) { |
502 | - if (tsp->dead) | |
503 | - continue; | |
504 | 500 | /* |
505 | 501 | * The remote address (ADDR) |
506 | 502 | */ |
net/sctp/sm_sideeffect.c
... | ... | @@ -259,12 +259,6 @@ |
259 | 259 | goto out_unlock; |
260 | 260 | } |
261 | 261 | |
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 | - | |
268 | 262 | /* Run through the state machine. */ |
269 | 263 | error = sctp_do_sm(net, SCTP_EVENT_T_TIMEOUT, |
270 | 264 | SCTP_ST_TIMEOUT(SCTP_EVENT_TIMEOUT_T3_RTX), |
... | ... | @@ -379,12 +373,6 @@ |
379 | 373 | sctp_transport_hold(transport); |
380 | 374 | goto out_unlock; |
381 | 375 | } |
382 | - | |
383 | - /* Is this structure just waiting around for us to actually | |
384 | - * get destroyed? | |
385 | - */ | |
386 | - if (transport->dead) | |
387 | - goto out_unlock; | |
388 | 376 | |
389 | 377 | error = sctp_do_sm(net, SCTP_EVENT_T_TIMEOUT, |
390 | 378 | SCTP_ST_TIMEOUT(SCTP_EVENT_TIMEOUT_HEARTBEAT), |
net/sctp/transport.c
... | ... | @@ -132,8 +132,6 @@ |
132 | 132 | */ |
133 | 133 | void sctp_transport_free(struct sctp_transport *transport) |
134 | 134 | { |
135 | - transport->dead = 1; | |
136 | - | |
137 | 135 | /* Try to delete the heartbeat timer. */ |
138 | 136 | if (del_timer(&transport->hb_timer)) |
139 | 137 | sctp_transport_put(transport); |
... | ... | @@ -169,7 +167,7 @@ |
169 | 167 | */ |
170 | 168 | static void sctp_transport_destroy(struct sctp_transport *transport) |
171 | 169 | { |
172 | - if (unlikely(!transport->dead)) { | |
170 | + if (unlikely(atomic_read(&transport->refcnt))) { | |
173 | 171 | WARN(1, "Attempt to destroy undead transport %p!\n", transport); |
174 | 172 | return; |
175 | 173 | } |