[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ntop-dev
Subject:    [Ntop-dev] Patch for the eth0:0 (hme0:0) problem
From:       "Burton M. Strauss III" <Burton () ntopsupport ! com>
Date:       2003-09-16 22:44:07
Message-ID: JIEPJGFPFMFIGBNCPKGGMEPLEFAA.Burton () ntopsupport ! com
[Download RAW message or body]

Luca:

The attached patch fixes the basic problem with ntop and virtual (alias)
interfaces.

If you've followed the thread, there's a visible problem and an underlying
problem.

The visual problem is that if you start ntop on an interface that has
aliases (virtual) interfaces, it says:

Listening on [eth0,eth0]

in the log.  The patch changes that to

Listening on [eth0,eth0:0]

which is better and more accurate.

The underlying problem is that the virtual device isn't marked as such, so
the plugin loader attempts to set a pcap filter on it and blows up.

However - this type of patch often has far reaching implications, so I'm
sending it to you for review rather than just applying it.  Especially as
I'll be OOO for two weeks.


-----Burton

["BMS0377-virtualdevices.patch" (application/octet-stream)]

--- ntop/initialize.c 2003-09-16 11:44:12.000000000 -0500
+++ ntop/initialize.c 2003-09-16 17:04:15.000000000 -0500
@@ -1276,9 +1276,11 @@
     struct in_addr myLocalHostAddress;
 
     if(myGlobals.numDevices < MAX_NUM_DEVICES) {
+      traceEvent(CONST_TRACE_INFO, "Checking %s for additional devices", \
myGlobals.device[deviceId].name);  for(k=0; k<8; k++) {
 	if(snprintf(tmpDeviceName, sizeof(tmpDeviceName), "%s:%d", \
myGlobals.device[deviceId].name, k) < 0)  BufferTooShort();
+	traceEvent(CONST_TRACE_NOISY, "Checking %s", tmpDeviceName);
 	if(getLocalHostAddress(&myLocalHostAddress, tmpDeviceName) == 0) {
 	  /* The virtual interface exists */
 
@@ -1292,9 +1294,11 @@
 	  myGlobals.device[myGlobals.numDevices].ifAddr.s_addr = myLocalHostAddress.s_addr;
 	  if(myLocalHostAddress.s_addr == myGlobals.device[deviceId].ifAddr.s_addr)
 	    continue; /* No virtual Interfaces */
-	  myGlobals.device[myGlobals.numDevices].humanFriendlyName = strdup(deviceDescr);
+	  myGlobals.device[myGlobals.numDevices].virtualDevice = 1;
+	  myGlobals.device[myGlobals.numDevices].activeDevice = 1;
+	  myGlobals.device[myGlobals.numDevices].humanFriendlyName = strdup(tmpDeviceName);
 	  myGlobals.device[myGlobals.numDevices++].name = strdup(deviceName);
-	  traceEvent(CONST_TRACE_INFO, "Added: %s", deviceName);
+	  traceEvent(CONST_TRACE_INFO, "Added virtual interface: '%s'", tmpDeviceName);
 	} else
 	  break; /* No virtual interface */
       }
@@ -1412,6 +1416,7 @@
       traceEvent(CONST_TRACE_FATALERROR, "Unable to locate default interface (%s)", \
ebuf);  exit(-1);
     }
+    traceEvent(CONST_TRACE_NOISY, "Default device is '%s'", tmpDev);
 
     tmpDescr = tmpDev;
 #endif
--- ntop/main.c 2003-09-05 11:23:29.000000000 -0500
+++ ntop/main.c 2003-09-16 16:30:03.000000000 -0500
@@ -1125,10 +1125,16 @@
       char tmpBuf[64];
 
       if(i>0) {
-	if(snprintf(tmpBuf, sizeof(tmpBuf), ",%s", myGlobals.device[i].name)  < 0)
+	if(snprintf(tmpBuf, sizeof(tmpBuf), ",%s", 
+                    myGlobals.device[i].humanFriendlyName != NULL ? 
+                      myGlobals.device[i].humanFriendlyName :
+                      myGlobals.device[i].name)  < 0)
 	  BufferTooShort();
       } else {
-	if(snprintf(tmpBuf, sizeof(tmpBuf), "%s", myGlobals.device[i].name) < 0)
+	if(snprintf(tmpBuf, sizeof(tmpBuf), "%s",
+                    myGlobals.device[i].humanFriendlyName != NULL ? 
+                      myGlobals.device[i].humanFriendlyName :
+                      myGlobals.device[i].name)  < 0)
 	  BufferTooShort();
       }
 



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic