Skip to content
This repository was archived by the owner on Nov 13, 2023. It is now read-only.

Commit 269ee2f

Browse files
Sumanth SathyanarayanaSumanth Sathyanarayana
authored andcommitted
Merge branch '1.1-clean' of github.com:mssumanth/flowvisor into 1.1-DEV
2 parents e92d9fe + 2eaee72 commit 269ee2f

File tree

10 files changed

+320
-239
lines changed

10 files changed

+320
-239
lines changed

src/org/flowvisor/FlowVisor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class FlowVisor {
4141

4242
// VERSION
4343

44-
public final static String FLOWVISOR_VERSION = "flowvisor-1.1.3";
44+
public final static String FLOWVISOR_VERSION = "flowvisor-1.1.4";
4545

4646
public final static int FLOWVISOR_DB_VERSION = 2;
4747

src/org/flowvisor/api/FlowTableCallback.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import java.io.InputStreamReader;
44
import java.io.OutputStreamWriter;
55
import java.net.HttpURLConnection;
6-
import java.net.MalformedURLException;
76
import java.net.URL;
87
import java.security.KeyManagementException;
98
import java.security.NoSuchAlgorithmException;
@@ -19,18 +18,13 @@
1918
import javax.net.ssl.X509TrustManager;
2019

2120
import org.apache.commons.codec.binary.Base64;
22-
import org.apache.xmlrpc.XmlRpcException;
2321
import org.apache.xmlrpc.client.XmlRpcClient;
2422
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
2523
import org.eclipse.jetty.http.HttpHeaders;
2624
import org.flowvisor.log.FVLog;
2725
import org.flowvisor.log.LogLevel;
28-
import org.openflow.protocol.statistics.OFStatistics;
29-
30-
import java.util.HashMap;
3126

3227
import com.thetransactioncompany.jsonrpc2.JSONRPC2Request;
33-
import com.thetransactioncompany.*;
3428

3529
public class FlowTableCallback implements Runnable {
3630
String URL;

src/org/flowvisor/classifier/FVClassifier.java

Lines changed: 2 additions & 217 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@
1616
import java.util.concurrent.ConcurrentLinkedQueue;
1717
import java.util.concurrent.TimeUnit;
1818

19-
import org.apache.commons.codec.binary.Hex;
2019
import org.flowvisor.api.FlowTableCallback;
2120
import org.flowvisor.api.TopologyCallback;
2221
import org.flowvisor.config.ConfigError;
2322
import org.flowvisor.config.ConfigurationEvent;
2423
import org.flowvisor.config.FVConfig;
2524

2625
import org.flowvisor.config.FlowMapChangedListener;
27-
import org.flowvisor.config.FlowSpace;
2826
import org.flowvisor.config.FlowSpaceImpl;
2927
import org.flowvisor.config.FlowvisorChangedListener;
3028
import org.flowvisor.config.FlowvisorImpl;
@@ -64,7 +62,6 @@
6462
import org.flowvisor.message.statistics.FVAggregateStatisticsRequest;
6563
import org.flowvisor.message.statistics.FVFlowStatisticsReply;
6664
import org.flowvisor.message.statistics.FVFlowStatisticsRequest;
67-
import org.flowvisor.ofswitch.TopologyController;
6865
import org.flowvisor.openflow.protocol.FVMatch;
6966
import org.flowvisor.resources.SlicerLimits;
7067
import org.flowvisor.resources.ratelimit.FixedIntervalRefillStrategy;
@@ -83,12 +80,8 @@
8380
import org.openflow.protocol.OFType;
8481
import org.openflow.protocol.OFError.OFHelloFailedCode;
8582
import org.openflow.protocol.action.*;
86-
import org.openflow.protocol.statistics.OFFlowStatisticsReply;
8783
import org.openflow.protocol.statistics.OFStatistics;
8884
import org.openflow.protocol.statistics.OFStatisticsType;
89-
import org.openflow.util.HexString;
90-
import org.openflow.util.U16;
91-
import org.openflow.util.U8;
9285

9386
/**
9487
* Map OF messages from the switch to the appropriate slice
@@ -1114,210 +1107,16 @@ public void sendFlowStatsResp(FVSlicer fvSlicer, FVStatisticsRequest original) {
11141107
}
11151108

11161109

1117-
public synchronized void classifyFlowStats(FVStatisticsReply fvStatisticsReply) {
1110+
public synchronized void classifyFlowStats(FVStatisticsReply fvStatisticsReply, HashMap<String,Object> cache) {
11181111
flowStats.clear();
11191112
List<OFStatistics> stats = fvStatisticsReply.getStatistics();
1120-
FVLog.log(LogLevel.DEBUG, this, " Inside classifyFlowStats, stats is: ",stats);
1121-
1122-
List<Object> params = new ArrayList<Object>();
1123-
//Serialize the stats to send it via JSON
1124-
1125-
for (int i=0; i<stats.size(); i++){
1126-
OFFlowStatisticsReply reply = (OFFlowStatisticsReply) stats.get(i);
1127-
1128-
HashMap <String,Object> cache = new HashMap<String,Object>();
1129-
1130-
cache.put(FlowSpace.PRIO, String.valueOf(reply.getPriority()));
1131-
1132-
//Put all the individual action fields into the cache
1133-
//cache.put(FlowSpace.ACTION, reply.getActions().toString());
1134-
for (OFAction act : reply.getActions()) {
1135-
switch (act.getType()) {
1136-
case OUTPUT:
1137-
OFActionOutput out = (OFActionOutput) act;
1138-
cache.put("OFPAT_OUTPUT type", out.getType().toString());
1139-
cache.put("OFPAT_OUTPUT len", U16.f(out.getLength()));
1140-
cache.put("OFPAT_OUTPUT port", U16.f(out.getPort()));
1141-
cache.put("OFPAT_OUTPUT max_len", U16.f(out.getMaxLength()));
1142-
break;
1143-
1144-
case OPAQUE_ENQUEUE:
1145-
OFActionEnqueue enq = (OFActionEnqueue) act;
1146-
cache.put("OFPAT_ENQUEUE type", enq.getType().toString());
1147-
cache.put("OFPAT_ENQUEUE len", U16.f(enq.getLength()));
1148-
cache.put("OFPAT_ENQUEUE port", U16.f(enq.getPort()));
1149-
cache.put("OFPAT_ENQUEUE queue_id", enq.getQueueId());
1150-
break;
1151-
1152-
case SET_VLAN_VID:
1153-
OFActionVirtualLanIdentifier vid = (OFActionVirtualLanIdentifier)act;
1154-
cache.put("OFPAT_SET_VLAN_VID type", vid.getType().toString());
1155-
cache.put("OFPAT_SET_VLAN_VID len", U16.f(vid.getLength()));
1156-
cache.put("OFPAT_SET_VLAN_VID vlan_vid", U16.f(vid.getVirtualLanIdentifier()));
1157-
break;
1158-
1159-
case SET_VLAN_PCP:
1160-
OFActionVirtualLanPriorityCodePoint vpcp = (OFActionVirtualLanPriorityCodePoint) act;
1161-
cache.put("OFPAT_SET_VLAN_PCP type", vpcp.getType().toString());
1162-
cache.put("OFPAT_SET_VLAN_PCP len", U16.f(vpcp.getLength()));
1163-
cache.put("OFPAT_SET_VLAN_PCP vlan_pcp", U8.f(vpcp.getVirtualLanPriorityCodePoint()));
1164-
break;
1165-
1166-
case STRIP_VLAN:
1167-
OFActionStripVirtualLan svlan = (OFActionStripVirtualLan) act;
1168-
cache.put("OFPAT_STRIP_VLAN type", svlan.getType().toString());
1169-
break;
1170-
1171-
case SET_DL_DST:
1172-
OFActionDataLayerDestination dl_dst = (OFActionDataLayerDestination) act;
1173-
cache.put("OFPAT_SET_DL_DST type",dl_dst.getType().toString());
1174-
cache.put("OFPAT_SET_DL_DST len",U16.f(dl_dst.getLength()));
1175-
cache.put("OFPAT_SET_DL_DST dl_addr", HexString.toHexString(dl_dst.getDataLayerAddress()));
1176-
break;
1177-
1178-
case SET_DL_SRC:
1179-
OFActionDataLayerSource dl_src = (OFActionDataLayerSource) act;
1180-
cache.put("OFPAT_SET_DL_SRC type",dl_src.getType().toString());
1181-
cache.put("OFPAT_SET_DL_SRC len",U16.f(dl_src.getLength()));
1182-
cache.put("OFPAT_SET_DL_SRC dl_addr", HexString.toHexString(dl_src.getDataLayerAddress()));
1183-
break;
1184-
1185-
case SET_NW_DST:
1186-
OFActionNetworkLayerDestination nw_dst = (OFActionNetworkLayerDestination) act;
1187-
cache.put("OFPAT_SET_NW_DST type", nw_dst.getType().toString());
1188-
cache.put("OFPAT_SET_NW_DST len", U16.f(nw_dst.getLength()));
1189-
cache.put("OFPAT_SET_NW_DST nw_addr", FlowSpaceUtil.intToIp(nw_dst.getNetworkAddress()));
1190-
break;
11911113

1192-
case SET_NW_SRC:
1193-
OFActionNetworkLayerSource nw_src = (OFActionNetworkLayerSource) act;
1194-
cache.put("OFPAT_SET_NW_SRC type", nw_src.getType().toString());
1195-
cache.put("OFPAT_SET_NW_SRC len", U16.f(nw_src.getLength()));
1196-
cache.put("OFPAT_SET_NW_SRC nw_addr", FlowSpaceUtil.intToIp(nw_src.getNetworkAddress()));
1197-
break;
1198-
1199-
case SET_NW_TOS:
1200-
OFActionNetworkTypeOfService nw_tos = (OFActionNetworkTypeOfService) act;
1201-
cache.put("OFPAT_SET_NW_TOS type", nw_tos.getType().toString());
1202-
cache.put("OFPAT_SET_NW_TOS len", U16.f(nw_tos.getLength()));
1203-
cache.put("OFPAT_SET_NW_TOS nw_tos", U8.f(nw_tos.getNetworkTypeOfService()));
1204-
break;
1205-
1206-
case SET_TP_DST:
1207-
OFActionTransportLayerDestination tp_dst = (OFActionTransportLayerDestination) act;
1208-
cache.put("OFPAT_SET_TP_DST type", tp_dst.getType().toString());
1209-
cache.put("OFPAT_SET_TP_DST len", U16.f(tp_dst.getLength()));
1210-
cache.put("OFPAT_SET_TP_DST tp_port", U16.f(tp_dst.getTransportPort()));
1211-
break;
1212-
1213-
case SET_TP_SRC:
1214-
OFActionTransportLayerSource tp_src = (OFActionTransportLayerSource) act;
1215-
cache.put("OFPAT_SET_TP_SRC type", tp_src.getType().toString());
1216-
cache.put("OFPAT_SET_TP_SRC len", U16.f(tp_src.getLength()));
1217-
cache.put("OFPAT_SET_TP_SRC tp_port", U16.f(tp_src.getTransportPort()));
1218-
break;
1219-
1220-
case VENDOR:
1221-
OFActionVendor ven = (OFActionVendor) act;
1222-
cache.put("OFPAT_VENDOR type", ven.getType().toString());
1223-
cache.put("OFPAT_VENDOR len", U16.f(ven.getLength()));
1224-
cache.put("OFPAT_VENDOR vendor", ven.getVendor());
1225-
break;
1226-
1227-
default:
1228-
//Error
1229-
FVLog.log(LogLevel.ALERT, this, "Shouldn't have come here- No default ActionType ");
1230-
break;
1231-
}
1232-
}
1233-
1234-
//Put all the individual match fields into the cache
1235-
//cache.put("OFMatch", reply.getMatch().toString());
1236-
int wildcards = reply.getMatch().getWildcards();
1237-
if((wildcards & OFMatch.OFPFW_IN_PORT) == 0)
1238-
cache.put(FlowSpace.INPORT, U16.f(reply.getMatch().getInputPort()));
1239-
if((wildcards & OFMatch.OFPFW_DL_DST) == 0)
1240-
cache.put(FlowSpace.DLDST, HexString.toHexString(reply.getMatch().getDataLayerDestination()));
1241-
if((wildcards & OFMatch.OFPFW_DL_SRC) == 0)
1242-
cache.put(FlowSpace.DLSRC, HexString.toHexString(reply.getMatch().getDataLayerSource()));
1243-
if((wildcards & OFMatch.OFPFW_DL_TYPE) == 0)
1244-
cache.put(FlowSpace.DLTYPE, Integer.toHexString(U16.f(reply.getMatch().getDataLayerType())));
1245-
if((wildcards & OFMatch.OFPFW_DL_VLAN) == 0)
1246-
cache.put(FlowSpace.VLAN, U16.f(reply.getMatch().getDataLayerVirtualLan()));
1247-
if((wildcards & OFMatch.OFPFW_DL_VLAN_PCP) == 0)
1248-
cache.put(FlowSpace.VPCP, U8.f(reply.getMatch().getDataLayerVirtualLanPriorityCodePoint()));
1249-
if(reply.getMatch().getNetworkDestinationMaskLen() > 0)
1250-
cache.put(FlowSpace.NWDST, cidrToString(reply.getMatch().getNetworkDestination(),reply.getMatch().getNetworkDestinationMaskLen()));
1251-
if(reply.getMatch().getNetworkSourceMaskLen() > 0)
1252-
cache.put(FlowSpace.NWSRC, cidrToString(reply.getMatch().getNetworkSource(),reply.getMatch().getNetworkSourceMaskLen()));
1253-
if((wildcards & OFMatch.OFPFW_NW_PROTO) == 0)
1254-
cache.put(FlowSpace.NWPROTO, reply.getMatch().getNetworkProtocol());
1255-
if((wildcards & OFMatch.OFPFW_NW_TOS) == 0)
1256-
cache.put(FlowSpace.NWTOS,reply.getMatch().getNetworkTypeOfService());
1257-
if((wildcards & OFMatch.OFPFW_TP_DST) == 0)
1258-
cache.put(FlowSpace.TPDST,reply.getMatch().getTransportDestination());
1259-
if((wildcards & OFMatch.OFPFW_TP_SRC) == 0)
1260-
cache.put(FlowSpace.TPSRC,reply.getMatch().getTransportSource());
1261-
1262-
cache.put(FlowSpace.DPID, getDPID());
1263-
cache.put("tableId ", HexString.toHexString(reply.getTableId()));
1264-
cache.put("nanoSecondDuration ", reply.getDurationNanoseconds());
1265-
cache.put("durationInSeconds ",reply.getDurationSeconds());
1266-
cache.put("hardTimeOut ",reply.getHardTimeout());
1267-
cache.put("idleTimeOut ", reply.getIdleTimeout());
1268-
cache.put("cookie ",reply.getCookie());
1269-
cache.put("packetCount ", reply.getPacketCount());
1270-
cache.put("byteCount ",reply.getByteCount());
1271-
cache.put("length ", reply.getLength());
1272-
1273-
//cache.put(FlowSpace.DLDST, HexString.toHexString(reply.getMatch().getDataLayerDestination()));
1274-
//cache.put(FlowSpace.DLSRC, HexString.toHexString(reply.getMatch().getDataLayerSource()));
1275-
//cache.put(FlowSpace.DLTYPE, reply.getMatch().getDataLayerType());
1276-
//cache.put(FlowSpace.INPORT, reply.getMatch().getInputPort());
1277-
//cache.put(FlowSpace.NWDST, reply.getMatch().getNetworkDestination());
1278-
//cache.put(FlowSpace.NWPROTO, reply.getMatch().getNetworkProtocol());
1279-
//cache.put(FlowSpace.NWSRC, reply.getMatch().getNetworkSource());
1280-
//cache.put(FlowSpace.NWTOS, reply.getMatch().getNetworkTypeOfService());
1281-
//cache.put(FlowSpace.TPDST, reply.getMatch().getTransportDestination());
1282-
//cache.put(FlowSpace.TPSRC, reply.getMatch().getTransportSource());
1283-
//cache.put(FlowSpace.VLAN, reply.getMatch().getDataLayerVirtualLan());
1284-
//cache.put(FlowSpace.VPCP, reply.getMatch().getDataLayerVirtualLanPriorityCodePoint());
1285-
//cache.put(FlowSpace.WILDCARDS, reply.getMatch().getWildcards());
1286-
1287-
params.add(cache);
1288-
}
1289-
//Probably not the most efficient way of doing but for now -
1290-
/*HashMap <String,Object> cache = new HashMap<String,Object>();
1291-
int initOffset=0;
1292-
int finalOffset=0;
1293-
1294-
for (int i=0; i<stats.size(); i++){
1295-
String st = stats.toString();
1296-
1297-
String temp = new String();
1298-
1299-
initOffset = stats.indexOf("=", stats.indexOf("length") + "length".length());
1300-
finalOffset = stats.indexOf(",",initOffset);
1301-
temp = stats.substring(initOffset+1, finalOffset);
1302-
System.out.println("Length is: "+temp);
1303-
cache.put("length", temp);
1304-
1305-
initOffset = stats.indexOf("=", stats.indexOf("tableId") + "tableId".length());
1306-
finalOffset = stats.indexOf(",",initOffset);
1307-
System.out.println("initOffset : "+initOffset+"finalOffset: "+finalOffset);
1308-
temp = stats.substring(initOffset+1, finalOffset);
1309-
System.out.println("Temp is: "+temp);
1310-
cache.put("tableId", temp);
1311-
1312-
System.out.println("Cache is: "+cache);
1313-
1314-
}*/
13151114
//Adding for registering a FlowTable
13161115
if (this.registeredForFlowTable == true && !this.flowTableList.isEmpty()){
13171116
FVLog.log(LogLevel.DEBUG, this, "Inside registeredForFlowTable ",this.registeredForFlowTable);
13181117
for (FlowTableCallback fcb : this.flowTableList) {
13191118
fcb.clearParams();
1320-
fcb.setParams(params);
1119+
fcb.setParams(cache);
13211120
fcb.spawn(); // Is this ok to use run, there will be only one thread of fcb per classifier?
13221121

13231122
}
@@ -1391,19 +1190,5 @@ public void deRegisterCallBack(String userName, String method,String cookie, Top
13911190
it.remove();
13921191
}
13931192
}
1394-
1395-
private String cidrToString(int ip, int prefix) {
1396-
String str;
1397-
if (prefix >= 32) {
1398-
str = OFMatch.ipToString(ip);;
1399-
1400-
} else {
1401-
// use the negation of mask to fake endian magic
1402-
int mask = ~((1 << (32 - prefix)) - 1);
1403-
str = OFMatch.ipToString(ip & mask) + "/" + prefix;
1404-
}
1405-
1406-
return str;
1407-
}
14081193

14091194
}

src/org/flowvisor/message/lldp/LLDPUtil.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
package org.flowvisor.message.lldp;
55

66
import java.nio.ByteBuffer;
7-
import java.util.List;
87

98
import org.flowvisor.FlowVisor;
109
import org.flowvisor.classifier.FVClassifier;
@@ -13,9 +12,6 @@
1312
import org.flowvisor.message.FVPacketIn;
1413
import org.flowvisor.message.FVPacketOut;
1514
import org.flowvisor.slicer.FVSlicer;
16-
import org.openflow.protocol.OFPhysicalPort;
17-
import org.openflow.protocol.action.OFAction;
18-
import org.openflow.protocol.action.OFActionOutput;
1915

2016
/**
2117
* Set of utilities for handling our LLDP virtualization hacks

src/org/flowvisor/message/statistics/FVAggregateStatisticsReply.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
package org.flowvisor.message.statistics;
22

3+
import java.util.HashMap;
4+
import java.util.List;
5+
36
import org.flowvisor.classifier.FVClassifier;
47
import org.flowvisor.log.FVLog;
58
import org.flowvisor.log.LogLevel;
69
import org.flowvisor.message.FVStatisticsReply;
710
import org.flowvisor.message.FVStatisticsRequest;
811
import org.flowvisor.slicer.FVSlicer;
912
import org.openflow.protocol.statistics.OFAggregateStatisticsReply;
13+
import org.openflow.protocol.statistics.OFStatistics;
1014

1115
public class FVAggregateStatisticsReply extends OFAggregateStatisticsReply
1216
implements SlicableStatistic, ClassifiableStatistic {
1317

14-
18+
private HashMap <String, Object> statsMap = new HashMap<String, Object>();
1519

1620
@Override
1721
public void classifyFromSwitch(FVStatisticsReply msg, FVClassifier fvClassifier) {
1822
FVLog.log(LogLevel.WARN, fvClassifier, "dropping unexpected msg: "
1923
+ msg);
24+
statsMap = toMap(msg);
2025
}
2126

2227
@Override
@@ -26,4 +31,22 @@ public void sliceFromController(FVStatisticsRequest msg, FVClassifier fvClassifi
2631
+ msg);
2732

2833
}
34+
35+
private HashMap<String, Object> toMap(FVStatisticsReply msg) {
36+
List<OFStatistics> stats = msg.getStatistics();
37+
HashMap <String,Object> cache = new HashMap<String,Object>();
38+
39+
for (int i=0; i<stats.size(); i++){
40+
OFAggregateStatisticsReply reply = (OFAggregateStatisticsReply) stats.get(i);
41+
cache.put("packet_count", reply.getPacketCount());
42+
cache.put("byte_count", reply.getByteCount());
43+
cache.put("flow_count", reply.getFlowCount());
44+
}
45+
return cache;
46+
}
47+
48+
public HashMap<String,Object> getMap(){
49+
return statsMap;
50+
}
51+
2952
}

0 commit comments

Comments
 (0)