Fixing a race condition which prevented barrier-replies from being recognized.
Uncommenting MPLS actions in driver, and creating new action of BoS, even though we do not push actions in flow-mods.
Change-Id: I333023b4ef88c9328d6c63c7f988b5e2225a19f3
diff --git a/src/main/java/net/floodlightcontroller/core/IOF13Switch.java b/src/main/java/net/floodlightcontroller/core/IOF13Switch.java
index 71a14e7..846197c 100644
--- a/src/main/java/net/floodlightcontroller/core/IOF13Switch.java
+++ b/src/main/java/net/floodlightcontroller/core/IOF13Switch.java
@@ -134,12 +134,12 @@
public void removePortFromGroups(PortNumber port);
public void addPortToGroups(PortNumber port);
+
/**
* give string tableType (ip, mpls, acl)
* @param tableType String equal to only one of (ip, mpls, acl)
* @return TableId
*/
-
public TableId getTableId(String tableType);
public int createTunnel(int tunnelId, List<String> route, NeighborSet ns);
diff --git a/src/main/java/net/floodlightcontroller/core/internal/OFSwitchImplBase.java b/src/main/java/net/floodlightcontroller/core/internal/OFSwitchImplBase.java
index 236ed06..a610c0d 100644
--- a/src/main/java/net/floodlightcontroller/core/internal/OFSwitchImplBase.java
+++ b/src/main/java/net/floodlightcontroller/core/internal/OFSwitchImplBase.java
@@ -1332,10 +1332,10 @@
.buildBarrierRequest()
.setXid(xid)
.build();
- write(Collections.singletonList(br));
OFBarrierReplyFuture future = new OFBarrierReplyFuture(threadPool, this,
(int) xid);
barrierFutureMap.put(xid, future);
+ write(Collections.singletonList(br));
return future;
}
@@ -1344,6 +1344,10 @@
if (f != null) {
f.deliverFuture(this, br);
barrierFutureMap.remove(br.getXid());
+ } else {
+ log.warn("Rcvd unknown barrier reply xid: {} from sw: {}",
+ br.getXid(), getStringId());
+
}
}
}
diff --git a/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingManager.java b/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingManager.java
index 1060531..8f52964 100644
--- a/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingManager.java
+++ b/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingManager.java
@@ -72,6 +72,7 @@
import org.json.JSONArray;
import org.json.JSONException;
+import org.projectfloodlight.openflow.protocol.OFBarrierReply;
import org.projectfloodlight.openflow.types.EthType;
import org.projectfloodlight.openflow.types.IPv4Address;
import org.slf4j.Logger;
@@ -646,18 +647,28 @@
// Send Barrier Message and make sure all rules are set
// before we set the rules to next routers
+ // TODO: barriers to all switches in this update stage
IOF13Switch sw13 = (IOF13Switch) floodlightProvider.getMasterSwitch(
getSwId(sw.getDpid().toString()));
if (sw13 != null) {
+ OFBarrierReplyFuture replyFuture = null;
try {
- OFBarrierReplyFuture replyFuture = sw13.sendBarrier();
- replyFuture.get(10, TimeUnit.SECONDS);
+ replyFuture = sw13.sendBarrier();
} catch (IOException e) {
- e.printStackTrace();
- } catch (InterruptedException | ExecutionException | TimeoutException e) {
- log.error("Barrier message not received for sw: {}", sw.getDpid());
- e.printStackTrace();
+ log.error("Error sending barrier request to switch {}",
+ sw13.getId(), e.getCause());
}
+ OFBarrierReply br = null;
+ try {
+ br = replyFuture.get(2, TimeUnit.SECONDS);
+ } catch (TimeoutException | InterruptedException | ExecutionException e) {
+ // XXX for some reason these exceptions are not being thrown
+ }
+ if (br == null) {
+ log.warn("Did not receive barrier-reply from {}", sw13.getId());
+ // XXX take corrective action
+ }
+
}
}
diff --git a/src/main/java/net/onrc/onos/core/drivermanager/OFSwitchImplCPqD13.java b/src/main/java/net/onrc/onos/core/drivermanager/OFSwitchImplCPqD13.java
index f799617..c2ac997 100644
--- a/src/main/java/net/onrc/onos/core/drivermanager/OFSwitchImplCPqD13.java
+++ b/src/main/java/net/onrc/onos/core/drivermanager/OFSwitchImplCPqD13.java
@@ -44,6 +44,9 @@
import net.onrc.onos.core.matchaction.action.ModifySrcMacAction;
import net.onrc.onos.core.matchaction.action.OutputAction;
import net.onrc.onos.core.matchaction.action.PopMplsAction;
+import net.onrc.onos.core.matchaction.action.PushMplsAction;
+import net.onrc.onos.core.matchaction.action.SetMplsBosAction;
+import net.onrc.onos.core.matchaction.action.SetMplsIdAction;
import net.onrc.onos.core.matchaction.match.Ipv4Match;
import net.onrc.onos.core.matchaction.match.Match;
import net.onrc.onos.core.matchaction.match.MplsMatch;
@@ -1254,15 +1257,21 @@
.ethSrc(MacAddress.of(srcMac));
ofAction = factory.actions().buildSetField()
.setField(smac).build();
- /*} else if (action instanceof PushMplsAction) {
- ofAction = factory.actions().pushMpls(EthType.MPLS_UNICAST);
- } else if (action instanceof SetMplsIdAction) {
- int labelid = ((SetMplsIdAction) action).getMplsId();
- OFOxmMplsLabel lid = factory.oxms()
- .mplsLabel(U32.of(labelid));
- ofAction = factory.actions().buildSetField()
- .setField(lid).build();
- */} else if (action instanceof PopMplsAction) {
+ } else if (action instanceof PushMplsAction) {
+ ofAction = factory.actions().pushMpls(EthType.MPLS_UNICAST);
+ } else if (action instanceof SetMplsIdAction) {
+ int labelid = ((SetMplsIdAction) action).getMplsId();
+ OFOxmMplsLabel lid = factory.oxms()
+ .mplsLabel(U32.of(labelid));
+ ofAction = factory.actions().buildSetField()
+ .setField(lid).build();
+ } else if (action instanceof SetMplsBosAction) {
+ OFBooleanValue val = OFBooleanValue.of(
+ ((SetMplsBosAction) action).isSet());
+ OFOxmMplsBos bos = factory.oxms().mplsBos(val);
+ OFAction setBos = factory.actions().buildSetField()
+ .setField(bos).build();
+ } else if (action instanceof PopMplsAction) {
EthType ethertype = ((PopMplsAction) action).getEthType();
ofAction = factory.actions().popMpls(ethertype);
} else if (action instanceof GroupAction) {
@@ -1299,10 +1308,6 @@
return null;
}
- // not supported by loxigen
- // OFAction setBos =
- // factory.actions().buildSetField().setField(bos).build();
-
return ofAction;
}
diff --git a/src/main/java/net/onrc/onos/core/matchaction/action/SetMplsBosAction.java b/src/main/java/net/onrc/onos/core/matchaction/action/SetMplsBosAction.java
new file mode 100644
index 0000000..610fc2d
--- /dev/null
+++ b/src/main/java/net/onrc/onos/core/matchaction/action/SetMplsBosAction.java
@@ -0,0 +1,13 @@
+package net.onrc.onos.core.matchaction.action;
+
+public class SetMplsBosAction implements Action {
+ private final boolean mplsBos;
+
+ public SetMplsBosAction(boolean setBos) {
+ mplsBos = setBos;
+ }
+
+ public boolean isSet() {
+ return mplsBos;
+ }
+}