EmbeddedRelated.com
Forums

Issue with ifconfig() before sock_init()?

Started by Jerry May 4, 2005
Hi all,

Using Dynamic C v9.21, I've had an intermittent issue calling
ifconfig() before sock_init(). I'm using "TCPCONFIG 6" and doing all
configuration at runtime. I've found that if I attempt to use
"IFS_ROUTER_SET" in ifconfig() before sock_init(), my RCM3700
sometimes locks up upon power-up.

I traced this to a problem that occurs in the ARP library when the
library starts using globals defined in ARP.lib such as the
_arp_data[] array. It appears that these globals are only initialized
in _arp_init(), which is only called from sock_init(). So it seems
that, if you don't call sock_init() before using ifconfig() with a
parameter that causes ifconfig() to make ARP calls, the ARP library
may work with un-initialized globals. _arp_init() sets all of the
globals to zero, and the problem only happens intermittently, so I'm
wondering if RAM usually comes up as zero, but sometimes doesn't (I
always assumed it doesn't get zeroed). When it doesn't, the ARP
library thinks there are valid entries and tries to traverse the
entries. Specifically, I've found that the ARP library gets to the
call _arp_unlink_to(), which locks up in a while loop while attempting
to search a bogus linked list.

My assumed cause might be wrong, as the BIOS may zero RAM...I haven't
checked. In any case, I've solved my problem by restructuring my code
to call sock_init() before using ifconfig(). But I was wondering if
the RAM idea seems plausible, or if there are some known ifconfig()
parameters you're not supposed to use before sock_init(). I couldn't
find anything in the documentation regarding this, and I noticed that
some of the samples (e.g. dhcp.c) call ifconfig() before sock_init(),
but don't use "IFS_ROUTER_SET".

--Jerry


We saw the problem with trying to use IFS_ROUTER_SET in ifconfig
before sock_init in DC 8.61. Tony at zworld said that you shouldn't
ever use ifconfig before sock_init, and I never pushed it any farther
(although, as you pointed out, there is sample code that calls
ifconfig before sock_init).

I rewrote the code to call sock_init first, and have been working fine
for 6 months.

The bios does not zero ram. We only had our problem from a cold
powerup, although it always happened then. If we just reset the board,
the problem did not occur.

Joe

On 5/4/05, Jerry <jerry@jerr...> wrote:
> Hi all,
>
> Using Dynamic C v9.21, I've had an intermittent issue calling
> ifconfig() before sock_init(). I'm using "TCPCONFIG 6" and doing all
> configuration at runtime. I've found that if I attempt to use
> "IFS_ROUTER_SET" in ifconfig() before sock_init(), my RCM3700
> sometimes locks up upon power-up.
>
> I traced this to a problem that occurs in the ARP library when the
> library starts using globals defined in ARP.lib such as the
> _arp_data[] array. It appears that these globals are only initialized
> in _arp_init(), which is only called from sock_init(). So it seems
> that, if you don't call sock_init() before using ifconfig() with a
> parameter that causes ifconfig() to make ARP calls, the ARP library
> may work with un-initialized globals. _arp_init() sets all of the
> globals to zero, and the problem only happens intermittently, so I'm
> wondering if RAM usually comes up as zero, but sometimes doesn't (I
> always assumed it doesn't get zeroed). When it doesn't, the ARP
> library thinks there are valid entries and tries to traverse the
> entries. Specifically, I've found that the ARP library gets to the
> call _arp_unlink_to(), which locks up in a while loop while attempting
> to search a bogus linked list.
>
> My assumed cause might be wrong, as the BIOS may zero RAM...I haven't
> checked. In any case, I've solved my problem by restructuring my code
> to call sock_init() before using ifconfig(). But I was wondering if
> the RAM idea seems plausible, or if there are some known ifconfig()
> parameters you're not supposed to use before sock_init(). I couldn't
> find anything in the documentation regarding this, and I noticed that
> some of the samples (e.g. dhcp.c) call ifconfig() before sock_init(),
> but don't use "IFS_ROUTER_SET".
>
> --Jerry >
> ________________________________
> Yahoo! Groups Links > To