- List<Routes> vpnExtraRoutes = VpnExtraRouteHelper.getAllVpnExtraRoutes(dataBroker,
- vpnName, usedRds, vrfEntry.getDestPrefix());
- // create loadbalancing groups for extra routes only when the extra route is present behind
- // multiple VMs
- if (!vpnExtraRoutes.isEmpty() && (vpnExtraRoutes.size() > 1
- || vpnExtraRoutes.get(0).getNexthopIpList().size() > 1)) {
- List<InstructionInfo> instructions = new ArrayList<>();
- // Obtain the local routes for this particular dpn.
- java.util.Optional<Routes> routes = vpnExtraRoutes
- .stream()
- .filter(route -> {
- Prefixes prefixToInterface = fibUtil.getPrefixToInterface(vpnId,
- fibUtil.getIpPrefix(route.getNexthopIpList().get(0)));
- if (prefixToInterface == null) {
- return false;
- }
- return remoteDpnId.equals(prefixToInterface.getDpnId());
- }).findFirst();
- long groupId = nextHopManager.createNextHopGroups(vpnId, rd, remoteDpnId, vrfEntry,
- routes.isPresent() ? routes.get() : null, vpnExtraRoutes);
- if (groupId == FibConstants.INVALID_GROUP_ID) {
- LOG.error("Unable to create Group for local prefix {} on rd {} on Node {}",
- vrfEntry.getDestPrefix(), rd, remoteDpnId.toString());
- return;
- }
- List<ActionInfo> actionInfos =
- Collections.singletonList(new ActionGroup(groupId));
- instructions.add(new InstructionApplyActions(actionInfos));
- baseVrfEntryHandler.makeConnectedRoute(remoteDpnId, vpnId, vrfEntry, rd, instructions,
- NwConstants.ADD_FLOW, TransactionAdapter.toWriteTransaction(tx), null);
+ List<Routes> vpnExtraRoutes =
+ VpnExtraRouteHelper.getAllVpnExtraRoutes(dataBroker, vpnName, usedRds, vrfEntry.getDestPrefix());
+ if (!vpnExtraRoutes.isEmpty()) {
+ programRemoteFibWithLoadBalancingGroups(remoteDpnId, vpnId, rd, vrfEntry, vpnExtraRoutes);