Search in sources :

Example 76 with TrafficSelector

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

the class K8sSwitchingHandler method setTunnelTagFlowRules.

/**
 * Configures the flow rule which is for using VXLAN/GRE/GENEVE 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 port kubernetes port object
 * @param install install flag, add the rule if true, remove it otherwise
 */
private void setTunnelTagFlowRules(K8sPort port, short ethType, boolean install) {
    TrafficSelector selector = DefaultTrafficSelector.builder().matchEthType(ethType).matchInPort(port.portNumber()).build();
    TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder().setTunnelId(getVni(port));
    if (ethType == Ethernet.TYPE_ARP) {
        tBuilder.transition(ARP_TABLE);
    } else if (ethType == Ethernet.TYPE_IPV4) {
        tBuilder.transition(JUMP_TABLE);
    }
    k8sFlowRuleService.setRule(appId, port.deviceId(), selector, tBuilder.build(), PRIORITY_TUNNEL_TAG_RULE, VTAG_TABLE, install);
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Example 77 with TrafficSelector

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

the class K8sSwitchingHandler method setLocalTunnelTagFlowRules.

private void setLocalTunnelTagFlowRules(K8sNode k8sNode, boolean install) {
    TrafficSelector selector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchInPort(k8sNode.intgEntryPortNum()).build();
    K8sNetwork net = k8sNetworkService.network(k8sNode.hostname());
    TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder().setTunnelId(Long.valueOf(net.segmentId())).transition(JUMP_TABLE);
    k8sFlowRuleService.setRule(appId, k8sNode.intgBridge(), selector, tBuilder.build(), PRIORITY_TUNNEL_TAG_RULE, VTAG_TABLE, install);
}
Also used : K8sNetwork(org.onosproject.k8snetworking.api.K8sNetwork) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Example 78 with TrafficSelector

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

the class K8sSwitchingHandler method setGatewayRulesForTunnel.

private void setGatewayRulesForTunnel(boolean install) {
    k8sNetworkService.networks().forEach(n -> {
        // switching rules for the instPorts in the same node
        TrafficSelector selector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPDst(IpPrefix.valueOf(n.gatewayIp(), 32)).matchTunnelId(Long.valueOf(n.segmentId())).build();
        TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(PortNumber.LOCAL).build();
        // FIXME: need to find a way to install the gateway rules into
        // right OVS
        k8sNodeService.completeNodes().forEach(node -> {
            k8sFlowRuleService.setRule(appId, node.intgBridge(), selector, treatment, PRIORITY_SWITCHING_RULE, FORWARDING_TABLE, install);
        });
    });
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Example 79 with TrafficSelector

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

the class K8sSwitchingHandler method setExtToIntgTunnelTagFlowRules.

private void setExtToIntgTunnelTagFlowRules(K8sNode k8sNode, boolean install) {
    TrafficSelector selector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchInPort(k8sNode.intgToExtPatchPortNum()).build();
    K8sNetwork net = k8sNetworkService.network(k8sNode.hostname());
    TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder().setTunnelId(Long.valueOf(net.segmentId())).transition(JUMP_TABLE);
    k8sFlowRuleService.setRule(appId, k8sNode.intgBridge(), selector, tBuilder.build(), PRIORITY_TUNNEL_TAG_RULE, VTAG_TABLE, install);
}
Also used : K8sNetwork(org.onosproject.k8snetworking.api.K8sNetwork) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Example 80 with TrafficSelector

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

the class RoadmManager method createConnection.

@Override
public FlowId createConnection(DeviceId deviceId, int priority, boolean isPermanent, int timeout, PortNumber inPort, PortNumber outPort, OchSignal ochSignal) {
    checkNotNull(deviceId);
    checkNotNull(inPort);
    checkNotNull(outPort);
    // Creation of selector.
    TrafficSelector selector = DefaultTrafficSelector.builder().add(Criteria.matchInPort(inPort)).add(Criteria.matchOchSignalType(OchSignalType.FIXED_GRID)).add(Criteria.matchLambda(ochSignal)).build();
    // Creation of treatment
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().add(Instructions.modL0Lambda(ochSignal)).add(Instructions.createOutput(outPort)).build();
    FlowRule.Builder flowBuilder = DefaultFlowRule.builder().forDevice(deviceId).fromApp(appId).withPriority(priority).withSelector(selector).withTreatment(treatment);
    if (isPermanent) {
        flowBuilder.makePermanent();
    } else {
        flowBuilder.makeTemporary(timeout);
    }
    FlowRule flowRule = flowBuilder.build();
    flowRuleService.applyFlowRules(flowRule);
    log.info("Created connection from input port {} to output port {}", inPort.toLong(), outPort.toLong());
    return flowRule.id();
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Aggregations

TrafficSelector (org.onosproject.net.flow.TrafficSelector)396 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)354 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)249 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)235 FlowRule (org.onosproject.net.flow.FlowRule)94 Test (org.junit.Test)85 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)84 PiAction (org.onosproject.net.pi.runtime.PiAction)54 ConnectPoint (org.onosproject.net.ConnectPoint)51 ForwardingObjective (org.onosproject.net.flowobjective.ForwardingObjective)48 DeviceId (org.onosproject.net.DeviceId)43 PortNumber (org.onosproject.net.PortNumber)43 List (java.util.List)42 NextObjective (org.onosproject.net.flowobjective.NextObjective)41 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)39 PiActionParam (org.onosproject.net.pi.runtime.PiActionParam)38 Instruction (org.onosproject.net.flow.instructions.Instruction)37 Criterion (org.onosproject.net.flow.criteria.Criterion)36 PiCriterion (org.onosproject.net.flow.criteria.PiCriterion)36 DefaultForwardingObjective (org.onosproject.net.flowobjective.DefaultForwardingObjective)35