Skip to content

Commit 421209c

Browse files
committed
fw: fix bug in sorting for forwarding + copy packet when setting ER tag in replicast
1 parent 833b15a commit 421209c

3 files changed

Lines changed: 16 additions & 10 deletions

File tree

e2e/test_005.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import random
22
import os
3+
import time
34
from pathlib import Path
45

56
from mininet.log import info
@@ -55,16 +56,18 @@ def receive_chat_message(node):
5556
buf = []
5657

5758
try:
59+
beg = time.time()
5860
for node in chatters[:publish_size]:
5961
# send a random message into chat
6062
msg = os.urandom(8).hex()
6163
node.write(msg + "\n")
62-
info(f"{node.name} publishing {msg}\n")
64+
info(f"[t={time.time() - beg:.2f}] {node.name} publishing {msg!r}\n")
6365

6466
for other_node in chatters:
6567
if other_node.name == node.name:
6668
continue
6769
received = receive_chat_message(other_node)
70+
info(f"[t={time.time() - beg:.2f}] {other_node.name} received {received!r}\n")
6871
assert msg in received, "received wrong message"
6972

7073
# custom cleanup logic for this test

fw/fw/bestroute.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func (s *BestRoute) AfterReceiveInterest(
7373

7474
// sort nexthops by cost and send to best-possible hop for each unique ER
7575
sort.Slice(nexthops, func(i, j int) bool {
76-
return nexthops[i].HopEntry.Cost < nexthops[i].HopEntry.Cost
76+
return nexthops[i].HopEntry.Cost < nexthops[j].HopEntry.Cost
7777
})
7878

7979
now := time.Now()
@@ -101,12 +101,10 @@ func (s *BestRoute) AfterReceiveInterest(
101101

102102
// if there is an associated EgressRouter tag with this new route, then set packet.EgressRouter to the tag
103103
if nh.EgressRouter != nil {
104-
oldEgress := packet.EgressRouter
105104
packet.EgressRouter = nh.EgressRouter
106105
if sent := s.SendInterest(packet, pitEntry, nh.HopEntry.Nexthop, inFace); sent {
107106
return
108107
}
109-
packet.EgressRouter = oldEgress
110108
// otherwise, normal forwarding
111109
} else {
112110
if sent := s.SendInterest(packet, pitEntry, nh.HopEntry.Nexthop, inFace); sent {

fw/fw/replicast.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,15 @@ func (s *Replicast) AfterReceiveInterest(
6767
return
6868
}
6969

70+
// interest with ER tag should only be unicast as dest router is known
71+
if len(packet.EgressRouter) > 0 {
72+
core.Log.Debug(s, "Interest with ER tag passed to replicast - DROP", "name", packet.Name)
73+
return
74+
}
75+
7076
// sort nexthops by cost and send to best-possible nexthop for each unique ER
7177
sort.Slice(nexthops, func(i, j int) bool {
72-
return nexthops[i].HopEntry.Cost < nexthops[i].HopEntry.Cost
78+
return nexthops[i].HopEntry.Cost < nexthops[j].HopEntry.Cost
7379
})
7480

7581
sentER := make(map[uint64]bool)
@@ -80,13 +86,12 @@ func (s *Replicast) AfterReceiveInterest(
8086
continue
8187
}
8288

83-
oldEgress := packet.EgressRouter
84-
packet.EgressRouter = nh.EgressRouter
85-
if sent := s.SendInterest(packet, pitEntry, nh.HopEntry.Nexthop, inFace); sent {
86-
core.Log.Trace(s, "Forwarded Interest", "name", packet.Name, "faceid", nh.HopEntry.Nexthop, "er", nh.EgressRouter, "inFace", inFace)
89+
outgoingPkt := *packet
90+
outgoingPkt.EgressRouter = nh.EgressRouter
91+
if sent := s.SendInterest(&outgoingPkt, pitEntry, nh.HopEntry.Nexthop, inFace); sent {
92+
core.Log.Trace(s, "Forwarded Interest", "name", outgoingPkt.Name, "faceid", nh.HopEntry.Nexthop, "er", nh.EgressRouter, "inFace", inFace)
8793
sentER[nh.EgressRouter.Hash()] = true
8894
}
89-
packet.EgressRouter = oldEgress
9095
}
9196

9297
for _, nh := range nexthops {

0 commit comments

Comments
 (0)