Search in sources :

Example 6 with FilteringObjective

use of org.onosproject.net.flowobjective.FilteringObjective 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 7 with FilteringObjective

use of org.onosproject.net.flowobjective.FilteringObjective 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 8 with FilteringObjective

use of org.onosproject.net.flowobjective.FilteringObjective 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 9 with FilteringObjective

use of org.onosproject.net.flowobjective.FilteringObjective 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)

Example 10 with FilteringObjective

use of org.onosproject.net.flowobjective.FilteringObjective in project onos by opennetworkinglab.

the class FilteringObjectiveCodecTest method testFilteringObjectiveEncode.

/**
 * Tests encoding of a FilteringObjective object.
 */
@Test
public void testFilteringObjectiveEncode() {
    Criterion condition1 = Criteria.matchVlanId(VlanId.ANY);
    Criterion condition2 = Criteria.matchEthType((short) 0x8844);
    FilteringObjective filteringObj = DefaultFilteringObjective.builder().makePermanent().permit().fromApp(APP_ID).withPriority(60).addCondition(condition1).addCondition(condition2).add();
    // TODO: need to add test case for TrafficTreatment (META in filteringObj)
    ObjectNode filteringObjJson = filteringObjectiveCodec.encode(filteringObj, context);
    assertThat(filteringObjJson, matchesFilteringObjective(filteringObj));
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Criterion(org.onosproject.net.flow.criteria.Criterion) DefaultFilteringObjective(org.onosproject.net.flowobjective.DefaultFilteringObjective) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective) FilteringObjectiveJsonMatcher.matchesFilteringObjective(org.onosproject.codec.impl.FilteringObjectiveJsonMatcher.matchesFilteringObjective) Test(org.junit.Test)

Aggregations

FilteringObjective (org.onosproject.net.flowobjective.FilteringObjective)36 DefaultFilteringObjective (org.onosproject.net.flowobjective.DefaultFilteringObjective)22 Test (org.junit.Test)21 ForwardingObjective (org.onosproject.net.flowobjective.ForwardingObjective)17 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)15 NextObjective (org.onosproject.net.flowobjective.NextObjective)15 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)14 Objective (org.onosproject.net.flowobjective.Objective)13 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)10 FlowRule (org.onosproject.net.flow.FlowRule)10 TrafficSelector (org.onosproject.net.flow.TrafficSelector)10 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)9 FlowObjectiveIntent (org.onosproject.net.intent.FlowObjectiveIntent)9 Intent (org.onosproject.net.intent.Intent)9 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)7 LinkCollectionIntent (org.onosproject.net.intent.LinkCollectionIntent)7 DefaultLink (org.onosproject.net.DefaultLink)6 DeviceId (org.onosproject.net.DeviceId)6 Link (org.onosproject.net.Link)6 PortCriterion (org.onosproject.net.flow.criteria.PortCriterion)6