use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes in project netvirt by opendaylight.
the class L3vpnOverMplsGrePopulator method populateFib.
@Override
public void populateFib(L3vpnInput input, WriteTransaction writeConfigTxn) {
if (input.getRouteOrigin() == RouteOrigin.CONNECTED) {
LOG.info("populateFib : Found SubnetRoute for subnet {} rd {}", input.getSubnetIp(), input.getPrimaryRd());
addSubnetRouteFibEntry(input);
return;
}
Adjacency nextHop = input.getNextHop();
long label = nextHop.getLabel();
String vpnName = input.getVpnName();
String primaryRd = input.getPrimaryRd();
String rd = input.getRd();
String nextHopIp = input.getNextHopIp();
VrfEntry.EncapType encapType = input.getEncapType();
LOG.info("populateFib : Found Interface Adjacency with prefix {} rd {}", nextHop.getIpAddress(), primaryRd);
List<VpnInstanceOpDataEntry> vpnsToImportRoute = VpnUtil.getVpnsImportingMyRoute(broker, vpnName);
long vpnId = VpnUtil.getVpnId(broker, vpnName);
// it is a valid case for nextHopIpAddress to be null
String nextHopIpAddress = nextHop.getIpAddress();
// and internalVpnForExtraRoute (where rd is DpnId)
if (VpnUtil.isEligibleForBgp(primaryRd, input.getVpnName(), input.getDpnId(), input.getNetworkName())) {
// the DpnId is set as rd in case of extra routes present in router based VPN
addToLabelMapper(label, input.getDpnId(), nextHopIpAddress, Arrays.asList(nextHopIp), vpnId, input.getInterfaceName(), null, false, primaryRd);
Objects.requireNonNull(input.getRouteOrigin(), "RouteOrigin is mandatory");
addPrefixToBGP(rd, primaryRd, null, /*macAddress*/
nextHopIpAddress, nextHopIp, encapType, label, 0, /*l3vni*/
input.getGatewayMac(), input.getRouteOrigin(), writeConfigTxn);
// TODO: ERT - check for VPNs importing my route
for (VpnInstanceOpDataEntry vpn : vpnsToImportRoute) {
String vpnRd = vpn.getVrfId();
if (vpnRd != null) {
fibManager.addOrUpdateFibEntry(vpnRd, null, /*macAddress*/
nextHopIpAddress, Arrays.asList(nextHopIp), encapType, (int) label, 0, /*l3vni*/
input.getGatewayMac(), null, /*parentVpnRd*/
RouteOrigin.SELF_IMPORTED, writeConfigTxn);
LOG.info("populateFib: Exported route with rd {} prefix {} nexthop {} label {}" + " to VPN {} for interface {} on dpn {}", vpnRd, nextHop.getIpAddress(), nextHopIp, label, vpn, input.getInterfaceName(), input.getDpnId());
}
}
} else {
// ### add FIB route directly
fibManager.addOrUpdateFibEntry(vpnName, null, /*macAddress*/
nextHopIpAddress, Arrays.asList(nextHopIp), encapType, (int) label, 0, /*l3vni*/
input.getGatewayMac(), null, /*parentVpnRd*/
input.getRouteOrigin(), writeConfigTxn);
LOG.info("populateFib: Added internal FIB entry for prefix {} nexthop {} label {}" + " to VPN {} for interface {} on dpn {}", nextHop.getIpAddress(), nextHopIp, label, vpnName, input.getInterfaceName(), input.getDpnId());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes in project netvirt by opendaylight.
the class NeutronvpnManager method addInterVpnRoutes.
/**
* Creates the corresponding static routes in the specified VPN. These static routes must be point to an
* InterVpnLink endpoint and the specified VPN must be the other end of the InterVpnLink. Otherwise the
* route will be ignored.
*
* @param vpnName the VPN identifier
* @param interVpnLinkRoutes The list of static routes
* @param nexthopsXinterVpnLinks A Map with the correspondence nextHop-InterVpnLink
*/
public void addInterVpnRoutes(Uuid vpnName, List<Routes> interVpnLinkRoutes, HashMap<String, InterVpnLink> nexthopsXinterVpnLinks) {
for (Routes route : interVpnLinkRoutes) {
String nexthop = String.valueOf(route.getNexthop().getValue());
String destination = String.valueOf(route.getDestination().getValue());
InterVpnLink interVpnLink = nexthopsXinterVpnLinks.get(nexthop);
if (isNexthopTheOtherVpnLinkEndpoint(nexthop, vpnName.getValue(), interVpnLink)) {
AddStaticRouteInput rpcInput = new AddStaticRouteInputBuilder().setDestination(destination).setNexthop(nexthop).setVpnInstanceName(vpnName.getValue()).build();
Future<RpcResult<AddStaticRouteOutput>> labelOuputFtr = vpnRpcService.addStaticRoute(rpcInput);
RpcResult<AddStaticRouteOutput> rpcResult;
try {
rpcResult = labelOuputFtr.get();
if (rpcResult.isSuccessful()) {
LOG.debug("Label generated for destination {} is: {}", destination, rpcResult.getResult().getLabel());
} else {
LOG.error("RPC call to add a static Route to {} with nexthop {} returned with errors {}", destination, nexthop, rpcResult.getErrors());
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("Error happened while invoking addStaticRoute RPC for nexthop {} with destination {} " + "for VPN {}", nexthop, destination, vpnName.getValue(), e);
}
} else {
// Any other case is a fault.
LOG.warn("route with destination {} and nexthop {} does not apply to any InterVpnLink", String.valueOf(route.getDestination().getValue()), nexthop);
continue;
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes in project netvirt by opendaylight.
the class NeutronvpnManager method checkAlarmExtraRoutes.
/**
* This method setup or down an alarm about extra route fault.
* When extra routes are configured, through a router, if the number of nexthops is greater than the number of
* available RDs, then an alarm and an error is generated.<br>
* <b>Be careful</b> the routeList could be changed.
*
* @param vpnId the vpnId of vpn to control.
* @param routeList the list of router to check, it could be modified.
*/
private void checkAlarmExtraRoutes(Uuid vpnId, List<Routes> routeList) {
if (!neutronvpnAlarm.isAlarmEnabled()) {
LOG.debug("checkAlarmExtraRoutes is not enable for vpnId {} routeList {}", vpnId, routeList);
return;
}
VpnInstance vpnInstance = neutronvpnUtils.getVpnInstance(dataBroker, vpnId);
if (vpnInstance == null || routeList == null || routeList.isEmpty() || !neutronvpnAlarm.isAlarmEnabled()) {
LOG.debug("checkAlarmExtraRoutes have args null as following : vpnId {} routeList {}", vpnId, routeList);
return;
}
List<Routes> routesError = new ArrayList();
for (Routes route : routeList) {
// count the number of nexthops for each same route.getDestingation().getValue()
String destination = String.valueOf(route.getDestination().getValue());
String nextHop = String.valueOf(route.getNexthop().getValue());
List<String> nextHopList = new ArrayList();
nextHopList.add(nextHop);
int nbNextHops = 0;
for (Routes routeTmp : routeList) {
String routeDest = String.valueOf(routeTmp.getDestination().getValue());
if (!destination.equals(routeDest)) {
continue;
}
String routeNextH = String.valueOf(routeTmp.getNexthop().getValue());
if (nextHop.equals(routeNextH)) {
continue;
}
nbNextHops++;
nextHopList.add(new String(routeTmp.getNexthop().getValue()));
}
final List<String> rdList = new ArrayList();
if (vpnInstance.getIpv4Family() != null && vpnInstance.getIpv4Family().getRouteDistinguisher() != null) {
vpnInstance.getIpv4Family().getRouteDistinguisher().stream().forEach(rd -> {
if (rd != null) {
rdList.add(rd);
}
});
}
if (vpnInstance.getIpv6Family() != null && vpnInstance.getIpv6Family().getRouteDistinguisher() != null) {
vpnInstance.getIpv6Family().getRouteDistinguisher().stream().forEach(rd -> {
if (rd != null && !rdList.contains(rd)) {
rdList.add(rd);
}
});
}
// 1. VPN Instance Name
String typeAlarm = "for vpnId: " + vpnId + " have exceeded next hops for prefixe";
// 2. Router ID
Uuid routerUuid = neutronvpnUtils.getRouterforVpn(vpnId);
StringBuilder detailsAlarm = new StringBuilder("routerUuid: ");
detailsAlarm.append(routerUuid == null ? vpnId.toString() : routerUuid.getValue());
// 3. List of RDs associated with the VPN
detailsAlarm.append(" List of RDs associated with the VPN: ");
for (String s : rdList) {
detailsAlarm.append(s);
detailsAlarm.append(", ");
}
// 4. Prefix in question
detailsAlarm.append(" for prefix: ");
detailsAlarm.append(route.getDestination().getValue());
// 5. List of NHs for the prefix
detailsAlarm.append(" for nextHops: ");
for (String s : nextHopList) {
detailsAlarm.append(s);
detailsAlarm.append(", ");
}
if (rdList.size() < nbNextHops) {
neutronvpnAlarm.raiseNeutronvpnAlarm(typeAlarm, detailsAlarm.toString());
LOG.error("there are too many next hops for prefixe in vpn {}", vpnId);
routesError.add(route);
} else {
neutronvpnAlarm.clearNeutronvpnAlarm(typeAlarm, detailsAlarm.toString());
}
}
// in routesError there are a few route raised in alarm, so they have not to be used
routeList.removeAll(routesError);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes in project netvirt by opendaylight.
the class NeutronvpnManager method createPortIpAdjacencies.
protected Adjacencies createPortIpAdjacencies(Port port, Boolean isRouterInterface, WriteTransaction wrtConfigTxn, Subnetmap sn, VpnInterface vpnIface) {
List<Adjacency> adjList = new ArrayList<>();
if (vpnIface != null) {
adjList = vpnIface.getAugmentation(Adjacencies.class).getAdjacency();
}
String infName = port.getUuid().getValue();
LOG.trace("neutronVpnManager: create config adjacencies for Port: {}", infName);
for (FixedIps ip : port.getFixedIps()) {
String ipValue = String.valueOf(ip.getIpAddress().getValue());
String ipPrefix = ip.getIpAddress().getIpv4Address() != null ? ipValue + "/32" : ipValue + "/128";
if (sn != null && !FibHelper.doesPrefixBelongToSubnet(ipPrefix, sn.getSubnetIp(), false)) {
continue;
}
Adjacency vmAdj = new AdjacencyBuilder().setKey(new AdjacencyKey(ipPrefix)).setIpAddress(ipPrefix).setMacAddress(port.getMacAddress().getValue()).setAdjacencyType(AdjacencyType.PrimaryAdjacency).setSubnetId(ip.getSubnetId()).build();
if (!adjList.contains(vmAdj)) {
adjList.add(vmAdj);
}
Subnetmap snTemp = sn != null ? sn : neutronvpnUtils.getSubnetmap(ip.getSubnetId());
Uuid routerId = snTemp != null ? snTemp.getRouterId() : null;
Uuid vpnId = snTemp != null ? snTemp.getVpnId() : null;
if (vpnId != null) {
neutronvpnUtils.createVpnPortFixedIpToPort(vpnId.getValue(), ipValue, infName, port.getMacAddress().getValue(), isRouterInterface, wrtConfigTxn);
}
if (snTemp != null && snTemp.getInternetVpnId() != null) {
neutronvpnUtils.createVpnPortFixedIpToPort(sn.getInternetVpnId().getValue(), ipValue, infName, port.getMacAddress().getValue(), isRouterInterface, wrtConfigTxn);
}
if (routerId != null) {
Router rtr = neutronvpnUtils.getNeutronRouter(routerId);
if (rtr != null && rtr.getRoutes() != null) {
List<Routes> routeList = rtr.getRoutes();
// create extraroute Adjacence for each ipValue,
// because router can have IPv4 and IPv6 subnet ports, or can have
// more that one IPv4 subnet port or more than one IPv6 subnet port
List<Adjacency> erAdjList = getAdjacencyforExtraRoute(routeList, ipValue);
if (!erAdjList.isEmpty()) {
adjList.addAll(erAdjList);
}
}
}
}
return new AdjacenciesBuilder().setAdjacency(adjList).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes in project netvirt by opendaylight.
the class NeutronvpnManager method removeInterVpnRoutes.
/**
* Removes the corresponding static routes from the specified VPN. These static routes point to an
* InterVpnLink endpoint and the specified VPN must be the other end of the InterVpnLink.
*
* @param vpnName the VPN identifier
* @param interVpnLinkRoutes The list of static routes
* @param nexthopsXinterVpnLinks A Map with the correspondence nextHop-InterVpnLink
*/
public void removeInterVpnRoutes(Uuid vpnName, List<Routes> interVpnLinkRoutes, HashMap<String, InterVpnLink> nexthopsXinterVpnLinks) {
for (Routes route : interVpnLinkRoutes) {
String nexthop = String.valueOf(route.getNexthop().getValue());
String destination = String.valueOf(route.getDestination().getValue());
InterVpnLink interVpnLink = nexthopsXinterVpnLinks.get(nexthop);
if (isNexthopTheOtherVpnLinkEndpoint(nexthop, vpnName.getValue(), interVpnLink)) {
RemoveStaticRouteInput rpcInput = new RemoveStaticRouteInputBuilder().setDestination(destination).setNexthop(nexthop).setVpnInstanceName(vpnName.getValue()).build();
ListenableFutures.addErrorLogging(JdkFutureAdapters.listenInPoolThread(vpnRpcService.removeStaticRoute(rpcInput)), LOG, "Remove VPN routes");
} else {
// Any other case is a fault.
LOG.warn("route with destination {} and nexthop {} does not apply to any InterVpnLink", String.valueOf(route.getDestination().getValue()), nexthop);
continue;
}
}
}
Aggregations