Merge pull request #445 from jonohart/master
Various improvements and bug fixes
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 813f095..d84d30d 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/bgproute/BgpRoute.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/bgproute/BgpRoute.java
@@ -122,6 +122,7 @@
private Map<InetAddress, BgpPeer> bgpPeers;
private SwitchPort bgpdAttachmentPoint;
private MACAddress bgpdMacAddress;
+ private short vlan;
//True when all switches have connected
private volatile boolean switchesConnected = false;
@@ -183,8 +184,8 @@
}
}
- private void readGatewaysConfiguration(String gatewaysFilename){
- File gatewaysFile = new File(gatewaysFilename);
+ private void readConfiguration(String configFilename){
+ File gatewaysFile = new File(configFilename);
ObjectMapper mapper = new ObjectMapper();
try {
@@ -205,6 +206,7 @@
new Port(config.getBgpdAttachmentPort()));
bgpdMacAddress = config.getBgpdMacAddress();
+ vlan = config.getVlan();
} catch (JsonParseException e) {
log.error("Error in JSON file", e);
System.exit(1);
@@ -313,7 +315,7 @@
}
log.debug("Config file set to {}", configFilename);
- readGatewaysConfiguration(configFilename);
+ readConfiguration(configFilename);
}
@Override
@@ -322,7 +324,7 @@
topologyService.addListener(this);
floodlightProvider.addOFSwitchListener(this);
- proxyArp.startUp();
+ proxyArp.startUp(vlan);
floodlightProvider.addOFMessageListener(OFType.PACKET_IN, proxyArp);
@@ -491,7 +493,7 @@
Map<Long, Interface> srcInterfaces = new HashMap<Long, Interface>();
for (Interface intf : interfaces.values()) {
if (!srcInterfaces.containsKey(intf.getDpid())
- && intf != egressInterface) {
+ && !intf.equals(egressInterface)) {
srcInterfaces.put(intf.getDpid(), intf);
}
}
@@ -693,7 +695,7 @@
List<PushedFlowMod> pushedFlows = new ArrayList<PushedFlowMod>();
for (Interface srcInterface : interfaces.values()) {
- if (dstInterface.getName().equals(srcInterface.getName())){
+ if (dstInterface.equals(srcInterface)){
continue;
}
@@ -1083,7 +1085,7 @@
private void checkTopologyReady(){
for (Interface dstInterface : interfaces.values()) {
for (Interface srcInterface : interfaces.values()) {
- if (dstInterface == srcInterface) {
+ if (dstInterface.equals(srcInterface)) {
continue;
}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/bgproute/Configuration.java b/src/main/java/net/onrc/onos/ofcontroller/bgproute/Configuration.java
index 1d90edc..7fabc72 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/bgproute/Configuration.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/bgproute/Configuration.java
@@ -12,6 +12,7 @@
private long bgpdAttachmentDpid;
private short bgpdAttachmentPort;
private MACAddress bgpdMacAddress;
+ private short vlan;
private List<String> switches;
private List<Interface> interfaces;
private List<BgpPeer> peers;
@@ -50,6 +51,15 @@
public List<String> getSwitches() {
return Collections.unmodifiableList(switches);
}
+
+ @JsonProperty("vlan")
+ public void setVlan(short vlan) {
+ this.vlan = vlan;
+ }
+
+ public short getVlan() {
+ return vlan;
+ }
@JsonProperty("switches")
public void setSwitches(List<String> switches) {
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 48b60d8..5db8f0a 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/bgproute/Interface.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/bgproute/Interface.java
@@ -59,4 +59,31 @@
public int getPrefixLength() {
return prefixLength;
}
+
+ @Override
+ public boolean equals(Object other) {
+ if (other == null || !(other instanceof Interface)) {
+ return false;
+ }
+
+ Interface otherInterface = (Interface)other;
+
+ //Don't check switchPort as it's comprised of dpid and port
+ return (name.equals(otherInterface.name)) &&
+ (dpid == otherInterface.dpid) &&
+ (port == otherInterface.port) &&
+ (ipAddress.equals(otherInterface.ipAddress)) &&
+ (prefixLength == otherInterface.prefixLength);
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 17;
+ hash = 31 * hash + name.hashCode();
+ hash = 31 * hash + (int)(dpid ^ dpid >>> 32);
+ hash = 31 * hash + (int)port;
+ hash = 31 * hash + ipAddress.hashCode();
+ hash = 31 * hash + prefixLength;
+ return hash;
+ }
}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/proxyarp/ProxyArpManager.java b/src/main/java/net/onrc/onos/ofcontroller/proxyarp/ProxyArpManager.java
index b6a9591..0151212 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/proxyarp/ProxyArpManager.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/proxyarp/ProxyArpManager.java
@@ -52,6 +52,9 @@
private final ILayer3InfoService layer3;
private final IRestApiService restApi;
+ private short vlan;
+ private static final short NO_VLAN = 0;
+
private final ArpCache arpCache;
private final SetMultimap<InetAddress, ArpRequest> arpRequests;
@@ -117,7 +120,10 @@
HashMultimap.<InetAddress, ArpRequest>create());
}
- public void startUp() {
+ public void startUp(short vlan) {
+ this.vlan = vlan;
+ log.info("vlan set to {}", this.vlan);
+
restApi.addRestletRoutable(new ArpWebRoutable());
Timer arpTimer = new Timer("arp-processing");
@@ -361,6 +367,11 @@
.setEtherType(Ethernet.TYPE_ARP)
.setPayload(arpRequest);
+ if (vlan != NO_VLAN) {
+ eth.setVlanID(vlan)
+ .setPriorityCode((byte)0);
+ }
+
sendArpRequestToSwitches(ipAddress, eth.serialize());
}
@@ -492,12 +503,19 @@
.setTargetHardwareAddress(arpRequest.getSenderHardwareAddress())
.setTargetProtocolAddress(arpRequest.getSenderProtocolAddress());
+
+
Ethernet eth = new Ethernet();
eth.setDestinationMACAddress(arpRequest.getSenderHardwareAddress())
.setSourceMACAddress(targetMac.toBytes())
.setEtherType(Ethernet.TYPE_ARP)
.setPayload(arpReply);
+ if (vlan != NO_VLAN) {
+ eth.setVlanID(vlan)
+ .setPriorityCode((byte)0);
+ }
+
List<OFAction> actions = new ArrayList<OFAction>();
actions.add(new OFActionOutput(port));
diff --git a/web/topology_rest.py b/web/topology_rest.py
index ea33a00..bac3113 100755
--- a/web/topology_rest.py
+++ b/web/topology_rest.py
@@ -397,28 +397,28 @@
if switches[sw_id]['group'] != 0:
switches[sw_id]['group'] = controllers.index(ctrl) + 1
- try:
- v1 = "00:00:00:00:00:0a:0d:00"
+# try:
+# v1 = "00:00:00:00:00:0a:0d:00"
# v1 = "00:00:00:00:00:0d:00:d1"
- p1=1
- v2 = "00:00:00:00:00:0b:0d:03"
+# p1=1
+# v2 = "00:00:00:00:00:0b:0d:03"
# v2 = "00:00:00:00:00:0d:00:d3"
- p2=1
- command = "curl -s http://%s:%s/wm/topology/route/%s/%s/%s/%s/json" % (RestIP, RestPort, v1, p1, v2, p2)
- result = os.popen(command).read()
- parsedResult = json.loads(result)
- except:
- log_error("No route")
- parsedResult = {}
+# p2=1
+# command = "curl -s http://%s:%s/wm/topology/route/%s/%s/%s/%s/json" % (RestIP, RestPort, v1, p1, v2, p2)
+# result = os.popen(command).read()
+# parsedResult = json.loads(result)
+# except:
+# log_error("No route")
+# parsedResult = {}
- path = []
- if parsedResult.has_key('flowEntries'):
- flowEntries= parsedResult['flowEntries']
- for i, v in enumerate(flowEntries):
- if i < len(flowEntries) - 1:
- sdpid= flowEntries[i]['dpid']['value']
- ddpid = flowEntries[i+1]['dpid']['value']
- path.append( (sdpid, ddpid))
+ #path = []
+ #if parsedResult.has_key('flowEntries'):
+ # flowEntries= parsedResult['flowEntries']
+ # for i, v in enumerate(flowEntries):
+ # if i < len(flowEntries) - 1:
+ # sdpid= flowEntries[i]['dpid']['value']
+ # ddpid = flowEntries[i+1]['dpid']['value']
+ # path.append( (sdpid, ddpid))
try:
command = "curl -s \'http://%s:%s/wm/core/topology/links/json\'" % (RestIP, RestPort)
@@ -441,12 +441,12 @@
link['source'] = src_id
link['target'] = dst_id
- onpath = 0
- for (s,d) in path:
- if s == v['src-switch'] and d == v['dst-switch']:
- onpath = 1
- break
- link['type'] = onpath
+ #onpath = 0
+ #for (s,d) in path:
+ # if s == v['src-switch'] and d == v['dst-switch']:
+ # onpath = 1
+ # break
+ #link['type'] = onpath
links.append(link)