Skip to content

Commit

Permalink
NDPV6: set the initial INCOMPLETE timeout correctly
Browse files Browse the repository at this point in the history
Previously the logic inside `tick_one` would correctly set the timeout
to `now + retrans_timer` when the initial timeout is hit, but the
initial timeout is erroneously set to the `now + reachable_time` which is
typically very long (~30s).

From RFC2461 [1] section 4.2

> Reachable Time 32-bit unsigned integer.  The time, in
>           milliseconds, that a node assumes a neighbor is
>           reachable after having received a reachability
>           confirmation.  Used by the Neighbor Unreachability
>           Detection algorithm (see Section 7.3).  A value of
>           zero means unspecified (by this router).
>
> Retrans Timer  32-bit unsigned integer.  The time, in
>           milliseconds, between retransmitted Neighbor
>           Solicitation messages.  Used by address resolution
>           and the Neighbor Unreachability Detection algorithm
>           (see Sections 7.2 and 7.3).  A value of zero means
>           unspecified (by this router).

This patch bases the initial NS timeout on the "Retrans timer" rather
than the "Reachable Time" since we've not yet received a reachability
confirmation.

[1] https://tools.ietf.org/html/rfc2461

Signed-off-by: David Scott <dave@recoil.org>
  • Loading branch information
djs55 committed Aug 5, 2017
1 parent 5eb770b commit 5fe31cf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ipv6/ndpv6.ml
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ module NeighborCache = struct
| Not_found ->
nc, []

let query nc ~now ~reachable_time ip =
let query nc ~now ~retrans_timer ip =
try
let nb = IpMap.find ip nc in
match nb.state with
Expand All @@ -659,7 +659,7 @@ module NeighborCache = struct
nc, Some dmac, []
with
| Not_found ->
let nb = {state = INCOMPLETE (Int64.add now reachable_time, 0); is_router = false} in
let nb = {state = INCOMPLETE (Int64.add now retrans_timer, 0); is_router = false} in
let nc = IpMap.add ip nb nc in
let dst = Ipaddr.Prefix.network_address solicited_node_prefix ip in
nc, None, [SendNS (`Specified, dst, ip)]
Expand Down Expand Up @@ -1110,7 +1110,7 @@ and send ~now ctx dst frame datav =
| false ->
let ctx, ip = next_hop ctx dst in
let neighbor_cache, mac, actions =
NeighborCache.query ctx.neighbor_cache ~now ~reachable_time:ctx.reachable_time ip in
NeighborCache.query ctx.neighbor_cache ~now ~retrans_timer:ctx.retrans_timer ip in
let ctx = {ctx with neighbor_cache} in
match mac with
| Some dmac ->
Expand Down

0 comments on commit 5fe31cf

Please sign in to comment.