use of org.onosproject.simplefabric.api.FabricRoute in project onos by opennetworkinglab.
the class SimpleFabricManager method dump.
// Dump handler
protected void dump(String subject, PrintStream out) {
if ("show".equals(subject)) {
out.println("Static Configuration Flag:");
out.println(" ALLOW_IPV6=" + ALLOW_IPV6);
out.println(" ALLOW_ETH_ADDRESS_SELECTOR=" + ALLOW_ETH_ADDRESS_SELECTOR);
out.println(" REACTIVE_SINGLE_TO_SINGLE=" + REACTIVE_SINGLE_TO_SINGLE);
out.println(" REACTIVE_ALLOW_LINK_CP=" + REACTIVE_ALLOW_LINK_CP);
out.println(" REACTIVE_HASHED_PATH_SELECTION=" + REACTIVE_HASHED_PATH_SELECTION);
out.println(" REACTIVE_MATCH_IP_PROTO=" + REACTIVE_MATCH_IP_PROTO);
out.println("");
out.println("SimpleFabricAppId:");
out.println(" " + appId());
out.println("");
out.println("fabricNetworks:");
for (FabricNetwork fabricNetwork : fabricNetworks()) {
out.println(" " + fabricNetwork);
}
out.println("");
out.println("fabricSubnets:");
for (FabricSubnet fabricIpSubnet : defaultFabricSubnets()) {
out.println(" " + fabricIpSubnet);
}
out.println("");
out.println("fabricRoutes:");
for (FabricRoute route : fabricRoutes()) {
out.println(" " + route);
}
}
}
use of org.onosproject.simplefabric.api.FabricRoute in project onos by opennetworkinglab.
the class SimpleFabricRouting method refreshIntercepts.
/**
* Refresh device flow rules for intercepts on local fabricSubnets.
*/
private void refreshIntercepts() {
Set<FlowRule> newInterceptFlowRules = new HashSet<>();
for (Device device : deviceService.getAvailableDevices()) {
for (FabricSubnet subnet : simpleFabric.defaultFabricSubnets()) {
newInterceptFlowRules.add(generateInterceptFlowRule(true, device.id(), subnet.prefix()));
// check if this devices has the fabricSubnet, then add ip broadcast flue rule
FabricNetwork fabricNetwork = simpleFabric.fabricNetwork(subnet.networkName());
if (fabricNetwork != null && fabricNetwork.contains(device.id())) {
newInterceptFlowRules.add(generateLocalSubnetIpBctFlowRule(device.id(), subnet.prefix(), fabricNetwork));
}
// JUST FOR FLOW RULE TEST ONLY
// newInterceptFlowRules.add(generateTestFlowRule(device.id(), subnet.ipPrefix()));
}
for (FabricRoute route : simpleFabric.fabricRoutes()) {
newInterceptFlowRules.add(generateInterceptFlowRule(false, device.id(), route.prefix()));
}
}
if (!newInterceptFlowRules.equals(interceptFlowRules)) {
// NOTE: DO NOT REMOVE INTERCEPT FLOW RULES FOR FAILED DEVICE FLOW UPDATE MIGHT BE BLOCKED
/*
interceptFlowRules.stream()
.filter(rule -> !newInterceptFlowRules.contains(rule))
.forEach(rule -> {
flowRuleService.removeFlowRules(rule);
log.info("simple fabric reactive routing remove intercept flow rule: {}", rule);
});
*/
newInterceptFlowRules.stream().filter(rule -> !interceptFlowRules.contains(rule)).forEach(rule -> {
flowRuleService.applyFlowRules(rule);
log.info("simple fabric routing apply intercept flow rule: {}", rule);
});
interceptFlowRules = newInterceptFlowRules;
}
}
use of org.onosproject.simplefabric.api.FabricRoute in project onos by opennetworkinglab.
the class DefaultFabricRouteTest method testConstruction.
/**
* Test object construction.
*/
@Test
public void testConstruction() {
FabricRoute route = fabricRoute1;
assertEquals(route.source(), SOURCE_1);
assertEquals(route.prefix(), IP_PREFIX_1);
assertEquals(route.nextHop(), NEXT_HOP_1);
assertEquals(route.sourceNode(), SOURCE_NODE_1);
}
use of org.onosproject.simplefabric.api.FabricRoute in project onos by opennetworkinglab.
the class SimpleFabricConfig method fabricRoutes.
/**
* Returns all routes in this configuration.
*
* @return a set of routes.
*/
public Set<FabricRoute> fabricRoutes() {
Set<FabricRoute> routes = Sets.newHashSet();
JsonNode routesNode = object.get(FABRIC_ROUTES);
if (routesNode == null) {
return routes;
}
routesNode.forEach(jsonNode -> {
try {
routes.add(DefaultFabricRoute.builder().source(FabricRoute.Source.STATIC).prefix(IpPrefix.valueOf(jsonNode.path(PREFIX).asText())).nextHop(IpAddress.valueOf(jsonNode.path(NEXT_HOP).asText())).build());
} catch (IllegalArgumentException e) {
log.warn("Fabric router parse error; skip: jsonNode={}", jsonNode);
}
});
return routes;
}
use of org.onosproject.simplefabric.api.FabricRoute in project onos by opennetworkinglab.
the class SimpleFabricManager method refresh.
// Set up from configuration
// returns found isDirty and refresh listeners are called (true) or not (false)
private boolean refresh() {
log.debug("simple fabric refresh");
boolean dirty = false;
SimpleFabricConfig config = configService.getConfig(coreService.registerApplication(APP_ID), SimpleFabricConfig.class);
if (config == null) {
log.debug("No simple fabric config available!");
return false;
}
// fabricNetworks
Set<FabricNetwork> newFabricNetworks = new HashSet<>();
Set<Interface> newInterfaces = new HashSet<>();
for (FabricNetwork newFabricNetworkConfig : config.fabricNetworks()) {
FabricNetwork newFabricNetwork = DefaultFabricNetwork.of(newFabricNetworkConfig);
// fill up interfaces and Hosts with active port only
for (String ifaceName : newFabricNetworkConfig.interfaceNames()) {
Interface iface = getInterfaceByName(ifaceName);
if (iface != null && deviceService.isAvailable(iface.connectPoint().deviceId())) {
newFabricNetwork.addInterface(iface);
newInterfaces.add(iface);
}
}
for (Host host : hostService.getHosts()) {
// consider host with ip only
if (!host.ipAddresses().isEmpty()) {
Interface iface = findAvailableDeviceHostInterface(host);
if (iface != null && newFabricNetwork.contains(iface)) {
newFabricNetwork.addHost(host);
}
}
}
newFabricNetwork.setDirty(true);
// update newFabricNetwork's isDirty flags if same entry already exists
for (FabricNetwork prevFabricNetwork : fabricNetworks) {
if (prevFabricNetwork.equals(newFabricNetwork)) {
newFabricNetwork.setDirty(prevFabricNetwork.isDirty());
break;
}
}
newFabricNetworks.add(newFabricNetwork);
}
if (!fabricNetworks.equals(newFabricNetworks)) {
fabricNetworks = newFabricNetworks;
dirty = true;
}
if (!networkInterfaces.equals(newInterfaces)) {
networkInterfaces = newInterfaces;
dirty = true;
}
// default Fabric Subnets
Set<FabricSubnet> newFabricSubnets = config.fabricSubnets();
InvertedRadixTree<FabricSubnet> newIp4SubnetTable = new ConcurrentInvertedRadixTree<>(new DefaultByteArrayNodeFactory());
InvertedRadixTree<FabricSubnet> newIp6SubnetTable = new ConcurrentInvertedRadixTree<>(new DefaultByteArrayNodeFactory());
Map<IpAddress, MacAddress> newVirtualGatewayIpMacMap = Maps.newConcurrentMap();
for (FabricSubnet subnet : newFabricSubnets) {
if (subnet.prefix().isIp4()) {
newIp4SubnetTable.put(createBinaryString(subnet.prefix()), subnet);
} else {
newIp6SubnetTable.put(createBinaryString(subnet.prefix()), subnet);
}
newVirtualGatewayIpMacMap.put(subnet.gatewayIp(), subnet.gatewayMac());
}
if (!fabricSubnets.equals(newFabricSubnets)) {
fabricSubnets = newFabricSubnets;
ip4SubnetTable = newIp4SubnetTable;
ip6SubnetTable = newIp6SubnetTable;
dirty = true;
}
if (!virtualGatewayIpMacMap.equals(newVirtualGatewayIpMacMap)) {
virtualGatewayIpMacMap = newVirtualGatewayIpMacMap;
dirty = true;
}
// fabricRoutes config handling
Set<FabricRoute> newFabricRoutes = config.fabricRoutes();
if (!fabricRoutes.equals(newFabricRoutes)) {
InvertedRadixTree<FabricRoute> newIp4BorderRouteTable = new ConcurrentInvertedRadixTree<>(new DefaultByteArrayNodeFactory());
InvertedRadixTree<FabricRoute> newIp6BorderRouteTable = new ConcurrentInvertedRadixTree<>(new DefaultByteArrayNodeFactory());
for (FabricRoute route : newFabricRoutes) {
if (route.prefix().isIp4()) {
newIp4BorderRouteTable.put(createBinaryString(route.prefix()), route);
} else {
newIp6BorderRouteTable.put(createBinaryString(route.prefix()), route);
}
}
fabricRoutes = newFabricRoutes;
ip4BorderRouteTable = newIp4BorderRouteTable;
ip6BorderRouteTable = newIp6BorderRouteTable;
dirty = true;
}
// notify to SimpleFabric listeners
if (dirty) {
log.info("simple fabric refresh; notify events");
process(new SimpleFabricEvent(SimpleFabricEvent.Type.SIMPLE_FABRIC_UPDATED, "updated"));
}
return dirty;
}
Aggregations