Search in sources :

Example 6 with VlanId

use of org.onlab.packet.VlanId in project trellis-control by opennetworkinglab.

the class RoutingRulePopulator method bridgingFwdObjBuilder.

/**
 * Generates a forwarding objective builder for bridging rules.
 * <p>
 * The forwarding objective bridges packets destined to a given MAC to
 * given port on given device.
 *
 * @param deviceId Device that host attaches to
 * @param mac MAC address of the host
 * @param hostVlanId VLAN ID of the host
 * @param outport Port that host attaches to
 * @param revoke true if forwarding objective is meant to revoke forwarding rule
 * @return Forwarding objective builder
 */
private ForwardingObjective.Builder bridgingFwdObjBuilder(DeviceId deviceId, MacAddress mac, VlanId hostVlanId, PortNumber outport, boolean revoke) {
    ConnectPoint connectPoint = new ConnectPoint(deviceId, outport);
    VlanId untaggedVlan = srManager.interfaceService.getUntaggedVlanId(connectPoint);
    Set<VlanId> taggedVlans = srManager.interfaceService.getTaggedVlanId(connectPoint);
    VlanId nativeVlan = srManager.interfaceService.getNativeVlanId(connectPoint);
    // Create host selector
    TrafficSelector.Builder sbuilder = DefaultTrafficSelector.builder();
    sbuilder.matchEthDst(mac);
    // Create host treatment
    TrafficTreatment.Builder tbuilder = DefaultTrafficTreatment.builder();
    tbuilder.immediate().setOutput(outport);
    // Create host meta
    TrafficSelector.Builder mbuilder = DefaultTrafficSelector.builder();
    // Adjust the selector, treatment and meta according to VLAN configuration
    if (taggedVlans.contains(hostVlanId)) {
        sbuilder.matchVlanId(hostVlanId);
        mbuilder.matchVlanId(hostVlanId);
    } else if (hostVlanId.equals(VlanId.NONE)) {
        if (untaggedVlan != null) {
            sbuilder.matchVlanId(untaggedVlan);
            mbuilder.matchVlanId(untaggedVlan);
            tbuilder.immediate().popVlan();
        } else if (nativeVlan != null) {
            sbuilder.matchVlanId(nativeVlan);
            mbuilder.matchVlanId(nativeVlan);
            tbuilder.immediate().popVlan();
        } else {
            log.warn("Untagged host {}/{} is not allowed on {} without untagged or native " + "vlan config", mac, hostVlanId, connectPoint);
            return null;
        }
    } else {
        log.warn("Tagged host {}/{} is not allowed on {} without VLAN listed in tagged vlan", mac, hostVlanId, connectPoint);
        return null;
    }
    // All forwarding is via Groups. Drivers can re-purpose to flow-actions if needed.
    // If the objective is to revoke an existing rule, and for some reason
    // the next-objective does not exist, then a new one should not be created
    int portNextObjId = srManager.getPortNextObjectiveId(deviceId, outport, tbuilder.build(), mbuilder.build(), !revoke);
    if (portNextObjId == -1) {
        // Warning log will come from getPortNextObjective method
        return null;
    }
    return DefaultForwardingObjective.builder().withFlag(ForwardingObjective.Flag.SPECIFIC).withSelector(sbuilder.build()).nextStep(portNextObjId).withPriority(100).fromApp(srManager.appId).makePermanent();
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) VlanId(org.onlab.packet.VlanId) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 7 with VlanId

use of org.onlab.packet.VlanId in project trellis-control by opennetworkinglab.

the class RoutingRulePopulator method getTreatmentAndMeta.

private ImmutablePair<TrafficTreatment, TrafficSelector> getTreatmentAndMeta(DeviceId deviceId, MacAddress hostMac, VlanId hostVlanId, PortNumber outPort, VlanId innerVlan, EthType outerTpid) throws DeviceConfigNotFoundException {
    MacAddress routerMac;
    routerMac = config.getDeviceMac(deviceId);
    ConnectPoint connectPoint = new ConnectPoint(deviceId, outPort);
    VlanId untaggedVlan = srManager.interfaceService.getUntaggedVlanId(connectPoint);
    Set<VlanId> taggedVlans = srManager.interfaceService.getTaggedVlanId(connectPoint);
    VlanId nativeVlan = srManager.interfaceService.getNativeVlanId(connectPoint);
    // Create route treatment
    TrafficTreatment.Builder tbuilder = DefaultTrafficTreatment.builder().deferred().setEthDst(hostMac).setEthSrc(routerMac).setOutput(outPort);
    // Create route meta
    TrafficSelector.Builder mbuilder = DefaultTrafficSelector.builder();
    // Adjust treatment and meta according to VLAN configuration
    if (taggedVlans.contains(hostVlanId)) {
        mbuilder.matchVlanId(hostVlanId);
        tbuilder.setVlanId(hostVlanId);
    } else if (hostVlanId.equals(VlanId.NONE)) {
        if (untaggedVlan != null) {
            mbuilder.matchVlanId(untaggedVlan);
            tbuilder.popVlan();
        } else if (nativeVlan != null) {
            mbuilder.matchVlanId(nativeVlan);
            tbuilder.popVlan();
        } else {
            log.warn("Untagged nexthop {}/{} is not allowed on {} without untagged or native vlan", hostMac, hostVlanId, connectPoint);
            return null;
        }
    } else {
        // Double tagged hosts
        if (innerVlan == null || outerTpid == null) {
            log.warn("Failed to construct NextObj for double tagged hosts {}/{}. {} {}", hostMac, hostVlanId, (innerVlan == null) ? "innerVlan = null." : "", (outerTpid == null) ? "outerTpid = null." : "");
            return null;
        }
        tbuilder.setVlanId(innerVlan);
        tbuilder.pushVlan(outerTpid);
        tbuilder.setVlanId(hostVlanId);
        mbuilder.matchVlanId(VlanId.ANY);
    }
    return ImmutablePair.of(tbuilder.build(), mbuilder.build());
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) MacAddress(org.onlab.packet.MacAddress) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) VlanId(org.onlab.packet.VlanId)

Example 8 with VlanId

use of org.onlab.packet.VlanId in project trellis-control by opennetworkinglab.

the class SegmentRoutingManager method getInternalVlanId.

@Override
public VlanId getInternalVlanId(ConnectPoint connectPoint) {
    VlanId untaggedVlanId = interfaceService.getUntaggedVlanId(connectPoint);
    VlanId nativeVlanId = interfaceService.getNativeVlanId(connectPoint);
    return untaggedVlanId != null ? untaggedVlanId : nativeVlanId;
}
Also used : VlanId(org.onlab.packet.VlanId)

Example 9 with VlanId

use of org.onlab.packet.VlanId in project trellis-control by opennetworkinglab.

the class SegmentRoutingManager method modified.

@Modified
private void modified(ComponentContext context) {
    Dictionary<?, ?> properties = context.getProperties();
    if (properties == null) {
        return;
    }
    String strActiveProbing = Tools.get(properties, PROP_ACTIVE_PROBING);
    boolean expectActiveProbing = Boolean.parseBoolean(strActiveProbing);
    if (expectActiveProbing != activeProbing) {
        activeProbing = expectActiveProbing;
        log.info("{} active probing", activeProbing ? "Enabling" : "Disabling");
    }
    String strSymmetricProbing = Tools.get(properties, PROP_SYMMETRIC_PROBING);
    boolean expectSymmetricProbing = Boolean.parseBoolean(strSymmetricProbing);
    if (expectSymmetricProbing != symmetricProbing) {
        symmetricProbing = expectSymmetricProbing;
        log.info("{} symmetric probing", symmetricProbing ? "Enabling" : "Disabling");
    }
    String strSingleHomedDown = Tools.get(properties, PROP_SINGLE_HOMED_DOWN);
    boolean expectSingleHomedDown = Boolean.parseBoolean(strSingleHomedDown);
    if (expectSingleHomedDown != singleHomedDown) {
        singleHomedDown = expectSingleHomedDown;
        log.info("{} downing of single homed hosts for lost uplinks", singleHomedDown ? "Enabling" : "Disabling");
        if (singleHomedDown && linkHandler != null) {
            hostService.getHosts().forEach(host -> host.locations().forEach(loc -> {
                if (interfaceService.isConfigured(loc)) {
                    linkHandler.checkUplinksForHost(loc);
                }
            }));
        } else {
            log.warn("Disabling singleHomedDown does not re-enable already " + "downed ports for single-homed hosts");
        }
    }
    String strRespondToUnknownHosts = Tools.get(properties, PROP_RESPOND_TO_UNKNOWN_HOSTS);
    boolean expectRespondToUnknownHosts = Boolean.parseBoolean(strRespondToUnknownHosts);
    if (expectRespondToUnknownHosts != respondToUnknownHosts) {
        respondToUnknownHosts = expectRespondToUnknownHosts;
        log.info("{} responding to ARPs/NDPs from unknown hosts", respondToUnknownHosts ? "Enabling" : "Disabling");
    }
    String strRouteDoubleTaggedHosts = Tools.get(properties, PROP_ROUTE_DOUBLE_TAGGED_HOSTS);
    boolean expectRouteDoubleTaggedHosts = Boolean.parseBoolean(strRouteDoubleTaggedHosts);
    if (expectRouteDoubleTaggedHosts != routeDoubleTaggedHosts) {
        routeDoubleTaggedHosts = expectRouteDoubleTaggedHosts;
        log.info("{} routing for double tagged hosts", routeDoubleTaggedHosts ? "Enabling" : "Disabling");
        if (routeDoubleTaggedHosts) {
            hostHandler.populateAllDoubleTaggedHost();
        } else {
            hostHandler.revokeAllDoubleTaggedHost();
        }
    }
    String strDefaultInternalVlan = Tools.get(properties, PROP_DEFAULT_INTERNAL_VLAN);
    int defIntVlan = Integer.parseInt(strDefaultInternalVlan);
    if (defIntVlan != defaultInternalVlan) {
        if (canUseVlanId(defIntVlan)) {
            log.warn("Default internal vlan value changed from {} to {}.. " + "re-programming filtering rules, but NOT any groups already " + "created with the former value", defaultInternalVlan, defIntVlan);
            VlanId oldDefIntVlan = VlanId.vlanId((short) defaultInternalVlan);
            defaultInternalVlan = defIntVlan;
            routingRulePopulator.updateSpecialVlanFilteringRules(true, oldDefIntVlan, VlanId.vlanId((short) defIntVlan));
        } else {
            log.warn("Cannot change default internal vlan to unusable " + "value {}", defIntVlan);
        }
    }
    String strPwTxpVlan = Tools.get(properties, PROP_PW_TRANSPORT_VLAN);
    int pwTxpVlan = Integer.parseInt(strPwTxpVlan);
    if (pwTxpVlan != pwTransportVlan) {
        if (canUseVlanId(pwTxpVlan)) {
            log.warn("Pseudowire transport vlan value changed from {} to {}.. " + "re-programming filtering rules, but NOT any groups already " + "created with the former value", pwTransportVlan, pwTxpVlan);
            VlanId oldPwTxpVlan = VlanId.vlanId((short) pwTransportVlan);
            pwTransportVlan = pwTxpVlan;
            routingRulePopulator.updateSpecialVlanFilteringRules(false, oldPwTxpVlan, VlanId.vlanId((short) pwTxpVlan));
        } else {
            log.warn("Cannot change pseudowire transport vlan to unusable " + "value {}", pwTxpVlan);
        }
    }
    String strRouteSimplification = Tools.get(properties, PROP_ROUTE_SIMPLIFICATION);
    boolean expectRouteSimplification = Boolean.parseBoolean(strRouteSimplification);
    if (expectRouteSimplification != routeSimplification) {
        routeSimplification = expectRouteSimplification;
        log.info("{} route simplification", routeSimplification ? "Enabling" : "Disabling");
    }
}
Also used : DeviceConfigNotFoundException(org.onosproject.segmentrouting.config.DeviceConfigNotFoundException) NetworkConfigRegistry(org.onosproject.net.config.NetworkConfigRegistry) ROUTE_SIMPLIFICATION_DEFAULT(org.onosproject.segmentrouting.OsgiPropertyConstants.ROUTE_SIMPLIFICATION_DEFAULT) McastStoreKey(org.onosproject.segmentrouting.mcast.McastStoreKey) PROP_ACTIVE_PROBING(org.onosproject.segmentrouting.OsgiPropertyConstants.PROP_ACTIVE_PROBING) PortNumber(org.onosproject.net.PortNumber) DeviceService(org.onosproject.net.device.DeviceService) TYPE_ARP(org.onlab.packet.Ethernet.TYPE_ARP) DefaultL2TunnelDescription(org.onosproject.segmentrouting.pwaas.DefaultL2TunnelDescription) ROUTE_DOUBLE_TAGGED_HOSTS_DEFAULT(org.onosproject.segmentrouting.OsgiPropertyConstants.ROUTE_DOUBLE_TAGGED_HOSTS_DEFAULT) NeighbourResolutionService(org.onosproject.net.neighbour.NeighbourResolutionService) L2TunnelDescription(org.onosproject.segmentrouting.pwaas.L2TunnelDescription) ConnectPoint(org.onosproject.net.ConnectPoint) StorageService(org.onosproject.store.service.StorageService) SubjectFactories(org.onosproject.net.config.basics.SubjectFactories) McastEvent(org.onosproject.mcast.api.McastEvent) Port(org.onosproject.net.Port) Map(java.util.Map) ApplicationId(org.onosproject.core.ApplicationId) NextObjective(org.onosproject.net.flowobjective.NextObjective) MulticastRouteService(org.onosproject.mcast.api.MulticastRouteService) KryoNamespaces(org.onosproject.store.serializers.KryoNamespaces) MastershipService(org.onosproject.mastership.MastershipService) SYMMETRIC_PROBING_DEFAULT(org.onosproject.segmentrouting.OsgiPropertyConstants.SYMMETRIC_PROBING_DEFAULT) Deactivate(org.osgi.service.component.annotations.Deactivate) Set(java.util.Set) PacketService(org.onosproject.net.packet.PacketService) WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) ReferencePolicy(org.osgi.service.component.annotations.ReferencePolicy) DEFAULT_INTERNAL_VLAN_DEFAULT(org.onosproject.segmentrouting.OsgiPropertyConstants.DEFAULT_INTERNAL_VLAN_DEFAULT) Executors(java.util.concurrent.Executors) RouteListener(org.onosproject.routeservice.RouteListener) ConfigFactory(org.onosproject.net.config.ConfigFactory) LinkListener(org.onosproject.net.link.LinkListener) DeviceEvent(org.onosproject.net.device.DeviceEvent) DeviceId(org.onosproject.net.DeviceId) ConfigException(org.onosproject.net.config.ConfigException) Dictionary(java.util.Dictionary) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Tools(org.onlab.util.Tools) Host(org.onosproject.net.Host) LinkEvent(org.onosproject.net.link.LinkEvent) NetworkConfigEvent(org.onosproject.net.config.NetworkConfigEvent) VlanNextObjectiveStoreKey(org.onosproject.segmentrouting.storekey.VlanNextObjectiveStoreKey) ComponentContext(org.osgi.service.component.ComponentContext) RouteEvent(org.onosproject.routeservice.RouteEvent) KryoNamespace(org.onlab.util.KryoNamespace) HostListener(org.onosproject.net.host.HostListener) InterfaceService(org.onosproject.net.intf.InterfaceService) HostService(org.onosproject.net.host.HostService) ArrayList(java.util.ArrayList) McastListener(org.onosproject.mcast.api.McastListener) CONFIG_UNREGISTERED(org.onosproject.net.config.NetworkConfigEvent.Type.CONFIG_UNREGISTERED) RESPOND_TO_UNKNOWN_HOSTS_DEFAULT(org.onosproject.segmentrouting.OsgiPropertyConstants.RESPOND_TO_UNKNOWN_HOSTS_DEFAULT) MastershipEvent(org.onosproject.mastership.MastershipEvent) SegmentRoutingAppConfig(org.onosproject.segmentrouting.config.SegmentRoutingAppConfig) Component(org.osgi.service.component.annotations.Component) Lists(com.google.common.collect.Lists) TrafficSelector(org.onosproject.net.flow.TrafficSelector) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) NextNeighbors(org.onosproject.segmentrouting.grouphandler.NextNeighbors) DefaultL2TunnelHandler(org.onosproject.segmentrouting.pwaas.DefaultL2TunnelHandler) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) DeviceListener(org.onosproject.net.device.DeviceListener) VlanId(org.onlab.packet.VlanId) PW_TRANSPORT_VLAN_DEFAULT(org.onosproject.segmentrouting.OsgiPropertyConstants.PW_TRANSPORT_VLAN_DEFAULT) IPv6(org.onlab.packet.IPv6) ExecutionException(java.util.concurrent.ExecutionException) IPv4(org.onlab.packet.IPv4) CONFIG_REGISTERED(org.onosproject.net.config.NetworkConfigEvent.Type.CONFIG_REGISTERED) DestinationSetNextObjectiveStoreKey(org.onosproject.segmentrouting.storekey.DestinationSetNextObjectiveStoreKey) MacAddress(org.onlab.packet.MacAddress) PROP_PW_TRANSPORT_VLAN(org.onosproject.segmentrouting.OsgiPropertyConstants.PROP_PW_TRANSPORT_VLAN) ResolvedRoute(org.onosproject.routeservice.ResolvedRoute) PROP_ROUTE_DOUBLE_TAGGED_HOSTS(org.onosproject.segmentrouting.OsgiPropertyConstants.PROP_ROUTE_DOUBLE_TAGGED_HOSTS) NetworkConfigListener(org.onosproject.net.config.NetworkConfigListener) PortNextObjectiveStoreKey(org.onosproject.segmentrouting.storekey.PortNextObjectiveStoreKey) XconnectService(org.onosproject.segmentrouting.xconnect.api.XconnectService) ScheduledFuture(java.util.concurrent.ScheduledFuture) Interface(org.onosproject.net.intf.Interface) CoreService(org.onosproject.core.CoreService) L2Tunnel(org.onosproject.segmentrouting.pwaas.L2Tunnel) LoggerFactory(org.slf4j.LoggerFactory) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) McastConfig(org.onosproject.net.config.basics.McastConfig) TopologyService(org.onosproject.net.topology.TopologyService) EventuallyConsistentMapBuilder(org.onosproject.store.service.EventuallyConsistentMapBuilder) Link(org.onosproject.net.Link) Ethernet(org.onlab.packet.Ethernet) HashMultimap(com.google.common.collect.HashMultimap) DefaultL2TunnelPolicy(org.onosproject.segmentrouting.pwaas.DefaultL2TunnelPolicy) McastFilteringObjStoreKey(org.onosproject.segmentrouting.mcast.McastFilteringObjStoreKey) PROP_ROUTE_SIMPLIFICATION(org.onosproject.segmentrouting.OsgiPropertyConstants.PROP_ROUTE_SIMPLIFICATION) WorkPartitionService(org.onosproject.net.intent.WorkPartitionService) PROP_DEFAULT_INTERNAL_VLAN(org.onosproject.segmentrouting.OsgiPropertyConstants.PROP_DEFAULT_INTERNAL_VLAN) Event(org.onosproject.event.Event) NodeId(org.onosproject.cluster.NodeId) RouteService(org.onosproject.routeservice.RouteService) McastHandler(org.onosproject.segmentrouting.mcast.McastHandler) TopologyEvent(org.onosproject.net.topology.TopologyEvent) ClusterEvent(org.onosproject.cluster.ClusterEvent) ImmutableMap(com.google.common.collect.ImmutableMap) Device(org.onosproject.net.Device) PacketProcessor(org.onosproject.net.packet.PacketProcessor) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Instant(java.time.Instant) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) Preconditions.checkState(com.google.common.base.Preconditions.checkState) PROP_RESPOND_TO_UNKNOWN_HOSTS(org.onosproject.segmentrouting.OsgiPropertyConstants.PROP_RESPOND_TO_UNKNOWN_HOSTS) List(java.util.List) InboundPacket(org.onosproject.net.packet.InboundPacket) PacketContext(org.onosproject.net.packet.PacketContext) LinkService(org.onosproject.net.link.LinkService) Optional(java.util.Optional) ClusterService(org.onosproject.cluster.ClusterService) IpPrefix(org.onlab.packet.IpPrefix) McastRole(org.onosproject.segmentrouting.mcast.McastRole) McastRoleStoreKey(org.onosproject.segmentrouting.mcast.McastRoleStoreKey) MacVlanNextObjectiveStoreKey(org.onosproject.segmentrouting.storekey.MacVlanNextObjectiveStoreKey) ICMP6(org.onlab.packet.ICMP6) InterfaceConfig(org.onosproject.net.config.basics.InterfaceConfig) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) SegmentRoutingDeviceConfig(org.onosproject.segmentrouting.config.SegmentRoutingDeviceConfig) CompletableFuture(java.util.concurrent.CompletableFuture) Multimap(com.google.common.collect.Multimap) XConnectStoreKey(org.onosproject.segmentrouting.storekey.XConnectStoreKey) ACTIVE_PROBING_DEFAULT(org.onosproject.segmentrouting.OsgiPropertyConstants.ACTIVE_PROBING_DEFAULT) FlowObjectiveService(org.onosproject.net.flowobjective.FlowObjectiveService) HashSet(java.util.HashSet) L2TunnelHandler(org.onosproject.segmentrouting.pwaas.L2TunnelHandler) DefaultGroupHandler(org.onosproject.segmentrouting.grouphandler.DefaultGroupHandler) PROP_SYMMETRIC_PROBING(org.onosproject.segmentrouting.OsgiPropertyConstants.PROP_SYMMETRIC_PROBING) PhasedRecoveryService(org.onosproject.segmentrouting.phasedrecovery.api.PhasedRecoveryService) HostEvent(org.onosproject.net.host.HostEvent) HostProbingService(org.onosproject.net.host.HostProbingService) Activate(org.osgi.service.component.annotations.Activate) EventuallyConsistentMap(org.onosproject.store.service.EventuallyConsistentMap) HostId(org.onosproject.net.HostId) SINGLE_HOMED_DOWN_DEFAULT(org.onosproject.segmentrouting.OsgiPropertyConstants.SINGLE_HOMED_DOWN_DEFAULT) ExecutorService(java.util.concurrent.ExecutorService) IpAddress(org.onlab.packet.IpAddress) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ClusterEventListener(org.onosproject.cluster.ClusterEventListener) DefaultL2Tunnel(org.onosproject.segmentrouting.pwaas.DefaultL2Tunnel) Logger(org.slf4j.Logger) Maps(com.google.common.collect.Maps) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) TimeUnit(java.util.concurrent.TimeUnit) DeviceAdminService(org.onosproject.net.device.DeviceAdminService) L2TunnelPolicy(org.onosproject.segmentrouting.pwaas.L2TunnelPolicy) DestinationSet(org.onosproject.segmentrouting.grouphandler.DestinationSet) Modified(org.osgi.service.component.annotations.Modified) MastershipListener(org.onosproject.mastership.MastershipListener) PROP_SINGLE_HOMED_DOWN(org.onosproject.segmentrouting.OsgiPropertyConstants.PROP_SINGLE_HOMED_DOWN) Reference(org.osgi.service.component.annotations.Reference) Collections(java.util.Collections) TopologyListener(org.onosproject.net.topology.TopologyListener) ConnectPoint(org.onosproject.net.ConnectPoint) VlanId(org.onlab.packet.VlanId) Modified(org.osgi.service.component.annotations.Modified)

Example 10 with VlanId

use of org.onlab.packet.VlanId in project trellis-control by opennetworkinglab.

the class SegmentRoutingManager method updateInterface.

private void updateInterface(InterfaceConfig conf, InterfaceConfig prevConf) {
    try {
        Set<Interface> intfs = conf.getInterfaces();
        Set<Interface> prevIntfs = prevConf.getInterfaces();
        // Now we only handle one interface config at each port.
        if (intfs.size() != 1 || prevIntfs.size() != 1) {
            log.warn("Interface update aborted - one at a time is allowed, " + "but {} / {}(prev) received.", intfs.size(), prevIntfs.size());
            return;
        }
        // The system is in an incoherent state, abort
        if (defaultRoutingHandler == null) {
            log.warn("Interface update aborted, defaultRoutingHandler is null");
            return;
        }
        Interface intf = intfs.stream().findFirst().get();
        Interface prevIntf = prevIntfs.stream().findFirst().get();
        DeviceId deviceId = intf.connectPoint().deviceId();
        PortNumber portNum = intf.connectPoint().port();
        if (!shouldProgram(deviceId)) {
            log.debug("Not leading the programming of {} skip update interface {}", deviceId, intf);
            return;
        }
        // We need to do nexthop update al least one time for each
        // interface config change. There is no difference when it is done;
        boolean updateNexthop = false;
        removeSubnetConfig(prevIntf.connectPoint(), Sets.difference(new HashSet<>(prevIntf.ipAddressesList()), new HashSet<>(intf.ipAddressesList())));
        if (!prevIntf.vlanNative().equals(VlanId.NONE) && !prevIntf.vlanNative().equals(intf.vlanUntagged()) && !prevIntf.vlanNative().equals(intf.vlanNative())) {
            if (intf.vlanTagged().contains(prevIntf.vlanNative())) {
                // Update filtering objective and L2IG group bucket
                updatePortVlanTreatment(deviceId, portNum, prevIntf.vlanNative(), false);
            } else {
                // RemoveVlanNative - affected scenarios:
                // (T,N)->U; (T*,N)->U; (T,N)->(T,N); (T,N)->T
                updateVlanConfigInternal(deviceId, portNum, prevIntf.vlanNative(), true, false);
                // Update the nexthops of the indirect routes
                updateNexthop = true;
                routeEventExecutor.execute(() -> routeHandler.processIntfVlanUpdatedEvent(deviceId, portNum));
            }
        }
        if (!prevIntf.vlanUntagged().equals(VlanId.NONE) && !prevIntf.vlanUntagged().equals(intf.vlanUntagged()) && !prevIntf.vlanUntagged().equals(intf.vlanNative())) {
            if (intf.vlanTagged().contains(prevIntf.vlanUntagged())) {
                // Update filtering objective and L2IG group bucket - affected scenarios:
                // U->(T*,N); U->T*
                updatePortVlanTreatment(deviceId, portNum, prevIntf.vlanUntagged(), false);
                if (!updateNexthop) {
                    updateNexthop = true;
                    routeEventExecutor.execute(() -> routeHandler.processIntfVlanUpdatedEvent(deviceId, portNum));
                }
            } else {
                // RemoveVlanUntagged - affected scenarios:
                // U->U; U->(T,N); U->T
                updateVlanConfigInternal(deviceId, portNum, prevIntf.vlanUntagged(), true, false);
                if (!updateNexthop) {
                    updateNexthop = true;
                    routeEventExecutor.execute(() -> routeHandler.processIntfVlanUpdatedEvent(deviceId, portNum));
                }
            }
        }
        if (!prevIntf.vlanTagged().isEmpty() && !intf.vlanTagged().equals(prevIntf.vlanTagged())) {
            // RemoveVlanTagged - affected scenarios:
            // T->U; T->T; (T,N*)->U; (T,N)->(T,N)
            Sets.difference(prevIntf.vlanTagged(), intf.vlanTagged()).stream().filter(i -> !intf.vlanUntagged().equals(i)).filter(i -> !intf.vlanNative().equals(i)).forEach(vlanId -> updateVlanConfigInternal(deviceId, portNum, vlanId, false, false));
        }
        if (!intf.vlanNative().equals(VlanId.NONE) && !prevIntf.vlanNative().equals(intf.vlanNative()) && !prevIntf.vlanUntagged().equals(intf.vlanNative())) {
            if (prevIntf.vlanTagged().contains(intf.vlanNative())) {
                // Update filtering objective and L2IG group bucket
                updatePortVlanTreatment(deviceId, portNum, intf.vlanNative(), true);
            } else {
                // AddVlanNative - affected scenarios
                // U->(T,N); U->(T*,N); T->(T,N)
                updateVlanConfigInternal(deviceId, portNum, intf.vlanNative(), true, true);
                if (!updateNexthop) {
                    updateNexthop = true;
                    routeEventExecutor.execute(() -> routeHandler.processIntfVlanUpdatedEvent(deviceId, portNum));
                }
            }
        }
        if (!intf.vlanTagged().isEmpty() && !intf.vlanTagged().equals(prevIntf.vlanTagged())) {
            // AddVlanTagged - affected scenarios
            // U->T; U->(T,N*); T->T; (T,N)->(T,N)
            Sets.difference(intf.vlanTagged(), prevIntf.vlanTagged()).stream().filter(i -> !prevIntf.vlanUntagged().equals(i)).filter(i -> !prevIntf.vlanNative().equals(i)).forEach(vlanId -> updateVlanConfigInternal(deviceId, portNum, vlanId, false, true));
        }
        if (!intf.vlanUntagged().equals(VlanId.NONE) && !prevIntf.vlanUntagged().equals(intf.vlanUntagged()) && !prevIntf.vlanNative().equals(intf.vlanUntagged())) {
            if (prevIntf.vlanTagged().contains(intf.vlanUntagged())) {
                // Update filtering objective and L2IG group bucket - affected scenarios
                // (T*,N)->U; T*->U
                updatePortVlanTreatment(deviceId, portNum, intf.vlanUntagged(), true);
                if (!updateNexthop) {
                    routeEventExecutor.execute(() -> routeHandler.processIntfVlanUpdatedEvent(deviceId, portNum));
                }
            } else {
                // AddVlanUntagged - affected scenarios
                // U->U; (T,N)->U; T->U
                updateVlanConfigInternal(deviceId, portNum, intf.vlanUntagged(), true, true);
                if (!updateNexthop) {
                    routeEventExecutor.execute(() -> routeHandler.processIntfVlanUpdatedEvent(deviceId, portNum));
                }
            }
        }
        addSubnetConfig(prevIntf.connectPoint(), Sets.difference(new HashSet<>(intf.ipAddressesList()), new HashSet<>(prevIntf.ipAddressesList())));
    } catch (ConfigException e) {
        log.error("Error in configuration");
    }
}
Also used : DeviceConfigNotFoundException(org.onosproject.segmentrouting.config.DeviceConfigNotFoundException) NetworkConfigRegistry(org.onosproject.net.config.NetworkConfigRegistry) ROUTE_SIMPLIFICATION_DEFAULT(org.onosproject.segmentrouting.OsgiPropertyConstants.ROUTE_SIMPLIFICATION_DEFAULT) McastStoreKey(org.onosproject.segmentrouting.mcast.McastStoreKey) PROP_ACTIVE_PROBING(org.onosproject.segmentrouting.OsgiPropertyConstants.PROP_ACTIVE_PROBING) PortNumber(org.onosproject.net.PortNumber) DeviceService(org.onosproject.net.device.DeviceService) TYPE_ARP(org.onlab.packet.Ethernet.TYPE_ARP) DefaultL2TunnelDescription(org.onosproject.segmentrouting.pwaas.DefaultL2TunnelDescription) ROUTE_DOUBLE_TAGGED_HOSTS_DEFAULT(org.onosproject.segmentrouting.OsgiPropertyConstants.ROUTE_DOUBLE_TAGGED_HOSTS_DEFAULT) NeighbourResolutionService(org.onosproject.net.neighbour.NeighbourResolutionService) L2TunnelDescription(org.onosproject.segmentrouting.pwaas.L2TunnelDescription) ConnectPoint(org.onosproject.net.ConnectPoint) StorageService(org.onosproject.store.service.StorageService) SubjectFactories(org.onosproject.net.config.basics.SubjectFactories) McastEvent(org.onosproject.mcast.api.McastEvent) Port(org.onosproject.net.Port) Map(java.util.Map) ApplicationId(org.onosproject.core.ApplicationId) NextObjective(org.onosproject.net.flowobjective.NextObjective) MulticastRouteService(org.onosproject.mcast.api.MulticastRouteService) KryoNamespaces(org.onosproject.store.serializers.KryoNamespaces) MastershipService(org.onosproject.mastership.MastershipService) SYMMETRIC_PROBING_DEFAULT(org.onosproject.segmentrouting.OsgiPropertyConstants.SYMMETRIC_PROBING_DEFAULT) Deactivate(org.osgi.service.component.annotations.Deactivate) Set(java.util.Set) PacketService(org.onosproject.net.packet.PacketService) WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) ReferencePolicy(org.osgi.service.component.annotations.ReferencePolicy) DEFAULT_INTERNAL_VLAN_DEFAULT(org.onosproject.segmentrouting.OsgiPropertyConstants.DEFAULT_INTERNAL_VLAN_DEFAULT) Executors(java.util.concurrent.Executors) RouteListener(org.onosproject.routeservice.RouteListener) ConfigFactory(org.onosproject.net.config.ConfigFactory) LinkListener(org.onosproject.net.link.LinkListener) DeviceEvent(org.onosproject.net.device.DeviceEvent) DeviceId(org.onosproject.net.DeviceId) ConfigException(org.onosproject.net.config.ConfigException) Dictionary(java.util.Dictionary) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Tools(org.onlab.util.Tools) Host(org.onosproject.net.Host) LinkEvent(org.onosproject.net.link.LinkEvent) NetworkConfigEvent(org.onosproject.net.config.NetworkConfigEvent) VlanNextObjectiveStoreKey(org.onosproject.segmentrouting.storekey.VlanNextObjectiveStoreKey) ComponentContext(org.osgi.service.component.ComponentContext) RouteEvent(org.onosproject.routeservice.RouteEvent) KryoNamespace(org.onlab.util.KryoNamespace) HostListener(org.onosproject.net.host.HostListener) InterfaceService(org.onosproject.net.intf.InterfaceService) HostService(org.onosproject.net.host.HostService) ArrayList(java.util.ArrayList) McastListener(org.onosproject.mcast.api.McastListener) CONFIG_UNREGISTERED(org.onosproject.net.config.NetworkConfigEvent.Type.CONFIG_UNREGISTERED) RESPOND_TO_UNKNOWN_HOSTS_DEFAULT(org.onosproject.segmentrouting.OsgiPropertyConstants.RESPOND_TO_UNKNOWN_HOSTS_DEFAULT) MastershipEvent(org.onosproject.mastership.MastershipEvent) SegmentRoutingAppConfig(org.onosproject.segmentrouting.config.SegmentRoutingAppConfig) Component(org.osgi.service.component.annotations.Component) Lists(com.google.common.collect.Lists) TrafficSelector(org.onosproject.net.flow.TrafficSelector) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) NextNeighbors(org.onosproject.segmentrouting.grouphandler.NextNeighbors) DefaultL2TunnelHandler(org.onosproject.segmentrouting.pwaas.DefaultL2TunnelHandler) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) DeviceListener(org.onosproject.net.device.DeviceListener) VlanId(org.onlab.packet.VlanId) PW_TRANSPORT_VLAN_DEFAULT(org.onosproject.segmentrouting.OsgiPropertyConstants.PW_TRANSPORT_VLAN_DEFAULT) IPv6(org.onlab.packet.IPv6) ExecutionException(java.util.concurrent.ExecutionException) IPv4(org.onlab.packet.IPv4) CONFIG_REGISTERED(org.onosproject.net.config.NetworkConfigEvent.Type.CONFIG_REGISTERED) DestinationSetNextObjectiveStoreKey(org.onosproject.segmentrouting.storekey.DestinationSetNextObjectiveStoreKey) MacAddress(org.onlab.packet.MacAddress) PROP_PW_TRANSPORT_VLAN(org.onosproject.segmentrouting.OsgiPropertyConstants.PROP_PW_TRANSPORT_VLAN) ResolvedRoute(org.onosproject.routeservice.ResolvedRoute) PROP_ROUTE_DOUBLE_TAGGED_HOSTS(org.onosproject.segmentrouting.OsgiPropertyConstants.PROP_ROUTE_DOUBLE_TAGGED_HOSTS) NetworkConfigListener(org.onosproject.net.config.NetworkConfigListener) PortNextObjectiveStoreKey(org.onosproject.segmentrouting.storekey.PortNextObjectiveStoreKey) XconnectService(org.onosproject.segmentrouting.xconnect.api.XconnectService) ScheduledFuture(java.util.concurrent.ScheduledFuture) Interface(org.onosproject.net.intf.Interface) CoreService(org.onosproject.core.CoreService) L2Tunnel(org.onosproject.segmentrouting.pwaas.L2Tunnel) LoggerFactory(org.slf4j.LoggerFactory) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) McastConfig(org.onosproject.net.config.basics.McastConfig) TopologyService(org.onosproject.net.topology.TopologyService) EventuallyConsistentMapBuilder(org.onosproject.store.service.EventuallyConsistentMapBuilder) Link(org.onosproject.net.Link) Ethernet(org.onlab.packet.Ethernet) HashMultimap(com.google.common.collect.HashMultimap) DefaultL2TunnelPolicy(org.onosproject.segmentrouting.pwaas.DefaultL2TunnelPolicy) McastFilteringObjStoreKey(org.onosproject.segmentrouting.mcast.McastFilteringObjStoreKey) PROP_ROUTE_SIMPLIFICATION(org.onosproject.segmentrouting.OsgiPropertyConstants.PROP_ROUTE_SIMPLIFICATION) WorkPartitionService(org.onosproject.net.intent.WorkPartitionService) PROP_DEFAULT_INTERNAL_VLAN(org.onosproject.segmentrouting.OsgiPropertyConstants.PROP_DEFAULT_INTERNAL_VLAN) Event(org.onosproject.event.Event) NodeId(org.onosproject.cluster.NodeId) RouteService(org.onosproject.routeservice.RouteService) McastHandler(org.onosproject.segmentrouting.mcast.McastHandler) TopologyEvent(org.onosproject.net.topology.TopologyEvent) ClusterEvent(org.onosproject.cluster.ClusterEvent) ImmutableMap(com.google.common.collect.ImmutableMap) Device(org.onosproject.net.Device) PacketProcessor(org.onosproject.net.packet.PacketProcessor) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Instant(java.time.Instant) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) Preconditions.checkState(com.google.common.base.Preconditions.checkState) PROP_RESPOND_TO_UNKNOWN_HOSTS(org.onosproject.segmentrouting.OsgiPropertyConstants.PROP_RESPOND_TO_UNKNOWN_HOSTS) List(java.util.List) InboundPacket(org.onosproject.net.packet.InboundPacket) PacketContext(org.onosproject.net.packet.PacketContext) LinkService(org.onosproject.net.link.LinkService) Optional(java.util.Optional) ClusterService(org.onosproject.cluster.ClusterService) IpPrefix(org.onlab.packet.IpPrefix) McastRole(org.onosproject.segmentrouting.mcast.McastRole) McastRoleStoreKey(org.onosproject.segmentrouting.mcast.McastRoleStoreKey) MacVlanNextObjectiveStoreKey(org.onosproject.segmentrouting.storekey.MacVlanNextObjectiveStoreKey) ICMP6(org.onlab.packet.ICMP6) InterfaceConfig(org.onosproject.net.config.basics.InterfaceConfig) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) SegmentRoutingDeviceConfig(org.onosproject.segmentrouting.config.SegmentRoutingDeviceConfig) CompletableFuture(java.util.concurrent.CompletableFuture) Multimap(com.google.common.collect.Multimap) XConnectStoreKey(org.onosproject.segmentrouting.storekey.XConnectStoreKey) ACTIVE_PROBING_DEFAULT(org.onosproject.segmentrouting.OsgiPropertyConstants.ACTIVE_PROBING_DEFAULT) FlowObjectiveService(org.onosproject.net.flowobjective.FlowObjectiveService) HashSet(java.util.HashSet) L2TunnelHandler(org.onosproject.segmentrouting.pwaas.L2TunnelHandler) DefaultGroupHandler(org.onosproject.segmentrouting.grouphandler.DefaultGroupHandler) PROP_SYMMETRIC_PROBING(org.onosproject.segmentrouting.OsgiPropertyConstants.PROP_SYMMETRIC_PROBING) PhasedRecoveryService(org.onosproject.segmentrouting.phasedrecovery.api.PhasedRecoveryService) HostEvent(org.onosproject.net.host.HostEvent) HostProbingService(org.onosproject.net.host.HostProbingService) Activate(org.osgi.service.component.annotations.Activate) EventuallyConsistentMap(org.onosproject.store.service.EventuallyConsistentMap) HostId(org.onosproject.net.HostId) SINGLE_HOMED_DOWN_DEFAULT(org.onosproject.segmentrouting.OsgiPropertyConstants.SINGLE_HOMED_DOWN_DEFAULT) ExecutorService(java.util.concurrent.ExecutorService) IpAddress(org.onlab.packet.IpAddress) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ClusterEventListener(org.onosproject.cluster.ClusterEventListener) DefaultL2Tunnel(org.onosproject.segmentrouting.pwaas.DefaultL2Tunnel) Logger(org.slf4j.Logger) Maps(com.google.common.collect.Maps) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) TimeUnit(java.util.concurrent.TimeUnit) DeviceAdminService(org.onosproject.net.device.DeviceAdminService) L2TunnelPolicy(org.onosproject.segmentrouting.pwaas.L2TunnelPolicy) DestinationSet(org.onosproject.segmentrouting.grouphandler.DestinationSet) Modified(org.osgi.service.component.annotations.Modified) MastershipListener(org.onosproject.mastership.MastershipListener) PROP_SINGLE_HOMED_DOWN(org.onosproject.segmentrouting.OsgiPropertyConstants.PROP_SINGLE_HOMED_DOWN) Reference(org.osgi.service.component.annotations.Reference) Collections(java.util.Collections) TopologyListener(org.onosproject.net.topology.TopologyListener) DeviceId(org.onosproject.net.DeviceId) ConfigException(org.onosproject.net.config.ConfigException) PortNumber(org.onosproject.net.PortNumber) Interface(org.onosproject.net.intf.Interface) HashSet(java.util.HashSet)

Aggregations

VlanId (org.onlab.packet.VlanId)202 DeviceId (org.onosproject.net.DeviceId)86 MacAddress (org.onlab.packet.MacAddress)82 List (java.util.List)76 ConnectPoint (org.onosproject.net.ConnectPoint)76 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)72 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)68 Collectors (java.util.stream.Collectors)65 Test (org.junit.Test)59 Ethernet (org.onlab.packet.Ethernet)58 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)56 Set (java.util.Set)55 Collection (java.util.Collection)54 Collections (java.util.Collections)53 TrafficSelector (org.onosproject.net.flow.TrafficSelector)53 IpAddress (org.onlab.packet.IpAddress)51 CoreService (org.onosproject.core.CoreService)51 ImmutableSet (com.google.common.collect.ImmutableSet)44 FlowRule (org.onosproject.net.flow.FlowRule)43 MplsLabel (org.onlab.packet.MplsLabel)42