}
}
+ @Override
public ConcurrentMap<String, StaticRouteConfig> getStaticRouteConfigs() {
return staticRouteConfigs;
}
}
private void notifyHostUpdate(HostNodeConnector host, boolean added) {
- if (host == null)
+ if (host == null) {
return;
+ }
for (StaticRoute s : staticRoutes.values()) {
- if (s.getType() == StaticRoute.NextHopType.SWITCHPORT)
+ if (s.getType() == StaticRoute.NextHopType.SWITCHPORT) {
continue;
+ }
if (s.getNextHopAddress().equals(host.getNetworkAddress())) {
if (added) {
s.setHost(host);
}
public boolean isIPv4AddressValid(String cidr) {
- if (cidr == null)
+ if (cidr == null) {
return false;
+ }
String values[] = cidr.split("/");
Pattern ipv4Pattern = Pattern
return 0;
}
+ @Override
public StaticRoute getBestMatchStaticRoute(InetAddress ipAddress) {
ByteBuffer bblongestPrefix = null;
try {
return longestPrefixRoute;
}
+ @Override
public Status addStaticRoute(StaticRouteConfig config) {
- Status status;
-
- status = config.isValid();
+ Status status = config.isValid();
if (!status.isSuccess()) {
return status;
}
"A valid Static Route configuration with this name " +
"already exists. Please use a different name");
}
- for (StaticRouteConfig s : staticRouteConfigs.values()) {
- if (s.equals(config)) {
+
+ // Update database
+ StaticRoute sRoute = new StaticRoute(config);
+
+ for (Map.Entry<String, StaticRoute> entry : staticRoutes.entrySet()) {
+ if (entry.getValue().compareTo(sRoute) == 0) {
return new Status(StatusCode.CONFLICT,
- "This conflicts with an existing Static Route " +
- "Configuration. Please check the configuration " +
- "and try again");
+ "This conflicts with an existing Static Route " +
+ "Configuration. Please check the configuration " +
+ "and try again");
}
}
+ staticRoutes.put(config.getName(), sRoute);
+ // Update config databse
staticRouteConfigs.put(config.getName(), config);
- StaticRoute sRoute = new StaticRoute(config);
- staticRoutes.put(config.getName(), sRoute);
+
+ // Notify
checkAndUpdateListeners(sRoute, true);
return status;
}
+ @Override
public Status removeStaticRoute(String name) {
staticRouteConfigs.remove(name);
StaticRoute sRoute = staticRoutes.remove(name);
allocateCaches();
retrieveCaches();
this.executor = Executors.newFixedThreadPool(1);
- if (staticRouteConfigs.isEmpty())
+ if (staticRouteConfigs.isEmpty()) {
loadConfiguration();
+ }
/*
* Slow probe to identify any gateway that might have silently appeared
/**
* Returns the list of Flow entries across network nodes which are part of
- * the same flow group, policy
+ * the same flow group, policy. This list contains the flows as they were
+ * requested to be installed by the applications, before any merging with
+ * container flow is done.
*
* @param group
* the group name
- * @return the list of flow entries belonging to the specified group
+ * @return the original list of flow entries belonging to the specified group
*/
public List<FlowEntry> getFlowEntriesForGroup(String group);
+ /**
+ * Returns the list of Flow entries installed in network nodes which are part of
+ * the same flow group, policy. This list contains the effective flows installed
+ * on the nodes after the merging with any possible container flow was performed.
+ * If no container flow are specified, this method returns the same list returned
+ * by getFlowEntriesForGroup(String group).
+ *
+ * @param group
+ * the group name
+ * @return the list of container flow merged flow entries belonging to the specified group
+ */
+ public List<FlowEntry> getInstalledFlowEntriesForGroup(String policyName);
+
/**
* Add a list of output port to the flow with the specified name on the
* specified network node
}
private void replaceHost(InetAddress networkAddr, HostNodeConnector removedHost, HostNodeConnector newHost) {
+ // Ignore ARP messages from internal nodes
+ NodeConnector newHostNc = newHost.getnodeConnector();
+ boolean newHostIsInternal = topologyManager.isInternal(newHostNc);
+ if (newHostIsInternal) {
+ return;
+ }
+
newHost.initArpSendCountDown();
+
if (hostsDB.replace(networkAddr, removedHost, newHost)) {
logger.debug("Host move occurred: Old Host IP:{}, New Host IP: {}", removedHost.getNetworkAddress()
.getHostAddress(), newHost.getNetworkAddress().getHostAddress());