Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve of DNS is not working correctly on contiki. #296

Closed
thetoster opened this issue Nov 17, 2016 · 3 comments
Closed

Resolve of DNS is not working correctly on contiki. #296

thetoster opened this issue Nov 17, 2016 · 3 comments
Milestone

Comments

@thetoster
Copy link
Contributor

It looks like code inside lwm2m_security_object.c is expecting that DNS will be resolved in calls while performing boostratp. However tests shows that bootstraping process might happen before DNS will be resolved. There is no next call to obtain resolved address for network layer. Probably some pulling mechanism is required to update proper structures. We found temporary workaround by adding following lines into mentioned file:

bool Lwm2mCore_ServerIsBootstrap(Lwm2mContextType * context, AddressType * address)
  {		  {
      bool result = false;
 +
 +    struct ListHead * current;
 +    ListForEach(current, Lwm2mCore_GetSecurityObjectList(context))
 +    {
 +        LWM2MSecurityInfo * securityInfo = ListEntry(current, LWM2MSecurityInfo, list);
 +        Lwm2m_Debug("Address found: %s, is bootstrap: %i\n", Lwm2mCore_DebugPrintAddress(&securityInfo->address),
 +        securityInfo->IsBootstrapServer);
 +        if(securityInfo->AddressResolved == 0)
 +        {
 +            securityInfo->AddressResolved = coap_ResolveAddressByURI(securityInfo->ServerURI, &securityInfo->address);
 +        }
 +    }
 +
LWM2MSecurityInfo * security = GetSecurityInfoForAddress(context, address);

Note: We spotted problem in contiki network layer (async handling of DNS requests) however given workaround is placed in security layer, which might be misleading.

@mtusnio
Copy link
Contributor

mtusnio commented Nov 18, 2016

Just to add up, the steps Awa & Contiki take for this issue to pop up are as follows:

  1. The coap_ResolveAddressByUri function gets called, it needs to resolve the DNS name so it kicks of an asynchronous resolution. In the meantime, Awa application saves a new address with all zeroes
  2. The resolution finishes, but never adds the address to the list
  3. ServerIsBootstrap is called with the proper resolved address, but since only [::] address is present it just decides the server is not a bootstrap one, and tries to do a regular write.

@mtusnio
Copy link
Contributor

mtusnio commented Nov 29, 2016

It seems that the asynchronous DNS resolution request never updates the security object, which is initially memset to 0. This happens regardless whether encryption is enabled on the device server.

[INFO] [lwm2m_bootstrap.c:72] Bootstrap with coap://ds-coap.flowcloud.systems:15683/bs?ep=Carpark1
[DEBUG] [network_abstraction_contiki.c:121] Still looking up "ds-coap.flowcloud.systems"...
[DEBUG] [network_abstraction_contiki.c:121] Still looking up "ds-coap.flowcloud.systems"...
[INFO] [coap_abstraction_erbium.c:385] Coap request: coap://ds-coap.flowcloud.systems:15683/bs?ep=Carpark1
[DEBUG] [coap_abstraction_erbium.c:451] Sending transaction [0]: A0008FF0
[ERROR] [lwm2m_bootstrap.c:235] No response to client initiated bootstrap
[WARN] [lwm2m_bootstrap.c:262] HoldOff Expired - Re-attempt bootstrap
[DEBUG] [lwm2m_bootstrap.c:99] Lwm2m_BootstrapFromSmartCard
[DEBUG] [lwm2m_bootstrap.c:105] Lwm2m_BootstrapFromFactory: False
[INFO] [lwm2m_bootstrap.c:203] Try existing server entries
[INFO] [lwm2m_registration.c:392] No servers are defined
[INFO] [lwm2m_bootstrap.c:224] Hold Off expired - attempt client-initiated bootstrap
[INFO] [lwm2m_bootstrap.c:72] Bootstrap with coap://ds-coap.flowcloud.systems:15683/bs?ep=Carpark1
[DEBUG] [network_abstraction_contiki.c:116] Lookup of "ds-coap.flowcloud.systems" succeded!
[DEBUG] [network_abstraction_contiki.c:337] Address add: coap://ds-coap.flowcloud.systems:15683
[DEBUG] [network_abstraction_contiki.c:299] Address free: coap://ds-coap.flowcloud.systems:15683
[DEBUG] [network_abstraction_contiki.c:116] Lookup of "ds-coap.flowcloud.systems" succeded!
[DEBUG] [network_abstraction_contiki.c:337] Address add: coap://ds-coap.flowcloud.systems:15683
[INFO] [coap_abstraction_erbium.c:385] Coap request: coap://ds-coap.flowcloud.systems:15683/bs?ep=Carpark1
[DEBUG] [coap_abstraction_erbium.c:451] Sending transaction [1]: A0009268
[DEBUG] [network_abstraction_contiki.c:483] Packet from: 28695 28695
[INFO] [lwm2m_bootstrap.c:85] Waiting for bootstrap to finish
[DEBUG] [network_abstraction_contiki.c:483] Packet from: 28695 28695
[DEBUG] [coap_abstraction_erbium.c:249] Coap PUT for /0
[DEBUG] [lwm2m_security_object.c:487] Printing all security objects:
[DEBUG] [lwm2m_security_object.c:491] Found security address: [0000:0000:0000:0000:0000:0000:0000:0000]:0
[WARN] [lwm2m_security_object.c:509] No security object matches address: [FD63:FAB9:6CCF:0064:0000:0000:0A64:7D56]:
17213

[DEBUG] [lwm2m_client_core.c:1985] WRITE (replace): /0
[DEBUG] [coap_abstraction_erbium.c:265] Coap Response code 400

@cheekyhalf
Copy link
Collaborator

cheekyhalf commented Dec 1, 2016

Should be fixed as of this pull request #300

@cheekyhalf cheekyhalf added this to the 0.2.5 milestone Dec 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants