Repository navigation
arp: compare the age of an entry in 8 bits - #1016
Merged
Merged
Conversation
arptime and the time of an entry are 8 bit counters, but their difference is computed as an int. Once arptime has wrapped the difference is negative, so an entry made in the upper part of the range never reaches the maximum age and is never picked as the oldest one.
feelfree69
approved these changes
Nov 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Nearly half of the ARP entries never time out.
arptimeand the time of an entry are 8 bit counters, but their difference is computed as anint. Oncearptimehas wrapped it is negative, so an entry made whilearptimewas 136 or more never reachesUIP_ARP_MAXAGE, and is never picked as the oldest one when the table is full.Both differences are cast back to 8 bits.
Tried with a host build of the unchanged
uip_arp.c: on main entries made atarptime0, 100 and 135 are removed after 120 timer calls, those made at 136, 200 and 255 are still there after 2000; with this change all six go after 120. With a full table main throws out a younger entry and this change the oldest. The firmware listing shows the 16 bit signed compare on main.