Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 23 additions & 28 deletions Torpedo/src/etri/sdn/controller/OFController.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,7 @@ public void run() {
} catch ( Exception | Error e ) {
logger.error(e.getMessage());
this.controller.removeSelf();
return; // end this controller thread.
}
}
}

/**
Expand Down Expand Up @@ -426,29 +425,27 @@ public void addSwitch(long id, IOFSwitch sw) {
public final boolean handleDisconnectEvent(Connection conn) {

assert( conn.getSwitch() != null );

if ( conn.getSwitch() != null ) {

try {
conn.getSwitch().getId();

for (OFModule m: modules) {
m.processDisconnect(conn);
}
} catch ( RuntimeException e ) {
// FEATURES_REPLY is not exchanged.
}

try {
switches.remove( conn.getSwitch().getId() );
} catch ( RuntimeException e ) {
// this catch clause is for catching RuntimeException
// raised within conn.getSwitch().getId().
// this exception is raised when the connection is abruptly cut
// before FEATURE_REPLY is received from the peer.
// So, we do nothing for this exception.
}
}


try {
conn.getSwitch().getId();

for (OFModule m: modules) {
m.processDisconnect(conn);
}
} catch ( RuntimeException e ) {
// FEATURES_REPLY is not exchanged.
}

try {
switches.remove( conn.getSwitch().getId() );
} catch ( RuntimeException e ) {
// this catch clause is for catching RuntimeException
// raised within conn.getSwitch().getId().
// this exception is raised when the connection is abruptly cut
// before FEATURE_REPLY is received from the peer.
// So, we do nothing for this exception.
}
return true;
}

Expand Down Expand Up @@ -488,9 +485,7 @@ public final OFModel[] getModels() {
if ( models == null ) {
continue;
}
for ( int i = 0; i < models.length; ++i ) {
l.add( models[i] );
}
Collections.addAll(l, models);
}

return l.toArray(new OFModel[l.size()]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,9 @@ protected boolean updateAttachmentPoint() {

// Prepare the new attachment point list.
if (moved) {
if ( newMap != null ) {
this.attachmentPoints.retainAll( newMap.values() );
this.attachmentPoints.addAllAbsent( newMap.values() );
}
}
this.attachmentPoints.retainAll( newMap.values() );
this.attachmentPoints.addAllAbsent( newMap.values() );
}

// empty the old ap list.
this.oldAPs.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,19 @@ protected boolean matches(Device value) {
if (sps == null) return false;

match = false;
for (SwitchPort sp : sps) {
if (switchDPID != null) {
if (switchDPID.longValue() != sp.getSwitchDPID())
return false;
}
if (switchPort != null) {
if (! switchPort.equals(sp.getPort()))
return false;
}
match = true;
break;
}
if (sps.length > 0) {
SwitchPort sp = sps[0];
if (switchDPID != null) {
if (switchDPID.longValue() != sp.getSwitchDPID())
return false;
}
if (switchPort != null) {
if (!switchPort.equals(sp.getPort()))
return false;
}
match = true;
}

if (!match) return false;
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private static class DeviceUpdate {
* The enum set of DeviceUpdate events
*/
public enum Change {
ADD, DELETE, CHANGE;
ADD, DELETE, CHANGE,
}

/**
Expand Down Expand Up @@ -1389,10 +1389,8 @@ public void removeSuppressAPs(long swId, OFPort port) {
* @return true if suppressedAPs includes switchPort, false otherwise
*/
public boolean isSuppressedAP(SwitchPort switchPort) {
if ( suppressedAPs.contains(switchPort) )
return true;
return false;
}
return suppressedAPs.contains(switchPort);
}

/**
* Returns information of devices that have more than one attachment point.
Expand Down Expand Up @@ -1507,7 +1505,6 @@ public void handle(Request request, Response response) {
response.setEntity(r, MediaType.APPLICATION_JSON);
} catch (Exception e) {
e.printStackTrace();
return;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class Entity implements Comparable<Entity> {
*
* @see etri.sdn.controller.module.devicemanager.Entity
*/
protected static int ACTIVITY_TIMEOUT = 30000;
protected static final int ACTIVITY_TIMEOUT = 30000;

/**
* The MAC address associated with this entity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ public class FirewallEntryTable extends TreeMap<String, Map<String, Object>>{
*
*/
public Map<String, Object> getFirewallEntry(String ruleid) {
Map<String, Object> entry = super.get(ruleid);
return entry;
return super.get(ruleid);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ public static String jsonToSubnetMask(String fmJson) throws IOException {
continue;

if (n == "subnet-mask") {
result = (String)jp.getText();
result = jp.getText();
}
}

Expand Down Expand Up @@ -541,7 +541,7 @@ public static FirewallRule jsonToFirewallRule(String fmJson) throws IOException

// This is currently only applicable for remove(). In store(), ruleid takes a random number
if (n == "ruleid") {
rule.ruleid = Integer.parseInt((String)jp.getText());
rule.ruleid = Integer.parseInt(jp.getText());
}

// This assumes user having dpid info for involved switches
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ final class OFFirewallRuleSerializer extends JsonSerializer<FirewallRule> {

@Override
public void serialize(FirewallRule rule, JsonGenerator jgen, SerializerProvider provider)
throws IOException, JsonProcessingException {
throws IOException {

jgen.writeStartObject();
jgen.writeNumberField("ruleid", (Integer)rule.ruleid);
jgen.writeNumberField("ruleid", rule.ruleid);
jgen.writeNumberField("dpid", rule.dpid);
jgen.writeNumberField("in_port", rule.in_port);
jgen.writeNumberField("dl_src", rule.dl_src);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,6 @@ protected void doFlood(IOFSwitch sw, OFPacketIn pi, MessageContext cntx) {
sw, pi, po, e);
}

return;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,9 @@ private boolean processPacketInMessage(Connection conn, MessageContext context,
if ( reverse != null ) {
target.setExact(MatchField.ETH_SRC, destMac);
}

this.writeFlowMod(conn.getSwitch(), OFFlowModCommand.ADD, OFBufferId.NO_BUFFER,

assert reverse != null;
this.writeFlowMod(conn.getSwitch(), OFFlowModCommand.ADD, OFBufferId.NO_BUFFER,
reverse.build(), inputPort, out );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public interface ILinkDiscovery {
*/
public enum SwitchType {
BASIC_SWITCH, CORE_SWITCH
};
}

/**
* This enum defines the type of each link.
Expand Down Expand Up @@ -55,5 +55,5 @@ public String toString() {
return "tunnel";
}
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,6 @@ public void handle(Request request, Response response) {
response.setEntity(r, MediaType.APPLICATION_JSON);
} catch (Exception e) {
e.printStackTrace();
return;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,19 @@ class NetworkConfiguration extends OFModel {
private OFMOpenstackML2Connector parent = null;
private RESTApi[] apis = null;

public NetworkConfiguration(OFMOpenstackML2Connector parent)
{
this.parent = parent;
this.apis = Arrays.asList(
new RESTApi(RestNetwork.neutronNetAll, new RestNetwork(this)),
new RESTApi(RestNetwork.neutronNet, new RestNetwork(this)),
new RESTApi(RestNetwork.neutronNetIRIS, new RestNetwork(this)),
new RESTApi(RestPort.neutronPortAll, new RestPort(this)),
new RESTApi(RestPort.neutronPort, new RestPort(this)),
new RESTApi(RestPort.neutronPortIRIS, new RestPort(this)),
new RESTApi(RestSubnet.neutronSubnetAll, new RestSubnet(this)),
new RESTApi(RestSubnet.neutronSubnet, new RestSubnet(this)),
new RESTApi(RestSubnet.neutronSubnetIRIS, new RestSubnet(this))
).toArray( new RESTApi[0] );
public NetworkConfiguration(OFMOpenstackML2Connector parent) {
this.parent = parent;
this.apis = new RESTApi[]{
new RESTApi(RestNetwork.neutronNetAll, new RestNetwork(this)),
new RESTApi(RestNetwork.neutronNet, new RestNetwork(this)),
new RESTApi(RestNetwork.neutronNetIRIS, new RestNetwork(this)),
new RESTApi(RestPort.neutronPortAll, new RestPort(this)),
new RESTApi(RestPort.neutronPort, new RestPort(this)),
new RESTApi(RestPort.neutronPortIRIS, new RestPort(this)),
new RESTApi(RestSubnet.neutronSubnetAll, new RestSubnet(this)),
new RESTApi(RestSubnet.neutronSubnet, new RestSubnet(this)),
new RESTApi(RestSubnet.neutronSubnetIRIS, new RestSubnet(this)),
};
}

OFMOpenstackML2Connector getModule() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public String listNetworks(String netId, String netKey, String netValue) {
Map<String, Object> vInfo = omm.readValue(jsonStr, new TypeReference<Map<String, Object>>(){});

for(Entry<String, Object> vEntry : vInfo.entrySet()) {
String vEntryKey = vEntry.getKey() == null ? "null" : vEntry.getKey().toString();
String vEntryKey = vEntry.getKey() == null ? "null" : vEntry.getKey();
String vEntryValue = vEntry.getValue() == null ? "null" : vEntry.getValue().toString();

if(netKey.equals(vEntryKey) && netValue.equals(vEntryValue)) {
Expand Down Expand Up @@ -383,7 +383,7 @@ public String listSubnets(String subId, String subKey, String subValue) {
Map<String, Object> vInfo = omm.readValue(jsonStr, new TypeReference<Map<String, Object>>(){});

for(Entry<String, Object> vEntry : vInfo.entrySet()) {
String vEntryKey = vEntry.getKey() == null ? "null" : vEntry.getKey().toString();
String vEntryKey = vEntry.getKey() == null ? "null" : vEntry.getKey();
String vEntryValue = vEntry.getValue() == null ? "null" : vEntry.getValue().toString();

if(subKey.equals(vEntryKey) && subValue.equals(vEntryValue)) {
Expand Down Expand Up @@ -513,7 +513,7 @@ public String listPorts(String porId, String porKey, String porValue) {
Map<String, Object> vInfo = omm.readValue(jsonStr, new TypeReference<Map<String, Object>>(){});

for(Entry<String, Object> vEntry : vInfo.entrySet()) {
String vEntryKey = vEntry.getKey() == null ? "null" : vEntry.getKey().toString();
String vEntryKey = vEntry.getKey() == null ? "null" : vEntry.getKey();
String vEntryValue = vEntry.getValue() == null ? "null" : vEntry.getValue().toString();

if(porKey.equals(vEntryKey) && porValue.equals(vEntryValue)) {
Expand Down
13 changes: 0 additions & 13 deletions Torpedo/src/etri/sdn/controller/module/ml2/VirtualNetwork.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ public VirtualNetwork(NetworkDefinition network) {
this.shared = network.shared;
this.netId = network.netId;
this.provider_segmentation_id = network.provider_segmentation_id;

return;
}

/**
Expand All @@ -49,7 +47,6 @@ public VirtualNetwork(NetworkDefinition network) {
*/
public void setNetName(String netName){
this.netName = netName;
return;
}

/**
Expand All @@ -58,7 +55,6 @@ public void setNetName(String netName){
*/
public void setProviderPhysicalNetwork(String provider_physical_network){
this.provider_physical_network = provider_physical_network;
return;
}

/**
Expand All @@ -67,7 +63,6 @@ public void setProviderPhysicalNetwork(String provider_physical_network){
*/
public void setAdminStateUp(String admin_state_up){
this.admin_state_up = admin_state_up;
return;
}

/**
Expand All @@ -76,7 +71,6 @@ public void setAdminStateUp(String admin_state_up){
*/
public void setProviderNetworkType(String provider_network_type){
this.provider_network_type = provider_network_type;
return;
}

/**
Expand All @@ -85,7 +79,6 @@ public void setProviderNetworkType(String provider_network_type){
*/
public void setRouterExternal(String router_external){
this.router_external = router_external;
return;
}

/**
Expand All @@ -94,7 +87,6 @@ public void setRouterExternal(String router_external){
*/
public void setShared(String shared){
this.shared = shared;
return;
}

/**
Expand All @@ -103,19 +95,14 @@ public void setShared(String shared){
*/
public void setProviderSegmentationId(String provider_segmentation_id){
this.provider_segmentation_id = provider_segmentation_id;
return;
}

public void addSubnets(String subId, String subName) {
this.subNameToGuid.put(subId, subName);

return;
}

public void delSubnets(String subId) {
this.subNameToGuid.remove(subId);

return;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
public class VirtualNetworkSerializer extends JsonSerializer<VirtualNetwork> {

@Override
public void serialize(VirtualNetwork vNet, JsonGenerator jGen, SerializerProvider serializer) throws IOException, JsonProcessingException {
public void serialize(VirtualNetwork vNet, JsonGenerator jGen, SerializerProvider serializer) throws IOException {
jGen.writeStartObject();
jGen.writeStringField("status", vNet.status);

jGen.writeArrayFieldStart("subnets");
for (Entry<String, String> entry : vNet.subNameToGuid.entrySet()) {
jGen.writeString(entry.getKey().toString());
jGen.writeString(entry.getKey());
}
jGen.writeEndArray();

Expand Down
Loading