]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1170 in SNORT/snort3 from debug_network_inspectors to master
authorTom Peters (thopeter) <thopeter@cisco.com>
Fri, 30 Mar 2018 15:01:12 +0000 (11:01 -0400)
committerTom Peters (thopeter) <thopeter@cisco.com>
Fri, 30 Mar 2018 15:01:12 +0000 (11:01 -0400)
Squashed commit of the following:

commit 3ef1153be9fa332495bdb63df8146b2a77d77dc0
Author: Nihal Desai <nihdesai@cisco.com>
Date:   Thu Mar 29 12:46:00 2018 -0400

    Removing debug messages from reputation

src/main/snort_debug.h
src/network_inspectors/reputation/reputation_config.h
src/network_inspectors/reputation/reputation_inspect.cc
src/network_inspectors/reputation/reputation_parse.cc

index 8d9b706a15bceefbf03a9e70a864d34bf1c0f946..659521de45469d493619ca76dc151c2ce8a93cd6 100644 (file)
@@ -62,7 +62,6 @@
 #define DEBUG_STREAM_PAF      0x0000000800000000LL
 #define DEBUG_ASN1            0x0000002000000000LL
 #define DEBUG_SIP             0x0000100000000000LL
-#define DEBUG_REPUTATION      0x0000800000000000LL
 
 #define DEBUG_CODEC           0x0001000000000000LL
 #define DEBUG_INSPECTOR       0x0002000000000000LL
index f2d75b99d2f5bef70c6bc4f971e1497a63616302..cba49a0e5d0997df155bc0520e2134efe476259d 100644 (file)
@@ -21,7 +21,6 @@
 #define REPUTATION_CONFIG_H
 
 #include "framework/counts.h"
-#include "main/snort_debug.h"
 #include "main/thread.h"
 #include "sfrt/sfrt_flat.h"
 
@@ -85,8 +84,6 @@ struct IPrepInfo
     MEM_OFFSET next;
 };
 
-DEBUG_WRAP(void ReputationPrintRepInfo(IPrepInfo* repInfo, uint8_t* base); )
-
 struct ReputationStats
 {
     PegCount packets;
index b5ac7a9bf6dac9604b50f5691032762d7328361f..ce8e75f44063e2eb37919a2209f6cc24181d517c 100644 (file)
@@ -158,13 +158,10 @@ static inline IPrepInfo* ReputationLookup(ReputationConfig* config, const SfIp*
 {
     IPrepInfo* result;
 
-    DEBUG_WRAP( SfIpString ip_str; )
-    DebugFormat(DEBUG_REPUTATION, "Lookup address: %s \n", ip->ntop(ip_str));
     if (!config->scanlocal)
     {
         if (ip->is_private() )
         {
-            DEBUG_WRAP(DebugMessage(DEBUG_REPUTATION, "Private address\n"); );
             return nullptr;
         }
     }
index 29491a1c7467e14507ccc079a480c56dc37ca48e..7c35549ed568df10926c0ca6f3c42607b79e1d10 100644 (file)
@@ -240,11 +240,6 @@ static int64_t updateEntryInfo(INFO* current, INFO new_entry, SaveDest saveDest,
     }
     newIndex = lastInfo->listIndexes[i++];
 
-    DEBUG_WRAP(DebugMessage(DEBUG_REPUTATION, "Current IP reputation information: \n"); );
-    DEBUG_WRAP(ReputationPrintRepInfo(currentInfo, base); );
-    DEBUG_WRAP(DebugMessage(DEBUG_REPUTATION, "New IP reputation information: \n"); );
-    DEBUG_WRAP(ReputationPrintRepInfo(newInfo, base); );
-
     if (SAVE_TO_NEW == saveDest)
     {
         int bytesDuplicated;
@@ -281,8 +276,6 @@ static int64_t updateEntryInfo(INFO* current, INFO new_entry, SaveDest saveDest,
             break;
         else if (destInfo->listIndexes[i] == newIndex)
         {
-            DEBUG_WRAP(DebugMessage(DEBUG_REPUTATION, "Final IP reputation information: \n"); );
-            DEBUG_WRAP(ReputationPrintRepInfo(destInfo, base); );
             return bytesAllocated;
         }
     }
@@ -303,9 +296,6 @@ static int64_t updateEntryInfo(INFO* current, INFO new_entry, SaveDest saveDest,
         bytesAllocated += sizeof(IPrepInfo);
     }
 
-    DEBUG_WRAP(DebugMessage(DEBUG_REPUTATION, "Final IP reputation information: \n"); );
-    DEBUG_WRAP(ReputationPrintRepInfo(destInfo, base); );
-
     return bytesAllocated;
 }
 
@@ -319,20 +309,6 @@ static int AddIPtoList(snort::SfCidr* ipAddr,INFO ipInfo_ptr, ReputationConfig*
     uint32_t usageBeforeAdd;
     uint32_t usageAfterAdd;
 
-#ifdef DEBUG_MSGS
-    if (nullptr != sfrt_flat_lookup(ipAddr->get_addr(), config->iplist))
-    {
-        snort::SfIpString ip_str;
-        DebugFormat(DEBUG_REPUTATION, "Find address before insert: %s\n", ipAddr->ntop(ip_str) );
-    }
-    else
-    {
-        snort::SfIpString ip_str;
-        DebugFormat(DEBUG_REPUTATION,
-            "Can't find address before insert: %s\n", ipAddr->ntop(ip_str) );
-    }
-#endif
-
     usageBeforeAdd =  sfrt_flat_usage(config->iplist);
 
     /*Check whether the same or more generic address is already in the table*/
@@ -343,38 +319,18 @@ static int AddIPtoList(snort::SfCidr* ipAddr,INFO ipInfo_ptr, ReputationConfig*
 
     iRet = sfrt_flat_insert(ipAddr, (unsigned char)ipAddr->get_bits(), ipInfo_ptr, RT_FAVOR_ALL,
         config->iplist, &updateEntryInfo);
-    DEBUG_WRAP(DebugFormat(DEBUG_REPUTATION, "Unused memory: %zu \n",segment_unusedmem()); );
 
     if (RT_SUCCESS == iRet)
     {
-#ifdef DEBUG_MSGS
-        IPrepInfo* result;
-        DebugFormat(DEBUG_REPUTATION, "Number of entries input: %d, in table: %u \n",
-            totalNumEntries,sfrt_flat_num_entries(config->iplist) );
-        DebugFormat(DEBUG_REPUTATION, "Memory allocated: %u \n",sfrt_flat_usage(config->iplist) );
-        result = (IPrepInfo*)sfrt_flat_lookup(ipAddr->get_addr(), config->iplist);
-        if (nullptr != result)
-        {
-            snort::SfIpString ip_str;
-            DebugFormat(DEBUG_REPUTATION, "Find address after insert: %s \n", ipAddr->ntop(ip_str) );
-            DEBUG_WRAP(ReputationPrintRepInfo(result, (uint8_t*)config->iplist); );
-        }
-#endif
         totalNumEntries++;
     }
     else if (MEM_ALLOC_FAILURE == iRet)
     {
         iFinalRet = IP_MEM_ALLOC_FAILURE;
-        snort::SfIpString ip_str;
-        DEBUG_WRAP(DebugFormat(DEBUG_REPUTATION, "Insert error: %d for address: %s \n",iRet,
-            ipAddr->ntop(ip_str) ); );
     }
     else
     {
         iFinalRet = IP_INSERT_FAILURE;
-        snort::SfIpString ip_str;
-        DEBUG_WRAP(DebugFormat(DEBUG_REPUTATION, "Insert error: %d for address: %s \n",iRet,
-            ipAddr->ntop(ip_str) ); );
     }
 
     usageAfterAdd = sfrt_flat_usage(config->iplist);
@@ -664,8 +620,6 @@ void LoadListFile(char* filename, INFO info, ReputationConfig* config)
         int iRet;
         addrline++;
 
-        DEBUG_WRAP(DebugFormat(DEBUG_REPUTATION, "Reputation configurations: %s\n",linebuf); );
-
         // Remove comments
         if ( (cmt = strchr(linebuf, '#')) )
             *cmt = '\0';
@@ -674,8 +628,6 @@ void LoadListFile(char* filename, INFO info, ReputationConfig* config)
         if ( (cmt = strchr(linebuf, '\n')) )
             *cmt = '\0';
 
-        DEBUG_WRAP(DebugFormat(DEBUG_REPUTATION, "Reputation configurations: %s\n",linebuf); );
-
         /* process the line */
         iRet = ProcessLine(linebuf, ipInfo_ptr, config);
 
@@ -786,63 +738,4 @@ void EstimateNumEntries(ReputationConfig* config)
     config->numEntries = totalLines;
 }
 
-#ifdef DEBUG_MSGS
-static void ReputationRepInfo(IPrepInfo* repInfo, uint8_t* base, char* repInfoBuff,
-    int bufLen)
-{
-    char* index = repInfoBuff;
-    int len = bufLen -1;
-    int writed;
-
-    writed = snprintf(index, len, "Reputation Info: ");
-    if (writed >= len || writed < 0)
-        return;
-
-    index += writed;
-    len -= writed;
-
-    while (repInfo)
-    {
-        int i;
-        for (i = 0; i < NUM_INDEX_PER_ENTRY; i++)
-        {
-            writed = snprintf(index, len, "%d,",repInfo->listIndexes[i]);
-            if (writed >= len || writed < 0)
-                return;
-            else
-            {
-                index += writed;
-                len -=writed;
-            }
-        }
-        writed = snprintf(index, len, "->");
-        if (writed >= len || writed < 0)
-            return;
-        else
-        {
-            index += writed;
-            len -=writed;
-        }
-
-        if (!repInfo->next)
-            break;
-
-        repInfo = (IPrepInfo*)(&base[repInfo->next]);
-    }
-}
-
-void ReputationPrintRepInfo(IPrepInfo* repInfo, uint8_t* base)
-{
-    char repInfoBuff[STD_BUF];
-    int len = STD_BUF -1;
-
-    repInfoBuff[STD_BUF -1] = '\0';
-
-    ReputationRepInfo(repInfo, base, repInfoBuff, len);
-
-    DEBUG_WRAP(DebugFormat(DEBUG_REPUTATION, "Reputation Info: %s \n",
-        repInfoBuff); );
-}
-
-#endif