netxduo
netxduo copied to clipboard
IPv6 SLAAC enabling
Hi,
I am trying to enable the IPV6 SLAAC for NetX 5.7 stack. What i observed is that the APIs to support SLAAC is present in stack but neither the feature is enabled nor any notification is sent to the host when SLAAC is successful. I have done the following code changes to enable complete SLAAC flow and tested to be working fine.
- To enable SLAAC called the _nxd_ipv6_stateless_address_autoconfig_enable() api within nxd_interface_address_set() api which is called when host tries to configure ip for interface either by DHCP/static.
- Registered the _nx_dhcpv6_ipv6_address_DAD_notify() api as callback handler for DAD success in _nx_dhcpv6_client_create() api.
- Inside nx_icmpv6_perform_DAD() once DAD is successful and host is notified about this, call the nx_dhcpv6_request_inform_request() api to send INFORMATION_REQUEST DHCPv6 msg to ask the DNS server address with DHCP server. (This was not present)
- When DNS server responds back with information response with DNS server name in it, copy it to the DNS server names data structures(array) in netx by adding new api in netx_wrappers.c which internally calls nxd_dns_server_add() to do this (this was not present)
After these changes SLAAC works fine, also DNS query works fine. This is for 5.7 stack. My question is do these changes looks fine? Or was there already an alternate way to enable all these things to happen which i missed?
@RishaHolla , as long as IPv6/ICMPv6 is enabled, SLAAC is enabled by default. The API nxd_ipv6_stateless_address_autoconfig_enable is needed only if nxd_ipv6_stateless_address_autoconfig_disable is called. The perquisition of SLAAC is that at least one IPv6 link local address must be configured. You can refer to this line to set the link local address.
BTW, it is highly recommended to upgrade to latest version 6.1.11.
@TiejunMS I understand that SLAAC needs to be enabled by default in the stack, but for it to be enabled the below variable needs to be set like this. ip_ptr -> nx_ip_interface[interface_index].nx_ipv6_stateless_address_autoconfig_status = NX_STATELESS_ADDRESS_AUTOCONFIG_ENABLED; But i do not see this variable set anywhere in 5.7 or 6.1.6 stack by default. This will be set only if we call nxd_ipv6_stateless_address_autoconfig_enable() api which isnt called by default anywhere as well. Inside _nxd_ipv6_enable() api its not called too. Hence i have to call this somewhere and i chose to call within nxd_interface_address_set() as the interface_index is available here. Is that right or should i add the call inside _nxd_ipv6_enable()?
Are you seeing unexpected behavior if nxd_ipv6_stateless_address_autoconfig_enable is not invoked? The value of NX_STATELESS_ADDRESS_AUTOCONFIG_ENABLED is defined to zero. It is the default value after IP is created. SLAAC will be disabled only if NX_IPV6_STATELESS_AUTOCONFIG_CONTROL is defined in project and nxd_ipv6_stateless_address_autoconfig_disable is invoked in application. If you build NetX Duo library with default configuration, the SLAAC is enabled by default.
Another thing needs to be noted is, IPv6 address must be set after ICMPv6 is enabled. Because SLAAC relies on ICMPv6.
Hey thanks! This comment helped, we had reversed this in our code under porting flag (i.e NX_STATELESS_ADDRESS_AUTOCONFIG_ENABLED is defined to 1) to disable SLAAC by default and not enable as IPV6 wasn't tested until now. I fixed this. How abt the other changes in my original query list above, are they ok? Point no 2 is already existing in 6.1.6 code, which wasn't present in 5.7 hence i copied, so it should be fine i guess. How about points 3,4? Are those changes ok? These two weren't there and i added and are needed to make IPv6 DNS query work.
Good to know the first two issues are solved. @bo-ms , could you help with the 3rd and 4th questions?
@TiejunMS As you mentioned icmpv6 needs to be enabled before SLAAC will start as SLAAC relies on icmpv6. But in netx stack icmpv6 is enabled only when host triggers a ipconfig via static or DHCP method from host application -> netx_initialization() -> nxd_icmpv6_enable(). So SLAAC wont begin until host tries to configure an IP via DHCP or static method, SLAAC wont be a independent process, is that fine?
Hi @RishaHolla Please check my answer below.
-
The DAD callback function in dhcpv6_client was added in 5.8, and suggest using the latest source code.
-
You may register the callback function for state change notify in nx_dhcpv6_client_create(), once the state is changed to NX_DHCPV6_STATE_BOUND_TO_ADDRESS, you may call nx_dhcpv6_request_inform_request to get the DNS server address. Or you can call nx_dhcpv6_request_option_DNS_server() before nx_dhcpv6_request_solicit(), once DHCPv6 interaction completed, call nx_dhcpv6_get_DNS_server_address() to get the DNS address, in this way, you need not call nx_dhcpv6_request_inform_request () again.
-
As in No3. nx_dhcpv6_request_option_DNS_server() and nx_dhcpv6_get_DNS_server_address() can be used to get the DNS server IP address, then directly call nxd_dns_server_add() to add the DNS server address into DNS module, I do not think you have to use netx_wrappers.c to covert the server name to address.
@bo-ms as quoted by you above "Or you can call nx_dhcpv6_request_option_DNS_server() before nx_dhcpv6_request_solicit(), once DHCPv6 interaction completed, call nx_dhcpv6_get_DNS_server_address() to get the DNS address, in this way, you need not call nx_dhcpv6_request_inform_request () again." - This is applicable when we are trying to acquire IP by DHCPv6 server rt, but in our case we are getting IPv6 address using SLAAC, so we have to send information request to DHCPv6 server (i.e. call nx_dhcpv6_request_inform_request () ) after SLAAC completes rt.
@bo-ms as quoted by you above "Or you can call nx_dhcpv6_request_option_DNS_server() before nx_dhcpv6_request_solicit(), once DHCPv6 interaction completed, call nx_dhcpv6_get_DNS_server_address() to get the DNS address, in this way, you need not call nx_dhcpv6_request_inform_request () again." - This is applicable when we are trying to acquire IP by DHCPv6 server rt, but in our case we are getting IPv6 address using SLAAC, so we have to send information request to DHCPv6 server (i.e. call nx_dhcpv6_request_inform_request () ) after SLAAC completes rt.
@RishaHolla Got it, you can try nx_dhcpv6_request_inform_request (). As there is a DHCPv6 Server, I was wondering why not directly using DHCPv6 client to get the IPv6 address.
Thanks @TiejunMS @bo-ms
So SLAAC wont begin until host tries to configure an IP via DHCP or static method, SLAAC wont be a independent process, is that fine?
For IPv6, a device at least needs to have one IP address which is different from IPv4. Setting a link local address is part of initialization of SLAAC. Does that answer your question?
Closing