use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs in project netvirt by opendaylight.
the class AclServiceUtils method deleteAclPortsLookup.
public List<ListenableFuture<Void>> deleteAclPortsLookup(AclInterface port, List<Uuid> aclList, List<AllowedAddressPairs> allowedAddresses) {
String portId = port.getInterfaceId();
LOG.trace("Deleting AclPortsLookup for port={}, acls={}, AAPs={}", portId, aclList, allowedAddresses);
if (aclList == null || allowedAddresses == null || allowedAddresses.isEmpty()) {
LOG.warn("aclList or allowedAddresses is null. port={}, acls={}, AAPs={}", portId, aclList, allowedAddresses);
return Collections.emptyList();
}
List<ListenableFuture<Void>> futures = new ArrayList<>();
for (Uuid aclId : aclList) {
String aclName = aclId.getValue();
synchronized (aclName.intern()) {
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
for (AllowedAddressPairs aap : allowedAddresses) {
InstanceIdentifier<PortIds> path = AclServiceUtils.getPortIdsPathInAclPortsLookup(aclName, aap.getIpAddress(), portId);
tx.delete(LogicalDatastoreType.OPERATIONAL, path);
}
cleanUpStaleEntriesInAclPortsLookup(aclName, tx);
}));
}
}
return futures;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs in project netvirt by opendaylight.
the class AclServiceUtils method getFlowForAllowedAddresses.
public static Map<String, List<MatchInfoBase>> getFlowForAllowedAddresses(List<AllowedAddressPairs> syncAllowedAddresses, Map<String, List<MatchInfoBase>> flowMatchesMap, boolean isSourceIpMacMatch) {
if (flowMatchesMap == null) {
return null;
}
Map<String, List<MatchInfoBase>> updatedFlowMatchesMap = new HashMap<>();
MatchInfoBase ipv4Match = MatchEthernetType.IPV4;
MatchInfoBase ipv6Match = MatchEthernetType.IPV6;
for (Entry<String, List<MatchInfoBase>> entry : flowMatchesMap.entrySet()) {
String flowName = entry.getKey();
List<MatchInfoBase> flows = entry.getValue();
// iterate over allow address pair and update match type
for (AllowedAddressPairs aap : syncAllowedAddresses) {
List<MatchInfoBase> matchInfoBaseList;
String flowId;
if (flows.contains(ipv4Match) && isIPv4Address(aap) && isNotIpv4AllNetwork(aap)) {
matchInfoBaseList = updateAAPMatches(isSourceIpMacMatch, flows, aap);
flowId = flowName + "_ipv4_remoteACL_interface_aap_" + getAapFlowId(aap);
updatedFlowMatchesMap.put(flowId, matchInfoBaseList);
} else if (flows.contains(ipv6Match) && !isIPv4Address(aap) && isNotIpv6AllNetwork(aap)) {
matchInfoBaseList = updateAAPMatches(isSourceIpMacMatch, flows, aap);
flowId = flowName + "_ipv6_remoteACL_interface_aap_" + getAapFlowId(aap);
updatedFlowMatchesMap.put(flowId, matchInfoBaseList);
}
}
}
return updatedFlowMatchesMap;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs in project netvirt by opendaylight.
the class AclServiceUtils method doesIpv6AddressExists.
/**
* Does IPv6 address exists in the list of allowed address pair.
*
* @param aaps the allowed address pairs
* @return true, if successful
*/
public static boolean doesIpv6AddressExists(List<AllowedAddressPairs> aaps) {
if (aaps == null) {
return false;
}
for (AllowedAddressPairs aap : aaps) {
IpPrefixOrAddress ipPrefixOrAddress = aap.getIpAddress();
IpPrefix ipPrefix = ipPrefixOrAddress.getIpPrefix();
if (ipPrefix != null) {
if (ipPrefix.getIpv6Prefix() != null) {
return true;
}
} else {
IpAddress ipAddress = ipPrefixOrAddress.getIpAddress();
if (ipAddress != null && ipAddress.getIpv6Address() != null) {
return true;
}
}
}
return false;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs in project netvirt by opendaylight.
the class AclServiceUtils method getUpdatedAllowedAddressPairs.
public static List<AllowedAddressPairs> getUpdatedAllowedAddressPairs(List<AllowedAddressPairs> updatedAllowedAddressPairs, List<AllowedAddressPairs> currentAllowedAddressPairs) {
if (updatedAllowedAddressPairs == null) {
return null;
}
List<AllowedAddressPairs> newAllowedAddressPairs = new ArrayList<>(updatedAllowedAddressPairs);
if (currentAllowedAddressPairs == null) {
return newAllowedAddressPairs;
}
List<AllowedAddressPairs> origAllowedAddressPairs = new ArrayList<>(currentAllowedAddressPairs);
for (Iterator<AllowedAddressPairs> iterator = newAllowedAddressPairs.iterator(); iterator.hasNext(); ) {
AllowedAddressPairs updatedAllowedAddressPair = iterator.next();
for (AllowedAddressPairs currentAllowedAddressPair : origAllowedAddressPairs) {
if (updatedAllowedAddressPair.getKey().equals(currentAllowedAddressPair.getKey())) {
iterator.remove();
break;
}
}
}
return newAllowedAddressPairs;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs in project netvirt by opendaylight.
the class AclServiceTestBase method newInterfaceWithAap.
@Test
public void newInterfaceWithAap() throws Exception {
LOG.info("newInterfaceWithAap test - start");
// AAP with same MAC and different IP
AllowedAddressPairs aapWithSameMac = buildAap("10.0.0.100/32", PORT_MAC_2);
// AAP with different MAC and different IP
AllowedAddressPairs aapWithDifferentMac = buildAap("10.0.0.101/32", "0D:AA:D8:42:30:A4");
newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1));
newAllowedAddressPair(PORT_2, Collections.singletonList(SG_UUID_1), Arrays.asList(AAP_PORT_2, aapWithSameMac, aapWithDifferentMac));
dataBrokerUtil.put(new IdentifiedSubnetIpPrefixBuilder().interfaceName(PORT_1).addAllIpPrefixOrAddress(Collections.singletonList(new IpPrefixOrAddress(SUBNET_IP_PREFIX_1.toCharArray()))));
dataBrokerUtil.put(new IdentifiedSubnetIpPrefixBuilder().interfaceName(PORT_2).addAllIpPrefixOrAddress(Collections.singletonList(new IpPrefixOrAddress(SUBNET_IP_PREFIX_1.toCharArray()))));
prepareInterfaceWithIcmpAcl();
// When
putNewStateInterface(dataBroker, PORT_1, PORT_MAC_1);
putNewStateInterface(dataBroker, PORT_2, PORT_MAC_2);
asyncEventsWaiter.awaitEventsConsumption();
// Then
newInterfaceWithAapCheck();
LOG.info("newInterfaceWithAap test - end");
}
Aggregations