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