if (sn != null && !FibHelper.doesPrefixBelongToSubnet(ipPrefix, sn.getSubnetIp(), false)) {
continue;
}
- Adjacency vmAdj = new AdjacencyBuilder().setKey(new AdjacencyKey(ipPrefix)).setIpAddress(ipPrefix)
- .setMacAddress(port.getMacAddress().getValue()).setAdjacencyType(AdjacencyType.PrimaryAdjacency)
- .setSubnetId(ip.getSubnetId()).build();
- if (!adjList.contains(vmAdj)) {
- adjList.add(vmAdj);
- }
Subnetmap snTemp = sn != null ? sn : neutronvpnUtils.getSubnetmap(ip.getSubnetId());
- Uuid routerId = snTemp != null ? snTemp.getRouterId() : null;
Uuid vpnId = snTemp != null ? snTemp.getVpnId() : null;
if (vpnId != null) {
neutronvpnUtils.createVpnPortFixedIpToPort(vpnId.getValue(), ipValue,
- infName, port.getMacAddress().getValue(), isRouterInterface, wrtConfigTxn);
+ infName, port.getMacAddress().getValue(), isRouterInterface, wrtConfigTxn);
+ //Create Neutron port adjacency if VPN presence is existing for subnet
+ Adjacency vmAdj = new AdjacencyBuilder().setKey(new AdjacencyKey(ipPrefix)).setIpAddress(ipPrefix)
+ .setMacAddress(port.getMacAddress().getValue()).setAdjacencyType(AdjacencyType.PrimaryAdjacency)
+ .setSubnetId(ip.getSubnetId()).build();
+ if (!adjList.contains(vmAdj)) {
+ adjList.add(vmAdj);
+ }
}
+ Uuid routerId = snTemp != null ? snTemp.getRouterId() : null;
if (snTemp != null && snTemp.getInternetVpnId() != null) {
neutronvpnUtils.createVpnPortFixedIpToPort(sn.getInternetVpnId().getValue(),
ipValue, infName, port.getMacAddress().getValue(), isRouterInterface, wrtConfigTxn);
}
for (Adjacency adj : copyOldAdjs) {
if (!isBgpVpnInternetVpn || VpnUtil.isAdjacencyEligibleToVpnInternet(dataBroker, adj)) {
- delAdjFromVpnInterface(vpnInterfaceOpIdentifier, adj, dpnId,
- writeOperTxn, writeConfigTxn);
+ if (adj.getAdjacencyType() == AdjacencyType.PrimaryAdjacency
+ && !adj.isPhysNetworkFunc()) {
+ delAdjFromVpnInterface(vpnInterfaceOpIdentifier, adj, dpnId,
+ writeOperTxn, writeConfigTxn);
+ Optional<VpnInterfaceOpDataEntry> optVpnInterface = VpnUtil.read(dataBroker,
+ LogicalDatastoreType.OPERATIONAL, vpnInterfaceOpIdentifier);
+ VpnInterfaceOpDataEntry vpnInterfaceOpDataEntry = optVpnInterface.get();
+ long vpnId = VpnUtil.getVpnId(dataBroker, newVpnName);
+ VpnUtil.removePrefixToInterfaceAdj(dataBroker, adj, vpnId, vpnInterfaceOpDataEntry,
+ writeOperTxn);
+ //remove FIB entry
+ String vpnRd = VpnUtil.getVpnRd(dataBroker, newVpnName);
+ LOG.debug("update: remove prefix {} from the FIB and BGP entry "
+ + "for the Vpn-Rd {} ", adj.getIpAddress(), vpnRd);
+ //remove BGP entry
+ fibManager.removeFibEntry(vpnRd, adj.getIpAddress(), writeConfigTxn);
+ if (vpnRd != null && !vpnRd.equalsIgnoreCase(newVpnName)) {
+ bgpManager.withdrawPrefix(vpnRd, adj.getIpAddress());
+ }
+ } else {
+ delAdjFromVpnInterface(vpnInterfaceOpIdentifier, adj, dpnId,
+ writeOperTxn, writeConfigTxn);
+ }
}
LOG.info("update: Adjacency {} with nextHop {} label {} subnet {} removed from"
+ " vpn interface {} on vpn {}", adj.getIpAddress(), adj.getNextHopIpList(),
L3vpnInput input = new L3vpnInput().setNextHop(adj).setVpnName(vpnName)
.setInterfaceName(currVpnIntf.getName()).setPrimaryRd(primaryRd).setRd(primaryRd);
Adjacency operationalAdjacency = null;
- if (adj.getNextHopIpList() != null && !adj.getNextHopIpList().isEmpty()) {
+ //Handling dual stack neutron port primary adjacency
+ if (adj.getAdjacencyType() == AdjacencyType.PrimaryAdjacency && !adj.isPhysNetworkFunc()) {
+ LOG.trace("addNewAdjToVpnInterface: Adding prefix {} to existing interface {} for vpn {}", prefix,
+ currVpnIntf.getName(), vpnName);
+ Interface interfaceState = InterfaceUtils.getInterfaceStateFromOperDS(dataBroker,
+ currVpnIntf.getName());
+ if (interfaceState != null) {
+ processVpnInterfaceAdjacencies(dpnId, currVpnIntf.getLportTag().intValue(), vpnName, primaryRd,
+ currVpnIntf.getName(),
+ vpnId, writeConfigTxn, writeOperTxn, null, interfaceState);
+ }
+ }
+ if (adj.getNextHopIpList() != null && !adj.getNextHopIpList().isEmpty()
+ && adj.getAdjacencyType() != AdjacencyType.PrimaryAdjacency) {
RouteOrigin origin = adj.getAdjacencyType() == AdjacencyType.PrimaryAdjacency ? RouteOrigin.LOCAL
: RouteOrigin.STATIC;
String nh = adj.getNextHopIpList().get(0);
*
*/
for (Prefixes pref : prefixToInterface) {
- if (isMatchedPrefixToInterface(pref, del)) {
+ if (VpnUtil.isMatchedPrefixToInterface(pref, del)) {
if (writeOperTxn != null) {
writeOperTxn.delete(LogicalDatastoreType.OPERATIONAL,
VpnUtil.getPrefixToInterfaceIdentifier(vpnInstOp.getVpnId(), pref.getIpAddress()));
notifyTaskIfRequired(interfaceName);
}
- private boolean isMatchedPrefixToInterface(Prefixes prefix, VpnInterfaceOpDataEntry vpnInterface) {
- if (prefix != null && vpnInterface != null) {
- if (prefix.getDpnId() != null && vpnInterface.getDpnId() != null) {
- if (prefix.getVpnInterfaceName() != null && vpnInterface.getName() != null) {
- return prefix.getDpnId().equals(vpnInterface.getDpnId())
- && prefix.getVpnInterfaceName().equalsIgnoreCase(vpnInterface.getName());
- }
- }
- }
- return false;
- }
-
private void notifyTaskIfRequired(String intfName) {
Runnable notifyTask = vpnInterfaceManager.isNotifyTaskQueued(intfName);
if (notifyTask == null) {
.child(ElanDpnInterfacesList.class, new ElanDpnInterfacesListKey(elanInstanceName))
.build();
}
+
+ public static boolean isMatchedPrefixToInterface(Prefixes prefix, VpnInterfaceOpDataEntry vpnInterface) {
+ if (prefix != null && vpnInterface != null) {
+ if (prefix.getDpnId() != null && vpnInterface.getDpnId() != null) {
+ if (prefix.getVpnInterfaceName() != null && vpnInterface.getName() != null) {
+ return prefix.getDpnId().equals(vpnInterface.getDpnId())
+ && prefix.getVpnInterfaceName().equalsIgnoreCase(vpnInterface.getName());
+ }
+ }
+ }
+ return false;
+ }
+
+ public static void removePrefixToInterfaceAdj(DataBroker dataBroker, Adjacency adj, long vpnId,
+ VpnInterfaceOpDataEntry vpnInterfaceOpDataEntry,
+ WriteTransaction writeOperTxn) {
+ Optional<Prefixes> prefix = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL,
+ VpnUtil.getPrefixToInterfaceIdentifier(vpnId,
+ VpnUtil.getIpPrefix(adj.getIpAddress())));
+ List<Prefixes> prefixToInterface = new ArrayList<>();
+ List<Prefixes> prefixToInterfaceLocal = new ArrayList<>();
+ if (prefix.isPresent()) {
+ prefixToInterfaceLocal.add(prefix.get());
+ }
+ if (prefixToInterfaceLocal.isEmpty()) {
+ for (String nh : adj.getNextHopIpList()) {
+ prefix = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL,
+ VpnUtil.getPrefixToInterfaceIdentifier(vpnId,
+ VpnUtil.getIpPrefix(nh)));
+ if (prefix.isPresent()) {
+ prefixToInterfaceLocal.add(prefix.get());
+ }
+ }
+ }
+ if (!prefixToInterfaceLocal.isEmpty()) {
+ prefixToInterface.addAll(prefixToInterfaceLocal);
+ }
+ for (Prefixes pref : prefixToInterface) {
+ if (VpnUtil.isMatchedPrefixToInterface(pref, vpnInterfaceOpDataEntry)) {
+ if (writeOperTxn != null) {
+ writeOperTxn.delete(LogicalDatastoreType.OPERATIONAL,
+ VpnUtil.getPrefixToInterfaceIdentifier(vpnId, pref.getIpAddress()));
+ } else {
+ VpnUtil.delete(dataBroker, LogicalDatastoreType.OPERATIONAL,
+ VpnUtil.getPrefixToInterfaceIdentifier(vpnId, pref.getIpAddress()),
+ VpnUtil.DEFAULT_CALLBACK);
+ }
+ }
+ }
+ }
}