use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.types.rev160517.IpPrefixOrAddress in project netvirt by opendaylight.
the class AclServiceUtils method buildArpIpMatches.
/**
* Builds the arp ip matches.
* @param ipPrefixOrAddress the ip prefix or address
* @return the MatchInfoBase list
*/
public static List<MatchInfoBase> buildArpIpMatches(IpPrefixOrAddress ipPrefixOrAddress) {
List<MatchInfoBase> flowMatches = new ArrayList<>();
IpPrefix ipPrefix = ipPrefixOrAddress.getIpPrefix();
if (ipPrefix != null) {
Ipv4Prefix ipv4Prefix = ipPrefix.getIpv4Prefix();
if (ipv4Prefix != null && !ipv4Prefix.getValue().equals(AclConstants.IPV4_ALL_NETWORK)) {
flowMatches.add(new MatchArpSpa(ipv4Prefix));
}
} else {
IpAddress ipAddress = ipPrefixOrAddress.getIpAddress();
if (ipAddress != null && ipAddress.getIpv4Address() != null) {
flowMatches.add(new MatchArpSpa(ipAddress.getIpv4Address().getValue(), "32"));
}
}
return flowMatches;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.types.rev160517.IpPrefixOrAddress 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.neutron.types.rev160517.IpPrefixOrAddress in project netvirt by opendaylight.
the class AclServiceUtils method skipDeleteInCaseOfOverlappingIP.
/**
* Skip delete in case of overlapping IP.
*
* <p>
* When there are multiple ports (e.g., p1, p2, p3) having same AAP (e.g.,
* 224.0.0.5) configured which are part of single SG, there would be single
* flow in remote ACL table. When one of these ports (say p1) is deleted,
* the single flow which is configured in remote ACL table shouldn't be
* deleted. It should be deleted only when there are no more references to
* it.
*
* @param portId the port id
* @param remoteAclId the remote Acl Id
* @param ipPrefix the ip prefix
* @param addOrRemove the add or remove
* @return true, if successful
*/
public boolean skipDeleteInCaseOfOverlappingIP(String portId, Uuid remoteAclId, IpPrefixOrAddress ipPrefix, int addOrRemove) {
boolean skipDelete = false;
if (addOrRemove != NwConstants.DEL_FLOW) {
return skipDelete;
}
AclIpPrefixes aclIpPrefixes = getAclIpPrefixesFromOperDs(remoteAclId.getValue(), ipPrefix);
if (aclIpPrefixes != null && aclIpPrefixes.getPortIds() != null) {
List<String> ignorePorts = Lists.newArrayList(portId);
List<PortIds> portIds = new ArrayList<>(aclIpPrefixes.getPortIds());
// Checking if there are any other ports excluding ignorePorts
long noOfRemotePorts = portIds.stream().map(x -> x.getPortId()).filter(y -> !ignorePorts.contains(y)).count();
if (noOfRemotePorts > 0) {
skipDelete = true;
}
}
return skipDelete;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.types.rev160517.IpPrefixOrAddress in project netvirt by opendaylight.
the class AclServiceTestBase method newInterfaceWithTcpDstAcl.
@Test
public void newInterfaceWithTcpDstAcl() throws Exception {
LOG.info("newInterfaceWithTcpDstAcl - start");
newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1));
newAllowedAddressPair(PORT_2, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_2));
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()))));
// Given
Matches matches = newMatch(AclConstants.SOURCE_LOWER_PORT_UNSPECIFIED, AclConstants.SOURCE_UPPER_PORT_UNSPECIFIED, AclConstants.DEST_LOWER_PORT_HTTP, AclConstants.DEST_UPPER_PORT_HTTP, AclConstants.SOURCE_REMOTE_IP_PREFIX_UNSPECIFIED, AclConstants.DEST_REMOTE_IP_PREFIX_SPECIFIED, (short) NwConstants.IP_PROT_TCP);
dataBrokerUtil.put(new IdentifiedAceBuilder().sgUuid(SG_UUID_1).newRuleName(SR_UUID_1_1).newMatches(matches).newDirection(DirectionEgress.class).newRemoteGroupId(new Uuid(SG_UUID_1)).build());
matches = newMatch(AclConstants.SOURCE_LOWER_PORT_UNSPECIFIED, AclConstants.SOURCE_UPPER_PORT_UNSPECIFIED, AclConstants.DEST_LOWER_PORT_HTTP, AclConstants.DEST_UPPER_PORT_HTTP, AclConstants.SOURCE_REMOTE_IP_PREFIX_SPECIFIED, AclConstants.DEST_REMOTE_IP_PREFIX_UNSPECIFIED, (short) NwConstants.IP_PROT_TCP);
dataBrokerUtil.put(new IdentifiedAceBuilder().sgUuid(SG_UUID_1).newRuleName(SR_UUID_1_2).newMatches(matches).newDirection(DirectionIngress.class).build());
// When
putNewStateInterface(dataBroker, PORT_1, PORT_MAC_1);
putNewStateInterface(dataBroker, PORT_2, PORT_MAC_2);
asyncEventsWaiter.awaitEventsConsumption();
// Then
newInterfaceWithTcpDstAclCheck();
LOG.info("newInterfaceWithTcpDstAcl - end");
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.types.rev160517.IpPrefixOrAddress 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