Fix: Avoid from deleting flat jump rules even if there are remained vm's in same host
Change-Id: Ia36f4a861454a8c7aeb7b70c4fcaaecc13891865
diff --git a/apps/openstacknetworking/api/src/main/java/org/onosproject/openstacknetworking/api/Constants.java b/apps/openstacknetworking/api/src/main/java/org/onosproject/openstacknetworking/api/Constants.java
index 6635559..f85d914 100644
--- a/apps/openstacknetworking/api/src/main/java/org/onosproject/openstacknetworking/api/Constants.java
+++ b/apps/openstacknetworking/api/src/main/java/org/onosproject/openstacknetworking/api/Constants.java
@@ -60,7 +60,10 @@
public static final int PRIORITY_EXTERNAL_FLOATING_ROUTING_RULE = 27000;
public static final int PRIORITY_SNAT_RULE = 26000;
public static final int PRIORITY_SWITCHING_RULE = 30000;
- public static final int PRIORITY_FLAT_RULE = 41000;
+ public static final int PRIORITY_FLAT_JUMP_UPSTREAM_RULE = 41000;
+ public static final int PRIORITY_FLAT_JUMP_DOWNSTREAM_RULE = 41000;
+ public static final int PRIORITY_FLAT_UPSTREAM_RULE = 41000;
+ public static final int PRIORITY_FLAT_DOWNSTREAM_RULE = 42000;
public static final int PRIORITY_DHCP_RULE = 42000;
public static final int PRIORITY_ADMIN_RULE = 32000;
public static final int PRIORITY_ACL_RULE = 31000;
diff --git a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackSwitchingHandler.java b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackSwitchingHandler.java
index 4fb03a2..4869101 100644
--- a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackSwitchingHandler.java
+++ b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackSwitchingHandler.java
@@ -61,7 +61,10 @@
import static org.onosproject.openstacknetworking.api.Constants.FORWARDING_TABLE;
import static org.onosproject.openstacknetworking.api.Constants.OPENSTACK_NETWORKING_APP_ID;
import static org.onosproject.openstacknetworking.api.Constants.PRIORITY_ADMIN_RULE;
-import static org.onosproject.openstacknetworking.api.Constants.PRIORITY_FLAT_RULE;
+import static org.onosproject.openstacknetworking.api.Constants.PRIORITY_FLAT_DOWNSTREAM_RULE;
+import static org.onosproject.openstacknetworking.api.Constants.PRIORITY_FLAT_JUMP_DOWNSTREAM_RULE;
+import static org.onosproject.openstacknetworking.api.Constants.PRIORITY_FLAT_JUMP_UPSTREAM_RULE;
+import static org.onosproject.openstacknetworking.api.Constants.PRIORITY_FLAT_UPSTREAM_RULE;
import static org.onosproject.openstacknetworking.api.Constants.PRIORITY_SWITCHING_RULE;
import static org.onosproject.openstacknetworking.api.Constants.PRIORITY_TUNNEL_TAG_RULE;
import static org.onosproject.openstacknetworking.api.Constants.VTAG_TABLE;
@@ -170,7 +173,7 @@
port.deviceId(),
selector.build(),
treatment.build(),
- PRIORITY_FLAT_RULE,
+ PRIORITY_FLAT_JUMP_UPSTREAM_RULE,
DHCP_ARP_TABLE,
install);
@@ -180,7 +183,6 @@
log.warn("The network does not exist");
return;
}
-
PortNumber portNumber = osNodeService.node(port.deviceId())
.phyIntfPortNum(network.getProviderPhyNet());
@@ -190,14 +192,30 @@
}
selector = DefaultTrafficSelector.builder();
- selector.matchInPort(portNumber);
+ selector.matchInPort(portNumber)
+ .matchEthType(Ethernet.TYPE_IPV4)
+ .matchIPDst(port.ipAddress().toIpPrefix());
osFlowRuleService.setRule(
appId,
port.deviceId(),
selector.build(),
treatment.build(),
- PRIORITY_FLAT_RULE,
+ PRIORITY_FLAT_JUMP_DOWNSTREAM_RULE,
+ DHCP_ARP_TABLE,
+ install);
+
+ selector = DefaultTrafficSelector.builder();
+ selector.matchInPort(portNumber)
+ .matchEthType(Ethernet.TYPE_ARP)
+ .matchArpTpa(port.ipAddress().getIp4Address());
+
+ osFlowRuleService.setRule(
+ appId,
+ port.deviceId(),
+ selector.build(),
+ treatment.build(),
+ PRIORITY_FLAT_JUMP_DOWNSTREAM_RULE,
DHCP_ARP_TABLE,
install);
}
@@ -216,7 +234,7 @@
instPort.deviceId(),
selector,
treatment,
- PRIORITY_FLAT_RULE,
+ PRIORITY_FLAT_DOWNSTREAM_RULE,
FLAT_TABLE,
install);
@@ -230,7 +248,7 @@
instPort.deviceId(),
selector,
treatment,
- PRIORITY_FLAT_RULE,
+ PRIORITY_FLAT_DOWNSTREAM_RULE,
FLAT_TABLE,
install);
}
@@ -264,7 +282,7 @@
instPort.deviceId(),
selector,
treatment,
- PRIORITY_FLAT_RULE,
+ PRIORITY_FLAT_UPSTREAM_RULE,
FLAT_TABLE,
install);
}