Search in sources :

Example 6 with Direction

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;
}
Also used : AclInterface(org.opendaylight.netvirt.aclservice.api.utils.AclInterface) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) Set(java.util.Set) HashSet(java.util.HashSet) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) HashSet(java.util.HashSet)

Example 7 with Direction

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);
        }
    }
}
Also used : SecurityRuleAttr(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.SecurityRuleAttr) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) Matches(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.Matches) AceIp(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.AceIp) List(java.util.List) ArrayList(java.util.ArrayList)

Example 8 with Direction

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());
}
Also used : Actions(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.Actions) SetPolicyClassifier(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.SetPolicyClassifier)

Example 9 with Direction

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);
    }
}
Also used : TcpFilter(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.elementrequestdata.filters.TcpFilter) UdpFilter(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.elementrequestdata.filters.UdpFilter)

Example 10 with Direction

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;
}
Also used : MatchIpv6Source(org.opendaylight.genius.mdsalutil.matches.MatchIpv6Source) MatchIpv6Destination(org.opendaylight.genius.mdsalutil.matches.MatchIpv6Destination) ArrayList(java.util.ArrayList) MatchIpv4Destination(org.opendaylight.genius.mdsalutil.matches.MatchIpv4Destination) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) MatchIpv4Source(org.opendaylight.genius.mdsalutil.matches.MatchIpv4Source) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase)

Aggregations

Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)9 BigInteger (java.math.BigInteger)5 ArrayList (java.util.ArrayList)5 HashSet (java.util.HashSet)5 GetAclPortStatisticsOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.GetAclPortStatisticsOutput)5 Direction (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.Direction)4 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)4 Test (org.junit.Test)3 GetAclPortStatisticsInput (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.GetAclPortStatisticsInput)3 GetAclPortStatisticsInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.GetAclPortStatisticsInputBuilder)3 SecurityRuleAttr (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.SecurityRuleAttr)3 Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Set (java.util.Set)2 MatchInfoBase (org.opendaylight.genius.mdsalutil.MatchInfoBase)2 AclInterface (org.opendaylight.netvirt.aclservice.api.utils.AclInterface)2 Acl (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.Acl)2 AccessListEntries (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.AccessListEntries)2 Ace (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.Ace)2