Strange return value from GetIpForwardTable

  • Thread starter Thread starter Polaris
  • Start date Start date
P

Polaris

Hi Experts:

I have a question about GetIpForwardTable():

I use the call below to get the required table size first:

ULONG dwSize = 0;
DWORD ret = GetIpForwardTable (NULL, &dwSize, TRUE);

The return value is ERROR_INSUFFICIENT_BUFFER as expected, the dwSize looks
fine.

Then I call it again to get the actual table:

MIB_IPFORWARDTABLE *pTable = (PMIB_IPFORWARDTABLE) malloc (dwSize);
ret = GetIpForwardTable (pTable, &dwSize, TRUE);

But the 2nd call above returns 234 (More data is available).

Just wondering, the first call returned the required table size already, why
the 2nd call indicate that the dwSize is too small?

Thanks in advance !
Polaris
 
Polaris said:
But the 2nd call above returns 234 (More data is available).

Just wondering, the first call returned the required table size
already, why the 2nd call indicate that the dwSize is too small?

What OS are you doing this on?

Note that in general you need to call this API in a loop since the table
size may change between any two calls. I doubt this is the problem you
have, though.
 
Thanks guys for your responses.

I think "More data .." means the buffer is not big enough to store the whole
routing table; if the first call to GetIpForwardTable returns the size
required to hold the routing table, the immediate following call should
retrieve the complete routing table. Is that correct?

Polaris
 
Polaris said:
Thanks guys for your responses.

I think "More data .." means the buffer is not big enough to store
the whole routing table; if the first call to GetIpForwardTable
returns the size required to hold the routing table, the immediate
following call should retrieve the complete routing table. Is that
correct?

No. Another process may have changed the table between your two calls.
However, I doubt this is the reason for the issue you are seeing. I vaguely
recall some buffer size issues with IPHelper on older OSes and that's why I
asked which OS your using.
 
But "more data" is not error of insufficient buffer, but warning that you
can read additional set of data
Arkady
 
Thanks. The OS is Windows Xp with SP2.
Polaris

Eugene Gershnik said:
No. Another process may have changed the table between your two calls.
However, I doubt this is the reason for the issue you are seeing. I
vaguely recall some buffer size issues with IPHelper on older OSes and
that's why I asked which OS your using.
 
Polaris said:
Thanks. The OS is Windows Xp with SP2.

Then it is really strange (assuming no other process/thread changes the
table in the middle). I don't recall any problems with this OS. If you have
a short repro code post it here and if others can get the same problem you
probably should file a bug with MS.
 
Thanks. I did send a feedback to MS.

This problem went away (meaning the GetIpForwardTable returns NO_ERROR)
after doubling the buffer size. But still, it is kind of strange.

Polaris
 
You can check additionally if table really change between calls with "route
print" in dos box
Arkady
 
Back
Top