Moved assignment of TunID to SourceMapper 91/19991/1
authorKeith Burns (alagalah) <alagalah@gmail.com>
Sun, 10 May 2015 23:45:33 +0000 (16:45 -0700)
committerKeith Burns (alagalah) <alagalah@gmail.com>
Mon, 11 May 2015 01:02:48 +0000 (18:02 -0700)
- TunID determined by SourceEP ordinals
- Removes need for matching on Source generated reg values in DestinationMapper
- Incredibly useful for SFC when EPs are both on same node.

Change-Id: I6598f7b10edbe4624694e884f760cfb894ca31ad
Signed-off-by: Keith Burns (alagalah) <alagalah@gmail.com>
renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/flow/DestinationMapper.java
renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/flow/SourceMapper.java

index 28c0bc073fbdceed24fb43d20c501ab61f41cbea..9feec5ee3ea993a70f3c3f16b0ee069ea24c8d4a 100644 (file)
@@ -93,7 +93,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg0;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg2;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg3;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg4;
@@ -216,9 +215,16 @@ public class DestinationMapper extends FlowTable {
     // group on the node
 
     private Flow createBroadcastFlow(EndpointFwdCtxOrdinals epOrd) {
-        FlowId flowId = new FlowId(new StringBuilder().append("broadcast|").append(epOrd.getFdId()).toString());
-        MatchBuilder mb = new MatchBuilder().setEthernetMatch(new EthernetMatchBuilder().setEthernetDestination(
-                new EthernetDestinationBuilder().setAddress(MULTICAST_MAC).setMask(MULTICAST_MAC).build()).build());
+        FlowId flowId = new FlowId(new StringBuilder().
+                                    append("broadcast|").
+                                    append(epOrd.getFdId()).
+                                    toString());
+        MatchBuilder mb = new MatchBuilder()
+                            .setEthernetMatch(new EthernetMatchBuilder()
+                            .setEthernetDestination(new EthernetDestinationBuilder().
+                                                        setAddress(MULTICAST_MAC)
+                                                        .setMask(MULTICAST_MAC).build())
+                            .build());
         addNxRegMatch(mb, RegMatch.of(NxmNxReg5.class, Long.valueOf(epOrd.getFdId())));
 
         FlowBuilder flowb = base().setPriority(Integer.valueOf(140))
@@ -728,9 +734,6 @@ public class DestinationMapper extends FlowTable {
         }
 
         setNextHop = nxLoadRegAction(NxmNxReg7.class, BigInteger.valueOf(portNum));
-        Action tunIdAction = nxLoadTunIdAction(BigInteger.valueOf(srcEpFwdCtxOrds.getTunnelId()), false);
-
-        applyActions.add(tunIdAction);
         applyActions.add(tundstAction);
         // END TUNNEL
 
@@ -756,7 +759,7 @@ public class DestinationMapper extends FlowTable {
             .append("|l2|")
             .append(ep.getMacAddress().getValue())
             .append("|")
-            .append(srcEpFwdCtxOrds.getTunnelId())
+            .append(srcEpFwdCtxOrds.getBdId())
             .append("|")
             .append(nextHop)
             .toString());
@@ -876,9 +879,6 @@ public class DestinationMapper extends FlowTable {
         }
 
         setNextHop = nxLoadRegAction(NxmNxReg7.class, BigInteger.valueOf(portNum));
-        Action tunIdAction = nxLoadTunIdAction(BigInteger.valueOf(srcEpFwdCtxOrds.getTunnelId()), false);
-
-        applyActions.add(tunIdAction);
         applyActions.add(tundstAction);
         // END TUNNEL
 
@@ -926,25 +926,17 @@ public class DestinationMapper extends FlowTable {
             .append("|l3|")
             .append(ikey)
             .append("|")
-            .append(destEpFwdCtxOrds.getEpgId())
-            .append("|")
-            .append(destEpFwdCtxOrds.getCgId())
-            .append("|")
             .append(matcherMac)
             .append("|")
             .append(destSubnetGatewayMac)
             .append("|")
-            .append(srcEpFwdCtxOrds.getEpgId())
-            .append("|")
-            .append(srcEpFwdCtxOrds.getFdId())
+            .append(srcEpFwdCtxOrds.getL3Id())
             .append("|")
             .append(nextHop)
             .toString());
         MatchBuilder mb = new MatchBuilder().setEthernetMatch(ethernetMatch(null, matcherMac, etherType))
             .setLayer3Match(m);
-        addNxRegMatch(mb, RegMatch.of(NxmNxReg0.class, Long.valueOf(srcEpFwdCtxOrds.getEpgId())),
-                RegMatch.of(NxmNxReg5.class, Long.valueOf(srcEpFwdCtxOrds.getFdId())),
-                RegMatch.of(NxmNxReg6.class, Long.valueOf(destEpFwdCtxOrds.getL3Id())));
+        addNxRegMatch(mb, RegMatch.of(NxmNxReg6.class, Long.valueOf(destEpFwdCtxOrds.getL3Id())));
 
         FlowBuilder flowb = base().setId(flowid)
             .setPriority(Integer.valueOf(132))
index b0871c89a808a09cc1100ff0eca668738e0e7d87..e469a5df070a69380b8f7cb7d61329381f72900c 100644 (file)
@@ -14,6 +14,7 @@ import static org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.FlowUtil
 import static org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.FlowUtils.gotoTableIns;
 import static org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.FlowUtils.instructions;
 import static org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.FlowUtils.nxLoadRegAction;
+import static org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.FlowUtils.nxLoadTunIdAction;
 
 import java.math.BigInteger;
 import java.util.Collections;
@@ -116,10 +117,8 @@ public class SourceMapper extends FlowTable {
             for (EgKey peer : peers) {
                 for (NodeId remoteNodeId : ctx.getEndpointManager().getNodesForGroup(peer)) {
 
-                    // Only put tunnels on destination nodes
-                    if (remoteNodeId.getValue().equals(nodeId.getValue())) {
-                        continue;
-                    }
+                    // Please do not check for remote v local nodeID, we need local to local tunnels
+                    // in the case of chaining - The Great Dr Sunal.
                     NodeConnectorId tunPort = ctx.getSwitchManager().getTunnelPort(remoteNodeId);
                     if (tunPort == null) {
                         LOG.trace("No tunnel port for tunnel in SourceMapper between local:{} and remote:{}",
@@ -225,6 +224,7 @@ public class SourceMapper extends FlowTable {
         int fdId = epFwdCtxOrds.getFdId();
         int l3Id = epFwdCtxOrds.getL3Id();
         int cgId = epFwdCtxOrds.getCgId();
+        int tunnelId = epFwdCtxOrds.getTunnelId();
 
         FlowId flowid = new FlowId(new StringBuilder().append(ofc.getNodeConnectorId().getValue())
             .append("|")
@@ -245,6 +245,8 @@ public class SourceMapper extends FlowTable {
         Action bdReg = nxLoadRegAction(NxmNxReg4.class, BigInteger.valueOf(bdId));
         Action fdReg = nxLoadRegAction(NxmNxReg5.class, BigInteger.valueOf(fdId));
         Action vrfReg = nxLoadRegAction(NxmNxReg6.class, BigInteger.valueOf(l3Id));
+        Action tunIdAction = nxLoadTunIdAction(BigInteger.valueOf(tunnelId), false);
+
         FlowBuilder flowb = base().setPriority(Integer.valueOf(100))
             .setId(flowid)
             .setMatch(
@@ -252,7 +254,7 @@ public class SourceMapper extends FlowTable {
                         .setInPort(ofc.getNodeConnectorId())
                         .build())
             .setInstructions(
-                    instructions(applyActionIns(segReg, scgReg, bdReg, fdReg, vrfReg),
+                    instructions(applyActionIns(segReg, scgReg, bdReg, fdReg, vrfReg,tunIdAction),
                             gotoTableIns((short) (TABLE_ID + 1))));
         flowMap.writeFlow(nodeId, TABLE_ID, flowb.build());
     }