org.onosproject.net.flowobjective.FilteringObjective Java Examples
The following examples show how to use
org.onosproject.net.flowobjective.FilteringObjective.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FabricFilteringPipelinerTest.java From onos with Apache License 2.0 | 6 votes |
/** * Creates only one rule for ingress_port_vlan table if there is no * condition of destination mac address. The packet will be handled by * bridging table by default. */ @Test public void testFwdBridging() throws Exception { FilteringObjective filteringObjective = buildFilteringObjective(null); ObjectiveTranslation actualTranslation = translator.translate(filteringObjective); // in port vlan flow rule FlowRule flowRuleExpected = buildExpectedVlanInPortRule( PORT_1, VlanId.NONE, VlanId.NONE, VLAN_100, FabricConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN); // No rules in forwarding classifier, will do default action: set fwd type to bridging ObjectiveTranslation expectedTranslation = ObjectiveTranslation.builder() .addFlowRule(flowRuleExpected) .build(); assertEquals(expectedTranslation, actualTranslation); }
Example #2
Source File: CorsaPipelineV3.java From onos with Apache License 2.0 | 6 votes |
@Override protected Builder processVlanFiler(FilteringObjective filt, VlanIdCriterion vlan, PortCriterion port) { log.debug("adding rule for VLAN: {}", vlan.vlanId()); TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); selector.matchVlanId(vlan.vlanId()); selector.matchInPort(port.port()); /* Static treatment for VLAN_CIRCUIT_TABLE */ treatment.setVlanPcp(MAX_VLAN_PCP); treatment.setQueue(0); treatment.meter(MeterId.meterId(defaultMeterId.id())); /* use default meter (Green) */ treatment.transition(L3_IF_MAC_DA_TABLE); return DefaultFlowRule.builder() .withSelector(selector.build()) .withTreatment(treatment.build()) .withPriority(CONTROLLER_PRIORITY) .makePermanent() .forTable(VLAN_CIRCUIT_TABLE); }
Example #3
Source File: SpringOpenTTPDell.java From onos with Apache License 2.0 | 6 votes |
@Override //Dell switches need ETH_DST based match condition in all IP table entries. //So while processing the ETH_DST based filtering objective, store //the device MAC to be used locally to use it while pushing the IP rules. protected List<FlowRule> processEthDstFilter(EthCriterion ethCriterion, VlanIdCriterion vlanIdCriterion, FilteringObjective filt, VlanId assignedVlan, ApplicationId applicationId) { // Store device termination Mac to be used in IP flow entries deviceTMac = ethCriterion.mac(); log.debug("For now not adding any TMAC rules " + "into Dell switches as it is ignoring"); return Collections.emptyList(); }
Example #4
Source File: FlowObjectiveManagerTest.java From onos with Apache License 2.0 | 6 votes |
/** * Tests adding a filtering objective. */ @Test public void filteringObjective() { TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment(); FilteringObjective filter = DefaultFilteringObjective.builder() .fromApp(NetTestTools.APP_ID) .withMeta(treatment) .makePermanent() .deny() .addCondition(Criteria.matchEthType(12)) .add(); manager.activate(null); manager.filter(id1, filter); TestTools.assertAfter(RETRY_MS, () -> assertThat(filteringObjectives, hasSize(1))); assertThat(forwardingObjectives, hasSize(0)); assertThat(filteringObjectives, hasItem("of:d1")); assertThat(nextObjectives, hasSize(0)); }
Example #5
Source File: XconnectManager.java From onos with Apache License 2.0 | 6 votes |
/** * Revokes filtering objectives for given XConnect. * * @param key XConnect store key * @param endpoints XConnect endpoints */ private void revokeFilter(XconnectKey key, Set<XconnectEndpoint> endpoints) { // FIXME Improve the logic // If port load balancer is not involved, use filtered port. Otherwise, use unfiltered port. // The purpose is to make sure existing XConnect logic can still work on a configured port. boolean filtered = endpoints.stream() .map(ep -> getNextTreatment(key.deviceId(), ep, false)) .allMatch(t -> t.type().equals(NextTreatment.Type.TREATMENT)); endpoints.stream() .map(ep -> getPhysicalPorts(key.deviceId(), ep)). flatMap(Set::stream).forEach(port -> { FilteringObjective.Builder filtObjBuilder = filterObjBuilder(key, port, filtered); ObjectiveContext context = new DefaultObjectiveContext( (objective) -> log.debug("XConnect FilterObj for {} on port {} revoked", key, port), (objective, error) -> log.warn("Failed to revoke XConnect FilterObj for {} on port {}: {}", key, port, error)); flowObjectiveService.filter(key.deviceId(), filtObjBuilder.remove(context)); }); }
Example #6
Source File: XconnectManager.java From onos with Apache License 2.0 | 6 votes |
/** * Populates filtering objectives for given XConnect. * * @param key XConnect store key * @param endpoints XConnect endpoints */ private void populateFilter(XconnectKey key, Set<XconnectEndpoint> endpoints) { // FIXME Improve the logic // If port load balancer is not involved, use filtered port. Otherwise, use unfiltered port. // The purpose is to make sure existing XConnect logic can still work on a configured port. boolean filtered = endpoints.stream() .map(ep -> getNextTreatment(key.deviceId(), ep, false)) .allMatch(t -> t.type().equals(NextTreatment.Type.TREATMENT)); endpoints.stream() .map(ep -> getPhysicalPorts(key.deviceId(), ep)) .flatMap(Set::stream).forEach(port -> { FilteringObjective.Builder filtObjBuilder = filterObjBuilder(key, port, filtered); ObjectiveContext context = new DefaultObjectiveContext( (objective) -> log.debug("XConnect FilterObj for {} on port {} populated", key, port), (objective, error) -> log.warn("Failed to populate XConnect FilterObj for {} on port {}: {}", key, port, error)); flowObjectiveService.filter(key.deviceId(), filtObjBuilder.add(context)); }); }
Example #7
Source File: InOrderFlowObjectiveManagerTest.java From onos with Apache License 2.0 | 6 votes |
/** * Creates filtering objective builder with a serial number encoded in MPLS label. * The serial number is used to identify same objective that occurs multiple times. * * @param portnum Port number * @param vlanId VLAN Id * @param mac MAC address * @param serial Serial number * @return Filtering objective builder */ private static FilteringObjective.Builder buildFilteringObjective(PortNumber portnum, VlanId vlanId, MacAddress mac, int serial) { FilteringObjective.Builder fob = DefaultFilteringObjective.builder(); fob.withKey(Criteria.matchInPort(portnum)) .addCondition(Criteria.matchEthDst(mac)) .addCondition(Criteria.matchVlanId(VlanId.NONE)) .addCondition(Criteria.matchMplsLabel(MplsLabel.mplsLabel(serial))) .withPriority(PRIORITY); TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder(); tBuilder.pushVlan().setVlanId(vlanId); fob.withMeta(tBuilder.build()); fob.permit().fromApp(APP_ID); return fob; }
Example #8
Source File: OfdpaPipelineUtility.java From onos with Apache License 2.0 | 6 votes |
/** * Determines if the filtering objective will be used for a pseudowire. * * @param filteringObjective the filtering objective * @return True if objective was created for a pseudowire, false otherwise. */ static boolean isPseudowire(FilteringObjective filteringObjective) { if (filteringObjective.meta() != null) { TrafficTreatment treatment = filteringObjective.meta(); for (Instruction instr : treatment.immediate()) { if (instr.type().equals(Instruction.Type.L2MODIFICATION)) { L2ModificationInstruction l2Instr = (L2ModificationInstruction) instr; if (l2Instr.subtype().equals(L2SubType.TUNNEL_ID)) { return true; } } } } return false; }
Example #9
Source File: FilteringObjectiveCodecTest.java From onos with Apache License 2.0 | 6 votes |
/** * Test decoding of a FilteringObjective object. */ @Test public void testFilteringObjectiveDecode() throws IOException { ApplicationId appId = new DefaultApplicationId(0, SAMPLE_APP_ID); expect(mockCoreService.registerApplication(SAMPLE_APP_ID)).andReturn(appId).anyTimes(); replay(mockCoreService); FilteringObjective filteringObjective = getFilteringObjective("FilteringObjective.json"); assertThat(filteringObjective.type(), is(FilteringObjective.Type.PERMIT)); assertThat(filteringObjective.priority(), is(60)); assertThat(filteringObjective.timeout(), is(1)); assertThat(filteringObjective.op(), is(FilteringObjective.Operation.ADD)); assertThat(filteringObjective.permanent(), is(false)); }
Example #10
Source File: FilterTable.java From onos with Apache License 2.0 | 6 votes |
public List<FilteringObjective> updateFilter(FilteringObjective filteringObjective) { List<FilteringObjective> updates = new ArrayList<>(); switch (filteringObjective.op()) { case ADD: this.filterMap.put(filteringObjective.id(), filteringObjective); updates.add(filteringObjective); break; case REMOVE: this.filterMap.remove(filteringObjective.id()); updates.add(filteringObjective); break; default: break; } return updates; }
Example #11
Source File: FibInstaller.java From onos with Apache License 2.0 | 6 votes |
/** * Installs or removes unicast filtering objectives relating to an interface. * * @param routerIntf interface to update objectives for * @param install true to install the objectives, false to remove them */ private void updateFilteringObjective(InterfaceProvisionRequest routerIntf, boolean install) { Interface intf = routerIntf.intf(); VlanId assignedVlan = (egressVlan().equals(VlanId.NONE)) ? VlanId.vlanId(ASSIGNED_VLAN) : egressVlan(); FilteringObjective.Builder fob = DefaultFilteringObjective.builder(); // first add filter for the interface fob.withKey(Criteria.matchInPort(intf.connectPoint().port())) .addCondition(Criteria.matchEthDst(intf.mac())) .addCondition(Criteria.matchVlanId(intf.vlan())); fob.withPriority(PRIORITY_OFFSET); if (intf.vlan() == VlanId.NONE) { TrafficTreatment tt = DefaultTrafficTreatment.builder() .pushVlan().setVlanId(assignedVlan).build(); fob.withMeta(tt); } fob.permit().fromApp(fibAppId); sendFilteringObjective(install, fob, intf); // then add the same mac/vlan filters for control-plane connect point fob.withKey(Criteria.matchInPort(routerIntf.controlPlaneConnectPoint().port())); sendFilteringObjective(install, fob, intf); }
Example #12
Source File: FibInstaller.java From onos with Apache License 2.0 | 6 votes |
/** * Installs or removes multicast filtering objectives relating to an interface. * * @param routerIntf interface to update objectives for * @param install true to install the objectives, false to remove them */ private void updateMcastFilteringObjective(InterfaceProvisionRequest routerIntf, boolean install) { Interface intf = routerIntf.intf(); VlanId assignedVlan = (egressVlan().equals(VlanId.NONE)) ? VlanId.vlanId(ASSIGNED_VLAN) : egressVlan(); FilteringObjective.Builder fob = DefaultFilteringObjective.builder(); // first add filter for the interface fob.withKey(Criteria.matchInPort(intf.connectPoint().port())) .addCondition(Criteria.matchEthDstMasked(MacAddress.IPV4_MULTICAST, MacAddress.IPV4_MULTICAST_MASK)) .addCondition(Criteria.matchVlanId(ingressVlan())); fob.withPriority(PRIORITY_OFFSET); TrafficTreatment tt = DefaultTrafficTreatment.builder() .pushVlan().setVlanId(assignedVlan).build(); fob.withMeta(tt); fob.permit().fromApp(fibAppId); sendFilteringObjective(install, fob, intf); }
Example #13
Source File: RoutingRulePopulator.java From onos with Apache License 2.0 | 6 votes |
/** * Creates or removes filtering objectives for a double-tagged host on a port. * * @param deviceId device identifier * @param portNum port identifier for port to be filtered * @param outerVlan outer VLAN ID * @param innerVlan inner VLAN ID * @param install true to install the filtering objective, false to remove */ void processDoubleTaggedFilter(DeviceId deviceId, PortNumber portNum, VlanId outerVlan, VlanId innerVlan, boolean install) { // We should trigger the removal of double tagged rules only when removing // the filtering objective and no other hosts are connected to the same device port. boolean cleanupDoubleTaggedRules = !anyDoubleTaggedHost(deviceId, portNum) && !install; FilteringObjective.Builder fob = buildDoubleTaggedFilteringObj(deviceId, portNum, outerVlan, innerVlan, cleanupDoubleTaggedRules); if (fob == null) { // error encountered during build return; } log.debug("{} double-tagged filtering objectives for dev/port: {}/{}", install ? "Installing" : "Removing", deviceId, portNum); ObjectiveContext context = new DefaultObjectiveContext( (objective) -> log.debug("Filter for {}/{} {}", deviceId, portNum, install ? "installed" : "removed"), (objective, error) -> log.warn("Failed to {} filter for {}/{}: {}", install ? "install" : "remove", deviceId, portNum, error)); if (install) { srManager.flowObjectiveService.filter(deviceId, fob.add(context)); } else { srManager.flowObjectiveService.filter(deviceId, fob.remove(context)); } }
Example #14
Source File: FlowObjectiveCompositionManager.java From onos with Apache License 2.0 | 6 votes |
@Override public void run() { try { Pipeliner pipeliner = getDevicePipeliner(deviceId); if (pipeliner != null) { if (objective instanceof NextObjective) { pipeliner.next((NextObjective) objective); } else if (objective instanceof ForwardingObjective) { pipeliner.forward((ForwardingObjective) objective); } else { pipeliner.filter((FilteringObjective) objective); } } else if (numAttempts < INSTALL_RETRY_ATTEMPTS) { Thread.sleep(INSTALL_RETRY_INTERVAL); executorService.execute(new ObjectiveInstaller(deviceId, objective, numAttempts + 1)); } else { // Otherwise we've tried a few times and failed, report an // error back to the user. objective.context().ifPresent( c -> c.onError(objective, ObjectiveError.NOPIPELINER)); } } catch (Exception e) { log.warn("Exception while installing flow objective", e); } }
Example #15
Source File: OltPipeline.java From onos with Apache License 2.0 | 6 votes |
private void provisionIgmp(FilteringObjective filter, EthTypeCriterion ethType, IPProtocolCriterion ipProto, Instructions.OutputInstruction output) { Instruction meter = filter.meta().metered(); Instruction writeMetadata = filter.meta().writeMetadata(); // cTag VlanIdCriterion vlanId = (VlanIdCriterion) filterForCriterion(filter.conditions(), Criterion.Type.VLAN_VID); Criterion cTagPriority = filterForCriterion(filter.conditions(), Criterion.Type.VLAN_PCP); TrafficSelector selector = buildSelector(filter.key(), ethType, ipProto, vlanId, cTagPriority); TrafficTreatment treatment = buildTreatment(output, meter, writeMetadata); buildAndApplyRule(filter, selector, treatment); }
Example #16
Source File: VirtualNetworkFlowObjectiveManagerTest.java From onos with Apache License 2.0 | 6 votes |
/** * Tests adding a filtering objective. */ @Test public void filteringObjective() { TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment(); FilteringObjective filter = DefaultFilteringObjective.builder() .fromApp(NetTestTools.APP_ID) .withMeta(treatment) .makePermanent() .deny() .addCondition(Criteria.matchEthType(12)) .add(new ObjectiveContext() { @Override public void onSuccess(Objective objective) { assertEquals("1 flowrule entry expected", 1, flowRuleStore.getFlowRuleCount(vnet1.id())); assertEquals("0 flowrule entry expected", 0, flowRuleStore.getFlowRuleCount(vnet2.id())); } }); service1.filter(VDID1, filter); }
Example #17
Source File: AppConfigHandler.java From onos with Apache License 2.0 | 5 votes |
private Set<FilteringObjective.Builder> getVRouterFlowObjBuilders(Set<MacAddress> macAddresses) { ImmutableSet.Builder<FilteringObjective.Builder> setBuilder = ImmutableSet.builder(); macAddresses.forEach(macAddress -> { FilteringObjective.Builder fobuilder = DefaultFilteringObjective.builder(); fobuilder.withKey(Criteria.matchInPort(PortNumber.ANY)) .addCondition(Criteria.matchEthDst(macAddress)) .permit() .withPriority(SegmentRoutingService.DEFAULT_PRIORITY) .fromApp(srManager.appId); setBuilder.add(fobuilder); }); return setBuilder.build(); }
Example #18
Source File: FabricFilteringPipelinerTest.java From onos with Apache License 2.0 | 5 votes |
/** * Test double VLAN pop filtering objective Creates one rule for * ingress_port_vlan table and 3 rules for fwd_classifier table (IPv4, IPv6 * and MPLS unicast) when the condition is MAC + VLAN + INNER_VLAN. */ @Test public void testPopVlan() throws FabricPipelinerException { FilteringObjective filteringObjective = DefaultFilteringObjective.builder() .withKey(Criteria.matchInPort(PORT_1)) .addCondition(Criteria.matchEthDst(ROUTER_MAC)) .addCondition(Criteria.matchVlanId(VLAN_100)) .addCondition(Criteria.matchInnerVlanId(VLAN_200)) .withPriority(PRIORITY) .fromApp(APP_ID) .withMeta(DefaultTrafficTreatment.builder() .popVlan() .build()) .permit() .add(); ObjectiveTranslation actualTranslation = translator.translate(filteringObjective); Collection<FlowRule> expectedFlowRules = Lists.newArrayList(); // Ingress port vlan rule expectedFlowRules.add(buildExpectedVlanInPortRule( PORT_1, VLAN_100, VLAN_200, VlanId.NONE, FabricConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN)); // Forwarding classifier rules (ipv6, ipv4, mpls) expectedFlowRules.addAll(buildExpectedFwdClassifierRule( PORT_1, ROUTER_MAC, null, Ethernet.TYPE_IPV4, FilteringObjectiveTranslator.FWD_IPV4_ROUTING)); expectedFlowRules.addAll(buildExpectedFwdClassifierRule( PORT_1, ROUTER_MAC, null, Ethernet.TYPE_IPV6, FilteringObjectiveTranslator.FWD_IPV6_ROUTING)); expectedFlowRules.addAll(buildExpectedFwdClassifierRule( PORT_1, ROUTER_MAC, null, Ethernet.MPLS_UNICAST, FilteringObjectiveTranslator.FWD_MPLS)); ObjectiveTranslation expectedTranslation = buildExpectedTranslation(expectedFlowRules); assertEquals(expectedTranslation, actualTranslation); }
Example #19
Source File: FilteringObjectiveTranslator.java From onos with Apache License 2.0 | 5 votes |
private Collection<FlowRule> ipFwdClassifierRules( PortNumber inPort, MacAddress dstMac, FilteringObjective obj) throws FabricPipelinerException { final Collection<FlowRule> flowRules = Lists.newArrayList(); flowRules.add(fwdClassifierRule( inPort, Ethernet.TYPE_IPV4, dstMac, null, fwdClassifierTreatment(FWD_IPV4_ROUTING), obj)); flowRules.add(fwdClassifierRule( inPort, Ethernet.TYPE_IPV6, dstMac, null, fwdClassifierTreatment(FWD_IPV6_ROUTING), obj)); return flowRules; }
Example #20
Source File: FlowObjectiveCompositionTree.java From onos with Apache License 2.0 | 5 votes |
protected List<FilteringObjective> updateFilterParallel(FilteringObjective filteringObjective) { List<FilteringObjective> leftUpdates = this.leftChild.updateFilter(filteringObjective); List<FilteringObjective> rightUpdates = this.rightChild.updateFilter(filteringObjective); List<FilteringObjective> updates = new ArrayList<>(); updates.addAll(leftUpdates); updates.addAll(rightUpdates); return this.filterTable.updateFilter(updates); }
Example #21
Source File: FilteringObjectiveCodecTest.java From onos with Apache License 2.0 | 5 votes |
/** * Sets up for each test. * Creates a context and fetches the FilteringObjective codec. */ @Before public void setUp() { context = new MockCodecContext(); filteringObjectiveCodec = context.codec(FilteringObjective.class); assertThat(filteringObjectiveCodec, notNullValue()); context.registerService(CoreService.class, mockCoreService); }
Example #22
Source File: XconnectManager.java From onos with Apache License 2.0 | 5 votes |
/** * Creates a filtering objective builder for XConnect. * * @param key XConnect key * @param port XConnect ports * @param filtered true if this is a filtered port * @return next objective builder */ private FilteringObjective.Builder filterObjBuilder(XconnectKey key, PortNumber port, boolean filtered) { FilteringObjective.Builder fob = DefaultFilteringObjective.builder(); fob.withKey(Criteria.matchInPort(port)) .addCondition(Criteria.matchEthDst(MacAddress.NONE)) .withPriority(XCONNECT_PRIORITY); if (filtered) { fob.addCondition(Criteria.matchVlanId(key.vlanId())); } else { fob.addCondition(Criteria.matchVlanId(VlanId.ANY)); } return fob.permit().fromApp(appId); }
Example #23
Source File: SpringOpenTTP.java From onos with Apache License 2.0 | 5 votes |
@Override public void filter(FilteringObjective filteringObjective) { if (filteringObjective.type() == FilteringObjective.Type.PERMIT) { log.debug("processing PERMIT filter objective"); processFilter(filteringObjective, filteringObjective.op() == Objective.Operation.ADD, filteringObjective.appId()); } else { log.debug("filter objective other than PERMIT not supported"); fail(filteringObjective, ObjectiveError.UNSUPPORTED); } }
Example #24
Source File: FlowObjectiveManager.java From onos with Apache License 2.0 | 5 votes |
@Override public void run() { try { Pipeliner pipeliner = getDevicePipeliner(deviceId); if (pipeliner != null) { if (objective instanceof NextObjective) { nextToDevice.put(objective.id(), deviceId); pipeliner.next((NextObjective) objective); } else if (objective instanceof ForwardingObjective) { pipeliner.forward((ForwardingObjective) objective); } else { pipeliner.filter((FilteringObjective) objective); } //Attempts to check if pipeliner is null for retry attempts } else if (numAttempts < INSTALL_RETRY_ATTEMPTS) { Thread.sleep(INSTALL_RETRY_INTERVAL); executor.execute(new ObjectiveProcessor(deviceId, objective, numAttempts + 1, executor)); } else { // Otherwise we've tried a few times and failed, report an // error back to the user. objective.context().ifPresent( c -> c.onError(objective, ObjectiveError.NOPIPELINER)); } //Exception thrown } catch (Exception e) { log.warn("Exception while processing flow objective", e); } }
Example #25
Source File: CorsaPipelineV3.java From onos with Apache License 2.0 | 5 votes |
@Override protected Builder processEthFiler(FilteringObjective filt, EthCriterion eth, PortCriterion port) { log.debug("adding rule for MAC: {}", eth.mac()); TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); selector.matchEthDst(eth.mac()); selector.matchInPort(port.port()); treatment.transition(ETHER_TABLE); return DefaultFlowRule.builder() .withSelector(selector.build()) .withTreatment(treatment.build()) .withPriority(CONTROLLER_PRIORITY) .makePermanent() .forTable(L3_IF_MAC_DA_TABLE); }
Example #26
Source File: OvsCorsaPipeline.java From onos with Apache License 2.0 | 5 votes |
protected FlowRule.Builder processEthFiler(FilteringObjective filt, EthCriterion eth, PortCriterion port) { log.debug("adding rule for MAC: {}", eth.mac()); TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); selector.matchEthDst(eth.mac()); treatment.transition(VLAN_MPLS_TABLE); return DefaultFlowRule.builder() .forDevice(deviceId) .withSelector(selector.build()) .withTreatment(treatment.build()) .withPriority(CONTROLLER_PRIORITY) .makePermanent() .forTable(MAC_TABLE); }
Example #27
Source File: OvsCorsaPipeline.java From onos with Apache License 2.0 | 5 votes |
@Override protected FlowRule.Builder processIpFilter(FilteringObjective filt, IPCriterion ip, PortCriterion port) { log.debug("adding rule for IP: {}", ip.ip()); TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); selector.matchEthType(Ethernet.TYPE_IPV4); selector.matchIPDst(ip.ip()); treatment.transition(LOCAL_TABLE); return DefaultFlowRule.builder() .withSelector(selector.build()) .withTreatment(treatment.build()) .withPriority(HIGHEST_PRIORITY) .makePermanent() .forTable(FIB_TABLE); }
Example #28
Source File: AbstractCorsaPipeline.java From onos with Apache License 2.0 | 5 votes |
@Override public void filter(FilteringObjective filteringObjective) { if (filteringObjective.type() == FilteringObjective.Type.PERMIT) { processFilter(filteringObjective, filteringObjective.op() == ADD, filteringObjective.appId()); } else { fail(filteringObjective, ObjectiveError.UNSUPPORTED); } }
Example #29
Source File: OltPipeline.java From onos with Apache License 2.0 | 5 votes |
private void buildAndApplyRule(FilteringObjective filter, TrafficSelector selector, TrafficTreatment treatment) { FlowRule rule = DefaultFlowRule.builder() .fromApp(filter.appId()) .forDevice(deviceId) .forTable(0) .makePermanent() .withSelector(selector) .withTreatment(treatment) .withPriority(filter.priority()) .build(); FlowRuleOperations.Builder opsBuilder = FlowRuleOperations.builder(); switch (filter.type()) { case PERMIT: opsBuilder.add(rule); break; case DENY: opsBuilder.remove(rule); break; default: log.warn("Unknown filter type : {}", filter.type()); fail(filter, ObjectiveError.UNSUPPORTED); } applyFlowRules(opsBuilder, filter); }
Example #30
Source File: OltPipeline.java From onos with Apache License 2.0 | 5 votes |
private void provisionEthTypeBasedFilter(FilteringObjective filter, EthTypeCriterion ethType, Instructions.OutputInstruction output) { Instruction meter = filter.meta().metered(); Instruction writeMetadata = filter.meta().writeMetadata(); Criterion vlanId = filterForCriterion(filter.conditions(), Criterion.Type.VLAN_VID); TrafficSelector selector = buildSelector(filter.key(), ethType, vlanId); TrafficTreatment treatment = buildTreatment(output, meter, writeMetadata); buildAndApplyRule(filter, selector, treatment); }