org.onosproject.net.flow.TrafficSelector Java Examples
The following examples show how to use
org.onosproject.net.flow.TrafficSelector.
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: TunnellingConnectivityManager.java From onos with Apache License 2.0 | 6 votes |
/** * Pushes the flow rules for forwarding BGP TCP packets to controller. * It is called when switches are connected and available. */ public void notifySwitchAvailable() { // control plane OVS is available, push default flows TrafficSelector selectorDst = DefaultTrafficSelector.builder() .matchEthType(Ethernet.TYPE_IPV4) .matchIPProtocol(IPv4.PROTOCOL_TCP) .matchTcpDst(TpPort.tpPort(BGP_PORT)) .build(); TrafficSelector selectorSrc = DefaultTrafficSelector.builder() .matchEthType(Ethernet.TYPE_IPV4) .matchIPProtocol(IPv4.PROTOCOL_TCP) .matchTcpSrc(TpPort.tpPort(BGP_PORT)) .build(); TrafficTreatment treatment = DefaultTrafficTreatment.builder() .punt() .build(); ForwardingObjective puntSrc = DefaultForwardingObjective.builder() .fromApp(appId) .makePermanent() .withSelector(selectorSrc) .withTreatment(treatment) .withFlag(ForwardingObjective.Flag.VERSATILE) .add(); flowObjectiveService.forward(bgpSpeaker.connectPoint().deviceId(), puntSrc); ForwardingObjective puntDst = DefaultForwardingObjective.builder() .fromApp(appId) .makePermanent() .withSelector(selectorDst) .withTreatment(treatment) .withFlag(ForwardingObjective.Flag.VERSATILE) .add(); flowObjectiveService.forward(bgpSpeaker.connectPoint().deviceId(), puntDst); log.info("Sent punt forwarding objective to {}", bgpSpeaker.connectPoint().deviceId()); }
Example #2
Source File: K8sSwitchingArpHandler.java From onos with Apache License 2.0 | 6 votes |
private void setDefaultArpRuleForProxyMode(K8sNode node, boolean install) { TrafficSelector selector = DefaultTrafficSelector.builder() .matchEthType(EthType.EtherType.ARP.ethType().toShort()) .build(); TrafficTreatment treatment = DefaultTrafficTreatment.builder() .punt() .build(); k8sFlowRuleService.setRule( appId, node.intgBridge(), selector, treatment, PRIORITY_ARP_CONTROL_RULE, ARP_TABLE, install ); }
Example #3
Source File: OfdpaGroupHandlerUtility.java From onos with Apache License 2.0 | 6 votes |
/** * The purpose of this function is to verify if the hashed next * objective is supported by the current pipeline. * * @param nextObjective the hashed objective to verify * @return true if the hashed objective is supported. Otherwise false. */ public static boolean verifyHashedNextObjective(NextObjective nextObjective) { // if it is not hashed, there is something wrong; if (nextObjective.type() != HASHED) { return false; } // The case non supported is the MPLS-ECMP. For now, we try // to create a MPLS-ECMP for the transport of a VPWS. The // necessary info are contained in the meta selector. In particular // we are looking for the case of BoS==False; TrafficSelector metaSelector = nextObjective.meta(); if (metaSelector != null && isNotMplsBos(metaSelector)) { return false; } return true; }
Example #4
Source File: K8sNodePortHandler.java From onos with Apache License 2.0 | 6 votes |
private void setDefaultExtEgrRule(K8sNode k8sNode, boolean install) { TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder() .matchInPort(PortNumber.LOCAL) .matchEthType(Ethernet.TYPE_IPV4); TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder() .setOutput(k8sNode.extBridgePortNum()); k8sFlowRuleService.setRule( appId, k8sNode.extBridge(), sBuilder.build(), tBuilder.build(), PRIORITY_NODE_PORT_INTER_RULE, EXT_ENTRY_TABLE, install); }
Example #5
Source File: DefaultVirtualFlowRuleProviderTest.java From onos with Apache License 2.0 | 6 votes |
@Test public void removeVirtualizeFlowRule() { TrafficSelector ts = DefaultTrafficSelector.builder().build(); TrafficTreatment tr = DefaultTrafficTreatment.builder() .setOutput(PORT_NUM2).build(); FlowRule r1 = DefaultFlowRule.builder() .forDevice(VDID) .withSelector(ts) .withTreatment(tr) .withPriority(10) .fromApp(vAppId) .makeTemporary(TIMEOUT) .build(); virtualProvider.removeFlowRule(VNET_ID, r1); assertEquals("0 rules should exist", 0, virtualProvider.flowRuleService.getFlowRuleCount()); }
Example #6
Source File: OpenstackSecurityGroupHandler.java From onos with Apache License 2.0 | 6 votes |
private void buildMatchProto(TrafficSelector.Builder sBuilder, String protocol) { if (protocol != null) { switch (protocol.toUpperCase()) { case PROTO_ICMP: sBuilder.matchIPProtocol(IPv4.PROTOCOL_ICMP); break; case PROTO_TCP: sBuilder.matchIPProtocol(IPv4.PROTOCOL_TCP); break; case PROTO_UDP: sBuilder.matchIPProtocol(IPv4.PROTOCOL_UDP); break; default: } } }
Example #7
Source File: PacketRequestCodec.java From onos with Apache License 2.0 | 6 votes |
@Override public PacketRequest decode(ObjectNode json, CodecContext context) { if (json == null || !json.isObject()) { return null; } final JsonCodec<TrafficSelector> trafficSelectorCodec = context.codec(TrafficSelector.class); TrafficSelector trafficSelector = trafficSelectorCodec.decode( get(json, TRAFFIC_SELECTOR), context); NodeId nodeId = NodeId.nodeId(extractMember(NODE_ID, json)); PacketPriority priority = PacketPriority.valueOf(extractMember(PRIORITY, json)); CoreService coreService = context.getService(CoreService.class); // TODO check appId (currently hardcoded - should it be read from json node?) ApplicationId appId = coreService.registerApplication(REST_APP_ID); DeviceId deviceId = null; JsonNode node = json.get(DEVICE_ID); if (node != null) { deviceId = DeviceId.deviceId(node.asText()); } return new DefaultPacketRequest(trafficSelector, priority, appId, nodeId, Optional.ofNullable(deviceId)); }
Example #8
Source File: MultiPointToSinglePointIntent.java From onos with Apache License 2.0 | 6 votes |
/** * Creates a new multi-to-single point connectivity intent for the specified * traffic selector and treatment with filtered connect point. * * @param appId application identifier * @param key intent key * @param selector traffic selector * @param treatment treatment * @param ingressPoints set of filtered ports from which ingress traffic originates * @param egressPoint filtered port to which traffic will egress * @param constraints constraints to apply to the intent * @param priority priority to use for flows generated by this intent * @throws NullPointerException if {@code ingressPoints} or * {@code egressPoint} is null. * @throws IllegalArgumentException if the size of {@code ingressPoints} is * not more than 1 */ private MultiPointToSinglePointIntent(ApplicationId appId, Key key, TrafficSelector selector, TrafficTreatment treatment, Set<FilteredConnectPoint> ingressPoints, FilteredConnectPoint egressPoint, List<Constraint> constraints, int priority, ResourceGroup resourceGroup) { super(appId, key, ImmutableSet.of(), selector, treatment, constraints, priority, resourceGroup); checkNotNull(ingressPoints); checkArgument(!ingressPoints.isEmpty(), "Ingress point set cannot be empty"); checkNotNull(egressPoint); checkArgument(!ingressPoints.contains(egressPoint), "Set of ingresses should not contain egress (egress: %s)", egressPoint); this.ingressPoints = ImmutableSet.copyOf(ingressPoints); this.egressPoint = egressPoint; }
Example #9
Source File: ControlPlaneRedirectManager.java From onos with Apache License 2.0 | 6 votes |
static TrafficSelector buildNdpSelector(PortNumber inPort, VlanId vlanId, IpPrefix srcIp, IpPrefix dstIp, byte subProto, MacAddress srcMac) { TrafficSelector.Builder selector = buildBaseSelectorBuilder(inPort, null, null, vlanId); selector.matchEthType(TYPE_IPV6) .matchIPProtocol(PROTOCOL_ICMP6) .matchIcmpv6Type(subProto); if (srcIp != null) { selector.matchIPv6Src(srcIp); } if (dstIp != null) { selector.matchIPv6Dst(dstIp); } if (srcMac != null) { selector.matchEthSrc(srcMac); } return selector.build(); }
Example #10
Source File: K8sRoutingArpHandler.java From onos with Apache License 2.0 | 6 votes |
private void setPodArpReplyRule(K8sNode k8sNode, boolean install) { TrafficSelector selector = DefaultTrafficSelector.builder() .matchInPort(k8sNode.extBridgePortNum()) .matchEthType(Ethernet.TYPE_ARP) .matchArpOp(ARP.OP_REPLY) .build(); TrafficTreatment treatment = DefaultTrafficTreatment.builder() .setOutput(k8sNode.extToIntgPatchPortNum()) .build(); k8sFlowRuleService.setRule( appId, k8sNode.extBridge(), selector, treatment, PRIORITY_ARP_POD_RULE, EXT_ENTRY_TABLE, install ); }
Example #11
Source File: OpenstackSwitchingArpHandler.java From onos with Apache License 2.0 | 6 votes |
private void setDefaultArpRuleForProxyMode(OpenstackNode osNode, boolean install) { TrafficSelector selector = DefaultTrafficSelector.builder() .matchEthType(EthType.EtherType.ARP.ethType().toShort()) .build(); TrafficTreatment treatment = DefaultTrafficTreatment.builder() .punt() .build(); osFlowRuleService.setRule( appId, osNode.intgBridge(), selector, treatment, PRIORITY_ARP_CONTROL_RULE, ARP_TABLE, install ); }
Example #12
Source File: OpenstackSwitchingHandler.java From onos with Apache License 2.0 | 6 votes |
private void setPortBlockRules(InstancePort instPort, boolean install) { TrafficSelector selector = DefaultTrafficSelector.builder() .matchInPort(instPort.portNumber()) .build(); TrafficTreatment treatment = DefaultTrafficTreatment.builder() .drop() .build(); osFlowRuleService.setRule( appId, instPort.deviceId(), selector, treatment, PRIORITY_ADMIN_RULE, VTAG_TABLE, install); }
Example #13
Source File: LinkCollectionCompiler.java From onos with Apache License 2.0 | 6 votes |
/** * The method generates a selector starting from * the encapsulation information (type and label to match). * * @param selectorBuilder the builder to update * @param type the type of encapsulation * @param identifier the label to match */ private void updateSelectorFromEncapsulation(TrafficSelector.Builder selectorBuilder, EncapsulationType type, Identifier<?> identifier) { switch (type) { case MPLS: MplsLabel label = (MplsLabel) identifier; selectorBuilder.matchMplsLabel(label); selectorBuilder.matchEthType(Ethernet.MPLS_UNICAST); break; case VLAN: VlanId id = (VlanId) identifier; selectorBuilder.matchVlanId(id); break; default: throw new IntentCompilationException(UNKNOWN_ENCAPSULATION); } }
Example #14
Source File: DefaultVirtualPacketProviderTest.java From onos with Apache License 2.0 | 6 votes |
@Before public void setUp() { virtualProvider = new DefaultVirtualPacketProvider(); virtualProvider.coreService = new CoreServiceAdapter(); virtualProvider.vnaService = new TestVirtualNetworkAdminService(); providerService = new TestVirtualPacketProviderService(); testPacketService = new TestPacketService(); virtualProvider.packetService = testPacketService; providerManager = new VirtualProviderManager(); virtualProvider.providerRegistryService = providerManager; providerManager.registerProviderService(VNET_ID, providerService); virtualProvider.activate(); vAppId = new TestApplicationId(0, "Virtual App"); TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); selector.matchEthType(Ethernet.TYPE_IPV4); virtualProvider.startPacketHandling(); }
Example #15
Source File: OvsOfdpaPipeline.java From onos with Apache License 2.0 | 6 votes |
@Override protected List<List<FlowRule>> processEthDstOnlyFilter(EthCriterion ethCriterion, ApplicationId applicationId) { TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); selector.matchEthType(Ethernet.TYPE_IPV4); selector.matchEthDst(ethCriterion.mac()); treatment.transition(UNICAST_ROUTING_TABLE); FlowRule rule = DefaultFlowRule.builder() .forDevice(deviceId) .withSelector(selector.build()) .withTreatment(treatment.build()) .withPriority(DEFAULT_PRIORITY) .fromApp(applicationId) .makePermanent() .forTable(TMAC_TABLE).build(); return ImmutableList.of(ImmutableList.of(rule)); }
Example #16
Source File: DefaultVirtualFlowRuleProvider.java From onos with Apache License 2.0 | 6 votes |
/** * Generates the corresponding flow rules for the physical network. * * @param networkId The virtual network identifier * @param ingressPoint The ingress point of the physical network * @param egressPoint The egress point of the physical network * @param commonSelector A common traffic selector between the virtual * and physical flow rules * @param commonTreatment A common traffic treatment between the virtual * and physical flow rules * @param flowRule The virtual flow rule to be translated * @return A set of flow rules for the physical network */ private Set<FlowRule> generateRules(NetworkId networkId, ConnectPoint ingressPoint, ConnectPoint egressPoint, TrafficSelector commonSelector, TrafficTreatment commonTreatment, FlowRule flowRule) { if (ingressPoint.deviceId().equals(egressPoint.deviceId()) || egressPoint.port().isLogical()) { return generateRuleForSingle(networkId, ingressPoint, egressPoint, commonSelector, commonTreatment, flowRule); } else { return generateRuleForMulti(networkId, ingressPoint, egressPoint, commonSelector, commonTreatment, flowRule); } }
Example #17
Source File: FabricForwardingPipelineTest.java From onos with Apache License 2.0 | 6 votes |
@Test public void testMpls() throws FabricPipelinerException { TrafficSelector selector = DefaultTrafficSelector.builder() .matchEthType(Ethernet.MPLS_UNICAST) .matchMplsLabel(MPLS_10) .matchMplsBos(true) .build(); TrafficSelector expectedSelector = DefaultTrafficSelector.builder() .matchMplsLabel(MPLS_10) .build(); PiActionParam nextIdParam = new PiActionParam(FabricConstants.NEXT_ID, NEXT_ID_1); PiAction setNextIdAction = PiAction.builder() .withId(FabricConstants.FABRIC_INGRESS_FORWARDING_POP_MPLS_AND_NEXT) .withParameter(nextIdParam) .build(); TrafficTreatment treatment = DefaultTrafficTreatment.builder() .piTableAction(setNextIdAction) .build(); testSpecificForward(FabricConstants.FABRIC_INGRESS_FORWARDING_MPLS, expectedSelector, selector, NEXT_ID_1, treatment); }
Example #18
Source File: OltPipeline.java From onos with Apache License 2.0 | 6 votes |
private void provisionDhcp(FilteringObjective filter, EthTypeCriterion ethType, IPProtocolCriterion ipProto, UdpPortCriterion udpSrcPort, UdpPortCriterion udpDstPort, Instructions.OutputInstruction output) { Instruction meter = filter.meta().metered(); Instruction writeMetadata = filter.meta().writeMetadata(); VlanIdCriterion vlanId = (VlanIdCriterion) filterForCriterion(filter.conditions(), Criterion.Type.VLAN_VID); TrafficSelector selector = buildSelector(filter.key(), ethType, ipProto, udpSrcPort, udpDstPort, vlanId); TrafficTreatment treatment = buildTreatment(output, meter, writeMetadata); buildAndApplyRule(filter, selector, treatment); }
Example #19
Source File: K8sFlowRuleManager.java From onos with Apache License 2.0 | 6 votes |
@Override public void setRule(ApplicationId appId, DeviceId deviceId, TrafficSelector selector, TrafficTreatment treatment, int priority, int tableType, boolean install) { FlowRule.Builder flowRuleBuilder = DefaultFlowRule.builder() .forDevice(deviceId) .withSelector(selector) .withTreatment(treatment) .withPriority(priority) .fromApp(appId) .forTable(tableType); if (priority == PRIORITY_SNAT_RULE) { flowRuleBuilder.makeTemporary(TIMEOUT_SNAT_RULE); } else { flowRuleBuilder.makePermanent(); } applyRule(flowRuleBuilder.build(), install); }
Example #20
Source File: PointToPointIntentCompiler.java From onos with Apache License 2.0 | 6 votes |
/** * Manufactures flow rule with treatment that is defined by failover * group and traffic selector determined by ingress port of the intent. * * @param intent intent which is being compiled (for appId) * @return a list of a singular flow rule with fast failover * outport traffic treatment */ private List<FlowRule> createFailoverFlowRules(PointToPointIntent intent) { List<FlowRule> flowRules = new ArrayList<>(); ConnectPoint ingress = intent.filteredIngressPoint().connectPoint(); DeviceId deviceId = ingress.deviceId(); // flow rule with failover traffic treatment TrafficSelector trafficSelector = DefaultTrafficSelector.builder(intent.selector()) .matchInPort(ingress.port()).build(); FlowRule.Builder flowRuleBuilder = DefaultFlowRule.builder(); flowRules.add(flowRuleBuilder.withSelector(trafficSelector) .withTreatment(buildFailoverTreatment(deviceId, makeGroupKey(intent.id()))) .fromApp(intent.appId()) .makePermanent() .forDevice(deviceId) .withPriority(PRIORITY) .build()); return flowRules; }
Example #21
Source File: ClassifierServiceImpl.java From onos with Apache License 2.0 | 6 votes |
@Override public void programL3InPortClassifierRules(DeviceId deviceId, PortNumber inPort, MacAddress srcMac, MacAddress dstMac, SegmentationId actionVni, Objective.Operation type) { TrafficSelector selector = DefaultTrafficSelector.builder() .matchInPort(inPort).matchEthSrc(srcMac).matchEthDst(dstMac) .build(); TrafficTreatment treatment = DefaultTrafficTreatment.builder() .setTunnelId(Long.parseLong(actionVni.segmentationId())).build(); ForwardingObjective.Builder objective = DefaultForwardingObjective .builder().withTreatment(treatment).withSelector(selector) .fromApp(appId).withFlag(Flag.SPECIFIC) .withPriority(L3_CLASSIFIER_PRIORITY); if (type.equals(Objective.Operation.ADD)) { log.debug("L3InternalClassifierRules-->ADD"); flowObjectiveService.forward(deviceId, objective.add()); } else { log.debug("L3InternalClassifierRules-->REMOVE"); flowObjectiveService.forward(deviceId, objective.remove()); } }
Example #22
Source File: PicaPipeline.java From onos with Apache License 2.0 | 5 votes |
private Collection<FlowRule> processVersatile(ForwardingObjective fwd) { log.debug("Processing versatile forwarding objective"); TrafficSelector selector = fwd.selector(); TrafficTreatment treatment = fwd.treatment(); Collection<FlowRule> flowrules = new ArrayList<FlowRule>(); // first add this rule for basic single-table operation // or non-ARP related multi-table operation FlowRule rule = DefaultFlowRule.builder() .forDevice(deviceId) .withSelector(selector) .withTreatment(treatment) .withPriority(fwd.priority()) .fromApp(fwd.appId()) .makePermanent() .forTable(ACL_TABLE).build(); flowrules.add(rule); EthTypeCriterion ethType = (EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE); if (ethType == null) { log.warn("No ethType in versatile forwarding obj. Not processing further."); return flowrules; } // now deal with possible mix of ARP with filtering objectives // in multi-table scenarios if (ethType.ethType().toShort() == Ethernet.TYPE_ARP) { if (filters.isEmpty()) { pendingVersatiles.add(fwd); return flowrules; } for (Filter filter : filters) { flowrules.addAll(processVersatilesWithFilters(filter, fwd)); } } return flowrules; }
Example #23
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 #24
Source File: OpenstackSecurityGroupHandler.java From onos with Apache License 2.0 | 5 votes |
private void buildMatches(TrafficSelector.Builder sBuilder, SecurityGroupRule sgRule, Ip4Address vmIp, IpPrefix remoteIp, String netId) { buildTunnelId(sBuilder, netId); buildMatchEthType(sBuilder, sgRule.getEtherType()); buildMatchDirection(sBuilder, sgRule.getDirection(), vmIp); buildMatchProto(sBuilder, sgRule.getProtocol()); buildMatchPort(sBuilder, sgRule.getProtocol(), sgRule.getDirection(), sgRule.getPortRangeMin() == null ? 0 : sgRule.getPortRangeMin(), sgRule.getPortRangeMax() == null ? 0 : sgRule.getPortRangeMax()); buildMatchRemoteIp(sBuilder, remoteIp, sgRule.getDirection()); }
Example #25
Source File: Dhcp4HandlerImpl.java From onos with Apache License 2.0 | 5 votes |
private void requestServerDhcpPacket(Ip4Address serverIp) { TrafficSelector serverSelector = DefaultTrafficSelector.builder(SERVER_RELAY_SELECTOR) .matchIPSrc(serverIp.toIpPrefix()) .build(); packetService.requestPackets(serverSelector, PacketPriority.CONTROL, appId); }
Example #26
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 #27
Source File: ForwardingFunctionTypeTest.java From onos with Apache License 2.0 | 5 votes |
private void testFft(TrafficSelector selector, ForwardingFunctionType expectedFft) { ForwardingObjective fwd = DefaultForwardingObjective.builder() .withSelector(selector) .withFlag(ForwardingObjective.Flag.SPECIFIC) .nextStep(0) .fromApp(APP_ID) .add(); assertEquals(expectedFft, ForwardingFunctionType.getForwardingFunctionType(fwd)); }
Example #28
Source File: CastorArpManager.java From onos with Apache License 2.0 | 5 votes |
/** * Withdraws the requested ARP packets. */ private void withdrawIntercepts() { if (deviceID != null && deviceID.isPresent()) { TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder(); selectorBuilder.matchEthType(TYPE_ARP); packetService.cancelPackets(selectorBuilder.build(), CONTROL, appId, deviceID); } }
Example #29
Source File: FibInstallerTest.java From onos with Apache License 2.0 | 5 votes |
/** * Creates a next objective with the given parameters. * * @param srcMac source MAC address * @param dstMac destination MAC address * @param port port number * @param vlan vlan ID * @param add whether to create an add objective or remove objective * @return new next objective */ private NextObjective createNextObjective(MacAddress srcMac, MacAddress dstMac, PortNumber port, VlanId vlan, boolean add) { TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder() .setEthSrc(srcMac) .setEthDst(dstMac); TrafficSelector.Builder metabuilder = null; if (!vlan.equals(VlanId.NONE)) { treatment.pushVlan() .setVlanId(vlan) .setVlanPcp((byte) 0); } else { metabuilder = DefaultTrafficSelector.builder(); metabuilder.matchVlanId(VlanId.vlanId(FibInstaller.ASSIGNED_VLAN)); } treatment.setOutput(port); NextObjective.Builder nextBuilder = DefaultNextObjective.builder() .withId(NEXT_ID) .addTreatment(treatment.build()) .withType(NextObjective.Type.SIMPLE) .fromApp(APPID); if (metabuilder != null) { nextBuilder.withMeta(metabuilder.build()); } return add ? nextBuilder.add() : nextBuilder.remove(); }
Example #30
Source File: OpenstackSwitchingHandler.java From onos with Apache License 2.0 | 5 votes |
/** * Configures the flow rule which is for using VXLAN/GRE to tag the packet * based on the in_port number of a virtual instance. * Note that this rule will be inserted in vTag table. * * @param instPort instance port object * @param install install flag, add the rule if true, remove it otherwise */ private void setTunnelTagFlowRules(InstancePort instPort, short ethType, boolean install) { TrafficSelector selector = DefaultTrafficSelector.builder() .matchEthType(ethType) .matchInPort(instPort.portNumber()) .build(); TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder() .setTunnelId(getVni(instPort)); if (ethType == Ethernet.TYPE_ARP) { tBuilder.transition(ARP_TABLE); } else if (ethType == Ethernet.TYPE_IPV4) { tBuilder.transition(ACL_EGRESS_TABLE); } osFlowRuleService.setRule( appId, instPort.deviceId(), selector, tBuilder.build(), PRIORITY_TUNNEL_TAG_RULE, VTAG_TABLE, install); }