Search in sources :

Example 21 with AllowedAddressPairs

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs in project netvirt by opendaylight.

the class AbstractAclServiceImpl method programRemoteAclTable.

private void programRemoteAclTable(String aclName, Set<Uuid> remoteAclIds, Set<BigInteger> dpns, int addOrRemove) {
    for (Uuid remoteAclId : remoteAclIds) {
        Collection<AclInterface> remoteAclInterfaces = aclDataUtil.getInterfaceList(remoteAclId);
        if (remoteAclInterfaces == null || remoteAclInterfaces.isEmpty()) {
            continue;
        }
        Set<AllowedAddressPairs> aaps = remoteAclInterfaces.stream().map(port -> port.getAllowedAddressPairs()).flatMap(List::stream).filter(aap -> AclServiceUtils.isNotIpAllNetwork(aap)).collect(Collectors.toSet());
        Integer aclTag = aclServiceUtils.getAclTag(remoteAclId);
        if (addOrRemove == NwConstants.ADD_FLOW) {
            for (BigInteger dpn : dpns) {
                for (AllowedAddressPairs aap : aaps) {
                    programRemoteAclTableFlow(dpn, aclTag, aap, addOrRemove);
                }
            }
        } else if (addOrRemove == NwConstants.DEL_FLOW) {
            Set<BigInteger> remoteAclDpns = new HashSet<>();
            Map<String, Set<AclInterface>> mapAclWithPortSet = aclDataUtil.getRemoteAclInterfaces(remoteAclId, this.direction);
            if (mapAclWithPortSet != null) {
                Map<String, Set<AclInterface>> copyOfMapAclWithPortSet = new HashMap<>(mapAclWithPortSet);
                copyOfMapAclWithPortSet.remove(aclName);
                remoteAclDpns = collectDpns(copyOfMapAclWithPortSet);
            }
            Set<BigInteger> dpnsToOperate = new HashSet<>(dpns);
            dpnsToOperate.removeAll(remoteAclDpns);
            LOG.debug("Deleting flows in Remote ACL table for remoteAclId={}, direction={}, dpnsToOperate={}, " + "remoteAclDpns={}, dpns={}", remoteAclId.getValue(), directionString, dpnsToOperate, remoteAclDpns, dpns);
            for (BigInteger dpn : dpnsToOperate) {
                for (AllowedAddressPairs aap : aaps) {
                    programRemoteAclTableFlow(dpn, aclTag, aap, addOrRemove);
                }
            }
        }
    }
}
Also used : AclInterface(org.opendaylight.netvirt.aclservice.api.utils.AclInterface) AceIpv4(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.ace.ip.ace.ip.version.AceIpv4) NxMatchCtState(org.opendaylight.genius.mdsalutil.nxmatches.NxMatchCtState) Acl(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.Acl) SortedSet(java.util.SortedSet) LoggerFactory(org.slf4j.LoggerFactory) AclServiceListener(org.opendaylight.netvirt.aclservice.api.AclServiceListener) ActionNxResubmit(org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) AllowedAddressPairs(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs) Map(java.util.Map) BigInteger(java.math.BigInteger) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) DirectionIngress(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.DirectionIngress) MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) AclConstants(org.opendaylight.netvirt.aclservice.utils.AclConstants) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) AclDataUtil(org.opendaylight.netvirt.aclservice.utils.AclDataUtil) Collection(java.util.Collection) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions) Set(java.util.Set) AclConntrackClassifierType(org.opendaylight.netvirt.aclservice.utils.AclConntrackClassifierType) 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) Collectors(java.util.stream.Collectors) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity) List(java.util.List) NxCtAction(org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack.NxCtAction) Entry(java.util.Map.Entry) 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) DirectionEgress(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.DirectionEgress) HashMap(java.util.HashMap) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase) ServiceModeBase(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.ServiceModeBase) AclServiceUtils(org.opendaylight.netvirt.aclservice.utils.AclServiceUtils) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Lists(com.google.common.collect.Lists) AclInterfaceCache(org.opendaylight.netvirt.aclservice.api.AclInterfaceCache) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) MatchEthernetType(org.opendaylight.genius.mdsalutil.matches.MatchEthernetType) SecurityRuleAttr(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.SecurityRuleAttr) NwConstants(org.opendaylight.genius.mdsalutil.NwConstants) AccessListEntries(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.AccessListEntries) AclServiceOFFlowBuilder(org.opendaylight.netvirt.aclservice.utils.AclServiceOFFlowBuilder) ServiceModeEgress(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.ServiceModeEgress) DirectionBase(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.DirectionBase) AclInterface(org.opendaylight.netvirt.aclservice.api.utils.AclInterface) Logger(org.slf4j.Logger) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) Ace(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.Ace) ActionNxConntrack(org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) IMdsalApiManager(org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager) Action(org.opendaylight.netvirt.aclservice.api.AclServiceManager.Action) Collections(java.util.Collections) SortedSet(java.util.SortedSet) Set(java.util.Set) HashSet(java.util.HashSet) BigInteger(java.math.BigInteger) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) AllowedAddressPairs(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs) BigInteger(java.math.BigInteger) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap)

Example 22 with AllowedAddressPairs

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs in project netvirt by opendaylight.

the class AbstractAclServiceImpl method updateRemoteAclFilterTable.

private void updateRemoteAclFilterTable(AclInterface port, List<Uuid> aclList, List<AllowedAddressPairs> aaps, int addOrRemove) {
    if (aclList == null) {
        LOG.debug("Port {} without SGs", port.getInterfaceId());
        return;
    }
    String portId = port.getInterfaceId();
    LOG.trace("updateRemoteAclFilterTable for portId={}, aclList={}, aaps={}, addOrRemove={}", portId, aclList, aaps, addOrRemove);
    for (Uuid aclId : aclList) {
        if (aclDataUtil.getRemoteAcl(aclId, this.direction) != null) {
            Integer aclTag = aclServiceUtils.getAclTag(aclId);
            if (addOrRemove == NwConstants.ADD_FLOW) {
                syncRemoteAclTable(portId, aclId, aclTag, aaps, addOrRemove);
            } else if (addOrRemove == NwConstants.DEL_FLOW) {
                // look-ups for AclPortsLookup data.
                synchronized (aclId.getValue().intern()) {
                    syncRemoteAclTable(portId, aclId, aclTag, aaps, addOrRemove);
                }
            }
        }
    }
    Set<Uuid> remoteAclIds = aclServiceUtils.getRemoteAclIdsByDirection(aclList, direction);
    for (Uuid remoteAclId : remoteAclIds) {
        syncRemoteAclTableFromOtherDpns(port, remoteAclId, addOrRemove);
    }
}
Also used : BigInteger(java.math.BigInteger) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)

Example 23 with AllowedAddressPairs

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs in project netvirt by opendaylight.

the class AclServiceTestBaseIPv6 method setUpData.

@Override
protected void setUpData() throws Exception {
    newElan(ELAN, ELAN_TAG);
    newElanInterface(ELAN, PORT_1, true);
    newElanInterface(ELAN, PORT_2, true);
    newElanInterface(ELAN, PORT_3, true);
    final AllowedAddressPairs aapPort1 = buildAap(IPv6_PREFIX_1, PORT_MAC_1);
    final AllowedAddressPairs aapPort2 = buildAap(IPv6_PREFIX_2, PORT_MAC_2);
    final AllowedAddressPairs aapPort3 = buildAap(IPv6_PREFIX_3, PORT_MAC_3);
    newAllowedAddressPair(PORT_1, Arrays.asList(SG_UUID_1), Arrays.asList(aapPort1));
    newAllowedAddressPair(PORT_2, Arrays.asList(SG_UUID_1), Arrays.asList(aapPort2));
    newAllowedAddressPair(PORT_3, Arrays.asList(SG_UUID_1, SG_UUID_2), Arrays.asList(aapPort3));
}
Also used : AllowedAddressPairs(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs)

Example 24 with AllowedAddressPairs

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs in project netvirt by opendaylight.

the class NeutronvpnUtils method getAclAllowedAddressPairs.

/**
 * Gets the acl allowed address pairs.
 *
 * @param macAddress the mac address
 * @param ipAddress the ip address
 * @return the acl allowed address pairs
 */
protected static AllowedAddressPairs getAclAllowedAddressPairs(MacAddress macAddress, org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.types.rev160517.IpPrefixOrAddress ipAddress) {
    AllowedAddressPairsBuilder aclAllowedAdressPairBuilder = new AllowedAddressPairsBuilder();
    aclAllowedAdressPairBuilder.setMacAddress(macAddress);
    if (ipAddress != null && ipAddress.getValue() != null) {
        if (ipAddress.getIpPrefix() != null) {
            aclAllowedAdressPairBuilder.setIpAddress(new IpPrefixOrAddress(ipAddress.getIpPrefix()));
        } else {
            aclAllowedAdressPairBuilder.setIpAddress(new IpPrefixOrAddress(ipAddress.getIpAddress()));
        }
    }
    return aclAllowedAdressPairBuilder.build();
}
Also used : IpPrefixOrAddress(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.IpPrefixOrAddress) AllowedAddressPairsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairsBuilder)

Example 25 with AllowedAddressPairs

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs in project netvirt by opendaylight.

the class NeutronPortChangeListener method handlePortSecurityUpdated.

private static InterfaceAclBuilder handlePortSecurityUpdated(Port portOriginal, Port portUpdated, boolean origSecurityEnabled, boolean updatedSecurityEnabled, InterfaceBuilder interfaceBuilder) {
    InterfaceAclBuilder interfaceAclBuilder = null;
    if (origSecurityEnabled != updatedSecurityEnabled) {
        interfaceAclBuilder = new InterfaceAclBuilder();
        interfaceAclBuilder.setPortSecurityEnabled(updatedSecurityEnabled);
        if (updatedSecurityEnabled) {
            // Handle security group enabled
            NeutronvpnUtils.populateInterfaceAclBuilder(interfaceAclBuilder, portUpdated);
        } else {
            // Handle security group disabled
            interfaceAclBuilder.setSecurityGroups(new ArrayList<>());
            interfaceAclBuilder.setAllowedAddressPairs(new ArrayList<>());
        }
    } else {
        if (updatedSecurityEnabled) {
            // handle SG add/delete delta
            InterfaceAcl interfaceAcl = interfaceBuilder.getAugmentation(InterfaceAcl.class);
            interfaceAclBuilder = new InterfaceAclBuilder(interfaceAcl);
            interfaceAclBuilder.setSecurityGroups(NeutronvpnUtils.getUpdatedSecurityGroups(interfaceAcl.getSecurityGroups(), portOriginal.getSecurityGroups(), portUpdated.getSecurityGroups()));
            List<AllowedAddressPairs> updatedAddressPairs = NeutronvpnUtils.getUpdatedAllowedAddressPairs(interfaceAcl.getAllowedAddressPairs(), portOriginal.getAllowedAddressPairs(), portUpdated.getAllowedAddressPairs());
            interfaceAclBuilder.setAllowedAddressPairs(NeutronvpnUtils.getAllowedAddressPairsForFixedIps(updatedAddressPairs, portOriginal.getMacAddress(), portOriginal.getFixedIps(), portUpdated.getFixedIps()));
        }
    }
    return interfaceAclBuilder;
}
Also used : InterfaceAclBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.InterfaceAclBuilder) AllowedAddressPairs(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs) InterfaceAcl(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.InterfaceAcl)

Aggregations

AllowedAddressPairs (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs)18 ArrayList (java.util.ArrayList)14 MatchInfoBase (org.opendaylight.genius.mdsalutil.MatchInfoBase)12 IpPrefixOrAddress (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.IpPrefixOrAddress)12 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)9 BigInteger (java.math.BigInteger)7 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)7 MatchEthernetType (org.opendaylight.genius.mdsalutil.matches.MatchEthernetType)6 List (java.util.List)5 Set (java.util.Set)5 InstructionGotoTable (org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable)5 MatchEthernetSource (org.opendaylight.genius.mdsalutil.matches.MatchEthernetSource)5 AclInterface (org.opendaylight.netvirt.aclservice.api.utils.AclInterface)5 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)5 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)5 Collections (java.util.Collections)4 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 SortedSet (java.util.SortedSet)4 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)4