Skip to content

Commit

Permalink
support for double digit ports (#375)
Browse files Browse the repository at this point in the history
Changes the interface variable into an integer, so that it avoids
alphabetical order which results in a BMV2 deadlock.

Fixes #373
  • Loading branch information
Calin Cascaval authored and ChrisDodd committed Mar 22, 2017
1 parent 42eb72c commit 951228b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions backends/bmv2/bmv2stf.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def readJson(self):
for t in self.json["pipelines"][1]["tables"]:
self.tables.append(BMV2Table(t))
def filename(self, interface, direction):
return self.folder + "/" + self.pcapPrefix + interface + "_" + direction + ".pcap"
return self.folder + "/" + self.pcapPrefix + str(interface) + "_" + direction + ".pcap"
def interface_of_filename(self, f):
return os.path.basename(f).rstrip('.pcap').lstrip(self.pcapPrefix).rsplit('_', 1)[0]
def do_cli_command(self, cmd):
Expand All @@ -380,6 +380,7 @@ def do_command(self, cmd):
self.do_cli_command(self.parse_table_set_default(cmd))
elif first == "packet":
interface, data = nextWord(cmd)
interface = int(interface)
data = ''.join(data.split())
time.sleep(self.packetDelay)
try:
Expand All @@ -391,6 +392,7 @@ def do_command(self, cmd):
self.packetDelay = 0
elif first == "expect":
interface, data = nextWord(cmd)
interface = int(interface)
data = ''.join(data.split())
if data != '':
self.expected.setdefault(interface, []).append(data)
Expand Down Expand Up @@ -464,7 +466,7 @@ def interfaceArgs(self):
# return list of interface names suitable for bmv2
result = []
for interface in sorted(self.interfaces):
result.append("-i " + interface + "@" + self.pcapPrefix + interface)
result.append("-i " + str(interface) + "@" + self.pcapPrefix + str(interface))
return result
def generate_model_inputs(self, stffile):
self.stffile = stffile
Expand All @@ -474,6 +476,7 @@ def generate_model_inputs(self, stffile):
first, cmd = nextWord(line)
if first == "packet" or first == "expect":
interface, cmd = nextWord(cmd)
interface = int(interface)
if not interface in self.interfaces:
# Can't open the interfaces yet, as that would block
ifname = self.interfaces[interface] = self.filename(interface, "in")
Expand Down

0 comments on commit 951228b

Please sign in to comment.