Always do a handshake (send features request, wait for features reply) since
the switch might not send packet-ins until it's done
diff --git a/tests/basic.py b/tests/basic.py
index 6d4d235..66f78aa 100644
--- a/tests/basic.py
+++ b/tests/basic.py
@@ -93,6 +93,10 @@
if self.controller.switch_addr is None:
raise Exception("Controller startup failed (no switch addr)")
basic_logger.info("Connected " + str(self.controller.switch_addr))
+ request = message.features_request()
+ reply, pkt = self.controller.transact(request, timeout=10)
+ self.supported_actions = reply.actions
+ basic_logger.info("Supported actions: " + hex(self.supported_actions))
def inheritSetup(self, parent):
"""
diff --git a/tests/pktact.py b/tests/pktact.py
index b53f13b..023e1ca 100644
--- a/tests/pktact.py
+++ b/tests/pktact.py
@@ -88,9 +88,6 @@
ofp.OFPAT_SET_TP_SRC,
ofp.OFPAT_SET_TP_DST]
-# Cache supported features to avoid transaction overhead
-cached_supported_actions = None
-
TEST_VID_DEFAULT = 2
def test_set_init(config):
@@ -1299,7 +1296,7 @@
"""
def runTest(self):
new_vid = 2
- sup_acts = supported_actions_get(self)
+ sup_acts = self.supported_actions
if not(sup_acts & 1<<ofp.OFPAT_SET_VLAN_VID):
skip_message_emit(self, "Add VLAN tag test")
return
@@ -1352,7 +1349,7 @@
def runTest(self):
old_vid = 2
new_vid = 3
- sup_acts = supported_actions_get(self)
+ sup_acts = self.supported_actions
if not (sup_acts & 1 << ofp.OFPAT_SET_VLAN_VID):
skip_message_emit(self, "Modify VLAN tag test")
return
@@ -1373,7 +1370,7 @@
def runTest(self):
old_vid = 2
new_vid = 3
- sup_acts = supported_actions_get(self)
+ sup_acts = self.supported_actions
if not (sup_acts & 1 << ofp.OFPAT_SET_VLAN_VID):
skip_message_emit(self, "ModifyVIDWithTagWildcarded test")
return
@@ -1420,7 +1417,7 @@
vid = 123
old_vlan_pcp = 2
new_vlan_pcp = 3
- sup_acts = supported_actions_get(self)
+ sup_acts = self.supported_actions
if not (sup_acts & 1 << ofp.OFPAT_SET_VLAN_PCP):
skip_message_emit(self, "Modify VLAN priority test")
return
@@ -1439,7 +1436,7 @@
"""
def runTest(self):
old_vid = 2
- sup_acts = supported_actions_get(self)
+ sup_acts = self.supported_actions
if not (sup_acts & 1 << ofp.OFPAT_STRIP_VLAN):
skip_message_emit(self, "Strip VLAN tag test")
return
@@ -1461,7 +1458,7 @@
"""
def runTest(self):
old_vid = 2
- sup_acts = supported_actions_get(self)
+ sup_acts = self.supported_actions
if not (sup_acts & 1 << ofp.OFPAT_STRIP_VLAN):
skip_message_emit(self, "StripVLANTagWithTagWildcarded test")
return
@@ -1502,7 +1499,7 @@
Modify the source MAC address (TP1)
"""
def runTest(self):
- sup_acts = supported_actions_get(self)
+ sup_acts = self.supported_actions
if not (sup_acts & 1 << ofp.OFPAT_SET_DL_SRC):
skip_message_emit(self, "ModifyL2Src test")
return
@@ -1517,7 +1514,7 @@
Modify the dest MAC address (TP1)
"""
def runTest(self):
- sup_acts = supported_actions_get(self)
+ sup_acts = self.supported_actions
if not (sup_acts & 1 << ofp.OFPAT_SET_DL_DST):
skip_message_emit(self, "ModifyL2dst test")
return
@@ -1532,7 +1529,7 @@
Modify the source IP address of an IP packet (TP1)
"""
def runTest(self):
- sup_acts = supported_actions_get(self)
+ sup_acts = self.supported_actions
if not (sup_acts & 1 << ofp.OFPAT_SET_NW_SRC):
skip_message_emit(self, "ModifyL3Src test")
return
@@ -1547,7 +1544,7 @@
Modify the dest IP address of an IP packet (TP1)
"""
def runTest(self):
- sup_acts = supported_actions_get(self)
+ sup_acts = self.supported_actions
if not (sup_acts & 1 << ofp.OFPAT_SET_NW_DST):
skip_message_emit(self, "ModifyL3Dst test")
return
@@ -1562,7 +1559,7 @@
Modify the source TCP port of a TCP packet (TP1)
"""
def runTest(self):
- sup_acts = supported_actions_get(self)
+ sup_acts = self.supported_actions
if not (sup_acts & 1 << ofp.OFPAT_SET_TP_SRC):
skip_message_emit(self, "ModifyL4Src test")
return
@@ -1577,7 +1574,7 @@
Modify the dest TCP port of a TCP packet (TP1)
"""
def runTest(self):
- sup_acts = supported_actions_get(self)
+ sup_acts = self.supported_actions
if not (sup_acts & 1 << ofp.OFPAT_SET_TP_DST):
skip_message_emit(self, "ModifyL4Dst test")
return
@@ -1592,7 +1589,7 @@
Modify the IP type of service of an IP packet (TP1)
"""
def runTest(self):
- sup_acts = supported_actions_get(self)
+ sup_acts = self.supported_actions
if not (sup_acts & 1 << ofp.OFPAT_SET_NW_TOS):
skip_message_emit(self, "ModifyTOS test")
return
@@ -1607,7 +1604,7 @@
Modify the L2 dest and send to 2 ports
"""
def runTest(self):
- sup_acts = supported_actions_get(self)
+ sup_acts = self.supported_actions
if not (sup_acts & 1 << ofp.OFPAT_SET_DL_DST):
skip_message_emit(self, "ModifyL2dstMC test")
return
@@ -1622,7 +1619,7 @@
Modify the L2 dest and send to the ingress port
"""
def runTest(self):
- sup_acts = supported_actions_get(self)
+ sup_acts = self.supported_actions
if not (sup_acts & 1 << ofp.OFPAT_SET_DL_DST):
skip_message_emit(self, "ModifyL2dstIngress test")
return
@@ -1638,7 +1635,7 @@
Modify the L2 dest and send to the ingress port
"""
def runTest(self):
- sup_acts = supported_actions_get(self)
+ sup_acts = self.supported_actions
if not (sup_acts & 1 << ofp.OFPAT_SET_DL_DST):
skip_message_emit(self, "ModifyL2dstMC test")
return
@@ -1654,7 +1651,7 @@
Modify the source MAC address (TP1) and send to multiple
"""
def runTest(self):
- sup_acts = supported_actions_get(self)
+ sup_acts = self.supported_actions
if not (sup_acts & 1 << ofp.OFPAT_SET_DL_SRC):
skip_message_emit(self, "ModifyL2SrcMC test")
return
@@ -1669,7 +1666,7 @@
Modify the L2 source and dest and send to 2 ports
"""
def runTest(self):
- sup_acts = supported_actions_get(self)
+ sup_acts = self.supported_actions
if (not (sup_acts & 1 << ofp.OFPAT_SET_DL_DST) or
not (sup_acts & 1 << ofp.OFPAT_SET_DL_SRC)):
skip_message_emit(self, "ModifyL2SrcDstMC test")
@@ -1686,7 +1683,7 @@
Modify the L2 dest and send to 2 ports
"""
def runTest(self):
- sup_acts = supported_actions_get(self)
+ sup_acts = self.supported_actions
if (not (sup_acts & 1 << ofp.OFPAT_SET_DL_DST) or
not (sup_acts & 1 << ofp.OFPAT_SET_VLAN_VID)):
skip_message_emit(self, "ModifyL2DstVIDMC test")
@@ -1879,20 +1876,5 @@
test_prio["MixedVLAN"] = -1
-def supported_actions_get(parent, use_cache=True):
- """
- Get the bitmap of supported actions from the switch
- If use_cache is false, the cached value will be updated
- """
- global cached_supported_actions
- if cached_supported_actions is None or not use_cache:
- request = message.features_request()
- (reply, pkt) = parent.controller.transact(request)
- parent.assertTrue(reply is not None, "Did not get response to ftr req")
- cached_supported_actions = reply.actions
- pa_logger.info("Supported actions: " + hex(cached_supported_actions))
-
- return cached_supported_actions
-
if __name__ == "__main__":
print "Please run through oft script: ./oft --test_spec=basic"