use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac in project netvirt by opendaylight.
the class NexthopManager method createLocalNextHop.
public long createLocalNextHop(long vpnId, BigInteger dpnId, String ifName, String ipNextHopAddress, String ipPrefixAddress, String gwMacAddress, String jobKey) {
String vpnName = fibUtil.getVpnNameFromId(vpnId);
if (vpnName == null) {
return 0;
}
String macAddress = fibUtil.getMacAddressFromPrefix(ifName, vpnName, ipPrefixAddress);
String ipAddress = macAddress != null ? ipPrefixAddress : ipNextHopAddress;
long groupId = createNextHopPointer(getNextHopKey(vpnId, ipAddress));
if (groupId == 0) {
LOG.error("Unable to allocate groupId for vpnId {} , prefix {} IntfName {}, nextHopAddr {}", vpnId, ipAddress, ifName, ipNextHopAddress);
return groupId;
}
String nextHopLockStr = vpnId + ipAddress;
jobCoordinator.enqueueJob(jobKey, () -> {
synchronized (nextHopLockStr.intern()) {
VpnNexthop nexthop = getVpnNexthop(vpnId, ipAddress);
LOG.trace("nexthop: {} retrieved for vpnId {}, prefix {}, ifName {} on dpn {}", nexthop, vpnId, ipAddress, ifName, dpnId);
if (nexthop == null) {
String encMacAddress = macAddress == null ? fibUtil.getMacAddressFromPrefix(ifName, vpnName, ipAddress) : macAddress;
List<BucketInfo> listBucketInfo = new ArrayList<>();
List<ActionInfo> listActionInfo = new ArrayList<>();
int actionKey = 0;
// MAC re-write
if (encMacAddress != null) {
if (gwMacAddress != null) {
LOG.trace("The Local NextHop Group Source Mac {} for VpnInterface {} on VPN {}", gwMacAddress, ifName, vpnId);
listActionInfo.add(new ActionSetFieldEthernetSource(actionKey++, new MacAddress(gwMacAddress)));
}
listActionInfo.add(new ActionSetFieldEthernetDestination(actionKey++, new MacAddress(encMacAddress)));
// listActionInfo.add(0, new ActionPopMpls());
} else {
// FIXME: Log message here.
LOG.debug("mac address for new local nexthop is null");
}
listActionInfo.addAll(getEgressActionsForInterface(ifName, actionKey));
BucketInfo bucket = new BucketInfo(listActionInfo);
listBucketInfo.add(bucket);
GroupEntity groupEntity = MDSALUtil.buildGroupEntity(dpnId, groupId, ipAddress, GroupTypes.GroupAll, listBucketInfo);
LOG.trace("Install LNH Group: id {}, mac address {}, interface {} for prefix {}", groupId, encMacAddress, ifName, ipAddress);
// Try to install group directly on the DPN bypassing the FRM, in order to avoid waiting for the
// group to get installed before programming the flows
installGroupOnDpn(groupId, dpnId, ipAddress, listBucketInfo, getNextHopKey(vpnId, ipAddress), GroupTypes.GroupAll);
// install Group
mdsalApiManager.syncInstallGroup(groupEntity);
// update MD-SAL DS
addVpnNexthopToDS(dpnId, vpnId, ipAddress, groupId);
} else {
// nexthop exists already; a new flow is going to point to
// it, increment the flowrefCount by 1
int flowrefCnt = nexthop.getFlowrefCount() + 1;
VpnNexthop nh = new VpnNexthopBuilder().setKey(new VpnNexthopKey(ipAddress)).setFlowrefCount(flowrefCnt).build();
LOG.trace("Updating vpnnextHop {} for refCount {} to Operational DS", nh, flowrefCnt);
MDSALUtil.syncUpdate(dataBroker, LogicalDatastoreType.OPERATIONAL, getVpnNextHopIdentifier(vpnId, ipAddress), nh);
}
}
return Collections.emptyList();
});
return groupId;
}
use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac in project netvirt by opendaylight.
the class RouterInterfaceVrfEntryHandler method installRouterFibEntries.
private Boolean installRouterFibEntries(VrfEntry vrfEntry, String rd, int addOrRemove, RouterInterface routerInterface) {
final VpnInstanceOpDataEntry vpnInstance = getFibUtil().getVpnInstance(rd);
Preconditions.checkNotNull(vpnInstance, "Vpn Instance not available " + rd);
Preconditions.checkNotNull(vpnInstance.getVpnId(), "Vpn Instance with rd " + vpnInstance.getVrfId() + " has null vpnId!");
synchronized (vpnInstance.getVpnInstanceName().intern()) {
final Collection<VpnToDpnList> vpnToDpnList;
if (vrfEntry.getParentVpnRd() != null && FibHelper.isControllerManagedNonSelfImportedRoute(RouteOrigin.value(vrfEntry.getOrigin()))) {
VpnInstanceOpDataEntry parentVpnInstance = getFibUtil().getVpnInstance(vrfEntry.getParentVpnRd());
vpnToDpnList = parentVpnInstance != null ? parentVpnInstance.getVpnToDpnList() : vpnInstance.getVpnToDpnList();
} else {
vpnToDpnList = vpnInstance.getVpnToDpnList();
}
final Long vpnId = vpnInstance.getVpnId();
if (vpnToDpnList != null) {
String routerId = routerInterface.getUuid();
String macAddress = routerInterface.getMacAddress();
String ipValue = routerInterface.getIpAddress();
LOG.trace("createFibEntries - Router augmented vrfentry found for for router uuid:{}, ip:{}, mac:{}", routerId, ipValue, macAddress);
for (VpnToDpnList vpnDpn : vpnToDpnList) {
if (vpnDpn.getDpnState() == VpnToDpnList.DpnState.Active) {
installRouterFibEntry(vrfEntry, vpnDpn.getDpnId(), vpnId, ipValue, new MacAddress(macAddress), addOrRemove);
}
}
}
}
return true;
}
use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac in project netvirt by opendaylight.
the class ElanL2GatewayMulticastUtils method updateMcastMacsForAllElanDevices.
/**
* Update mcast macs for this elan.
* for all dpns in this elan recompute and update broadcast group
* for all l2gw devices in this elan recompute and update remote mcast mac entry
*
* @param elanName
* the elan name
* @param device
* the device
* @param updateThisDevice
* the update this device
* @return the listenable future
*/
private ListenableFuture<Void> updateMcastMacsForAllElanDevices(String elanName, L2GatewayDevice device, boolean updateThisDevice) {
SettableFuture<Void> ft = SettableFuture.create();
ft.set(null);
List<DpnInterfaces> dpns = elanUtils.getElanDPNByName(elanName);
ConcurrentMap<String, L2GatewayDevice> devices = ElanL2GwCacheUtils.getInvolvedL2GwDevices(elanName);
List<IpAddress> dpnsTepIps = getAllTepIpsOfDpns(device, dpns);
List<IpAddress> l2GwDevicesTepIps = getAllTepIpsOfL2GwDevices(devices);
return txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
if (updateThisDevice) {
preapareRemoteMcastMacEntry(elanName, device, dpnsTepIps, l2GwDevicesTepIps);
}
// present to configure RemoteMcastMac entry
for (L2GatewayDevice otherDevice : devices.values()) {
if (!otherDevice.getDeviceName().equals(device.getDeviceName())) {
preapareRemoteMcastMacEntry(elanName, otherDevice, dpnsTepIps, l2GwDevicesTepIps);
}
}
});
}
use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac in project netvirt by opendaylight.
the class ElanL2GatewayMulticastUtils method preapareRemoteMcastMacEntry.
/**
* Update remote mcast mac.
*
* @param elanName
* the elan name
* @param device
* the device
* @param dpnsTepIps
* the dpns tep ips
* @param l2GwDevicesTepIps
* the l2 gw devices tep ips
* @return the write transaction
*/
private void preapareRemoteMcastMacEntry(String elanName, L2GatewayDevice device, List<IpAddress> dpnsTepIps, List<IpAddress> l2GwDevicesTepIps) {
NodeId nodeId = new NodeId(device.getHwvtepNodeId());
ArrayList<IpAddress> remoteTepIps = new ArrayList<>(l2GwDevicesTepIps);
remoteTepIps.remove(device.getTunnelIp());
remoteTepIps.addAll(dpnsTepIps);
IpAddress dhcpDesignatedSwitchTepIp = getTepIpOfDesignatedSwitchForExternalTunnel(device, elanName);
if (dpnsTepIps.isEmpty()) {
// physical locator in l2 gw device
if (dhcpDesignatedSwitchTepIp != null) {
remoteTepIps.add(dhcpDesignatedSwitchTepIp);
HwvtepPhysicalLocatorAugmentation phyLocatorAug = HwvtepSouthboundUtils.createHwvtepPhysicalLocatorAugmentation(String.valueOf(dhcpDesignatedSwitchTepIp.getValue()));
InstanceIdentifier<TerminationPoint> iid = HwvtepSouthboundUtils.createPhysicalLocatorInstanceIdentifier(nodeId, phyLocatorAug);
TerminationPoint terminationPoint = new TerminationPointBuilder().setKey(HwvtepSouthboundUtils.getTerminationPointKey(phyLocatorAug)).addAugmentation(HwvtepPhysicalLocatorAugmentation.class, phyLocatorAug).build();
ResourceBatchingManager.getInstance().put(ResourceBatchingManager.ShardResource.CONFIG_TOPOLOGY, iid, terminationPoint);
LOG.info("Adding PhysicalLocator for node: {} with Dhcp designated switch Tep Ip {} " + "as physical locator, elan {}", device.getHwvtepNodeId(), String.valueOf(dhcpDesignatedSwitchTepIp.getValue()), elanName);
} else {
LOG.warn("Dhcp designated switch Tep Ip not found for l2 gw node {} and elan {}", device.getHwvtepNodeId(), elanName);
}
}
if (dhcpDesignatedSwitchTepIp != null && !remoteTepIps.contains(dhcpDesignatedSwitchTepIp)) {
remoteTepIps.add(dhcpDesignatedSwitchTepIp);
}
String logicalSwitchName = ElanL2GatewayUtils.getLogicalSwitchFromElan(elanName);
putRemoteMcastMac(nodeId, logicalSwitchName, remoteTepIps);
LOG.info("Adding RemoteMcastMac for node: {} with physical locators: {}", device.getHwvtepNodeId(), remoteTepIps);
}
use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac in project netvirt by opendaylight.
the class ElanL2GatewayUtils method removeRemoteUcastMacsFromExternalDevice.
/**
* Removes the given MAC Addresses from the specified External Device.
*
* @param deviceNodeId
* the device node id
* @param macAddresses
* the mac addresses
* @return the listenable future
*/
private ListenableFuture<Void> removeRemoteUcastMacsFromExternalDevice(String deviceNodeId, String logicalSwitchName, List<PhysAddress> macAddresses) {
NodeId nodeId = new NodeId(deviceNodeId);
// TODO (eperefr)
List<MacAddress> lstMac = macAddresses.stream().filter(Objects::nonNull).map(physAddress -> new MacAddress(physAddress.getValue())).collect(Collectors.toList());
return HwvtepUtils.deleteRemoteUcastMacs(broker, nodeId, logicalSwitchName, lstMac);
}
Aggregations