Search in sources :

Example 1 with FabricNetwork

use of org.onosproject.simplefabric.api.FabricNetwork in project onos by opennetworkinglab.

the class SimpleFabricConfig method fabricNetworks.

/**
 * Returns all fabric networks in this configuration.
 *
 * @return a set of fabric networks
 */
public Set<FabricNetwork> fabricNetworks() {
    Set<FabricNetwork> fabricNetworks = Sets.newHashSet();
    JsonNode fabricNetworkNodes = object.get(FABRIC_NETWORKS);
    if (fabricNetworkNodes == null) {
        return fabricNetworks;
    }
    fabricNetworkNodes.forEach(jsonNode -> {
        Set<String> ifaces = Sets.newHashSet();
        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()));
        }
        // NONE or VLAN
        String encapsulation = NONE_ENCAPSULATION;
        if (jsonNode.hasNonNull(ENCAPSULATION)) {
            encapsulation = jsonNode.get(ENCAPSULATION).asText();
        }
        boolean isForward = true;
        if (jsonNode.hasNonNull(IS_FORWARD)) {
            isForward = jsonNode.get(IS_FORWARD).asBoolean();
        }
        boolean isBroadcast = true;
        if (jsonNode.hasNonNull(IS_BROADCAST)) {
            isBroadcast = jsonNode.get(IS_BROADCAST).asBoolean();
        }
        try {
            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("Fabric network parse failed; skip: jsonNode={}", jsonNode);
        }
    });
    return fabricNetworks;
}
Also used : Config(org.onosproject.net.config.Config) Logger(org.slf4j.Logger) FabricNetwork(org.onosproject.simplefabric.api.FabricNetwork) LoggerFactory(org.slf4j.LoggerFactory) Set(java.util.Set) FabricSubnet(org.onosproject.simplefabric.api.FabricSubnet) Sets(com.google.common.collect.Sets) EncapsulationType(org.onosproject.net.EncapsulationType) ApplicationId(org.onosproject.core.ApplicationId) JsonNode(com.fasterxml.jackson.databind.JsonNode) MacAddress(org.onlab.packet.MacAddress) FabricRoute(org.onosproject.simplefabric.api.FabricRoute) IpPrefix(org.onlab.packet.IpPrefix) IpAddress(org.onlab.packet.IpAddress) JsonNode(com.fasterxml.jackson.databind.JsonNode) FabricNetwork(org.onosproject.simplefabric.api.FabricNetwork)

Example 2 with FabricNetwork

use of org.onosproject.simplefabric.api.FabricNetwork in project onos by opennetworkinglab.

the class SimpleFabricManager method dump.

// Dump handler
protected void dump(String subject, PrintStream out) {
    if ("show".equals(subject)) {
        out.println("Static Configuration Flag:");
        out.println("    ALLOW_IPV6=" + ALLOW_IPV6);
        out.println("    ALLOW_ETH_ADDRESS_SELECTOR=" + ALLOW_ETH_ADDRESS_SELECTOR);
        out.println("    REACTIVE_SINGLE_TO_SINGLE=" + REACTIVE_SINGLE_TO_SINGLE);
        out.println("    REACTIVE_ALLOW_LINK_CP=" + REACTIVE_ALLOW_LINK_CP);
        out.println("    REACTIVE_HASHED_PATH_SELECTION=" + REACTIVE_HASHED_PATH_SELECTION);
        out.println("    REACTIVE_MATCH_IP_PROTO=" + REACTIVE_MATCH_IP_PROTO);
        out.println("");
        out.println("SimpleFabricAppId:");
        out.println("    " + appId());
        out.println("");
        out.println("fabricNetworks:");
        for (FabricNetwork fabricNetwork : fabricNetworks()) {
            out.println("    " + fabricNetwork);
        }
        out.println("");
        out.println("fabricSubnets:");
        for (FabricSubnet fabricIpSubnet : defaultFabricSubnets()) {
            out.println("    " + fabricIpSubnet);
        }
        out.println("");
        out.println("fabricRoutes:");
        for (FabricRoute route : fabricRoutes()) {
            out.println("    " + route);
        }
    }
}
Also used : FabricSubnet(org.onosproject.simplefabric.api.FabricSubnet) FabricNetwork(org.onosproject.simplefabric.api.FabricNetwork) FabricRoute(org.onosproject.simplefabric.api.FabricRoute)

Example 3 with FabricNetwork

use of org.onosproject.simplefabric.api.FabricNetwork in project onos by opennetworkinglab.

the class SimpleFabricRouting method refreshIntercepts.

/**
 * Refresh device flow rules for intercepts on local fabricSubnets.
 */
private void refreshIntercepts() {
    Set<FlowRule> newInterceptFlowRules = new HashSet<>();
    for (Device device : deviceService.getAvailableDevices()) {
        for (FabricSubnet subnet : simpleFabric.defaultFabricSubnets()) {
            newInterceptFlowRules.add(generateInterceptFlowRule(true, device.id(), subnet.prefix()));
            // check if this devices has the fabricSubnet, then add ip broadcast flue rule
            FabricNetwork fabricNetwork = simpleFabric.fabricNetwork(subnet.networkName());
            if (fabricNetwork != null && fabricNetwork.contains(device.id())) {
                newInterceptFlowRules.add(generateLocalSubnetIpBctFlowRule(device.id(), subnet.prefix(), fabricNetwork));
            }
        // JUST FOR FLOW RULE TEST ONLY
        // newInterceptFlowRules.add(generateTestFlowRule(device.id(), subnet.ipPrefix()));
        }
        for (FabricRoute route : simpleFabric.fabricRoutes()) {
            newInterceptFlowRules.add(generateInterceptFlowRule(false, device.id(), route.prefix()));
        }
    }
    if (!newInterceptFlowRules.equals(interceptFlowRules)) {
        // NOTE: DO NOT REMOVE INTERCEPT FLOW RULES FOR FAILED DEVICE FLOW UPDATE MIGHT BE BLOCKED
        /*
            interceptFlowRules.stream()
                .filter(rule -> !newInterceptFlowRules.contains(rule))
                .forEach(rule -> {
                    flowRuleService.removeFlowRules(rule);
                    log.info("simple fabric reactive routing remove intercept flow rule: {}", rule);
                });
            */
        newInterceptFlowRules.stream().filter(rule -> !interceptFlowRules.contains(rule)).forEach(rule -> {
            flowRuleService.applyFlowRules(rule);
            log.info("simple fabric routing apply intercept flow rule: {}", rule);
        });
        interceptFlowRules = newInterceptFlowRules;
    }
}
Also used : HashedPathSelectionConstraint(org.onosproject.net.intent.constraint.HashedPathSelectionConstraint) REACTIVE_MATCH_IP_PROTO(org.onosproject.simplefabric.api.Constants.REACTIVE_MATCH_IP_PROTO) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) Interface(org.onosproject.net.intf.Interface) FabricNetwork(org.onosproject.simplefabric.api.FabricNetwork) CoreService(org.onosproject.core.CoreService) DeviceService(org.onosproject.net.device.DeviceService) LoggerFactory(org.slf4j.LoggerFactory) ALLOW_ETH_ADDRESS_SELECTOR(org.onosproject.simplefabric.api.Constants.ALLOW_ETH_ADDRESS_SELECTOR) ROUTING_APP_ID(org.onosproject.simplefabric.api.Constants.ROUTING_APP_ID) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ByteBuffer(java.nio.ByteBuffer) ConnectPoint(org.onosproject.net.ConnectPoint) Ethernet(org.onlab.packet.Ethernet) FlowRuleService(org.onosproject.net.flow.FlowRuleService) SimpleFabricEvent(org.onosproject.simplefabric.api.SimpleFabricEvent) ApplicationId(org.onosproject.core.ApplicationId) Ip4Prefix(org.onlab.packet.Ip4Prefix) PRI_REACTIVE_BORDER_STEP(org.onosproject.simplefabric.api.Constants.PRI_REACTIVE_BORDER_STEP) Ip6Address(org.onlab.packet.Ip6Address) Ip4Address(org.onlab.packet.Ip4Address) ALLOW_IPV6(org.onosproject.simplefabric.api.Constants.ALLOW_IPV6) Device(org.onosproject.net.Device) Deactivate(org.osgi.service.component.annotations.Deactivate) PacketProcessor(org.onosproject.net.packet.PacketProcessor) Set(java.util.Set) ICMP(org.onlab.packet.ICMP) PacketService(org.onosproject.net.packet.PacketService) Constraint(org.onosproject.net.intent.Constraint) EthType(org.onlab.packet.EthType) Key(org.onosproject.net.intent.Key) List(java.util.List) InboundPacket(org.onosproject.net.packet.InboundPacket) EncapsulationType(org.onosproject.net.EncapsulationType) REACTIVE_SINGLE_TO_SINGLE(org.onosproject.simplefabric.api.Constants.REACTIVE_SINGLE_TO_SINGLE) FlowRule(org.onosproject.net.flow.FlowRule) PacketContext(org.onosproject.net.packet.PacketContext) LinkService(org.onosproject.net.link.LinkService) PRI_REACTIVE_BORDER_INTERCEPT(org.onosproject.simplefabric.api.Constants.PRI_REACTIVE_BORDER_INTERCEPT) DeviceId(org.onosproject.net.DeviceId) PRI_REACTIVE_LOCAL_FORWARD(org.onosproject.simplefabric.api.Constants.PRI_REACTIVE_LOCAL_FORWARD) IpPrefix(org.onlab.packet.IpPrefix) REACTIVE_HASHED_PATH_SELECTION(org.onosproject.simplefabric.api.Constants.REACTIVE_HASHED_PATH_SELECTION) ICMP6(org.onlab.packet.ICMP6) Host(org.onosproject.net.Host) InterfaceService(org.onosproject.net.intf.InterfaceService) HostService(org.onosproject.net.host.HostService) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Component(org.osgi.service.component.annotations.Component) SimpleFabricListener(org.onosproject.simplefabric.api.SimpleFabricListener) TrafficSelector(org.onosproject.net.flow.TrafficSelector) ImmutableList(com.google.common.collect.ImmutableList) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) IntentService(org.onosproject.net.intent.IntentService) OutboundPacket(org.onosproject.net.packet.OutboundPacket) Intent(org.onosproject.net.intent.Intent) PartialFailureConstraint(org.onosproject.net.intent.constraint.PartialFailureConstraint) Activate(org.osgi.service.component.annotations.Activate) FabricRoute(org.onosproject.simplefabric.api.FabricRoute) PRI_REACTIVE_BORDER_FORWARD(org.onosproject.simplefabric.api.Constants.PRI_REACTIVE_BORDER_FORWARD) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) IpAddress(org.onlab.packet.IpAddress) SimpleFabricService(org.onosproject.simplefabric.api.SimpleFabricService) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PrintStream(java.io.PrintStream) PRI_REACTIVE_BORDER_BASE(org.onosproject.simplefabric.api.Constants.PRI_REACTIVE_BORDER_BASE) Logger(org.slf4j.Logger) PRI_REACTIVE_LOCAL_INTERCEPT(org.onosproject.simplefabric.api.Constants.PRI_REACTIVE_LOCAL_INTERCEPT) VlanId(org.onlab.packet.VlanId) FabricSubnet(org.onosproject.simplefabric.api.FabricSubnet) Ip6Prefix(org.onlab.packet.Ip6Prefix) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) IPv6(org.onlab.packet.IPv6) IPv4(org.onlab.packet.IPv4) REACTIVE_ALLOW_LINK_CP(org.onosproject.simplefabric.api.Constants.REACTIVE_ALLOW_LINK_CP) MacAddress(org.onlab.packet.MacAddress) PacketPriority(org.onosproject.net.packet.PacketPriority) Reference(org.osgi.service.component.annotations.Reference) Comparator(java.util.Comparator) Collections(java.util.Collections) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) FabricSubnet(org.onosproject.simplefabric.api.FabricSubnet) Device(org.onosproject.net.Device) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) FabricNetwork(org.onosproject.simplefabric.api.FabricNetwork) HashSet(java.util.HashSet) FabricRoute(org.onosproject.simplefabric.api.FabricRoute)

Example 4 with FabricNetwork

use of org.onosproject.simplefabric.api.FabricNetwork in project onos by opennetworkinglab.

the class DefaultFabricNetworkTest method testConstruction.

/**
 * Test object construction.
 */
@Test
public void testConstruction() {
    FabricNetwork network = fabricNetwork1;
    assertEquals(network.name(), NAME_1);
    assertEquals(network.interfaceNames(), INTF_NAME_SET_1);
    assertEquals(network.encapsulation(), ENCAP_TYPE_1);
    assertEquals(network.isForward(), IS_FORWARD_1);
    assertEquals(network.isBroadcast(), IS_BROADCAST_1);
}
Also used : FabricNetwork(org.onosproject.simplefabric.api.FabricNetwork) Test(org.junit.Test)

Example 5 with FabricNetwork

use of org.onosproject.simplefabric.api.FabricNetwork in project onos by opennetworkinglab.

the class SimpleFabricForwarding method refresh.

private void refresh() {
    log.debug("simple fabric forwarding refresh");
    Map<Key, SinglePointToMultiPointIntent> newBctIntentsMap = Maps.newConcurrentMap();
    Map<Key, MultiPointToSinglePointIntent> newUniIntentsMap = Maps.newConcurrentMap();
    for (FabricNetwork fabricNetwork : simpleFabric.fabricNetworks()) {
        // 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(fabricNetwork, hostsFromL2Network(fabricNetwork))) {
            newUniIntentsMap.put(intent.key(), intent);
        }
        if (fabricNetwork.isDirty()) {
            fabricNetwork.setDirty(false);
        }
    }
    boolean bctUpdated = false;
    for (SinglePointToMultiPointIntent intent : bctIntentsMap.values()) {
        SinglePointToMultiPointIntent newIntent = newBctIntentsMap.get(intent.key());
        if (newIntent == null) {
            log.info("simple fabric forwarding withdraw broadcast intent: {}", intent.key().toString());
            toBePurgedIntentKeys.add(intent.key());
            intentService.withdraw(intent);
            bctUpdated = true;
        }
    }
    for (SinglePointToMultiPointIntent intent : newBctIntentsMap.values()) {
        SinglePointToMultiPointIntent oldIntent = bctIntentsMap.get(intent.key());
        if (oldIntent == null || !oldIntent.filteredEgressPoints().equals(intent.filteredEgressPoints()) || !oldIntent.filteredIngressPoint().equals(intent.filteredIngressPoint()) || !oldIntent.selector().equals(intent.selector()) || !oldIntent.treatment().equals(intent.treatment()) || !oldIntent.constraints().equals(intent.constraints())) {
            log.info("simple fabric forwarding submit broadcast intent: {}", intent.key().toString());
            toBePurgedIntentKeys.remove(intent.key());
            intentService.submit(intent);
            bctUpdated = true;
        }
    }
    boolean uniUpdated = false;
    for (MultiPointToSinglePointIntent intent : uniIntentsMap.values()) {
        MultiPointToSinglePointIntent newIntent = newUniIntentsMap.get(intent.key());
        if (newIntent == null) {
            log.info("simple fabric forwarding withdraw unicast intent: {}", intent.key().toString());
            toBePurgedIntentKeys.add(intent.key());
            intentService.withdraw(intent);
            uniUpdated = true;
        }
    }
    for (MultiPointToSinglePointIntent intent : newUniIntentsMap.values()) {
        MultiPointToSinglePointIntent oldIntent = uniIntentsMap.get(intent.key());
        if (oldIntent == null || !oldIntent.filteredEgressPoint().equals(intent.filteredEgressPoint()) || !oldIntent.filteredIngressPoints().equals(intent.filteredIngressPoints()) || !oldIntent.selector().equals(intent.selector()) || !oldIntent.treatment().equals(intent.treatment()) || !oldIntent.constraints().equals(intent.constraints())) {
            log.info("simple fabric forwarding submit unicast intent: {}", intent.key().toString());
            toBePurgedIntentKeys.remove(intent.key());
            intentService.submit(intent);
            uniUpdated = true;
        }
    }
    if (bctUpdated) {
        bctIntentsMap = newBctIntentsMap;
    }
    if (uniUpdated) {
        uniIntentsMap = newUniIntentsMap;
    }
}
Also used : SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) FabricNetwork(org.onosproject.simplefabric.api.FabricNetwork) Key(org.onosproject.net.intent.Key)

Aggregations

FabricNetwork (org.onosproject.simplefabric.api.FabricNetwork)11 MacAddress (org.onlab.packet.MacAddress)7 FabricSubnet (org.onosproject.simplefabric.api.FabricSubnet)6 Host (org.onosproject.net.Host)5 Interface (org.onosproject.net.intf.Interface)5 FabricRoute (org.onosproject.simplefabric.api.FabricRoute)5 IpAddress (org.onlab.packet.IpAddress)4 EncapsulationType (org.onosproject.net.EncapsulationType)4 HashSet (java.util.HashSet)3 Set (java.util.Set)3 IpPrefix (org.onlab.packet.IpPrefix)3 ApplicationId (org.onosproject.core.ApplicationId)3 ConnectPoint (org.onosproject.net.ConnectPoint)3 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)3 Constraint (org.onosproject.net.intent.Constraint)3 Key (org.onosproject.net.intent.Key)3 MultiPointToSinglePointIntent (org.onosproject.net.intent.MultiPointToSinglePointIntent)3 EncapsulationConstraint (org.onosproject.net.intent.constraint.EncapsulationConstraint)3 PartialFailureConstraint (org.onosproject.net.intent.constraint.PartialFailureConstraint)3 SimpleFabricEvent (org.onosproject.simplefabric.api.SimpleFabricEvent)3