use of org.onosproject.net.flow.criteria.ExtensionSelector in project onos by opennetworkinglab.
the class K8sServiceHandler method setUntrack.
private void setUntrack(DeviceId deviceId, long ctState, long ctMask, String srcCidr, String dstCidr, int installTable, int transitTable, int priority, boolean install) {
ExtensionSelector esCtSate = RulePopulatorUtil.buildCtExtensionSelector(driverService, deviceId, ctState, ctMask);
TrafficSelector selector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPSrc(IpPrefix.valueOf(srcCidr)).matchIPDst(IpPrefix.valueOf(dstCidr)).extension(esCtSate, deviceId).build();
NiciraConnTrackTreatmentBuilder connTreatmentBuilder = niciraConnTrackTreatmentBuilder(driverService, deviceId).natAction(false).commit(false).table((short) transitTable);
TrafficTreatment treatment = DefaultTrafficTreatment.builder().extension(connTreatmentBuilder.build(), deviceId).build();
k8sFlowRuleService.setRule(appId, deviceId, selector, treatment, priority, installTable, install);
}
use of org.onosproject.net.flow.criteria.ExtensionSelector in project onos by opennetworkinglab.
the class K8sServiceHandler method setTrackNew.
private void setTrackNew(DeviceId deviceId, long ctState, long ctMask, IpAddress dstIp, TpPort dstPort, int installTable, int groupId, int priority, boolean install) {
ExtensionSelector esCtSate = RulePopulatorUtil.buildCtExtensionSelector(driverService, deviceId, ctState, ctMask);
TrafficSelector selector = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPDst(IpPrefix.valueOf(dstIp, HOST_CIDR_NUM)).matchIPProtocol(IPv4.PROTOCOL_TCP).matchTcpDst(dstPort).extension(esCtSate, deviceId).build();
TrafficTreatment treatment = DefaultTrafficTreatment.builder().group(GroupId.valueOf(groupId)).build();
k8sFlowRuleService.setRule(appId, deviceId, selector, treatment, priority, installTable, install);
}
use of org.onosproject.net.flow.criteria.ExtensionSelector in project onos by opennetworkinglab.
the class RulePopulatorUtil method buildCtExtensionSelector.
/**
* Builds OVS ConnTrack matches.
*
* @param driverService driver service
* @param deviceId device ID
* @param ctState connection tracking sate masking value
* @param ctSateMask connection tracking sate masking value
* @return OVS ConnTrack extension match
*/
public static ExtensionSelector buildCtExtensionSelector(DriverService driverService, DeviceId deviceId, long ctState, long ctSateMask) {
DriverHandler handler = driverService.createHandler(deviceId);
ExtensionSelectorResolver esr = handler.behaviour(ExtensionSelectorResolver.class);
ExtensionSelector extensionSelector = esr.getExtensionSelector(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_CONNTRACK_STATE.type());
try {
extensionSelector.setPropertyValue(CT_STATE, ctState);
extensionSelector.setPropertyValue(CT_STATE_MASK, ctSateMask);
} catch (Exception e) {
log.error("Failed to set nicira match CT state", e);
return null;
}
return extensionSelector;
}
use of org.onosproject.net.flow.criteria.ExtensionSelector in project onos by opennetworkinglab.
the class ExtensionCriterionSerializer method read.
@Override
public ExtensionCriterion read(Kryo kryo, Input input, Class<ExtensionCriterion> type) {
ExtensionSelectorType exType = (ExtensionSelectorType) kryo.readClassAndObject(input);
DeviceId deviceId = (DeviceId) kryo.readClassAndObject(input);
DriverService driverService = DefaultServiceDirectory.getService(DriverService.class);
byte[] bytes = (byte[]) kryo.readClassAndObject(input);
ExtensionSelector selector;
try {
DriverHandler handler = new DefaultDriverHandler(new DefaultDriverData(driverService.getDriver(deviceId), deviceId));
ExtensionSelectorResolver resolver = handler.behaviour(ExtensionSelectorResolver.class);
selector = resolver.getExtensionSelector(exType);
selector.deserialize(bytes);
} catch (ItemNotFoundException | IllegalArgumentException e) {
selector = new UnresolvedExtensionSelector(bytes, exType);
}
return Criteria.extension(selector, deviceId);
}
Aggregations