From c06e320f99b3c156811ce4e2e71a807acf7adb6d Mon Sep 17 00:00:00 2001 From: zzz Date: Fri, 31 Mar 2017 12:28:31 +0000 Subject: [PATCH] SSU: When a IPv6 peer connects, trigger a IPv6 peer test, not a IPv4 one Require two consecutive peer test results for some state transitions, to prevent frequent transitions to firewalled and back --- history.txt | 12 ++++++++ .../src/net/i2p/router/RouterVersion.java | 2 +- .../router/transport/udp/UDPTransport.java | 28 +++++++++++++++++-- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/history.txt b/history.txt index 1bc09ad928..447cd4cad2 100644 --- a/history.txt +++ b/history.txt @@ -1,5 +1,17 @@ +2017-03-31 zzz + * SSU: + - When a IPv6 peer connects, trigger a IPv6 peer test, not a IPv4 one + - Require two consecutive peer test results for some state transitions, + to prevent frequent transitions to firewalled and back + +2017-03-29 zzz + * SSU: Refactor PeerTestEvent out of UDPTransport + * Throttle: Reduce threshold for probabalistic throttling + on slow platforms (ticket #1964) + 2017-03-27 zzz * Blockfile: Include authentication strings in exports + * Build: Suppress JarScanner warning during Debian build (ticket #1975) * Debian: Add missing addressbook.jar to package (ticket #1973) * SusiDNS: Add addressbook.jar to classpath, don't fail to start if it's still not found (ticket #1973) diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index e36cd3b143..7f4edb9752 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,7 +18,7 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Monotone"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 12; + public final static long BUILD = 13; /** for example "-test" */ public final static String EXTRA = ""; diff --git a/router/java/src/net/i2p/router/transport/udp/UDPTransport.java b/router/java/src/net/i2p/router/transport/udp/UDPTransport.java index d7f55564f8..1d0b659bb2 100644 --- a/router/java/src/net/i2p/router/transport/udp/UDPTransport.java +++ b/router/java/src/net/i2p/router/transport/udp/UDPTransport.java @@ -81,6 +81,8 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority private final PeerTestEvent _testEvent; private final PacketBuilder _destroyBuilder; private Status _reachabilityStatus; + private Status _reachabilityStatusPending; + // only for logging, to be removed private long _reachabilityStatusLastUpdated; private int _reachabilityStatusUnchanged; private long _introducersSelectedOn; @@ -267,6 +269,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority _testManager = new PeerTestManager(_context, this); _testEvent = new PeerTestEvent(_context, this, _testManager); _reachabilityStatus = Status.UNKNOWN; + _reachabilityStatusPending = Status.OK; _introManager = new IntroductionManager(_context, this); _introducersSelectedOn = -1; _lastInboundReceivedOn = -1; @@ -1345,8 +1348,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority status != Status.IPV4_DISABLED_IPV6_FIREWALLED && status != Status.DISCONNECTED && _reachabilityStatusUnchanged < 7) { - // IPv4 only for now - _testEvent.forceRunSoon(false); + _testEvent.forceRunSoon(peer.isIPv6()); } } return true; @@ -3155,6 +3157,27 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority } if (status != old) { + // for the following transitions ONLY, require two in a row + // to prevent thrashing + if ((old == Status.OK && (status == Status.DIFFERENT || + status == Status.REJECT_UNSOLICITED || + status == Status.IPV4_FIREWALLED_IPV6_OK || + status == Status.IPV4_SNAT_IPV6_OK || + status == Status.IPV4_OK_IPV6_FIREWALLED)) || + (status == Status.OK && (old == Status.DIFFERENT || + old == Status.REJECT_UNSOLICITED || + old == Status.IPV4_FIREWALLED_IPV6_OK || + old == Status.IPV4_SNAT_IPV6_OK || + old == Status.IPV4_OK_IPV6_FIREWALLED))) { + if (status != _reachabilityStatusPending) { + if (_log.shouldLog(Log.WARN)) + _log.warn("Old status: " + old + " status pending confirmation: " + status + + " Caused by update: " + newStatus); + _reachabilityStatusPending = status; + _testEvent.forceRunSoon(isIPv6); + return; + } + } _reachabilityStatusUnchanged = 0; long now = _context.clock().now(); _reachabilityStatusLastUpdated = now; @@ -3162,6 +3185,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority } else { _reachabilityStatusUnchanged++; } + _reachabilityStatusPending = status; } if (status != old) { if (_log.shouldLog(Log.WARN))