Home/Support/Support Forum/Strange Behaviour After Dynamically Changing Gateway Address
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

Strange Behaviour After Dynamically Changing Gateway Address

0 votes
Hi All,

I have encountered a weird problem when trying to change the gateway address on the fly. Currently, the embedded application waits and listens for a telnet session and response to commands and closes the telnet session fine - everything has been working well for a few years. Now the client wants to be able to set a gateway so that UDP data can be redirected to other subnets through a gateway.

Researching the documentation, I figured out I needed to change the code to add the gateway address to an ifconfig() call when a command in the telnet session is received to change the gateway, namely:

ifconfig(IF_ETH0, IFS_DOWN, IFS_END); //shut down TCP
ifconfig(IF_ETH0, IFS_IPADDR, aton (tcpAddr),
IFS_NETMASK, aton(subnet),
IFS_ROUTER_SET, aton(gatewayAddr),
IFS_UP, IFS_END); //startup on new address

Obviously, after invoking the this, the telnet session drops which is expected and simply starting up a new telnet session will re-establish comms with the embedded application.

This seems to work AS LONG AS I change to a valid gateway address that's active on the network. But what I found during my testing is that when I change to an inactive/invalid gateway address, it will work as long as the inactive/invalid address is always the same one. In other words, if I toggle between the valid and invalid gateway addresses, everything will work as expected.

As soon as I change the invalid gateway address to something other than the first invalid address, I can no longer telnet to the embedded application. I will get a "connection refused" response and can no longer get a telnet connection until a reboot (not good). Monitoring the ethernet card traffic (using Wireshark), I see that the TCP stack of the embedded app is responding to the telnet session request (SYN) with a restart (RST).

I tried doing the same sequence but with the code to set the gateway (IFS_ROUTER_SET) commented out and I never lost the telnet access. So I'm suspecting it's something to do with changing gateway address on th fly but what's weird is if I stick to the same valid and same invalid address, it's all fine.

Anyone done or encountered anthing like this? Is there more I need to do than just bringing the net interface down, updating the ip, subnet and gateway info and bringing the interface back up? And why does it work if I use the same valid/invalid address pairs?

Any insight on this would be greatly appreciated.

BTW, I'm using Dynamic C 9.21 on a BL2600 board.

Thanks for your consideration.
asked Apr 17, 2011 in Rabbit by diginorml New to the Community (0 points)

Please log in or register to answer this question.