Refactor: extract interfaces for a set of simple fabric classes
Change-Id: I4a23fb2277498f466ce20f82e38d5e9cb25dab6e
diff --git a/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricConfig.java b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricConfig.java
index b163660..53c33a4 100644
--- a/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricConfig.java
+++ b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricConfig.java
@@ -22,11 +22,14 @@
import org.onlab.packet.IpPrefix;
import org.onlab.packet.MacAddress;
import org.onosproject.core.ApplicationId;
-import org.onosproject.net.config.Config;
import org.onosproject.net.EncapsulationType;
-import org.onosproject.simplefabric.api.IpSubnet;
-import org.onosproject.simplefabric.api.L2Network;
-import org.onosproject.simplefabric.api.Route;
+import org.onosproject.net.config.Config;
+import org.onosproject.simplefabric.api.DefaultFabricRoute;
+import org.onosproject.simplefabric.api.DefaultFabricSubnet;
+import org.onosproject.simplefabric.api.DefaultFabricNetwork;
+import org.onosproject.simplefabric.api.FabricRoute;
+import org.onosproject.simplefabric.api.FabricSubnet;
+import org.onosproject.simplefabric.api.FabricNetwork;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -38,92 +41,101 @@
public class SimpleFabricConfig extends Config<ApplicationId> {
public static final String KEY = "simpleFabric";
- private static final String L2NETWORKS = "l2Networks";
+ private static final String FABRIC_NETWORKS = "fabricNetworks";
private static final String NAME = "name";
private static final String INTERFACES = "interfaces";
private static final String ENCAPSULATION = "encapsulation";
- private static final String L2FORWARD = "l2Forward";
- private static final String L2BROADCAST = "l2Broadcast";
- private static final String IPSUBNETS = "ipSubnets";
- private static final String BORDERROUTES = "borderRoutes";
- private static final String IPPREFIX = "ipPrefix";
- private static final String GATEWAYIP = "gatewayIp";
- private static final String GATEWAYMAC = "gatewayMac";
- private static final String L2NETWORKNAME = "l2NetworkName";
- private static final String NEXTHOP = "nextHop";
+ private static final String IS_FORWARD = "isForward";
+ private static final String IS_BROADCAST = "isBroadcast";
+
+ private static final String FABRIC_SUBNETS = "fabricSubnets";
+ private static final String PREFIX = "prefix";
+ private static final String GATEWAY_IP = "gatewayIp";
+ private static final String GATEWAY_MAC = "gatewayMac";
+ private static final String NETWORK_NAME = "networkName";
+
+ private static final String FABRIC_ROUTES = "fabricRoutes";
+ private static final String NEXT_HOP = "nextHop";
+
+ private static final String NONE_ENCAPSULATION = "NONE";
private final Logger log = LoggerFactory.getLogger(getClass());
/**
- * Returns all l2Networks in this configuration.
+ * Returns all fabric networks in this configuration.
*
- * @return A set of L2Network.
+ * @return a set of fabric networks
*/
- public Set<L2Network> getL2Networks() {
- Set<L2Network> l2Networks = Sets.newHashSet();
- JsonNode l2NetworkNode = object.get(L2NETWORKS);
- if (l2NetworkNode == null) {
- return l2Networks;
+ public Set<FabricNetwork> fabricNetworks() {
+ Set<FabricNetwork> fabricNetworks = Sets.newHashSet();
+ JsonNode fabricNetworkNodes = object.get(FABRIC_NETWORKS);
+ if (fabricNetworkNodes == null) {
+ return fabricNetworks;
}
- l2NetworkNode.forEach(jsonNode -> {
+ fabricNetworkNodes.forEach(jsonNode -> {
Set<String> ifaces = Sets.newHashSet();
- JsonNode l2NetworkIfaces = jsonNode.path(INTERFACES);
- if (l2NetworkIfaces == null) {
- log.warn("simple fabric network config cannot find {}; skip: jsonNode={}", INTERFACES, jsonNode);
- } else if (!l2NetworkIfaces.toString().isEmpty()) {
- l2NetworkIfaces.forEach(ifacesNode -> ifaces.add(new String(ifacesNode.asText())));
+ JsonNode fabricNetworkIfaces = jsonNode.path(INTERFACES);
+ if (fabricNetworkIfaces == null) {
+ log.warn("Fabric network interfaces cannot find {}; skip: jsonNode={}", INTERFACES, jsonNode);
+ } else if (!fabricNetworkIfaces.toString().isEmpty()) {
+ fabricNetworkIfaces.forEach(ifacesNode -> ifaces.add(ifacesNode.asText()));
}
- String encapsulation = "NONE"; // NONE or VLAN
+ String encapsulation = NONE_ENCAPSULATION; // NONE or VLAN
if (jsonNode.hasNonNull(ENCAPSULATION)) {
encapsulation = jsonNode.get(ENCAPSULATION).asText();
}
- boolean l2Forward = true;
- if (jsonNode.hasNonNull(L2FORWARD)) {
- l2Forward = jsonNode.get(L2FORWARD).asBoolean();
+ boolean isForward = true;
+ if (jsonNode.hasNonNull(IS_FORWARD)) {
+ isForward = jsonNode.get(IS_FORWARD).asBoolean();
}
- boolean l2Broadcast = true;
- if (jsonNode.hasNonNull(L2BROADCAST)) {
- l2Broadcast = jsonNode.get(L2BROADCAST).asBoolean();
+ boolean isBroadcast = true;
+ if (jsonNode.hasNonNull(IS_BROADCAST)) {
+ isBroadcast = jsonNode.get(IS_BROADCAST).asBoolean();
}
try {
- l2Networks.add(new L2Network(
- jsonNode.get(NAME).asText(), ifaces, EncapsulationType.enumFromString(encapsulation),
- l2Forward, l2Broadcast));
+ fabricNetworks.add(DefaultFabricNetwork.builder()
+ .name(jsonNode.get(NAME).asText())
+ .interfaceNames(ifaces)
+ .encapsulation(EncapsulationType.enumFromString(encapsulation))
+ .forward(isForward)
+ .broadcast(isBroadcast)
+ .build());
} catch (Exception e) {
- log.warn("simple fabric network config l2Network parse failed; skip: error={} jsonNode={}", jsonNode);
+ log.warn("Fabric network parse failed; skip: jsonNode={}", jsonNode);
}
});
- return l2Networks;
+ return fabricNetworks;
}
/**
- * Gets the set of configured local IP subnets.
+ * Gets the set of configured local subnets.
*
- * @return IP Subnets
+ * @return a set of subnets
*/
- public Set<IpSubnet> ipSubnets() {
- Set<IpSubnet> subnets = Sets.newHashSet();
- JsonNode subnetsNode = object.get(IPSUBNETS);
+ public Set<FabricSubnet> fabricSubnets() {
+ Set<FabricSubnet> subnets = Sets.newHashSet();
+ JsonNode subnetsNode = object.get(FABRIC_SUBNETS);
if (subnetsNode == null) {
- log.warn("simple fabric network config ipSubnets is null!");
+ log.warn("FabricSubnets is null!");
return subnets;
}
subnetsNode.forEach(jsonNode -> {
- String encapsulation = "NONE"; // NONE or VLAN
+ String encapsulation = NONE_ENCAPSULATION; // NONE or VLAN
if (jsonNode.hasNonNull(ENCAPSULATION)) {
encapsulation = jsonNode.get(ENCAPSULATION).asText();
}
try {
- subnets.add(new IpSubnet(
- IpPrefix.valueOf(jsonNode.get(IPPREFIX).asText()),
- IpAddress.valueOf(jsonNode.get(GATEWAYIP).asText()),
- MacAddress.valueOf(jsonNode.get(GATEWAYMAC).asText()),
- EncapsulationType.enumFromString(encapsulation),
- jsonNode.get(L2NETWORKNAME).asText()));
+ subnets.add(DefaultFabricSubnet.builder()
+ .ipPrefix(IpPrefix.valueOf(jsonNode.get(PREFIX).asText()))
+ .gatewayIp(IpAddress.valueOf(jsonNode.get(GATEWAY_IP).asText()))
+ .gatewayMac(MacAddress.valueOf(jsonNode.get(GATEWAY_MAC).asText()))
+ .encapsulation(EncapsulationType.enumFromString(encapsulation))
+ .name(jsonNode.get(NETWORK_NAME).asText())
+ .build());
} catch (Exception e) {
- log.warn("simple fabric network config ipSubnet parse failed; skip: error={} jsonNode={}", jsonNode);
+ log.warn("Fabric subnet parse failed; skip: jsonNode={}", jsonNode);
}
});
@@ -133,29 +145,28 @@
/**
* Returns all routes in this configuration.
*
- * @return A set of route.
+ * @return a set of routes.
*/
- public Set<Route> borderRoutes() {
- Set<Route> routes = Sets.newHashSet();
+ public Set<FabricRoute> fabricRoutes() {
+ Set<FabricRoute> routes = Sets.newHashSet();
- JsonNode routesNode = object.get(BORDERROUTES);
+ JsonNode routesNode = object.get(FABRIC_ROUTES);
if (routesNode == null) {
- //log.warn("simple fabric network config borderRoutes is null!");
return routes;
}
routesNode.forEach(jsonNode -> {
try {
- routes.add(new Route(
- Route.Source.STATIC,
- IpPrefix.valueOf(jsonNode.path(IPPREFIX).asText()),
- IpAddress.valueOf(jsonNode.path(NEXTHOP).asText())));
+ 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("simple fabric network config parse error; skip: {}", jsonNode);
+ log.warn("Fabric router parse error; skip: jsonNode={}", jsonNode);
}
});
return routes;
}
-
}
diff --git a/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricL2Forward.java b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricForwarding.java
similarity index 77%
rename from apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricL2Forward.java
rename to apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricForwarding.java
index 819beee..f7eaa70 100644
--- a/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricL2Forward.java
+++ b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricForwarding.java
@@ -29,7 +29,6 @@
import org.onlab.packet.VlanId;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
-import org.onosproject.net.intf.Interface;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.EncapsulationType;
import org.onosproject.net.FilteredConnectPoint;
@@ -46,7 +45,8 @@
import org.onosproject.net.intent.SinglePointToMultiPointIntent;
import org.onosproject.net.intent.constraint.EncapsulationConstraint;
import org.onosproject.net.intent.constraint.PartialFailureConstraint;
-import org.onosproject.simplefabric.api.L2Network;
+import org.onosproject.net.intf.Interface;
+import org.onosproject.simplefabric.api.FabricNetwork;
import org.onosproject.simplefabric.api.SimpleFabricEvent;
import org.onosproject.simplefabric.api.SimpleFabricListener;
import org.onosproject.simplefabric.api.SimpleFabricService;
@@ -56,14 +56,14 @@
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Set;
import java.util.HashSet;
import java.util.List;
-import java.util.Objects;
import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
import java.util.stream.Collectors;
-import static org.onosproject.simplefabric.api.Constants.L2FORWARD_APP_ID;
+import static org.onosproject.simplefabric.api.Constants.FORWARDING_APP_ID;
import static org.onosproject.simplefabric.api.Constants.PRI_L2NETWORK_BROADCAST;
import static org.onosproject.simplefabric.api.Constants.PRI_L2NETWORK_UNICAST;
@@ -74,13 +74,13 @@
* application.
*/
@Component(immediate = true, enabled = false)
-public class SimpleFabricL2Forward {
+public class SimpleFabricForwarding {
public static final String BROADCAST = "BCAST";
public static final String UNICAST = "UNI";
private final Logger log = LoggerFactory.getLogger(getClass());
- protected ApplicationId l2ForwardAppId;
+ protected ApplicationId appId;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected CoreService coreService;
@@ -105,20 +105,20 @@
@Activate
public void activate() {
- l2ForwardAppId = coreService.registerApplication(L2FORWARD_APP_ID);
- log.info("simple fabric l2 forwaring starting with l2net app id {}", l2ForwardAppId.toString());
+ appId = coreService.registerApplication(FORWARDING_APP_ID);
+ log.info("simple fabric forwarding starting with l2net app id {}", appId.toString());
simpleFabric.addListener(simpleFabricListener);
refresh();
checkIntentsPurge();
- log.info("simple fabric l2forward started");
+ log.info("simple fabric forwarding started");
}
@Deactivate
public void deactivate() {
- log.info("simple fabric l2forward stopping");
+ log.info("simple fabric forwarding stopping");
simpleFabric.removeListener(simpleFabricListener);
@@ -141,26 +141,27 @@
//bctIntentsMap.clear();
//uniIntentsMap.clear();
- log.info("simple fabric l2forward stopped");
+ log.info("simple fabric forwarding stopped");
}
private void refresh() {
- log.debug("simple fabric l2forward refresh");
+ log.debug("simple fabric forwarding refresh");
Map<Key, SinglePointToMultiPointIntent> newBctIntentsMap = Maps.newConcurrentMap();
Map<Key, MultiPointToSinglePointIntent> newUniIntentsMap = Maps.newConcurrentMap();
- for (L2Network l2Network : simpleFabric.getL2Networks()) {
- // scans all l2network regardless of dirty flag
- // if l2Network.l2Forward == false or number of interfaces() < 2, no Intents generated
- for (SinglePointToMultiPointIntent intent : buildBrcIntents(l2Network)) {
+ for (FabricNetwork fabricNetwork : simpleFabric.fabricNetworks()) {
+ // scans all l2network regardless of isDirty flag
+ // if fabricNetwork.isForward == false or number of interfaces() < 2, no Intents generated
+ for (SinglePointToMultiPointIntent intent : buildBrcIntents(fabricNetwork)) {
newBctIntentsMap.put(intent.key(), intent);
}
- for (MultiPointToSinglePointIntent intent : buildUniIntents(l2Network, hostsFromL2Network(l2Network))) {
+ for (MultiPointToSinglePointIntent intent :
+ buildUniIntents(fabricNetwork, hostsFromL2Network(fabricNetwork))) {
newUniIntentsMap.put(intent.key(), intent);
}
- if (l2Network.dirty()) {
- l2Network.setDirty(false);
+ if (fabricNetwork.isDirty()) {
+ fabricNetwork.setDirty(false);
}
}
@@ -168,7 +169,8 @@
for (SinglePointToMultiPointIntent intent : bctIntentsMap.values()) {
SinglePointToMultiPointIntent newIntent = newBctIntentsMap.get(intent.key());
if (newIntent == null) {
- log.info("simple fabric l2forward withdraw broadcast intent: {}", intent.key().toString());
+ log.info("simple fabric forwarding withdraw broadcast intent: {}",
+ intent.key().toString());
toBePurgedIntentKeys.add(intent.key());
intentService.withdraw(intent);
bctUpdated = true;
@@ -182,7 +184,8 @@
!oldIntent.selector().equals(intent.selector()) ||
!oldIntent.treatment().equals(intent.treatment()) ||
!oldIntent.constraints().equals(intent.constraints())) {
- log.info("simple fabric l2forward submit broadcast intent: {}", intent.key().toString());
+ log.info("simple fabric forwarding submit broadcast intent: {}",
+ intent.key().toString());
toBePurgedIntentKeys.remove(intent.key());
intentService.submit(intent);
bctUpdated = true;
@@ -193,7 +196,8 @@
for (MultiPointToSinglePointIntent intent : uniIntentsMap.values()) {
MultiPointToSinglePointIntent newIntent = newUniIntentsMap.get(intent.key());
if (newIntent == null) {
- log.info("simple fabric l2forward withdraw unicast intent: {}", intent.key().toString());
+ log.info("simple fabric forwarding withdraw unicast intent: {}",
+ intent.key().toString());
toBePurgedIntentKeys.add(intent.key());
intentService.withdraw(intent);
uniUpdated = true;
@@ -207,7 +211,8 @@
!oldIntent.selector().equals(intent.selector()) ||
!oldIntent.treatment().equals(intent.treatment()) ||
!oldIntent.constraints().equals(intent.constraints())) {
- log.info("simple fabric l2forward submit unicast intent: {}", intent.key().toString());
+ log.info("simple fabric forwarding submit unicast intent: {}",
+ intent.key().toString());
toBePurgedIntentKeys.remove(intent.key());
intentService.submit(intent);
uniUpdated = true;
@@ -229,13 +234,14 @@
for (Key key : toBePurgedIntentKeys) {
Intent intentToPurge = intentService.getIntent(key);
if (intentToPurge == null) {
- log.info("simple fabric l2forward purged intent: key={}", key.toString());
+ log.info("simple fabric forwarding purged intent: key={}", key.toString());
purgedKeys.add(key);
} else {
switch (intentService.getIntentState(key)) {
case FAILED:
case WITHDRAWN:
- log.info("simple fabric l2forward try to purge intent: key={}", key.toString());
+ log.info("simple fabric forwarding try to purge intent: key={}",
+ key.toString());
intentService.purge(intentToPurge);
break;
case INSTALL_REQ:
@@ -243,7 +249,7 @@
case INSTALLING:
case RECOMPILING:
case COMPILING:
- log.warn("simple fabric l2forward withdraw intent to purge: key={}", key);
+ log.warn("simple fabric forwarding withdraw intent to purge: key={}", key);
intentService.withdraw(intentToPurge);
break;
case WITHDRAW_REQ:
@@ -262,21 +268,21 @@
// Generates Unicast Intents and broadcast Intents for the L2 Network.
- private Set<Intent> generateL2NetworkIntents(L2Network l2Network) {
+ private Set<Intent> generateL2NetworkIntents(FabricNetwork fabricNetwork) {
return new ImmutableSet.Builder<Intent>()
- .addAll(buildBrcIntents(l2Network))
- .addAll(buildUniIntents(l2Network, hostsFromL2Network(l2Network)))
+ .addAll(buildBrcIntents(fabricNetwork))
+ .addAll(buildUniIntents(fabricNetwork, hostsFromL2Network(fabricNetwork)))
.build();
}
// Build Boadcast Intents for a L2 Network.
- private Set<SinglePointToMultiPointIntent> buildBrcIntents(L2Network l2Network) {
- Set<Interface> interfaces = l2Network.interfaces();
- if (interfaces.size() < 2 || !l2Network.l2Forward() || !l2Network.l2Broadcast()) {
+ private Set<SinglePointToMultiPointIntent> buildBrcIntents(FabricNetwork fabricNetwork) {
+ Set<Interface> interfaces = fabricNetwork.interfaces();
+ if (interfaces.size() < 2 || !fabricNetwork.isForward() || !fabricNetwork.isBroadcast()) {
return ImmutableSet.of();
}
Set<SinglePointToMultiPointIntent> brcIntents = Sets.newHashSet();
- ResourceGroup resourceGroup = ResourceGroup.of(l2Network.name());
+ ResourceGroup resourceGroup = ResourceGroup.of(fabricNetwork.name());
// Generates broadcast Intents from any network interface to other
// network interface from the L2 Network.
@@ -287,17 +293,20 @@
.filter(iface -> !iface.equals(src))
.map(this::buildFilteredConnectedPoint)
.collect(Collectors.toSet());
- Key key = buildKey(l2Network.name(), "BCAST", srcFcp.connectPoint(), MacAddress.BROADCAST);
+ Key key = buildKey(fabricNetwork.name(), "BCAST",
+ srcFcp.connectPoint(), MacAddress.BROADCAST);
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchEthDst(MacAddress.BROADCAST)
.build();
- SinglePointToMultiPointIntent.Builder intentBuilder = SinglePointToMultiPointIntent.builder()
- .appId(l2ForwardAppId)
+ SinglePointToMultiPointIntent.Builder
+ intentBuilder = SinglePointToMultiPointIntent.builder()
+ .appId(appId)
.key(key)
.selector(selector)
.filteredIngressPoint(srcFcp)
.filteredEgressPoints(dstFcps)
- .constraints(buildConstraints(L2NETWORK_CONSTRAINTS, l2Network.encapsulation()))
+ .constraints(buildConstraints(L2NETWORK_CONSTRAINTS,
+ fabricNetwork.encapsulation()))
.priority(PRI_L2NETWORK_BROADCAST)
.resourceGroup(resourceGroup);
brcIntents.add(intentBuilder.build());
@@ -306,29 +315,32 @@
}
// Builds unicast Intents for a L2 Network.
- private Set<MultiPointToSinglePointIntent> buildUniIntents(L2Network l2Network, Set<Host> hosts) {
- Set<Interface> interfaces = l2Network.interfaces();
- if (!l2Network.l2Forward() || interfaces.size() < 2) {
+ private Set<MultiPointToSinglePointIntent> buildUniIntents(FabricNetwork fabricNetwork,
+ Set<Host> hosts) {
+ Set<Interface> interfaces = fabricNetwork.interfaces();
+ if (!fabricNetwork.isForward() || interfaces.size() < 2) {
return ImmutableSet.of();
}
Set<MultiPointToSinglePointIntent> uniIntents = Sets.newHashSet();
- ResourceGroup resourceGroup = ResourceGroup.of(l2Network.name());
+ ResourceGroup resourceGroup = ResourceGroup.of(fabricNetwork.name());
hosts.forEach(host -> {
FilteredConnectPoint hostFcp = buildFilteredConnectedPoint(host);
Set<FilteredConnectPoint> srcFcps = interfaces.stream()
.map(this::buildFilteredConnectedPoint)
.filter(fcp -> !fcp.equals(hostFcp))
.collect(Collectors.toSet());
- Key key = buildKey(l2Network.name(), "UNI", hostFcp.connectPoint(), host.mac());
+ Key key = buildKey(fabricNetwork.name(), "UNI", hostFcp.connectPoint(), host.mac());
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchEthDst(host.mac()).build();
- MultiPointToSinglePointIntent.Builder intentBuilder = MultiPointToSinglePointIntent.builder()
- .appId(l2ForwardAppId)
+ MultiPointToSinglePointIntent.Builder
+ intentBuilder = MultiPointToSinglePointIntent.builder()
+ .appId(appId)
.key(key)
.selector(selector)
.filteredIngressPoints(srcFcps)
.filteredEgressPoint(hostFcp)
- .constraints(buildConstraints(L2NETWORK_CONSTRAINTS, l2Network.encapsulation()))
+ .constraints(buildConstraints(L2NETWORK_CONSTRAINTS,
+ fabricNetwork.encapsulation()))
.priority(PRI_L2NETWORK_UNICAST)
.resourceGroup(resourceGroup);
uniIntents.add(intentBuilder.build());
@@ -339,8 +351,8 @@
// Intent generate utilities
- private Set<Host> hostsFromL2Network(L2Network l2Network) {
- Set<Interface> interfaces = l2Network.interfaces();
+ private Set<Host> hostsFromL2Network(FabricNetwork fabricNetwork) {
+ Set<Interface> interfaces = fabricNetwork.interfaces();
return interfaces.stream()
.map(this::hostsFromInterface)
.flatMap(Collection::stream)
@@ -354,11 +366,14 @@
.collect(Collectors.toSet());
}
- private Key buildKey(String l2NetworkName, String type, ConnectPoint cPoint, MacAddress dstMac) {
- return Key.of(l2NetworkName + "-" + type + "-" + cPoint.toString() + "-" + dstMac, l2ForwardAppId);
+ private Key buildKey(String l2NetworkName, String type,
+ ConnectPoint cPoint, MacAddress dstMac) {
+ return Key.of(l2NetworkName + "-" + type + "-" +
+ cPoint.toString() + "-" + dstMac, appId);
}
- private List<Constraint> buildConstraints(List<Constraint> constraints, EncapsulationType encapsulation) {
+ private List<Constraint> buildConstraints(List<Constraint> constraints,
+ EncapsulationType encapsulation) {
if (!encapsulation.equals(EncapsulationType.NONE)) {
List<Constraint> newConstraints = new ArrayList<>(constraints);
constraints.stream()
@@ -393,25 +408,27 @@
// Dump command handler
private void dump(String subject, PrintStream out) {
if ("intents".equals(subject)) {
- out.println("L2Forward Broadcast Intents:\n");
+ out.println("Forwarding Broadcast Intents:\n");
for (SinglePointToMultiPointIntent intent: bctIntentsMap.values()) {
out.println(" " + intent.key().toString()
+ ": " + intent.selector().criteria()
+ ", [" + intent.filteredIngressPoint().connectPoint()
+ "] -> " + intent.filteredEgressPoints().stream()
- .map(FilteredConnectPoint::connectPoint).collect(Collectors.toSet()));
+ .map(FilteredConnectPoint::connectPoint)
+ .collect(Collectors.toSet()));
}
out.println("");
- out.println("L2Forward Unicast Intents:\n");
+ out.println("Forwarding Unicast Intents:\n");
for (MultiPointToSinglePointIntent intent: uniIntentsMap.values()) {
out.println(" " + intent.key().toString()
+ ": " + intent.selector().criteria()
+ ", [" + intent.filteredIngressPoints().stream()
- .map(FilteredConnectPoint::connectPoint).collect(Collectors.toSet())
+ .map(FilteredConnectPoint::connectPoint)
+ .collect(Collectors.toSet())
+ "] -> " + intent.filteredEgressPoint().connectPoint());
}
out.println("");
- out.println("L2Forward Intents to Be Purged:\n");
+ out.println("Forwarding Intents to Be Purged:\n");
for (Key key: toBePurgedIntentKeys) {
out.println(" " + key.toString());
}
diff --git a/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricManager.java b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricManager.java
index 59f26f0..de87ba1 100644
--- a/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricManager.java
+++ b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricManager.java
@@ -37,7 +37,6 @@
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
import org.onlab.packet.ndp.NeighborSolicitation;
-import org.onosproject.app.ApplicationService;
import org.onosproject.component.ComponentService;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
@@ -65,9 +64,10 @@
import org.onosproject.net.packet.DefaultOutboundPacket;
import org.onosproject.net.packet.OutboundPacket;
import org.onosproject.net.packet.PacketService;
-import org.onosproject.simplefabric.api.IpSubnet;
-import org.onosproject.simplefabric.api.L2Network;
-import org.onosproject.simplefabric.api.Route;
+import org.onosproject.simplefabric.api.DefaultFabricNetwork;
+import org.onosproject.simplefabric.api.FabricNetwork;
+import org.onosproject.simplefabric.api.FabricRoute;
+import org.onosproject.simplefabric.api.FabricSubnet;
import org.onosproject.simplefabric.api.SimpleFabricEvent;
import org.onosproject.simplefabric.api.SimpleFabricListener;
import org.onosproject.simplefabric.api.SimpleFabricService;
@@ -82,7 +82,6 @@
import java.util.Map;
import java.util.Set;
-import static org.onosproject.simplefabric.util.RouteTools.createBinaryString;
import static org.onosproject.simplefabric.api.Constants.ALLOW_ETH_ADDRESS_SELECTOR;
import static org.onosproject.simplefabric.api.Constants.ALLOW_IPV6;
import static org.onosproject.simplefabric.api.Constants.APP_ID;
@@ -91,6 +90,7 @@
import static org.onosproject.simplefabric.api.Constants.REACTIVE_HASHED_PATH_SELECTION;
import static org.onosproject.simplefabric.api.Constants.REACTIVE_MATCH_IP_PROTO;
import static org.onosproject.simplefabric.api.Constants.REACTIVE_SINGLE_TO_SINGLE;
+import static org.onosproject.simplefabric.util.RouteTools.createBinaryString;
/**
@@ -107,9 +107,6 @@
protected CoreService coreService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected ApplicationService applicationService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected NetworkConfigService configService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
@@ -127,32 +124,32 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected PacketService packetService;
- // compoents to be activated within SimpleFabric
+ // components to be activated within SimpleFabric
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected ComponentService componentService;
// SimpleFabric variables
private ApplicationId appId = null;
- // l2 broadcast networks
- private Set<L2Network> l2Networks = new HashSet<>();
- private Set<Interface> l2NetworkInterfaces = new HashSet<>();
+ // fabric networks
+ private Set<FabricNetwork> fabricNetworks = new HashSet<>();
+ private Set<Interface> networkInterfaces = new HashSet<>();
// Subnet table
- private Set<IpSubnet> ipSubnets = new HashSet<>();
- private InvertedRadixTree<IpSubnet> ip4SubnetTable =
+ private Set<FabricSubnet> fabricSubnets = new HashSet<>();
+ private InvertedRadixTree<FabricSubnet> ip4SubnetTable =
new ConcurrentInvertedRadixTree<>(new DefaultByteArrayNodeFactory());
- private InvertedRadixTree<IpSubnet> ip6SubnetTable =
+ private InvertedRadixTree<FabricSubnet> ip6SubnetTable =
new ConcurrentInvertedRadixTree<>(new DefaultByteArrayNodeFactory());
- // Border Route table
- private Set<Route> borderRoutes = new HashSet<>();
- private InvertedRadixTree<Route> ip4BorderRouteTable =
+ // Fabric Route table
+ private Set<FabricRoute> fabricRoutes = new HashSet<>();
+ private InvertedRadixTree<FabricRoute> ip4BorderRouteTable =
new ConcurrentInvertedRadixTree<>(new DefaultByteArrayNodeFactory());
- private InvertedRadixTree<Route> ip6BorderRouteTable =
+ private InvertedRadixTree<FabricRoute> ip6BorderRouteTable =
new ConcurrentInvertedRadixTree<>(new DefaultByteArrayNodeFactory());
- // VirtialGateway
+ // Virtual gateway
private Map<IpAddress, MacAddress> virtualGatewayIpMacMap = Maps.newConcurrentMap();
// Refresh monitor thread
@@ -165,7 +162,6 @@
private final InternalNetworkConfigListener configListener = new InternalNetworkConfigListener();
private final InternalDeviceListener deviceListener = new InternalDeviceListener();
private final InternalHostListener hostListener = new InternalHostListener();
- private final InternalInterfaceListener interfaceListener = new InternalInterfaceListener();
private ConfigFactory<ApplicationId, SimpleFabricConfig> simpleFabricConfigFactory =
new ConfigFactory<ApplicationId, SimpleFabricConfig>(
@@ -194,9 +190,9 @@
hostService.addListener(hostListener);
componentService.activate(appId, SimpleFabricNeighbour.class.getName());
- componentService.activate(appId, SimpleFabricReactiveRouting.class.getName());
+ componentService.activate(appId, SimpleFabricRouting.class.getName());
if (ALLOW_ETH_ADDRESS_SELECTOR) {
- componentService.activate(appId, SimpleFabricL2Forward.class.getName());
+ componentService.activate(appId, SimpleFabricForwarding.class.getName());
}
refreshThread = new InternalRefreshThread();
@@ -210,9 +206,9 @@
log.info("simple fabric stopping");
componentService.deactivate(appId, SimpleFabricNeighbour.class.getName());
- componentService.deactivate(appId, SimpleFabricReactiveRouting.class.getName());
+ componentService.deactivate(appId, SimpleFabricRouting.class.getName());
if (ALLOW_ETH_ADDRESS_SELECTOR) {
- componentService.deactivate(appId, SimpleFabricL2Forward.class.getName());
+ componentService.deactivate(appId, SimpleFabricForwarding.class.getName());
}
deviceService.removeListener(deviceListener);
@@ -227,7 +223,7 @@
}
// Set up from configuration
- // returns found dirty and refresh listners are called (true) or not (false)
+ // returns found isDirty and refresh listeners are called (true) or not (false)
private boolean refresh() {
log.debug("simple fabric refresh");
boolean dirty = false;
@@ -239,66 +235,66 @@
return false;
}
- // l2Networks
- Set<L2Network> newL2Networks = new HashSet<>();
- Set<Interface> newL2NetworkInterfaces = new HashSet<>();
- for (L2Network newL2NetworkConfig : config.getL2Networks()) {
- L2Network newL2Network = L2Network.of(newL2NetworkConfig);
+ // 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 : newL2NetworkConfig.interfaceNames()) {
+ for (String ifaceName : newFabricNetworkConfig.interfaceNames()) {
Interface iface = getInterfaceByName(ifaceName);
if (iface != null && deviceService.isAvailable(iface.connectPoint().deviceId())) {
- newL2Network.addInterface(iface);
- newL2NetworkInterfaces.add(iface);
+ 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 && newL2Network.contains(iface)) {
- newL2Network.addHost(host);
+ if (iface != null && newFabricNetwork.contains(iface)) {
+ newFabricNetwork.addHost(host);
}
}
}
- newL2Network.setDirty(true);
+ newFabricNetwork.setDirty(true);
- // update newL2Network's dirty flags if same entry already exists
- for (L2Network prevL2Network : l2Networks) {
- if (prevL2Network.equals(newL2Network)) {
- newL2Network.setDirty(prevL2Network.dirty());
+ // update newFabricNetwork's isDirty flags if same entry already exists
+ for (FabricNetwork prevFabricNetwork : fabricNetworks) {
+ if (prevFabricNetwork.equals(newFabricNetwork)) {
+ newFabricNetwork.setDirty(prevFabricNetwork.isDirty());
break;
}
}
- newL2Networks.add(newL2Network);
+ newFabricNetworks.add(newFabricNetwork);
}
- if (!l2Networks.equals(newL2Networks)) {
- l2Networks = newL2Networks;
+ if (!fabricNetworks.equals(newFabricNetworks)) {
+ fabricNetworks = newFabricNetworks;
dirty = true;
}
- if (!l2NetworkInterfaces.equals(newL2NetworkInterfaces)) {
- l2NetworkInterfaces = newL2NetworkInterfaces;
+ if (!networkInterfaces.equals(newInterfaces)) {
+ networkInterfaces = newInterfaces;
dirty = true;
}
- // ipSubnets
- Set<IpSubnet> newIpSubnets = config.ipSubnets();
- InvertedRadixTree<IpSubnet> newIp4SubnetTable =
+ // default Fabric Subnets
+ Set<FabricSubnet> newFabricSubnets = config.fabricSubnets();
+ InvertedRadixTree<FabricSubnet> newIp4SubnetTable =
new ConcurrentInvertedRadixTree<>(new DefaultByteArrayNodeFactory());
- InvertedRadixTree<IpSubnet> newIp6SubnetTable =
+ InvertedRadixTree<FabricSubnet> newIp6SubnetTable =
new ConcurrentInvertedRadixTree<>(new DefaultByteArrayNodeFactory());
Map<IpAddress, MacAddress> newVirtualGatewayIpMacMap = Maps.newConcurrentMap();
- for (IpSubnet subnet : newIpSubnets) {
- if (subnet.ipPrefix().isIp4()) {
- newIp4SubnetTable.put(createBinaryString(subnet.ipPrefix()), subnet);
+ for (FabricSubnet subnet : newFabricSubnets) {
+ if (subnet.prefix().isIp4()) {
+ newIp4SubnetTable.put(createBinaryString(subnet.prefix()), subnet);
} else {
- newIp6SubnetTable.put(createBinaryString(subnet.ipPrefix()), subnet);
+ newIp6SubnetTable.put(createBinaryString(subnet.prefix()), subnet);
}
newVirtualGatewayIpMacMap.put(subnet.gatewayIp(), subnet.gatewayMac());
}
- if (!ipSubnets.equals(newIpSubnets)) {
- ipSubnets = newIpSubnets;
+ if (!fabricSubnets.equals(newFabricSubnets)) {
+ fabricSubnets = newFabricSubnets;
ip4SubnetTable = newIp4SubnetTable;
ip6SubnetTable = newIp6SubnetTable;
dirty = true;
@@ -308,21 +304,21 @@
dirty = true;
}
- // borderRoutes config handling
- Set<Route> newBorderRoutes = config.borderRoutes();
- if (!borderRoutes.equals(newBorderRoutes)) {
- InvertedRadixTree<Route> newIp4BorderRouteTable =
+ // fabricRoutes config handling
+ Set<FabricRoute> newFabricRoutes = config.fabricRoutes();
+ if (!fabricRoutes.equals(newFabricRoutes)) {
+ InvertedRadixTree<FabricRoute> newIp4BorderRouteTable =
new ConcurrentInvertedRadixTree<>(new DefaultByteArrayNodeFactory());
- InvertedRadixTree<Route> newIp6BorderRouteTable =
+ InvertedRadixTree<FabricRoute> newIp6BorderRouteTable =
new ConcurrentInvertedRadixTree<>(new DefaultByteArrayNodeFactory());
- for (Route route : newBorderRoutes) {
+ for (FabricRoute route : newFabricRoutes) {
if (route.prefix().isIp4()) {
newIp4BorderRouteTable.put(createBinaryString(route.prefix()), route);
} else {
newIp6BorderRouteTable.put(createBinaryString(route.prefix()), route);
}
}
- borderRoutes = newBorderRoutes;
+ fabricRoutes = newFabricRoutes;
ip4BorderRouteTable = newIp4BorderRouteTable;
ip6BorderRouteTable = newIp6BorderRouteTable;
dirty = true;
@@ -348,7 +344,7 @@
}
@Override
- public ApplicationId getAppId() {
+ public ApplicationId appId() {
if (appId == null) {
appId = coreService.registerApplication(APP_ID);
}
@@ -356,57 +352,57 @@
}
@Override
- public Collection<L2Network> getL2Networks() {
- return ImmutableSet.copyOf(l2Networks);
+ public Collection<FabricNetwork> fabricNetworks() {
+ return ImmutableSet.copyOf(fabricNetworks);
}
@Override
- public Set<IpSubnet> getIpSubnets() {
- return ImmutableSet.copyOf(ipSubnets);
+ public Set<FabricSubnet> defaultFabricSubnets() {
+ return ImmutableSet.copyOf(fabricSubnets);
}
@Override
- public Set<Route> getBorderRoutes() {
- return ImmutableSet.copyOf(borderRoutes);
+ public Set<FabricRoute> fabricRoutes() {
+ return ImmutableSet.copyOf(fabricRoutes);
}
@Override
- public boolean isVMac(MacAddress mac) {
+ public boolean isVirtualGatewayMac(MacAddress mac) {
return virtualGatewayIpMacMap.containsValue(mac);
}
@Override
- public boolean isL2NetworkInterface(Interface intf) {
- return l2NetworkInterfaces.contains(intf);
+ public boolean isFabricNetworkInterface(Interface intf) {
+ return networkInterfaces.contains(intf);
}
@Override
- public MacAddress findVMacForIp(IpAddress ip) {
+ public MacAddress vMacForIp(IpAddress ip) {
return virtualGatewayIpMacMap.get(ip);
}
@Override
- public L2Network findL2Network(ConnectPoint port, VlanId vlanId) {
- for (L2Network l2Network : l2Networks) {
- if (l2Network.contains(port, vlanId)) {
- return l2Network;
+ public FabricNetwork fabricNetwork(ConnectPoint port, VlanId vlanId) {
+ for (FabricNetwork fabricNetwork : fabricNetworks) {
+ if (fabricNetwork.contains(port, vlanId)) {
+ return fabricNetwork;
}
}
return null;
}
@Override
- public L2Network findL2Network(String name) {
- for (L2Network l2Network : l2Networks) {
- if (l2Network.name().equals(name)) {
- return l2Network;
+ public FabricNetwork fabricNetwork(String name) {
+ for (FabricNetwork fabricNetwork : fabricNetworks) {
+ if (fabricNetwork.name().equals(name)) {
+ return fabricNetwork;
}
}
return null;
}
@Override
- public IpSubnet findIpSubnet(IpAddress ip) {
+ public FabricSubnet fabricSubnet(IpAddress ip) {
if (ip.isIp4()) {
return ip4SubnetTable.getValueForLongestKeyPrefixing(
createBinaryString(IpPrefix.valueOf(ip, Ip4Address.BIT_LENGTH)));
@@ -417,8 +413,8 @@
}
@Override
- public Route findBorderRoute(IpAddress ip) {
- // ASSUME: ipAddress is out of ipSubnet
+ public FabricRoute fabricRoute(IpAddress ip) {
+ // ASSUME: ipAddress is out of fabricSubnet
if (ip.isIp4()) {
return ip4BorderRouteTable.getValueForLongestKeyPrefixing(
createBinaryString(IpPrefix.valueOf(ip, Ip4Address.BIT_LENGTH)));
@@ -430,7 +426,7 @@
@Override
- public Interface findHostInterface(Host host) {
+ public Interface hostInterface(Host host) {
return interfaceService.getInterfaces().stream()
.filter(iface -> iface.connectPoint().equals(host.location()) &&
iface.vlan().equals(host.vlan()))
@@ -449,32 +445,32 @@
@Override
public boolean requestMac(IpAddress ip) {
- IpSubnet ipSubnet = findIpSubnet(ip);
- if (ipSubnet == null) {
- log.warn("simple fabric request mac failed for unknown IpSubnet: {}", ip);
+ FabricSubnet fabricSubnet = fabricSubnet(ip);
+ if (fabricSubnet == null) {
+ log.warn("simple fabric request mac failed for unknown fabricSubnet: {}", ip);
return false;
}
- L2Network l2Network = findL2Network(ipSubnet.l2NetworkName());
- if (l2Network == null) {
- log.warn("simple fabric request mac failed for unknown l2Network name {}: {}",
- ipSubnet.l2NetworkName(), ip);
+ FabricNetwork fabricNetwork = fabricNetwork(fabricSubnet.name());
+ if (fabricNetwork == null) {
+ log.warn("simple fabric request mac failed for unknown fabricNetwork name {}: {}",
+ fabricSubnet.name(), ip);
return false;
}
- log.debug("simple fabric send request mac L2Network {}: {}", l2Network.name(), ip);
- for (Interface iface : l2Network.interfaces()) {
+ log.debug("simple fabric send request mac fabricNetwork {}: {}", fabricNetwork.name(), ip);
+ for (Interface iface : fabricNetwork.interfaces()) {
Ethernet neighbourReq;
if (ip.isIp4()) {
- neighbourReq = ARP.buildArpRequest(ipSubnet.gatewayMac().toBytes(),
- ipSubnet.gatewayIp().toOctets(),
+ neighbourReq = ARP.buildArpRequest(fabricSubnet.gatewayMac().toBytes(),
+ fabricSubnet.gatewayIp().toOctets(),
ip.toOctets(),
iface.vlan().toShort());
} else {
byte[] soliciteIp = IPv6.getSolicitNodeAddress(ip.toOctets());
neighbourReq = NeighborSolicitation.buildNdpSolicit(
ip.toOctets(),
- ipSubnet.gatewayIp().toOctets(),
+ fabricSubnet.gatewayIp().toOctets(),
soliciteIp,
- ipSubnet.gatewayMac().toBytes(),
+ fabricSubnet.gatewayMac().toBytes(),
IPv6.getMCastMacAddress(soliciteIp),
iface.vlan());
}
@@ -506,20 +502,20 @@
out.println(" REACTIVE_MATCH_IP_PROTO=" + REACTIVE_MATCH_IP_PROTO);
out.println("");
out.println("SimpleFabricAppId:");
- out.println(" " + getAppId());
+ out.println(" " + appId());
out.println("");
- out.println("l2Networks:");
- for (L2Network l2Network : getL2Networks()) {
- out.println(" " + l2Network);
+ out.println("fabricNetworks:");
+ for (FabricNetwork fabricNetwork : fabricNetworks()) {
+ out.println(" " + fabricNetwork);
}
out.println("");
- out.println("ipSubnets:");
- for (IpSubnet ipSubnet : getIpSubnets()) {
- out.println(" " + ipSubnet);
+ out.println("fabricSubnets:");
+ for (FabricSubnet fabricIpSubnet : defaultFabricSubnets()) {
+ out.println(" " + fabricIpSubnet);
}
out.println("");
- out.println("borderRoutes:");
- for (Route route : getBorderRoutes()) {
+ out.println("fabricRoutes:");
+ for (FabricRoute route : fabricRoutes()) {
out.println(" " + route);
}
}
diff --git a/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricNeighbour.java b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricNeighbour.java
index 9924343..b17f999 100644
--- a/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricNeighbour.java
+++ b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricNeighbour.java
@@ -30,7 +30,7 @@
import org.onosproject.net.neighbour.NeighbourResolutionService;
import org.onosproject.net.Host;
import org.onosproject.net.host.HostService;
-import org.onosproject.simplefabric.api.L2Network;
+import org.onosproject.simplefabric.api.FabricNetwork;
import org.onosproject.simplefabric.api.SimpleFabricEvent;
import org.onosproject.simplefabric.api.SimpleFabricListener;
import org.onosproject.simplefabric.api.SimpleFabricService;
@@ -77,7 +77,7 @@
@Activate
public void activate() {
- appId = simpleFabric.getAppId();
+ appId = simpleFabric.appId();
simpleFabric.addListener(simpleFabricListener);
refresh();
log.info("simple fabric neighbour started");
@@ -98,7 +98,7 @@
Set<Interface> interfaces = interfaceService.getInterfaces();
// check for new interfaces
for (Interface intf : interfaces) {
- if (!monitoredInterfaces.contains(intf) && simpleFabric.isL2NetworkInterface(intf)) {
+ if (!monitoredInterfaces.contains(intf) && simpleFabric.isFabricNetworkInterface(intf)) {
log.info("simple fabric neighbour register handler: {}", intf);
neighbourService.registerNeighbourHandler(intf, neighbourHandler, appId);
monitoredInterfaces.add(intf);
@@ -134,7 +134,7 @@
* @param context the message context
*/
protected void handleRequest(NeighbourMessageContext context) {
- MacAddress mac = simpleFabric.findVMacForIp(context.target());
+ MacAddress mac = simpleFabric.vMacForIp(context.target());
if (mac != null) {
log.trace("simple fabric neightbour request on virtualGatewayAddress {}; response to {} {} mac={}",
context.target(), context.inPort(), context.vlan(), mac);
@@ -143,8 +143,8 @@
}
// else forward to corresponding host
- L2Network l2Network = simpleFabric.findL2Network(context.inPort(), context.vlan());
- if (l2Network != null) {
+ FabricNetwork fabricNetwork = simpleFabric.fabricNetwork(context.inPort(), context.vlan());
+ if (fabricNetwork != null) {
int numForwards = 0;
if (!context.dstMac().isBroadcast() && !context.dstMac().isMulticast()) {
for (Host host : hostService.getHostsByMac(context.dstMac())) {
@@ -160,7 +160,7 @@
// else do broadcast to all host in the same l2 network
log.trace("simple fabric neightbour request forward broadcast: {} {}",
context.inPort(), context.vlan());
- for (Interface iface : l2Network.interfaces()) {
+ for (Interface iface : fabricNetwork.interfaces()) {
if (!context.inPort().equals(iface.connectPoint())) {
log.trace("simple fabric forward neighbour request broadcast to {}", iface);
context.forward(iface);
@@ -182,10 +182,10 @@
protected void handleReply(NeighbourMessageContext context,
HostService hostService) {
// Find target L2 Network, then reply to the host
- L2Network l2Network = simpleFabric.findL2Network(context.inPort(), context.vlan());
- if (l2Network != null) {
- // TODO: need to check and update simpleFabric.L2Network
- MacAddress mac = simpleFabric.findVMacForIp(context.target());
+ FabricNetwork fabricNetwork = simpleFabric.fabricNetwork(context.inPort(), context.vlan());
+ if (fabricNetwork != null) {
+ // TODO: need to check and update simpleFabric.DefaultFabricNetwork
+ MacAddress mac = simpleFabric.vMacForIp(context.target());
if (mac != null) {
log.trace("simple fabric neightbour response message to virtual gateway; drop: {} {} target={}",
context.inPort(), context.vlan(), context.target());
@@ -196,14 +196,14 @@
log.trace("simple fabric neightbour response message forward: {} {} target={} -> {}",
context.inPort(), context.vlan(), context.target(), hosts);
hosts.stream()
- .map(host -> simpleFabric.findHostInterface(host))
+ .map(host -> simpleFabric.hostInterface(host))
.filter(Objects::nonNull)
.forEach(context::forward);
}
} else {
// this might be happened when we remove an interface from L2 Network
// just ignore this message
- log.warn("simple fabric neightbour response message drop for unknown l2Network: {} {}",
+ log.warn("simple fabric neightbour response message drop for unknown fabricNetwork: {} {}",
context.inPort(), context.vlan());
context.drop();
}
diff --git a/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricReactiveRouting.java b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricRouting.java
similarity index 90%
rename from apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricReactiveRouting.java
rename to apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricRouting.java
index 8dab9c8..7a03b9d 100644
--- a/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricReactiveRouting.java
+++ b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricRouting.java
@@ -70,9 +70,9 @@
import org.onosproject.net.packet.PacketPriority;
import org.onosproject.net.packet.PacketProcessor;
import org.onosproject.net.packet.PacketService;
-import org.onosproject.simplefabric.api.IpSubnet;
-import org.onosproject.simplefabric.api.L2Network;
-import org.onosproject.simplefabric.api.Route;
+import org.onosproject.simplefabric.api.FabricNetwork;
+import org.onosproject.simplefabric.api.FabricSubnet;
+import org.onosproject.simplefabric.api.FabricRoute;
import org.onosproject.simplefabric.api.SimpleFabricEvent;
import org.onosproject.simplefabric.api.SimpleFabricListener;
import org.onosproject.simplefabric.api.SimpleFabricService;
@@ -97,20 +97,20 @@
import static org.onosproject.simplefabric.api.Constants.PRI_REACTIVE_LOCAL_FORWARD;
import static org.onosproject.simplefabric.api.Constants.PRI_REACTIVE_LOCAL_INTERCEPT;
import static org.onosproject.simplefabric.api.Constants.REACTIVE_ALLOW_LINK_CP;
-import static org.onosproject.simplefabric.api.Constants.REACTIVE_APP_ID;
+import static org.onosproject.simplefabric.api.Constants.ROUTING_APP_ID;
import static org.onosproject.simplefabric.api.Constants.REACTIVE_HASHED_PATH_SELECTION;
import static org.onosproject.simplefabric.api.Constants.REACTIVE_MATCH_IP_PROTO;
import static org.onosproject.simplefabric.api.Constants.REACTIVE_SINGLE_TO_SINGLE;
/**
- * SimpleFabricReactiveRouting handles L3 Reactive Routing.
+ * SimpleFabricRouting handles Routing.
*/
@Component(immediate = true, enabled = false)
-public class SimpleFabricReactiveRouting {
+public class SimpleFabricRouting {
private final Logger log = LoggerFactory.getLogger(getClass());
- private ApplicationId reactiveAppId;
+ private ApplicationId appId;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected CoreService coreService;
@@ -150,12 +150,12 @@
// NOTE: manage purged intents by key for intentService.getIntent() supports key only
private final InternalSimpleFabricListener simpleFabricListener = new InternalSimpleFabricListener();
- private ReactiveRoutingProcessor processor = new ReactiveRoutingProcessor();
+ private InternalRoutingProcessor processor = new InternalRoutingProcessor();
@Activate
public void activate() {
- reactiveAppId = coreService.registerApplication(REACTIVE_APP_ID);
- log.info("simple fabric reactive routing starting with app id {}", reactiveAppId.toString());
+ appId = coreService.registerApplication(ROUTING_APP_ID);
+ log.info("simple fabric routing starting with app id {}", appId.toString());
// NOTE: may not clear at init for MIGHT generate pending_remove garbages
// use flush event from simple fabric cli command
@@ -167,19 +167,19 @@
reactiveConstraints = ImmutableList.of(new PartialFailureConstraint());
}
- processor = new ReactiveRoutingProcessor();
+ processor = new InternalRoutingProcessor();
packetService.addProcessor(processor, PacketProcessor.director(2));
simpleFabric.addListener(simpleFabricListener);
registerIntercepts();
refreshIntercepts();
- log.info("simple fabric reactive routing started");
+ log.info("simple fabric routing started");
}
@Deactivate
public void deactivate() {
- log.info("simple fabric reactive routing stopping");
+ log.info("simple fabric routing stopping");
packetService.removeProcessor(processor);
simpleFabric.removeListener(simpleFabricListener);
@@ -191,11 +191,11 @@
toBePurgedIntentKeys.clear();
- flowRuleService.removeFlowRulesById(reactiveAppId);
+ flowRuleService.removeFlowRulesById(appId);
processor = null;
- log.info("simple fabric reactive routing stopped");
+ log.info("simple fabric routing stopped");
}
/**
@@ -206,15 +206,15 @@
packetService.requestPackets(
DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).build(),
- PacketPriority.REACTIVE, reactiveAppId);
+ PacketPriority.REACTIVE, appId);
if (ALLOW_IPV6) {
packetService.requestPackets(
DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV6).build(),
- PacketPriority.REACTIVE, reactiveAppId);
+ PacketPriority.REACTIVE, appId);
}
- log.info("simple fabric reactive routing ip packet intercepts started");
+ log.info("simple fabric routing ip packet intercepts started");
}
/**
@@ -225,35 +225,35 @@
packetService.cancelPackets(
DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).build(),
- PacketPriority.REACTIVE, reactiveAppId);
+ PacketPriority.REACTIVE, appId);
if (ALLOW_IPV6) {
packetService.cancelPackets(
DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV6).build(),
- PacketPriority.REACTIVE, reactiveAppId);
+ PacketPriority.REACTIVE, appId);
}
- log.info("simple fabric reactive routing ip packet intercepts stopped");
+ log.info("simple fabric routing ip packet intercepts stopped");
}
/**
- * Refresh device flow rules for reative intercepts on local ipSubnets.
+ * Refresh device flow rules for intercepts on local fabricSubnets.
*/
private void refreshIntercepts() {
Set<FlowRule> newInterceptFlowRules = new HashSet<>();
for (Device device : deviceService.getAvailableDevices()) {
- for (IpSubnet subnet : simpleFabric.getIpSubnets()) {
- newInterceptFlowRules.add(generateInterceptFlowRule(true, device.id(), subnet.ipPrefix()));
- // check if this devices has the ipSubnet, then add ip broadcast flue rule
- L2Network l2Network = simpleFabric.findL2Network(subnet.l2NetworkName());
- if (l2Network != null && l2Network.contains(device.id())) {
- newInterceptFlowRules.add(generateLocalSubnetIpBctFlowRule(device.id(), subnet.ipPrefix(),
- l2Network));
+ 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.name());
+ 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 (Route route : simpleFabric.getBorderRoutes()) {
+ for (FabricRoute route : simpleFabric.fabricRoutes()) {
newInterceptFlowRules.add(generateInterceptFlowRule(false, device.id(), route.prefix()));
}
}
@@ -272,7 +272,7 @@
.filter(rule -> !interceptFlowRules.contains(rule))
.forEach(rule -> {
flowRuleService.applyFlowRules(rule);
- log.info("simple fabric reactive routing apply intercept flow rule: {}", rule);
+ log.info("simple fabric routing apply intercept flow rule: {}", rule);
});
interceptFlowRules = newInterceptFlowRules;
}
@@ -296,13 +296,13 @@
.withPriority(reactivePriority(false, isDstLocalSubnet, prefix.prefixLength()))
.withSelector(selector.build())
.withTreatment(DefaultTrafficTreatment.builder().punt().build())
- .fromApp(reactiveAppId)
+ .fromApp(appId)
.makePermanent()
.forTable(0).build();
return rule;
}
- private FlowRule generateLocalSubnetIpBctFlowRule(DeviceId deviceId, IpPrefix prefix, L2Network l2Network) {
+ private FlowRule generateLocalSubnetIpBctFlowRule(DeviceId deviceId, IpPrefix prefix, FabricNetwork fabricNetwork) {
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
IpPrefix bctPrefix;
if (prefix.isIp4()) {
@@ -323,7 +323,7 @@
}
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
Set<ConnectPoint> newEgressPoints = new HashSet<>();
- for (Interface iface : l2Network.interfaces()) {
+ for (Interface iface : fabricNetwork.interfaces()) {
if (iface.connectPoint().deviceId().equals(deviceId)) {
treatment.setOutput(iface.connectPoint().port());
}
@@ -333,7 +333,7 @@
.withPriority(reactivePriority(true, true, bctPrefix.prefixLength()))
.withSelector(selector.build())
.withTreatment(treatment.build())
- .fromApp(reactiveAppId)
+ .fromApp(appId)
.makePermanent()
.forTable(0).build();
return rule;
@@ -344,7 +344,7 @@
*/
private void refreshRouteIntents() {
for (Intent entry : intentService.getIntents()) {
- if (!reactiveAppId.equals(entry.appId())) {
+ if (!appId.equals(entry.appId())) {
continue;
}
@@ -382,7 +382,7 @@
toBePurgedIntentKeys.add(intent.key());
continue;
}
- if (!(simpleFabric.findL2Network(intent.egressPoint(), VlanId.NONE) != null ||
+ if (!(simpleFabric.fabricNetwork(intent.egressPoint(), VlanId.NONE) != null ||
(REACTIVE_ALLOW_LINK_CP &&
!linkService.getEgressLinks(intent.egressPoint()).isEmpty()))) {
log.info("refresh route intents; remove intent for egress point not available: key={}", intent.key());
@@ -401,7 +401,7 @@
boolean ingressPointChanged = false;
for (FilteredConnectPoint cp : intent.filteredIngressPoints()) {
if (deviceService.isAvailable(cp.connectPoint().deviceId()) &&
- (simpleFabric.findL2Network(cp.connectPoint(), VlanId.NONE) != null ||
+ (simpleFabric.fabricNetwork(cp.connectPoint(), VlanId.NONE) != null ||
(REACTIVE_ALLOW_LINK_CP &&
!linkService.getIngressLinks(cp.connectPoint()).isEmpty()))) {
newIngressPoints.add(cp);
@@ -422,7 +422,7 @@
if (ingressPointChanged) {
MultiPointToSinglePointIntent updatedIntent =
MultiPointToSinglePointIntent.builder()
- .appId(reactiveAppId)
+ .appId(appId)
.key(intent.key())
.selector(intent.selector())
.treatment(intent.treatment())
@@ -486,7 +486,7 @@
// NOTE: cli calls are handling within the cli called node only; so should not user inents.isLocal()
Set<Intent> myIntents = new HashSet<>();
for (Intent intent : intentService.getIntents()) {
- if (reactiveAppId.equals(intent.appId())) {
+ if (appId.equals(intent.appId())) {
myIntents.add(intent);
}
}
@@ -523,9 +523,9 @@
}
/**
- * Reactive Packet Handling.
+ * Internal Packet Handling.
*/
- private class ReactiveRoutingProcessor implements PacketProcessor {
+ private class InternalRoutingProcessor implements PacketProcessor {
@Override
public void process(PacketContext context) {
InboundPacket pkt = context.inPacket();
@@ -572,8 +572,8 @@
private boolean checkVirtualGatewayIpPacket(InboundPacket pkt, IpAddress srcIp, IpAddress dstIp) {
Ethernet ethPkt = pkt.parsed(); // assume valid
- MacAddress mac = simpleFabric.findVMacForIp(dstIp);
- if (mac == null || !simpleFabric.isVMac(ethPkt.getDestinationMAC())) {
+ MacAddress mac = simpleFabric.vMacForIp(dstIp);
+ if (mac == null || !simpleFabric.isVirtualGatewayMac(ethPkt.getDestinationMAC())) {
/* Destination MAC should be any of virtual gateway macs */
return false;
} else if (dstIp.isIp4()) {
@@ -641,12 +641,12 @@
IpAddress dstNextHop = dstIp;
MacAddress treatmentSrcMac = ethPkt.getDestinationMAC();
int borderRoutePrefixLength = 0;
- boolean updateMac = simpleFabric.isVMac(ethPkt.getDestinationMAC());
+ boolean updateMac = simpleFabric.isVirtualGatewayMac(ethPkt.getDestinationMAC());
// check subnet local or route
- IpSubnet srcSubnet = simpleFabric.findIpSubnet(srcIp);
+ FabricSubnet srcSubnet = simpleFabric.fabricSubnet(srcIp);
if (srcSubnet == null) {
- Route route = simpleFabric.findBorderRoute(srcIp);
+ FabricRoute route = simpleFabric.fabricRoute(srcIp);
if (route == null) {
log.warn("unknown srcIp; drop: srcCp={} srcIp={} dstIp={} ipProto={}",
srcCp, srcIp, dstIp, ipProto);
@@ -656,9 +656,9 @@
srcNextHop = route.nextHop();
borderRoutePrefixLength = route.prefix().prefixLength();
}
- IpSubnet dstSubnet = simpleFabric.findIpSubnet(dstIp);
+ FabricSubnet dstSubnet = simpleFabric.fabricSubnet(dstIp);
if (dstSubnet == null) {
- Route route = simpleFabric.findBorderRoute(dstIp);
+ FabricRoute route = simpleFabric.fabricRoute(dstIp);
if (route == null) {
log.warn("unknown dstIp; drop: srcCp={} srcIp={} dstIp={} ipProto={}",
srcCp, srcIp, dstIp, ipProto);
@@ -672,10 +672,10 @@
if (dstSubnet != null) {
// destination is local subnet ip
if (ALLOW_ETH_ADDRESS_SELECTOR && dstSubnet.equals(srcSubnet)) {
- // NOTE: if ALLOW_ETH_ADDRESS_SELECTOR=false; l2Forward is always false
- L2Network l2Network = simpleFabric.findL2Network(dstSubnet.l2NetworkName());
+ // NOTE: if ALLOW_ETH_ADDRESS_SELECTOR=false; isForward is always false
+ FabricNetwork fabricNetwork = simpleFabric.fabricNetwork(dstSubnet.name());
treatmentSrcMac = ethPkt.getSourceMAC();
- if (l2Network != null && l2Network.l2Forward()) {
+ if (fabricNetwork != null && fabricNetwork.isForward()) {
// NOTE: no reactive route action but do forward packet for L2Forward do not handle packet
// update mac only if dstMac is virtualGatewayMac, else assume valid mac already for the l2 network
log.info("LOCAL FORWARD ONLY: "
@@ -729,7 +729,7 @@
log.warn("forward packet nextHopIp host_mac unknown: nextHopIp={}", nextHopIp);
hostService.startMonitoringIp(nextHopIp);
simpleFabric.requestMac(nextHopIp);
- // CONSIDER: make flood on all port of the dstHost's L2Network
+ // CONSIDER: make flood on all port of the dstHost's DefaultFabricNetwork
return;
}
TrafficTreatment treatment = DefaultTrafficTreatment.builder()
@@ -756,15 +756,15 @@
*
* ToHost: dstPrefix = dstHostIp.toIpPrefix(), nextHopIp = destHostIp
* ToInternet: dstPrefix = route.prefix(), nextHopIp = route.nextHopIp
- * returns intent submited or not
+ * returns intent submitted or not
*/
private boolean setUpConnectivity(ConnectPoint srcCp, byte ipProto, IpPrefix srcPrefix, IpPrefix dstPrefix,
IpAddress nextHopIp, MacAddress treatmentSrcMac,
EncapsulationType encap, boolean updateMac,
boolean isDstLocalSubnet, int borderRoutePrefixLength) {
- if (!(simpleFabric.findL2Network(srcCp, VlanId.NONE) != null ||
+ if (!(simpleFabric.fabricNetwork(srcCp, VlanId.NONE) != null ||
(REACTIVE_ALLOW_LINK_CP && !linkService.getIngressLinks(srcCp).isEmpty()))) {
- log.warn("NO REGI for srcCp not in L2Network; srcCp={} srcPrefix={} dstPrefix={} nextHopIp={}",
+ log.warn("NO REGI for srcCp not in DefaultFabricNetwork; srcCp={} srcPrefix={} dstPrefix={} nextHopIp={}",
srcCp, srcPrefix, dstPrefix, nextHopIp);
return false;
}
@@ -824,10 +824,10 @@
}
if (REACTIVE_SINGLE_TO_SINGLE) {
// allocate intent per (srcPrefix, dstPrefix)
- key = Key.of(srcPrefix.toString() + "-to-" + dstPrefix.toString() + keyProtoTag, reactiveAppId);
+ key = Key.of(srcPrefix.toString() + "-to-" + dstPrefix.toString() + keyProtoTag, appId);
} else {
// allocate intent per (srcDeviceId, dstPrefix)
- key = Key.of(srcCp.deviceId().toString() + "-to-" + dstPrefix.toString() + keyProtoTag, reactiveAppId);
+ key = Key.of(srcCp.deviceId().toString() + "-to-" + dstPrefix.toString() + keyProtoTag, appId);
}
// check and merge already existing ingress points
@@ -855,7 +855,7 @@
MultiPointToSinglePointIntent newIntent = MultiPointToSinglePointIntent.builder()
.key(key)
- .appId(reactiveAppId)
+ .appId(appId)
.selector(selector.build())
.treatment(treatment)
.filteredIngressPoints(ingressPoints)
@@ -863,7 +863,7 @@
.priority(priority)
.constraints(buildConstraints(reactiveConstraints, encap))
.build();
- log.info("submmit mp2p intent: srcPrefix={} dstPrefix={} srcCp={} "
+ log.info("submit mp2p intent: srcPrefix={} dstPrefix={} srcCp={} "
+ "newIntent={} nextHopIp={} nextHopMac={} priority={}",
srcPrefix, dstPrefix, ingressPoints, newIntent, nextHopIp, nextHopMac, priority);
toBePurgedIntentKeys.remove(newIntent.key());
@@ -882,7 +882,7 @@
// monitor border peers for routeService lookup to be effective
private void monitorBorderPeers() {
- for (Route route : simpleFabric.getBorderRoutes()) {
+ for (FabricRoute route : simpleFabric.fabricRoutes()) {
hostService.startMonitoringIp(route.nextHop());
simpleFabric.requestMac(route.nextHop());
}
@@ -924,9 +924,9 @@
// Dump Cli Handler
private void dump(String subject, PrintStream out) {
if ("intents".equals(subject)) {
- out.println("Reactive Routing Route Intents:\n");
+ out.println("Routing Route Intents:\n");
for (Intent entry : intentService.getIntents()) {
- if (reactiveAppId.equals(entry.appId())) {
+ if (appId.equals(entry.appId())) {
MultiPointToSinglePointIntent intent = (MultiPointToSinglePointIntent) entry;
out.println(" " + intent.key().toString()
+ " to " + intent.egressPoint().toString()
@@ -936,7 +936,7 @@
}
out.println("");
- out.println("Reactive Routing Intercept Flow Rules:\n");
+ out.println("Routing Intercept Flow Rules:\n");
List<FlowRule> rules = new ArrayList(interceptFlowRules);
Collections.sort(rules, new Comparator<FlowRule>() {
@Override
@@ -951,7 +951,7 @@
+ " selector=" + rule.selector().criteria().toString());
}
out.println("");
- out.println("Reactive Routing Intents to Be Purged:\n");
+ out.println("Routing Intents to Be Purged:\n");
for (Key key: toBePurgedIntentKeys) {
out.println(" " + key.toString());
}
@@ -959,7 +959,7 @@
} else if ("reactive-intents".equals(subject)) {
for (Intent entry : intentService.getIntents()) {
- if (reactiveAppId.equals(entry.appId())) {
+ if (appId.equals(entry.appId())) {
MultiPointToSinglePointIntent intent = (MultiPointToSinglePointIntent) entry;
out.println(intent.key().toString()
+ " to " + intent.egressPoint().toString()