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);
}
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);
}
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);
}
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);
}
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));
}
Aggregations