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 BaseVrfEntryHandler method addRewriteDstMacAction.
protected void addRewriteDstMacAction(Uint32 vpnId, VrfEntry vrfEntry, @Nullable Prefixes prefixInfo, List<ActionInfo> actionInfos) {
if (vrfEntry.getMac() != null) {
actionInfos.add(new ActionSetFieldEthernetDestination(actionInfos.size(), new MacAddress(vrfEntry.getMac())));
return;
}
if (prefixInfo == null) {
prefixInfo = fibUtil.getPrefixToInterface(vpnId, vrfEntry.getDestPrefix());
// Checking PrefixtoInterface again as it is populated later in some cases
if (prefixInfo == null) {
LOG.debug("No prefix info found for prefix {}", vrfEntry.getDestPrefix());
return;
}
}
if (prefixInfo.getPrefixCue() == Prefixes.PrefixCue.Nat) {
/* natprefix prefix-to-interface will not hold vpninterface at all. Also such natprefixes
* tend to use remote-flows without destMac filled. Hence just return here.
*/
return;
}
String ipPrefix = prefixInfo.getIpAddress();
String ifName = prefixInfo.getVpnInterfaceName();
if (ifName == null) {
LOG.debug("Failed to get VPN interface for prefix {}", ipPrefix);
return;
}
String vpnName = fibUtil.getVpnNameFromId(vpnId);
if (vpnName == null) {
LOG.debug("Failed to get VPN name for vpnId {}", vpnId);
return;
}
String macAddress = null;
if (vrfEntry.getParentVpnRd() != null) {
// Handling iRT/eRT use-case for missing destination mac address in Remote FIB flow
Optional<VpnInstanceOpDataEntry> vpnInstance = fibUtil.getVpnInstanceOpData(vrfEntry.getParentVpnRd());
if (vpnInstance.isPresent()) {
macAddress = fibUtil.getMacAddressFromPrefix(ifName, vpnInstance.get().getVpnInstanceName(), ipPrefix);
} else {
LOG.warn("VpnInstance missing for Parent Rd {} value for prefix {}", vrfEntry.getParentVpnRd(), vrfEntry.getDestPrefix());
}
} else {
macAddress = fibUtil.getMacAddressFromPrefix(ifName, vpnName, ipPrefix);
}
if (macAddress == null) {
LOG.warn("No MAC address found for VPN interface {} prefix {}", ifName, ipPrefix);
return;
}
actionInfos.add(new ActionSetFieldEthernetDestination(actionInfos.size(), new MacAddress(macAddress)));
}
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 BaseVrfEntryHandler method resolveAdjacency.
@NonNull
protected List<AdjacencyResult> resolveAdjacency(final Uint64 remoteDpnId, final Uint32 vpnId, final VrfEntry vrfEntry, String rd) {
List<RoutePaths> routePaths = new ArrayList<RoutePaths>(vrfEntry.nonnullRoutePaths().values());
FibHelper.sortIpAddress(routePaths);
List<AdjacencyResult> adjacencyList = new ArrayList<>();
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());
if (vpnExtraRoutes.isEmpty()) {
Prefixes prefixInfo = fibUtil.getPrefixToInterface(vpnId, vrfEntry.getDestPrefix());
/* We don't want to provide an adjacencyList for
* (1) an extra-route-prefix or,
* (2) for a local route without prefix-to-interface.
* Allow only self-imported routes in such cases */
if (prefixInfo == null && FibHelper.isControllerManagedNonSelfImportedRoute(RouteOrigin.value(vrfEntry.getOrigin()))) {
LOG.debug("The prefix {} in rd {} for vpn {} does not have a valid extra-route or" + " prefix-to-interface entry in the data-store", vrfEntry.getDestPrefix(), rd, vpnId);
return adjacencyList;
}
prefixIpList = Collections.singletonList(vrfEntry.getDestPrefix());
} else {
List<String> prefixIpListLocal = new ArrayList<>();
vpnExtraRoutes.stream().filter(route -> route.getNexthopIpList() != null).forEach(route -> route.getNexthopIpList().forEach(extraRouteIp -> {
String ipPrefix;
if (isIpv4Address(extraRouteIp)) {
ipPrefix = extraRouteIp + NwConstants.IPV4PREFIX;
} else {
ipPrefix = extraRouteIp + NwConstants.IPV6PREFIX;
}
prefixIpListLocal.add(ipPrefix);
}));
prefixIpList = prefixIpListLocal;
}
} 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, tunnelType);
addAdjacencyResultToList(adjacencyList, adjacencyResult);
continue;
}
adjacencyList.addAll(routePaths.stream().map(routePath -> {
LOG.debug("NextHop IP for destination {} is {}", prefixIp, routePath.getNexthopAddress());
return nextHopManager.getRemoteNextHopPointer(remoteDpnId, vpnId, prefixIp, routePath.getNexthopAddress(), tunnelType);
}).filter(adjacencyResult -> adjacencyResult != null && !adjacencyList.contains(adjacencyResult)).distinct().collect(toList()));
}
} catch (NullPointerException e) {
// FIXME: NPEs should not be caught but rather their root cause should be eliminated
LOG.trace("Failed to remove adjacency", e);
}
return adjacencyList;
}
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 NatUtil method addPrefixToInterface.
static void addPrefixToInterface(DataBroker broker, Uint32 vpnId, @Nullable String interfaceName, String ipPrefix, String networkId, Uint64 dpId, Prefixes.PrefixCue prefixCue) {
InstanceIdentifier<Prefixes> prefixId = InstanceIdentifier.builder(PrefixToInterface.class).child(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.VpnIds.class, new org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.VpnIdsKey(vpnId)).child(Prefixes.class, new PrefixesKey(ipPrefix)).build();
PrefixesBuilder prefixBuilder = new PrefixesBuilder().setDpnId(dpId).setIpAddress(ipPrefix);
prefixBuilder.setVpnInterfaceName(interfaceName).setPrefixCue(prefixCue);
prefixBuilder.setNetworkId(new Uuid(networkId));
try {
SingleTransactionDataBroker.syncWrite(broker, LogicalDatastoreType.OPERATIONAL, prefixId, prefixBuilder.build());
} catch (TransactionCommitFailedException e) {
LOG.error("addPrefixToInterface : Failed to write prefxi-to-interface for {} vpn-id {} DPN {}", ipPrefix, vpnId, dpId, e);
}
}
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 AclServiceUtils method skipDeleteInCaseOfOverlappingIP.
/**
* Skip delete in case of overlapping IP.
*
* <p>
* When there are multiple ports (e.g., p1, p2, p3) having same AAP (e.g.,
* 224.0.0.5) configured which are part of single SG, there would be single
* flow in remote ACL table. When one of these ports (say p1) is deleted,
* the single flow which is configured in remote ACL table shouldn't be
* deleted. It should be deleted only when there are no more references to
* it.
*
* @param portId the port id
* @param remoteAclId the remote Acl Id
* @param ipPrefix the ip prefix
* @param addOrRemove the add or remove
* @return true, if successful
*/
public boolean skipDeleteInCaseOfOverlappingIP(String portId, Uuid remoteAclId, IpPrefixOrAddress ipPrefix, int addOrRemove) {
boolean skipDelete = false;
if (addOrRemove != NwConstants.DEL_FLOW) {
return skipDelete;
}
AclIpPrefixes aclIpPrefixes = getAclIpPrefixesFromOperDs(remoteAclId.getValue(), ipPrefix);
if (aclIpPrefixes != null && aclIpPrefixes.getPortIds() != null) {
List<String> ignorePorts = Lists.newArrayList(portId);
List<PortIds> portIds = new ArrayList<>(aclIpPrefixes.getPortIds().values());
// Checking if there are any other ports excluding ignorePorts
long noOfRemotePorts = portIds.stream().map(PortIds::getPortId).filter(y -> !ignorePorts.contains(y)).count();
if (noOfRemotePorts > 0) {
skipDelete = true;
}
}
return skipDelete;
}
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 printAcl.
private void printAcl(String aclId, Acl acl) {
session.getConsole().println();
session.getConsole().println(ACL_HEADER + String.format("%-32s ", aclId));
if (null != acl.getAccessListEntries() && null != acl.getAccessListEntries().getAce()) {
printHeader(ACL_ENTRIES_HEADERS, ACL_ENTRIES_HEADER_LINE);
List<Ace> aceList = acl.getAccessListEntries().getAce();
for (Ace ace : aceList) {
LOG.info("ace data: {}", ace);
SecurityRuleAttr aceAttr = getAccessListAttributes(ace);
Class<? extends DirectionBase> aceAttrDirection = aceAttr.getDirection();
AceIp aceIp = (AceIp) ace.getMatches().getAceType();
AceIpVersion ipVersion = aceIp.getAceIpVersion();
Uint8 protoNum = aceIp.getProtocol();
String protocol = "Any";
if (null != protoNum) {
protocol = protoMap.get(protoNum.toString());
protocol = (protocol == null) ? protoNum.toString() : protocol;
}
String ipVer = "";
String direction = DirectionEgress.class.equals(aceAttrDirection) ? "Egress" : "Ingress";
String ipPrefix = " -- ";
if (null != ipVersion && ipVersion instanceof AceIpv4) {
ipVer = "IPv4";
Ipv4Prefix srcNetwork = ((AceIpv4) ipVersion).getSourceIpv4Network();
if (null != srcNetwork) {
ipPrefix = srcNetwork.getValue();
}
} else if (null != ipVersion && ipVersion instanceof AceIpv6) {
ipVer = "IPv6";
Ipv6Prefix srcNetwork = ((AceIpv6) ipVersion).getSourceIpv6Network();
if (null != srcNetwork) {
ipPrefix = srcNetwork.getValue();
}
}
String remoteGroupId = "-";
if (aceAttr.getRemoteGroupId() != null) {
remoteGroupId = aceAttr.getRemoteGroupId().getValue();
ipPrefix = "-";
}
String prefixAndRemoteId = ipPrefix + " / " + remoteGroupId;
session.getConsole().print(String.format(ACE_ENTRIES_FORMAT_STRING, ace.key().getRuleName(), direction, protocol, ipVer, prefixAndRemoteId));
}
}
session.getConsole().println();
}
Aggregations