ed744e551f72ce1b6774536e6ef95714d2dcaf1b
[netvirt.git] / vpnmanager / impl / src / main / java / org / opendaylight / netvirt / vpnmanager / intervpnlink / IVpnLinkServiceImpl.java
1 /*
2  * Copyright (c) 2017 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.netvirt.vpnmanager.intervpnlink;
9
10 import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
11
12 import com.google.common.base.Optional;
13 import com.google.common.base.Preconditions;
14 import java.math.BigInteger;
15 import java.util.ArrayList;
16 import java.util.Collections;
17 import java.util.HashMap;
18 import java.util.List;
19 import java.util.Map;
20 import java.util.Objects;
21 import java.util.stream.Collectors;
22 import javax.annotation.Nullable;
23 import javax.annotation.PostConstruct;
24 import javax.annotation.PreDestroy;
25 import javax.inject.Inject;
26 import javax.inject.Singleton;
27 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
28 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
29 import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
30 import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
31 import org.opendaylight.genius.mdsalutil.MDSALUtil;
32 import org.opendaylight.genius.mdsalutil.NwConstants;
33 import org.opendaylight.infrautils.utils.concurrent.ListenableFutures;
34 import org.opendaylight.netvirt.bgpmanager.api.IBgpManager;
35 import org.opendaylight.netvirt.fibmanager.api.FibHelper;
36 import org.opendaylight.netvirt.fibmanager.api.IFibManager;
37 import org.opendaylight.netvirt.fibmanager.api.RouteOrigin;
38 import org.opendaylight.netvirt.neutronvpn.api.utils.NeutronUtils;
39 import org.opendaylight.netvirt.vpnmanager.VpnConstants;
40 import org.opendaylight.netvirt.vpnmanager.VpnUtil;
41 import org.opendaylight.netvirt.vpnmanager.api.InterfaceUtils;
42 import org.opendaylight.netvirt.vpnmanager.api.intervpnlink.IVpnLinkService;
43 import org.opendaylight.netvirt.vpnmanager.api.intervpnlink.InterVpnLinkCache;
44 import org.opendaylight.netvirt.vpnmanager.api.intervpnlink.InterVpnLinkDataComposite;
45 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
46 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntryBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntryKey;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.VpnMaps;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.VpnMap;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.l3.attributes.Routes;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.Routers;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.Router;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
60 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
61 import org.slf4j.Logger;
62 import org.slf4j.LoggerFactory;
63
64 @Singleton
65 public class IVpnLinkServiceImpl implements IVpnLinkService, AutoCloseable {
66
67     private static final Logger LOG = LoggerFactory.getLogger(IVpnLinkServiceImpl.class);
68
69     private final DataBroker dataBroker;
70     private final ManagedNewTransactionRunner txRunner;
71     private final IdManagerService idManager;
72     private final IBgpManager bgpManager;
73     private final IFibManager fibManager;
74     private final InterVpnLinkCache interVpnLinkCache;
75     private final VpnUtil vpnUtil;
76     private final InterVpnLinkUtil interVpnLinkUtil;
77
78     @Inject
79     public IVpnLinkServiceImpl(final DataBroker dataBroker, final IdManagerService idMgr, final IBgpManager bgpMgr,
80                                final IFibManager fibMgr, final InterVpnLinkCache interVpnLinkCache,
81                                VpnUtil vpnUtil, InterVpnLinkUtil interVpnLinkUtil) {
82         this.dataBroker = dataBroker;
83         this.txRunner = new ManagedNewTransactionRunnerImpl(dataBroker);
84         this.idManager = idMgr;
85         this.bgpManager = bgpMgr;
86         this.fibManager = fibMgr;
87         this.interVpnLinkCache = interVpnLinkCache;
88         this.vpnUtil = vpnUtil;
89         this.interVpnLinkUtil = interVpnLinkUtil;
90     }
91
92     @PostConstruct
93     public void start() {
94         LOG.info("{} start", getClass().getSimpleName());
95     }
96
97     @Override
98     @PreDestroy
99     public void close() {
100     }
101
102     @Override
103     public void leakRoute(String vpnName, String prefix, List<String> nextHopList, int label, int addOrRemove) {
104         LOG.trace("leakRoute: vpnName={}  prefix={}  nhList={}  label={}", vpnName, prefix, nextHopList, label);
105         Optional<InterVpnLinkDataComposite> optIVpnLink = interVpnLinkCache.getInterVpnLinkByVpnId(vpnName);
106         if (!optIVpnLink.isPresent()) {
107             LOG.debug("Vpn {} not involved in any InterVpnLink", vpnName);
108             return;
109         }
110         leakRoute(optIVpnLink.get(), vpnName, prefix, nextHopList, label, addOrRemove);
111     }
112
113     // TODO Clean up the exception handling
114     @SuppressWarnings("checkstyle:IllegalCatch")
115     private void leakRoute(InterVpnLinkDataComposite interVpnLink, String vpnName, String prefix,
116                            List<String> nextHopList, int label, int addOrRemove) {
117
118         String dstVpnName = interVpnLink.getOtherVpnName(vpnName);
119
120         LOG.trace("leakingRoute: from VPN={} to VPN={}: prefix={}  nhList={}  label={}",
121                   vpnName, dstVpnName, prefix, nextHopList, label);
122
123         // For leaking, we need the InterVpnLink to be active.
124         if (addOrRemove == NwConstants.ADD_FLOW && !interVpnLink.isActive()) {
125             LOG.warn("Cannot leak route [prefix={}, label={}] from VPN {} to VPN {} because "
126                      + "InterVpnLink {} is not active",
127                      prefix, label, vpnName, dstVpnName, interVpnLink.getInterVpnLinkName());
128             return;
129         }
130
131         String dstVpnRd = vpnUtil.getVpnRd(dstVpnName);
132         if (addOrRemove == NwConstants.ADD_FLOW) {
133             LOG.debug("Leaking route (prefix={}, nexthop={}) from Vpn={} to Vpn={} (RD={})",
134                       prefix, nextHopList, vpnName, dstVpnName, dstVpnRd);
135             String key = dstVpnRd + VpnConstants.SEPARATOR + prefix;
136             long leakedLabel = vpnUtil.getUniqueId(VpnConstants.VPN_IDPOOL_NAME, key);
137             String leakedNexthop = interVpnLink.getEndpointIpAddr(vpnName);
138             fibManager.addOrUpdateFibEntry(dstVpnRd, null /*macAddress*/, prefix,
139                                            Collections.singletonList(leakedNexthop), VrfEntry.EncapType.Mplsgre,
140                                            (int) leakedLabel, 0 /*l3vni*/, null /*gatewayMacAddress*/,
141                                            null /*parentVpnRd*/, RouteOrigin.INTERVPN, null /*writeConfigTxn*/);
142
143             List<String> ivlNexthops =
144                 interVpnLink.getEndpointDpnsByVpnName(dstVpnName).stream()
145                             .map(dpnId -> InterfaceUtils.getEndpointIpAddressForDPN(dataBroker, dpnId))
146                             .collect(Collectors.toList());
147             try {
148                 bgpManager.advertisePrefix(dstVpnRd, null /*macAddress*/, prefix, ivlNexthops,
149                                            VrfEntry.EncapType.Mplsgre, (int)leakedLabel, 0 /*l3vni*/, 0 /*l2vni*/,
150                                            null /*gwMacAddress*/);
151             } catch (Exception e) {
152                 LOG.error("Exception while advertising prefix {} on vpnRd {} for intervpn link", prefix, dstVpnRd, e);
153             }
154         } else {
155             LOG.debug("Removing leaked route to {} from VPN {}", prefix, dstVpnName);
156             fibManager.removeFibEntry(dstVpnRd, prefix, null /*writeConfigTxn*/);
157             bgpManager.withdrawPrefix(dstVpnRd, prefix);
158         }
159     }
160
161     // TODO Clean up the exception handling
162     @SuppressWarnings("checkstyle:IllegalCatch")
163     @Override
164     public void leakRoute(InterVpnLinkDataComposite interVpnLink, String srcVpnUuid, String dstVpnUuid,
165                           String prefix, Long label, @Nullable RouteOrigin forcedOrigin) {
166         String ivpnLinkName = interVpnLink.getInterVpnLinkName();
167         // The source VPN must participate in the InterVpnLink
168         Preconditions.checkArgument(interVpnLink.isVpnLinked(srcVpnUuid),
169                                     "The source VPN {} does not participate in the interVpnLink {}",
170                                     srcVpnUuid, ivpnLinkName);
171         // The destination VPN must participate in the InterVpnLink
172         Preconditions.checkArgument(interVpnLink.isVpnLinked(dstVpnUuid),
173                                     "The destination VPN {} does not participate in the interVpnLink {}",
174                                     dstVpnUuid, ivpnLinkName);
175
176         String endpointIp = interVpnLink.getOtherEndpointIpAddr(dstVpnUuid);
177         String leakedOrigin = forcedOrigin != null ? forcedOrigin.getValue() : RouteOrigin.INTERVPN.getValue();
178         FibHelper.buildRoutePath(endpointIp, label);
179         VrfEntry newVrfEntry =
180             new VrfEntryBuilder().withKey(new VrfEntryKey(prefix)).setDestPrefix(prefix)
181                                  .setRoutePaths(Collections.singletonList(FibHelper.buildRoutePath(endpointIp, label)))
182                                  .setOrigin(leakedOrigin).build();
183
184         String dstVpnRd = vpnUtil.getVpnRd(dstVpnUuid);
185         InstanceIdentifier<VrfEntry> newVrfEntryIid =
186             InstanceIdentifier.builder(FibEntries.class)
187                               .child(VrfTables.class, new VrfTablesKey(dstVpnRd))
188                               .child(VrfEntry.class, new VrfEntryKey(newVrfEntry.getDestPrefix()))
189                               .build();
190         ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx ->
191             tx.put(newVrfEntryIid, newVrfEntry)), LOG, "Error adding VRF entry {}", newVrfEntry);
192
193         // Finally, route is advertised it to the DC-GW. But while in the FibEntries the nexthop is the other
194         // endpoint's IP, in the DC-GW the nexthop for those prefixes are the IPs of those DPNs where the target
195         // VPN has been instantiated
196         List<BigInteger> srcDpnList = interVpnLink.getEndpointDpnsByVpnName(srcVpnUuid);
197         List<String> nexthops =
198             srcDpnList.stream().map(dpnId -> InterfaceUtils.getEndpointIpAddressForDPN(dataBroker, dpnId))
199                                .collect(Collectors.toList());
200
201         LOG.debug("Advertising route in VPN={} [prefix={} label={}  nexthops={}] to DC-GW",
202                   dstVpnRd, newVrfEntry.getDestPrefix(), label.intValue(), nexthops);
203         try {
204             bgpManager.advertisePrefix(dstVpnRd, null /*macAddress*/, prefix, nexthops,
205                                        VrfEntry.EncapType.Mplsgre, label.intValue(), 0 /*l3vni*/, 0 /*l2vni*/,
206                                        null /*gwMacAddress*/);
207         } catch (Exception e) {
208             LOG.error("Exception while advertising prefix {} on vpnRd {} for intervpn link", prefix, dstVpnRd, e);
209         }
210     }
211
212     @Override
213     public void leakRouteIfNeeded(String vpnName, String prefix, List<String> nextHopList, int label,
214                                   RouteOrigin origin, int addOrRemove) {
215
216         Optional<InterVpnLinkDataComposite> optIVpnLink = interVpnLinkCache.getInterVpnLinkByVpnId(vpnName);
217         if (!optIVpnLink.isPresent()) {
218             LOG.debug("Vpn {} not involved in any InterVpnLink", vpnName);
219             return;
220         }
221         InterVpnLinkDataComposite ivpnLink = optIVpnLink.get();
222         if (addOrRemove == NwConstants.ADD_FLOW && !ivpnLink.isActive()) {
223             // Note: for the removal case it is not necessary that ivpnlink is ACTIVE
224             LOG.debug("Route to {} in VPN {} cannot be leaked because InterVpnLink {} is not ACTIVE",
225                       prefix, vpnName, ivpnLink.getInterVpnLinkName());
226             return;
227         }
228
229         switch (origin) {
230             case BGP:
231                 if (!ivpnLink.isBgpRoutesLeaking()) {
232                     LOG.debug("BGP route to {} not leaked because bgp-routes-leaking is disabled", prefix);
233                     return;
234                 }
235                 leakRoute(vpnName, prefix, nextHopList, label, addOrRemove);
236                 break;
237             case STATIC:
238                 /* NOTE: There are 2 types of static routes depending on the next hop:
239                     + static route when next hop is a VM, the DC-GW or a DPNIP
240                     + static route when next hop is an Inter-VPN Link
241                  Only the 1st type should be considered since the 2nd has a special treatment */
242                 if (!ivpnLink.isStaticRoutesLeaking()) {
243                     LOG.debug("Static route to {} not leaked because static-routes-leaking is disabled", prefix);
244                     return;
245                 }
246                 leakRoute(vpnName, prefix, nextHopList, label, addOrRemove);
247                 break;
248             case CONNECTED:
249                 if (!ivpnLink.isConnectedRoutesLeaking()) {
250                     LOG.debug("Connected route to {} not leaked because connected-routes-leaking is disabled", prefix);
251                     return;
252                 }
253                 leakRoute(vpnName, prefix, nextHopList, label, addOrRemove);
254                 break;
255             default:
256                 LOG.warn("origin {} not considered in Route-leaking", origin.getValue());
257         }
258
259     }
260
261     @Override
262     public void exchangeRoutes(InterVpnLinkDataComposite ivpnLink) {
263         if (!ivpnLink.isComplete()) {
264             return;
265         }
266
267         // The type of routes to exchange depend on the leaking flags that have been activated
268         List<RouteOrigin> originsToConsider = new ArrayList<>();
269         if (ivpnLink.isBgpRoutesLeaking()) {
270             originsToConsider.add(RouteOrigin.BGP);
271         }
272         if (ivpnLink.isStaticRoutesLeaking()) {
273             originsToConsider.add(RouteOrigin.STATIC);
274         }
275         if (ivpnLink.isConnectedRoutesLeaking()) {
276             originsToConsider.add(RouteOrigin.CONNECTED);
277         }
278
279         String vpn1Uuid = ivpnLink.getFirstEndpointVpnUuid().get();
280         String vpn2Uuid = ivpnLink.getSecondEndpointVpnUuid().get();
281
282         if (! originsToConsider.isEmpty()) {
283             // 1st Endpoint ==> 2nd endpoint
284             leakRoutes(ivpnLink, vpn1Uuid, vpn2Uuid, originsToConsider);
285
286
287             // 2nd Endpoint ==> 1st endpoint
288             leakRoutes(ivpnLink, vpn2Uuid, vpn1Uuid, originsToConsider);
289         }
290
291         // Static routes in Vpn1 pointing to Vpn2's endpoint
292         leakExtraRoutesToVpnEndpoint(ivpnLink, vpn1Uuid, vpn2Uuid);
293
294         // Static routes in Vpn2 pointing to Vpn1's endpoint
295         leakExtraRoutesToVpnEndpoint(ivpnLink, vpn2Uuid, vpn1Uuid);
296     }
297
298     /*
299      * Checks if there are static routes in Vpn1 whose nexthop is Vpn2's endpoint.
300      * Those routes must be leaked to Vpn1.
301      *
302      * @param vpnLink
303      * @param vpn1Uuid
304      * @param vpn2Uuid
305      */
306     private void leakExtraRoutesToVpnEndpoint(InterVpnLinkDataComposite vpnLink, String vpn1Uuid, String vpn2Uuid) {
307
308         String vpn1Rd = vpnUtil.getVpnRd(vpn1Uuid);
309         String vpn2Endpoint = vpnLink.getOtherEndpointIpAddr(vpn2Uuid);
310         List<VrfEntry> allVpnVrfEntries = vpnUtil.getAllVrfEntries(vpn1Rd);
311         for (VrfEntry vrfEntry : allVpnVrfEntries) {
312             vrfEntry.nonnullRoutePaths().stream()
313                     .filter(routePath -> Objects.equals(routePath.getNexthopAddress(), vpn2Endpoint))
314                     .forEach(routePath -> {
315                         // Vpn1 has a route pointing to Vpn2's endpoint. Forcing the leaking of the route will update
316                         // the BGP accordingly
317                         long label = vpnUtil.getUniqueId(VpnConstants.VPN_IDPOOL_NAME,
318                                                          VpnUtil.getNextHopLabelKey(vpn1Rd, vrfEntry.getDestPrefix()));
319                         if (label == VpnConstants.INVALID_LABEL) {
320                             LOG.error("Unable to fetch label from Id Manager. Bailing out of leaking extra routes for "
321                                       + "InterVpnLink {} rd {} prefix {}",
322                                       vpnLink.getInterVpnLinkName(), vpn1Rd, vrfEntry.getDestPrefix());
323                         } else {
324                             leakRoute(vpnLink, vpn2Uuid, vpn1Uuid, vrfEntry.getDestPrefix(), label,
325                                       RouteOrigin.value(vrfEntry.getOrigin()));
326                         }
327                     });
328
329         }
330     }
331
332     private void leakRoutes(InterVpnLinkDataComposite vpnLink, String srcVpnUuid, String dstVpnUuid,
333                             List<RouteOrigin> originsToConsider) {
334         String srcVpnRd = vpnUtil.getVpnRd(srcVpnUuid);
335         String dstVpnRd = vpnUtil.getVpnRd(dstVpnUuid);
336         List<VrfEntry> srcVpnRemoteVrfEntries = vpnUtil.getVrfEntriesByOrigin(srcVpnRd, originsToConsider);
337         for (VrfEntry vrfEntry : srcVpnRemoteVrfEntries) {
338             long label = vpnUtil.getUniqueId(VpnConstants.VPN_IDPOOL_NAME,
339                                              VpnUtil.getNextHopLabelKey(dstVpnRd, vrfEntry.getDestPrefix()));
340             if (label == VpnConstants.INVALID_LABEL) {
341                 LOG.error("Unable to fetch label from Id Manager. Bailing out of leaking routes for InterVpnLink {} "
342                           + "rd {} prefix {}",
343                         vpnLink.getInterVpnLinkName(), dstVpnRd, vrfEntry.getDestPrefix());
344                 continue;
345             }
346             leakRoute(vpnLink, srcVpnUuid, dstVpnUuid, vrfEntry.getDestPrefix(), label, null /*NotForcedOrigin*/);
347         }
348     }
349
350     private Map<String, String> buildRouterXL3VPNMap() {
351         InstanceIdentifier<VpnMaps> vpnMapsIdentifier = InstanceIdentifier.builder(VpnMaps.class).build();
352         Optional<VpnMaps> optVpnMaps =
353             MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnMapsIdentifier);
354         if (!optVpnMaps.isPresent()) {
355             LOG.info("Could not retrieve VpnMaps object from Configurational DS");
356             return new HashMap<>();
357         }
358         Map<String,String> vmap = new HashMap<>();
359         final List<VpnMap> VpnMapList = optVpnMaps.get().nonnullVpnMap();
360         for (VpnMap map : VpnMapList) {
361             if (map.getRouterIds() == null) {
362                 continue;
363             }
364             final List<Uuid> vpnRouterIds = NeutronUtils.getVpnMapRouterIdsListUuid(map.getRouterIds());
365             for (Uuid routerId : vpnRouterIds) {
366                 if (map.getVpnId().getValue().equalsIgnoreCase(routerId.getValue())) {
367                     break; // VPN is internal
368                 }
369                 vmap.put(routerId.getValue(), map.getVpnId().getValue());
370             }
371         }
372         return vmap;
373     }
374
375
376     @Override
377     public void handleStaticRoutes(InterVpnLinkDataComposite ivpnLink) {
378         /*
379          * Checks if there are any static routes pointing to any of both
380          * InterVpnLink's endpoints. Goes through all routers checking if they have
381          * a route whose nexthop is an InterVpnLink endpoint
382          */
383
384         // Map that corresponds a routerId with the L3VPN that it's been assigned to.
385         Map<String, String> routerXL3VpnMap = buildRouterXL3VPNMap();
386
387         // Retrieving all Routers
388         InstanceIdentifier<Routers> routersIid = InstanceIdentifier.builder(Neutron.class)
389                 .child(Routers.class).build();
390         Optional<Routers> routerOpData = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, routersIid);
391         if (!routerOpData.isPresent()) {
392
393             return;
394         }
395         List<Router> routers = routerOpData.get().nonnullRouter();
396         for (Router router : routers) {
397             String vpnId = routerXL3VpnMap.get(router.getUuid().getValue());
398             if (vpnId == null) {
399                 LOG.warn("Could not find suitable VPN for router {}", router.getUuid());
400                 continue; // with next router
401             }
402             List<Routes> routerRoutes = router.getRoutes();
403             if (routerRoutes != null) {
404                 for (Routes route : routerRoutes) {
405                     handleStaticRoute(vpnId, route, ivpnLink);
406                 }
407             }
408         }
409     }
410
411     /*
412      * Takes care of an static route to see if flows related to interVpnLink
413      * must be installed in tables 20 and 17
414      *
415      * @param vpnId Vpn to which the route belongs
416      * @param route Route to handle. Will only be considered if its nexthop is the VPN's endpoint IpAddress
417      *              at the other side of the InterVpnLink
418      * @param iVpnLink
419      */
420     @SuppressWarnings("checkstyle:IllegalCatch")
421     private void handleStaticRoute(String vpnId, Routes route, InterVpnLinkDataComposite ivpnLink) {
422
423         IpAddress nhIpAddr = route.getNexthop();
424         String routeNextHop = nhIpAddr.getIpv4Address() != null ? nhIpAddr.getIpv4Address().getValue()
425                                                                   : nhIpAddr.getIpv6Address().getValue();
426         String destination = route.getDestination().stringValue();
427
428         // is nexthop the other endpoint's IP
429         String otherEndpoint = ivpnLink.getOtherEndpoint(vpnId);
430         if (!routeNextHop.equals(otherEndpoint)) {
431             LOG.debug("VPN {}: Route to {} nexthop={} points to an InterVpnLink endpoint, but its not "
432                       + "the other endpoint. Other endpoint is {}",
433                       vpnId, destination, routeNextHop, otherEndpoint);
434             return;
435         }
436
437         // Lets work: 1) write Fibentry, 2) advertise to BGP and 3) check if it must be leaked
438         String vpnRd = vpnUtil.getVpnRd(vpnId);
439         if (vpnRd == null) {
440             LOG.warn("Could not find Route-Distinguisher for VpnName {}", vpnId);
441             return;
442         }
443
444         int label = vpnUtil.getUniqueId(VpnConstants.VPN_IDPOOL_NAME, VpnUtil.getNextHopLabelKey(vpnId, destination));
445
446         try {
447             interVpnLinkUtil.handleStaticRoute(ivpnLink, vpnId, destination, routeNextHop, label);
448         } catch (Exception e) {
449             LOG.error("Exception while advertising prefix for intervpn link, {}", e);
450         }
451     }
452 }