use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.Destination in project netvirt by opendaylight.
the class NexthopManager method removeDcGwLoadBalancingGroup.
/**
* This method is invoked when the neighbor is removed from DS.
* All the LB groups which point to the given destination will be deleted.
*/
public void removeDcGwLoadBalancingGroup(Uint64 dpnId, String destinationIp) {
jobCoordinator.enqueueJob(FibHelper.getJobKeyForDcGwLoadBalancingGroup(dpnId), () -> {
List<String> availableDcGws = fibUtil.getL3VpnDcGateWays();
if (availableDcGws.contains(destinationIp)) {
availableDcGws.remove(destinationIp);
}
List<ListenableFuture<?>> futures = new ArrayList<>();
futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, operationalTx -> {
futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, configTx -> {
availableDcGws.forEach(dcGwIp -> {
List<String> dcGws = Arrays.asList(dcGwIp, destinationIp);
Collections.sort(dcGws);
String nextHopKey = FibUtil.getGreLbGroupKey(dcGws);
Optional<Nexthops> optionalNextHops = fibUtil.getNexthops(nextHopKey);
if (!optionalNextHops.isPresent()) {
return;
}
Nexthops nexthops = optionalNextHops.get();
final String groupId = nexthops.getGroupId();
final long groupIdValue = Long.parseLong(groupId);
Group group = MDSALUtil.buildGroup(groupIdValue, nextHopKey, GroupTypes.GroupSelect, MDSALUtil.buildBucketLists(Collections.emptyList()));
LOG.trace("Removed LB group {} on dpn {}", group, dpnId);
try {
mdsalApiManager.removeGroup(configTx, dpnId, group);
} catch (ExecutionException | InterruptedException e) {
LOG.error("Group removal failed for group {} with exception", groupId, e);
}
removeNextHopPointer(nextHopKey);
FibUtil.removeOrUpdateNextHopInfo(dpnId, nextHopKey, groupId, nexthops, operationalTx);
});
synchronized (getDcGateWaySyncKey(destinationIp)) {
FibUtil.removeL3vpnDcGateWay(destinationIp, operationalTx);
}
}));
}));
return futures;
}, RETRY_COUNT);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.Destination in project netvirt by opendaylight.
the class VrfEntryListener method cleanUpOpDataForFib.
protected void cleanUpOpDataForFib(Uint32 vpnId, String primaryRd, final VrfEntry vrfEntry) {
/* Get interface info from prefix to interface mapping;
Use the interface info to get the corresponding vpn interface op DS entry,
remove the adjacency corresponding to this fib entry.
If adjacency removed is the last adjacency, clean up the following:
- vpn interface from dpntovpn list, dpn if last vpn interface on dpn
- prefix to interface entry
- vpn interface op DS
*/
LOG.debug("Cleanup of prefix {} in VPN {}", vrfEntry.getDestPrefix(), vpnId);
Prefixes prefixInfo = fibUtil.getPrefixToInterface(vpnId, vrfEntry.getDestPrefix());
if (prefixInfo == null) {
List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnId, vrfEntry.getDestPrefix());
String usedRd = usedRds.isEmpty() ? primaryRd : usedRds.get(0);
Routes extraRoute = baseVrfEntryHandler.getVpnToExtraroute(vpnId, usedRd, vrfEntry.getDestPrefix());
if (extraRoute != null && extraRoute.getNexthopIpList() != null) {
for (String nextHopIp : extraRoute.getNexthopIpList()) {
LOG.debug("NextHop IP for destination {} is {}", vrfEntry.getDestPrefix(), nextHopIp);
if (nextHopIp != null) {
String ipPrefix;
if (isIpv4Address(nextHopIp)) {
ipPrefix = nextHopIp + NwConstants.IPV4PREFIX;
} else {
ipPrefix = nextHopIp + NwConstants.IPV6PREFIX;
}
prefixInfo = fibUtil.getPrefixToInterface(vpnId, ipPrefix);
checkCleanUpOpDataForFib(prefixInfo, vpnId, primaryRd, vrfEntry, extraRoute);
}
}
}
if (prefixInfo == null) {
java.util.Optional<Uint32> optionalLabel = FibUtil.getLabelFromRoutePaths(vrfEntry);
if (optionalLabel.isPresent()) {
Uint32 label = optionalLabel.get();
List<String> nextHopAddressList = FibHelper.getNextHopListFromRoutePaths(vrfEntry);
LabelRouteInfo lri = getLabelRouteInfo(label);
if (isPrefixAndNextHopPresentInLri(vrfEntry.getDestPrefix(), nextHopAddressList, lri)) {
PrefixesBuilder prefixBuilder = new PrefixesBuilder();
prefixBuilder.setDpnId(lri.getDpnId());
prefixBuilder.setVpnInterfaceName(lri.getVpnInterfaceName());
prefixBuilder.setIpAddress(lri.getPrefix());
prefixInfo = prefixBuilder.build();
LOG.debug("Fetched labelRouteInfo for label {} interface {} and got dpn {}", label, prefixInfo.getVpnInterfaceName(), lri.getDpnId());
checkCleanUpOpDataForFib(prefixInfo, vpnId, primaryRd, vrfEntry, extraRoute);
}
}
}
} else {
checkCleanUpOpDataForFib(prefixInfo, vpnId, primaryRd, vrfEntry, null);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.Destination in project netvirt by opendaylight.
the class FibUtil method removeOrUpdateFibEntry.
/**
* Removes a specific Nexthop from a VrfEntry. If Nexthop to remove is the
* last one in the VrfEntry, then the VrfEntry is removed too.
* @param rd Route-Distinguisher to which the VrfEntry belongs to
* @param prefix Destination of the route
* @param nextHopToRemove Specific nexthop within the Route to be removed.
* If null or empty, then the whole VrfEntry is removed
*/
public void removeOrUpdateFibEntry(String rd, String prefix, String nextHopToRemove, TypedWriteTransaction<Configuration> writeConfigTxn) {
LOG.debug("Removing fib entry with destination prefix {} from vrf table for rd {} nextHop {}", prefix, rd, nextHopToRemove);
// Looking for existing prefix in MDSAL database
InstanceIdentifier<VrfEntry> vrfEntryId = InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd)).child(VrfEntry.class, new VrfEntryKey(prefix)).build();
Optional<VrfEntry> entry = Optional.empty();
try {
entry = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, vrfEntryId);
} catch (ExecutionException | InterruptedException e) {
LOG.error("removeOrUpdateFibEntry: Exception while reading vrfEntry for the prefix {} rd {} nexthop {}", prefix, rd, nextHopToRemove, e);
}
if (entry.isPresent()) {
final List<RoutePaths> routePaths = new ArrayList<>(entry.get().nonnullRoutePaths().values());
if (routePaths == null || routePaths.isEmpty()) {
LOG.warn("routePaths is null/empty for given rd {}, prefix {}", rd, prefix);
return;
}
java.util.Optional<RoutePaths> optRoutePath = routePaths.stream().filter(routePath -> Objects.equals(routePath.getNexthopAddress(), nextHopToRemove)).findFirst();
if (!optRoutePath.isPresent()) {
LOG.error("Unable to find a routePath that contains the given nextHop to remove {}", nextHopToRemove);
return;
}
RoutePaths routePath = optRoutePath.get();
if (routePaths.size() == 1) {
// Remove the whole entry
if (writeConfigTxn != null) {
writeConfigTxn.delete(vrfEntryId);
} else {
MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, vrfEntryId);
}
LOG.info("Removed Fib Entry rd {} prefix {} nextHop {}", rd, prefix, nextHopToRemove);
} else {
InstanceIdentifier<RoutePaths> routePathsId = FibHelper.buildRoutePathId(rd, prefix, routePath.getNexthopAddress());
// Remove route
MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, routePathsId);
LOG.info("Removed Route Path rd {} prefix {}, nextHop {}, label {}", rd, prefix, routePath.getNexthopAddress(), routePath.getLabel());
}
} else {
LOG.warn("Could not find VrfEntry for Route-Distinguisher {} prefix {} nexthop {}", rd, prefix, nextHopToRemove);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.Destination in project netvirt by opendaylight.
the class Ipv6PktHandlerTest method testonPacketReceivedRouterSolicitationWithInvalidPayload.
@Test
public void testonPacketReceivedRouterSolicitationWithInvalidPayload() throws Exception {
// incorrect checksum in Router Solicitation
Uint64 mdata = Uint64.valueOf(0x1000000);
Metadata metadata = new MetadataBuilder().setMetadata(mdata).build();
MatchBuilder matchbuilder = new MatchBuilder().setMetadata(metadata);
pktHandler.onPacketReceived(new PacketReceivedBuilder().setPayload(ipv6TestUtils.buildPacket(// Destination MAC
"33 33 FF F5 00 00", // Source MAC
"00 01 02 03 04 05", // IPv6
"86 DD", // Version 6, traffic class E0, no flowlabel
"6E 00 00 00", // Payload length
"00 18", // Next header is ICMPv6
"3A", // Hop limit
"FF", // Source IP
"00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00", // Destination IP
"FF 02 00 00 00 00 00 00 00 00 00 01 FF F5 00 00", // ICMPv6 router solicitation
"85", // Code
"00", // Checksum (invalid, should be 67 3C)
"69 3E", // ICMPv6 message body
"00 00 00 00", // Target
"FE 80 00 00 00 00 00 00 C0 00 54 FF FE F5 00 00")).setMatch(matchbuilder.build()).build());
// wait on this thread until the async job is completed in the packet handler.
waitForPacketProcessing();
verify(pktProcessService, times(0)).transmitPacket(any(TransmitPacketInput.class));
// Request from an unknown port (i.e., unknown MAC Address)
when(ifMgrInstance.getInterfaceNameFromTag(anyLong())).thenReturn("ddec9dba-d831-4ad7-84b9-00d7f65f052f");
when(ifMgrInstance.obtainV6Interface(any())).thenReturn(null);
counter = pktHandler.getPacketProcessedCounter();
pktHandler.onPacketReceived(new PacketReceivedBuilder().setPayload(ipv6TestUtils.buildPacket(// Destination MAC
"33 33 FF F5 00 00", // Source MAC
"00 01 02 03 04 05", // IPv6
"86 DD", // Version 6, traffic class E0, no flowlabel
"6E 00 00 00", // Payload length
"00 18", // Next header is ICMPv6
"3A", // Hop limit
"FF", // Source IP
"00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00", // Destination IP
"FF 02 00 00 00 00 00 00 00 00 00 01 FF F5 00 00", // ICMPv6 router solicitation
"85", // Code
"00", // Checksum (valid)
"69 3C", // ICMPv6 message body
"00 00 00 00", // Target
"FE 80 00 00 00 00 00 00 C0 00 54 FF FE F5 00 00")).setMatch(matchbuilder.build()).build());
// wait on this thread until the async job is completed in the packet handler.
waitForPacketProcessing();
verify(pktProcessService, times(0)).transmitPacket(any(TransmitPacketInput.class));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.Destination in project netvirt by opendaylight.
the class Ipv6PktHandlerTest method testOnPacketReceivedWithInvalidParams.
@Test
public void testOnPacketReceivedWithInvalidParams() throws Exception {
// invalid ethtype
pktHandler.onPacketReceived(new PacketReceivedBuilder().setPayload(ipv6TestUtils.buildPacket(// Destination MAC
"33 33 FF F5 00 00", // Source MAC
"00 01 02 03 04 05", // Invalid (fake IPv6)
"80 00", // Version 6, traffic class E0, no flowlabel
"6E 00 00 00", // Payload length
"00 18", // Next header is authentication
"3A", // Hop limit
"FF", // Source IP
"00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00", // Destination IP
"FF 02 00 00 00 00 00 00 00 00 00 01 FF F5 00 00")).build());
verify(pktProcessService, times(0)).transmitPacket(any(TransmitPacketInput.class));
// invalid ipv6 header
pktHandler.onPacketReceived(new PacketReceivedBuilder().setPayload(ipv6TestUtils.buildPacket(// Destination MAC
"33 33 FF F5 00 00", // Source MAC
"00 01 02 03 04 05", // IPv6
"86 DD", // Version 6, traffic class E0, no flowlabel
"6E 00 00 00", // Payload length
"00 18", // Next header is authentication
"33", // Hop limit
"FF", // Source IP
"00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00", // Destination IP
"FF 02 00 00 00 00 00 00 00 00 00 01 FF F5 00 00")).build());
verify(pktProcessService, times(0)).transmitPacket(any(TransmitPacketInput.class));
// invalid icmpv6 header
pktHandler.onPacketReceived(new PacketReceivedBuilder().setPayload(ipv6TestUtils.buildPacket(// Destination MAC
"33 33 FF F5 00 00", // Source MAC
"00 01 02 03 04 05", // IPv6
"86 DD", // Version 6, traffic class E0, no flowlabel
"6E 00 00 00", // Payload length
"00 18", // Next header is ICMPv6
"3A", // Hop limit
"FF", // Source IP
"00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00", // Destination IP
"FF 02 00 00 00 00 00 00 00 00 00 01 FF F5 00 00", // ICMPv6 router solicitation
"85", // Code
"00", // Checksum (valid)
"67 3C", // ICMPv6 message body
"00 00 00 00", // Target
"FE 80 00 00 00 00 00 00 C0 00 54 FF FE F5 00 00")).build());
verify(pktProcessService, times(0)).transmitPacket(any(TransmitPacketInput.class));
}
Aggregations