use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv6._case.Ipv6 in project openflowplugin by opendaylight.
the class MatchConvertorTest method testIpv6ExtHeaderConversion.
@Test
public void testIpv6ExtHeaderConversion() {
Ipv6MatchBuilder ipv6Builder = new Ipv6MatchBuilder();
Ipv6ExtHeaderBuilder extHdrBuilder = new Ipv6ExtHeaderBuilder();
extHdrBuilder.setIpv6Exthdr(358);
extHdrBuilder.setIpv6ExthdrMask(258);
ipv6Builder.setIpv6ExtHeader(extHdrBuilder.build());
MatchBuilder builder = new MatchBuilder();
builder.setLayer3Match(ipv6Builder.build());
Match match = builder.build();
Optional<List<MatchEntry>> entriesOptional = converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
List<MatchEntry> entries = entriesOptional.get();
Assert.assertEquals("Wrong entries size", 1, entries.size());
MatchEntry entry = entries.get(0);
checkEntryHeader(entry, Ipv6Exthdr.class, true);
Assert.assertEquals("Wrong ipv6 ext hdr", new Ipv6ExthdrFlags(true, false, true, false, true, false, true, false, true), ((Ipv6ExthdrCase) entry.getMatchEntryValue()).getIpv6Exthdr().getPseudoField());
Assert.assertArrayEquals("Wrong ipv6 ext hdr mask", new byte[] { 1, 2 }, ((Ipv6ExthdrCase) entry.getMatchEntryValue()).getIpv6Exthdr().getMask());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv6._case.Ipv6 in project netvirt by opendaylight.
the class AclServiceOFFlowBuilder method programIcmpFlow.
/**
*Converts icmp matches to flows.
* @param acl the access control list
* @return the map containing the flows and the respective flow id
*/
public static Map<String, List<MatchInfoBase>> programIcmpFlow(AceIp acl) {
List<MatchInfoBase> flowMatches = new ArrayList<>();
flowMatches.addAll(addSrcIpMatches(acl));
flowMatches.addAll(addDstIpMatches(acl));
// For ICMP port range indicates type and code
SourcePortRange sourcePortRange = acl.getSourcePortRange();
String flowId = "ICMP_";
if (sourcePortRange != null) {
if (acl.getAceIpVersion() instanceof AceIpv4) {
flowMatches.add(new MatchIcmpv4(sourcePortRange.getLowerPort().getValue().shortValue(), sourcePortRange.getUpperPort().getValue().shortValue()));
flowId = flowId + "V4_SOURCE_" + sourcePortRange.getLowerPort().getValue() + sourcePortRange.getUpperPort().getValue();
} else if (acl.getAceIpVersion() instanceof AceIpv6) {
flowMatches.add(new MatchIcmpv6(sourcePortRange.getLowerPort().getValue().shortValue(), sourcePortRange.getUpperPort().getValue().shortValue()));
flowId = flowId + "V6_SOURCE_" + sourcePortRange.getLowerPort().getValue() + "_" + sourcePortRange.getUpperPort().getValue() + "_";
}
}
DestinationPortRange destinationPortRange = acl.getDestinationPortRange();
if (destinationPortRange != null) {
if (acl.getAceIpVersion() instanceof AceIpv4) {
flowMatches.add(new MatchIcmpv4(destinationPortRange.getLowerPort().getValue().shortValue(), destinationPortRange.getUpperPort().getValue().shortValue()));
flowId = flowId + "V4_DESTINATION_" + destinationPortRange.getLowerPort().getValue() + destinationPortRange.getUpperPort().getValue() + "_";
} else if (acl.getAceIpVersion() instanceof AceIpv6) {
flowMatches.add(new MatchIcmpv6(destinationPortRange.getLowerPort().getValue().shortValue(), destinationPortRange.getUpperPort().getValue().shortValue()));
flowId = flowId + "V6_DESTINATION_" + destinationPortRange.getLowerPort().getValue() + destinationPortRange.getUpperPort().getValue() + "_";
}
}
if (acl.getAceIpVersion() instanceof AceIpv6 && acl.getProtocol().toJava() == NwConstants.IP_PROT_ICMP) {
// We are aligning our implementation similar to Neutron Firewall driver where a Security
// Group rule with "Ethertype as IPv6 and Protocol as icmp" is treated as ICMPV6 SG Rule.
flowMatches.add(new MatchIpProtocol(AclConstants.IP_PROT_ICMPV6));
} else {
flowMatches.add(new MatchIpProtocol(acl.getProtocol().toJava()));
}
Map<String, List<MatchInfoBase>> flowMatchesMap = new HashMap<>();
flowMatchesMap.put(flowId, flowMatches);
return flowMatchesMap;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv6._case.Ipv6 in project netvirt by opendaylight.
the class IngressAclServiceImpl method programIcmpv6RARule.
@Override
protected void programIcmpv6RARule(List<FlowEntity> flowEntries, AclInterface port, List<SubnetInfo> subnets, int addOrRemove) {
if (!AclServiceUtils.isIpv6Subnet(subnets)) {
return;
}
Uint64 dpid = Uint64.valueOf(port.getDpId());
/* Allow ICMPv6 Router Advertisement packets from external routers as well as internal routers
* if subnet is configured with IPv6 version
* Allow ICMPv6 Router Advertisement packets if originating from any LinkLocal Address.
*/
List<InstructionInfo> instructions = getDispatcherTableResubmitInstructions();
List<MatchInfoBase> matches = AclServiceUtils.buildIcmpV6Matches(AclConstants.ICMPV6_TYPE_RA, 0, port.getLPortTag(), serviceMode);
matches.addAll(AclServiceUtils.buildIpMatches(new IpPrefixOrAddress(IpPrefixBuilder.getDefaultInstance(AclConstants.IPV6_LINK_LOCAL_PREFIX)), AclServiceManager.MatchCriteria.MATCH_SOURCE));
String flowName = "Ingress_ICMPv6" + "_" + dpid + "_" + port.getLPortTag() + "_" + AclConstants.ICMPV6_TYPE_RA + "_LinkLocal_Permit_";
addFlowEntryToList(flowEntries, dpid, getAclAntiSpoofingTable(), flowName, AclConstants.PROTO_IPV6_ALLOWED_PRIORITY, 0, 0, AclConstants.COOKIE_ACL_BASE, matches, instructions, addOrRemove);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv6._case.Ipv6 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.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv6._case.Ipv6 in project netvirt by opendaylight.
the class VpnInterfaceManager method processVpnInterfaceUp.
// "Unconditional wait" and "Wait not in loop" wrt the VpnNotifyTask below - suppressing the FB violation -
// see comments below.
@SuppressFBWarnings({ "UW_UNCOND_WAIT", "WA_NOT_IN_LOOP" })
protected void processVpnInterfaceUp(final Uint64 dpId, VpnInterface vpnInterface, final String primaryRd, final int lportTag, boolean isInterfaceUp, TypedWriteTransaction<Configuration> writeConfigTxn, TypedWriteTransaction<Operational> writeOperTxn, TypedReadWriteTransaction<Configuration> writeInvTxn, Interface interfaceState, final String vpnName, Set<String> prefixListForRefreshFib) throws ExecutionException, InterruptedException {
final String interfaceName = vpnInterface.getName();
Optional<VpnInterfaceOpDataEntry> optOpVpnInterface = vpnUtil.getVpnInterfaceOpDataEntry(interfaceName, vpnName);
VpnInterfaceOpDataEntry opVpnInterface = optOpVpnInterface.isPresent() ? optOpVpnInterface.get() : null;
boolean isBgpVpnInternetVpn = vpnUtil.isBgpVpnInternet(vpnName);
if (!isInterfaceUp) {
LOG.info("processVpnInterfaceUp: Binding vpn service to interface {} onto dpn {} for vpn {}", interfaceName, dpId, vpnName);
Uint32 vpnId = vpnUtil.getVpnId(vpnName);
if (VpnConstants.INVALID_ID.equals(vpnId)) {
LOG.warn("processVpnInterfaceUp: VpnInstance to VPNId mapping not available for VpnName {}" + " processing vpninterface {} on dpn {}, bailing out now.", vpnName, interfaceName, dpId);
return;
}
boolean waitForVpnInterfaceOpRemoval = false;
if (opVpnInterface != null) {
String opVpnName = opVpnInterface.getVpnInstanceName();
String primaryInterfaceIp = null;
if (Objects.equals(opVpnName, vpnName)) {
// Please check if the primary VRF Entry does not exist for VPNInterface
// If so, we have to process ADD, as this might be a DPN Restart with Remove and Add triggered
// back to back
// However, if the primary VRF Entry for this VPNInterface exists, please continue bailing out !
List<Adjacency> adjs = vpnUtil.getAdjacenciesForVpnInterfaceFromConfig(interfaceName);
if (adjs == null) {
LOG.error("processVpnInterfaceUp: VPN Interface {} on dpn {} for vpn {} failed as adjacencies" + " for this vpn interface could not be obtained", interfaceName, dpId, vpnName);
return;
}
for (Adjacency adj : adjs) {
if (adj.getAdjacencyType() == AdjacencyType.PrimaryAdjacency) {
primaryInterfaceIp = adj.getIpAddress();
break;
}
}
if (primaryInterfaceIp == null) {
LOG.error("processVpnInterfaceUp: VPN Interface {} addition on dpn {} for vpn {} failed" + " as primary adjacency for this vpn interface could not be obtained", interfaceName, dpId, vpnName);
return;
}
// Get the rd of the vpn instance
VrfEntry vrf = vpnUtil.getVrfEntry(primaryRd, primaryInterfaceIp);
if (vrf != null) {
LOG.error("processVpnInterfaceUp: VPN Interface {} on dpn {} for vpn {} already provisioned ," + " bailing out from here.", interfaceName, dpId, vpnName);
return;
}
waitForVpnInterfaceOpRemoval = true;
} else {
LOG.error("processVpnInterfaceUp: vpn interface {} to go to configured vpn {} on dpn {}," + " but in operational vpn {}", interfaceName, vpnName, dpId, opVpnName);
}
}
if (!waitForVpnInterfaceOpRemoval) {
// Add the VPNInterface and quit
vpnFootprintService.updateVpnToDpnMapping(dpId, vpnName, primaryRd, interfaceName, null, /*ipAddressSourceValuePair*/
true);
processVpnInterfaceAdjacencies(dpId, lportTag, vpnName, primaryRd, interfaceName, vpnId, writeConfigTxn, writeOperTxn, writeInvTxn, interfaceState, prefixListForRefreshFib);
if (!isBgpVpnInternetVpn) {
vpnUtil.bindService(vpnName, interfaceName, false);
}
LOG.info("processVpnInterfaceUp: Plumbed vpn interface {} onto dpn {} for vpn {}", interfaceName, dpId, vpnName);
if (interfaceManager.isExternalInterface(interfaceName)) {
processExternalVpnInterface(interfaceName, vpnName, dpId, lportTag, NwConstants.ADD_FLOW);
}
return;
}
// FIB didn't get a chance yet to clean up this VPNInterface
// Let us give it a chance here !
LOG.info("processVpnInterfaceUp: Trying to add VPN Interface {} on dpn {} for vpn {}," + " but waiting for FIB to clean up! ", interfaceName, dpId, vpnName);
try {
Runnable notifyTask = new VpnNotifyTask();
synchronized (notifyTask) {
// Per FB's "Unconditional wait" violation, the code should really verify that the condition it
// intends to wait for is not already satisfied before calling wait. However the VpnNotifyTask is
// published here while holding the lock on it so this path will hit the wait before notify can be
// invoked.
vpnIntfMap.put(interfaceName, notifyTask);
try {
notifyTask.wait(VpnConstants.MAX_WAIT_TIME_IN_MILLISECONDS);
} catch (InterruptedException e) {
// Ignored
}
}
} finally {
vpnIntfMap.remove(interfaceName);
}
if (opVpnInterface != null) {
LOG.warn("processVpnInterfaceUp: VPN Interface {} removal on dpn {} for vpn {}" + " by FIB did not complete on time," + " bailing addition ...", interfaceName, dpId, vpnName);
vpnUtil.unsetScheduledToRemoveForVpnInterface(interfaceName);
return;
}
// VPNInterface got removed, proceed with Add
LOG.info("processVpnInterfaceUp: Continuing to plumb vpn interface {} onto dpn {} for vpn {}", interfaceName, dpId, vpnName);
vpnFootprintService.updateVpnToDpnMapping(dpId, vpnName, primaryRd, interfaceName, null, /*ipAddressSourceValuePair*/
true);
processVpnInterfaceAdjacencies(dpId, lportTag, vpnName, primaryRd, interfaceName, vpnId, writeConfigTxn, writeOperTxn, writeInvTxn, interfaceState, prefixListForRefreshFib);
if (!isBgpVpnInternetVpn) {
vpnUtil.bindService(vpnName, interfaceName, false);
}
LOG.info("processVpnInterfaceUp: Plumbed vpn interface {} onto dpn {} for vpn {} after waiting for" + " FIB to clean up", interfaceName, dpId, vpnName);
if (interfaceManager.isExternalInterface(interfaceName)) {
processExternalVpnInterface(interfaceName, vpnName, dpId, lportTag, NwConstants.ADD_FLOW);
}
} else {
try {
// Interface is retained in the DPN, but its Link Up.
// Advertise prefixes again for this interface to BGP
InstanceIdentifier<VpnInterface> identifier = VpnUtil.getVpnInterfaceIdentifier(vpnInterface.getName());
InstanceIdentifier<VpnInterfaceOpDataEntry> vpnInterfaceOpIdentifier = VpnUtil.getVpnInterfaceOpDataEntryIdentifier(interfaceName, vpnName);
advertiseAdjacenciesForVpnToBgp(primaryRd, dpId, vpnInterfaceOpIdentifier, vpnName, interfaceName);
// Perform similar operation as interface add event for extraroutes.
InstanceIdentifier<Adjacencies> path = identifier.augmentation(Adjacencies.class);
Optional<Adjacencies> optAdjacencies = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, path);
if (!optAdjacencies.isPresent()) {
LOG.trace("No config adjacencyKeyAdjacencyMap present for vpninterface {}", vpnInterface);
return;
}
Map<AdjacencyKey, Adjacency> adjacencyKeyAdjacencyMap = optAdjacencies.get().nonnullAdjacency();
for (Adjacency adjacency : adjacencyKeyAdjacencyMap.values()) {
if (adjacency.getAdjacencyType() == AdjacencyType.PrimaryAdjacency) {
continue;
}
// if BGPVPN Internet, filter only IPv6 Adjacencies
if (isBgpVpnInternetVpn && !vpnUtil.isAdjacencyEligibleToVpnInternet(adjacency)) {
continue;
}
addNewAdjToVpnInterface(vpnInterfaceOpIdentifier, primaryRd, adjacency, dpId, writeOperTxn, writeConfigTxn, writeInvTxn, prefixListForRefreshFib);
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("processVpnInterfaceUp: Failed to read data store for interface {} vpn {} rd {} dpn {}", interfaceName, vpnName, primaryRd, dpId);
}
}
}
Aggregations