Search in sources :

Example 26 with Host

use of org.onosproject.net.Host in project onos by opennetworkinglab.

the class OvsOfdpaPipeline method processDoubleVlanIdFilter.

/**
 * Internal implementation of processDoubleVlanIdFilter.
 *
 * @param portCriterion       port on device for which this filter is programmed
 * @param innerVidCriterion   inner vlan
 * @param outerVidCriterion   outer vlan
 * @param popVlan             true if outer vlan header needs to be removed
 * @param applicationId       for application programming this filter
 * @return flow rules for port-vlan filters
 */
private List<FlowRule> processDoubleVlanIdFilter(PortCriterion portCriterion, VlanIdCriterion innerVidCriterion, VlanIdCriterion outerVidCriterion, boolean popVlan, ApplicationId applicationId) {
    List<FlowRule> rules = new ArrayList<>();
    TrafficSelector.Builder outerSelector = DefaultTrafficSelector.builder();
    TrafficTreatment.Builder outerTreatment = DefaultTrafficTreatment.builder();
    TrafficSelector.Builder innerSelector = DefaultTrafficSelector.builder();
    TrafficTreatment.Builder innerTreatment = DefaultTrafficTreatment.builder();
    VlanId outerVlanId = outerVidCriterion.vlanId();
    VlanId innerVlanId = innerVidCriterion.vlanId();
    PortNumber portNumber = portCriterion.port();
    // Check arguments
    if (PortNumber.ALL.equals(portNumber) || outerVlanId.equals(VlanId.NONE) || innerVlanId.equals(VlanId.NONE)) {
        log.warn("Incomplete Filtering Objective. " + "VLAN Table cannot be programmed for {}", deviceId);
        return ImmutableList.of();
    } else {
        outerSelector.matchInPort(portNumber);
        innerSelector.matchInPort(portNumber);
        outerTreatment.transition(VLAN_1_TABLE);
        innerTreatment.transition(TMAC_TABLE);
        outerTreatment.writeMetadata(outerVlanId.toShort(), 0xFFF);
        outerSelector.matchVlanId(outerVlanId);
        innerSelector.matchVlanId(innerVlanId);
        // force recompilation
        // FIXME might be issue due tu /fff mask
        innerSelector.matchMetadata(outerVlanId.toShort());
        if (popVlan) {
            outerTreatment.popVlan();
        }
    }
    // NOTE: for double-tagged packets, restore original outer vlan
    // before sending it to the controller.
    GroupKey groupKey = popVlanPuntGroupKey();
    Group group = groupService.getGroup(deviceId, groupKey);
    if (group != null) {
        // push outer vlan and send to controller
        TrafficSelector.Builder sbuilder = DefaultTrafficSelector.builder().matchInPort(portNumber).matchVlanId(innerVlanId);
        Host host = handler().get(HostService.class).getConnectedHosts(ConnectPoint.deviceConnectPoint(deviceId + "/" + portNumber.toLong())).stream().filter(h -> h.vlan().equals(outerVlanId)).findFirst().orElse(null);
        EthType vlanType = EthType.EtherType.VLAN.ethType();
        if (host != null) {
            vlanType = host.tpid();
        }
        TrafficTreatment.Builder tbuilder = DefaultTrafficTreatment.builder().pushVlan(vlanType).setVlanId(outerVlanId).punt();
        rules.add(DefaultFlowRule.builder().forDevice(deviceId).withSelector(sbuilder.build()).withTreatment(tbuilder.build()).withPriority(PacketPriority.CONTROL.priorityValue()).fromApp(driverId).makePermanent().forTable(PUNT_TABLE).build());
    } else {
        log.info("popVlanPuntGroup not found in dev:{}", deviceId);
        return Collections.emptyList();
    }
    FlowRule outerRule = DefaultFlowRule.builder().forDevice(deviceId).withSelector(outerSelector.build()).withTreatment(outerTreatment.build()).withPriority(DEFAULT_PRIORITY).fromApp(applicationId).makePermanent().forTable(VLAN_TABLE).build();
    FlowRule innerRule = DefaultFlowRule.builder().forDevice(deviceId).withSelector(innerSelector.build()).withTreatment(innerTreatment.build()).withPriority(DEFAULT_PRIORITY).fromApp(applicationId).makePermanent().forTable(VLAN_1_TABLE).build();
    rules.add(outerRule);
    rules.add(innerRule);
    return rules;
}
Also used : NextGroup(org.onosproject.net.behaviour.NextGroup) Group(org.onosproject.net.group.Group) HostService(org.onosproject.net.host.HostService) ArrayList(java.util.ArrayList) GroupKey(org.onosproject.net.group.GroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) Host(org.onosproject.net.Host) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) EthType(org.onlab.packet.EthType) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) PortNumber(org.onosproject.net.PortNumber) VlanId(org.onlab.packet.VlanId)

Example 27 with Host

use of org.onosproject.net.Host in project onos by opennetworkinglab.

the class ScaleTestManager method createRoutes.

// Creates the specified number of random routes. Such routes are generated
// using random IP prefices with next hop being an IP address of a randomly
// chosen hosts.
private void createRoutes(int routeCount) {
    List<Host> hosts = ImmutableList.copyOf(hostAdminService.getHosts());
    ImmutableSet.Builder<Route> routes = ImmutableSet.builder();
    for (int i = 0; i < routeCount; i++) {
        IpPrefix prefix = randomIp().toIpPrefix();
        IpAddress nextHop = randomIp(hosts);
        routes.add(new Route(Route.Source.STATIC, prefix, nextHop));
    }
    routeAdminService.update(routes.build());
}
Also used : IpPrefix(org.onlab.packet.IpPrefix) ImmutableSet(com.google.common.collect.ImmutableSet) Host(org.onosproject.net.Host) IpAddress(org.onlab.packet.IpAddress) Route(org.onosproject.routeservice.Route)

Example 28 with Host

use of org.onosproject.net.Host in project onos by opennetworkinglab.

the class HostToHostIntentCompiler method compile.

@Override
public List<Intent> compile(HostToHostIntent intent, List<Intent> installable) {
    // If source and destination are the same, there are never any installables.
    if (Objects.equals(intent.one(), intent.two())) {
        return ImmutableList.of();
    }
    boolean isAsymmetric = intent.constraints().contains(new AsymmetricPathConstraint());
    Path pathOne = getPathOrException(intent, intent.one(), intent.two());
    Path pathTwo = isAsymmetric ? getPathOrException(intent, intent.two(), intent.one()) : invertPath(pathOne);
    Host one = hostService.getHost(intent.one());
    Host two = hostService.getHost(intent.two());
    return Arrays.asList(createLinkCollectionIntent(pathOne, one, two, intent), createLinkCollectionIntent(pathTwo, two, one, intent));
}
Also used : DefaultPath(org.onosproject.net.DefaultPath) Path(org.onosproject.net.Path) Host(org.onosproject.net.Host) AsymmetricPathConstraint(org.onosproject.net.intent.constraint.AsymmetricPathConstraint)

Example 29 with Host

use of org.onosproject.net.Host in project onos by opennetworkinglab.

the class HostToHostIntentCompiler method createLinkCollectionIntent.

private Intent createLinkCollectionIntent(Path path, Host src, Host dst, HostToHostIntent intent) {
    // Try to allocate bandwidth
    List<ConnectPoint> pathCPs = path.links().stream().flatMap(l -> Stream.of(l.src(), l.dst())).collect(Collectors.toList());
    allocateBandwidth(intent, pathCPs);
    Link ingressLink = path.links().get(0);
    Link egressLink = path.links().get(path.links().size() - 1);
    FilteredConnectPoint ingressPoint = getFilteredPointFromLink(ingressLink);
    FilteredConnectPoint egressPoint = getFilteredPointFromLink(egressLink);
    TrafficSelector selector = builder(intent.selector()).matchEthSrc(src.mac()).matchEthDst(dst.mac()).build();
    /*
         * The path contains also the edge links, these are not necessary
         * for the LinkCollectionIntent.
         */
    Set<Link> coreLinks = path.links().stream().filter(link -> !link.type().equals(EDGE)).collect(Collectors.toSet());
    return LinkCollectionIntent.builder().key(intent.key()).appId(intent.appId()).selector(selector).treatment(intent.treatment()).links(coreLinks).filteredIngressPoints(ImmutableSet.of(ingressPoint)).filteredEgressPoints(ImmutableSet.of(egressPoint)).applyTreatmentOnEgress(true).constraints(intent.constraints()).priority(intent.priority()).resourceGroup(intent.resourceGroup()).build();
}
Also used : Arrays(java.util.Arrays) Host(org.onosproject.net.Host) AsymmetricPathConstraint(org.onosproject.net.intent.constraint.AsymmetricPathConstraint) IntentCompilationException(org.onosproject.net.intent.IntentCompilationException) Link(org.onosproject.net.Link) HostService(org.onosproject.net.host.HostService) ConnectPoint(org.onosproject.net.ConnectPoint) ArrayList(java.util.ArrayList) Component(org.osgi.service.component.annotations.Component) TrafficSelector(org.onosproject.net.flow.TrafficSelector) ImmutableList(com.google.common.collect.ImmutableList) DefaultPath(org.onosproject.net.DefaultPath) Intent(org.onosproject.net.intent.Intent) Activate(org.osgi.service.component.annotations.Activate) DefaultLink(org.onosproject.net.DefaultLink) ImmutableSet(com.google.common.collect.ImmutableSet) Logger(org.slf4j.Logger) HostToHostIntent(org.onosproject.net.intent.HostToHostIntent) Deactivate(org.osgi.service.component.annotations.Deactivate) Set(java.util.Set) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) DefaultTrafficSelector.builder(org.onosproject.net.flow.DefaultTrafficSelector.builder) Collectors(java.util.stream.Collectors) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) Objects(java.util.Objects) List(java.util.List) Stream(java.util.stream.Stream) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) EDGE(org.onosproject.net.Link.Type.EDGE) Path(org.onosproject.net.Path) Reference(org.osgi.service.component.annotations.Reference) DeviceId(org.onosproject.net.DeviceId) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) TrafficSelector(org.onosproject.net.flow.TrafficSelector) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Link(org.onosproject.net.Link) DefaultLink(org.onosproject.net.DefaultLink) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Example 30 with Host

use of org.onosproject.net.Host in project onos by opennetworkinglab.

the class ReactiveForwarding method fixBlackhole.

private void fixBlackhole(ConnectPoint egress) {
    Set<FlowEntry> rules = getFlowRulesFrom(egress);
    Set<SrcDstPair> pairs = findSrcDstPairs(rules);
    Map<DeviceId, Set<Path>> srcPaths = new HashMap<>();
    for (SrcDstPair sd : pairs) {
        // get the edge deviceID for the src host
        Host srcHost = hostService.getHost(HostId.hostId(sd.src));
        Host dstHost = hostService.getHost(HostId.hostId(sd.dst));
        if (srcHost != null && dstHost != null) {
            DeviceId srcId = srcHost.location().deviceId();
            DeviceId dstId = dstHost.location().deviceId();
            log.trace("SRC ID is {}, DST ID is {}", srcId, dstId);
            cleanFlowRules(sd, egress.deviceId());
            Set<Path> shortestPaths = srcPaths.get(srcId);
            if (shortestPaths == null) {
                shortestPaths = topologyService.getPaths(topologyService.currentTopology(), egress.deviceId(), srcId);
                srcPaths.put(srcId, shortestPaths);
            }
            backTrackBadNodes(shortestPaths, dstId, sd);
        }
    }
}
Also used : Path(org.onosproject.net.Path) Set(java.util.Set) ImmutableSet(com.google.common.collect.ImmutableSet) HashMap(java.util.HashMap) DeviceId(org.onosproject.net.DeviceId) Host(org.onosproject.net.Host) FlowEntry(org.onosproject.net.flow.FlowEntry)

Aggregations

Host (org.onosproject.net.Host)144 MacAddress (org.onlab.packet.MacAddress)55 IpAddress (org.onlab.packet.IpAddress)54 HostEvent (org.onosproject.net.host.HostEvent)50 ConnectPoint (org.onosproject.net.ConnectPoint)47 Test (org.junit.Test)45 DefaultHost (org.onosproject.net.DefaultHost)45 HostService (org.onosproject.net.host.HostService)45 Set (java.util.Set)43 VlanId (org.onlab.packet.VlanId)43 DeviceId (org.onosproject.net.DeviceId)39 Logger (org.slf4j.Logger)39 HostLocation (org.onosproject.net.HostLocation)38 LoggerFactory (org.slf4j.LoggerFactory)37 List (java.util.List)34 HostId (org.onosproject.net.HostId)33 Interface (org.onosproject.net.intf.Interface)32 Sets (com.google.common.collect.Sets)31 Optional (java.util.Optional)30 Lists (com.google.common.collect.Lists)29