use of org.opendaylight.yang.gen.v1.urn.opendaylight.coe.northbound.pod.rev170611.pod_attributes.Interface in project netvirt by opendaylight.
the class ElanUtils method setupTermDmacFlows.
/**
* Installs a Flow in INTERNAL_TUNNEL_TABLE of the affected DPN that sends
* the packet through the specified interface if the tunnel_id matches the
* interface's lportTag.
*
* @param interfaceInfo
* the interface info
* @param mdsalApiManager
* the mdsal API manager
* @param writeFlowGroupTx
* the writeFLowGroup tx
*/
public void setupTermDmacFlows(InterfaceInfo interfaceInfo, IMdsalApiManager mdsalApiManager, WriteTransaction writeFlowGroupTx) {
BigInteger dpId = interfaceInfo.getDpId();
int lportTag = interfaceInfo.getInterfaceTag();
Flow flow = MDSALUtil.buildFlowNew(NwConstants.INTERNAL_TUNNEL_TABLE, getIntTunnelTableFlowRef(NwConstants.INTERNAL_TUNNEL_TABLE, lportTag), 5, String.format("%s:%d", "ITM Flow Entry ", lportTag), 0, 0, ITMConstants.COOKIE_ITM.add(BigInteger.valueOf(lportTag)), getTunnelIdMatchForFilterEqualsLPortTag(lportTag), getInstructionsInPortForOutGroup(interfaceInfo.getInterfaceName()));
mdsalApiManager.addFlowToTx(dpId, flow, writeFlowGroupTx);
LOG.debug("Terminating service table flow entry created on dpn:{} for logical Interface port:{}", dpId, interfaceInfo.getPortName());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.coe.northbound.pod.rev170611.pod_attributes.Interface in project netvirt by opendaylight.
the class ElanUtils method installEtreeLocalDmacFlow.
private void installEtreeLocalDmacFlow(long elanTag, BigInteger dpId, String ifName, String macAddress, ElanInstance elanInfo, long ifTag, WriteTransaction writeFlowGroupTx) {
EtreeInterface etreeInterface = elanInterfaceCache.getEtreeInterface(ifName).orNull();
if (etreeInterface != null && etreeInterface.getEtreeInterfaceType() == EtreeInterfaceType.Root) {
EtreeLeafTagName etreeTagName = elanEtreeUtils.getEtreeLeafTagByElanTag(elanTag);
if (etreeTagName == null) {
LOG.warn("Interface {} seems like it belongs to Etree but etreeTagName from elanTag {} is null", ifName, elanTag);
} else {
Flow flowEntity = buildLocalDmacFlowEntry(etreeTagName.getEtreeLeafTag().getValue(), dpId, ifName, macAddress, elanInfo, ifTag);
mdsalManager.addFlowToTx(dpId, flowEntity, writeFlowGroupTx);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.coe.northbound.pod.rev170611.pod_attributes.Interface in project netvirt by opendaylight.
the class VrfEntryListener method deleteLocalFibEntry.
public List<BigInteger> deleteLocalFibEntry(Long vpnId, String rd, VrfEntry vrfEntry) {
List<BigInteger> returnLocalDpnId = new ArrayList<>();
Prefixes localNextHopInfo = fibUtil.getPrefixToInterface(vpnId, vrfEntry.getDestPrefix());
String vpnName = fibUtil.getVpnNameFromId(vpnId);
boolean isExtraroute = false;
if (localNextHopInfo == null) {
List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnId, vrfEntry.getDestPrefix());
if (usedRds.size() > 1) {
LOG.error("The extra route prefix {} is still present in some DPNs in vpn {} on rd {}", vrfEntry.getDestPrefix(), vpnName, rd);
return returnLocalDpnId;
}
// Is this fib route an extra route? If yes, get the nexthop which would be an adjacency
// in the vpn
Optional<Routes> extraRouteOptional = VpnExtraRouteHelper.getVpnExtraroutes(dataBroker, vpnName, rd, vrfEntry.getDestPrefix());
if (extraRouteOptional.isPresent()) {
isExtraroute = true;
Routes extraRoute = extraRouteOptional.get();
String ipPrefix;
if (isIpv4Address(extraRoute.getNexthopIpList().get(0))) {
ipPrefix = extraRoute.getNexthopIpList().get(0) + NwConstants.IPV4PREFIX;
} else {
ipPrefix = extraRoute.getNexthopIpList().get(0) + NwConstants.IPV6PREFIX;
}
localNextHopInfo = fibUtil.getPrefixToInterface(vpnId, ipPrefix);
if (localNextHopInfo != null) {
String localNextHopIP = localNextHopInfo.getIpAddress();
BigInteger dpnId = checkDeleteLocalFibEntry(localNextHopInfo, localNextHopIP, vpnId, rd, vrfEntry, isExtraroute, vpnId);
if (!dpnId.equals(BigInteger.ZERO)) {
LOG.trace("Deleting ECMP group for prefix {}, dpn {}", vrfEntry.getDestPrefix(), dpnId);
nextHopManager.setupLoadBalancingNextHop(vpnId, dpnId, vrfEntry.getDestPrefix(), /*listBucketInfo*/
Collections.emptyList(), /*remove*/
false);
returnLocalDpnId.add(dpnId);
}
} else {
LOG.error("localNextHopInfo unavailable while deleting prefix {} with rds {}, primary rd {} in " + "vpn {}", vrfEntry.getDestPrefix(), usedRds, rd, vpnName);
}
}
if (localNextHopInfo == null) {
/* Imported VRF entry */
java.util.Optional<Long> optionalLabel = FibUtil.getLabelFromRoutePaths(vrfEntry);
if (optionalLabel.isPresent()) {
Long label = optionalLabel.get();
List<String> nextHopAddressList = FibHelper.getNextHopListFromRoutePaths(vrfEntry);
LabelRouteInfo lri = getLabelRouteInfo(label);
if (isPrefixAndNextHopPresentInLri(vrfEntry.getDestPrefix(), nextHopAddressList, lri)) {
PrefixesBuilder prefixBuilder = new PrefixesBuilder();
prefixBuilder.setDpnId(lri.getDpnId());
BigInteger dpnId = checkDeleteLocalFibEntry(prefixBuilder.build(), nextHopAddressList.get(0), vpnId, rd, vrfEntry, isExtraroute, lri.getParentVpnid());
if (!dpnId.equals(BigInteger.ZERO)) {
returnLocalDpnId.add(dpnId);
}
}
}
}
} else {
LOG.debug("Obtained prefix to interface for rd {} prefix {}", rd, vrfEntry.getDestPrefix());
String localNextHopIP = localNextHopInfo.getIpAddress();
BigInteger dpnId = checkDeleteLocalFibEntry(localNextHopInfo, localNextHopIP, vpnId, rd, vrfEntry, isExtraroute, vpnId);
if (!dpnId.equals(BigInteger.ZERO)) {
returnLocalDpnId.add(dpnId);
}
}
return returnLocalDpnId;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.coe.northbound.pod.rev170611.pod_attributes.Interface in project netvirt by opendaylight.
the class ExpectedObjects method newInterfaceConfig.
public static Interface newInterfaceConfig(final String interfaceName, final String parentName) {
InterfaceBuilder _interfaceBuilder = new InterfaceBuilder();
final Procedure1<InterfaceBuilder> _function = (InterfaceBuilder it) -> {
it.setDescription(interfaceName);
it.setName(interfaceName);
it.setType(L2vlan.class);
ParentRefsBuilder _parentRefsBuilder = new ParentRefsBuilder();
final Procedure1<ParentRefsBuilder> _function_1 = (ParentRefsBuilder it_1) -> {
it_1.setParentInterface(parentName);
};
ParentRefs _doubleGreaterThan = XtendBuilderExtensions.<ParentRefs, ParentRefsBuilder>operator_doubleGreaterThan(_parentRefsBuilder, _function_1);
it.addAugmentation(ParentRefs.class, _doubleGreaterThan);
IfL2vlanBuilder _ifL2vlanBuilder = new IfL2vlanBuilder();
final Procedure1<IfL2vlanBuilder> _function_2 = (IfL2vlanBuilder it_1) -> {
it_1.setL2vlanMode(IfL2vlan.L2vlanMode.Trunk);
VlanId _vlanId = new VlanId(Integer.valueOf(0));
it_1.setVlanId(_vlanId);
};
IfL2vlan _doubleGreaterThan_1 = XtendBuilderExtensions.<IfL2vlan, IfL2vlanBuilder>operator_doubleGreaterThan(_ifL2vlanBuilder, _function_2);
it.addAugmentation(IfL2vlan.class, _doubleGreaterThan_1);
};
return XtendBuilderExtensions.<Interface, InterfaceBuilder>operator_doubleGreaterThan(_interfaceBuilder, _function);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.coe.northbound.pod.rev170611.pod_attributes.Interface in project netvirt by opendaylight.
the class EvpnVrfEntryHandler method createRemoteFibEntry.
private void createRemoteFibEntry(final BigInteger remoteDpnId, final long vpnId, final VrfTablesKey vrfTableKey, final VrfEntry vrfEntry, boolean isNatPrefix, WriteTransaction tx) {
String rd = vrfTableKey.getRouteDistinguisher();
List<SubTransaction> subTxns = new ArrayList<>();
LOG.debug("createremotefibentry: adding route {} for rd {} with transaction {}", vrfEntry.getDestPrefix(), rd, tx);
List<NexthopManager.AdjacencyResult> tunnelInterfaceList = resolveAdjacency(remoteDpnId, vpnId, vrfEntry, rd);
if (tunnelInterfaceList.isEmpty()) {
LOG.error("Could not get interface for route-paths: {} in vpn {}", vrfEntry.getRoutePaths(), rd);
LOG.warn("Failed to add Route: {} in vpn: {}", vrfEntry.getDestPrefix(), rd);
return;
}
for (NexthopManager.AdjacencyResult adjacencyResult : tunnelInterfaceList) {
List<ActionInfo> actionInfos = new ArrayList<>();
BigInteger tunnelId;
String prefix = adjacencyResult.getPrefix();
Prefixes prefixInfo = getFibUtil().getPrefixToInterface(vpnId, prefix);
String interfaceName = prefixInfo.getVpnInterfaceName();
if (vrfEntry.getOrigin().equals(RouteOrigin.BGP.getValue()) || isNatPrefix) {
tunnelId = BigInteger.valueOf(vrfEntry.getL3vni());
} else if (elanManager.isOpenStackVniSemanticsEnforced()) {
tunnelId = BigInteger.valueOf(getFibUtil().getVniForVxlanNetwork(prefixInfo.getSubnetId()).get());
} else {
Interface interfaceState = getFibUtil().getInterfaceStateFromOperDS(interfaceName);
tunnelId = BigInteger.valueOf(interfaceState.getIfIndex());
}
LOG.debug("adding set tunnel id action for label {}", tunnelId);
String macAddress = null;
String vpnName = getFibUtil().getVpnNameFromId(vpnId);
if (vpnName == null) {
LOG.debug("Failed to get VPN name for vpnId {}", vpnId);
return;
}
if (interfaceName != null) {
macAddress = getFibUtil().getMacAddressFromPrefix(interfaceName, vpnName, prefix);
actionInfos.add(new ActionSetFieldEthernetDestination(new MacAddress(macAddress)));
}
actionInfos.add(new ActionSetFieldTunnelId(tunnelId));
List<ActionInfo> egressActions = nexthopManager.getEgressActionsForInterface(adjacencyResult.getInterfaceName(), actionInfos.size());
if (egressActions.isEmpty()) {
LOG.error("Failed to retrieve egress action for prefix {} route-paths {} interface {}." + " Aborting remote FIB entry creation..", vrfEntry.getDestPrefix(), vrfEntry.getRoutePaths(), adjacencyResult.getInterfaceName());
return;
}
actionInfos.addAll(egressActions);
List<InstructionInfo> instructions = new ArrayList<>();
instructions.add(new InstructionApplyActions(actionInfos));
makeConnectedRoute(remoteDpnId, vpnId, vrfEntry, rd, instructions, NwConstants.ADD_FLOW, tx, subTxns);
}
LOG.debug("Successfully added FIB entry for prefix {} in rd {}", vrfEntry.getDestPrefix(), rd);
}
Aggregations