use of org.onosproject.net.flow.instructions.ExtensionTreatment in project onos by opennetworkinglab.
the class OpenstackVtapManager method buildTunnelExtension.
/**
* Returns tunnel destination extension treatment object.
*
* @param deviceId device id to apply this treatment
* @param remoteIp tunnel destination ip address
* @return extension treatment
*/
private ExtensionTreatment buildTunnelExtension(DeviceId deviceId, IpAddress remoteIp) {
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_SET_TUNNEL_DST.type());
try {
treatment.setPropertyValue(TUNNEL_DST_EXTENSION, remoteIp.getIp4Address());
return treatment;
} catch (ExtensionPropertyException e) {
log.error("Failed to set nicira tunnelDst extension treatment for {}", deviceId);
return null;
}
}
use of org.onosproject.net.flow.instructions.ExtensionTreatment in project onos by opennetworkinglab.
the class OpenstackTroubleshootUtil method buildExtension.
/**
* Returns tunnel destination extension treatment object.
*
* @param deviceService driver service
* @param deviceId device id to apply this treatment
* @param remoteIp tunnel destination ip address
* @return extension treatment
*/
public static ExtensionTreatment buildExtension(DeviceService deviceService, DeviceId deviceId, Ip4Address remoteIp) {
Device device = deviceService.getDevice(deviceId);
if (device != null && !device.is(ExtensionTreatmentResolver.class)) {
log.error("The extension treatment is not supported");
return null;
}
if (device == null) {
return null;
}
ExtensionTreatmentResolver resolver = device.as(ExtensionTreatmentResolver.class);
ExtensionTreatment treatment = resolver.getExtensionInstruction(NICIRA_SET_TUNNEL_DST.type());
try {
treatment.setPropertyValue(TUNNEL_DST, remoteIp);
return treatment;
} catch (ExtensionPropertyException e) {
log.warn("Failed to get tunnelDst extension treatment for {}", deviceId);
return null;
}
}
use of org.onosproject.net.flow.instructions.ExtensionTreatment in project onos by opennetworkinglab.
the class SelectGroupHandler method buildNiciraExtenstion.
/**
* Builds Nicira extension for tagging remoteIp of vxlan.
*
* @param id device id of vxlan source device
* @param hostIp remote ip of vxlan destination device
* @return NiciraExtension Treatment
*/
private ExtensionTreatment buildNiciraExtenstion(DeviceId id, Ip4Address hostIp) {
Driver driver = driverService.getDriver(id);
DriverHandler driverHandler = new DefaultDriverHandler(new DefaultDriverData(driver, id));
ExtensionTreatmentResolver resolver = driverHandler.behaviour(ExtensionTreatmentResolver.class);
ExtensionTreatment extensionInstruction = resolver.getExtensionInstruction(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_TUNNEL_DST.type());
try {
extensionInstruction.setPropertyValue(TUNNEL_DESTINATION, hostIp);
} catch (ExtensionPropertyException e) {
log.error("Error setting Nicira extension setting {}", e);
}
return extensionInstruction;
}
use of org.onosproject.net.flow.instructions.ExtensionTreatment in project onos by opennetworkinglab.
the class KubevirtSecurityGroupHandler method populateSecurityGroupRule.
private void populateSecurityGroupRule(KubevirtSecurityGroupRule sgRule, KubevirtPort port, IpPrefix remoteIp, boolean install) {
if (!checkProtocol(sgRule.protocol())) {
return;
}
DeviceId deviceId = port.isTenant() ? port.tenantDeviceId() : port.deviceId();
Set<TrafficSelector> ctSelectors = buildSelectors(sgRule, Ip4Address.valueOf(port.ipAddress().toInetAddress()), port.macAddress(), remoteIp, port.networkId());
if (ctSelectors == null || ctSelectors.isEmpty()) {
return;
}
// if the device is not available we do not perform any action
if (deviceId == null || !deviceService.isAvailable(deviceId)) {
return;
}
// XXX All egress traffic needs to go through connection tracking module,
// which might hurt its performance.
ExtensionTreatment ctTreatment = niciraConnTrackTreatmentBuilder(driverService, deviceId).commit(true).build();
TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
KubevirtNetwork net = networkService.network(port.networkId());
int aclTable;
if (sgRule.direction().equalsIgnoreCase(EGRESS)) {
if (net.type() == FLAT || net.type() == VLAN) {
aclTable = ACL_EGRESS_TABLE;
} else {
aclTable = TENANT_ACL_EGRESS_TABLE;
}
tBuilder.transition(TENANT_ACL_RECIRC_TABLE);
} else {
if (net.type() == FLAT || net.type() == VLAN) {
aclTable = ACL_INGRESS_TABLE;
} else {
aclTable = TENANT_ACL_INGRESS_TABLE;
}
tBuilder.extension(ctTreatment, deviceId).transition(TENANT_FORWARDING_TABLE);
}
int finalAclTable = aclTable;
ctSelectors.forEach(selector -> {
flowRuleService.setRule(appId, deviceId, selector, tBuilder.build(), PRIORITY_ACL_RULE, finalAclTable, install);
});
TrafficSelector tSelector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchEthDst(port.macAddress()).matchIPDst(IpPrefix.valueOf(port.ipAddress(), 32)).build();
TrafficTreatment tTreatment = DefaultTrafficTreatment.builder().transition(TENANT_ACL_INGRESS_TABLE).build();
flowRuleService.setRule(appId, deviceId, tSelector, tTreatment, PRIORITY_ACL_RULE, TENANT_ACL_RECIRC_TABLE, install);
}
use of org.onosproject.net.flow.instructions.ExtensionTreatment in project onos by opennetworkinglab.
the class KubevirtSecurityGroupHandler method initializeAclTable.
private void initializeAclTable(DeviceId deviceId, int recircTable, PortNumber outport, 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).setOutput(outport);
flowRuleService.setRule(appId, deviceId, sBuilder.build(), tBuilder.build(), PRIORITY_ACL_INGRESS_RULE, recircTable, install);
}
Aggregations