Yes, those both 'feel' wrong.  The netFlow device can get any index number -
if you run -i none, it could be zero, or it could be any other number
depending upon what interfaces DO exist (including aliases) and whether
other virtuals (sFlow) exist or not.  So ANY dependence upon the value of
the index is a BAD practice.

If you look in setNetFlowInSocket() you'll see another call to
setNetFlowInterfaceMatrix(), which is conditional on
myGlobals.netFlowDeviceId == -1 (i.e. never having started netFlow).

I think what you need to do is at the beginning of that URL processing
piece, store the values of myGlobals.netFlowDeviceId,
myGlobals.netFlowIfAddress.s_addr and myGlobals.netFlowIfMask.s_addr.  Then
in the loop where you set the new values don't make the free/set call, just
update the prefs.

At the bottom of the url processing, after you've process all the parameters
test if the settings truly are new:

  Do the free only if you already HAD an active netFlow device
(oldNetFlowDeviceId != -1)
  Do the set - but this time the index will be properly valued.

-----Burton



> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf
> Of Markus Rehbach
> Sent: Sunday, February 29, 2004 11:30 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [Ntop-dev] Duplicated name entries in the eth0 host lists
> (orig. from eth0 and NerFlow-Device)
>
>
> Below 2 patches which will solve my problem, but I'm not sure
> about evil consequences.
>
> The following was my first try, but nobody knows whether the
> NetFlow device will get the device index 1, or?
>
> --- netflowPlugin.c.old 2004-02-29 16:23:19.000000000 +0100
> +++ netflowPlugin.c     2004-02-29 18:12:22.479901113 +0100
> @@ -280,11 +280,11 @@
>
>  /* ************************************************** */
>
>  static void setNetFlowInterfaceMatrix() {
>    if((!myGlobals.device[myGlobals.netFlowDeviceId].activeDevice)
> -     || (myGlobals.netFlowDeviceId == -1))
> +     || (myGlobals.netFlowDeviceId == -1) ||
> (myGlobals.netFlowDeviceId == 0))
>      return;
>
>    myGlobals.device[myGlobals.netFlowDeviceId].numHosts       =
> 0xFFFFFFFF - myGlobals.netFlowIfMask.s_addr+1;
>    myGlobals.device[myGlobals.netFlowDeviceId].ifAddr.s_addr  =
> myGlobals.netFlowIfAddress.s_addr;
>    myGlobals.device[myGlobals.netFlowDeviceId].network.s_addr =
> myGlobals.netFlowIfAddress.s_addr;
>
>
> BUT: The real problem seems to be the calls from handleNetflowHTTPrequest.
> Filling in values in the plugin configuration dialog, never started the
> plugin before and pressing the set button will generate a call to
> setNetFlowInterfaceMatrix with actualDeviceId=0, which unfortunately
> is my eth0. The patch below will avoid this, but what's about a started
> NetFlow Device which will be reconfigured while running?
>
> @@ -2526,18 +2541,16 @@
>         if(sscanf(value, "%d.%d.%d.%d/%d.%d.%d.%d",
>                   &a, &b, &c, &d, &a1, &b1, &c1, &d1) == 8) {
>           myGlobals.netFlowIfAddress.s_addr =(a << 24) +(b << 16)
> +(c << 8) + d;
>           myGlobals.netFlowIfMask.s_addr    =(a1 << 24) +(b1 <<
> 16) +(c1 << 8) + d1;
>           storePrefsValue("netFlow.ifNetMask", value);
> -         freeNetFlowMatrixMemory(); setNetFlowInterfaceMatrix();
>         } else if(sscanf(value, "%d.%d.%d.%d/%d",
>                          &a, &b, &c, &d, &a1) == 5) {
>           myGlobals.netFlowIfAddress.s_addr = (a << 24) +(b <<
> 16) +(c << 8) + d;
>           myGlobals.netFlowIfMask.s_addr    = 0xffffffff >> a1;
>           myGlobals.netFlowIfMask.s_addr =~
> myGlobals.netFlowIfMask.s_addr;
>           storePrefsValue("netFlow.ifNetMask", value);
> -         freeNetFlowMatrixMemory(); setNetFlowInterfaceMatrix();
>         } else
>           traceEvent(CONST_TRACE_ERROR, "NETFLOW: HTTP request
> netmask parse error (%s)", value);
>        } else if(strcmp(device, "whiteList") == 0) {
>         /* Cleanup the http control char xform */
>         char *fPtr=value, *tPtr=value;
>
> Cheers
>
> Markus
>
>
>
>
>
> On Saturday 28 February 2004 13:51, Burton M. Strauss III wrote:
> > I'm going to update things so that the <!-- --> entries are generated if
> > you use the -K flag too.  That way we can see what's really going on.
> >
> > -----Burton
> >
> > > -----Original Message-----
> > > From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf
> > > Of Markus Rehbach
> > > Sent: Saturday, February 28, 2004 1:50 AM
> > > To: [EMAIL PROTECTED]
> > > Subject: Re: [Ntop-dev] Duplicated name entries in the eth0 host lists
> > > (orig. from eth0 and NerFlow-Device)
> > >
> > >
> > > It was a fresh cv pull from 27.07 20:00 GMT I tried. The reports are
> > > 'Summary, Hosts', 'IP Summary, Trafic' and 'All Protocols,
> Traffic' (hope
> > > these are all).
> > >
> > > Will investigate a litte bit further, I think in 3.0pre1 the
> > > behaviour was
> > > different.
> > >
> > > Markus
> > >
> > > _____________________________
> > >
> > > On Saturday 28 February 2004 00:29, Burton M. Strauss III wrote:
> > > > Well, there are some places where there is a foreach device
> loop, but
> > > > within a single device those should be totally separate - the
> > >
> > > data from the
> > >
> > > > two interfaces should not be commingled.  Which report is this?
> > > >
> > > > If they were deleted, then they were purged as inactive, but I
> > >
> > > fail to see
> > >
> > > > why they would be there at all.  There was a fix in the cvs
> a couple of
> > > > days ago, where one of the transitions wasn't being done, so
> > >
> > > items could be
> > >
> > > > duplicated.  Maybe try a fresh pull of the cvs...
> > > >
> > > > -----Burton
> > > >
> > > > > -----Original Message-----
> > > > > From: [EMAIL PROTECTED]
> > >
> > > [mailto:[EMAIL PROTECTED] Behalf
> > >
> > > > > Of Markus Rehbach
> > > > > Sent: Friday, February 27, 2004 5:03 PM
> > > > > To: [EMAIL PROTECTED]
> > > > > Subject: Re: [Ntop-dev] Duplicated name entries in the eth0 host
> > > > > lists (orig. from eth0 and NerFlow-Device)
> > > > >
> > > > >
> > > > > Ok, for my understanding:
> > > > >
> > > > > It is right looking at the eth0 interface to have the name
> > > > > resolutions entries
> > > > > for the NetFlow-Interface, too (2 hosts, 4 entries, 2 without MAC
> > > > > wich are
> > > > > 'borrowed' on eth0 from the NetFlow-Interface)?
> > > > >
> > > > > You are right the -o will avoid the duplicated entries.
> > >
> > > Perfect that way.
> > >
> > > > > Markus
> > >
> > > _______________________________________________
> > > Ntop-dev mailing list
> > > [EMAIL PROTECTED]
> > > http://listgateway.unipi.it/mailman/listinfo/ntop-dev
> >
> > _______________________________________________
> > Ntop-dev mailing list
> > [EMAIL PROTECTED]
> > http://listgateway.unipi.it/mailman/listinfo/ntop-dev
>
> _______________________________________________
> Ntop-dev mailing list
> [EMAIL PROTECTED]
> http://listgateway.unipi.it/mailman/listinfo/ntop-dev
>

_______________________________________________
Ntop-dev mailing list
[EMAIL PROTECTED]
http://listgateway.unipi.it/mailman/listinfo/ntop-dev

Reply via email to