]
},
{
- "name": "Tunnel PCP Trust",
+ "name": "Tunnel DSCP Trust",
"doc": [
"Classify traffic class and color based on VLAN PCP field."
],
"instruction_set": [
{
"instruction": "GOTO_TABLE",
- "table": "MPLS L2 Port DSCP Trust"
+ "table": "MPLS L2 Port DSCP Trust"
},
{
"instruction": "APPLY_ACTIONS",
"instruction_set": [
{
"instruction": "GOTO_TABLE",
- "table": "MPLS L2 Port DSCP Trust"
+ "table": "MPLS L2 Port DSCP Trust"
},
{
"instruction": "APPLY_ACTIONS",
"instruction_set": [
{
"instruction": "GOTO_TABLE",
- "table": "MPLS L2 Port PCP Trust"
+ "table": "MPLS L2 Port PCP Trust"
},
{
"instruction": "APPLY_ACTIONS",
},
{
"instruction": "GOTO_TABLE",
- "table": "PolicyACL"
+ "table": "Policy ACL"
}
]
},
}
]
}
- ]
+ ],
+ "built_in_flow_mods": []
},
{
"name": "MPLS L2 Port DSCP Trust",
"zero_or_one": [
{
"instruction": "GOTO_TABLE",
- "table": "PolicyACL"
+ "table": "Policy ACL"
}
]
},
"zero_or_one": [
{
"instruction": "GOTO_TABLE",
- "table": "PolicyACL"
+ "table": "Policy ACL"
}
]
},
"zero_or_one": [
{
"instruction": "GOTO_TABLE",
- "table": "PolicyACL"
+ "table": "Policy ACL"
}
]
},
"zero_or_one": [
{
"instruction": "GOTO_TABLE",
- "table": "PolicyACL"
+ "table": "Policy ACL"
}
]
},
"instruction_set": [
{
"instruction": "GOTO_TABLE",
- "table": "MPLS 2"
+ "table": "MPLS 3"
},
{
"instruction": "APPLY_ACTIONS",
"zero_or_one": [
{
"instruction": "GOTO_TABLE",
- "table": "PolicyACL"
+ "table": "Policy ACL"
}
]
},
"zero_or_one": [
{
"instruction": "GOTO_TABLE",
- "table": "PolicyACL"
+ "table": "Policy ACL"
}
]
},
"zero_or_one": [
{
"instruction": "GOTO_TABLE",
- "table": "PolicyACL"
+ "table": "Policy ACL"
}
]
},
"instruction_set": [
{
"instruction": "GOTO_TABLE",
- "table": "MPLS 2"
+ "table": "MPLS 3"
},
{
"instruction": "APPLY_ACTIONS",
"zero_or_one": [
{
"instruction": "GOTO_TABLE",
- "table": "PolicyACL"
+ "table": "Policy ACL"
}
]
},
"Actions based on packet color.",
"Must be separate from L2 Policer table."
],
- "flow_mod_types": []
+ "flow_mod_types": [],
+ "built_in_flow_mods": []
},
{
"name": "Policy ACL",
}
]
}
-}
\ No newline at end of file
+}
import org.opendaylight.yang.gen.v1.urn.onf.ttp.rev140711.flow_mod.properties.instruction_set.ExactlyOne;
import org.opendaylight.yang.gen.v1.urn.onf.ttp.rev140711.flow_mod.properties.instruction_set.ZeroOrOne;
import org.opendaylight.yang.gen.v1.urn.onf.ttp.rev140711.opendaylight.ttps.table.type.patterns.TableTypePattern;
+import org.opendaylight.yang.gen.v1.urn.onf.ttp.rev140711.table.type.pattern.properties.NDMMetadata;
+import org.opendaylight.yang.gen.v1.urn.onf.ttp.rev140711.table.type.pattern.properties.NDMMetadataBuilder;
import org.opendaylight.yang.gen.v1.urn.onf.ttp.rev140711.table.type.pattern.properties.FlowTables;
import org.opendaylight.yang.gen.v1.urn.onf.ttp.rev140711.table.type.pattern.properties.flow_tables.FlowModTypes;
+import org.opendaylight.yang.gen.v1.urn.onf.ttp.rev140711.table.type.pattern.properties.flow_tables.BuiltInFlowMods;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
System.out.println("<cmd> validate <ttp-file> // check the syntax of the ttp");
System.out.println("<cmd> compare <ttp-file1> <ttp-file2> // check 2 ttps for common flow paths");
System.out.println("<cmd> dot <ttp-file> // generate dot formatted table map graphic to stdout");
+ System.out.println("<cmd> flowpaths <ttp-file> // generate list of flowpaths in ttp");
break;
case "format":
case "validate":
prettyPrintTTP(odlTTPs);
}
break;
+ case "flowpaths":
+ if (args.length != 2) {
+ System.out.println("<cmd> "+args[0]+" <ttp-file> // check the syntax of the ttp");
+ }
+ else {
+ OpendaylightTtps odlTTPs = readTTPFromFile(args[1]);
+ printFlowPaths(odlTTPs.getTableTypePatterns().getTableTypePattern().get(0));
+ }
+ break;
case "dot":
if (args.length != 2) {
System.out.println("<cmd> "+args[0]+" <ttp-file> // check the syntax of the ttp");
}
static void printDOT(TableTypePattern ttp) {
- Map<String, String> legalTableHops = new HashMap<>();
+ Map<String, List<String>> legalTableHops = new HashMap<>();
for (FlowTables flowTable : ttp.getFlowTables()) {
+ List<String> dests = new ArrayList<>();
for (FlowModTypes fmt : flowTable.getFlowModTypes()) {// ft.getFlowModTypes()) {
for (InstructionSet ins : fmt.getInstructionSet()) {
}
}
+
// add a legal hop from the flow table to the action listed in the goto table
for (InstructionSetProperties gotoTable : gotoTables) {
- legalTableHops.put(flowTable.getName(), gotoTable.getTable());
+ String dest = gotoTable.getTable();
+ if (dests.contains(dest)) {
+ System.out.println("dest already in list: " + dest);
+ }
+ else {
+ System.out.println("adding goto_table to table dests " + flowTable.getName() + "," + gotoTable.getTable());
+ dests.add(dest);
+ }
+
}
}
}
+ for (BuiltInFlowMods bifm : flowTable.getBuiltInFlowMods()) {// ft.getFlowModTypes()) {
+ for (InstructionSet ins : bifm.getInstructionSet()) {
+
+ // get all the goto_table instructions even if they are in meta keywords
+ List<InstructionSetProperties> gotoTables = new ArrayList<>();
+ if (ins.getInstruction() != null) {
+ if (ins.getInstruction().equalsIgnoreCase("goto_table")) {
+ gotoTables.add(ins);
+ }
+ }
+ if (ins.getExactlyOne() != null) {
+ for (ExactlyOne eo : ins.getExactlyOne()) {
+ if (eo.getInstruction().equalsIgnoreCase("goto_table")) {
+ gotoTables.add(eo);
+ }
+ }
+ }
+ if (ins.getZeroOrOne() != null) {
+ for (ZeroOrOne zoo : ins.getZeroOrOne()) {
+ if (zoo.getInstruction().equalsIgnoreCase("goto_table")) {
+ gotoTables.add(zoo);
+ }
+ }
+ }
+
+ // add a legal hop from the flow table to the action listed in the goto table
+ for (InstructionSetProperties gotoTable : gotoTables) {
+ String dest = gotoTable.getTable();
+ if (dests.contains(dest)) {
+ System.out.println("dest already in list: " + dest);
+ }
+ else {
+ System.out.println("adding goto_table to table dests " + flowTable.getName() + "," + gotoTable.getTable());
+ dests.add(dest);
+ }
+
+ }
+ }
+ }
+ if (!dests.isEmpty()) {
+ System.out.println("adding dest list to table hops " + flowTable.getName());
+
+ legalTableHops.put(flowTable.getName(), dests);
+ }
}
System.out.println("digraph ttp {");
- for (Map.Entry<String, String> hop : legalTableHops.entrySet()) {
- System.out.println(" \"" + hop.getKey() + "\" -> \"" + hop.getValue() + "\";");
+ for (String source : legalTableHops.keySet()) {
+ List<String> dests = legalTableHops.get(source);
+ for (String dest : dests) {
+ System.out.println(" \"" + source + "\" -> \"" + dest + "\";");
+ }
}
System.out.println("}");
}
+ static void nextFlowPathHop(TableTypePattern ttp, String Path, String tableName, int recurse) {
+ boolean tableNameValid = false;
+
+ if (recurse > 12) {
+ System.out.println("excessive recursion, Path = " + Path);
+ return;
+ }
+ recurse++;
+ Path = Path.concat(tableName);
+// System.out.println("nextFlowPathHop called, table= " + tableName + " recurse= " + recurse);
+ for (FlowTables flowTable : ttp.getFlowTables()) {
+ if (flowTable.getName().equals(tableName)) {
+ tableNameValid = true;
+ int fmtCount = 0;
+ List<String> dests = new ArrayList<>();
+ for (FlowModTypes fmt : flowTable.getFlowModTypes()) {
+ boolean gotGoTo = false;
+ if (fmtCount++ > 100) {
+ System.out.println("more than 100 flowmodtypes in a table");
+ break;
+ }
+ for (InstructionSet ins : fmt.getInstructionSet()) {
+ if (ins.getInstruction() != null) {
+ if (ins.getInstruction().equalsIgnoreCase("goto_table")) {
+ gotGoTo = true;
+ String destName = ins.getTable();
+ if (!dests.contains(destName)) {
+ dests.add(destName);
+ nextFlowPathHop(ttp, Path.concat(" -> "), destName, recurse);
+ }
+ }
+ }
+ if (ins.getExactlyOne() != null) {
+ for (ExactlyOne eo : ins.getExactlyOne()) {
+ if (eo.getInstruction().equalsIgnoreCase("goto_table")) {
+ gotGoTo = true;
+ String destName = eo.getTable();
+ if (!dests.contains(destName)) {
+ dests.add(destName);
+ nextFlowPathHop(ttp, Path.concat(" -> "), destName, recurse);
+ }
+ }
+ }
+ }
+ if (ins.getZeroOrOne() != null) {
+ for (ZeroOrOne zoo : ins.getZeroOrOne()) {
+ if (zoo.getInstruction().equalsIgnoreCase("goto_table")) {
+ gotGoTo = true;
+ String destName = zoo.getTable();
+ if (!dests.contains(destName)) {
+ dests.add(destName);
+ nextFlowPathHop(ttp, Path.concat(" -> "), destName, recurse);
+ }
+ }
+ }
+ }
+
+ }
+ if (!gotGoTo) {
+ if (!dests.contains("__NOGOTO__")) {
+ dests.add("__NOGOTO__");
+ System.out.println(Path);
+ }
+ }
+ }
+ if (fmtCount == 0) {
+ System.out.println(Path + "[LAST TABLE has no FMTs!]");
+ }
+// System.out.println("beginning BuiltIns for " + tableName);
+ for (BuiltInFlowMods bifm : flowTable.getBuiltInFlowMods()) {
+ boolean gotGoTo = false;
+ if (fmtCount++ > 100) {
+ System.out.println("more than 100 flowmodtypes and builtins in a table");
+ break;
+ }
+ for (InstructionSet ins : bifm.getInstructionSet()) {
+ if (ins.getInstruction() != null) {
+ if (ins.getInstruction().equalsIgnoreCase("goto_table")) {
+ gotGoTo = true;
+ String destName = ins.getTable();
+ if (!dests.contains(destName)) {
+ dests.add(destName);
+ nextFlowPathHop(ttp, Path.concat(" -> "), destName, recurse);
+ }
+ }
+ }
+ if (ins.getExactlyOne() != null) {
+ for (ExactlyOne eo : ins.getExactlyOne()) {
+ if (eo.getInstruction().equalsIgnoreCase("goto_table")) {
+ gotGoTo = true;
+ String destName = eo.getTable();
+ if (!dests.contains(destName)) {
+ dests.add(destName);
+ nextFlowPathHop(ttp, Path.concat(" -> "), destName, recurse);
+ }
+ }
+ }
+ }
+ if (ins.getZeroOrOne() != null) {
+ for (ZeroOrOne zoo : ins.getZeroOrOne()) {
+ if (zoo.getInstruction().equalsIgnoreCase("goto_table")) {
+ gotGoTo = true;
+ String destName = zoo.getTable();
+ if (!dests.contains(destName)) {
+ dests.add(destName);
+ nextFlowPathHop(ttp, Path.concat(" -> "), destName, recurse);
+ }
+ }
+ }
+ }
+
+ }
+ if (!gotGoTo) {
+ if (!dests.contains("__NOGOTO__")) {
+ dests.add("__NOGOTO__");
+ System.out.println(Path);
+ }
+ }
+ }
+ }
+ }
+ if (!tableNameValid) {
+ System.out.println(Path + " [LAST TABLE NOT FOUND!]");
+ }
+ }
+
+ static void printFlowPaths(TableTypePattern ttp) {
+ String Path = "";
+ System.out.println("Begin table names");
+ for (FlowTables ftLoop : ttp.getFlowTables()) {
+ System.out.println(ftLoop.getName());
+ }
+ System.out.println("End table names");
+ System.out.println("");
+ FlowTables flowTable = ttp.getFlowTables().get(0);
+ String tableName = flowTable.getName();
+ nextFlowPathHop(ttp, Path, tableName, 0);
+ }
}