AbstractServices need unique flowIds in order to avoid rules coalescing 54/19454/1
authorFlavio Fernandes <ffernand@redhat.com>
Fri, 1 May 2015 19:48:51 +0000 (15:48 -0400)
committerFlavio Fernandes <ffernand@redhat.com>
Fri, 1 May 2015 21:04:03 +0000 (17:04 -0400)
This is a follow up from gerrit https://git.opendaylight.org/gerrit/#/c/19410/.
When assembling different flow rules for different match, it is important
to make their flowIds unique. By not doing that, openflowPlugin will treat
them as one; and that is what gets pushed to OF capable node.

Also removed cases when writeFlow() was being invoked twice for no reason.

Change-Id: I898d777e779e61da3c9f070306915c4c37f65572
Signed-off-by: Flavio Fernandes <ffernand@redhat.com>
openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/ArpResponderService.java
openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/EgressAclService.java
openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/InboundNatService.java
openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/IngressAclService.java
openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/L3ForwardingService.java
openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/LoadBalancerService.java
openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/OutboundNatService.java
openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/RoutingService.java

index 94afb368a61972a4e29b55f3c38a88a29bce9dc2..440ab7f7c8129065be930e3f04b525d18b176231 100644 (file)
@@ -134,7 +134,7 @@ public class ArpResponderService extends AbstractServiceInstance implements ArpP
         flowBuilder.setMatch(matchBuilder.build());
         flowBuilder.setInstructions(isb.setInstruction(instructions).build());
 
-        String flowId = "ArpResponder_" + ipAddress.getHostAddress();
+        String flowId = "ArpResponder_" + segmentationId + "_" + ipAddress.getHostAddress();
         flowBuilder.setId(new FlowId(flowId));
         FlowKey key = new FlowKey(new FlowId(flowId));
         flowBuilder.setBarrier(true);
index a7803d2f2e591c772cf458f540700cd1b5d89bc7..4c3d146cfb0a1e790f5e5f2205f1af3fc436ae25 100644 (file)
@@ -229,7 +229,7 @@ public class EgressAclService extends AbstractServiceInstance implements EgressA
                                                                        attachedMac, Constants.TCP_SYN, segmentationId).build());
         logger.debug("MatchBuilder contains: {}", flowBuilder.getMatch());
 
-        String flowId = "TCP_Syn_Egress_Default_Drop_" + attachedMac;
+        String flowId = "TCP_Syn_Egress_Default_Drop_" + segmentationId + "_" + attachedMac;
         flowBuilder.setId(new FlowId(flowId));
         FlowKey key = new FlowKey(new FlowId(flowId));
         flowBuilder.setStrict(false);
index 5d0f1732db5793d2de35e396a2103f83edc91b80..6e46b21e20c24bcf2eb557f2c0d3ae878c54d873 100644 (file)
@@ -78,7 +78,7 @@ public class InboundNatService extends AbstractServiceInstance implements Inboun
         flowBuilder.setMatch(matchBuilder.build());
         flowBuilder.setInstructions(isb.setInstruction(instructions).build());
 
-        String flowId = "InboundNAT_" + rewriteAddress.getHostAddress();
+        String flowId = "InboundNAT_" + segmentationId + "_" + rewriteAddress.getHostAddress();
         flowBuilder.setId(new FlowId(flowId));
         FlowKey key = new FlowKey(new FlowId(flowId));
         flowBuilder.setBarrier(true);
@@ -125,7 +125,7 @@ public class InboundNatService extends AbstractServiceInstance implements Inboun
         flowBuilder.setMatch(matchBuilder.build());
         flowBuilder.setInstructions(isb.setInstruction(instructions).build());
 
-        String flowId = "InboundNATExclusion_" + excludedCidr;
+        String flowId = "InboundNATExclusion_" + segmentationId + "_" + excludedCidr;
         flowBuilder.setId(new FlowId(flowId));
         FlowKey key = new FlowKey(new FlowId(flowId));
         flowBuilder.setBarrier(true);
index 3ccdead9a10653a3ca36bde1848860696acb68d8..fccaa42b4c369eeaa30855d02059d34d98e7ba4e 100644 (file)
@@ -219,7 +219,7 @@ public class IngressAclService extends AbstractServiceInstance implements Ingres
                                                               Constants.TCP_SYN, segmentationId).build());
 
         logger.debug("ingressACLTcpSyn MatchBuilder contains:  {}", flowBuilder.getMatch());
-        String flowId = "UcastOut_ACL2" + segmentationId + "_" + attachedMac + securityRulePortMin;
+        String flowId = "UcastOut_ACL2_" + segmentationId + "_" + attachedMac + securityRulePortMin;
         // Add Flow Attributes
         flowBuilder.setId(new FlowId(flowId));
         FlowKey key = new FlowKey(new FlowId(flowId));
@@ -368,7 +368,7 @@ public class IngressAclService extends AbstractServiceInstance implements Ingres
                 attachedMac, Constants.TCP_SYN, segmentationId).build());
 
         logger.debug("MatchBuilder contains: {}", flowBuilder.getMatch());
-        String flowId = "PortSec_TCP_Syn_Default_Drop_" + attachedMac;
+        String flowId = "PortSec_TCP_Syn_Default_Drop_" + segmentationId + "_" + attachedMac;
         flowBuilder.setId(new FlowId(flowId));
         FlowKey key = new FlowKey(new FlowId(flowId));
         flowBuilder.setStrict(false);
index b768c7f0a3a4a03e9375b71ecc867f5fe55b08fd..9a795c27a226914d5158fbfdcb2021527843bdf3 100644 (file)
@@ -80,7 +80,7 @@ public class L3ForwardingService extends AbstractServiceInstance implements L3Fo
         flowBuilder.setMatch(matchBuilder.build());
         flowBuilder.setInstructions(isb.setInstruction(instructions).build());
 
-        String flowId = "L3Forwarding_" + ipAddress.getHostAddress();
+        String flowId = "L3Forwarding_" + segmentationId + "_" + ipAddress.getHostAddress();
         flowBuilder.setId(new FlowId(flowId));
         FlowKey key = new FlowKey(new FlowId(flowId));
         flowBuilder.setBarrier(true);
index a68430f76f3813ae900d5a3e2586eed3d9c465f1..03664d8547600852e17efebe6fb70b390f4f3ba0 100644 (file)
@@ -173,7 +173,7 @@ public class LoadBalancerService extends AbstractServiceInstance implements Load
         MatchUtils.createDstL3IPv4Match(matchBuilder, MatchUtils.iPv4PrefixFromIPv4Address(lbConfig.getVip()));
         MatchUtils.addNxRegMatch(matchBuilder, new MatchUtils.RegMatch(REG_FIELD_A, FIRST_PASS_REGA_MATCH_VALUE));
 
-        String flowId = "LOADBALANCER_FORWARD_FLOW1_" + lbConfig.getVip();
+        String flowId = "LOADBALANCER_FORWARD_FLOW1_" + lbConfig.getProviderSegmentationId() + "_" + lbConfig.getVip();
         flowBuilder.setId(new FlowId(flowId));
         FlowKey key = new FlowKey(new FlowId(flowId));
         flowBuilder.setMatch(matchBuilder.build());
@@ -273,7 +273,8 @@ public class LoadBalancerService extends AbstractServiceInstance implements Load
         MatchUtils.addNxRegMatch(matchBuilder, new MatchUtils.RegMatch(REG_FIELD_A, SECOND_PASS_REGA_MATCH_VALUE),
                                                new MatchUtils.RegMatch(REG_FIELD_B, (long)member.getIndex()));
 
-        String flowId = "LOADBALANCER_FORWARD_FLOW2_" + vip + "_" + member.getIP();
+        String flowId = "LOADBALANCER_FORWARD_FLOW2_" + lbConfig.getProviderSegmentationId() + "_" +
+                        vip + "_" + member.getIP();
         flowBuilder.setId(new FlowId(flowId));
         FlowKey key = new FlowKey(new FlowId(flowId));
         flowBuilder.setMatch(matchBuilder.build());
@@ -369,7 +370,8 @@ public class LoadBalancerService extends AbstractServiceInstance implements Load
         MatchUtils.createSrcL3IPv4Match(matchBuilder, MatchUtils.iPv4PrefixFromIPv4Address(member.getIP()));
         MatchUtils.createSetSrcTcpMatch(matchBuilder, new PortNumber(member.getPort()));
 
-        String flowId = "LOADBALANCER_REVERSE_FLOW_" + vip + "_" + member.getIP();
+        String flowId = "LOADBALANCER_REVERSE_FLOW_" + lbConfig.getProviderSegmentationId() +
+                        vip + "_" + member.getIP();
         flowBuilder.setId(new FlowId(flowId));
         FlowKey key = new FlowKey(new FlowId(flowId));
         flowBuilder.setMatch(matchBuilder.build());
index b3da3a90f0126e7c65246c692242dba77b3dce6e..8e6ce4135ea34dd6d782cb2e9622978553a8ae43 100644 (file)
@@ -81,7 +81,7 @@ public class OutboundNatService extends AbstractServiceInstance implements Outbo
         flowBuilder.setMatch(matchBuilder.build());
         flowBuilder.setInstructions(isb.setInstruction(instructions).build());
 
-        String flowId = "OutboundNAT_" + rewriteAddress.getHostAddress();
+        String flowId = "OutboundNAT_" + segmentationId + "_" + rewriteAddress.getHostAddress();
         flowBuilder.setId(new FlowId(flowId));
         FlowKey key = new FlowKey(new FlowId(flowId));
         flowBuilder.setBarrier(true);
@@ -128,7 +128,7 @@ public class OutboundNatService extends AbstractServiceInstance implements Outbo
         flowBuilder.setMatch(matchBuilder.build());
         flowBuilder.setInstructions(isb.setInstruction(instructions).build());
 
-        String flowId = "OutboundNATExclusion_" + excludedCidr;
+        String flowId = "OutboundNATExclusion_" + segmentationId + "_" + excludedCidr;
         flowBuilder.setId(new FlowId(flowId));
         FlowKey key = new FlowKey(new FlowId(flowId));
         flowBuilder.setBarrier(true);
index 57fa8dc62527face9fcec764d95a451ced93b239..02e7586d65cd7bcdb13379847bd67ae7f3f2abfb 100644 (file)
@@ -31,7 +31,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
@@ -115,7 +114,6 @@ public class RoutingService extends AbstractServiceInstance implements RoutingPr
         flowBuilder.setBarrier(true);
         flowBuilder.setTableId(this.getTable());
         flowBuilder.setKey(key);
-        flowBuilder.setCookie(new FlowCookie(new BigInteger(sourceSegId)));
         flowBuilder.setPriority(2048);
         flowBuilder.setFlowName(flowId);
         flowBuilder.setHardTimeout(0);