forked from I2P_Developers/i2p.i2p
SSU2: Don't publish or connect if our MTU becomes too small
after initial check in constructor Don't rectify 1280 IPv4 MTU down to 1276 Add note about replay detector
This commit is contained in:
@@ -432,7 +432,10 @@ class EstablishmentManager {
|
||||
}
|
||||
if (version == 2) {
|
||||
int mtu = addr.getMTU();
|
||||
if (mtu > 0 && mtu < PeerState2.MIN_MTU) {
|
||||
boolean isIPv6 = TransportUtil.isIPv6(ra);
|
||||
int ourMTU = _transport.getMTU(isIPv6);
|
||||
if ((mtu > 0 && mtu < PeerState2.MIN_MTU) ||
|
||||
(ourMTU > 0 && ourMTU < PeerState2.MIN_MTU)) {
|
||||
if (ra.getTransportStyle().equals("SSU2")) {
|
||||
_transport.markUnreachable(toHash);
|
||||
_transport.failed(msg, "MTU too small");
|
||||
@@ -677,7 +680,12 @@ class EstablishmentManager {
|
||||
return;
|
||||
}
|
||||
|
||||
/**** TODO
|
||||
/****
|
||||
// A token request or session request with a bad token is
|
||||
// inexpensive to reply to.
|
||||
// A token can only be used once, so a replayed session request
|
||||
// will only generate a retry.
|
||||
// So probably don't need a replay detector at all
|
||||
if (_replayFilter.add(state.getReceivedX(), 0, 8)) {
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn("Duplicate X in session request from: " + from);
|
||||
|
||||
@@ -105,6 +105,10 @@ public class MTU {
|
||||
}
|
||||
if (isSSU2)
|
||||
return Math.min(mtu, PeerState2.MAX_MTU);
|
||||
// don't rectify 1280 down to 1276 because that
|
||||
// borks a shared SSU/SSU2 address
|
||||
if (mtu == PeerState2.MIN_MTU)
|
||||
return PeerState2.MIN_MTU;
|
||||
return rectify(isIPv6, mtu);
|
||||
} catch (SocketException se) {
|
||||
// ignore
|
||||
|
||||
@@ -2790,7 +2790,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
options.setProperty(UDPAddress.PROP_CAPACITY, caps);
|
||||
if (mtu != PeerState.LARGE_MTU && mtu > 0)
|
||||
options.setProperty(UDPAddress.PROP_MTU, Integer.toString(mtu));
|
||||
if (_enableSSU2)
|
||||
if (_enableSSU2 && (mtu >= PeerState2.MIN_MTU || mtu == 0))
|
||||
addSSU2Options(options);
|
||||
RouterAddress current = getCurrentAddress(false);
|
||||
RouterAddress addr = new RouterAddress(STYLE, options, SSU_OUTBOUND_COST);
|
||||
@@ -2882,7 +2882,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
else if (config == IPV6_NOT_PREFERRED)
|
||||
cost++;
|
||||
}
|
||||
if (_enableSSU2)
|
||||
if (_enableSSU2 && (mtu >= PeerState2.MIN_MTU || mtu == 0))
|
||||
addSSU2Options(options);
|
||||
RouterAddress addr = new RouterAddress(STYLE, options, cost);
|
||||
|
||||
@@ -2952,7 +2952,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
opts.setProperty(UDPAddress.PROP_CAPACITY, isIPv6 ? CAP_IPV6 : CAP_IPV4);
|
||||
if (mtu != PeerState.LARGE_MTU && mtu > 0)
|
||||
opts.setProperty(UDPAddress.PROP_MTU, Integer.toString(mtu));
|
||||
if (_enableSSU2)
|
||||
if (_enableSSU2 && (mtu >= PeerState2.MIN_MTU || mtu == 0))
|
||||
addSSU2Options(opts);
|
||||
RouterAddress addr = new RouterAddress(STYLE, opts, SSU_OUTBOUND_COST);
|
||||
RouterAddress current = getCurrentAddress(isIPv6);
|
||||
|
||||
Reference in New Issue
Block a user