Search in sources :

Example 66 with FlowRule

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

the class FilteringObjectiveTranslatorTest method testIsPairPort.

/**
 * Test is pair port scenarios for filtering objective.
 */
@Test
public void testIsPairPort() throws FabricPipelinerException {
    // Only pair port flag
    FilteringObjective filteringObjective = DefaultFilteringObjective.builder().withKey(Criteria.matchInPort(PORT_1)).addCondition(Criteria.matchEthDst(ROUTER_MAC)).addCondition(Criteria.matchVlanId(VLAN_100)).withPriority(PRIORITY).withMeta(DefaultTrafficTreatment.builder().writeMetadata(PAIR_PORT, 0xffffffffffffffffL).build()).fromApp(APP_ID).permit().add();
    ObjectiveTranslation actualTranslation = translator.translate(filteringObjective);
    Collection<FlowRule> expectedFlowRules = Lists.newArrayList();
    expectedFlowRules.add(buildExpectedVlanInPortRule(PORT_1, VLAN_100, null, VlanId.NONE, PORT_TYPE_INFRA, FabricConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN));
    expectedFlowRules.addAll(buildExpectedFwdClassifierRule(PORT_1, ROUTER_MAC, null, Ethernet.TYPE_IPV4, FWD_IPV4_ROUTING));
    expectedFlowRules.addAll(buildExpectedFwdClassifierRule(PORT_1, ROUTER_MAC, null, Ethernet.TYPE_IPV6, FWD_IPV6_ROUTING));
    expectedFlowRules.addAll(buildExpectedFwdClassifierRule(PORT_1, ROUTER_MAC, null, Ethernet.MPLS_UNICAST, FWD_MPLS));
    ObjectiveTranslation expectedTranslation = buildExpectedTranslation(expectedFlowRules);
    assertEquals(expectedTranslation, actualTranslation);
    // Pair port and config update flags
    filteringObjective = DefaultFilteringObjective.builder().withKey(Criteria.matchInPort(PORT_1)).addCondition(Criteria.matchEthDst(ROUTER_MAC)).addCondition(Criteria.matchVlanId(VLAN_100)).withPriority(PRIORITY).fromApp(APP_ID).withMeta(DefaultTrafficTreatment.builder().writeMetadata(6, 0xffffffffffffffffL).build()).permit().add();
    actualTranslation = translator.translate(filteringObjective);
    expectedFlowRules = Lists.newArrayList();
    // Ingress port vlan rule
    expectedFlowRules.add(buildExpectedVlanInPortRule(PORT_1, VLAN_100, null, VlanId.NONE, PORT_TYPE_INFRA, FabricConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN));
    expectedTranslation = buildExpectedTranslation(expectedFlowRules);
    assertEquals(expectedTranslation, actualTranslation);
}
Also used : DefaultFilteringObjective(org.onosproject.net.flowobjective.DefaultFilteringObjective) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) Test(org.junit.Test)

Example 67 with FlowRule

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

the class FilteringObjectiveTranslatorTest method testRouterMacAndVlanFilter.

/**
 * Creates one rule for ingress_port_vlan table and 3 rules for
 * fwd_classifier table (IPv4, IPv6 and MPLS unicast) when the condition is
 * VLAN + MAC.
 */
@Test
public void testRouterMacAndVlanFilter() throws FabricPipelinerException {
    FilteringObjective filteringObjective = buildFilteringObjective(ROUTER_MAC, EDGE_PORT);
    ObjectiveTranslation actualTranslation = translator.translate(filteringObjective);
    Collection<FlowRule> expectedFlowRules = Lists.newArrayList();
    // in port vlan flow rule
    expectedFlowRules.add(buildExpectedVlanInPortRule(PORT_1, VlanId.NONE, VlanId.NONE, VLAN_100, PORT_TYPE_EDGE, FabricConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN));
    // forwarding classifier ipv4
    expectedFlowRules.addAll(buildExpectedFwdClassifierRule(PORT_1, ROUTER_MAC, null, Ethernet.TYPE_IPV4, FWD_IPV4_ROUTING));
    // forwarding classifier ipv6
    expectedFlowRules.addAll(buildExpectedFwdClassifierRule(PORT_1, ROUTER_MAC, null, Ethernet.TYPE_IPV6, FWD_IPV6_ROUTING));
    // forwarding classifier mpls
    expectedFlowRules.addAll(buildExpectedFwdClassifierRule(PORT_1, ROUTER_MAC, null, Ethernet.MPLS_UNICAST, FWD_MPLS));
    // ObjectiveTranslation.Builder expectedTranslationBuilder = ObjectiveTranslation.builder()
    // .addFlowRule(inportFlowRuleExpected);
    // for (FlowRule flowRule : classifierV4FlowRuleExpected) {
    // expectedTranslationBuilder.addFlowRule(flowRule);
    // }
    // for (FlowRule flowRule : classifierV6FlowRuleExpected) {
    // expectedTranslationBuilder.addFlowRule(flowRule);
    // }
    // for (FlowRule flowRule : classifierMplsFlowRuleExpected) {
    // expectedTranslationBuilder.addFlowRule(flowRule);
    // }
    ObjectiveTranslation expectedTranslation = buildExpectedTranslation(expectedFlowRules);
    assertEquals(expectedTranslation, actualTranslation);
}
Also used : DefaultFilteringObjective(org.onosproject.net.flowobjective.DefaultFilteringObjective) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) Test(org.junit.Test)

Example 68 with FlowRule

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

the class FilteringObjectiveTranslatorTest method testIpv4MulticastFwdClass.

/**
 * Creates one rule for ingress_port_vlan table and one rule for
 * fwd_classifier table (IPv4 multicast) when the condition is ipv4
 * multicast mac address.
 */
@Test
public void testIpv4MulticastFwdClass() throws FabricPipelinerException {
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().pushVlan().setVlanId(VLAN_100).writeMetadata(EDGE_PORT, 0xffffffffffffffffL).build();
    FilteringObjective filteringObjective = DefaultFilteringObjective.builder().permit().withPriority(PRIORITY).withKey(Criteria.matchInPort(PORT_1)).addCondition(Criteria.matchEthDstMasked(MacAddress.IPV4_MULTICAST, MacAddress.IPV4_MULTICAST_MASK)).addCondition(Criteria.matchVlanId(VlanId.NONE)).withMeta(treatment).fromApp(APP_ID).makePermanent().add();
    ObjectiveTranslation actualTranslation = translator.translate(filteringObjective);
    List<FlowRule> expectedFlowRules = Lists.newArrayList();
    // in port vlan flow rule
    expectedFlowRules.add(buildExpectedVlanInPortRule(PORT_1, VlanId.NONE, VlanId.NONE, VLAN_100, PORT_TYPE_EDGE, FabricConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN));
    // forwarding classifier
    expectedFlowRules.addAll(buildExpectedFwdClassifierRule(PORT_1, MacAddress.IPV4_MULTICAST, MacAddress.IPV4_MULTICAST_MASK, Ethernet.TYPE_IPV4, FWD_IPV4_ROUTING));
    ObjectiveTranslation expectedTranslation = buildExpectedTranslation(expectedFlowRules);
    assertEquals(expectedTranslation, actualTranslation);
}
Also used : DefaultFilteringObjective(org.onosproject.net.flowobjective.DefaultFilteringObjective) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Test(org.junit.Test)

Example 69 with FlowRule

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

the class FilteringObjectiveTranslatorTest method testIpv6MulticastFwdClass.

/**
 * Creates one rule for ingress_port_vlan table and one rule for
 * fwd_classifier table (IPv6 multicast) when the condition is ipv6
 * multicast mac address.
 */
@Test
public void testIpv6MulticastFwdClass() throws FabricPipelinerException {
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().pushVlan().setVlanId(VLAN_100).writeMetadata(EDGE_PORT, 0xffffffffffffffffL).build();
    FilteringObjective filteringObjective = DefaultFilteringObjective.builder().permit().withPriority(PRIORITY).withKey(Criteria.matchInPort(PORT_1)).addCondition(Criteria.matchEthDstMasked(MacAddress.IPV6_MULTICAST, MacAddress.IPV6_MULTICAST_MASK)).addCondition(Criteria.matchVlanId(VlanId.NONE)).withMeta(treatment).fromApp(APP_ID).makePermanent().add();
    ObjectiveTranslation actualTranslation = translator.translate(filteringObjective);
    Collection<FlowRule> flowRules = Lists.newArrayList();
    // in port vlan flow rule
    flowRules.add(buildExpectedVlanInPortRule(PORT_1, VlanId.NONE, VlanId.NONE, VLAN_100, PORT_TYPE_EDGE, FabricConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN));
    flowRules.addAll(buildExpectedFwdClassifierRule(PORT_1, MacAddress.IPV6_MULTICAST, MacAddress.IPV6_MULTICAST_MASK, Ethernet.TYPE_IPV6, FWD_IPV6_ROUTING));
    ObjectiveTranslation expectedTranslation = buildExpectedTranslation(flowRules);
    assertEquals(expectedTranslation, actualTranslation);
}
Also used : DefaultFilteringObjective(org.onosproject.net.flowobjective.DefaultFilteringObjective) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Test(org.junit.Test)

Example 70 with FlowRule

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

the class FilteringObjectiveTranslatorTest method testIsInfraPort.

/**
 * Test is infra port scenarios for filtering objective.
 */
@Test
public void testIsInfraPort() throws FabricPipelinerException {
    // PW transport vlan
    FilteringObjective filteringObjective = DefaultFilteringObjective.builder().withKey(Criteria.matchInPort(PORT_1)).addCondition(Criteria.matchEthDst(ROUTER_MAC)).addCondition(Criteria.matchVlanId(VlanId.vlanId((short) DEFAULT_PW_TRANSPORT_VLAN))).withPriority(PRIORITY).withMeta(DefaultTrafficTreatment.builder().writeMetadata(INFRA_PORT, 0xffffffffffffffffL).build()).fromApp(APP_ID).permit().add();
    ObjectiveTranslation actualTranslation = translator.translate(filteringObjective);
    Collection<FlowRule> expectedFlowRules = Lists.newArrayList();
    expectedFlowRules.add(buildExpectedVlanInPortRule(PORT_1, VlanId.vlanId((short) DEFAULT_PW_TRANSPORT_VLAN), null, VlanId.NONE, PORT_TYPE_INFRA, FabricConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN));
    expectedFlowRules.addAll(buildExpectedFwdClassifierRule(PORT_1, ROUTER_MAC, null, Ethernet.TYPE_IPV4, FWD_IPV4_ROUTING));
    expectedFlowRules.addAll(buildExpectedFwdClassifierRule(PORT_1, ROUTER_MAC, null, Ethernet.TYPE_IPV6, FWD_IPV6_ROUTING));
    expectedFlowRules.addAll(buildExpectedFwdClassifierRule(PORT_1, ROUTER_MAC, null, Ethernet.MPLS_UNICAST, FWD_MPLS));
    ObjectiveTranslation expectedTranslation = buildExpectedTranslation(expectedFlowRules);
    assertEquals(expectedTranslation, actualTranslation);
    // Untagged port scenario
    filteringObjective = DefaultFilteringObjective.builder().withKey(Criteria.matchInPort(PORT_1)).addCondition(Criteria.matchEthDst(ROUTER_MAC)).addCondition(Criteria.matchVlanId(VlanId.NONE)).withPriority(PRIORITY).fromApp(APP_ID).withMeta(DefaultTrafficTreatment.builder().pushVlan().setVlanId(VlanId.vlanId((short) DEFAULT_VLAN)).writeMetadata(INFRA_PORT, 0xffffffffffffffffL).build()).permit().add();
    actualTranslation = translator.translate(filteringObjective);
    expectedFlowRules = Lists.newArrayList();
    expectedFlowRules.add(buildExpectedVlanInPortRule(PORT_1, null, null, VlanId.vlanId((short) DEFAULT_VLAN), PORT_TYPE_INFRA, FabricConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN));
    expectedFlowRules.addAll(buildExpectedFwdClassifierRule(PORT_1, ROUTER_MAC, null, Ethernet.TYPE_IPV4, FWD_IPV4_ROUTING));
    expectedFlowRules.addAll(buildExpectedFwdClassifierRule(PORT_1, ROUTER_MAC, null, Ethernet.TYPE_IPV6, FWD_IPV6_ROUTING));
    expectedFlowRules.addAll(buildExpectedFwdClassifierRule(PORT_1, ROUTER_MAC, null, Ethernet.MPLS_UNICAST, FWD_MPLS));
    expectedTranslation = buildExpectedTranslation(expectedFlowRules);
    assertEquals(expectedTranslation, actualTranslation);
}
Also used : DefaultFilteringObjective(org.onosproject.net.flowobjective.DefaultFilteringObjective) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) Test(org.junit.Test)

Aggregations

FlowRule (org.onosproject.net.flow.FlowRule)351 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)226 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)207 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)207 TrafficSelector (org.onosproject.net.flow.TrafficSelector)174 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)174 Test (org.junit.Test)133 FlowRuleIntent (org.onosproject.net.intent.FlowRuleIntent)90 Intent (org.onosproject.net.intent.Intent)88 DeviceId (org.onosproject.net.DeviceId)87 List (java.util.List)86 Collection (java.util.Collection)68 Collectors (java.util.stream.Collectors)68 CoreService (org.onosproject.core.CoreService)66 VlanId (org.onlab.packet.VlanId)65 VlanIdCriterion (org.onosproject.net.flow.criteria.VlanIdCriterion)61 Collections (java.util.Collections)60 FlowEntry (org.onosproject.net.flow.FlowEntry)59 MplsCriterion (org.onosproject.net.flow.criteria.MplsCriterion)56 ArrayList (java.util.ArrayList)54