@@ -14,12 +14,6 @@ use super::{
1414} ;
1515use crate :: disco:: SendAddr ;
1616
17- /// The minimum time between pings to an endpoint.
18- ///
19- /// Except in the case of CallMeMaybe frames resetting the counter, as the first pings
20- /// likely didn't through the firewall.
21- const DISCO_PING_INTERVAL : Duration = Duration :: from_secs ( 5 ) ;
22-
2317/// State about a particular path to another [`NodeState`].
2418///
2519/// This state is used for both the relay path and any direct UDP paths.
@@ -31,13 +25,6 @@ pub(super) struct PathState {
3125 node_id : NodeId ,
3226 /// The path this applies for.
3327 path : SendAddr ,
34- /// The last (outgoing) ping time.
35- pub ( super ) last_ping : Option < Instant > ,
36-
37- /// If non-zero, means that this was an endpoint that we learned about at runtime (from an
38- /// incoming ping). If so, we keep the time updated and use it to discard old candidates.
39- // NOTE: tx_id Originally added in tailscale due to <https://github.com/tailscale/tailscale/issues/7078>.
40- last_got_ping : Option < ( Instant , stun_rs:: TransactionId ) > ,
4128
4229 /// The time this endpoint was last advertised via a call-me-maybe DISCO message.
4330 pub ( super ) call_me_maybe_time : Option < Instant > ,
@@ -61,8 +48,6 @@ impl PathState {
6148 Self {
6249 node_id,
6350 path,
64- last_ping : None ,
65- last_got_ping : None ,
6651 call_me_maybe_time : None ,
6752 last_payload_msg : None ,
6853 sources,
@@ -87,8 +72,6 @@ impl PathState {
8772 PathState {
8873 node_id,
8974 path,
90- last_ping : None ,
91- last_got_ping : None ,
9275 call_me_maybe_time : None ,
9376 last_payload_msg : Some ( now) ,
9477 sources,
@@ -109,11 +92,6 @@ impl PathState {
10992 . unwrap_or ( false )
11093 }
11194
112- /// Returns the instant the last incoming ping was received.
113- pub ( super ) fn last_incoming_ping ( & self ) -> Option < & Instant > {
114- self . last_got_ping . as_ref ( ) . map ( |( time, _tx_id) | time)
115- }
116-
11795 /// Reports the last instant this path was considered alive.
11896 ///
11997 /// Alive means the path is considered in use by the remote endpoint. Either because we
@@ -130,15 +108,13 @@ impl PathState {
130108 . as_ref ( )
131109 . into_iter ( )
132110 . chain ( self . call_me_maybe_time . as_ref ( ) )
133- . chain ( self . last_incoming_ping ( ) )
134111 . max ( )
135112 . copied ( )
136113 }
137114
138115 /// The last control or DISCO message **about** this path.
139116 ///
140117 /// This is the most recent instant among:
141- /// - when last pong was received.
142118 /// - when this path was last advertised in a received CallMeMaybe message.
143119 /// - when the last ping from them was received.
144120 ///
@@ -149,41 +125,18 @@ impl PathState {
149125 . call_me_maybe_time
150126 . as_ref ( )
151127 . map ( |call_me| ( * call_me, ControlMsg :: CallMeMaybe ) ) ;
152- let last_ping = self
153- . last_incoming_ping ( )
154- . map ( |ping| ( * ping, ControlMsg :: Ping ) ) ;
155128
156129 last_call_me_maybe
157130 . into_iter ( )
158- . chain ( last_ping)
159131 . max_by_key ( |( instant, _kind) | * instant)
160132 . map ( |( instant, kind) | ( now. duration_since ( instant) , kind) )
161133 }
162134
163- pub ( super ) fn needs_ping ( & self , now : & Instant ) -> bool {
164- match self . last_ping {
165- None => true ,
166- Some ( last_ping) => {
167- let elapsed = now. duration_since ( last_ping) ;
168-
169- // TODO: remove!
170- // This logs "ping is too new" for each send whenever the endpoint does *not* need
171- // a ping. Pretty sure this is not a useful log, but maybe there was a reason?
172- // if !needs_ping {
173- // debug!("ping is too new: {}ms", elapsed.as_millis());
174- // }
175- elapsed > DISCO_PING_INTERVAL
176- }
177- }
178- }
179-
180135 pub ( super ) fn add_source ( & mut self , source : Source , now : Instant ) {
181136 self . sources . insert ( source, now) ;
182137 }
183138
184139 pub ( super ) fn clear ( & mut self ) {
185- self . last_ping = None ;
186- self . last_got_ping = None ;
187140 self . call_me_maybe_time = None ;
188141 }
189142
@@ -192,12 +145,6 @@ impl PathState {
192145 if self . is_active ( ) {
193146 write ! ( w, "active " ) ?;
194147 }
195- if let Some ( when) = self . last_incoming_ping ( ) {
196- write ! ( w, "ping-received({:?} ago) " , when. elapsed( ) ) ?;
197- }
198- if let Some ( ref when) = self . last_ping {
199- write ! ( w, "ping-sent({:?} ago) " , when. elapsed( ) ) ?;
200- }
201148 if let Some ( last_source) = self . sources . iter ( ) . max_by_key ( |& ( _, instant) | instant) {
202149 write ! (
203150 w,
0 commit comments