Search in sources :

Example 41 with TrafficSelector

use of org.onosproject.net.flow.TrafficSelector in project onos by opennetworkinglab.

the class OplinkOpticalUtility method fromFlowRule.

/**
 * Transforms a flow FlowRule object to an OplinkCrossConnect object.
 * @param behaviour the parent driver handler
 * @param rule FlowRule object
 * @return cross connect object
 */
public static OplinkCrossConnect fromFlowRule(HandlerBehaviour behaviour, FlowRule rule) {
    // TrafficSelector
    Set<Criterion> criterions = rule.selector().criteria();
    int channel = criterions.stream().filter(c -> c instanceof OchSignalCriterion).map(c -> ((OchSignalCriterion) c).lambda().spacingMultiplier()).findAny().orElse(null);
    PortNumber inPort = criterions.stream().filter(c -> c instanceof PortCriterion).map(c -> ((PortCriterion) c).port()).findAny().orElse(null);
    // TrafficTreatment
    List<Instruction> instructions = rule.treatment().immediate();
    PortNumber outPort = instructions.stream().filter(c -> c instanceof Instructions.OutputInstruction).map(c -> ((Instructions.OutputInstruction) c).port()).findAny().orElse(null);
    int attenuation = instructions.stream().filter(c -> c instanceof Instructions.ExtensionInstructionWrapper).map(c -> ((Instructions.ExtensionInstructionWrapper) c).extensionInstruction()).filter(c -> c instanceof OplinkAttenuation).map(c -> ((OplinkAttenuation) c).getAttenuation()).findAny().orElse(DEFAULT_ATT);
    return new OplinkCrossConnect(inPort, outPort, channel, attenuation);
}
Also used : GridType(org.onosproject.net.GridType) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) CoreService(org.onosproject.core.CoreService) PortNumber(org.onosproject.net.PortNumber) FlowEntry(org.onosproject.net.flow.FlowEntry) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) HandlerBehaviour(org.onosproject.net.driver.HandlerBehaviour) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) OplinkAttenuation(org.onosproject.driver.extensions.OplinkAttenuation) OchSignalCriterion(org.onosproject.net.flow.criteria.OchSignalCriterion) Frequency(org.onlab.util.Frequency) FlowRuleService(org.onosproject.net.flow.FlowRuleService) TrafficSelector(org.onosproject.net.flow.TrafficSelector) Criteria(org.onosproject.net.flow.criteria.Criteria) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) Criterion(org.onosproject.net.flow.criteria.Criterion) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) OchSignalType(org.onosproject.net.OchSignalType) Instructions(org.onosproject.net.flow.instructions.Instructions) Instruction(org.onosproject.net.flow.instructions.Instruction) Range(com.google.common.collect.Range) Set(java.util.Set) Lambda(org.onosproject.net.Lambda) List(java.util.List) FlowRule(org.onosproject.net.flow.FlowRule) ChannelSpacing(org.onosproject.net.ChannelSpacing) Instructions(org.onosproject.net.flow.instructions.Instructions) OplinkAttenuation(org.onosproject.driver.extensions.OplinkAttenuation) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) Instruction(org.onosproject.net.flow.instructions.Instruction) OchSignalCriterion(org.onosproject.net.flow.criteria.OchSignalCriterion) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) OchSignalCriterion(org.onosproject.net.flow.criteria.OchSignalCriterion) Criterion(org.onosproject.net.flow.criteria.Criterion) PortNumber(org.onosproject.net.PortNumber)

Example 42 with TrafficSelector

use of org.onosproject.net.flow.TrafficSelector in project onos by opennetworkinglab.

the class DhcpRelayManagerTest method testRemoveIgnoreVlan.

/**
 * "IgnoreVlan" policy should be removed when the config removed.
 */
@Test
public void testRemoveIgnoreVlan() {
    v4Handler.ignoredVlans.put(DEV_1_ID, IGNORED_VLAN);
    v4Handler.ignoredVlans.put(DEV_2_ID, IGNORED_VLAN);
    v6Handler.ignoredVlans.put(DEV_1_ID, IGNORED_VLAN);
    v6Handler.ignoredVlans.put(DEV_2_ID, IGNORED_VLAN);
    IgnoreDhcpConfig config = new IgnoreDhcpConfig();
    Capture<Objective> capturedFromDev1 = newCapture(CaptureType.ALL);
    flowObjectiveService.apply(eq(DEV_1_ID), capture(capturedFromDev1));
    expectLastCall().times(DHCP_SELECTORS.size());
    Capture<Objective> capturedFromDev2 = newCapture(CaptureType.ALL);
    flowObjectiveService.apply(eq(DEV_2_ID), capture(capturedFromDev2));
    expectLastCall().times(DHCP_SELECTORS.size());
    replay(flowObjectiveService);
    manager.removeConfig(config);
    verify(flowObjectiveService);
    List<Objective> objectivesFromDev1 = capturedFromDev1.getValues();
    List<Objective> objectivesFromDev2 = capturedFromDev2.getValues();
    assertTrue(objectivesFromDev1.containsAll(objectivesFromDev2));
    assertTrue(objectivesFromDev2.containsAll(objectivesFromDev1));
    for (int index = 0; index < objectivesFromDev1.size(); index++) {
        TrafficSelector selector = DefaultTrafficSelector.builder(DHCP_SELECTORS.get(index)).matchVlanId(IGNORED_VLAN).build();
        ForwardingObjective fwd = (ForwardingObjective) objectivesFromDev1.get(index);
        assertEquals(selector, fwd.selector());
        assertEquals(DefaultTrafficTreatment.emptyTreatment(), fwd.treatment());
        assertEquals(IGNORE_CONTROL_PRIORITY, fwd.priority());
        assertEquals(ForwardingObjective.Flag.VERSATILE, fwd.flag());
        assertEquals(Objective.Operation.REMOVE, fwd.op());
        fwd.context().ifPresent(ctx -> {
            ctx.onSuccess(fwd);
        });
    }
    objectivesFromDev2.forEach(obj -> obj.context().ifPresent(ctx -> ctx.onSuccess(obj)));
    assertEquals(0, v4Handler.ignoredVlans.size());
    assertEquals(0, v6Handler.ignoredVlans.size());
}
Also used : NetworkConfigRegistry(org.onosproject.net.config.NetworkConfigRegistry) Dhcp6IaPdOption(org.onlab.packet.dhcp.Dhcp6IaPdOption) DeviceService(org.onosproject.net.device.DeviceService) ARP(org.onlab.packet.ARP) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) InterfaceServiceAdapter(org.onosproject.net.intf.InterfaceServiceAdapter) Pair(org.apache.commons.lang3.tuple.Pair) IgnoreDhcpConfig(org.onosproject.dhcprelay.config.IgnoreDhcpConfig) Map(java.util.Map) ApplicationId(org.onosproject.core.ApplicationId) JsonNode(com.fasterxml.jackson.databind.JsonNode) DhcpRelayCounters(org.onosproject.dhcprelay.store.DhcpRelayCounters) Dhcp6IaNaOption(org.onlab.packet.dhcp.Dhcp6IaNaOption) Ip6Address(org.onlab.packet.Ip6Address) DhcpRelayStore(org.onosproject.dhcprelay.store.DhcpRelayStore) Ip4Address(org.onlab.packet.Ip4Address) Set(java.util.Set) StoreDelegate(org.onosproject.store.StoreDelegate) DeviceEvent(org.onosproject.net.device.DeviceEvent) DhcpServerConfig(org.onosproject.dhcprelay.config.DhcpServerConfig) DeviceId(org.onosproject.net.DeviceId) Dictionary(java.util.Dictionary) Pipeliner(org.onosproject.net.behaviour.Pipeliner) Host(org.onosproject.net.Host) ComponentContext(org.osgi.service.component.ComponentContext) HostService(org.onosproject.net.host.HostService) ArrayList(java.util.ArrayList) Dhcp6InterfaceIdOption(org.onlab.packet.dhcp.Dhcp6InterfaceIdOption) DhcpRelayStoreEvent(org.onosproject.dhcprelay.store.DhcpRelayStoreEvent) Lists(com.google.common.collect.Lists) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DeserializationException(org.onlab.packet.DeserializationException) CircuitId(org.onlab.packet.dhcp.CircuitId) DhcpRelayAgentOption(org.onlab.packet.dhcp.DhcpRelayAgentOption) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) Before(org.junit.Before) Charsets(org.apache.commons.io.Charsets) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) Capture(org.easymock.Capture) Resources(com.google.common.io.Resources) VlanId(org.onlab.packet.VlanId) Test(org.junit.Test) IOException(java.io.IOException) EasyMock(org.easymock.EasyMock) Dhcp6IaAddressOption(org.onlab.packet.dhcp.Dhcp6IaAddressOption) IPv6(org.onlab.packet.IPv6) IPv4(org.onlab.packet.IPv4) DHCP6(org.onlab.packet.DHCP6) DhcpRecord(org.onosproject.dhcprelay.store.DhcpRecord) Objective(org.onosproject.net.flowobjective.Objective) MacAddress(org.onlab.packet.MacAddress) Dhcp6Duid(org.onlab.packet.dhcp.Dhcp6Duid) DHCP(org.onlab.packet.DHCP) Assert(org.junit.Assert) DefaultDhcpRelayConfig(org.onosproject.dhcprelay.config.DefaultDhcpRelayConfig) Route(org.onosproject.routeservice.Route) HostLocation(org.onosproject.net.HostLocation) Interface(org.onosproject.net.intf.Interface) TestApplicationId(org.onosproject.TestApplicationId) CoreService(org.onosproject.core.CoreService) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) Dhcp6ClientIdOption(org.onlab.packet.dhcp.Dhcp6ClientIdOption) ByteBuffer(java.nio.ByteBuffer) Ethernet(org.onlab.packet.Ethernet) HostProviderService(org.onosproject.net.host.HostProviderService) Dhcp6IaPrefixOption(org.onlab.packet.dhcp.Dhcp6IaPrefixOption) After(org.junit.After) ImmutableSet(com.google.common.collect.ImmutableSet) Device(org.onosproject.net.Device) Collection(java.util.Collection) PacketProcessor(org.onosproject.net.packet.PacketProcessor) Streams(com.google.common.collect.Streams) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) TestTools.assertAfter(org.onlab.junit.TestTools.assertAfter) IndirectDhcpRelayConfig(org.onosproject.dhcprelay.config.IndirectDhcpRelayConfig) List(java.util.List) InboundPacket(org.onosproject.net.packet.InboundPacket) PacketContext(org.onosproject.net.packet.PacketContext) Optional(java.util.Optional) HostDescription(org.onosproject.net.host.HostDescription) IpPrefix(org.onlab.packet.IpPrefix) PacketContextAdapter(org.onosproject.net.packet.PacketContextAdapter) RouteStoreAdapter(org.onosproject.routeservice.RouteStoreAdapter) Dhcp6RelayOption(org.onlab.packet.dhcp.Dhcp6RelayOption) DhcpRelayCountersStore(org.onosproject.dhcprelay.store.DhcpRelayCountersStore) FlowObjectiveService(org.onosproject.net.flowobjective.FlowObjectiveService) DefaultHost(org.onosproject.net.DefaultHost) ImmutableList(com.google.common.collect.ImmutableList) OutboundPacket(org.onosproject.net.packet.OutboundPacket) PacketServiceAdapter(org.onosproject.net.packet.PacketServiceAdapter) HostId(org.onosproject.net.HostId) DHCP_RELAY_APP(org.onosproject.dhcprelay.DhcpRelayManager.DHCP_RELAY_APP) IpAddress(org.onlab.packet.IpAddress) DefaultInboundPacket(org.onosproject.net.packet.DefaultInboundPacket) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Dhcp6Option(org.onlab.packet.dhcp.Dhcp6Option) Maps(com.google.common.collect.Maps) UDP(org.onlab.packet.UDP) DhcpOption(org.onlab.packet.dhcp.DhcpOption) CaptureType(org.easymock.CaptureType) PacketPriority(org.onosproject.net.packet.PacketPriority) IgnoreDhcpConfig(org.onosproject.dhcprelay.config.IgnoreDhcpConfig) Objective(org.onosproject.net.flowobjective.Objective) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) ConnectPoint(org.onosproject.net.ConnectPoint) Test(org.junit.Test)

Example 43 with TrafficSelector

use of org.onosproject.net.flow.TrafficSelector in project onos by opennetworkinglab.

the class DhcpRelayManagerTest method testIgnoreVlan.

/**
 * Ignores specific vlans from specific devices if config.
 *
 * @throws Exception the exception from this test
 */
@Test
public void testIgnoreVlan() throws Exception {
    ObjectMapper om = new ObjectMapper();
    JsonNode json = om.readTree(Resources.getResource(CONFIG_FILE_PATH));
    IgnoreDhcpConfig config = new IgnoreDhcpConfig();
    json = json.path("apps").path(DHCP_RELAY_APP).path(IgnoreDhcpConfig.KEY);
    config.init(APP_ID, IgnoreDhcpConfig.KEY, json, om, null);
    Capture<Objective> capturedFromDev1 = newCapture(CaptureType.ALL);
    flowObjectiveService.apply(eq(DEV_1_ID), capture(capturedFromDev1));
    expectLastCall().times(DHCP_SELECTORS.size());
    Capture<Objective> capturedFromDev2 = newCapture(CaptureType.ALL);
    flowObjectiveService.apply(eq(DEV_2_ID), capture(capturedFromDev2));
    expectLastCall().times(DHCP_SELECTORS.size());
    replay(flowObjectiveService);
    manager.updateConfig(config);
    verify(flowObjectiveService);
    List<Objective> objectivesFromDev1 = capturedFromDev1.getValues();
    List<Objective> objectivesFromDev2 = capturedFromDev2.getValues();
    assertTrue(objectivesFromDev1.containsAll(objectivesFromDev2));
    assertTrue(objectivesFromDev2.containsAll(objectivesFromDev1));
    for (int index = 0; index < objectivesFromDev1.size(); index++) {
        TrafficSelector selector = DefaultTrafficSelector.builder(DHCP_SELECTORS.get(index)).matchVlanId(IGNORED_VLAN).build();
        ForwardingObjective fwd = (ForwardingObjective) objectivesFromDev1.get(index);
        assertEquals(selector, fwd.selector());
        assertEquals(DefaultTrafficTreatment.emptyTreatment(), fwd.treatment());
        assertEquals(IGNORE_CONTROL_PRIORITY, fwd.priority());
        assertEquals(ForwardingObjective.Flag.VERSATILE, fwd.flag());
        assertEquals(Objective.Operation.ADD, fwd.op());
        fwd.context().ifPresent(ctx -> {
            ctx.onSuccess(fwd);
        });
    }
    objectivesFromDev2.forEach(obj -> obj.context().ifPresent(ctx -> ctx.onSuccess(obj)));
    assertEquals(2, v4Handler.ignoredVlans.size());
    assertEquals(2, v6Handler.ignoredVlans.size());
}
Also used : NetworkConfigRegistry(org.onosproject.net.config.NetworkConfigRegistry) Dhcp6IaPdOption(org.onlab.packet.dhcp.Dhcp6IaPdOption) DeviceService(org.onosproject.net.device.DeviceService) ARP(org.onlab.packet.ARP) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) InterfaceServiceAdapter(org.onosproject.net.intf.InterfaceServiceAdapter) Pair(org.apache.commons.lang3.tuple.Pair) IgnoreDhcpConfig(org.onosproject.dhcprelay.config.IgnoreDhcpConfig) Map(java.util.Map) ApplicationId(org.onosproject.core.ApplicationId) JsonNode(com.fasterxml.jackson.databind.JsonNode) DhcpRelayCounters(org.onosproject.dhcprelay.store.DhcpRelayCounters) Dhcp6IaNaOption(org.onlab.packet.dhcp.Dhcp6IaNaOption) Ip6Address(org.onlab.packet.Ip6Address) DhcpRelayStore(org.onosproject.dhcprelay.store.DhcpRelayStore) Ip4Address(org.onlab.packet.Ip4Address) Set(java.util.Set) StoreDelegate(org.onosproject.store.StoreDelegate) DeviceEvent(org.onosproject.net.device.DeviceEvent) DhcpServerConfig(org.onosproject.dhcprelay.config.DhcpServerConfig) DeviceId(org.onosproject.net.DeviceId) Dictionary(java.util.Dictionary) Pipeliner(org.onosproject.net.behaviour.Pipeliner) Host(org.onosproject.net.Host) ComponentContext(org.osgi.service.component.ComponentContext) HostService(org.onosproject.net.host.HostService) ArrayList(java.util.ArrayList) Dhcp6InterfaceIdOption(org.onlab.packet.dhcp.Dhcp6InterfaceIdOption) DhcpRelayStoreEvent(org.onosproject.dhcprelay.store.DhcpRelayStoreEvent) Lists(com.google.common.collect.Lists) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DeserializationException(org.onlab.packet.DeserializationException) CircuitId(org.onlab.packet.dhcp.CircuitId) DhcpRelayAgentOption(org.onlab.packet.dhcp.DhcpRelayAgentOption) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) Before(org.junit.Before) Charsets(org.apache.commons.io.Charsets) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) Capture(org.easymock.Capture) Resources(com.google.common.io.Resources) VlanId(org.onlab.packet.VlanId) Test(org.junit.Test) IOException(java.io.IOException) EasyMock(org.easymock.EasyMock) Dhcp6IaAddressOption(org.onlab.packet.dhcp.Dhcp6IaAddressOption) IPv6(org.onlab.packet.IPv6) IPv4(org.onlab.packet.IPv4) DHCP6(org.onlab.packet.DHCP6) DhcpRecord(org.onosproject.dhcprelay.store.DhcpRecord) Objective(org.onosproject.net.flowobjective.Objective) MacAddress(org.onlab.packet.MacAddress) Dhcp6Duid(org.onlab.packet.dhcp.Dhcp6Duid) DHCP(org.onlab.packet.DHCP) Assert(org.junit.Assert) DefaultDhcpRelayConfig(org.onosproject.dhcprelay.config.DefaultDhcpRelayConfig) Route(org.onosproject.routeservice.Route) HostLocation(org.onosproject.net.HostLocation) Interface(org.onosproject.net.intf.Interface) TestApplicationId(org.onosproject.TestApplicationId) CoreService(org.onosproject.core.CoreService) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) Dhcp6ClientIdOption(org.onlab.packet.dhcp.Dhcp6ClientIdOption) ByteBuffer(java.nio.ByteBuffer) Ethernet(org.onlab.packet.Ethernet) HostProviderService(org.onosproject.net.host.HostProviderService) Dhcp6IaPrefixOption(org.onlab.packet.dhcp.Dhcp6IaPrefixOption) After(org.junit.After) ImmutableSet(com.google.common.collect.ImmutableSet) Device(org.onosproject.net.Device) Collection(java.util.Collection) PacketProcessor(org.onosproject.net.packet.PacketProcessor) Streams(com.google.common.collect.Streams) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) TestTools.assertAfter(org.onlab.junit.TestTools.assertAfter) IndirectDhcpRelayConfig(org.onosproject.dhcprelay.config.IndirectDhcpRelayConfig) List(java.util.List) InboundPacket(org.onosproject.net.packet.InboundPacket) PacketContext(org.onosproject.net.packet.PacketContext) Optional(java.util.Optional) HostDescription(org.onosproject.net.host.HostDescription) IpPrefix(org.onlab.packet.IpPrefix) PacketContextAdapter(org.onosproject.net.packet.PacketContextAdapter) RouteStoreAdapter(org.onosproject.routeservice.RouteStoreAdapter) Dhcp6RelayOption(org.onlab.packet.dhcp.Dhcp6RelayOption) DhcpRelayCountersStore(org.onosproject.dhcprelay.store.DhcpRelayCountersStore) FlowObjectiveService(org.onosproject.net.flowobjective.FlowObjectiveService) DefaultHost(org.onosproject.net.DefaultHost) ImmutableList(com.google.common.collect.ImmutableList) OutboundPacket(org.onosproject.net.packet.OutboundPacket) PacketServiceAdapter(org.onosproject.net.packet.PacketServiceAdapter) HostId(org.onosproject.net.HostId) DHCP_RELAY_APP(org.onosproject.dhcprelay.DhcpRelayManager.DHCP_RELAY_APP) IpAddress(org.onlab.packet.IpAddress) DefaultInboundPacket(org.onosproject.net.packet.DefaultInboundPacket) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Dhcp6Option(org.onlab.packet.dhcp.Dhcp6Option) Maps(com.google.common.collect.Maps) UDP(org.onlab.packet.UDP) DhcpOption(org.onlab.packet.dhcp.DhcpOption) CaptureType(org.easymock.CaptureType) PacketPriority(org.onosproject.net.packet.PacketPriority) IgnoreDhcpConfig(org.onosproject.dhcprelay.config.IgnoreDhcpConfig) Objective(org.onosproject.net.flowobjective.Objective) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) JsonNode(com.fasterxml.jackson.databind.JsonNode) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ConnectPoint(org.onosproject.net.ConnectPoint) Test(org.junit.Test)

Example 44 with TrafficSelector

use of org.onosproject.net.flow.TrafficSelector in project onos by opennetworkinglab.

the class ControlPlaneRedirectManager method updateOspfForwarding.

/**
 * Installs or removes OSPF forwarding rules.
 *
 * @param request provisioning request containing router and interface
 * @param install true to create an add objective, false to create a remove
 *            objective
 */
private void updateOspfForwarding(InterfaceProvisionRequest request, boolean install) {
    // TODO IPv6 support has not been implemented yet
    Interface intf = request.intf();
    log.debug("{} OSPF flows for {}", operation(install), intf);
    // OSPF to router
    TrafficSelector toSelector = DefaultTrafficSelector.builder().matchInPort(intf.connectPoint().port()).matchEthType(EthType.EtherType.IPV4.ethType().toShort()).matchVlanId(intf.vlan()).matchIPProtocol((byte) OSPF_IP_PROTO).build();
    // create nextObjectives for forwarding to the controlPlaneConnectPoint
    DeviceId deviceId = intf.connectPoint().deviceId();
    PortNumber controlPlanePort = request.controlPlaneConnectPoint().port();
    int cpNextId;
    if (intf.vlan() == VlanId.NONE) {
        cpNextId = modifyNextObjective(deviceId, controlPlanePort, VlanId.vlanId(ASSIGNED_VLAN), true, install);
    } else {
        cpNextId = modifyNextObjective(deviceId, controlPlanePort, intf.vlan(), false, install);
    }
    flowObjectiveService.forward(intf.connectPoint().deviceId(), buildForwardingObjective(toSelector, null, cpNextId, install ? request.info().ospfEnabled() : install, ACL_PRIORITY));
}
Also used : DeviceId(org.onosproject.net.DeviceId) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) PortNumber(org.onosproject.net.PortNumber) Interface(org.onosproject.net.intf.Interface)

Example 45 with TrafficSelector

use of org.onosproject.net.flow.TrafficSelector in project onos by opennetworkinglab.

the class ControlPlaneRedirectManagerTest method setUpInterfaceConfiguration.

/**
 * Setting up flowobjective expectations for basic forwarding and ospf.
 */
private void setUpInterfaceConfiguration(Interface intf, boolean install) {
    DeviceId deviceId = controlPlaneConnectPoint.deviceId();
    PortNumber controlPlanePort = controlPlaneConnectPoint.port();
    for (InterfaceIpAddress ip : intf.ipAddressesList()) {
        int cpNextId, intfNextId;
        cpNextId = modifyNextObjective(deviceId, controlPlanePort, VlanId.vlanId(ControlPlaneRedirectManager.ASSIGNED_VLAN), true, install);
        intfNextId = modifyNextObjective(deviceId, intf.connectPoint().port(), VlanId.vlanId(ControlPlaneRedirectManager.ASSIGNED_VLAN), true, install);
        // IP to router
        TrafficSelector toSelector = buildIPDstSelector(ip.ipAddress().toIpPrefix(), intf.connectPoint().port(), null, intf.mac(), intf.vlan());
        flowObjectiveService.forward(deviceId, buildForwardingObjective(toSelector, null, cpNextId, install, ACL_PRIORITY));
        expectLastCall().once();
        // IP from router
        TrafficSelector fromSelector = buildIPSrcSelector(ip.ipAddress().toIpPrefix(), controlPlanePort, intf.mac(), null, intf.vlan());
        flowObjectiveService.forward(deviceId, buildForwardingObjective(fromSelector, null, intfNextId, install, ACL_PRIORITY));
        expectLastCall().once();
        TrafficTreatment puntTreatment = DefaultTrafficTreatment.builder().punt().build();
        if (ip.ipAddress().isIp4()) {
            // ARP to router
            toSelector = buildArpSelector(intf.connectPoint().port(), intf.vlan(), null, null);
            flowObjectiveService.forward(deviceId, buildForwardingObjective(toSelector, puntTreatment, cpNextId, install, ACL_PRIORITY + 1));
            expectLastCall().once();
            // ARP from router
            fromSelector = buildArpSelector(controlPlanePort, intf.vlan(), ip.ipAddress().getIp4Address(), intf.mac());
            flowObjectiveService.forward(deviceId, buildForwardingObjective(fromSelector, puntTreatment, intfNextId, install, ACL_PRIORITY + 1));
            expectLastCall().once();
        } else {
            // NDP solicitation to router
            // Global unicast address
            toSelector = buildNdpSelector(intf.connectPoint().port(), intf.vlan(), null, ip.ipAddress().toIpPrefix(), NEIGHBOR_SOLICITATION, null);
            flowObjectiveService.forward(deviceId, buildForwardingObjective(toSelector, puntTreatment, cpNextId, install, ACL_PRIORITY + 1));
            expectLastCall().once();
            // NDP solicitation to router
            // Link local address
            toSelector = buildNdpSelector(intf.connectPoint().port(), intf.vlan(), null, Ip6Address.valueOf(getLinkLocalAddress(intf.mac().toBytes())).toIpPrefix(), NEIGHBOR_SOLICITATION, null);
            flowObjectiveService.forward(deviceId, buildForwardingObjective(toSelector, puntTreatment, cpNextId, install, ACL_PRIORITY + 1));
            expectLastCall().once();
            // NDP solicitation to router
            // solicitated global unicast address
            toSelector = buildNdpSelector(intf.connectPoint().port(), intf.vlan(), null, Ip6Address.valueOf(getSolicitNodeAddress(ip.ipAddress().toOctets())).toIpPrefix(), NEIGHBOR_SOLICITATION, null);
            flowObjectiveService.forward(deviceId, buildForwardingObjective(toSelector, puntTreatment, cpNextId, install, ACL_PRIORITY + 1));
            expectLastCall().once();
            // NDP solicitation to router
            // solicitated link local address
            toSelector = buildNdpSelector(intf.connectPoint().port(), intf.vlan(), null, Ip6Address.valueOf(getSolicitNodeAddress(getLinkLocalAddress(intf.mac().toBytes()))).toIpPrefix(), NEIGHBOR_SOLICITATION, null);
            flowObjectiveService.forward(deviceId, buildForwardingObjective(toSelector, puntTreatment, cpNextId, install, ACL_PRIORITY + 1));
            expectLastCall().once();
            // NDP solicitation from router
            // Global unicast address
            fromSelector = buildNdpSelector(controlPlanePort, intf.vlan(), ip.ipAddress().toIpPrefix(), null, NEIGHBOR_SOLICITATION, intf.mac());
            flowObjectiveService.forward(deviceId, buildForwardingObjective(fromSelector, puntTreatment, intfNextId, install, ACL_PRIORITY + 1));
            expectLastCall().once();
            // NDP solicitation from router
            // Link local address
            fromSelector = buildNdpSelector(controlPlanePort, intf.vlan(), Ip6Address.valueOf(getLinkLocalAddress(intf.mac().toBytes())).toIpPrefix(), null, NEIGHBOR_SOLICITATION, intf.mac());
            flowObjectiveService.forward(deviceId, buildForwardingObjective(fromSelector, puntTreatment, intfNextId, install, ACL_PRIORITY + 1));
            expectLastCall().once();
            // NDP advertisement to router
            // Global unicast address
            toSelector = buildNdpSelector(intf.connectPoint().port(), intf.vlan(), null, ip.ipAddress().toIpPrefix(), NEIGHBOR_ADVERTISEMENT, null);
            flowObjectiveService.forward(deviceId, buildForwardingObjective(toSelector, puntTreatment, cpNextId, install, ACL_PRIORITY + 1));
            expectLastCall().once();
            // NDP advertisement to router
            // Link local address
            toSelector = buildNdpSelector(intf.connectPoint().port(), intf.vlan(), null, Ip6Address.valueOf(getLinkLocalAddress(intf.mac().toBytes())).toIpPrefix(), NEIGHBOR_ADVERTISEMENT, null);
            flowObjectiveService.forward(deviceId, buildForwardingObjective(toSelector, puntTreatment, cpNextId, install, ACL_PRIORITY + 1));
            expectLastCall().once();
            // NDP advertisement from the router
            // Global unicast address
            fromSelector = buildNdpSelector(controlPlanePort, intf.vlan(), ip.ipAddress().toIpPrefix(), null, NEIGHBOR_ADVERTISEMENT, null);
            flowObjectiveService.forward(deviceId, buildForwardingObjective(fromSelector, puntTreatment, intfNextId, install, ACL_PRIORITY + 1));
            expectLastCall().once();
            // NDP advertisement from router
            // Link local address
            fromSelector = buildNdpSelector(controlPlanePort, intf.vlan(), Ip6Address.valueOf(getLinkLocalAddress(intf.mac().toBytes())).toIpPrefix(), null, NEIGHBOR_ADVERTISEMENT, null);
            flowObjectiveService.forward(deviceId, buildForwardingObjective(fromSelector, puntTreatment, intfNextId, install, ACL_PRIORITY + 1));
            expectLastCall().once();
        }
    }
    // setting expectations for ospf forwarding.
    TrafficSelector toSelector = DefaultTrafficSelector.builder().matchInPort(intf.connectPoint().port()).matchEthType(EthType.EtherType.IPV4.ethType().toShort()).matchVlanId(intf.vlan()).matchIPProtocol((byte) OSPF_IP_PROTO).build();
    modifyNextObjective(deviceId, controlPlanePort, VlanId.vlanId((short) 4094), true, install);
    flowObjectiveService.forward(controlPlaneConnectPoint.deviceId(), buildForwardingObjective(toSelector, null, 1, install, 40001));
    expectLastCall().once();
}
Also used : DeviceId(org.onosproject.net.DeviceId) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) PortNumber(org.onosproject.net.PortNumber) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) ConnectPoint(org.onosproject.net.ConnectPoint)

Aggregations

TrafficSelector (org.onosproject.net.flow.TrafficSelector)396 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)354 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)249 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)235 FlowRule (org.onosproject.net.flow.FlowRule)94 Test (org.junit.Test)85 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)84 PiAction (org.onosproject.net.pi.runtime.PiAction)54 ConnectPoint (org.onosproject.net.ConnectPoint)51 ForwardingObjective (org.onosproject.net.flowobjective.ForwardingObjective)48 DeviceId (org.onosproject.net.DeviceId)43 PortNumber (org.onosproject.net.PortNumber)43 List (java.util.List)42 NextObjective (org.onosproject.net.flowobjective.NextObjective)41 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)39 PiActionParam (org.onosproject.net.pi.runtime.PiActionParam)38 Instruction (org.onosproject.net.flow.instructions.Instruction)37 Criterion (org.onosproject.net.flow.criteria.Criterion)36 PiCriterion (org.onosproject.net.flow.criteria.PiCriterion)36 DefaultForwardingObjective (org.onosproject.net.flowobjective.DefaultForwardingObjective)35