Hi There,
I'm currently migrating from MQX 4.1 to MQX 4.2
- my system is initialized by ipcfg_dhcp_wait() once from inittask
- after that, I'm running ipcfg_task_poll() continuously ever 250 ms, like that
uint8_t link = ipcfg_get_link_active(ENET_DEVICE);
uint8_t ipcfg_state = ipcfg_get_state(ENET_DEVICE);
ipcfg_task_poll();
epc_dbg("ipcfg_get_link_active(%d) ipcfg_get_state(%d='%s')\n",
link,
ipcfg_state, ipcfg_get_state_string(ipcfg_state));
in MQX v4.1 everything is OK: when unplugging the ethernet link the state dropped down from 6='DHCP' to 1='UNBOUND'
After plugging the ethernet link it comes back to 6='DHCP', by passing 2='BUSY', just like this:
EPC-> ipcfg_get_link_active(1) ipcfg_get_state(6='DHCP')
EPC-> ipcfg_get_link_active(1) ipcfg_get_state(6='DHCP')
EPC-> ipcfg_get_link_active(0) ipcfg_get_state(6='DHCP')
RTCS-> eth0 link down
EPC-> ipcfg_get_link_active(0) ipcfg_get_state(1='UNBOUND')
EPC-> sec handler 3, 8.58s eth(0)
EPC-> ipcfg_get_link_active(0) ipcfg_get_state(1='UNBOUND')
EPC-> ipcfg_get_link_active(0) ipcfg_get_state(1='UNBOUND')
EPC-> ipcfg_get_link_active(0) ipcfg_get_state(1='UNBOUND')
EPC-> ipcfg_get_link_active(0) ipcfg_get_state(1='UNBOUND')
EPC-> sec handler 3, 9.58s eth(0)
EPC-> ipcfg_get_link_active(0) ipcfg_get_state(1='UNBOUND')
EPC-> ipcfg_get_link_active(0) ipcfg_get_state(1='UNBOUND')
EPC-> ipcfg_get_link_active(0) ipcfg_get_state(1='UNBOUND')
EPC-> ipcfg_get_link_active(0) ipcfg_get_state(1='UNBOUND')
EPC-> sec handler 3, 10.58s eth(0)
EPC-> ipcfg_get_link_active(0) ipcfg_get_state(1='UNBOUND')
EPC-> ipcfg_get_link_active(1) ipcfg_get_state(1='UNBOUND')
RTCS-> eth0 link up
EPC-> ipcfg_get_link_active(1) ipcfg_get_state(2='BUSY')
EPC-> ipcfg_get_link_active(1) ipcfg_get_state(6='DHCP')
RTCS-> IP Address : 192.168.3.38
RTCS-> Subnet Address : 255.255.240.0
RTCS-> Gateway Address : 192.168.1.3
RTCS-> DNS Address : 192.168.1.5
With MQX 4.2, it simply stays in 6='DHCP' after ethernet is disconnected, no DHCP requests are send after re-plugging the cable.
Maybe this is due to the removal of unbinding the the device in ipcfg_task_poll().
ipcfg.c now says:
#if 0 /* It is done automatically inside ipcfg_bind_xxx().
* Also it caused wrong behavior for devices that have wrong link detection,
* and there was no possibility to get IP parameters when cable is disconnected.*/
else if ((! link) && (actual_state != IPCFG_STATE_UNBOUND))
{
// link is down, unbind any interface
ipcfg_unbind_internal (i);
}
#endif
Issue no 2 is: I'm loosing IP connection when the DHCP lease time is expired, there is to rebinding process after half lease time anymore.
Maybe these 2 issues are connected to each other.
However, running ipcfg_dhcp_wait() intially and then running ipcfg_task_poll() continuously isn't like it was before...
I hope I can find out more tomorrow, but maybe someone already can give a me clue?
cheers, Martin
解決済! 解決策の投稿を見る。
issue no 1 fixed:
enabling the "#if 0" section mentioned aboved helped with that, and no more crashes after fix issue no 2 applied.
But, I do not enable this, instead I'm unbinding for myself when link-down is detected and DHCP is desired.
When Link comes up again, I'm calling another ipcfg_bind_dhcp()
so, everything mint again...
Hi Martin,
thank you for sharing your solutions. This willl be reported to MQX development team.
Regards,
Carlos
issue no 1 fixed:
enabling the "#if 0" section mentioned aboved helped with that, and no more crashes after fix issue no 2 applied.
But, I do not enable this, instead I'm unbinding for myself when link-down is detected and DHCP is desired.
When Link comes up again, I'm calling another ipcfg_bind_dhcp()
so, everything mint again...
issue no 2 fixed (rtcs threat crashes on DHCP renewals):
--- a/MQX/rtcs/source/tcpip/dhcpclnt.c
+++ b/MQX/rtcs/source/tcpip/dhcpclnt.c
@@ -1773,7 +1773,7 @@ static uint32_t DHCP_send_internal
/* initialize sockaddr for use with UDP_send_internal */
fromaddr.sa_family = AF_INET;
- toaddr.sa_family = AF_INET6;
+ toaddr.sa_family = AF_INET;
SOCKADDR_init((void*)srcaddr, 0, &fromaddr);
SOCKADDR_init((void*)destaddr, destport, &toaddr);