Skip to content

Commit

Permalink
refactor: move MaxNextHops to defn
Browse files Browse the repository at this point in the history
  • Loading branch information
pulsejet committed Dec 25, 2024
1 parent 460b7c6 commit c1fd578
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
3 changes: 3 additions & 0 deletions fw/defn/mtu.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ package defn

// MaxNDNPacketSize is the maximum allowed NDN packet size
const MaxNDNPacketSize = 8800

// Maximum number of next hops for a given path
const MaxNextHops = 16
2 changes: 1 addition & 1 deletion fw/fw/bestroute.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (s *BestRoute) AfterReceiveInterest(
packet *defn.Pkt,
pitEntry table.PitEntry,
inFace uint64,
nexthops [MaxNextHops]*table.FibNextHopEntry,
nexthops [defn.MaxNextHops]*table.FibNextHopEntry,
nexthopsCount int,
) {
if nexthopsCount == 0 {
Expand Down
2 changes: 1 addition & 1 deletion fw/fw/multicast.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (s *Multicast) AfterReceiveInterest(
packet *defn.Pkt,
pitEntry table.PitEntry,
inFace uint64,
nexthops [MaxNextHops]*table.FibNextHopEntry,
nexthops [defn.MaxNextHops]*table.FibNextHopEntry,
nexthopsCount int,
) {
if nexthopsCount == 0 {
Expand Down
5 changes: 1 addition & 4 deletions fw/fw/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ import (
// StrategyPrefix is the prefix of all strategy names for YaNFD
const StrategyPrefix = "/localhost/nfd/strategy"

// Maximum number of possible next hops (i.e. router links) for optimization
const MaxNextHops = 32

// Strategy represents a forwarding strategy.
type Strategy interface {
Instantiate(fwThread *Thread)
Expand All @@ -39,7 +36,7 @@ type Strategy interface {
packet *defn.Pkt,
pitEntry table.PitEntry,
inFace uint64,
nexthops [MaxNextHops]*table.FibNextHopEntry,
nexthops [defn.MaxNextHops]*table.FibNextHopEntry,
nexthopsCount int,
)
BeforeSatisfyInterest(
Expand Down
4 changes: 2 additions & 2 deletions fw/fw/thread.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,15 +327,15 @@ func (t *Thread) processIncomingInterest(packet *defn.Pkt) {

// Exclude faces that have an in-record for this interest
// TODO: unclear where NFD dev guide specifies such behavior (if any)
allowedNexthops := [MaxNextHops]*table.FibNextHopEntry{}
allowedNexthops := [defn.MaxNextHops]*table.FibNextHopEntry{}
allowedNexthopsCount := 0
for _, nexthop := range nexthops {
record := pitEntry.InRecords()[nexthop.Nexthop]
if record == nil || nexthop.Nexthop == incomingFace.FaceID() {
allowedNexthops[allowedNexthopsCount] = nexthop
allowedNexthopsCount++
}
if allowedNexthopsCount >= MaxNextHops {
if allowedNexthopsCount >= defn.MaxNextHops {
break // limit reached
}
}
Expand Down

0 comments on commit c1fd578

Please sign in to comment.