Fix an action of t3-troubleshot-mcast command when no sink for a multicast route
- Prints a message saying that there is no sink to trace
Change-Id: Ib113170c2c2a73e8a71b3819d2b814113adf357d
(cherry picked from commit fbd65dbd60d20878a3576de1fbd68d4bdee6f26c)
diff --git a/apps/t3/app/src/main/java/org/onosproject/t3/cli/TroubleshootMcastCommand.java b/apps/t3/app/src/main/java/org/onosproject/t3/cli/TroubleshootMcastCommand.java
index d3fefec..325691e 100644
--- a/apps/t3/app/src/main/java/org/onosproject/t3/cli/TroubleshootMcastCommand.java
+++ b/apps/t3/app/src/main/java/org/onosproject/t3/cli/TroubleshootMcastCommand.java
@@ -81,7 +81,7 @@
print("Failure: %s", trace.resultMessage());
failedTraces.add(trace);
} else {
- print("Success");
+ print(trace.resultMessage());
}
}
} else {
diff --git a/apps/t3/app/src/main/java/org/onosproject/t3/impl/McastGenerator.java b/apps/t3/app/src/main/java/org/onosproject/t3/impl/McastGenerator.java
index a5022a2..e93af15 100644
--- a/apps/t3/app/src/main/java/org/onosproject/t3/impl/McastGenerator.java
+++ b/apps/t3/app/src/main/java/org/onosproject/t3/impl/McastGenerator.java
@@ -40,6 +40,9 @@
private static final Logger log = getLogger(McastGenerator.class);
protected static final MacAddress IPV4_ADDRESS = MacAddress.valueOf("01:00:5E:00:00:00");
protected static final MacAddress IPV6_ADDRESS = MacAddress.valueOf("33:33:00:00:00:00");
+ private static final String NO_SINK = "There is no sink for this mcast route";
+ private static final String GENERATOR_ERROR =
+ "Generator for mcast route trace has benn interrupted. The trace result may be incomplete.";
private final MulticastRouteService mcastService;
private final TroubleshootManager manager;
@@ -77,16 +80,27 @@
.matchIPv6Dst(group.toIpPrefix())
.matchEthType(EthType.EtherType.IPV6.ethType().toShort());
}
+
+ StaticPacketTrace trace;
+ // check this mcast route has no sink
+ if (routeData.allSinks().size() == 0) {
+ trace = new StaticPacketTrace(selector.build(), source);
+ trace.addResultMessage(NO_SINK);
+ // tracing mcast route with no sink is not a failure
+ trace.setSuccess(true);
+ } else {
+ trace = manager.trace(selector.build(), source);
+ }
try {
- yield(ImmutableSet.of(manager.trace(selector.build(), source)));
+ yield(ImmutableSet.of(trace));
} catch (InterruptedException e) {
log.warn("Interrupted generator", e.getMessage());
log.debug("exception", e);
+ trace.setSuccess(false);
+ trace.addResultMessage(GENERATOR_ERROR);
}
});
});
-
});
-
}
}