mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-17 10:21:52 +02:00
Refactor: extract interfaces for a set of simple fabric classes
Change-Id: I4a23fb2277498f466ce20f82e38d5e9cb25dab6e
This commit is contained in:
parent
8df54a9dc8
commit
e2d87513be
@ -26,8 +26,8 @@ public final class Constants {
|
||||
|
||||
// App symbols
|
||||
public static final String APP_ID = "org.onosproject.simplefabric";
|
||||
public static final String L2FORWARD_APP_ID = "org.onosproject.simplefabric.l2forward";
|
||||
public static final String REACTIVE_APP_ID = "org.onosproject.simplefabric.reactive";
|
||||
public static final String FORWARDING_APP_ID = "org.onosproject.simplefabric.forwarding";
|
||||
public static final String ROUTING_APP_ID = "org.onosproject.simplefabric.routing";
|
||||
|
||||
// Priority for l2NetworkRouting: L2NETWORK_UNICAST or L2NETWORK_BROADCAST
|
||||
public static final int PRI_L2NETWORK_UNICAST = 601;
|
||||
|
@ -0,0 +1,315 @@
|
||||
/*
|
||||
* Copyright 2018-present Open Networking Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.onosproject.simplefabric.api;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.onlab.packet.VlanId;
|
||||
import org.onosproject.net.ConnectPoint;
|
||||
import org.onosproject.net.DeviceId;
|
||||
import org.onosproject.net.EncapsulationType;
|
||||
import org.onosproject.net.Host;
|
||||
import org.onosproject.net.HostId;
|
||||
import org.onosproject.net.intf.Interface;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static org.onosproject.simplefabric.api.Constants.ALLOW_ETH_ADDRESS_SELECTOR;
|
||||
|
||||
|
||||
/**
|
||||
* Class stores a DefaultFabricNetwork information.
|
||||
*/
|
||||
public final class DefaultFabricNetwork implements FabricNetwork {
|
||||
|
||||
private static final String NOT_NULL_MSG = "FabricNetwork % cannot be null";
|
||||
|
||||
private final String name;
|
||||
private final Set<String> interfaceNames;
|
||||
private final EncapsulationType encapsulation;
|
||||
private boolean forward;
|
||||
private boolean broadcast;
|
||||
|
||||
/* status variables */
|
||||
private final Set<Interface> interfaces;
|
||||
private final Set<HostId> hostIds;
|
||||
private boolean dirty;
|
||||
|
||||
/**
|
||||
* Constructs a DefaultFabricNetwork instance.
|
||||
*
|
||||
* @param name fabric name name
|
||||
* @param interfaceNames a collection of interface names
|
||||
* @param encapsulation encapsulation type
|
||||
* @param forward flag for forward intents to be installed or not
|
||||
* @param broadcast flag for broadcast intents to be installed or not
|
||||
*/
|
||||
private DefaultFabricNetwork(String name, Collection<String> interfaceNames,
|
||||
EncapsulationType encapsulation,
|
||||
boolean forward, boolean broadcast) {
|
||||
this.name = name;
|
||||
this.interfaceNames = Sets.newHashSet();
|
||||
|
||||
if (interfaceNames != null) {
|
||||
this.interfaceNames.addAll(interfaceNames);
|
||||
}
|
||||
|
||||
this.encapsulation = encapsulation;
|
||||
this.forward = (ALLOW_ETH_ADDRESS_SELECTOR) && forward;
|
||||
this.broadcast = (ALLOW_ETH_ADDRESS_SELECTOR) && broadcast;
|
||||
this.interfaces = Sets.newHashSet();
|
||||
this.hostIds = Sets.newHashSet();
|
||||
this.dirty = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a DefaultFabricNetwork instance.
|
||||
*
|
||||
* @param name fabric network name
|
||||
* @param encapsulation encapsulation type
|
||||
*/
|
||||
private DefaultFabricNetwork(String name, EncapsulationType encapsulation) {
|
||||
this.name = name;
|
||||
this.interfaceNames = Sets.newHashSet();
|
||||
this.encapsulation = encapsulation;
|
||||
this.forward = ALLOW_ETH_ADDRESS_SELECTOR;
|
||||
this.broadcast = ALLOW_ETH_ADDRESS_SELECTOR;
|
||||
this.interfaces = Sets.newHashSet();
|
||||
this.hostIds = Sets.newHashSet();
|
||||
this.dirty = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DefaultFabricNetwork data by given name.
|
||||
* The encapsulation type of the DefaultFabricNetwork will be NONE.
|
||||
*
|
||||
* @param name fabric network name
|
||||
* @return DefaultFabricNetwork instance
|
||||
*/
|
||||
public static FabricNetwork of(String name) {
|
||||
Objects.requireNonNull(name);
|
||||
return new DefaultFabricNetwork(name, EncapsulationType.NONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a copy of DefaultFabricNetwork instance.
|
||||
*
|
||||
* @param fabricNetwork DefaultFabricNetwork instance
|
||||
* @return the copy of the DefaultFabricNetwork instance
|
||||
*/
|
||||
public static FabricNetwork of(FabricNetwork fabricNetwork) {
|
||||
Objects.requireNonNull(fabricNetwork);
|
||||
DefaultFabricNetwork fabricNetworkCopy =
|
||||
new DefaultFabricNetwork(fabricNetwork.name(), fabricNetwork.encapsulation());
|
||||
fabricNetworkCopy.interfaceNames.addAll(fabricNetwork.interfaceNames());
|
||||
fabricNetworkCopy.forward = (ALLOW_ETH_ADDRESS_SELECTOR) && fabricNetwork.isForward();
|
||||
fabricNetworkCopy.broadcast = (ALLOW_ETH_ADDRESS_SELECTOR) && fabricNetwork.isBroadcast();
|
||||
fabricNetworkCopy.interfaces.addAll(fabricNetwork.interfaces());
|
||||
fabricNetworkCopy.hostIds.addAll(fabricNetwork.hostIds());
|
||||
fabricNetworkCopy.setDirty(fabricNetwork.isDirty());
|
||||
return fabricNetworkCopy;
|
||||
}
|
||||
|
||||
// field queries
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> interfaceNames() {
|
||||
return ImmutableSet.copyOf(interfaceNames);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EncapsulationType encapsulation() {
|
||||
return encapsulation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isForward() {
|
||||
return forward;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBroadcast() {
|
||||
return broadcast;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Interface> interfaces() {
|
||||
return ImmutableSet.copyOf(interfaces);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<HostId> hostIds() {
|
||||
return ImmutableSet.copyOf(hostIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDirty() {
|
||||
return dirty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Interface iface) {
|
||||
return interfaces.contains(iface);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(ConnectPoint port, VlanId vlanId) {
|
||||
for (Interface iface : interfaces) {
|
||||
if (iface.connectPoint().equals(port) && iface.vlan().equals(vlanId)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(DeviceId deviceId) {
|
||||
for (Interface iface : interfaces) {
|
||||
if (iface.connectPoint().deviceId().equals(deviceId)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInterface(Interface iface) {
|
||||
Objects.requireNonNull(iface);
|
||||
if (interfaces.add(iface)) {
|
||||
setDirty(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addHost(Host host) {
|
||||
Objects.requireNonNull(host);
|
||||
if (hostIds.add(host.id())) {
|
||||
setDirty(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDirty(boolean newDirty) {
|
||||
dirty = newDirty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(getClass())
|
||||
.add("name", name)
|
||||
.add("interfaceNames", interfaceNames)
|
||||
.add("encapsulation", encapsulation)
|
||||
.add("forward", forward)
|
||||
.add("broadcast", broadcast)
|
||||
.add("interfaces", interfaces)
|
||||
.add("hostIds", hostIds)
|
||||
.add("isDirty", dirty)
|
||||
.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof DefaultFabricNetwork)) {
|
||||
return false;
|
||||
}
|
||||
DefaultFabricNetwork other = (DefaultFabricNetwork) obj;
|
||||
return Objects.equals(other.name, this.name)
|
||||
&& Objects.equals(other.interfaceNames, this.interfaceNames)
|
||||
&& Objects.equals(other.encapsulation, this.encapsulation)
|
||||
&& Objects.equals(other.forward, this.forward)
|
||||
&& Objects.equals(other.broadcast, this.broadcast)
|
||||
&& Objects.equals(other.interfaces, this.interfaces)
|
||||
&& Objects.equals(other.hostIds, this.hostIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name, interfaces, encapsulation, forward, broadcast);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new builder instance.
|
||||
*
|
||||
* @return fabric network builder
|
||||
*/
|
||||
public static DefaultFabricNetworkBuilder builder() {
|
||||
return new DefaultFabricNetworkBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* A builder class for fabric network.
|
||||
*/
|
||||
public static final class DefaultFabricNetworkBuilder implements Builder {
|
||||
private String name;
|
||||
private Set<String> interfaceNames;
|
||||
private EncapsulationType encapsulation;
|
||||
private boolean forward;
|
||||
private boolean broadcast;
|
||||
|
||||
private DefaultFabricNetworkBuilder() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder interfaceNames(Set<String> interfaceNames) {
|
||||
this.interfaceNames = interfaceNames;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder encapsulation(EncapsulationType encapsulation) {
|
||||
this.encapsulation = encapsulation;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder forward(boolean forward) {
|
||||
this.forward = forward;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder broadcast(boolean broadcast) {
|
||||
this.broadcast = broadcast;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FabricNetwork build() {
|
||||
checkArgument(name != null, NOT_NULL_MSG, "name");
|
||||
return new DefaultFabricNetwork(name, interfaceNames,
|
||||
encapsulation, forward, broadcast);
|
||||
}
|
||||
}
|
||||
}
|
@ -13,10 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*
|
||||
* local copy of onos/incubator/api/src/main/java/org/onosproject/incubator/net/routing/Route.java
|
||||
* to remove dependency on onos.incubator.routing services, since 2017-08-09.
|
||||
*/
|
||||
|
||||
package org.onosproject.simplefabric.api;
|
||||
|
||||
@ -33,38 +29,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
/**
|
||||
* Represents a route.
|
||||
*/
|
||||
public class Route {
|
||||
public final class DefaultFabricRoute implements FabricRoute {
|
||||
|
||||
private static final String VERSION_MISMATCH =
|
||||
"Prefix and next hop must be in the same address family";
|
||||
|
||||
private static final NodeId UNDEFINED = new NodeId("-");
|
||||
|
||||
/**
|
||||
* Source of the route.
|
||||
*/
|
||||
public enum Source {
|
||||
/**
|
||||
* Route came from the iBGP route source.
|
||||
*/
|
||||
BGP,
|
||||
|
||||
/**
|
||||
* Route came from the FPM route source.
|
||||
*/
|
||||
FPM,
|
||||
|
||||
/**
|
||||
* Route can from the static route source.
|
||||
*/
|
||||
STATIC,
|
||||
|
||||
/**
|
||||
* Route source was not defined.
|
||||
*/
|
||||
UNDEFINED
|
||||
}
|
||||
|
||||
private final Source source;
|
||||
private final IpPrefix prefix;
|
||||
private final IpAddress nextHop;
|
||||
@ -77,7 +48,7 @@ public class Route {
|
||||
* @param prefix IP prefix
|
||||
* @param nextHop next hop IP address
|
||||
*/
|
||||
public Route(Source source, IpPrefix prefix, IpAddress nextHop) {
|
||||
private DefaultFabricRoute(Source source, IpPrefix prefix, IpAddress nextHop) {
|
||||
this(source, prefix, nextHop, UNDEFINED);
|
||||
}
|
||||
|
||||
@ -89,49 +60,30 @@ public class Route {
|
||||
* @param nextHop next hop IP address
|
||||
* @param sourceNode ONOS node the route was sourced from
|
||||
*/
|
||||
public Route(Source source, IpPrefix prefix, IpAddress nextHop, NodeId sourceNode) {
|
||||
checkNotNull(prefix);
|
||||
checkNotNull(nextHop);
|
||||
checkArgument(prefix.version().equals(nextHop.version()), VERSION_MISMATCH);
|
||||
|
||||
private DefaultFabricRoute(Source source, IpPrefix prefix,
|
||||
IpAddress nextHop, NodeId sourceNode) {
|
||||
this.source = checkNotNull(source);
|
||||
this.prefix = prefix;
|
||||
this.nextHop = nextHop;
|
||||
this.sourceNode = checkNotNull(sourceNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the route source.
|
||||
*
|
||||
* @return route source
|
||||
*/
|
||||
@Override
|
||||
public Source source() {
|
||||
return source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the IP prefix of the route.
|
||||
*
|
||||
* @return IP prefix
|
||||
*/
|
||||
@Override
|
||||
public IpPrefix prefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the next hop IP address.
|
||||
*
|
||||
* @return next hop
|
||||
*/
|
||||
@Override
|
||||
public IpAddress nextHop() {
|
||||
return nextHop;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ONOS node the route was sourced from.
|
||||
*
|
||||
* @return ONOS node ID
|
||||
*/
|
||||
@Override
|
||||
public NodeId sourceNode() {
|
||||
return sourceNode;
|
||||
}
|
||||
@ -147,11 +99,11 @@ public class Route {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(other instanceof Route)) {
|
||||
if (!(other instanceof DefaultFabricRoute)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Route that = (Route) other;
|
||||
DefaultFabricRoute that = (DefaultFabricRoute) other;
|
||||
|
||||
return Objects.equals(this.prefix, that.prefix) &&
|
||||
Objects.equals(this.nextHop, that.nextHop);
|
||||
@ -164,4 +116,64 @@ public class Route {
|
||||
.add("nextHop", nextHop)
|
||||
.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new builder instance.
|
||||
*
|
||||
* @return fabric route builder
|
||||
*/
|
||||
public static DefaultFabricRouteBuilder builder() {
|
||||
return new DefaultFabricRouteBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* A builder class for fabric route.
|
||||
*/
|
||||
public static final class DefaultFabricRouteBuilder implements Builder {
|
||||
private Source source;
|
||||
private IpPrefix prefix;
|
||||
private IpAddress nextHop;
|
||||
private NodeId sourceNode;
|
||||
|
||||
private DefaultFabricRouteBuilder() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder source(Source source) {
|
||||
this.source = source;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder prefix(IpPrefix prefix) {
|
||||
this.prefix = prefix;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder nextHop(IpAddress nextHop) {
|
||||
this.nextHop = nextHop;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder sourceNode(NodeId sourceNode) {
|
||||
this.sourceNode = sourceNode;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FabricRoute build() {
|
||||
|
||||
checkNotNull(prefix);
|
||||
checkNotNull(nextHop);
|
||||
checkArgument(prefix.version().equals(nextHop.version()), VERSION_MISMATCH);
|
||||
|
||||
if (sourceNode != null) {
|
||||
return new DefaultFabricRoute(source, prefix, nextHop, sourceNode);
|
||||
} else {
|
||||
return new DefaultFabricRoute(source, prefix, nextHop);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,194 @@
|
||||
/*
|
||||
* Copyright 2018-present Open Networking Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.onosproject.simplefabric.api;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import org.onlab.packet.IpAddress;
|
||||
import org.onlab.packet.IpPrefix;
|
||||
import org.onlab.packet.MacAddress;
|
||||
import org.onosproject.net.EncapsulationType;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
/**
|
||||
* Configuration details for an ip subnet entry.
|
||||
*/
|
||||
public final class DefaultFabricSubnet implements FabricSubnet {
|
||||
|
||||
private static final String NOT_NULL_MSG = "FabricSubnet % cannot be null";
|
||||
|
||||
private final IpPrefix prefix;
|
||||
private final IpAddress gatewayIp;
|
||||
private final MacAddress gatewayMac;
|
||||
private EncapsulationType encapsulation;
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* Creates a new subnet entry.
|
||||
*
|
||||
* @param prefix an ip subnet
|
||||
* @param gatewayIp IP of the virtual gateway
|
||||
* @param gatewayMac MacAddress of the virtual gateway
|
||||
* @param encapsulation encapsulation type
|
||||
* @param name subnet name
|
||||
*/
|
||||
private DefaultFabricSubnet(IpPrefix prefix, IpAddress gatewayIp,
|
||||
MacAddress gatewayMac, EncapsulationType encapsulation,
|
||||
String name) {
|
||||
this.prefix = prefix;
|
||||
this.gatewayIp = gatewayIp;
|
||||
this.gatewayMac = gatewayMac;
|
||||
this.encapsulation = encapsulation;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IpPrefix prefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IpAddress gatewayIp() {
|
||||
return gatewayIp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MacAddress gatewayMac() {
|
||||
return gatewayMac;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EncapsulationType encapsulation() {
|
||||
return encapsulation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIp4() {
|
||||
return prefix.isIp4();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIp6() {
|
||||
return prefix.isIp6();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(prefix, gatewayIp, gatewayMac, encapsulation, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof DefaultFabricSubnet)) {
|
||||
return false;
|
||||
}
|
||||
DefaultFabricSubnet that = (DefaultFabricSubnet) obj;
|
||||
return Objects.equals(this.prefix, that.prefix)
|
||||
&& Objects.equals(this.gatewayIp, that.gatewayIp)
|
||||
&& Objects.equals(this.gatewayMac, that.gatewayMac)
|
||||
&& Objects.equals(this.encapsulation, that.encapsulation)
|
||||
&& Objects.equals(this.name, that.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(getClass())
|
||||
.add("prefix", prefix)
|
||||
.add("gatewayIp", gatewayIp)
|
||||
.add("gatewayMac", gatewayMac)
|
||||
.add("encapsulation", encapsulation)
|
||||
.add("name", name)
|
||||
.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new builder instance.
|
||||
*
|
||||
* @return fabric IP subnet builder
|
||||
*/
|
||||
public static DefaultSubnetBuilder builder() {
|
||||
return new DefaultSubnetBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* A builder class for Ip Subnet.
|
||||
*/
|
||||
public static final class DefaultSubnetBuilder implements Builder {
|
||||
private IpPrefix ipPrefix;
|
||||
private IpAddress gatewayIp;
|
||||
private MacAddress gatewayMac;
|
||||
private EncapsulationType encapsulation;
|
||||
private String name;
|
||||
|
||||
private DefaultSubnetBuilder() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder ipPrefix(IpPrefix ipPrefix) {
|
||||
this.ipPrefix = ipPrefix;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder gatewayIp(IpAddress gatewayIp) {
|
||||
this.gatewayIp = gatewayIp;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder gatewayMac(MacAddress gatewayMac) {
|
||||
this.gatewayMac = gatewayMac;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder encapsulation(EncapsulationType encapsulation) {
|
||||
this.encapsulation = encapsulation;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder name(String networkName) {
|
||||
this.name = networkName;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FabricSubnet build() {
|
||||
checkArgument(ipPrefix != null, NOT_NULL_MSG, "prefix");
|
||||
checkArgument(gatewayIp != null, NOT_NULL_MSG, "gatewayIp");
|
||||
checkArgument(gatewayMac != null, NOT_NULL_MSG, "gatewayMac");
|
||||
checkArgument(name != null, NOT_NULL_MSG, "name");
|
||||
|
||||
if (this.encapsulation == null) {
|
||||
encapsulation = EncapsulationType.NONE;
|
||||
}
|
||||
|
||||
return new DefaultFabricSubnet(ipPrefix, gatewayIp, gatewayMac,
|
||||
encapsulation, name);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,188 @@
|
||||
/*
|
||||
* Copyright 2018-present Open Networking Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.onosproject.simplefabric.api;
|
||||
|
||||
import org.onlab.packet.VlanId;
|
||||
import org.onosproject.net.ConnectPoint;
|
||||
import org.onosproject.net.DeviceId;
|
||||
import org.onosproject.net.EncapsulationType;
|
||||
import org.onosproject.net.Host;
|
||||
import org.onosproject.net.HostId;
|
||||
import org.onosproject.net.intf.Interface;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Interface of fabric network.
|
||||
*/
|
||||
public interface FabricNetwork {
|
||||
|
||||
/**
|
||||
* Gets DefaultFabricNetwork name.
|
||||
*
|
||||
* @return the name of DefaultFabricNetwork
|
||||
*/
|
||||
String name();
|
||||
|
||||
/**
|
||||
* Gets DefaultFabricNetwork interfaceNames.
|
||||
*
|
||||
* @return the interfaceNames of DefaultFabricNetwork
|
||||
*/
|
||||
Set<String> interfaceNames();
|
||||
|
||||
/**
|
||||
* Gets DefaultFabricNetwork encapsulation type.
|
||||
*
|
||||
* @return the encapsulation type of DefaultFabricNetwork
|
||||
*/
|
||||
EncapsulationType encapsulation();
|
||||
|
||||
/**
|
||||
* Gets DefaultFabricNetwork forward flag.
|
||||
*
|
||||
* @return the forward flag of DefaultFabricNetwork
|
||||
*/
|
||||
boolean isForward();
|
||||
|
||||
/**
|
||||
* Gets DefaultFabricNetwork broadcast flag.
|
||||
*
|
||||
* @return the broadcast flag of DefaultFabricNetwork
|
||||
*/
|
||||
boolean isBroadcast();
|
||||
|
||||
/**
|
||||
* Gets DefaultFabricNetwork interfaces.
|
||||
*
|
||||
* @return the interfaces of DefaultFabricNetwork
|
||||
*/
|
||||
Set<Interface> interfaces();
|
||||
|
||||
/**
|
||||
* Gets DefaultFabricNetwork hosts.
|
||||
*
|
||||
* @return the hosts of DefaultFabricNetwork
|
||||
*/
|
||||
Set<HostId> hostIds();
|
||||
|
||||
/**
|
||||
* Gets DefaultFabricNetwork isDirty flag.
|
||||
*
|
||||
* @return the isDirty flag of DefaultFabricNetwork
|
||||
*/
|
||||
boolean isDirty();
|
||||
|
||||
/**
|
||||
* Checks if the interface is of DefaultFabricNetwork.
|
||||
*
|
||||
* @param iface the interface to be checked
|
||||
* @return true if DefaultFabricNetwork contains the interface
|
||||
*/
|
||||
boolean contains(Interface iface);
|
||||
|
||||
/**
|
||||
* Checks if the ConnectPoint and Vlan is of DefaultFabricNetwork.
|
||||
*
|
||||
* @param port the ConnectPoint to be checked
|
||||
* @param vlanId the VlanId of the ConnectPoint to be checked
|
||||
* @return true if DefaultFabricNetwork contains the interface of the ConnnectPoint and VlanId
|
||||
*/
|
||||
boolean contains(ConnectPoint port, VlanId vlanId);
|
||||
|
||||
/**
|
||||
* Checks if the DeviceId is of DefaultFabricNetwork.
|
||||
*
|
||||
* @param deviceId the DeviceId to be checked
|
||||
* @return true if DefaultFabricNetwork contains any interface of the DeviceId
|
||||
*/
|
||||
boolean contains(DeviceId deviceId);
|
||||
|
||||
/**
|
||||
* Adds interface to DefaultFabricNetwork.
|
||||
*
|
||||
* @param iface the Interface to be added
|
||||
*/
|
||||
void addInterface(Interface iface);
|
||||
|
||||
/**
|
||||
* Adds host to DefaultFabricNetwork.
|
||||
*
|
||||
* @param host the Host to be added
|
||||
*/
|
||||
void addHost(Host host);
|
||||
|
||||
/**
|
||||
* Sets DefaultFabricNetwork isDirty flag.
|
||||
*
|
||||
* @param newDirty the isDirty flag to be set
|
||||
*/
|
||||
void setDirty(boolean newDirty);
|
||||
|
||||
/**
|
||||
* Builder of FabricNetwork.
|
||||
*/
|
||||
interface Builder {
|
||||
|
||||
/**
|
||||
* Returns FabricNetwork builder with supplied network name.
|
||||
*
|
||||
* @param name network name
|
||||
* @return FabricNetwork instance builder
|
||||
*/
|
||||
Builder name(String name);
|
||||
|
||||
/**
|
||||
* Returns FabricNetwork builder with supplied interface names.
|
||||
*
|
||||
* @param interfaceNames interface names
|
||||
* @return FabricNetwork instance builder
|
||||
*/
|
||||
Builder interfaceNames(Set<String> interfaceNames);
|
||||
|
||||
/**
|
||||
* Returns FabricNetwork builder with supplied encapsulation type.
|
||||
*
|
||||
* @param encapsulation encapsulation type
|
||||
* @return FabricNetwork instance builder
|
||||
*/
|
||||
Builder encapsulation(EncapsulationType encapsulation);
|
||||
|
||||
/**
|
||||
* Returns FabricNetwork builder with supplied forward flag.
|
||||
*
|
||||
* @param forward forward flag
|
||||
* @return FabricNetwork instance builder
|
||||
*/
|
||||
Builder forward(boolean forward);
|
||||
|
||||
/**
|
||||
* Returns FabricNetwork builder with supplied broadcast flag.
|
||||
*
|
||||
* @param broadcast broadcast flag
|
||||
* @return FabricNetwork instance builder
|
||||
*/
|
||||
Builder broadcast(boolean broadcast);
|
||||
|
||||
/**
|
||||
* Builds an immutable FabricNetwork instance.
|
||||
*
|
||||
* @return FabricNetwork instance
|
||||
*/
|
||||
FabricNetwork build();
|
||||
}
|
||||
}
|
@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Copyright 2018-present Open Networking Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.onosproject.simplefabric.api;
|
||||
|
||||
import org.onlab.packet.IpAddress;
|
||||
import org.onlab.packet.IpPrefix;
|
||||
import org.onosproject.cluster.NodeId;
|
||||
|
||||
/**
|
||||
* Interface of fabric route.
|
||||
*/
|
||||
public interface FabricRoute {
|
||||
|
||||
/**
|
||||
* Source of the route.
|
||||
*/
|
||||
enum Source {
|
||||
/**
|
||||
* Route came from the iBGP route source.
|
||||
*/
|
||||
BGP,
|
||||
|
||||
/**
|
||||
* Route came from the FPM route source.
|
||||
*/
|
||||
FPM,
|
||||
|
||||
/**
|
||||
* Route can from the static route source.
|
||||
*/
|
||||
STATIC,
|
||||
|
||||
/**
|
||||
* Route source was not defined.
|
||||
*/
|
||||
UNDEFINED
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the route source.
|
||||
*
|
||||
* @return route source
|
||||
*/
|
||||
Source source();
|
||||
|
||||
/**
|
||||
* Returns the IP prefix of the route.
|
||||
*
|
||||
* @return IP prefix
|
||||
*/
|
||||
IpPrefix prefix();
|
||||
|
||||
/**
|
||||
* Returns the next hop IP address.
|
||||
*
|
||||
* @return next hop
|
||||
*/
|
||||
IpAddress nextHop();
|
||||
|
||||
/**
|
||||
* Returns the ONOS node the route was sourced from.
|
||||
*
|
||||
* @return ONOS node ID
|
||||
*/
|
||||
NodeId sourceNode();
|
||||
|
||||
/**
|
||||
* Builder of FabricRoute.
|
||||
*/
|
||||
interface Builder {
|
||||
|
||||
/**
|
||||
* Returns FabricRoute builder with supplied source.
|
||||
*
|
||||
* @param source source of route
|
||||
* @return FabricRoute instance builder
|
||||
*/
|
||||
Builder source(Source source);
|
||||
|
||||
/**
|
||||
* Returns FabricRoute builder with supplied IP prefix.
|
||||
*
|
||||
* @param prefix IP prefix
|
||||
* @return FabricRoute instance builder
|
||||
*/
|
||||
Builder prefix(IpPrefix prefix);
|
||||
|
||||
/**
|
||||
* Returns Fabric builder with supplied next hop.
|
||||
*
|
||||
* @param nextHop next hop
|
||||
* @return FabricRoute instance builder
|
||||
*/
|
||||
Builder nextHop(IpAddress nextHop);
|
||||
|
||||
/**
|
||||
* Returns Fabric builder with supplied source node identifier.
|
||||
*
|
||||
* @param sourceNode source node identifier
|
||||
* @return FabricRoute instance builder
|
||||
*/
|
||||
Builder sourceNode(NodeId sourceNode);
|
||||
|
||||
/**
|
||||
* Builds an immutable FabricRoute instance.
|
||||
*
|
||||
* @return FabricRoute instance
|
||||
*/
|
||||
FabricRoute build();
|
||||
}
|
||||
}
|
@ -0,0 +1,130 @@
|
||||
/*
|
||||
* Copyright 2018-present Open Networking Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.onosproject.simplefabric.api;
|
||||
|
||||
import org.onlab.packet.IpAddress;
|
||||
import org.onlab.packet.IpPrefix;
|
||||
import org.onlab.packet.MacAddress;
|
||||
import org.onosproject.net.EncapsulationType;
|
||||
|
||||
/**
|
||||
* Interface of FabricSubnet.
|
||||
*/
|
||||
public interface FabricSubnet {
|
||||
|
||||
/**
|
||||
* Gets the IP subnet of the IP subnet entry.
|
||||
*
|
||||
* @return the IP subnet
|
||||
*/
|
||||
IpPrefix prefix();
|
||||
|
||||
/**
|
||||
* Gets the virtual gateway IP address of the IP subnet entry.
|
||||
*
|
||||
* @return the virtual gateway IP address
|
||||
*/
|
||||
IpAddress gatewayIp();
|
||||
|
||||
/**
|
||||
* Gets the virtual gateway Mac address of the IP subnet entry.
|
||||
*
|
||||
* @return the virtuai gateway Mac address
|
||||
*/
|
||||
MacAddress gatewayMac();
|
||||
|
||||
/**
|
||||
* Gets the encapsulation type of IP subnet entry.
|
||||
*
|
||||
* @return the encapsulation type
|
||||
*/
|
||||
EncapsulationType encapsulation();
|
||||
|
||||
/**
|
||||
* Gets the subnet name.
|
||||
*
|
||||
* @return the subnet name
|
||||
*/
|
||||
String name();
|
||||
|
||||
/**
|
||||
* Tests whether the IP version of this entry is IPv4.
|
||||
*
|
||||
* @return true if the IP version of this entry is IPv4, otherwise false.
|
||||
*/
|
||||
boolean isIp4();
|
||||
|
||||
/**
|
||||
* Tests whether the IP version of this entry is IPv6.
|
||||
*
|
||||
* @return true if the IP version of this entry is IPv6, otherwise false.
|
||||
*/
|
||||
boolean isIp6();
|
||||
|
||||
/**
|
||||
* Builder of Ip Subnet.
|
||||
*/
|
||||
interface Builder {
|
||||
|
||||
/**
|
||||
* Returns FabricSubnet builder with supplied IpPrefix.
|
||||
*
|
||||
* @param ipPrefix IP prefix
|
||||
* @return FabricSubnet instance builder
|
||||
*/
|
||||
Builder ipPrefix(IpPrefix ipPrefix);
|
||||
|
||||
/**
|
||||
* Returns FabricSubnet builder with supplied gatewayIp.
|
||||
*
|
||||
* @param gatewayIp gateway IP
|
||||
* @return FabricSubnet instance builder
|
||||
*/
|
||||
Builder gatewayIp(IpAddress gatewayIp);
|
||||
|
||||
/**
|
||||
* Returns FabricSubnet builder with supplied gatewayMac.
|
||||
*
|
||||
* @param gatewayMac gateway MAC
|
||||
* @return FabricSubnet instance builder
|
||||
*/
|
||||
Builder gatewayMac(MacAddress gatewayMac);
|
||||
|
||||
/**
|
||||
* Returns FabricSubnet builder with supplied encapsulation type.
|
||||
*
|
||||
* @param encapsulation encapsulation type
|
||||
* @return FabricSubnet instance builder
|
||||
*/
|
||||
Builder encapsulation(EncapsulationType encapsulation);
|
||||
|
||||
/**
|
||||
* Returns FabricSubnet builder with supplied subnet name.
|
||||
*
|
||||
* @param name subnet name
|
||||
* @return FabricSubnet instance builder
|
||||
*/
|
||||
Builder name(String name);
|
||||
|
||||
/**
|
||||
* Builds an immutable FabricSubnet instance.
|
||||
*
|
||||
* @return FabricSubnet instance
|
||||
*/
|
||||
FabricSubnet build();
|
||||
}
|
||||
}
|
@ -1,148 +0,0 @@
|
||||
/*
|
||||
* Copyright 2018-present Open Networking Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.onosproject.simplefabric.api;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import org.onlab.packet.IpAddress;
|
||||
import org.onlab.packet.IpPrefix;
|
||||
import org.onlab.packet.MacAddress;
|
||||
import org.onosproject.net.EncapsulationType;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Configuration details for an ip subnet entry.
|
||||
*/
|
||||
public class IpSubnet {
|
||||
private final IpPrefix ipPrefix;
|
||||
private final IpAddress gatewayIp;
|
||||
private final MacAddress gatewayMac;
|
||||
private EncapsulationType encapsulation;
|
||||
private final String l2NetworkName;
|
||||
|
||||
/**
|
||||
* Creates a new ip subnet entry.
|
||||
*
|
||||
* @param ipPrefix an ip subnet
|
||||
* @param gatewayIp IP of the virtual gateway
|
||||
* @param gatewayMac MacAddress of the virtual gateway
|
||||
* @param encapsulation EnacaptulatioType for routes related to this subnet
|
||||
* @param l2NetworkName Name of L2 Network this subnet is bound
|
||||
*/
|
||||
public IpSubnet(IpPrefix ipPrefix, IpAddress gatewayIp, MacAddress gatewayMac,
|
||||
EncapsulationType encapsulation, String l2NetworkName) {
|
||||
this.ipPrefix = ipPrefix;
|
||||
this.gatewayIp = gatewayIp;
|
||||
this.gatewayMac = gatewayMac;
|
||||
this.encapsulation = EncapsulationType.NONE;
|
||||
this.l2NetworkName = l2NetworkName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ip subnet of the ip subnet entry.
|
||||
*
|
||||
* @return the ip subnet
|
||||
*/
|
||||
public IpPrefix ipPrefix() {
|
||||
return ipPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the virtual gateway IP address of the ip subnet entry.
|
||||
*
|
||||
* @return the virtual gateway IP address
|
||||
*/
|
||||
public IpAddress gatewayIp() {
|
||||
return gatewayIp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the virtual gateway Mac address of the ip subnet entry.
|
||||
*
|
||||
* @return the virtuai gateway Mac address
|
||||
*/
|
||||
public MacAddress gatewayMac() {
|
||||
return gatewayMac;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the encapsulation type of ip subnet entry.
|
||||
*
|
||||
* @return the encapsulation type
|
||||
*/
|
||||
public EncapsulationType encapsulation() {
|
||||
return encapsulation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of L2 Network this subnet is bound.
|
||||
*
|
||||
* @return the l2Network name this subnet is allocated
|
||||
*/
|
||||
public String l2NetworkName() {
|
||||
return l2NetworkName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether the IP version of this entry is IPv4.
|
||||
*
|
||||
* @return true if the IP version of this entry is IPv4, otherwise false.
|
||||
*/
|
||||
public boolean isIp4() {
|
||||
return ipPrefix.isIp4();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether the IP version of this entry is IPv6.
|
||||
*
|
||||
* @return true if the IP version of this entry is IPv6, otherwise false.
|
||||
*/
|
||||
public boolean isIp6() {
|
||||
return ipPrefix.isIp6();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(ipPrefix, gatewayIp, gatewayMac, encapsulation, l2NetworkName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof IpSubnet)) {
|
||||
return false;
|
||||
}
|
||||
IpSubnet that = (IpSubnet) obj;
|
||||
return Objects.equals(this.ipPrefix, that.ipPrefix)
|
||||
&& Objects.equals(this.gatewayIp, that.gatewayIp)
|
||||
&& Objects.equals(this.gatewayMac, that.gatewayMac)
|
||||
&& Objects.equals(this.encapsulation, that.encapsulation)
|
||||
&& Objects.equals(this.l2NetworkName, that.l2NetworkName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(getClass())
|
||||
.add("ipPrefix", ipPrefix)
|
||||
.add("gatewayIp", gatewayIp)
|
||||
.add("gatewayMac", gatewayMac)
|
||||
.add("encapsulation", encapsulation)
|
||||
.add("l2NetworkName", l2NetworkName)
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -1,306 +0,0 @@
|
||||
/*
|
||||
* Copyright 2018-present Open Networking Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.onosproject.simplefabric.api;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.onlab.packet.VlanId;
|
||||
import org.onosproject.net.ConnectPoint;
|
||||
import org.onosproject.net.DeviceId;
|
||||
import org.onosproject.net.EncapsulationType;
|
||||
import org.onosproject.net.Host;
|
||||
import org.onosproject.net.HostId;
|
||||
import org.onosproject.net.intf.Interface;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.onosproject.simplefabric.api.Constants.ALLOW_ETH_ADDRESS_SELECTOR;
|
||||
|
||||
|
||||
/**
|
||||
* Class stores a L2Network information.
|
||||
*/
|
||||
public final class L2Network {
|
||||
|
||||
private String name; // also for network configuration
|
||||
private Set<String> interfaceNames; // also for network configuration
|
||||
private EncapsulationType encapsulation; // also for network configuration
|
||||
private boolean l2Forward; // do l2Forward (default:true) or not
|
||||
private boolean l2Broadcast; // do l2Broadcast (default:true) or not
|
||||
|
||||
/* status variables */
|
||||
private Set<Interface> interfaces; // available interfaces from interfaceNames
|
||||
private Set<HostId> hostIds; // available hosts from interfaces
|
||||
private boolean dirty;
|
||||
|
||||
/**
|
||||
* Constructs a L2Network data for Config value.
|
||||
*
|
||||
* @param name the given name
|
||||
* @param ifaceNames the interface names
|
||||
* @param encapsulation the encapsulation type
|
||||
* @param l2Forward flag for l2Forward intents to be installed or not
|
||||
* @param l2Broadcast flag for l2Broadcast intents to be installed or not
|
||||
*/
|
||||
public L2Network(String name, Collection<String> ifaceNames, EncapsulationType encapsulation,
|
||||
boolean l2Forward, boolean l2Broadcast) {
|
||||
this.name = name;
|
||||
this.interfaceNames = Sets.newHashSet();
|
||||
this.interfaceNames.addAll(ifaceNames);
|
||||
this.encapsulation = encapsulation;
|
||||
this.l2Forward = (ALLOW_ETH_ADDRESS_SELECTOR) ? l2Forward : false;
|
||||
this.l2Broadcast = (ALLOW_ETH_ADDRESS_SELECTOR) ? l2Broadcast : false;
|
||||
this.interfaces = Sets.newHashSet();
|
||||
this.hostIds = Sets.newHashSet();
|
||||
this.dirty = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a L2Network data by given name and encapsulation type.
|
||||
*
|
||||
* @param name the given name
|
||||
* @param encapsulation the encapsulation type
|
||||
*/
|
||||
private L2Network(String name, EncapsulationType encapsulation) {
|
||||
this.name = name;
|
||||
this.interfaceNames = Sets.newHashSet();
|
||||
this.encapsulation = encapsulation;
|
||||
this.l2Forward = (ALLOW_ETH_ADDRESS_SELECTOR) ? true : false;
|
||||
this.l2Broadcast = (ALLOW_ETH_ADDRESS_SELECTOR) ? true : false;
|
||||
this.interfaces = Sets.newHashSet();
|
||||
this.hostIds = Sets.newHashSet();
|
||||
this.dirty = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a L2Network data by given name.
|
||||
* The encapsulation type of the L2Network will be NONE.
|
||||
*
|
||||
* @param name the given name
|
||||
* @return the L2Network data
|
||||
*/
|
||||
public static L2Network of(String name) {
|
||||
Objects.requireNonNull(name);
|
||||
return new L2Network(name, EncapsulationType.NONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a copy of L2Network data.
|
||||
*
|
||||
* @param l2Network the L2Network data
|
||||
* @return the copy of the L2Network data
|
||||
*/
|
||||
public static L2Network of(L2Network l2Network) {
|
||||
Objects.requireNonNull(l2Network);
|
||||
L2Network l2NetworkCopy = new L2Network(l2Network.name(), l2Network.encapsulation());
|
||||
l2NetworkCopy.interfaceNames.addAll(l2Network.interfaceNames());
|
||||
l2NetworkCopy.l2Forward = (ALLOW_ETH_ADDRESS_SELECTOR) ? l2Network.l2Forward() : false;
|
||||
l2NetworkCopy.l2Broadcast = (ALLOW_ETH_ADDRESS_SELECTOR) ? l2Network.l2Broadcast() : false;
|
||||
l2NetworkCopy.interfaces.addAll(l2Network.interfaces());
|
||||
l2NetworkCopy.hostIds.addAll(l2Network.hostIds());
|
||||
l2NetworkCopy.setDirty(l2Network.dirty());
|
||||
return l2NetworkCopy;
|
||||
}
|
||||
|
||||
// field queries
|
||||
|
||||
/**
|
||||
* Gets L2Network name.
|
||||
*
|
||||
* @return the name of L2Network
|
||||
*/
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets L2Network interfaceNames.
|
||||
*
|
||||
* @return the interfaceNames of L2Network
|
||||
*/
|
||||
public Set<String> interfaceNames() {
|
||||
return ImmutableSet.copyOf(interfaceNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets L2Network encapsulation type.
|
||||
*
|
||||
* @return the encapsulation type of L2Network
|
||||
*/
|
||||
public EncapsulationType encapsulation() {
|
||||
return encapsulation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets L2Network l2Forward flag.
|
||||
*
|
||||
* @return the l2Forward flag of L2Network
|
||||
*/
|
||||
public boolean l2Forward() {
|
||||
return l2Forward;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets L2Network l2Broadcast flag.
|
||||
*
|
||||
* @return the l2Broadcast flag of L2Network
|
||||
*/
|
||||
public boolean l2Broadcast() {
|
||||
return l2Broadcast;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets L2Network interfaces.
|
||||
*
|
||||
* @return the interfaces of L2Network
|
||||
*/
|
||||
public Set<Interface> interfaces() {
|
||||
return ImmutableSet.copyOf(interfaces);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets L2Network hosts.
|
||||
*
|
||||
* @return the hosts of L2Network
|
||||
*/
|
||||
public Set<HostId> hostIds() {
|
||||
return ImmutableSet.copyOf(hostIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets L2Network dirty flag.
|
||||
*
|
||||
* @return the dirty flag of L2Network
|
||||
*/
|
||||
public boolean dirty() {
|
||||
return dirty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the interface is of L2Network.
|
||||
*
|
||||
* @param iface the interface to be checked
|
||||
* @return true if L2Network contains the interface
|
||||
*/
|
||||
public boolean contains(Interface iface) {
|
||||
return interfaces.contains(iface);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the ConnectPoint and Vlan is of L2Network.
|
||||
*
|
||||
* @param port the ConnectPoint to be checked
|
||||
* @param vlanId the VlanId of the ConnectPoint to be checked
|
||||
* @return true if L2Network contains the interface of the ConnnectPoint and VlanId
|
||||
*/
|
||||
public boolean contains(ConnectPoint port, VlanId vlanId) {
|
||||
for (Interface iface : interfaces) {
|
||||
if (iface.connectPoint().equals(port) && iface.vlan().equals(vlanId)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the DeviceId is of L2Network.
|
||||
*
|
||||
* @param deviceId the DeviceId to be checked
|
||||
* @return true if L2Network contains any interface of the DeviceId
|
||||
*/
|
||||
public boolean contains(DeviceId deviceId) {
|
||||
for (Interface iface : interfaces) {
|
||||
if (iface.connectPoint().deviceId().equals(deviceId)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds interface to L2Network.
|
||||
*
|
||||
* @param iface the Interface to be added
|
||||
*/
|
||||
public void addInterface(Interface iface) {
|
||||
Objects.requireNonNull(iface);
|
||||
if (interfaces.add(iface)) {
|
||||
setDirty(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds host to L2Network.
|
||||
*
|
||||
* @param host the Host to be added
|
||||
*/
|
||||
public void addHost(Host host) {
|
||||
Objects.requireNonNull(host);
|
||||
if (hostIds.add(host.id())) {
|
||||
setDirty(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets L2Network dirty flag.
|
||||
*
|
||||
* @param newDirty the dirty flag to be set
|
||||
*/
|
||||
public void setDirty(boolean newDirty) {
|
||||
dirty = newDirty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(getClass())
|
||||
.add("name", name)
|
||||
.add("interfaceNames", interfaceNames)
|
||||
.add("encapsulation", encapsulation)
|
||||
.add("l2Forward", l2Forward)
|
||||
.add("l2Broadcast", l2Broadcast)
|
||||
.add("interfaces", interfaces)
|
||||
.add("hostIds", hostIds)
|
||||
.add("dirty", dirty)
|
||||
.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof L2Network)) {
|
||||
return false;
|
||||
}
|
||||
L2Network other = (L2Network) obj;
|
||||
return Objects.equals(other.name, this.name)
|
||||
&& Objects.equals(other.interfaceNames, this.interfaceNames)
|
||||
&& Objects.equals(other.encapsulation, this.encapsulation)
|
||||
&& Objects.equals(other.l2Forward, this.l2Forward)
|
||||
&& Objects.equals(other.l2Broadcast, this.l2Broadcast)
|
||||
&& Objects.equals(other.interfaces, this.interfaces)
|
||||
&& Objects.equals(other.hostIds, this.hostIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name, interfaces, encapsulation, l2Forward, l2Broadcast);
|
||||
}
|
||||
}
|
@ -39,105 +39,104 @@ public interface SimpleFabricService
|
||||
*
|
||||
* @return appId of simple fabric app
|
||||
*/
|
||||
ApplicationId getAppId();
|
||||
ApplicationId appId();
|
||||
|
||||
/**
|
||||
* Gets all the l2Networks.
|
||||
* Gets all the fabric networks.
|
||||
*
|
||||
* @return all the l2Networks
|
||||
* @return all the fabric networks
|
||||
*/
|
||||
Collection<L2Network> getL2Networks();
|
||||
Collection<FabricNetwork> fabricNetworks();
|
||||
|
||||
/**
|
||||
* Retrieves the entire set of ipSubnets configuration.
|
||||
* Retrieves the entire set of fabricSubnets configuration.
|
||||
*
|
||||
* @return all the ipSubnets
|
||||
* @return all the fabricSubnets
|
||||
*/
|
||||
Set<IpSubnet> getIpSubnets();
|
||||
Set<FabricSubnet> defaultFabricSubnets();
|
||||
|
||||
/**
|
||||
* Retrieves the entire set of static routes to outer networks.
|
||||
*
|
||||
* @return the set of static routes to outer networks.
|
||||
*/
|
||||
Set<Route> getBorderRoutes();
|
||||
Set<FabricRoute> fabricRoutes();
|
||||
|
||||
/**
|
||||
* Evaluates whether a mac is of Virtual Gateway Mac Addresses.
|
||||
* Evaluates whether a MAC is of virtual gateway MAC addresses.
|
||||
*
|
||||
* @param mac the MacAddress to evaluate
|
||||
* @return true if the mac is of any Vitrual Gateway Mac Address of ipSubnets
|
||||
* @param mac the MAC address to evaluate
|
||||
* @return true if the mac is of any virtual gateway MAC address of fabricSubnets
|
||||
*/
|
||||
boolean isVMac(MacAddress mac);
|
||||
boolean isVirtualGatewayMac(MacAddress mac);
|
||||
|
||||
/**
|
||||
* Evaluates whether an Interface belongs to l2Networks.
|
||||
* Evaluates whether an interface belongs to fabric network or not.
|
||||
*
|
||||
* @param intf the interface to evaluate
|
||||
* @return true if the inteface belongs to l2Networks configed, otherwise false
|
||||
* @return true if the interface belongs to fabric network, otherwise false
|
||||
*/
|
||||
boolean isL2NetworkInterface(Interface intf);
|
||||
boolean isFabricNetworkInterface(Interface intf);
|
||||
|
||||
/**
|
||||
* Find Virtual Gateway Mac Address for Local Subnet Virtual Gateway Ip.
|
||||
* Finds virtual gateway MAC address for local subnet virtual gateway IP.
|
||||
*
|
||||
* @param ip the ip to check for Virtual Gateway Ip
|
||||
* @return mac address of virtual gateway
|
||||
* @param ip the IP to check for virtual gateway IP
|
||||
* @return MAC address of virtual gateway
|
||||
*/
|
||||
MacAddress findVMacForIp(IpAddress ip);
|
||||
MacAddress vMacForIp(IpAddress ip);
|
||||
|
||||
/**
|
||||
* Finds the L2 Network with given port and vlanId.
|
||||
* Finds the L2 fabric network with given port and vlanId.
|
||||
*
|
||||
* @param port the port to be matched
|
||||
* @param vlanId the vlanId to be matched
|
||||
* @return the L2 Network for specific port and vlanId or null
|
||||
*/
|
||||
L2Network findL2Network(ConnectPoint port, VlanId vlanId);
|
||||
FabricNetwork fabricNetwork(ConnectPoint port, VlanId vlanId);
|
||||
|
||||
/**
|
||||
* Finds the L2 Network of the name.
|
||||
* Finds the fabric network by its name.
|
||||
*
|
||||
* @param name the name to be matched
|
||||
* @return the L2 Network for specific name
|
||||
* @return the fabric network
|
||||
*/
|
||||
L2Network findL2Network(String name);
|
||||
FabricNetwork fabricNetwork(String name);
|
||||
|
||||
/**
|
||||
* Finds the IpSubnet containing the ipAddress.
|
||||
* Finds the FabricSubnet which contains the given IP address.
|
||||
*
|
||||
* @param ipAddress the ipAddress to be matched
|
||||
* @return the IpSubnet for specific ipAddress
|
||||
* @param ipAddress the IP address to be matched
|
||||
* @return the FabricSubnet
|
||||
*/
|
||||
IpSubnet findIpSubnet(IpAddress ipAddress);
|
||||
FabricSubnet fabricSubnet(IpAddress ipAddress);
|
||||
|
||||
/**
|
||||
* Finds the Border Route containing the ipAddress.
|
||||
* ASSUME: ipAddress is out of ipSubnets
|
||||
* Finds the FabricRoute which contains the given IP address.
|
||||
*
|
||||
* @param ipAddress the ipAddress to be matched
|
||||
* @return the IpSubnet for specific ipAddress
|
||||
* @param ipAddress the IP address to be matched
|
||||
* @return the FabricRoute
|
||||
*/
|
||||
Route findBorderRoute(IpAddress ipAddress);
|
||||
FabricRoute fabricRoute(IpAddress ipAddress);
|
||||
|
||||
/**
|
||||
* Finds the network interface related to the host.
|
||||
* Finds the network interface which associated with the host.
|
||||
*
|
||||
* @param host the host
|
||||
* @return the interface related to the host
|
||||
* @return the interface associated with the host
|
||||
*/
|
||||
Interface findHostInterface(Host host);
|
||||
Interface hostInterface(Host host);
|
||||
|
||||
/**
|
||||
* Sends Neighbour Query (ARP or NDP) to Find Host Location.
|
||||
* Sends neighbour query (ARP or NDP) to find host location.
|
||||
*
|
||||
* @param ip the ip address to resolve
|
||||
* @return true if request mac packets are emitted. otherwise false
|
||||
* @param ip the IP address to resolve
|
||||
* @return true if request MAC packets are emitted, false otherwise
|
||||
*/
|
||||
boolean requestMac(IpAddress ip);
|
||||
|
||||
/**
|
||||
* Sends Dump Event to all SimpleFabricListeners to Dump Info on the Subject.
|
||||
* Sends dump event to all SimpleFabricListeners to dump info on the subject.
|
||||
*
|
||||
* @param subject the subject to dump
|
||||
* @param out the output stream to dump
|
||||
@ -145,13 +144,12 @@ public interface SimpleFabricService
|
||||
void dumpToStream(String subject, OutputStream out);
|
||||
|
||||
/**
|
||||
* Triggers to send Refresh Notification to all sub modules.
|
||||
* Triggers to send refresh notification to all sub modules.
|
||||
*/
|
||||
void triggerRefresh();
|
||||
|
||||
/**
|
||||
* Triggers to send Flush Notification to all sub modules.
|
||||
* Triggers to send flush notification to all sub modules.
|
||||
*/
|
||||
void triggerFlush();
|
||||
|
||||
}
|
||||
|
@ -22,11 +22,14 @@ import org.onlab.packet.IpAddress;
|
||||
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 @@ import java.util.Set;
|
||||
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 @@ public class SimpleFabricConfig extends Config<ApplicationId> {
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ import org.onlab.packet.MacAddress;
|
||||
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.MultiPointToSinglePointIntent;
|
||||
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 org.slf4j.LoggerFactory;
|
||||
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 @@ import static org.onosproject.simplefabric.api.Constants.PRI_L2NETWORK_UNICAST;
|
||||
* 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 @@ public class SimpleFabricL2Forward {
|
||||
|
||||
@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 @@ public class SimpleFabricL2Forward {
|
||||
//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 @@ public class SimpleFabricL2Forward {
|
||||
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 @@ public class SimpleFabricL2Forward {
|
||||
!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 @@ public class SimpleFabricL2Forward {
|
||||
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 @@ public class SimpleFabricL2Forward {
|
||||
!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 @@ public class SimpleFabricL2Forward {
|
||||
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 @@ public class SimpleFabricL2Forward {
|
||||
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 @@ public class SimpleFabricL2Forward {
|
||||
|
||||
// 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 @@ public class SimpleFabricL2Forward {
|
||||
.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 @@ public class SimpleFabricL2Forward {
|
||||
}
|
||||
|
||||
// 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 @@ public class SimpleFabricL2Forward {
|
||||
|
||||
// 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 @@ public class SimpleFabricL2Forward {
|
||||
.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 @@ public class SimpleFabricL2Forward {
|
||||
// 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());
|
||||
}
|
@ -37,7 +37,6 @@ import org.onlab.packet.IpPrefix;
|
||||
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.intf.InterfaceService;
|
||||
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.HashSet;
|
||||
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_ALLOW_LINK_CP;
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
@ -106,9 +106,6 @@ public class SimpleFabricManager extends ListenerRegistry<SimpleFabricEvent, Sim
|
||||
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
|
||||
protected CoreService coreService;
|
||||
|
||||
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
|
||||
protected ApplicationService applicationService;
|
||||
|
||||
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
|
||||
protected NetworkConfigService configService;
|
||||
|
||||
@ -127,32 +124,32 @@ public class SimpleFabricManager extends ListenerRegistry<SimpleFabricEvent, Sim
|
||||
@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 @@ public class SimpleFabricManager extends ListenerRegistry<SimpleFabricEvent, Sim
|
||||
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 @@ public class SimpleFabricManager extends ListenerRegistry<SimpleFabricEvent, Sim
|
||||
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 @@ public class SimpleFabricManager extends ListenerRegistry<SimpleFabricEvent, Sim
|
||||
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 @@ public class SimpleFabricManager extends ListenerRegistry<SimpleFabricEvent, Sim
|
||||
}
|
||||
|
||||
// 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 @@ public class SimpleFabricManager extends ListenerRegistry<SimpleFabricEvent, Sim
|
||||
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 @@ public class SimpleFabricManager extends ListenerRegistry<SimpleFabricEvent, Sim
|
||||
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 @@ public class SimpleFabricManager extends ListenerRegistry<SimpleFabricEvent, Sim
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationId getAppId() {
|
||||
public ApplicationId appId() {
|
||||
if (appId == null) {
|
||||
appId = coreService.registerApplication(APP_ID);
|
||||
}
|
||||
@ -356,57 +352,57 @@ public class SimpleFabricManager extends ListenerRegistry<SimpleFabricEvent, Sim
|
||||
}
|
||||
|
||||
@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 @@ public class SimpleFabricManager extends ListenerRegistry<SimpleFabricEvent, Sim
|
||||
}
|
||||
|
||||
@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 @@ public class SimpleFabricManager extends ListenerRegistry<SimpleFabricEvent, Sim
|
||||
|
||||
|
||||
@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 @@ public class SimpleFabricManager extends ListenerRegistry<SimpleFabricEvent, Sim
|
||||
|
||||
@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 @@ public class SimpleFabricManager extends ListenerRegistry<SimpleFabricEvent, Sim
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ import org.onosproject.net.neighbour.NeighbourMessageHandler;
|
||||
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 @@ public class SimpleFabricNeighbour {
|
||||
|
||||
@Activate
|
||||
public void activate() {
|
||||
appId = simpleFabric.getAppId();
|
||||
appId = simpleFabric.appId();
|
||||
simpleFabric.addListener(simpleFabricListener);
|
||||
refresh();
|
||||
log.info("simple fabric neighbour started");
|
||||
@ -98,7 +98,7 @@ public class SimpleFabricNeighbour {
|
||||
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 @@ public class SimpleFabricNeighbour {
|
||||
* @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 @@ public class SimpleFabricNeighbour {
|
||||
}
|
||||
// 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 @@ public class SimpleFabricNeighbour {
|
||||
// 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 @@ public class SimpleFabricNeighbour {
|
||||
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 @@ public class SimpleFabricNeighbour {
|
||||
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();
|
||||
}
|
||||
|
@ -70,9 +70,9 @@ import org.onosproject.net.packet.PacketContext;
|
||||
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_BORDER_STE
|
||||
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 @@ public class SimpleFabricReactiveRouting {
|
||||
// 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 @@ public class SimpleFabricReactiveRouting {
|
||||
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 @@ public class SimpleFabricReactiveRouting {
|
||||
|
||||
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 @@ public class SimpleFabricReactiveRouting {
|
||||
|
||||
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 @@ public class SimpleFabricReactiveRouting {
|
||||
|
||||
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 @@ public class SimpleFabricReactiveRouting {
|
||||
.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 @@ public class SimpleFabricReactiveRouting {
|
||||
.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 @@ public class SimpleFabricReactiveRouting {
|
||||
}
|
||||
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 @@ public class SimpleFabricReactiveRouting {
|
||||
.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 @@ public class SimpleFabricReactiveRouting {
|
||||
*/
|
||||
private void refreshRouteIntents() {
|
||||
for (Intent entry : intentService.getIntents()) {
|
||||
if (!reactiveAppId.equals(entry.appId())) {
|
||||
if (!appId.equals(entry.appId())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -382,7 +382,7 @@ public class SimpleFabricReactiveRouting {
|
||||
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 @@ public class SimpleFabricReactiveRouting {
|
||||
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 @@ public class SimpleFabricReactiveRouting {
|
||||
if (ingressPointChanged) {
|
||||
MultiPointToSinglePointIntent updatedIntent =
|
||||
MultiPointToSinglePointIntent.builder()
|
||||
.appId(reactiveAppId)
|
||||
.appId(appId)
|
||||
.key(intent.key())
|
||||
.selector(intent.selector())
|
||||
.treatment(intent.treatment())
|
||||
@ -486,7 +486,7 @@ public class SimpleFabricReactiveRouting {
|
||||
// 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 @@ public class SimpleFabricReactiveRouting {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 @@ public class SimpleFabricReactiveRouting {
|
||||
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 @@ public class SimpleFabricReactiveRouting {
|
||||
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 @@ public class SimpleFabricReactiveRouting {
|
||||
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 @@ public class SimpleFabricReactiveRouting {
|
||||
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 @@ public class SimpleFabricReactiveRouting {
|
||||
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 @@ public class SimpleFabricReactiveRouting {
|
||||
*
|
||||
* 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 @@ public class SimpleFabricReactiveRouting {
|
||||
}
|
||||
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 @@ public class SimpleFabricReactiveRouting {
|
||||
|
||||
MultiPointToSinglePointIntent newIntent = MultiPointToSinglePointIntent.builder()
|
||||
.key(key)
|
||||
.appId(reactiveAppId)
|
||||
.appId(appId)
|
||||
.selector(selector.build())
|
||||
.treatment(treatment)
|
||||
.filteredIngressPoints(ingressPoints)
|
||||
@ -863,7 +863,7 @@ public class SimpleFabricReactiveRouting {
|
||||
.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 @@ public class SimpleFabricReactiveRouting {
|
||||
|
||||
// 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 @@ public class SimpleFabricReactiveRouting {
|
||||
// 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 @@ public class SimpleFabricReactiveRouting {
|
||||
}
|
||||
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 @@ public class SimpleFabricReactiveRouting {
|
||||
+ " 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 @@ public class SimpleFabricReactiveRouting {
|
||||
|
||||
} 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()
|
@ -1,56 +1,229 @@
|
||||
{
|
||||
|
||||
"devices":{
|
||||
"of:0000000000000011":{ "basic":{ "name":"LS1", "latitude":35, "longitude":-100 } },
|
||||
"of:0000000000000012":{ "basic":{ "name":"LS2", "latitude":35, "longitude":-90 } },
|
||||
"of:0000000000000021":{ "basic":{ "name":"SS1", "latitude":40, "longitude":-100 } },
|
||||
"of:0000000000000022":{ "basic":{ "name":"SS2", "latitude":40, "longitude":-90 } }
|
||||
"devices": {
|
||||
"of:0000000000000011": {
|
||||
"basic": {
|
||||
"name": "LS1",
|
||||
"latitude": 35,
|
||||
"longitude": -100
|
||||
}
|
||||
},
|
||||
"of:0000000000000012": {
|
||||
"basic": {
|
||||
"name": "LS2",
|
||||
"latitude": 35,
|
||||
"longitude": -90
|
||||
}
|
||||
},
|
||||
"of:0000000000000021": {
|
||||
"basic": {
|
||||
"name": "SS1",
|
||||
"latitude": 40,
|
||||
"longitude": -100
|
||||
}
|
||||
},
|
||||
"of:0000000000000022": {
|
||||
"basic": {
|
||||
"name": "SS2",
|
||||
"latitude": 40,
|
||||
"longitude": -90
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"ports" : {
|
||||
"of:0000000000000011/1" : { "interfaces" : [ { "name" : "h11" } ] },
|
||||
"of:0000000000000011/2" : { "interfaces" : [ { "name" : "h12" } ] },
|
||||
"of:0000000000000011/3" : { "interfaces" : [ { "name" : "h13" } ] },
|
||||
"of:0000000000000011/4" : { "interfaces" : [ { "name" : "h14" } ] },
|
||||
"of:0000000000000011/5" : { "interfaces" : [ { "name" : "d11" } ] },
|
||||
"of:0000000000000011/6" : { "interfaces" : [ { "name" : "d12" } ] },
|
||||
"of:0000000000000011/7" : { "interfaces" : [ { "name" : "LS1_SS1" } ] },
|
||||
"of:0000000000000011/8" : { "interfaces" : [ { "name" : "LS1_SS2" } ] },
|
||||
|
||||
"of:0000000000000012/1" : { "interfaces" : [ { "name" : "h21" } ] } ,
|
||||
"of:0000000000000012/2" : { "interfaces" : [ { "name" : "h22" } ] },
|
||||
"of:0000000000000012/3" : { "interfaces" : [ { "name" : "h23" } ] },
|
||||
"of:0000000000000012/4" : { "interfaces" : [ { "name" : "h24" } ] },
|
||||
"of:0000000000000012/5" : { "interfaces" : [ { "name" : "d21" } ] },
|
||||
"of:0000000000000012/6" : { "interfaces" : [ { "name" : "d22" } ] },
|
||||
"of:0000000000000012/7" : { "interfaces" : [ { "name" : "LS2_SS1" } ] },
|
||||
"of:0000000000000012/8" : { "interfaces" : [ { "name" : "LS2_SS2" } ] },
|
||||
|
||||
"of:0000000000000021/1" : { "interfaces" : [ { "name" : "SS1_LS1" } ] },
|
||||
"of:0000000000000021/2" : { "interfaces" : [ { "name" : "SS1_LS2" } ] },
|
||||
|
||||
"of:0000000000000022/1" : { "interfaces" : [ { "name" : "SS2_LS1" } ] },
|
||||
"of:0000000000000022/2" : { "interfaces" : [ { "name" : "SS2_LS2" } ] }
|
||||
|
||||
"ports": {
|
||||
"of:0000000000000011/1": {
|
||||
"interfaces": [
|
||||
{
|
||||
"name": "h11"
|
||||
}
|
||||
]
|
||||
},
|
||||
"of:0000000000000011/2": {
|
||||
"interfaces": [
|
||||
{
|
||||
"name": "h12"
|
||||
}
|
||||
]
|
||||
},
|
||||
"of:0000000000000011/3": {
|
||||
"interfaces": [
|
||||
{
|
||||
"name": "h13"
|
||||
}
|
||||
]
|
||||
},
|
||||
"of:0000000000000011/4": {
|
||||
"interfaces": [
|
||||
{
|
||||
"name": "h14"
|
||||
}
|
||||
]
|
||||
},
|
||||
"of:0000000000000011/5": {
|
||||
"interfaces": [
|
||||
{
|
||||
"name": "d11"
|
||||
}
|
||||
]
|
||||
},
|
||||
"of:0000000000000011/6": {
|
||||
"interfaces": [
|
||||
{
|
||||
"name": "d12"
|
||||
}
|
||||
]
|
||||
},
|
||||
"of:0000000000000011/7": {
|
||||
"interfaces": [
|
||||
{
|
||||
"name": "LS1_SS1"
|
||||
}
|
||||
]
|
||||
},
|
||||
"of:0000000000000011/8": {
|
||||
"interfaces": [
|
||||
{
|
||||
"name": "LS1_SS2"
|
||||
}
|
||||
]
|
||||
},
|
||||
"of:0000000000000012/1": {
|
||||
"interfaces": [
|
||||
{
|
||||
"name": "h21"
|
||||
}
|
||||
]
|
||||
},
|
||||
"of:0000000000000012/2": {
|
||||
"interfaces": [
|
||||
{
|
||||
"name": "h22"
|
||||
}
|
||||
]
|
||||
},
|
||||
"of:0000000000000012/3": {
|
||||
"interfaces": [
|
||||
{
|
||||
"name": "h23"
|
||||
}
|
||||
]
|
||||
},
|
||||
"of:0000000000000012/4": {
|
||||
"interfaces": [
|
||||
{
|
||||
"name": "h24"
|
||||
}
|
||||
]
|
||||
},
|
||||
"of:0000000000000012/5": {
|
||||
"interfaces": [
|
||||
{
|
||||
"name": "d21"
|
||||
}
|
||||
]
|
||||
},
|
||||
"of:0000000000000012/6": {
|
||||
"interfaces": [
|
||||
{
|
||||
"name": "d22"
|
||||
}
|
||||
]
|
||||
},
|
||||
"of:0000000000000012/7": {
|
||||
"interfaces": [
|
||||
{
|
||||
"name": "LS2_SS1"
|
||||
}
|
||||
]
|
||||
},
|
||||
"of:0000000000000012/8": {
|
||||
"interfaces": [
|
||||
{
|
||||
"name": "LS2_SS2"
|
||||
}
|
||||
]
|
||||
},
|
||||
"of:0000000000000021/1": {
|
||||
"interfaces": [
|
||||
{
|
||||
"name": "SS1_LS1"
|
||||
}
|
||||
]
|
||||
},
|
||||
"of:0000000000000021/2": {
|
||||
"interfaces": [
|
||||
{
|
||||
"name": "SS1_LS2"
|
||||
}
|
||||
]
|
||||
},
|
||||
"of:0000000000000022/1": {
|
||||
"interfaces": [
|
||||
{
|
||||
"name": "SS2_LS1"
|
||||
}
|
||||
]
|
||||
},
|
||||
"of:0000000000000022/2": {
|
||||
"interfaces": [
|
||||
{
|
||||
"name": "SS2_LS2"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
"apps" : {
|
||||
"org.onosproject.simplefabric" : {
|
||||
"simpleFabric" : {
|
||||
"l2Networks" : [
|
||||
{ "name" : "LEAF1", "interfaces" : ["h11", "h12", "h13", "h14", "d11", "d12" ], "l2Forward" : true, "l2Broadcast" : true },
|
||||
{ "name" : "LEAF2", "interfaces" : ["h21", "h22", "h23", "h24", "d21", "d22" ], "l2Forward" : true, "l2Broadcast" : true }
|
||||
"apps": {
|
||||
"org.onosproject.simplefabric": {
|
||||
"simpleFabric": {
|
||||
"fabricNetworks": [
|
||||
{
|
||||
"name": "LEAF1",
|
||||
"interfaces": [
|
||||
"h11",
|
||||
"h12",
|
||||
"h13",
|
||||
"h14",
|
||||
"d11",
|
||||
"d12"
|
||||
],
|
||||
"isForward": true,
|
||||
"isBroadcast": true
|
||||
},
|
||||
{
|
||||
"name": "LEAF2",
|
||||
"interfaces": [
|
||||
"h21",
|
||||
"h22",
|
||||
"h23",
|
||||
"h24",
|
||||
"d21",
|
||||
"d22"
|
||||
],
|
||||
"isForward": true,
|
||||
"isBroadcast": true
|
||||
}
|
||||
],
|
||||
"ipSubnets" : [
|
||||
{ "ipPrefix" : "10.0.1.0/24", "gatewayIp" : "10.0.1.1", "gatewayMac" : "00:00:10:00:01:01", "l2NetworkName" : "LEAF1" },
|
||||
{ "ipPrefix" : "10.0.2.0/24", "gatewayIp" : "10.0.2.1", "gatewayMac" : "00:00:10:00:02:01", "l2NetworkName" : "LEAF2" }
|
||||
"fabricSubnets": [
|
||||
{
|
||||
"prefix": "10.0.1.0/24",
|
||||
"gatewayIp": "10.0.1.1",
|
||||
"gatewayMac": "00:00:10:00:01:01",
|
||||
"networkName": "LEAF1"
|
||||
},
|
||||
{
|
||||
"prefix": "10.0.2.0/24",
|
||||
"gatewayIp": "10.0.2.1",
|
||||
"gatewayMac": "00:00:10:00:02:01",
|
||||
"networkName": "LEAF2"
|
||||
}
|
||||
],
|
||||
"borderRoutes" : [
|
||||
{ "ipPrefix" : "0.0.0.0/0", "nextHop" : "10.0.1.2" }
|
||||
"fabricRoutes": [
|
||||
{
|
||||
"prefix": "0.0.0.0/0",
|
||||
"nextHop": "10.0.1.2"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user