Search in sources :

Example 11 with Interface

use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.

the class FibInstaller method updateFilteringObjective.

/**
 * Installs or removes unicast filtering objectives relating to an interface.
 *
 * @param routerIntf interface to update objectives for
 * @param install true to install the objectives, false to remove them
 */
private void updateFilteringObjective(InterfaceProvisionRequest routerIntf, boolean install) {
    Interface intf = routerIntf.intf();
    VlanId assignedVlan = (egressVlan().equals(VlanId.NONE)) ? VlanId.vlanId(ASSIGNED_VLAN) : egressVlan();
    FilteringObjective.Builder fob = DefaultFilteringObjective.builder();
    // first add filter for the interface
    fob.withKey(Criteria.matchInPort(intf.connectPoint().port())).addCondition(Criteria.matchEthDst(intf.mac())).addCondition(Criteria.matchVlanId(intf.vlan()));
    fob.withPriority(PRIORITY_OFFSET);
    if (intf.vlan() == VlanId.NONE) {
        TrafficTreatment tt = DefaultTrafficTreatment.builder().pushVlan().setVlanId(assignedVlan).build();
        fob.withMeta(tt);
    }
    fob.permit().fromApp(fibAppId);
    sendFilteringObjective(install, fob, intf);
    // then add the same mac/vlan filters for control-plane connect point
    fob.withKey(Criteria.matchInPort(routerIntf.controlPlaneConnectPoint().port()));
    sendFilteringObjective(install, fob, intf);
}
Also used : DefaultFilteringObjective(org.onosproject.net.flowobjective.DefaultFilteringObjective) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Interface(org.onosproject.net.intf.Interface) VlanId(org.onlab.packet.VlanId)

Example 12 with Interface

use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.

the class FibInstallerTest method setUpInterfaceService.

/**
 * Sets up InterfaceService.
 */
private void setUpInterfaceService() {
    interfaceService.addListener(anyObject(InterfaceListener.class));
    expectLastCall().andDelegateTo(new TestInterfaceService());
    // Interface with no VLAN
    Interface sw1Eth1 = new Interface("intf1", SW1_ETH1, Collections.singletonList(INTF1), MAC1, VlanId.NONE);
    expect(interfaceService.getMatchingInterface(NEXT_HOP1)).andReturn(sw1Eth1);
    interfaces.add(sw1Eth1);
    // Interface with a VLAN
    Interface sw2Eth1 = new Interface("intf2", SW1_ETH2, Collections.singletonList(INTF2), MAC2, VLAN1);
    expect(interfaceService.getMatchingInterface(NEXT_HOP2)).andReturn(sw2Eth1);
    interfaces.add(sw2Eth1);
    expect(interfaceService.getInterfaces()).andReturn(interfaces);
    replay(interfaceService);
}
Also used : InterfaceListener(org.onosproject.net.intf.InterfaceListener) Interface(org.onosproject.net.intf.Interface)

Example 13 with Interface

use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.

the class DirectHostManager method handle.

private boolean handle(Ethernet eth) {
    checkNotNull(eth);
    // skip them.
    if (!enabled || (eth.getEtherType() != Ethernet.TYPE_IPV6 && eth.getEtherType() != Ethernet.TYPE_IPV4)) {
        return false;
    }
    // According to the type we set the destIp.
    IpAddress dstIp;
    if (eth.getEtherType() == Ethernet.TYPE_IPV4) {
        IPv4 ip = (IPv4) eth.getPayload();
        dstIp = IpAddress.valueOf(ip.getDestinationAddress());
    } else {
        IPv6 ip = (IPv6) eth.getPayload();
        dstIp = IpAddress.valueOf(INET6, ip.getDestinationAddress());
    }
    // Looking for a candidate output port.
    Interface egressInterface = interfaceService.getMatchingInterface(dstIp);
    if (egressInterface == null) {
        log.info("No egress interface found for {}", dstIp);
        return false;
    }
    // Looking for the destination mac.
    Optional<Host> host = hostService.getHostsByIp(dstIp).stream().filter(h -> h.location().equals(egressInterface.connectPoint())).filter(h -> h.vlan().equals(egressInterface.vlan())).findAny();
    // and we queue the packets waiting for a destination.
    if (host.isPresent()) {
        transformAndSend((IP) eth.getPayload(), eth.getEtherType(), egressInterface, host.get().mac());
    } else {
        hostService.startMonitoringIp(dstIp);
        ipPacketCache.asMap().compute(dstIp, (ip, queue) -> {
            if (queue == null) {
                queue = new ConcurrentLinkedQueue<>();
            }
            queue.add((IP) eth.getPayload());
            return queue;
        });
    }
    return true;
}
Also used : ENABLED(org.onosproject.routing.impl.OsgiPropertyConstants.ENABLED) Tools(org.onlab.util.Tools) Host(org.onosproject.net.Host) Interface(org.onosproject.net.intf.Interface) CoreService(org.onosproject.core.CoreService) ComponentContext(org.osgi.service.component.ComponentContext) LoggerFactory(org.slf4j.LoggerFactory) INET6(org.onlab.packet.IpAddress.Version.INET6) HostListener(org.onosproject.net.host.HostListener) InterfaceService(org.onosproject.net.intf.InterfaceService) HostService(org.onosproject.net.host.HostService) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ByteBuffer(java.nio.ByteBuffer) ConnectPoint(org.onosproject.net.ConnectPoint) Ethernet(org.onlab.packet.Ethernet) Component(org.osgi.service.component.annotations.Component) TrafficSelector(org.onosproject.net.flow.TrafficSelector) OutboundPacket(org.onosproject.net.packet.OutboundPacket) ApplicationId(org.onosproject.core.ApplicationId) HostEvent(org.onosproject.net.host.HostEvent) Activate(org.osgi.service.component.annotations.Activate) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) IpAddress(org.onlab.packet.IpAddress) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) Logger(org.slf4j.Logger) Deactivate(org.osgi.service.component.annotations.Deactivate) ENABLED_DEFAULT(org.onosproject.routing.impl.OsgiPropertyConstants.ENABLED_DEFAULT) VlanId(org.onlab.packet.VlanId) PacketProcessor(org.onosproject.net.packet.PacketProcessor) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) PacketService(org.onosproject.net.packet.PacketService) IPv6(org.onlab.packet.IPv6) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) TimeUnit(java.util.concurrent.TimeUnit) EthType(org.onlab.packet.EthType) IPv4(org.onlab.packet.IPv4) IP(org.onlab.packet.IP) PacketContext(org.onosproject.net.packet.PacketContext) Modified(org.osgi.service.component.annotations.Modified) Optional(java.util.Optional) MacAddress(org.onlab.packet.MacAddress) CacheBuilder(com.google.common.cache.CacheBuilder) PacketPriority(org.onosproject.net.packet.PacketPriority) Queue(java.util.Queue) Cache(com.google.common.cache.Cache) Reference(org.osgi.service.component.annotations.Reference) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) IPv6(org.onlab.packet.IPv6) IPv4(org.onlab.packet.IPv4) IpAddress(org.onlab.packet.IpAddress) Host(org.onosproject.net.Host) Interface(org.onosproject.net.intf.Interface)

Example 14 with Interface

use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.

the class PimInterfaceManager method updateInterface.

private void updateInterface(PimInterfaceConfig config) {
    ConnectPoint cp = config.subject();
    if (!config.isEnabled()) {
        removeInterface(cp);
        return;
    }
    String intfName = config.getInterfaceName();
    Interface intf = interfaceService.getInterfaceByName(cp, intfName);
    if (intf == null) {
        log.debug("Interface configuration missing: {}", config.getInterfaceName());
        return;
    }
    log.debug("Updating Interface for " + intf.connectPoint().toString());
    pimInterfaces.computeIfAbsent(cp, k -> buildPimInterface(config, intf));
}
Also used : ConnectPoint(org.onosproject.net.ConnectPoint) Interface(org.onosproject.net.intf.Interface)

Example 15 with Interface

use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.

the class PimInterfaceManager method getSourceInterface.

private PimInterface getSourceInterface(McastRoute route) {
    Route unicastRoute = unicastRouteService.longestPrefixMatch(route.source());
    if (unicastRoute == null) {
        log.warn("No route to source {}", route.source());
        return null;
    }
    Interface intf = interfaceService.getMatchingInterface(unicastRoute.nextHop());
    if (intf == null) {
        log.warn("No interface with route to next hop {}", unicastRoute.nextHop());
        return null;
    }
    PimInterface pimInterface = pimInterfaces.get(intf.connectPoint());
    if (pimInterface == null) {
        log.warn("PIM is not enabled on interface {}", intf);
        return null;
    }
    Set<Host> hosts = hostService.getHostsByIp(unicastRoute.nextHop());
    Host host = null;
    for (Host h : hosts) {
        if (h.vlan().equals(intf.vlan())) {
            host = h;
        }
    }
    if (host == null) {
        log.warn("Next hop host entry not found: {}", unicastRoute.nextHop());
        return null;
    }
    pimInterface.addRoute(route, unicastRoute.nextHop(), host.mac());
    return pimInterface;
}
Also used : Host(org.onosproject.net.Host) Route(org.onosproject.routeservice.Route) McastRoute(org.onosproject.net.mcast.McastRoute) Interface(org.onosproject.net.intf.Interface)

Aggregations

Interface (org.onosproject.net.intf.Interface)92 ConnectPoint (org.onosproject.net.ConnectPoint)51 MacAddress (org.onlab.packet.MacAddress)35 VlanId (org.onlab.packet.VlanId)34 InterfaceIpAddress (org.onosproject.net.host.InterfaceIpAddress)32 Ethernet (org.onlab.packet.Ethernet)28 IpAddress (org.onlab.packet.IpAddress)28 ArrayList (java.util.ArrayList)26 DeviceId (org.onosproject.net.DeviceId)26 Host (org.onosproject.net.Host)25 InterfaceService (org.onosproject.net.intf.InterfaceService)25 Logger (org.slf4j.Logger)25 Set (java.util.Set)23 TrafficSelector (org.onosproject.net.flow.TrafficSelector)23 LoggerFactory (org.slf4j.LoggerFactory)23 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)22 Test (org.junit.Test)21 ApplicationId (org.onosproject.core.ApplicationId)21 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)20 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)20