diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index de2f9d4e17..553250c851 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -106,6 +106,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP
stat => stat.Value = m_udpServer.IncomingPacketsProcessed,
StatVerbosity.Debug));
+ StatsManager.RegisterStat(
+ new Stat(
+ "IncomingPacketsMalformedCount",
+ "Number of inbound UDP packets that could not be recognized as LL protocol packets.",
+ "",
+ "",
+ "clientstack",
+ scene.Name,
+ StatType.Pull,
+ MeasuresOfInterest.AverageChangeOverTime,
+ stat => stat.Value = m_udpServer.IncomingMalformedPacketCount,
+ StatVerbosity.Info));
+
StatsManager.RegisterStat(
new Stat(
"OutgoingUDPSendsCount",
@@ -268,7 +281,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public Socket Server { get { return null; } }
- private int m_malformedCount = 0; // Guard against a spamming attack
+ ///
+ /// Record how many inbound packets could not be recognized as LLUDP packets.
+ ///
+ public int IncomingMalformedPacketCount { get; private set; }
///
/// Record current outgoing client for monitoring purposes.
@@ -1181,6 +1197,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP
outgoingPacket.TickCount = Environment.TickCount & Int32.MaxValue;
}
+ private void RecordMalformedInboundPacket(IPEndPoint endPoint)
+ {
+// if (m_malformedCount < 100)
+// m_log.DebugFormat("[LLUDPSERVER]: Dropped malformed packet: " + e.ToString());
+
+ IncomingMalformedPacketCount++;
+
+ if ((IncomingMalformedPacketCount % 10000) == 0)
+ m_log.WarnFormat(
+ "[LLUDPSERVER]: Received {0} malformed packets so far, probable network attack. Last malformed was from {1}",
+ IncomingMalformedPacketCount, endPoint);
+ }
+
public override void PacketReceived(UDPPacketBuffer buffer)
{
// Debugging/Profiling
@@ -1202,6 +1231,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// "[LLUDPSERVER]: Dropping undersized packet with {0} bytes received from {1} in {2}",
// buffer.DataLength, buffer.RemoteEndPoint, m_scene.RegionInfo.RegionName);
+ RecordMalformedInboundPacket(endPoint);
+
return; // Drop undersized packet
}
@@ -1220,6 +1251,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// "[LLUDPSERVER]: Dropping packet with malformed header received from {0} in {1}",
// buffer.RemoteEndPoint, m_scene.RegionInfo.RegionName);
+ RecordMalformedInboundPacket(endPoint);
+
return; // Malformed header
}
@@ -1235,34 +1268,24 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// Only allocate a buffer for zerodecoding if the packet is zerocoded
((buffer.Data[0] & Helpers.MSG_ZEROCODED) != 0) ? new byte[4096] : null);
}
- catch (MalformedDataException)
- {
- }
- catch (IndexOutOfRangeException)
- {
-// m_log.WarnFormat(
-// "[LLUDPSERVER]: Dropping short packet received from {0} in {1}",
-// buffer.RemoteEndPoint, m_scene.RegionInfo.RegionName);
-
- return; // Drop short packet
- }
catch (Exception e)
{
- if (m_malformedCount < 100)
+ if (IncomingMalformedPacketCount < 100)
m_log.DebugFormat("[LLUDPSERVER]: Dropped malformed packet: " + e.ToString());
-
- m_malformedCount++;
-
- if ((m_malformedCount % 100000) == 0)
- m_log.DebugFormat("[LLUDPSERVER]: Received {0} malformed packets so far, probable network attack.", m_malformedCount);
}
// Fail-safe check
if (packet == null)
{
- m_log.ErrorFormat("[LLUDPSERVER]: Malformed data, cannot parse {0} byte packet from {1}:",
- buffer.DataLength, buffer.RemoteEndPoint);
- m_log.Error(Utils.BytesToHexString(buffer.Data, buffer.DataLength, null));
+ if (IncomingMalformedPacketCount < 100)
+ {
+ m_log.ErrorFormat("[LLUDPSERVER]: Malformed data, cannot parse {0} byte packet from {1}:",
+ buffer.DataLength, buffer.RemoteEndPoint);
+ m_log.Error(Utils.BytesToHexString(buffer.Data, buffer.DataLength, null));
+ }
+
+ RecordMalformedInboundPacket(endPoint);
+
return;
}