From 0de8dfceda180efcb88705de124ce3352910df0c Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Fri, 3 Jan 2025 00:50:24 +0000 Subject: [PATCH] fw: implement localhop (close #73) --- fw/fw/thread.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/fw/fw/thread.go b/fw/fw/thread.go index 6a76c531..707b82cc 100644 --- a/fw/fw/thread.go +++ b/fw/fw/thread.go @@ -305,13 +305,25 @@ func (t *Thread) processIncomingInterest(packet *defn.Pkt) { lookupName = fhName } - // Query the FIB for possible nexthops + // Query the FIB for all possible nexthops nexthops := table.FibStrategyTable.FindNextHopsEnc(lookupName) - // Exclude faces that have an in-record for this interest - // TODO: unclear where NFD dev guide specifies such behavior (if any) + // If the first component is /localhop, we do not forward interests received + // on non-local faces to non-local faces + localFacesOnly := incomingFace.Scope() != defn.Local && len(packet.Name) > 0 && packet.Name[0].Equal(enc.LOCALHOP) + + // Filter the nexthops that are allowed for this Interest allowedNexthops := make([]*table.FibNextHopEntry, 0, len(nexthops)) for _, nexthop := range nexthops { + // Exclude non-local faces for localhop enforcement + if localFacesOnly { + if face := dispatch.GetFace(nexthop.Nexthop); face != nil && face.Scope() != defn.Local { + continue + } + } + + // Exclude faces that have an in-record for this interest + // TODO: unclear where NFD dev guide specifies such behavior (if any) record := pitEntry.InRecords()[nexthop.Nexthop] if record == nil || nexthop.Nexthop == incomingFace.FaceID() { allowedNexthops = append(allowedNexthops, nexthop)