Giter Club home page Giter Club logo

Comments (7)

BartVolkaerts avatar BartVolkaerts commented on May 26, 2024

Actually, this happens in every case when the client goes back to init state.

from picotcp.

bogdanlu avatar bogdanlu commented on May 26, 2024

ROOT CAUSE:

  • On mbed platform the dhcp_cb function adds a route to ip 0.0.0.0 which messes up the DHCP client during INIT state

if (gateway.addr != 0) {
pico_ipv4_to_string(gw_addr, gateway.addr);
eth_dbg("Default gateway assigned : %s\n",gw_addr);
pico_ipv4_route_add(zero, zero, gateway, 1, NULL);
}

DETAILED ANALYSIS:
-There are several conditions for the bug to occur and to be 100% reproducible on any environment:

  1. The route to 0.0.0.0 needs to be added in the DHCP client callback function
  2. The DHCP server needs to answer with OFFER using the broadcast address and not directly the IP (bug reproduced with dnsmasq; bug not reproduced with picoTCP DHCP server )
    -In the chronological order below is what happens:
  3. ACK is received from the server. IP is registered. Callback is called with DHCP_SUCCESS and route to 0.0.0.0 is added but the IP in the link contains the IP registered.
  4. Renew time expires. NAK received from server. Resetting the DHCP client and going to INIT state
  5. In INIT state the DHCP client creates a 0.0.0.0 link and tries to add it to the route table -> FAIL because there already is this link; The return status of the route_add function is not checked to initialization continues
  6. OFFER messages arrive but these messages are dropped. The current implementation of picoTCP socket allows broadcast messages to be received only if the linked IP is 0.0.0.0. Socket looks for the dest.addr in the IP link of the route table of destination 0.0.0.0 and the IP is the initial registered IP

SOLUTION PROPOSED:

  • Remove the route present in the DHCP client callback function.

from picotcp.

bogdanlu avatar bogdanlu commented on May 26, 2024

Initial solution proposed has been dropped as the route is needed for the default gateway.

SECOND SOLUTION PROPOSED:

  • clear the 0.0.0.0 route in the reset function of the dhcp client. Little probability of regression because in case the route is not found, initialization continues as normal. Also the route should not exist after init because a new IP might be received from dhcp server

from picotcp.

bogdanlu avatar bogdanlu commented on May 26, 2024

IMPACTED MODULES:

  • pico_dhcp_client.c function reset
  • call pico_ipv4_route_del to delete the route assigned to dest 0.0.0.0

TESTS:

  • mbed and linux using dnsmaq as dhcp server -> OFFER messages are processed

Merged on both mbed and github

from picotcp.

maartenvds avatar maartenvds commented on May 26, 2024

After the fix, no discover messages are send by PicoTCP after he received the NAK.
Reproduce with:
sudo ./run.sh --test nackafterrequest testcases/hardware/dhcp_client_dora.txt
The test will fail with: "Sniff timed out after 40.00 seconds"

from picotcp.

andreixc avatar andreixc commented on May 26, 2024

The dhcp client callbacks us with a reset after the first NAK
it waits some time then it's reporting error and it gives up.
Checking further into dhcp client..

from picotcp.

bogdanlu avatar bogdanlu commented on May 26, 2024

Even though the issues seem to be related the root cause is different. Closing this ticket and opening Issue #45 to track the fix for the new behavior described by Maarten

from picotcp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.