use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Sent in project lispflowmapping by opendaylight.
the class MapServer method handleMapRegister.
@SuppressWarnings("unchecked")
public void handleMapRegister(MapRegister mapRegister) {
boolean mappingUpdated = false;
boolean merge = ConfigIni.getInstance().mappingMergeIsSet() && mapRegister.isMergeEnabled();
MappingRecord oldMapping;
if (merge) {
if (!mapRegister.isXtrSiteIdPresent() || mapRegister.getXtrId() == null) {
LOG.error("Merge bit is set in Map-Register, but xTR-ID is not present. Will not merge.");
merge = false;
} else if (Arrays.equals(mapRegister.getXtrId().getValue(), ALL_ZEROES_XTR_ID)) {
LOG.warn("Merge bit is set in Map-Register, but xTR-ID is all zeroes.");
}
}
for (MappingRecordItem record : mapRegister.getMappingRecordItem()) {
MappingRecord mapping = record.getMappingRecord();
Eid eid = mapping.getEid();
MappingData mappingData = new MappingData(mapping, System.currentTimeMillis());
mappingData.setMergeEnabled(merge);
mappingData.setXtrId(mapRegister.getXtrId());
oldMapping = getMappingRecord(mapService.getMapping(MappingOrigin.Southbound, eid));
mapService.addMapping(MappingOrigin.Southbound, eid, getSiteId(mapRegister), mappingData);
if (merge) {
MappingRecord newMapping = getMappingRecord(mapService.getMapping(MappingOrigin.Southbound, eid));
if (MappingRecordUtil.mappingChanged(oldMapping, newMapping)) {
// If there is a SB mapping change with merge on, Map-Notify will be sent to ALL xTRs, not jus the
// one registering (merging is done in the MappingSystem code)
mappingUpdated = true;
}
}
}
if (BooleanUtils.isTrue(mapRegister.isWantMapNotify())) {
LOG.trace("MapRegister wants MapNotify");
MapNotifyBuilder builder = new MapNotifyBuilder();
List<TransportAddress> rlocs = null;
if (merge) {
Set<IpAddressBinary> notifyRlocs = new HashSet<IpAddressBinary>();
List<MappingRecordItem> mergedMappings = new ArrayList<MappingRecordItem>();
for (MappingRecordItem record : mapRegister.getMappingRecordItem()) {
MappingRecord mapping = record.getMappingRecord();
MappingRecord currentRecord = getMappingRecord(mapService.getMapping(MappingOrigin.Southbound, mapping.getEid()));
mergedMappings.add(new MappingRecordItemBuilder().setMappingRecord(currentRecord).build());
Set<IpAddressBinary> sourceRlocs = (Set<IpAddressBinary>) mapService.getData(MappingOrigin.Southbound, mapping.getEid(), SubKeys.SRC_RLOCS);
if (sourceRlocs != null) {
notifyRlocs.addAll(sourceRlocs);
}
}
MapNotifyBuilderHelper.setFromMapRegisterAndMappingRecordItems(builder, mapRegister, mergedMappings);
// send map-notify to merge group only when mapping record is changed
if (mappingUpdated) {
rlocs = getTransportAddresses(notifyRlocs);
}
} else {
MapNotifyBuilderHelper.setFromMapRegister(builder, mapRegister);
}
List<MappingRecordItem> mappings = builder.getMappingRecordItem();
if (mappings != null && mappings.get(0) != null && mappings.get(0).getMappingRecord() != null && mappings.get(0).getMappingRecord().getEid() != null) {
MappingAuthkey authkey = mapService.getAuthenticationKey(mappings.get(0).getMappingRecord().getEid());
if (authkey != null) {
builder.setAuthenticationData(LispAuthenticationUtil.createAuthenticationData(builder.build(), authkey.getKeyString()));
}
}
notifyHandler.handleMapNotify(builder.build(), rlocs);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Sent in project genius by opendaylight.
the class ArpUtilImpl method getMac.
@Override
public Future<RpcResult<GetMacOutput>> getMac(GetMacInput input) {
try {
final String dstIpAddress = getIpAddressInString(input.getIpaddress());
LOG.trace("getMac rpc invoked for ip {}", dstIpAddress);
if (macAddrs.get(dstIpAddress) != null) {
if (LOG.isInfoEnabled()) {
LOG.info("get mac already in progress for the ip {}", dstIpAddress);
}
return macAddrs.get(dstIpAddress);
}
SendArpRequestInputBuilder builder = new SendArpRequestInputBuilder().setInterfaceAddress(input.getInterfaceAddress()).setIpaddress(input.getIpaddress());
Future<RpcResult<Void>> arpReqFt = sendArpRequest(builder.build());
final SettableFuture<RpcResult<GetMacOutput>> ft = SettableFuture.create();
Futures.addCallback(JdkFutureAdapters.listenInPoolThread(arpReqFt, threadPool), new FutureCallback<RpcResult<Void>>() {
@Override
public void onFailure(Throwable ex) {
RpcResultBuilder<GetMacOutput> resultBuilder = RpcResultBuilder.<GetMacOutput>failed().withError(ErrorType.APPLICATION, ex.getMessage(), ex);
ft.set(resultBuilder.build());
}
@Override
public void onSuccess(RpcResult<Void> result) {
LOG.trace("Successfully sent the arp pkt out for ip {}", dstIpAddress);
}
}, MoreExecutors.directExecutor());
macAddrs.put(dstIpAddress, ft);
return ft;
} catch (UnknownHostException e) {
LOG.error("Failed to handle getMac request for {}", input.getIpaddress(), e);
RpcResultBuilder<GetMacOutput> resultBuilder = RpcResultBuilder.<GetMacOutput>failed().withError(ErrorType.APPLICATION, e.getMessage(), e);
return Futures.immediateFuture(resultBuilder.build());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Sent in project netvirt by opendaylight.
the class VpnFootprintService method removeOrUpdateVpnToDpnListForInterfaceName.
private void removeOrUpdateVpnToDpnListForInterfaceName(Uint32 vpnId, String rd, Uint64 dpnId, String intfName, String vpnName) {
AtomicBoolean lastDpnOnVpn = new AtomicBoolean(false);
/* Starts synchronized block. This ensures only one reader/writer get access to vpn-dpn-list
* The future.get ensures that the write to the datastore is complete before leaving the synchronized block.
*/
// FIXME: separate this out somehow?
final ReentrantLock lock = JvmGlobalLocks.getLockForString(vpnName);
lock.lock();
try {
try {
ListenableFuture<?> future = txRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, tx -> {
InstanceIdentifier<VpnToDpnList> id = VpnHelper.getVpnToDpnListIdentifier(rd, dpnId);
Optional<VpnToDpnList> dpnInVpnOpt = tx.read(id).get();
if (!dpnInVpnOpt.isPresent()) {
LOG.error("removeOrUpdateVpnToDpnList: Could not find DpnToVpn map for VPN=[name={}" + " rd={} id={}] and dpnId={}", vpnName, rd, id, dpnId);
return;
}
VpnToDpnList dpnInVpn = dpnInVpnOpt.get();
List<VpnInterfaces> vpnInterfaces = new ArrayList<>(dpnInVpn.nonnullVpnInterfaces().values());
if (vpnInterfaces == null) {
LOG.error("Could not find vpnInterfaces for DpnInVpn map for VPN=[name={} rd={} id={}] and " + "dpnId={}", vpnName, rd, id, dpnId);
return;
}
VpnInterfaces currVpnInterface = new VpnInterfacesBuilder().setInterfaceName(intfName).build();
if (vpnInterfaces.remove(currVpnInterface)) {
if (vpnInterfaces.isEmpty()) {
Map<IpAddressesKey, IpAddresses> ipAddressesMap = dpnInVpn.nonnullIpAddresses();
VpnToDpnListBuilder dpnInVpnBuilder = new VpnToDpnListBuilder(dpnInVpn).setVpnInterfaces(Collections.emptyMap());
if (ipAddressesMap == null || ipAddressesMap.isEmpty()) {
dpnInVpnBuilder.setDpnState(VpnToDpnList.DpnState.Inactive);
lastDpnOnVpn.set(true);
} else {
LOG.error("removeOrUpdateVpnToDpnList: vpn interfaces are empty but ip addresses" + " are present for the vpn {} in dpn {} interface {}", vpnName, dpnId, intfName);
}
LOG.debug("removeOrUpdateVpnToDpnList: Removing vpn footprint for vpn {} vpnId {} " + "interface {}, on dpn {}", vpnName, vpnName, intfName, dpnId);
tx.mergeParentStructurePut(id, dpnInVpnBuilder.build());
} else {
tx.delete(id.child(VpnInterfaces.class, new VpnInterfacesKey(intfName)));
LOG.debug("removeOrUpdateVpnToDpnList: Updating vpn footprint for vpn {} vpnId {} " + "interface {}, on dpn {}", vpnName, vpnName, intfName, dpnId);
}
}
});
future.get();
} catch (InterruptedException | ExecutionException e) {
LOG.error("removeOrUpdateVpnToDpnList: Error removing from dpnToVpnList for vpn {} vpnId {}" + " interface {} dpn {}", vpnName, vpnId, intfName, dpnId, e);
throw new RuntimeException(e.getMessage(), e);
}
// Ends synchronized block
LOG.info("removeOrUpdateVpnToDpnList: Updated/Removed vpn footprint for vpn {} vpnId {} interface {}," + " on dpn {}", vpnName, vpnName, intfName, dpnId);
if (lastDpnOnVpn.get()) {
fibManager.cleanUpDpnForVpn(dpnId, vpnId, rd, new DpnEnterExitVpnWorker(dpnId, vpnName, rd, false));
LOG.info("removeOrUpdateVpnToDpnList: Sent cleanup event for dpn {} in VPN {} vpnId {} interface {}", dpnId, vpnName, vpnId, intfName);
}
} finally {
lock.unlock();
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Sent in project netvirt by opendaylight.
the class VpnManagerImpl method installArpResponderFlowsToExternalNetworkIp.
private void installArpResponderFlowsToExternalNetworkIp(String macAddress, Uint64 dpnId, String extInterfaceName, int lportTag, String fixedIp) {
// reset the split-horizon bit to allow traffic to be sent back to the
// provider port
List<Instruction> instructions = new ArrayList<>();
instructions.add(new InstructionWriteMetadata(Uint64.ZERO, MetaDataUtil.METADATA_MASK_SH_FLAG).buildInstruction(1));
instructions.addAll(ArpResponderUtil.getExtInterfaceInstructions(interfaceManager, itmRpcService, extInterfaceName, fixedIp, macAddress));
ArpReponderInputBuilder builder = new ArpReponderInputBuilder().setDpId(dpnId.toJava()).setInterfaceName(extInterfaceName).setSpa(fixedIp).setSha(macAddress).setLportTag(lportTag);
builder.setInstructions(instructions);
elanService.addArpResponderFlow(builder.buildForInstallFlow());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Sent in project netvirt by opendaylight.
the class ElanUtils method getInstructionsInPortForOutGroup.
/**
* Constructs the Instructions that take the packet over a given interface.
*
* @param ifName
* Name of the interface where the packet must be sent over. It
* can be a local interface or a tunnel interface (internal or
* external)
* @return the Instruction
*/
public Map<InstructionKey, Instruction> getInstructionsInPortForOutGroup(String ifName) {
int instructionsKey = 0;
Map<InstructionKey, Instruction> mkInstructions = new HashMap<>();
List<Action> actions = getEgressActionsForInterface(ifName, /* tunnelKey */
null);
mkInstructions.put(new InstructionKey(++instructionsKey), MDSALUtil.buildApplyActionsInstruction(actions));
return mkInstructions;
}
Aggregations