From ce5c75cb61c4796754d4517224bb1c2efc7496dc Mon Sep 17 00:00:00 2001 From: zzz Date: Wed, 17 Jan 2024 08:03:16 -0500 Subject: [PATCH] SSU2: Drop small packets in UDPReceiver now that SSU1 is disabled. SSU2 min packet size is 40 and does not support 0-byte hole punch --- .../net/i2p/router/transport/udp/UDPReceiver.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/router/java/src/net/i2p/router/transport/udp/UDPReceiver.java b/router/java/src/net/i2p/router/transport/udp/UDPReceiver.java index cae3030f2e..9d35c83e71 100644 --- a/router/java/src/net/i2p/router/transport/udp/UDPReceiver.java +++ b/router/java/src/net/i2p/router/transport/udp/UDPReceiver.java @@ -248,8 +248,8 @@ public void run() { _socket.receive(dpacket); //} int size = dpacket.getLength(); - if (_log.shouldLog(Log.INFO)) - _log.info("After blocking socket.receive: packet is " + size + " bytes on " + System.identityHashCode(packet)); + //if (_log.shouldDebug()) + // _log.debug("After blocking socket.receive: packet is " + size + " bytes on " + System.identityHashCode(packet)); packet.resetBegin(); // and block after we know how much we read but before @@ -261,7 +261,7 @@ public void run() { if (_context.commSystem().isDummy()) { // testing packet.release(); - } else if (size > 0) { + } else if (size >= SSU2Util.MIN_DATA_LEN) { //FIFOBandwidthLimiter.Request req = _context.bandwidthLimiter().requestInbound(size, "UDP receiver"); //_context.bandwidthLimiter().requestInbound(req, size, "UDP receiver"); FIFOBandwidthLimiter.Request req = @@ -280,11 +280,9 @@ public void run() { receive(packet); //_context.statManager().addRateData("udp.receivePacketSize", size); } else { - _context.statManager().addRateData("udp.receiveHolePunch", 1); - // nat hole punch packets are 0 bytes - if (_log.shouldLog(Log.INFO)) - _log.info("Received a 0 byte udp packet from " + dpacket.getAddress() + ":" + dpacket.getPort()); - _transport.getEstablisher().receiveHolePunch(dpacket.getAddress(), dpacket.getPort()); + // SSU1 had 0 byte hole punch, SSU2 does not + if (_log.shouldWarn()) + _log.warn("Dropping short " + size + " byte udp packet from " + dpacket.getAddress() + ":" + dpacket.getPort()); packet.release(); } } catch (IOException ioe) {