Skip to content

Commit ce5c75c

Browse files
committed
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
1 parent 67f1593 commit ce5c75c

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

router/java/src/net/i2p/router/transport/udp/UDPReceiver.java

+6-8
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@ public void run() {
248248
_socket.receive(dpacket);
249249
//}
250250
int size = dpacket.getLength();
251-
if (_log.shouldLog(Log.INFO))
252-
_log.info("After blocking socket.receive: packet is " + size + " bytes on " + System.identityHashCode(packet));
251+
//if (_log.shouldDebug())
252+
// _log.debug("After blocking socket.receive: packet is " + size + " bytes on " + System.identityHashCode(packet));
253253
packet.resetBegin();
254254

255255
// and block after we know how much we read but before
@@ -261,7 +261,7 @@ public void run() {
261261
if (_context.commSystem().isDummy()) {
262262
// testing
263263
packet.release();
264-
} else if (size > 0) {
264+
} else if (size >= SSU2Util.MIN_DATA_LEN) {
265265
//FIFOBandwidthLimiter.Request req = _context.bandwidthLimiter().requestInbound(size, "UDP receiver");
266266
//_context.bandwidthLimiter().requestInbound(req, size, "UDP receiver");
267267
FIFOBandwidthLimiter.Request req =
@@ -280,11 +280,9 @@ public void run() {
280280
receive(packet);
281281
//_context.statManager().addRateData("udp.receivePacketSize", size);
282282
} else {
283-
_context.statManager().addRateData("udp.receiveHolePunch", 1);
284-
// nat hole punch packets are 0 bytes
285-
if (_log.shouldLog(Log.INFO))
286-
_log.info("Received a 0 byte udp packet from " + dpacket.getAddress() + ":" + dpacket.getPort());
287-
_transport.getEstablisher().receiveHolePunch(dpacket.getAddress(), dpacket.getPort());
283+
// SSU1 had 0 byte hole punch, SSU2 does not
284+
if (_log.shouldWarn())
285+
_log.warn("Dropping short " + size + " byte udp packet from " + dpacket.getAddress() + ":" + dpacket.getPort());
288286
packet.release();
289287
}
290288
} catch (IOException ioe) {

0 commit comments

Comments
 (0)