Added explicity forward-to-controller rule for LLDP and BDDP. Also made Interface and BgpPeer immutable
diff --git a/src/main/java/net/onrc/onos/ofcontroller/bgproute/BgpPeer.java b/src/main/java/net/onrc/onos/ofcontroller/bgproute/BgpPeer.java
index e98c3e8..fa11c17 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/bgproute/BgpPeer.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/bgproute/BgpPeer.java
@@ -7,24 +7,20 @@
import com.google.common.net.InetAddresses;
public class BgpPeer {
- private String interfaceName;
- private InetAddress ipAddress;
+ private final String interfaceName;
+ private final InetAddress ipAddress;
+
+ public BgpPeer(@JsonProperty("interface") String interfaceName,
+ @JsonProperty("ipAddress") String ipAddress) {
+ this.interfaceName = interfaceName;
+ this.ipAddress = InetAddresses.forString(ipAddress);
+ }
public String getInterfaceName() {
return interfaceName;
}
-
- @JsonProperty("interface")
- public void setInterfaceName(String interfaceName) {
- this.interfaceName = interfaceName;
- }
-
+
public InetAddress getIpAddress() {
return ipAddress;
}
-
- @JsonProperty("ipAddress")
- public void setIpAddress(String ipAddress) {
- this.ipAddress = InetAddresses.forString(ipAddress);
- }
}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/bgproute/BgpRoute.java b/src/main/java/net/onrc/onos/ofcontroller/bgproute/BgpRoute.java
index 5bbaa6c..d918db3 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/bgproute/BgpRoute.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/bgproute/BgpRoute.java
@@ -1053,7 +1053,7 @@
private void setupDefaultDropFlows() {
OFFlowMod fm = new OFFlowMod();
fm.setMatch(new OFMatch());
- //No action means drop
+ fm.setActions(new ArrayList<OFAction>()); //No action means drop
fm.setIdleTimeout((short)0)
.setHardTimeout((short)0)
@@ -1063,14 +1063,52 @@
.setPriority((short)0)
.setLengthU(OFFlowMod.MINIMUM_LENGTH);
+ OFFlowMod fmLLDP;
+ OFFlowMod fmBDDP;
+ try {
+ fmLLDP = fm.clone();
+ fmBDDP = fm.clone();
+ } catch (CloneNotSupportedException e1) {
+ log.error("Error cloning flow mod", e1);
+ return;
+ }
+
+ OFMatch matchLLDP = new OFMatch();
+ matchLLDP.setDataLayerType((short)0x8942);
+ matchLLDP.setWildcards(matchLLDP.getWildcards() & ~ OFMatch.OFPFW_DL_TYPE);
+ fmLLDP.setMatch(matchLLDP);
+
+ OFMatch matchBDDP = new OFMatch();
+ matchBDDP.setDataLayerType((short)0x88cc);
+ matchBDDP.setWildcards(matchBDDP.getWildcards() & ~ OFMatch.OFPFW_DL_TYPE);
+ fmBDDP.setMatch(matchBDDP);
+
+ OFActionOutput action = new OFActionOutput();
+ action.setPort(OFPort.OFPP_CONTROLLER.getValue());
+ action.setMaxLength((short)0xffff);
+ List<OFAction> actions = new ArrayList<OFAction>(1);
+ actions.add(action);
+
+ fmLLDP.setActions(actions);
+ fmBDDP.setActions(actions);
+
+ fmLLDP.setPriority(ARP_PRIORITY);
+ fmLLDP.setLengthU(OFFlowMod.MINIMUM_LENGTH + OFActionOutput.MINIMUM_LENGTH);
+ fmBDDP.setPriority(ARP_PRIORITY);
+ fmBDDP.setLengthU(OFFlowMod.MINIMUM_LENGTH + OFActionOutput.MINIMUM_LENGTH);
+
for (String strdpid : switches){
IOFSwitch sw = floodlightProvider.getSwitches().get(HexString.toLong(strdpid));
if (sw == null) {
log.debug("Couldn't find switch to push default deny flow");
}
else {
+ List<OFMessage> msgList = new ArrayList<OFMessage>();
+ msgList.add(fm);
+ msgList.add(fmLLDP);
+ msgList.add(fmBDDP);
try {
- sw.write(fm, null);
+ sw.write(msgList, null);
} catch (IOException e) {
log.warn("Failure writing default deny flow to switch", e);
}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/bgproute/Interface.java b/src/main/java/net/onrc/onos/ofcontroller/bgproute/Interface.java
index 088c18e..48b60d8 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/bgproute/Interface.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/bgproute/Interface.java
@@ -6,68 +6,57 @@
import net.onrc.onos.ofcontroller.util.Port;
import net.onrc.onos.ofcontroller.util.SwitchPort;
+import org.codehaus.jackson.annotate.JsonCreator;
import org.codehaus.jackson.annotate.JsonProperty;
import org.openflow.util.HexString;
import com.google.common.net.InetAddresses;
public class Interface {
- private String name;
- private SwitchPort switchPort = null;
- private long dpid;
- private short port;
- private InetAddress ipAddress;
- private int prefixLength;
+ private final String name;
+ private final SwitchPort switchPort;
+ private final long dpid;
+ private final short port;
+ private final InetAddress ipAddress;
+ private final int prefixLength;
+
+ @JsonCreator
+ public Interface (@JsonProperty("name") String name,
+ @JsonProperty("dpid") String dpid,
+ @JsonProperty("port") short port,
+ @JsonProperty("ipAddress") String ipAddress,
+ @JsonProperty("prefixLength") int prefixLength) {
+ this.name = name;
+ this.dpid = HexString.toLong(dpid);
+ this.port = port;
+ this.ipAddress = InetAddresses.forString(ipAddress);
+ this.prefixLength = prefixLength;
+ this.switchPort = new SwitchPort(new Dpid(this.dpid), new Port(this.port));
+ }
public String getName() {
return name;
}
- @JsonProperty("name")
- public void setName(String name) {
- this.name = name;
- }
-
- public synchronized SwitchPort getSwitchPort() {
- if (switchPort == null){
- switchPort = new SwitchPort(new Dpid(dpid), new Port(port));
- }
- return switchPort;
+ public SwitchPort getSwitchPort() {
+ //TODO SwitchPort, Dpid and Port are mutable, but they could probably
+ //be made immutable which would prevent the need to copy
+ return new SwitchPort(new Dpid(dpid), new Port(port));
}
public long getDpid() {
return dpid;
}
- @JsonProperty("dpid")
- public void setDpid(String dpid) {
- this.dpid = HexString.toLong(dpid);
- }
-
public short getPort() {
return port;
}
- @JsonProperty("port")
- public void setPort(short port) {
- this.port = port;
- }
-
public InetAddress getIpAddress() {
return ipAddress;
}
- @JsonProperty("ipAddress")
- public void setIpAddress(String ipAddress) {
- this.ipAddress = InetAddresses.forString(ipAddress);
- }
-
public int getPrefixLength() {
return prefixLength;
}
-
- @JsonProperty("prefixLength")
- public void setPrefixLength(int prefixLength) {
- this.prefixLength = prefixLength;
- }
}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/bgproute/RibUpdate.java b/src/main/java/net/onrc/onos/ofcontroller/bgproute/RibUpdate.java
index 7d4d7a5..d866304 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/bgproute/RibUpdate.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/bgproute/RibUpdate.java
@@ -3,9 +3,9 @@
public class RibUpdate {
public enum Operation {UPDATE, DELETE};
- private Operation operation;
- private Prefix prefix;
- private RibEntry ribEntry;
+ private final Operation operation;
+ private final Prefix prefix;
+ private final RibEntry ribEntry;
public RibUpdate(Operation operation, Prefix prefix, RibEntry ribEntry) {
this.operation = operation;