use of org.onosproject.net.flow.instructions.ExtensionTreatment in project onos by opennetworkinglab.
the class OpenstackSecurityGroupHandler method initializeAclTable.
private void initializeAclTable(DeviceId deviceId, boolean install) {
ExtensionTreatment ctTreatment = niciraConnTrackTreatmentBuilder(driverService, deviceId).commit(true).build();
TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder();
sBuilder.matchEthType(Ethernet.TYPE_IPV4);
TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
tBuilder.extension(ctTreatment, deviceId).transition(JUMP_TABLE);
osFlowRuleService.setRule(appId, deviceId, sBuilder.build(), tBuilder.build(), PRIORITY_ACL_INGRESS_RULE, ACL_RECIRC_TABLE, install);
}
use of org.onosproject.net.flow.instructions.ExtensionTreatment in project onos by opennetworkinglab.
the class OpenstackVtapManager method setOutputTableForTunnel.
private void setOutputTableForTunnel(DeviceId deviceId, int tableId, PortNumber outPort, IpAddress serverIp, boolean install) {
log.debug("setOutputTableForTunnel[{}]: deviceId={}, tableId={}, outPort={}, serverIp={}", install ? "add" : "remove", deviceId, tableId, outPort, serverIp);
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder().setOutput(outPort);
if (tunnelNicira) {
ExtensionTreatment extensionTreatment = buildTunnelExtension(deviceId, serverIp);
if (extensionTreatment == null) {
return;
}
treatment.extension(extensionTreatment, deviceId);
}
FlowRule flowRule = DefaultFlowRule.builder().forDevice(deviceId).withSelector(selector.build()).withTreatment(treatment.build()).withPriority(PRIORITY_VTAP_OUTPUT_RULE).makePermanent().forTable(tableId).fromApp(appId).build();
log.debug("setOutputTableForTunnel flowRule={}, install={}", flowRule, install);
applyFlowRule(flowRule, install);
}
use of org.onosproject.net.flow.instructions.ExtensionTreatment in project onos by opennetworkinglab.
the class OpenstackVtapManager method buildResubmitExtension.
private ExtensionTreatment buildResubmitExtension(DeviceId deviceId, int tableId) {
Device device = deviceService.getDevice(deviceId);
if (device == null || !device.is(ExtensionTreatmentResolver.class)) {
log.warn("Nicira extension treatment is not supported");
return null;
}
ExtensionTreatmentResolver resolver = device.as(ExtensionTreatmentResolver.class);
ExtensionTreatment treatment = resolver.getExtensionInstruction(NICIRA_RESUBMIT_TABLE.type());
try {
treatment.setPropertyValue(TABLE_EXTENSION, ((short) tableId));
return treatment;
} catch (ExtensionPropertyException e) {
log.error("Failed to set nicira resubmit extension treatment for {}", deviceId);
return null;
}
}
use of org.onosproject.net.flow.instructions.ExtensionTreatment in project onos by opennetworkinglab.
the class K8sRoutingSnatHandler method setExtSnatUpstreamRule.
private void setExtSnatUpstreamRule(K8sNode k8sNode, boolean install) {
K8sNetwork net = k8sNetworkService.network(k8sNode.hostname());
if (net == null) {
return;
}
TrafficSelector selector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchInPort(k8sNode.extToIntgPatchPortNum()).matchEthDst(DEFAULT_GATEWAY_MAC).build();
TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
if (install) {
ExtensionTreatment natTreatment = RulePopulatorUtil.niciraConnTrackTreatmentBuilder(driverService, k8sNode.extBridge()).commit(true).natFlag(CT_NAT_SRC_FLAG).natAction(true).natIp(k8sNode.extBridgeIp()).natPortMin(TpPort.tpPort(TP_PORT_MINIMUM_NUM)).natPortMax(TpPort.tpPort(TP_PORT_MAXIMUM_NUM)).build();
tBuilder.extension(natTreatment, k8sNode.extBridge()).setEthSrc(k8sNode.extBridgeMac()).setEthDst(k8sNode.extGatewayMac());
if (k8sNode.mode() == PASSTHROUGH) {
tBuilder.setOutput(k8sNode.extToRouterPortNum());
} else {
if (MacAddress.valueOf(DEFAULT_EXTERNAL_GATEWAY_MAC).equals(k8sNode.extGatewayMac())) {
tBuilder.setOutput(k8sNode.extIntfPortNum());
} else {
tBuilder.setOutput(k8sNode.extBridgePortNum());
}
}
}
k8sFlowRuleService.setRule(appId, k8sNode.extBridge(), selector, tBuilder.build(), PRIORITY_STATEFUL_SNAT_RULE, EXT_ENTRY_TABLE, install);
}
use of org.onosproject.net.flow.instructions.ExtensionTreatment in project onos by opennetworkinglab.
the class K8sRoutingSnatHandler method setExtSnatDownstreamRule.
private void setExtSnatDownstreamRule(K8sNode k8sNode, boolean install) {
DeviceId deviceId = k8sNode.extBridge();
TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPDst(IpPrefix.valueOf(k8sNode.extBridgeIp(), HOST_PREFIX));
ExtensionTreatment natTreatment = RulePopulatorUtil.niciraConnTrackTreatmentBuilder(driverService, deviceId).commit(false).natAction(true).table((short) POD_RESOLUTION_TABLE).build();
TrafficTreatment treatment = DefaultTrafficTreatment.builder().setEthSrc(DEFAULT_GATEWAY_MAC).extension(natTreatment, deviceId).build();
k8sFlowRuleService.setRule(appId, deviceId, sBuilder.build(), treatment, PRIORITY_STATEFUL_SNAT_RULE, EXT_ENTRY_TABLE, install);
}
Aggregations