import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeMplsOverGre;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
List<String> prefixIpList;
LOG.trace("resolveAdjacency called with remotedDpnId {}, vpnId{}, VrfEntry {}",
remoteDpnId, vpnId, vrfEntry);
+ final Class<? extends TunnelTypeBase> tunnelType;
try {
if (RouteOrigin.value(vrfEntry.getOrigin()) != RouteOrigin.BGP) {
+ tunnelType = TunnelTypeVxlan.class;
List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnId, vrfEntry.getDestPrefix());
List<Routes> vpnExtraRoutes = VpnExtraRouteHelper.getAllVpnExtraRoutes(dataBroker,
fibUtil.getVpnNameFromId(vpnId), usedRds, vrfEntry.getDestPrefix());
}
} else {
prefixIpList = Collections.singletonList(vrfEntry.getDestPrefix());
+ if (vrfEntry.getEncapType() == VrfEntry.EncapType.Mplsgre) {
+ tunnelType = TunnelTypeMplsOverGre.class;
+ } else {
+ tunnelType = TunnelTypeVxlan.class;
+ }
}
for (String prefixIp : prefixIpList) {
if (routePaths == null || routePaths.isEmpty()) {
LOG.trace("Processing Destination IP {} without NextHop IP", prefixIp);
AdjacencyResult adjacencyResult = nextHopManager.getRemoteNextHopPointer(remoteDpnId, vpnId,
- prefixIp, null);
+ prefixIp, null, tunnelType);
addAdjacencyResultToList(adjacencyList, adjacencyResult);
continue;
}
LOG.debug("NextHop IP for destination {} is {}", prefixIp,
routePath.getNexthopAddress());
return nextHopManager.getRemoteNextHopPointer(remoteDpnId, vpnId,
- prefixIp, routePath.getNexthopAddress());
+ prefixIp, routePath.getNexthopAddress(), tunnelType);
})
.filter(adjacencyResult -> adjacencyResult != null && !adjacencyList.contains(adjacencyResult))
.distinct()
}
protected String getTunnelInterfaceName(BigInteger srcDpId, org.opendaylight.yang.gen.v1.urn.ietf.params
- .xml.ns.yang.ietf.inet.types.rev130715.IpAddress dstIp) {
- Class<? extends TunnelTypeBase> tunType = getReqTunType(getReqTransType().toUpperCase(Locale.getDefault()));
+ .xml.ns.yang.ietf.inet.types.rev130715.IpAddress dstIp, Class<? extends TunnelTypeBase> tunnelType) {
Future<RpcResult<GetInternalOrExternalInterfaceNameOutput>> result;
try {
+ LOG.debug("Trying to fetch tunnel interface name for source dpn {} destIp {} tunType {}", srcDpId,
+ dstIp.getValue(), tunnelType.getName());
result = itmManager.getInternalOrExternalInterfaceName(new GetInternalOrExternalInterfaceNameInputBuilder()
.setSourceDpid(srcDpId)
.setDestinationIp(dstIp)
- .setTunnelType(tunType)
+ .setTunnelType(tunnelType)
.build());
RpcResult<GetInternalOrExternalInterfaceNameOutput> rpcResult = result.get();
if (!rpcResult.isSuccessful()) {
}
public AdjacencyResult getRemoteNextHopPointer(BigInteger remoteDpnId, long vpnId, String prefixIp,
- String nextHopIp) {
+ String nextHopIp, Class<? extends TunnelTypeBase> tunnelType) {
String egressIfName = null;
LOG.trace("getRemoteNextHopPointer: input [remoteDpnId {}, vpnId {}, prefixIp {}, nextHopIp {} ]", remoteDpnId,
vpnId, prefixIp, nextHopIp);
}
if (Tunnel.class.equals(egressIfType)) {
- egressIfName = getTunnelRemoteNextHopPointer(remoteDpnId, nextHopIp);
+ egressIfName = getTunnelRemoteNextHopPointer(remoteDpnId, nextHopIp, tunnelType);
} else {
egressIfName = getExtPortRemoteNextHopPointer(remoteDpnId, elanInstance);
}
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
- private String getTunnelRemoteNextHopPointer(BigInteger remoteDpnId, String nextHopIp) {
+ private String getTunnelRemoteNextHopPointer(BigInteger remoteDpnId, String nextHopIp,
+ Class<? extends TunnelTypeBase> tunnelType) {
if (nextHopIp != null && !nextHopIp.isEmpty()) {
try {
// here use the config for tunnel type param
return getTunnelInterfaceName(remoteDpnId,
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder
- .getDefaultInstance(nextHopIp));
+ .getDefaultInstance(nextHopIp), tunnelType);
} catch (Exception ex) {
LOG.error("Error while retrieving nexthop pointer for nexthop {} remoteDpn {}",
nextHopIp, remoteDpnId, ex);
// There would be only one nexthop address for a VM ip which would be the tep Ip
String tepIp = tepIpAddresses.get(0);
AdjacencyResult adjacencyResult = getRemoteNextHopPointer(dpnId, vpnId,
- vrfEntry.getDestPrefix(), tepIp);
+ vrfEntry.getDestPrefix(), tepIp, TunnelTypeVxlan.class);
if (adjacencyResult == null) {
return;
}
return listBucketInfo;
}
- public void createDcGwLoadBalancingGroup(List<String> availableDcGws, BigInteger dpnId, String destinationIp) {
+ public void createDcGwLoadBalancingGroup(List<String> availableDcGws, BigInteger dpnId, String destinationIp,
+ Class<? extends TunnelTypeBase> tunnelType) {
Preconditions.checkNotNull(availableDcGws, "There are no dc-gws present");
int noOfDcGws = availableDcGws.size();
if (noOfDcGws == 1) {
Long groupId = createNextHopPointer(groupIdKey);
List<Bucket> listBucket = new ArrayList<>();
for (int index = 0; index < noOfDcGws; index++) {
- if (isTunnelUp(availableDcGws.get(index), dpnId)) {
- listBucket.add(buildBucketForDcGwLbGroup(availableDcGws.get(index), dpnId, index));
+ if (isTunnelUp(availableDcGws.get(index), dpnId, tunnelType)) {
+ listBucket.add(buildBucketForDcGwLbGroup(availableDcGws.get(index), dpnId, index, tunnelType));
}
}
Group group = MDSALUtil.buildGroup(groupId, groupIdKey, GroupTypes.GroupSelect,
LOG.trace("LB group {} towards DC-GW installed on dpn {}. Group - {}", groupIdKey, dpnId, group);
}
- private boolean isTunnelUp(String dcGwIp, BigInteger dpnId) {
- String tunnelName = getTunnelRemoteNextHopPointer(dpnId, dcGwIp);
+ private boolean isTunnelUp(String dcGwIp, BigInteger dpnId, Class<? extends TunnelTypeBase> tunnelType) {
+ String tunnelName = getTunnelRemoteNextHopPointer(dpnId, dcGwIp, tunnelType);
if (tunnelName != null) {
InstanceIdentifier<StateTunnelList> tunnelStateId =
InstanceIdentifier.builder(TunnelsState.class).child(
* The bucket is directly removed/added based on the operational status of the tunnel.
*/
public void updateDcGwLoadBalancingGroup(List<String> availableDcGws,
- BigInteger dpnId, String destinationIp, boolean isTunnelUp) {
+ BigInteger dpnId, String destinationIp, boolean isTunnelUp, Class<? extends TunnelTypeBase> tunnelType) {
Preconditions.checkNotNull(availableDcGws, "There are no dc-gws present");
ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(confTx -> {
// TODO : Place the logic to construct all possible DC-GW combination here.
final String groupId = nexthops.getGroupId();
final long groupIdValue = Long.parseLong(groupId);
if (isTunnelUp) {
- Bucket bucket = buildBucketForDcGwLbGroup(destinationIp, dpnId, bucketId);
+ Bucket bucket = buildBucketForDcGwLbGroup(destinationIp, dpnId, bucketId, tunnelType);
LOG.trace("Added bucket {} to group {} on dpn {}.", bucket, groupId, dpnId);
mdsalApiManager.addBucketToTx(dpnId, groupIdValue, bucket , confTx);
} else {
}), LOG, "Error updating load-balancing group");
}
- private Bucket buildBucketForDcGwLbGroup(String ipAddress, BigInteger dpnId,
- int index) {
+ private Bucket buildBucketForDcGwLbGroup(String ipAddress, BigInteger dpnId, int index,
+ Class<? extends TunnelTypeBase> tunnelType) {
List<Action> listAction = new ArrayList<>();
// ActionKey 0 goes to mpls label.
int actionKey = 1;
listAction.add(new ActionPushMpls().buildAction());
listAction.add(new ActionRegMove(actionKey++, FibConstants.NXM_REG_MAPPING
.get(index), 0, 19).buildAction());
- String tunnelInterfaceName = getTunnelInterfaceName(dpnId, new IpAddress(ipAddress.toCharArray()));
+ String tunnelInterfaceName = getTunnelInterfaceName(dpnId, new IpAddress(ipAddress.toCharArray()), tunnelType);
List<Action> egressActions = getEgressActions(tunnelInterfaceName, actionKey++);
if (!egressActions.isEmpty()) {
listAction.addAll(getEgressActions(tunnelInterfaceName, actionKey++));
MDSALUtil.WATCH_PORT, MDSALUtil.WATCH_GROUP);
}
- public void programDcGwLoadBalancingGroup(List<String> availableDcGws, BigInteger dpnId,
- String destinationIp, int addRemoveOrUpdate, boolean isTunnelUp) {
+ public void programDcGwLoadBalancingGroup(List<String> availableDcGws, BigInteger dpnId, String destinationIp,
+ int addRemoveOrUpdate, boolean isTunnelUp,
+ Class<? extends TunnelTypeBase> tunnelType) {
if (NwConstants.ADD_FLOW == addRemoveOrUpdate) {
- createDcGwLoadBalancingGroup(availableDcGws, dpnId, destinationIp);
+ createDcGwLoadBalancingGroup(availableDcGws, dpnId, destinationIp, tunnelType);
} else if (NwConstants.DEL_FLOW == addRemoveOrUpdate) {
removeOrUpdateDcGwLoadBalancingGroup(availableDcGws, dpnId, destinationIp);
} else if (NwConstants.MOD_FLOW == addRemoveOrUpdate) {
- updateDcGwLoadBalancingGroup(availableDcGws, dpnId, destinationIp, isTunnelUp);
+ updateDcGwLoadBalancingGroup(availableDcGws, dpnId, destinationIp, isTunnelUp, tunnelType);
}
}
}