use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.Direction in project netvirt by opendaylight.
the class AclDataUtil method getRemoteAclInterfaces.
/**
* Gets the set of ACL interfaces per ACL (in a map) which has specified
* remote ACL ID.
*
* @param remoteAclId the remote acl id
* @param direction the direction
* @return the set of ACL interfaces per ACL (in a map) which has specified
* remote ACL ID.
*/
public Map<String, Set<AclInterface>> getRemoteAclInterfaces(Uuid remoteAclId, Class<? extends DirectionBase> direction) {
Collection<Uuid> remoteAclList = getRemoteAcl(remoteAclId, direction);
if (remoteAclList == null) {
return null;
}
Map<String, Set<AclInterface>> mapOfAclWithInterfaces = new HashMap<>();
for (Uuid acl : remoteAclList) {
Set<AclInterface> interfaceSet = new HashSet<>();
Collection<AclInterface> interfaces = getInterfaceList(acl);
if (interfaces != null && !interfaces.isEmpty()) {
interfaceSet.addAll(interfaces);
mapOfAclWithInterfaces.put(acl.getValue(), interfaceSet);
}
}
return mapOfAclWithInterfaces;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.Direction in project netvirt by opendaylight.
the class AbstractAclServiceImpl method programAceRule.
/**
* Programs the ace specific rule.
*
* @param port acl interface
* @param aclName the acl name
* @param ace rule to be program
* @param addOrRemove whether to delete or add flow
*/
protected void programAceRule(AclInterface port, String aclName, Ace ace, int addOrRemove) {
SecurityRuleAttr aceAttr = AclServiceUtils.getAccesssListAttributes(ace);
if (!isValidDirection(aceAttr.getDirection())) {
LOG.trace("Ignoring {} direction while processing for {} ACE Rule {}", aceAttr.getDirection(), this.directionString, ace.getRuleName());
return;
}
LOG.debug("Program {} ACE rule for dpId={}, lportTag={}, addOrRemove={}, ace={}, portId={}", this.directionString, port.getDpId(), port.getLPortTag(), addOrRemove, ace.getRuleName(), port.getInterfaceId());
Matches matches = ace.getMatches();
Map<String, List<MatchInfoBase>> flowMap = null;
if (matches.getAceType() instanceof AceIp) {
flowMap = AclServiceOFFlowBuilder.programIpFlow(matches);
if (!AclServiceUtils.doesAceHaveRemoteGroupId(aceAttr)) {
// programming for ACE which doesn't have any remote group Id
programForAceNotHavingRemoteAclId(port, aclName, ace, flowMap, addOrRemove);
} else {
Uuid remoteAclId = aceAttr.getRemoteGroupId();
// programming for ACE which have remote group Id
programAceSpecificFlows(port, aclName, ace, flowMap, remoteAclId, addOrRemove);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.Direction in project netvirt by opendaylight.
the class PolicyServiceUtil method getAcePolicyClassifier.
public Optional<String> getAcePolicyClassifier(Ace ace) {
Actions actions = ace.getActions();
SetPolicyClassifier setPolicyClassifier = actions.getAugmentation(SetPolicyClassifier.class);
if (setPolicyClassifier == null) {
LOG.warn("No valid policy action found for ACE rule {}", ace.getRuleName());
return Optional.absent();
}
Class<? extends DirectionBase> direction;
try {
direction = setPolicyClassifier.getDirection();
} catch (IllegalArgumentException e) {
LOG.warn("Failed to parse policy classifier direction");
return Optional.absent();
}
if (direction == null || !direction.isAssignableFrom(DirectionEgress.class)) {
LOG.trace("Ignoring non egress policy ACE rule {}", ace.getRuleName());
return Optional.absent();
}
return Optional.of(setPolicyClassifier.getPolicyClassifier());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.Direction in project netvirt by opendaylight.
the class StatisticsImpl method addElementCounterRequest.
private void addElementCounterRequest(List<ElementCountersRequest> ecrList, String portId, int lportTag, BigInteger dpn, ElementCountersDirection direction, Filters filters) {
ElementCountersRequest ecr = new ElementCountersRequest(portId);
ecr.setLportTag(lportTag);
ecr.setDpn(dpn);
ecr.setElementCountersDirection(direction);
if (filters.getIpFilter() != null) {
String ip = filters.getIpFilter().getIp();
if (ip != null) {
ecr.addFilterToFilterGroup(CountersUtils.ELEMENT_COUNTERS_IP_FILTER_GROUP_NAME, CountersUtils.IP_FILTER_NAME, ip);
}
}
boolean isTcpPortExist = false;
if (filters.getTcpFilter() != null && filters.getTcpFilter().isOn()) {
TcpFilter tcpFilter = filters.getTcpFilter();
int srcPort = tcpFilter.getSrcPort();
int dstPort = tcpFilter.getDstPort();
if (srcPort != -1) {
isTcpPortExist = true;
ecr.addFilterToFilterGroup(CountersUtils.ELEMENT_COUNTERS_TCP_FILTER_GROUP_NAME, CountersUtils.TCP_SRC_PORT_FILTER_NAME, String.valueOf(srcPort));
}
if (dstPort != -1) {
isTcpPortExist = true;
ecr.addFilterToFilterGroup(CountersUtils.ELEMENT_COUNTERS_TCP_FILTER_GROUP_NAME, CountersUtils.TCP_DST_PORT_FILTER_NAME, String.valueOf(dstPort));
}
if (!isTcpPortExist) {
ecr.addFilterToFilterGroup(CountersUtils.ELEMENT_COUNTERS_TCP_FILTER_GROUP_NAME, CountersUtils.TCP_FILTER_NAME, "");
}
} else if (filters.getUdpFilter() != null && filters.getUdpFilter().isOn()) {
UdpFilter udpFilter = filters.getUdpFilter();
int srcPort = udpFilter.getSrcPort();
int dstPort = udpFilter.getDstPort();
if (srcPort != -1) {
isTcpPortExist = true;
ecr.addFilterToFilterGroup(CountersUtils.ELEMENT_COUNTERS_UDP_FILTER_GROUP_NAME, CountersUtils.UDP_SRC_PORT_FILTER_NAME, String.valueOf(srcPort));
}
if (dstPort != -1) {
isTcpPortExist = true;
ecr.addFilterToFilterGroup(CountersUtils.ELEMENT_COUNTERS_UDP_FILTER_GROUP_NAME, CountersUtils.UDP_DST_PORT_FILTER_NAME, String.valueOf(dstPort));
}
if (!isTcpPortExist) {
ecr.addFilterToFilterGroup(CountersUtils.ELEMENT_COUNTERS_UDP_FILTER_GROUP_NAME, CountersUtils.UDP_FILTER_NAME, "");
}
}
if (!ecr.getFilters().isEmpty()) {
ecrList.add(ecr);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.Direction in project netvirt by opendaylight.
the class CountersServiceUtils method buildIpMatches.
private static List<MatchInfoBase> buildIpMatches(String ip, ElementCountersDirection direction) {
List<MatchInfoBase> flowMatches = new ArrayList<>();
IpAddress ipAddress = new IpAddress(ip.toCharArray());
if (ipAddress.getIpv4Address() != null) {
flowMatches.add(MatchEthernetType.IPV4);
flowMatches.add(direction == ElementCountersDirection.EGRESS ? new MatchIpv4Source(ipAddress.getIpv4Address().getValue(), "32") : new MatchIpv4Destination(ipAddress.getIpv4Address().getValue(), "32"));
} else {
flowMatches.add(MatchEthernetType.IPV6);
flowMatches.add(direction == ElementCountersDirection.EGRESS ? new MatchIpv6Source(ipAddress.getIpv6Address().getValue() + "/128") : new MatchIpv6Destination(ipAddress.getIpv6Address().getValue() + "/128"));
}
return flowMatches;
}
Aggregations