import org.opendaylight.genius.mdsalutil.MDSALUtil;
import org.opendaylight.genius.mdsalutil.MatchInfo;
import org.opendaylight.genius.mdsalutil.MetaDataUtil;
+import org.opendaylight.genius.mdsalutil.NWUtil;
import org.opendaylight.genius.mdsalutil.NwConstants;
import org.opendaylight.genius.mdsalutil.actions.ActionPopMpls;
import org.opendaylight.genius.mdsalutil.actions.ActionRegLoad;
* @param lportTag Pseudo Logical Port tag
* @return the FlowEntity
*/
- public static FlowEntity buildLFibVpnPseudoPortFlow(BigInteger dpId, Long label, String nextHop, int lportTag) {
+ public static FlowEntity buildLFibVpnPseudoPortFlow(BigInteger dpId, Long label, int etherType, String nextHop,
+ int lportTag) {
List<MatchInfo> matches = new ArrayList<>();
matches.add(MatchEthernetType.MPLS_UNICAST);
matches.add(new MatchMplsLabel(label));
- List<ActionInfo> actionsInfos = Collections.singletonList(new ActionPopMpls());
+ List<ActionInfo> actionsInfos = Collections.singletonList(new ActionPopMpls(etherType));
List<InstructionInfo> instructions = new ArrayList<>();
instructions.add(new InstructionWriteMetadata(
MetaDataUtil.getMetaDataForLPortDispatcher(lportTag,
.forEach(routePath -> {
Long label = routePath.getLabel();
String nextHop = routePath.getNexthopAddress();
- FlowEntity flowEntity = buildLFibVpnPseudoPortFlow(dpId, label, nextHop, lportTag);
- if (addOrRemove == NwConstants.ADD_FLOW) {
- mdsalMgr.installFlow(flowEntity);
- } else {
- mdsalMgr.removeFlow(flowEntity);
+ try {
+ int etherType = NWUtil.getEtherTypeFromIpPrefix(vrfEntry.getDestPrefix());
+ FlowEntity flowEntity = buildLFibVpnPseudoPortFlow(dpId, label, etherType, nextHop,
+ lportTag);
+ if (addOrRemove == NwConstants.ADD_FLOW) {
+ mdsalMgr.installFlow(flowEntity);
+ } else {
+ mdsalMgr.removeFlow(flowEntity);
+ }
+ LOG.debug(
+ "LFIBEntry for label={}, destination={}, nexthop={} {} successfully in dpn={}",
+ label, vrfEntry.getDestPrefix(), nextHop,
+ addOrRemove == NwConstants.DEL_FLOW ? "removed" : "installed", dpId);
+ } catch (IllegalArgumentException ex) {
+ LOG.warn("Unable to get etherType for IP Prefix {}", vrfEntry.getDestPrefix());
}
- LOG.debug(
- "LFIBEntry for label={}, destination={}, nexthop={} {} successfully in dpn={}",
- label, vrfEntry.getDestPrefix(), nextHop,
- addOrRemove == NwConstants.DEL_FLOW ? "removed" : "installed", dpId);
}));
}
}
import org.opendaylight.genius.mdsalutil.MDSALUtil;
import org.opendaylight.genius.mdsalutil.MatchInfo;
import org.opendaylight.genius.mdsalutil.MetaDataUtil;
+import org.opendaylight.genius.mdsalutil.NWUtil;
import org.opendaylight.genius.mdsalutil.NwConstants;
import org.opendaylight.genius.mdsalutil.actions.ActionDrop;
import org.opendaylight.genius.mdsalutil.actions.ActionGroup;
}
return;
}
+ // Get etherType value based on the IpPrefix address family type
+ int etherType;
+ try {
+ etherType = NWUtil.getEtherTypeFromIpPrefix(vrfEntry.getDestPrefix());
+ } catch (IllegalArgumentException ex) {
+ LOG.error("Unable to get etherType for IP Prefix {}", vrfEntry.getDestPrefix());
+ return;
+ }
- final List<BigInteger> localDpnIdList = createLocalFibEntry(vpnInstance.getVpnId(), rd, vrfEntry);
+ final List<BigInteger> localDpnIdList = createLocalFibEntry(vpnInstance.getVpnId(), rd, vrfEntry, etherType);
if (!localDpnIdList.isEmpty() && vpnToDpnList != null) {
jobCoordinator.enqueueJob(FibUtil.getJobKeyForRdPrefix(rd, vrfEntry.getDestPrefix()),
() -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
// This is an static route that points to the other endpoint of an InterVpnLink
// In that case, we should add another entry in FIB table pointing to LPortDispatcher table.
installIVpnLinkSwitchingFlows(interVpnLink, vpnUuid, vrfEntry, vpnId);
- installInterVpnRouteInLFib(interVpnLink, vpnUuid, vrfEntry);
+ installInterVpnRouteInLFib(interVpnLink, vpnUuid, vrfEntry, etherType);
}
});
}
"Error installing subnet route in FIB");
return;
}
+ int etherType;
+ try {
+ etherType = NWUtil.getEtherTypeFromIpPrefix(vrfEntry.getDestPrefix());
+ } catch (IllegalArgumentException ex) {
+ LOG.error("Unable to get etherType for IP Prefix {}", vrfEntry.getDestPrefix());
+ return;
+ }
FibUtil.getLabelFromRoutePaths(vrfEntry).ifPresent(label -> {
List<String> nextHopAddressList = FibHelper.getNextHopListFromRoutePaths(vrfEntry);
synchronized (label.toString().intern()) {
instructions.add(new InstructionGotoTable(NwConstants.L3_SUBNET_ROUTE_TABLE));
baseVrfEntryHandler.makeConnectedRoute(dpnId, vpnId, vrfEntry, rd, instructions,
NwConstants.ADD_FLOW, tx, null);
-
if (vrfEntry.getRoutePaths() != null) {
for (RoutePaths routePath : vrfEntry.getRoutePaths()) {
if (RouteOrigin.value(vrfEntry.getOrigin()) != RouteOrigin.SELF_IMPORTED) {
List<ActionInfo> actionsInfos = new ArrayList<>();
// reinitialize instructions list for LFIB Table
final List<InstructionInfo> LFIBinstructions = new ArrayList<>();
-
- actionsInfos.add(new ActionPopMpls());
+ actionsInfos.add(new ActionPopMpls(etherType));
LFIBinstructions.add(new InstructionApplyActions(actionsInfos));
LFIBinstructions.add(new InstructionWriteMetadata(subnetRouteMeta,
MetaDataUtil.METADATA_MASK_SUBNET_ROUTE));
* LportDispatcher table (via table 80)
*/
private void installInterVpnRouteInLFib(final InterVpnLinkDataComposite interVpnLink, final String vpnName,
- final VrfEntry vrfEntry) {
+ final VrfEntry vrfEntry, int etherType) {
// INTERVPN routes are routes in a Vpn1 that have been leaked to Vpn2. In DC-GW, this Vpn2 route is pointing
// to a list of DPNs where Vpn2's VpnLink was instantiated. In these DPNs LFIB must be programmed so that the
// packet is commuted from Vpn2 to Vpn1.
return;
}
- List<BigInteger> targetDpns = interVpnLink.getEndpointDpnsByVpnName(vpnName);
Optional<Long> optLportTag = interVpnLink.getEndpointLportTagByVpnName(vpnName);
if (!optLportTag.isPresent()) {
LOG.warn("Could not retrieve lportTag for VPN {} endpoint in InterVpnLink {}", vpnName, interVpnLinkName);
vrfEntry.getDestPrefix(), vrfEntry.getRoutePaths());
return;
}
- List<ActionInfo> actionsInfos = Collections.singletonList(new ActionPopMpls());
+ List<ActionInfo> actionsInfos = Collections.singletonList(new ActionPopMpls(etherType));
List<InstructionInfo> instructions = Arrays.asList(
new InstructionApplyActions(actionsInfos),
new InstructionWriteMetadata(MetaDataUtil.getMetaDataForLPortDispatcher(lportTag.intValue(),
MetaDataUtil.getMetaDataMaskForLPortDispatcher()),
new InstructionGotoTable(NwConstants.L3_INTERFACE_TABLE));
List<String> interVpnNextHopList = FibHelper.getNextHopListFromRoutePaths(vrfEntry);
+ List<BigInteger> targetDpns = interVpnLink.getEndpointDpnsByVpnName(vpnName);
for (BigInteger dpId : targetDpns) {
LOG.debug("Installing flow: VrfEntry=[prefix={} label={} nexthop={}] dpn {} for InterVpnLink {} in LFIB",
}
}
- private List<BigInteger> createLocalFibEntry(Long vpnId, String rd, VrfEntry vrfEntry) {
+ private List<BigInteger> createLocalFibEntry(Long vpnId, String rd, VrfEntry vrfEntry, int etherType) {
List<BigInteger> returnLocalDpnId = new ArrayList<>();
String localNextHopIP = vrfEntry.getDestPrefix();
Prefixes localNextHopInfo = fibUtil.getPrefixToInterface(vpnId, localNextHopIP);
localNextHopSeen = true;
BigInteger dpnId =
checkCreateLocalFibEntry(localNextHopInfoLocal, localNextHopInfoLocal.getIpAddress(),
- vpnId, rd, vrfEntry, vpnExtraRoute, vpnExtraRoutes);
+ vpnId, rd, vrfEntry, vpnExtraRoute, vpnExtraRoutes, etherType);
returnLocalDpnId.add(dpnId);
}
}
label, localNextHopInfo.getVpnInterfaceName(), lri.getDpnId());
if (vpnExtraRoutes.isEmpty()) {
BigInteger dpnId = checkCreateLocalFibEntry(localNextHopInfo, localNextHopIP,
- vpnId, rd, vrfEntry, null, vpnExtraRoutes);
+ vpnId, rd, vrfEntry, null, vpnExtraRoutes, etherType);
returnLocalDpnId.add(dpnId);
} else {
for (Routes extraRoutes : vpnExtraRoutes) {
BigInteger dpnId = checkCreateLocalFibEntry(localNextHopInfo, localNextHopIP,
- vpnId, rd, vrfEntry, extraRoutes, vpnExtraRoutes);
+ vpnId, rd, vrfEntry, extraRoutes, vpnExtraRoutes, etherType);
returnLocalDpnId.add(dpnId);
}
}
}
} else {
BigInteger dpnId = checkCreateLocalFibEntry(localNextHopInfo, localNextHopIP, vpnId,
- rd, vrfEntry, /*routes*/ null, /*vpnExtraRoutes*/ null);
+ rd, vrfEntry, /*routes*/ null, /*vpnExtraRoutes*/ null, etherType);
if (dpnId != null) {
returnLocalDpnId.add(dpnId);
}
private BigInteger checkCreateLocalFibEntry(Prefixes localNextHopInfo, String localNextHopIP,
final Long vpnId, final String rd,
final VrfEntry vrfEntry,
- Routes routes, List<Routes> vpnExtraRoutes) {
+ Routes routes, List<Routes> vpnExtraRoutes,
+ int etherType) {
String vpnName = fibUtil.getVpnNameFromId(vpnId);
if (localNextHopInfo != null) {
long groupId;
Collections.singletonList(new ActionGroup(groupId))));
final List<InstructionInfo> lfibinstructions = Collections.singletonList(
new InstructionApplyActions(
- Arrays.asList(new ActionPopMpls(), new ActionGroup(groupId))));
+ Arrays.asList(new ActionPopMpls(etherType), new ActionGroup(groupId))));
java.util.Optional<Long> optLabel = FibUtil.getLabelFromRoutePaths(vrfEntry);
List<String> nextHopAddressList = FibHelper.getNextHopListFromRoutePaths(vrfEntry);
jobCoordinator.enqueueJob(jobKey, () -> {
LabelRouteInfo lri = getLabelRouteInfo(optionalLabel.get());
if (isPrefixAndNextHopPresentInLri(vrfEntry.getDestPrefix(), nextHopList, lri)) {
if (lri.getDpnId().equals(dpnId)) {
- createLocalFibEntry(vpnId, rd, vrfEntry);
+ try {
+ int etherType = NWUtil.getEtherTypeFromIpPrefix(
+ vrfEntry.getDestPrefix());
+ createLocalFibEntry(vpnId, rd, vrfEntry, etherType);
+ } catch (IllegalArgumentException ex) {
+ LOG.warn("Unable to get etherType for IP Prefix {}",
+ vrfEntry.getDestPrefix());
+ }
continue;
}
}