use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefix in project netvirt by opendaylight.
the class DisplayAclDataCaches method printAclInterface.
private void printAclInterface(AclInterface aclInterface) {
session.getConsole().println(String.format(ACL_INTERFACE_FORMAT_STRING, aclInterface.getInterfaceId(), aclInterface.getInterfaceType(), aclInterface.isPortSecurityEnabled(), aclInterface.getDpId(), aclInterface.getLPortTag(), aclInterface.getElanId(), aclInterface.isMarkedForDelete()));
List<AllowedAddressPairs> aaps = aclInterface.getAllowedAddressPairs();
if (aaps == null || aaps.isEmpty()) {
session.getConsole().println("--");
} else {
for (AllowedAddressPairs aap : aaps) {
IpPrefixOrAddress ipPrefixOrAddress = aap.getIpAddress();
IpPrefix ipPrefix = ipPrefixOrAddress.getIpPrefix();
String ipAddrStr = "";
if (ipPrefix != null) {
if (ipPrefix.getIpv4Prefix() != null) {
ipAddrStr = ipPrefix.getIpv4Prefix().getValue();
} else {
ipAddrStr = ipPrefix.getIpv6Prefix().getValue();
}
} else {
IpAddress ipAddress = ipPrefixOrAddress.getIpAddress();
if (ipAddress != null) {
if (ipAddress.getIpv4Address() != null) {
ipAddrStr = ipAddress.getIpv4Address().getValue();
} else {
ipAddrStr = ipAddress.getIpv6Address().getValue();
}
}
}
String macAddrStr = aap.getMacAddress().getValue();
session.getConsole().println(ipAddrStr + ", " + macAddrStr);
}
}
List<Uuid> sgsUuid = aclInterface.getSecurityGroups();
if (sgsUuid == null || sgsUuid.isEmpty()) {
session.getConsole().println("--");
} else {
for (Uuid sgUuid : sgsUuid) {
session.getConsole().println(sgUuid.getValue());
}
}
SortedSet<Integer> ingressRemoteAclTags = aclInterface.getIngressRemoteAclTags();
if (ingressRemoteAclTags == null || ingressRemoteAclTags.isEmpty()) {
session.getConsole().println("--");
} else {
session.getConsole().println(ingressRemoteAclTags);
}
SortedSet<Integer> egressRemoteAclTags = aclInterface.getEgressRemoteAclTags();
if (egressRemoteAclTags == null || egressRemoteAclTags.isEmpty()) {
session.getConsole().println("--");
} else {
session.getConsole().println(egressRemoteAclTags);
}
session.getConsole().println();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefix in project netvirt by opendaylight.
the class NexthopManager method removeVpnNexthopFromDS.
private void removeVpnNexthopFromDS(Uint32 vpnId, String ipPrefix) {
InstanceIdentifierBuilder<VpnNexthop> idBuilder = InstanceIdentifier.builder(L3nexthop.class).child(VpnNexthops.class, new VpnNexthopsKey(vpnId)).child(VpnNexthop.class, new VpnNexthopKey(ipPrefix));
InstanceIdentifier<VpnNexthop> id = idBuilder.build();
// remove from DS
LOG.trace("Removing vpn next hop from datastore : {}", id);
MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefix in project netvirt by opendaylight.
the class NexthopManager method getEgressActionsForInterface.
protected List<ActionInfo> getEgressActionsForInterface(final String ifName, int actionKey, boolean isTunnelInterface, Uint32 vpnId, String destIpPrefix) {
List<Action> actions;
try {
if (isTunnelInterface && interfaceManager.isItmDirectTunnelsEnabled()) {
RpcResult<GetEgressActionsForTunnelOutput> rpcResult = itmManager.getEgressActionsForTunnel(new GetEgressActionsForTunnelInputBuilder().setIntfName(ifName).build()).get();
if (!rpcResult.isSuccessful()) {
LOG.error("RPC Call to Get egress tunnel actions for interface {} returned with Errors {}", ifName, rpcResult.getErrors());
return Collections.emptyList();
} else {
actions = new ArrayList<Action>(rpcResult.getResult().nonnullAction().values());
}
} else {
RpcResult<GetEgressActionsForInterfaceOutput> rpcResult = odlInterfaceRpcService.getEgressActionsForInterface(new GetEgressActionsForInterfaceInputBuilder().setIntfName(ifName).build()).get();
if (!rpcResult.isSuccessful()) {
LOG.error("RPC Call to Get egress vm actions for interface {} vpnId {} ipPrefix {} returned with " + "Errors {}", ifName, vpnId, destIpPrefix, rpcResult.getErrors());
return Collections.emptyList();
} else {
actions = new ArrayList<Action>(rpcResult.getResult().nonnullAction().values());
}
}
List<ActionInfo> listActionInfo = new ArrayList<>();
for (Action action : actions) {
actionKey = action.key().getOrder() + actionKey;
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionClass = action.getAction();
if (actionClass instanceof OutputActionCase) {
listActionInfo.add(new ActionOutput(actionKey, ((OutputActionCase) actionClass).getOutputAction().getOutputNodeConnector()));
} else if (actionClass instanceof PushVlanActionCase) {
listActionInfo.add(new ActionPushVlan(actionKey));
} else if (actionClass instanceof SetFieldCase) {
if (((SetFieldCase) actionClass).getSetField().getVlanMatch() != null) {
int vlanVid = ((SetFieldCase) actionClass).getSetField().getVlanMatch().getVlanId().getVlanId().getValue().toJava();
listActionInfo.add(new ActionSetFieldVlanVid(actionKey, vlanVid));
}
} else if (actionClass instanceof NxActionResubmitRpcAddGroupCase) {
Short tableId = ((NxActionResubmitRpcAddGroupCase) actionClass).getNxResubmit().getTable().toJava();
listActionInfo.add(new ActionNxResubmit(actionKey, tableId));
} else if (actionClass instanceof NxActionRegLoadNodesNodeTableFlowApplyActionsCase) {
NxRegLoad nxRegLoad = ((NxActionRegLoadNodesNodeTableFlowApplyActionsCase) actionClass).getNxRegLoad();
listActionInfo.add(new ActionRegLoad(actionKey, NxmNxReg6.class, nxRegLoad.getDst().getStart().toJava(), nxRegLoad.getDst().getEnd().toJava(), nxRegLoad.getValue().longValue()));
}
}
return listActionInfo;
} catch (InterruptedException | ExecutionException | NullPointerException e) {
LOG.error("Exception when egress actions for interface {} isTunnel {} vpnId {} ipPrefix {}", ifName, isTunnelInterface, vpnId, destIpPrefix, e);
}
LOG.warn("Exception when egress actions for interface {}", ifName);
return Collections.emptyList();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefix in project netvirt by opendaylight.
the class VrfEntryListener method deleteLocalFibEntry.
public List<Uint64> deleteLocalFibEntry(Uint32 vpnId, String rd, VrfEntry vrfEntry) {
List<Uint64> returnLocalDpnId = new ArrayList<>();
Prefixes localNextHopInfo = fibUtil.getPrefixToInterface(vpnId, vrfEntry.getDestPrefix());
String vpnName = fibUtil.getVpnNameFromId(vpnId);
boolean shouldUpdateNonEcmpLocalNextHop = true;
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;
}
String vpnRd = !usedRds.isEmpty() ? usedRds.get(0) : rd;
// 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, vpnRd, vrfEntry.getDestPrefix());
if (extraRouteOptional.isPresent()) {
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;
}
if (extraRoute.getNexthopIpList().size() > 1) {
shouldUpdateNonEcmpLocalNextHop = false;
}
localNextHopInfo = fibUtil.getPrefixToInterface(vpnId, ipPrefix);
if (localNextHopInfo != null) {
String localNextHopIP = localNextHopInfo.getIpAddress();
Uint64 dpnId = checkDeleteLocalFibEntry(localNextHopInfo, localNextHopIP, vpnName, vpnId, rd, vrfEntry, shouldUpdateNonEcmpLocalNextHop);
if (!dpnId.equals(Uint64.ZERO)) {
LOG.trace("Deleting ECMP group for prefix {}, dpn {}", vrfEntry.getDestPrefix(), dpnId);
nextHopManager.deleteLoadBalancingNextHop(vpnId, dpnId, vrfEntry.getDestPrefix());
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<Uint32> optionalLabel = FibUtil.getLabelFromRoutePaths(vrfEntry);
if (optionalLabel.isPresent()) {
Uint32 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());
Uint64 dpnId = checkDeleteLocalFibEntry(prefixBuilder.build(), nextHopAddressList.get(0), vpnName, vpnId, rd, vrfEntry, shouldUpdateNonEcmpLocalNextHop);
if (!dpnId.equals(Uint64.ZERO)) {
returnLocalDpnId.add(dpnId);
}
}
}
}
} else {
LOG.debug("Obtained prefix to interface for rd {} prefix {}", rd, vrfEntry.getDestPrefix());
String localNextHopIP = localNextHopInfo.getIpAddress();
Uint64 dpnId = checkDeleteLocalFibEntry(localNextHopInfo, localNextHopIP, vpnName, vpnId, rd, vrfEntry, shouldUpdateNonEcmpLocalNextHop);
if (!dpnId.equals(Uint64.ZERO)) {
returnLocalDpnId.add(dpnId);
}
}
return returnLocalDpnId;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefix in project netvirt by opendaylight.
the class VrfEntryListener method createLocalFibEntry.
private List<Uint64> createLocalFibEntry(Uint32 vpnId, String rd, VrfEntry vrfEntry, int etherType) {
List<Uint64> returnLocalDpnId = new ArrayList<>();
String localNextHopIP = vrfEntry.getDestPrefix();
Prefixes localNextHopInfo = fibUtil.getPrefixToInterface(vpnId, localNextHopIP);
String vpnName = fibUtil.getVpnNameFromId(vpnId);
if (localNextHopInfo == null) {
boolean localNextHopSeen = false;
List<Routes> vpnExtraRoutes = null;
// Synchronized to prevent missing bucket action due to race condition between refreshFib and
// add/updateFib threads on missing nexthop in VpnToExtraroutes
// FIXME: use an Identifier structure?
final ReentrantLock lock = JvmGlobalLocks.getLockForString(localNextHopIP + FibConstants.SEPARATOR + rd);
lock.lock();
try {
List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnId, localNextHopIP);
vpnExtraRoutes = VpnExtraRouteHelper.getAllVpnExtraRoutes(dataBroker, vpnName, usedRds, localNextHopIP);
if (LOG.isDebugEnabled()) {
LOG.debug("Creating Local fib entry with vpnName {} usedRds {} localNextHopIP {} vpnExtraRoutes {}", vpnName, usedRds, localNextHopIP, vpnExtraRoutes);
}
// Is this fib route an extra route? If yes, get the nexthop which would be an adjacency in the vpn
for (Routes vpnExtraRoute : vpnExtraRoutes) {
String ipPrefix;
if (isIpv4Address(vpnExtraRoute.getNexthopIpList().get(0))) {
ipPrefix = vpnExtraRoute.getNexthopIpList().get(0) + NwConstants.IPV4PREFIX;
} else {
ipPrefix = vpnExtraRoute.getNexthopIpList().get(0) + NwConstants.IPV6PREFIX;
}
Prefixes localNextHopInfoLocal = fibUtil.getPrefixToInterface(vpnId, ipPrefix);
if (localNextHopInfoLocal != null) {
localNextHopSeen = true;
Uint64 dpnId = checkCreateLocalFibEntry(localNextHopInfoLocal, localNextHopInfoLocal.getIpAddress(), vpnId, rd, vrfEntry, vpnExtraRoute, vpnExtraRoutes, etherType, /*parentVpnId*/
null);
returnLocalDpnId.add(dpnId);
}
}
} finally {
lock.unlock();
}
if (!localNextHopSeen && RouteOrigin.value(vrfEntry.getOrigin()) == RouteOrigin.SELF_IMPORTED) {
java.util.Optional<Uint32> optionalLabel = FibUtil.getLabelFromRoutePaths(vrfEntry);
if (optionalLabel.isPresent()) {
Uint32 label = optionalLabel.get();
List<String> nextHopAddressList = FibHelper.getNextHopListFromRoutePaths(vrfEntry);
final LabelRouteInfoKey lriKey = new LabelRouteInfoKey(label);
final ReentrantLock labelLock = lockFor(lriKey);
labelLock.lock();
try {
LabelRouteInfo lri = getLabelRouteInfo(lriKey);
Uint32 parentVpnId = lri.getParentVpnid();
if (isPrefixAndNextHopPresentInLri(localNextHopIP, nextHopAddressList, lri)) {
Optional<VpnInstanceOpDataEntry> vpnInstanceOpDataEntryOptional = fibUtil.getVpnInstanceOpData(rd);
if (vpnInstanceOpDataEntryOptional.isPresent()) {
String vpnInstanceName = vpnInstanceOpDataEntryOptional.get().getVpnInstanceName();
if (lri.getVpnInstanceList() != null && lri.getVpnInstanceList().contains(vpnInstanceName)) {
localNextHopInfo = updateVpnReferencesInLri(lri, vpnInstanceName, true);
localNextHopIP = lri.getPrefix();
} else {
localNextHopInfo = updateVpnReferencesInLri(lri, vpnInstanceName, false);
localNextHopIP = lri.getPrefix();
}
}
if (localNextHopInfo != null) {
LOG.debug("Fetched labelRouteInfo for label {} interface {} and got dpn {}", label, localNextHopInfo.getVpnInterfaceName(), lri.getDpnId());
if (vpnExtraRoutes.isEmpty()) {
Uint64 dpnId = checkCreateLocalFibEntry(localNextHopInfo, localNextHopIP, vpnId, rd, vrfEntry, null, vpnExtraRoutes, etherType, parentVpnId);
returnLocalDpnId.add(dpnId);
} else {
for (Routes extraRoutes : vpnExtraRoutes) {
Uint64 dpnId = checkCreateLocalFibEntry(localNextHopInfo, localNextHopIP, vpnId, rd, vrfEntry, extraRoutes, vpnExtraRoutes, etherType, parentVpnId);
returnLocalDpnId.add(dpnId);
}
}
}
}
} finally {
labelLock.unlock();
}
}
}
if (returnLocalDpnId.isEmpty()) {
LOG.error("Local DPNID is empty for rd {}, vpnId {}, vrfEntry {}", rd, vpnId, vrfEntry);
}
} else {
Uint64 dpnId = checkCreateLocalFibEntry(localNextHopInfo, localNextHopIP, vpnId, rd, vrfEntry, /*routes*/
null, /*vpnExtraRoutes*/
null, etherType, /*parentVpnId*/
null);
if (dpnId != null) {
returnLocalDpnId.add(dpnId);
}
}
return returnLocalDpnId;
}
Aggregations