use of org.onosproject.openstacknode.api.OpenstackNode in project onos by opennetworkinglab.
the class OpenstackSwitchingArpHandler method setArpReplyRuleForGeneve.
/**
* Installs flow rules to match ARP reply packets only for GENEVE.
*
* @param port instance port
* @param install installation flag
*/
private void setArpReplyRuleForGeneve(InstancePort port, boolean install) {
OpenstackNode localNode = osNodeService.node(port.deviceId());
TrafficSelector selector = getArpReplySelectorForGeneve(port);
setLocalArpReplyTreatmentForGeneve(selector, port, install);
setRemoteArpTreatmentForTunnel(selector, port, localNode, install);
}
use of org.onosproject.openstacknode.api.OpenstackNode in project onos by opennetworkinglab.
the class OpenstackSwitchingArpHandler method setRemoteArpTreatmentForTunnel.
// a helper method
private void setRemoteArpTreatmentForTunnel(TrafficSelector selector, InstancePort port, OpenstackNode localNode, boolean install) {
for (OpenstackNode remoteNode : osNodeService.completeNodes(COMPUTE)) {
if (!remoteNode.intgBridge().equals(port.deviceId())) {
PortNumber portNum = tunnelPortNumByNetId(port.networkId(), osNetworkService, remoteNode);
TrafficTreatment treatmentToRemote = DefaultTrafficTreatment.builder().extension(buildExtension(deviceService, remoteNode.intgBridge(), localNode.dataIp().getIp4Address()), remoteNode.intgBridge()).setOutput(portNum).build();
osFlowRuleService.setRule(appId, remoteNode.intgBridge(), selector, treatmentToRemote, PRIORITY_ARP_REQUEST_RULE, ARP_TABLE, install);
}
}
}
use of org.onosproject.openstacknode.api.OpenstackNode in project onos by opennetworkinglab.
the class OpenstackSwitchingHandler method setForwardingRulesForTunnel.
/**
* Configures the flow rules which are used for L2 packet switching.
* Note that these rules will be inserted in switching table (table 5).
*
* @param instPort instance port object
* @param install install flag, add the rule if true, remove it otherwise
*/
private void setForwardingRulesForTunnel(InstancePort instPort, boolean install) {
// switching rules for the instPorts in the same node
TrafficSelector selector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPDst(instPort.ipAddress().toIpPrefix()).matchTunnelId(getVni(instPort)).build();
TrafficTreatment treatment = DefaultTrafficTreatment.builder().setEthDst(instPort.macAddress()).setOutput(instPort.portNumber()).build();
osFlowRuleService.setRule(appId, instPort.deviceId(), selector, treatment, PRIORITY_SWITCHING_RULE, FORWARDING_TABLE, install);
// switching rules for the instPorts in the remote node
OpenstackNode localNode = osNodeService.node(instPort.deviceId());
if (localNode == null) {
final String error = String.format("Cannot find openstack node for %s", instPort.deviceId());
throw new IllegalStateException(error);
}
osNodeService.completeNodes(COMPUTE).stream().filter(remoteNode -> !remoteNode.intgBridge().equals(localNode.intgBridge())).forEach(remoteNode -> {
PortNumber portNum = tunnelPortNumByNetId(instPort.networkId(), osNetworkService, remoteNode);
TrafficTreatment treatmentToRemote = DefaultTrafficTreatment.builder().extension(buildExtension(deviceService, remoteNode.intgBridge(), localNode.dataIp().getIp4Address()), remoteNode.intgBridge()).setOutput(portNum).build();
osFlowRuleService.setRule(appId, remoteNode.intgBridge(), selector, treatmentToRemote, PRIORITY_SWITCHING_RULE, FORWARDING_TABLE, install);
});
}
use of org.onosproject.openstacknode.api.OpenstackNode in project onos by opennetworkinglab.
the class OpenstackK8sIntegrationManager method setNodePortEgressRules.
private void setNodePortEgressRules(IpAddress k8sNodeIp, String osK8sExtPortName, boolean install) {
InstancePort instPort = instPortByNodeIp(k8sNodeIp);
if (instPort == null) {
return;
}
OpenstackNode osNode = osNodeByNodeIp(k8sNodeIp);
if (osNode == null) {
return;
}
PortNumber osK8sExtPortNum = portNumberByNodeIpAndPortName(k8sNodeIp, osK8sExtPortName);
Port phyPort = phyPortByInstPort(instPort);
if (phyPort == null) {
log.warn("No phys interface found for instance port {}", instPort);
return;
}
TrafficSelector selector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchInPort(osK8sExtPortNum).build();
TrafficTreatment treatment = DefaultTrafficTreatment.builder().setEthSrc(instPort.macAddress()).setOutput(phyPort.number()).build();
osFlowRuleService.setRule(appId, osNode.intgBridge(), selector, treatment, PRIORITY_CNI_PT_NODE_PORT_IP_RULE, PRE_FLAT_TABLE, install);
setJumpRules(osK8sExtPortNum, osNode, install);
}
use of org.onosproject.openstacknode.api.OpenstackNode in project onos by opennetworkinglab.
the class OpenstackK8sIntegrationManager method setNodeToPodIpRules.
private void setNodeToPodIpRules(IpAddress k8sNodeIp, IpPrefix podCidr, IpPrefix serviceCidr, IpAddress gatewayIp, String osK8sIntPortName, MacAddress k8sIntOsPortMac, boolean install) {
OpenstackNode osNode = osNodeByNodeIp(k8sNodeIp);
if (osNode == null) {
return;
}
PortNumber osK8sIntPortNum = osNode.portNumByName(osK8sIntPortName);
if (osK8sIntPortNum == null) {
return;
}
TrafficSelector originalPodSelector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPSrc(IpPrefix.valueOf(k8sNodeIp, 32)).matchIPDst(podCidr).build();
TrafficSelector transformedPodSelector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPSrc(IpPrefix.valueOf(k8sNodeIp, 32)).matchIPDst(IpPrefix.valueOf(shiftIpDomain(podCidr.toString(), SHIFTED_IP_PREFIX))).build();
TrafficSelector serviceSelector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPSrc(IpPrefix.valueOf(k8sNodeIp, 32)).matchIPDst(serviceCidr).build();
TrafficTreatment treatment = DefaultTrafficTreatment.builder().setIpSrc(gatewayIp).setEthSrc(k8sIntOsPortMac).setOutput(osK8sIntPortNum).build();
osFlowRuleService.setRule(appId, osNode.intgBridge(), originalPodSelector, treatment, PRIORITY_CNI_PT_IP_RULE, FLAT_TABLE, install);
osFlowRuleService.setRule(appId, osNode.intgBridge(), transformedPodSelector, treatment, PRIORITY_CNI_PT_IP_RULE, FLAT_TABLE, install);
osFlowRuleService.setRule(appId, osNode.intgBridge(), serviceSelector, treatment, PRIORITY_CNI_PT_IP_RULE, FLAT_TABLE, install);
}
Aggregations