Cleaned up ProxyArpManager code by creating an interface through which it can request information about the L3 configuration (IP addresses, ports, etc)
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 9e7bf61..4a0aa27 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/bgproute/BgpRoute.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/bgproute/BgpRoute.java
@@ -76,7 +76,7 @@
public class BgpRoute implements IFloodlightModule, IBgpRouteService,
ITopologyListener, IArpRequester,
- IOFSwitchListener {
+ IOFSwitchListener, ILayer3InfoService {
protected static Logger log = LoggerFactory.getLogger(BgpRoute.class);
@@ -158,7 +158,6 @@
ldu.getDst(), ldu.getDstPort());
if (activeLinks.contains(l)){
- log.debug("Not found: {}", l);
it.remove();
}
}
@@ -263,7 +262,7 @@
//TODO We'll initialise this here for now, but it should really be done as
//part of the controller core
- proxyArp = new ProxyArpManager(floodlightProvider, topology);
+ proxyArp = new ProxyArpManager(floodlightProvider, topology, this);
linkUpdates = new ArrayList<LDUpdate>();
ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
@@ -309,7 +308,7 @@
readGatewaysConfiguration(configFilename);
- proxyArp.setL3Mode(interfacePtrie, interfaces.values(), bgpdMacAddress);
+ //proxyArp.setL3Mode(interfacePtrie, interfaces.values(), bgpdMacAddress);
}
@Override
@@ -466,7 +465,8 @@
Path path = pushedPaths.get(dstIpAddress);
if (path == null) {
path = new Path(egressInterface, dstIpAddress);
- setUpDataPath(path, MACAddress.valueOf(nextHopMacAddress));
+ //setUpDataPath(path, MACAddress.valueOf(nextHopMacAddress));
+ calculateAndPushPath(path, MACAddress.valueOf(nextHopMacAddress));
pushedPaths.put(dstIpAddress, path);
}
@@ -572,7 +572,12 @@
try {
sw.write(msglist, null);
sw.flush();
- //Thread.sleep(0, 100000);
+
+ /*
+ * XXX Rate limit hack!
+ * This should be solved properly by adding a rate limiting
+ * layer on top of the switches if we know they need it.
+ */
Thread.sleep(1);
} catch (IOException e) {
log.error("Failure writing flow mod", e);
@@ -703,13 +708,16 @@
}
//If we know the MAC, lets go ahead and push the paths to this peer
- setUpDataPath(path, MACAddress.valueOf(mac));
+ //setUpDataPath(path, MACAddress.valueOf(mac));
+ calculateAndPushPath(path, MACAddress.valueOf(mac));
}
}
+ /*
private void setUpDataPath(Path path, MACAddress dstMacAddress) {
calculateAndPushPath(path, dstMacAddress);
}
+ */
private void calculateAndPushPath(Path path, MACAddress dstMacAddress) {
Interface dstInterface = path.getDstInterface();
@@ -989,7 +997,8 @@
}
}
else {
- setUpDataPath(path, MACAddress.valueOf(macAddress));
+ //setUpDataPath(path, MACAddress.valueOf(macAddress));
+ calculateAndPushPath(path, MACAddress.valueOf(macAddress));
pushedPaths.put(path.getDstIpAddress(), path);
}
}
@@ -1214,20 +1223,54 @@
}
@Override
- public void removedSwitch(IOFSwitch sw) {
- // TODO Auto-generated method stub
-
- }
+ public void removedSwitch(IOFSwitch sw) {}
@Override
- public void switchPortChanged(Long switchId) {
- // TODO Auto-generated method stub
-
- }
+ public void switchPortChanged(Long switchId) {}
@Override
public String getName() {
- // TODO Auto-generated method stub
- return null;
+ return "BgpRoute";
+ }
+
+ /*
+ * ILayer3InfoService methods
+ */
+
+ @Override
+ public boolean isInterfaceAddress(InetAddress address) {
+ Interface intf = interfacePtrie.match(new Prefix(address.getAddress(), 32));
+ return (intf != null && intf.getIpAddress().equals(address));
+ }
+
+ @Override
+ public boolean inConnectedNetwork(InetAddress address) {
+ Interface intf = interfacePtrie.match(new Prefix(address.getAddress(), 32));
+ return (intf != null && !intf.getIpAddress().equals(address));
+ }
+
+ @Override
+ public boolean fromExternalNetwork(long inDpid, short inPort) {
+ for (Interface intf : interfaces.values()) {
+ if (intf.getDpid() == inDpid && intf.getPort() == inPort) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public Interface getOutgoingInterface(InetAddress dstIpAddress) {
+ return interfacePtrie.match(new Prefix(dstIpAddress.getAddress(), 32));
+ }
+
+ @Override
+ public boolean hasLayer3Configuration() {
+ return !interfaces.isEmpty();
+ }
+
+ @Override
+ public MACAddress getRouterMacAddress() {
+ return bgpdMacAddress;
}
}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/bgproute/GatewayRouter.java b/src/main/java/net/onrc/onos/ofcontroller/bgproute/GatewayRouter.java
deleted file mode 100644
index e893acf..0000000
--- a/src/main/java/net/onrc/onos/ofcontroller/bgproute/GatewayRouter.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package net.onrc.onos.ofcontroller.bgproute;
-
-import net.floodlightcontroller.util.MACAddress;
-import net.onrc.onos.ofcontroller.util.Dpid;
-import net.onrc.onos.ofcontroller.util.IPv4;
-import net.onrc.onos.ofcontroller.util.Port;
-import net.onrc.onos.ofcontroller.util.SwitchPort;
-
-import org.codehaus.jackson.annotate.JsonProperty;
-import org.openflow.util.HexString;
-
-public class GatewayRouter {
- private SwitchPort attachmentPoint = null;
- private long dpid;
- private short port;
- private MACAddress routerMac;
- private IPv4 routerIp;
- private IPv4 myIpAddress;
-
-
- public SwitchPort getAttachmentPoint() {
- if (attachmentPoint == null){
- attachmentPoint = new SwitchPort(new Dpid(dpid), new Port(port));
- }
- return attachmentPoint;
- }
-
- public long getDpid() {
- return dpid;
- }
-
- @JsonProperty("attachmentDpid")
- public void setDpid(String dpid) {
- this.dpid = HexString.toLong(dpid);
- }
-
- public short getPort() {
- return port;
- }
-
- @JsonProperty("attachmentPort")
- public void setPort(short port) {
- this.port = port;
- }
-
- public MACAddress getRouterMac() {
- return routerMac;
- }
-
- @JsonProperty("macAddress")
- public void setRouterMac(String routerMac) {
- this.routerMac = MACAddress.valueOf(routerMac);;
- }
-
- public IPv4 getRouterIp() {
- return routerIp;
- }
-
- @JsonProperty("ipAddress")
- public void setRouterIp(String routerIp) {
- this.routerIp = new IPv4(routerIp);
- }
-
- public IPv4 getMyIpAddress() {
- return myIpAddress;
- }
-
- @JsonProperty("myIpAddress")
- public void setMyIpAddress(String myIpAddress) {
- this.myIpAddress = new IPv4(myIpAddress);
- }
-}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/bgproute/ILayer3InfoService.java b/src/main/java/net/onrc/onos/ofcontroller/bgproute/ILayer3InfoService.java
new file mode 100644
index 0000000..0f14dd6
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/bgproute/ILayer3InfoService.java
@@ -0,0 +1,36 @@
+package net.onrc.onos.ofcontroller.bgproute;
+
+import java.net.InetAddress;
+
+import net.floodlightcontroller.util.MACAddress;
+
+/**
+ * Provides information about the layer 3 properties of the network.
+ * This is based on IP addresses configured on ports in the network.
+ *
+ */
+public interface ILayer3InfoService {
+ //public Collection<Interface> getInterfaces();
+ public boolean isInterfaceAddress(InetAddress address);
+ public boolean inConnectedNetwork(InetAddress address);
+ public boolean fromExternalNetwork(long inDpid, short inPort);
+
+ /**
+ * Retrieves the {@link Interface} object for the interface that packets
+ * to dstIpAddress will be sent out of. Returns null if dstIpAddress is not
+ * in a directly connected network, or if no interfaces are configured.
+ * @param dstIpAddress Destination IP address that we want to match to
+ * an outgoing interface
+ * @return The {@link Interface} object if found, null if not
+ */
+ public Interface getOutgoingInterface(InetAddress dstIpAddress);
+
+ /**
+ * Returns whether this controller has a layer 3 configuration
+ * (i.e. interfaces and IP addresses)
+ * @return True if IP addresses are configured, false if not
+ */
+ public boolean hasLayer3Configuration();
+
+ public MACAddress getRouterMacAddress();
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/bgproute/PushedFlowMod.java b/src/main/java/net/onrc/onos/ofcontroller/bgproute/PushedFlowMod.java
index 56f4c04..fd9ba6f 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/bgproute/PushedFlowMod.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/bgproute/PushedFlowMod.java
@@ -2,6 +2,13 @@
import org.openflow.protocol.OFFlowMod;
+/**
+ * Wraps up a DPID and a OFFlowMod so we know how to delete
+ * the flow if we have to.
+ *
+ * TODO This functionality should be handled by ONOS's flow layer in future.
+ *
+ */
public class PushedFlowMod {
private long dpid;
private OFFlowMod flowMod;
diff --git a/src/main/java/net/onrc/onos/ofcontroller/bgproute/RibEntry.java b/src/main/java/net/onrc/onos/ofcontroller/bgproute/RibEntry.java
index 8087471..1520c60 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/bgproute/RibEntry.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/bgproute/RibEntry.java
@@ -5,8 +5,8 @@
import com.google.common.net.InetAddresses;
public class RibEntry {
- private InetAddress routerId;
- private InetAddress nextHop;
+ private final InetAddress routerId;
+ private final InetAddress nextHop;
public RibEntry(InetAddress routerId, InetAddress nextHop) {
this.routerId = routerId;