VOL-1608: Fixed LLDP flow not getting deleted
Change-Id: I520fea7f6e3066ad80281b085d1fb177477604b9
diff --git a/voltha/adapters/openolt/openolt_flow_mgr.py b/voltha/adapters/openolt/openolt_flow_mgr.py
index 1cc58db..d0bf2f7 100644
--- a/voltha/adapters/openolt/openolt_flow_mgr.py
+++ b/voltha/adapters/openolt/openolt_flow_mgr.py
@@ -299,11 +299,20 @@
def _clear_flow_id_from_rm(self, flow, flow_id, flow_direction):
try:
- pon_intf, onu_id, uni_id \
+ pon_intf, onu_id, uni_id, eth_type \
= self.platform.flow_extract_info(flow, flow_direction)
except ValueError:
- self.log.error("failure extracting pon_intf, onu_id, uni_id info from flow")
+ self.log.error("failure-extracting-flow-info")
+ return
else:
+ if eth_type == LLDP_ETH_TYPE:
+ network_intf_id = self.data_model.olt_nni_intf_id()
+ onu_id = -1
+ uni_id = -1
+
+ self.resource_mgr.free_flow_id(network_intf_id, onu_id, uni_id, flow_id)
+ return
+
flows = self.resource_mgr.get_flow_id_info(pon_intf, onu_id, uni_id, flow_id)
assert (isinstance(flows, list))
self.log.debug("retrieved-flows", flows=flows)
diff --git a/voltha/adapters/openolt/openolt_platform.py b/voltha/adapters/openolt/openolt_platform.py
index a56b319..fdb37ec 100644
--- a/voltha/adapters/openolt/openolt_platform.py
+++ b/voltha/adapters/openolt/openolt_platform.py
@@ -154,21 +154,27 @@
def flow_extract_info(self, flow, flow_direction):
uni_port_no = None
+ eth_type = None
+
if flow_direction == "upstream":
for field in fd.get_ofb_fields(flow):
if field.type == fd.IN_PORT:
uni_port_no = field.port
break
elif flow_direction == "downstream":
+ for field in fd.get_ofb_fields(flow):
+ if field.type == fd.ETH_TYPE:
+ eth_type = field.eth_type
+ break
+
+ uni_port_no = fd.get_metadata_from_write_metadata(flow) & 0xFFFFFFFF
+
if uni_port_no is None:
for action in fd.get_actions(flow):
if action.type == fd.OUTPUT:
uni_port_no = action.output.port
break
- if uni_port_no is None:
- uni_port_no = fd.get_metadata_from_write_metadata(flow) & 0xFFFFFFFF
-
if uni_port_no is None:
raise ValueError
@@ -176,4 +182,4 @@
onu_id = self.onu_id_from_uni_port_num(uni_port_no)
uni_id = self.uni_id_from_port_num(uni_port_no)
- return int(pon_intf), int(onu_id), int(uni_id)
+ return int(pon_intf), int(onu_id), int(uni_id), eth_type