Skip to content

arp: compare the age of an entry in 8 bits - #1016

Merged
feelfree69 merged 1 commit into
RTLPlayground:mainfrom
DrDoof:fix/arp-age-wrap
Nov 26, 2026
Merged

feelfree69 merged 1 commit into
RTLPlayground:mainfrom
DrDoof:fix/arp-age-wrap

Conversation

@DrDoof

@DrDoof DrDoof commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

Nearly half of the ARP entries never time out. arptime and the time of an entry are 8 bit counters, but their difference is computed as an int. Once arptime has wrapped it is negative, so an entry made while arptime was 136 or more never reaches UIP_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 at arptime 0, 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.

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
feelfree69 merged commit 8426137 into RTLPlayground:main Nov 26, 2026
1 check passed
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.

2 participants