Home All Groups Group Topic Archive Search About

Strange return value from GetIpForwardTable

Author
29 Aug 2006 8:28 PM
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

Author
30 Aug 2006 3:23 AM
Eugene Gershnik
Polaris wrote:
>
> 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.


Author
30 Aug 2006 7:23 AM
Arkady Frenkel
But "more data" is not error of insufficient  buffer,  but warning that you
can read additional set of data
Arkady

Show quoteHide quote
"Polaris" <etpola***@hotmail.com> wrote in message
news:OnsvEn6yGHA.1252@TK2MSFTNGP04.phx.gbl...
> 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
>
Author
30 Aug 2006 6:46 AM
Polaris
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

Show quoteHide quote
"Arkady Frenkel" <arka***@hotmailxdotx.com> wrote in message
news:eWMpe0$yGHA.3908@TK2MSFTNGP05.phx.gbl...
> But "more data" is not error of insufficient  buffer,  but warning that
> you can read additional set of data
> Arkady
>
> "Polaris" <etpola***@hotmail.com> wrote in message
> news:OnsvEn6yGHA.1252@TK2MSFTNGP04.phx.gbl...
>> 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
>>
>
>
Author
30 Aug 2006 7:15 AM
Eugene Gershnik
Polaris wrote:
> 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.


Author
30 Aug 2006 5:01 PM
Polaris
Thanks. The OS is Windows Xp with SP2.
Polaris

Show quoteHide quote
"Eugene Gershnik" <gersh***@hotmail.com> wrote in message
news:%2311LkQAzGHA.3704@TK2MSFTNGP02.phx.gbl...
> Polaris wrote:
>> 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.
>
>
> --
> Eugene
> http://www.gershnik.com
>
>
Author
30 Aug 2006 9:37 PM
Eugene Gershnik
Polaris wrote:
> 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.

Author
31 Aug 2006 6:31 AM
Polaris
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

Show quoteHide quote
"Eugene Gershnik" <gersh***@hotmail.com> wrote in message
news:u69Y2yHzGHA.3908@TK2MSFTNGP05.phx.gbl...
> Polaris wrote:
>> 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.
>
> --
> Eugene
> http://www.gershnik.com
>
>
>
>
Author
31 Aug 2006 12:01 PM
Arkady Frenkel
You can check additionally if table really change between calls with "route
print" in dos box
Arkady

Show quoteHide quote
"Polaris" <etpola***@hotmail.com> wrote in message
news:%23X4QXcMzGHA.3440@TK2MSFTNGP06.phx.gbl...
> 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
>
> "Eugene Gershnik" <gersh***@hotmail.com> wrote in message
> news:u69Y2yHzGHA.3908@TK2MSFTNGP05.phx.gbl...
>> Polaris wrote:
>>> 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.
>>
>> --
>> Eugene
>> http://www.gershnik.com
>>
>>
>>
>>
>
>