Skip to content

DHCP state machine error handling #80

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

Merged
merged 9 commits into from
Jan 9, 2023
Merged

DHCP state machine error handling #80

merged 9 commits into from
Jan 9, 2023

Conversation

BiffoBear
Copy link
Contributor

Closes #75 #79. @FoamyGuy Refactored DHCP.parse_dhcp_response to raise ValueError instead of returning 0, 0. Refactored DHCP._dhcp_state_machine to catch the exception, print it if debugging is on, and continue.

Fixed off-by-one bugs in DHCP.send_dhcp_message that caused the buffer to grow by 1 or 2 bytes every time the function is called.
Fixed logic bugs in DHCP.parse_dhcp_response that meant that some errors were not being caught.
Fixed a bug in DHCP.parse_dhcp_response where an IP address with more than 4 bytes would be returned if more than one router address was supplied by the DHCP server.

BiffoBear added 7 commits December 15, 2022 06:19
…avoid problems with Pytest collecting tests. Began tests.
…parse_dhcp_message and simplified MAGIC_COOKIE. Fixed router IP assignment to allow for multiple routers. Updated type hints.
…hcp_message. Added pytest to optional_requirements.txt.
@FoamyGuy
Copy link
Contributor

Thanks for working on this! I will check it out this evening.

Copy link
Contributor

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this successfully on a Feather S2 TFT under both 7.3.3 and 8.0.0 beta5. Can confirm this fixes the issues mentioned in #75.

It's now able to reconnect successfully to my wired network. I'm guessing one of the off-by-1 errors that were fixed perhaps was the root cause of my transaction ID problem. Not certain, but either way it does appear to be solved, I have been able to successfully run the simpletest several times under both versions of circuitpython core.

@BiffoBear
Copy link
Contributor Author

BiffoBear commented Dec 17, 2022

I tested this successfully on a Feather S2 TFT under both 7.3.3 and 8.0.0 beta5. Can confirm this fixes the issues mentioned in #75.

It's now able to reconnect successfully to my wired network. I'm guessing one of the off-by-1 errors that were fixed perhaps was the root cause of my transaction ID problem. Not certain, but either way it does appear to be solved, I have been able to successfully run the simpletest several times under both versions of circuitpython core.

That's good news. Thanks for testing this. The 'f' you were seeing with the error shows that the problem you had was a mismatched packet ID, probably from another device's DHCP request. If you run with debug=True I expect you'll see occasional messages about that. I never see that here because there is very little DHCP traffic on my network. The off-by-ones all caused errors to be ignored.

@FoamyGuy
Copy link
Contributor

FoamyGuy commented Jan 9, 2023

I merged main into this to resolve the current conflicts.

Going to merge this PR. I re-tested the simpletest successfully with Feather TFT from the branch after merging main and resolving conflicts.

For my ethernet environment the fixes in this PR seem to be required in order for me to successfully connect to the network. So merging this one will allow me to test out the other open PRs.

@FoamyGuy FoamyGuy merged commit 1b8ff4e into adafruit:main Jan 9, 2023
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Jan 10, 2023
Updating https://github.com/adafruit/Adafruit_CircuitPython_Wiznet5k to 1.13.1 from 1.13.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_Wiznet5k#80 from BiffoBear/dhcp_error_handling

Updating https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad to 1.17.0 from 1.16.8:
  > Merge pull request adafruit/Adafruit_CircuitPython_ImageLoad#63 from FoamyGuy/png_typing_and_example
  > Add .venv to .gitignore
  > Update .pylintrc for v2.15.5
  > Fix release CI files
  > Update pylint to 2.15.5
  > Updated pylint version to 2.13.0
  > Switching to composite actions

Updating https://github.com/adafruit/Adafruit_CircuitPython_Motor to 3.4.6 from 3.4.5:
  > Merge pull request adafruit/Adafruit_CircuitPython_Motor#67 from tekktrik/pwmout-fix
  > Add .venv to .gitignore
  > Update .pylintrc for v2.15.5
  > Fix release CI files
  > Update pylint to 2.15.5
  > Updated pylint version to 2.13.0
  > Switching to composite actions

Updating https://github.com/adafruit/Adafruit_CircuitPython_Requests to 1.12.12 from 1.12.11:
  > Merge pull request adafruit/Adafruit_CircuitPython_Requests#124 from adafruit/chain-exception-when-fail
  > Add .venv to .gitignore

Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA:
  > Updated download stats for the libraries
@BiffoBear BiffoBear deleted the dhcp_error_handling branch January 17, 2023 00:12
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

Successfully merging this pull request may close these issues.

DHCP Fails, prints f and returns a value that causes exception
2 participants