use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.Adjacency in project netvirt by opendaylight.
the class AbstractIpLearnNotificationHandler method validateAndProcessIpLearning.
protected void validateAndProcessIpLearning(String srcInterface, IpAddress srcIP, MacAddress srcMac, IpAddress targetIP, Uint64 metadata) {
List<Adjacency> adjacencies = vpnUtil.getAdjacenciesForVpnInterfaceFromConfig(srcInterface);
IpVersionChoice srcIpVersion = VpnUtil.getIpVersionFromString(srcIP.stringValue());
boolean isSrcIpVersionPartOfVpn = false;
if (adjacencies != null && !adjacencies.isEmpty()) {
for (Adjacency adj : adjacencies) {
IpPrefix ipPrefix = IpPrefixBuilder.getDefaultInstance(adj.getIpAddress());
// If extra/static route is configured, we should ignore for learning process
if (NWUtil.isIpAddressInRange(srcIP, ipPrefix)) {
return;
}
IpVersionChoice currentAdjIpVersion = VpnUtil.getIpVersionFromString(adj.getIpAddress());
if (srcIpVersion.isIpVersionChosen(currentAdjIpVersion)) {
isSrcIpVersionPartOfVpn = true;
}
}
// If srcIP version is not part of the srcInterface VPN Adjacency, ignore IpLearning process
if (!isSrcIpVersionPartOfVpn) {
return;
}
}
LOG.trace("ARP/NA Notification Response Received from interface {} and IP {} having MAC {}, learning MAC", srcInterface, srcIP.stringValue(), srcMac.getValue());
processIpLearning(srcInterface, srcIP, srcMac, metadata, targetIP);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.Adjacency in project netvirt by opendaylight.
the class IpMonitorStopTask method call.
@Override
public List<ListenableFuture<Void>> call() {
final List<ListenableFuture<Void>> futures = new ArrayList<>();
java.util.Optional<Uint32> monitorIdOptional = alivenessMonitorUtils.getMonitorIdFromInterface(macEntry);
if (monitorIdOptional.isPresent()) {
alivenessMonitorUtils.stopIpMonitoring(monitorIdOptional.get());
} else {
LOG.warn("MonitorId not available for IP {} interface {}. IpMonitoring not stopped", macEntry.getIpAddress(), macEntry.getInterfaceName());
}
String learntIp = macEntry.getIpAddress().getHostAddress();
if (this.isRemoveMipAdjAndLearntIp) {
String vpnName = macEntry.getVpnName();
LearntVpnVipToPort vpnVipToPort = vpnUtil.getLearntVpnVipToPort(vpnName, learntIp);
if (vpnVipToPort != null && !Objects.equals(vpnVipToPort.getCreationTime(), macEntry.getCreatedTime())) {
LOG.warn("The MIP {} over vpn {} has been learnt again and processed. " + "Ignoring this remove event.", learntIp, vpnName);
return futures;
}
vpnUtil.removeLearntVpnVipToPort(macEntry.getVpnName(), macEntry.getIpAddress().getHostAddress(), null);
vpnUtil.removeVpnPortFixedIpToPort(dataBroker, macEntry.getVpnName(), macEntry.getIpAddress().getHostAddress(), null);
LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.CONFIGURATION, tx -> vpnUtil.removeMipAdjacency(macEntry.getVpnName(), macEntry.getInterfaceName(), macEntry.getIpAddress().getHostAddress(), tx)), LOG, "ArpMonitorStopTask: Error writing to datastore for Vpn {} IP {}", macEntry.getVpnName(), macEntry.getIpAddress().getHostAddress());
} else {
// Delete only MIP adjacency
vpnUtil.removeMipAdjacency(macEntry.getInterfaceName(), learntIp);
}
return futures;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.Adjacency in project netvirt by opendaylight.
the class L3vpnOverMplsGrePopulator method createOperationalAdjacency.
@Override
public Adjacency createOperationalAdjacency(L3vpnInput input) {
Adjacency nextHop = input.getNextHop();
String nextHopIp = input.getNextHopIp();
String prefix = VpnUtil.getIpPrefix(nextHop.getIpAddress());
List<String> adjNextHop = nextHop.getNextHopIpList();
String rd = input.getRd();
String primaryRd = input.getPrimaryRd();
String vpnName = input.getVpnName();
Uint32 label = vpnUtil.getUniqueId(VpnConstants.VPN_IDPOOL_NAME, VpnUtil.getNextHopLabelKey(primaryRd, prefix));
if (label.longValue() == VpnConstants.INVALID_LABEL) {
String error = "Unable to fetch label from Id Manager. Bailing out of creation of operational " + "vpn interface adjacency " + prefix + "for vpn " + vpnName;
throw new NullPointerException(error);
}
List<String> nextHopList = adjNextHop != null && !adjNextHop.isEmpty() ? adjNextHop : nextHopIp == null ? Collections.emptyList() : singletonList(nextHopIp);
return new AdjacencyBuilder(nextHop).setLabel(label).setNextHopIpList(nextHopList).setIpAddress(prefix).setVrfId(rd).withKey(new AdjacencyKey(prefix)).setAdjacencyType(nextHop.getAdjacencyType()).setSubnetGatewayMacAddress(nextHop.getSubnetGatewayMacAddress()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.Adjacency in project netvirt by opendaylight.
the class L3vpnOverVxlanPopulator method populateFib.
@Override
public void populateFib(L3vpnInput input, TypedWriteTransaction<Configuration> writeConfigTxn) {
if (input.getRouteOrigin() == RouteOrigin.CONNECTED) {
LOG.info("populateFib : Found SubnetRoute for subnet {} rd {}", input.getSubnetIp(), input.getPrimaryRd());
addSubnetRouteFibEntry(input);
return;
}
String rd = input.getRd();
String primaryRd = input.getPrimaryRd();
Adjacency nextHop = input.getNextHop();
LOG.info("populateFib : Found Interface Adjacency with prefix {} rd {}", nextHop.getIpAddress(), primaryRd);
if (!rd.equalsIgnoreCase(input.getVpnName()) && !rd.equals(input.getNetworkName())) {
Objects.requireNonNull(input.getRouteOrigin(), "populateFib: RouteOrigin is mandatory");
addPrefixToBGP(rd, primaryRd, nextHop.getMacAddress(), nextHop.getIpAddress(), input.getNextHopIp(), input.getEncapType(), Uint32.ZERO, /*label*/
Uint32.valueOf(input.getL3vni()), input.getGatewayMac(), input.getRouteOrigin(), writeConfigTxn);
} else {
LOG.error("Internal VPN for L3 Over VxLAN is not supported. Aborting.");
return;
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.Adjacency in project netvirt by opendaylight.
the class NeutronvpnNatManager method removeAdjacencyAndLearnedEntriesforExternalSubnet.
private void removeAdjacencyAndLearnedEntriesforExternalSubnet(Uuid extNetId, Uuid extSubnetId) {
Collection<String> extElanInterfaces = elanService.getExternalElanInterfaces(extNetId.getValue());
if (extElanInterfaces == null || extElanInterfaces.isEmpty()) {
LOG.error("No external ports attached to external network {}", extNetId.getValue());
return;
}
for (String infName : extElanInterfaces) {
InstanceIdentifier<VpnInterface> vpnIfIdentifier = InstanceIdentifier.builder(VpnInterfaces.class).child(VpnInterface.class, new VpnInterfaceKey(infName)).build();
InstanceIdentifier<Adjacencies> adjacenciesIdentifier = vpnIfIdentifier.augmentation(Adjacencies.class);
try {
// Looking for existing prefix in MDSAL database
Optional<Adjacencies> optionalAdjacencies = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, adjacenciesIdentifier);
if (optionalAdjacencies.isPresent()) {
Map<AdjacencyKey, Adjacency> keyAdjacencyMap = optionalAdjacencies.get().nonnullAdjacency();
Iterator<Adjacency> adjacencyIter = keyAdjacencyMap.values().iterator();
while (adjacencyIter.hasNext()) {
Adjacency adjacency = adjacencyIter.next();
if (!adjacency.getSubnetId().equals(extSubnetId)) {
continue;
}
InstanceIdentifier<Adjacency> adjacencyIdentifier = adjacenciesIdentifier.child(Adjacency.class, new AdjacencyKey(adjacency.getIpAddress()));
SingleTransactionDataBroker.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, adjacencyIdentifier);
LOG.trace("Removed Adjacency for fixedIP {} for port {} on external subnet {} ", adjacency.getIpAddress(), infName, extSubnetId);
String extNetVpnName = extNetId.getValue();
String learnedSrcIp = adjacency.getIpAddress().split("/")[0];
InstanceIdentifier<LearntVpnVipToPort> id = NeutronvpnUtils.buildLearntVpnVipToPortIdentifier(extNetVpnName, learnedSrcIp);
Optional<LearntVpnVipToPort> optionalLearntVpnVipToPort = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
if (optionalLearntVpnVipToPort.isPresent()) {
neutronvpnUtils.removeLearntVpnVipToPort(extNetVpnName, learnedSrcIp);
LOG.trace("Removed Learnt Entry for fixedIP {} for port {}", adjacency.getIpAddress(), infName);
}
}
}
} catch (TransactionCommitFailedException | ExecutionException | InterruptedException e) {
LOG.error("exception in removeAdjacencyAndLearnedEntriesforExternalSubnet for interface {}", infName, e);
}
}
}
Aggregations