Search in sources :

Example 36 with Sent

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);
    }
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) MappingRecordItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder) Set(java.util.Set) HashSet(java.util.HashSet) MappingRecordItem(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem) TransportAddress(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddress) ArrayList(java.util.ArrayList) IpAddressBinary(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.IpAddressBinary) MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) MappingAuthkey(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) MapNotifyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapnotifymessage.MapNotifyBuilder) HashSet(java.util.HashSet)

Example 37 with Sent

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());
    }
}
Also used : RpcResultBuilder(org.opendaylight.yangtools.yang.common.RpcResultBuilder) UnknownHostException(java.net.UnknownHostException) SendArpRequestInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.arputil.rev160406.SendArpRequestInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetMacOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.arputil.rev160406.GetMacOutput)

Example 38 with Sent

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();
    }
}
Also used : ReentrantLock(java.util.concurrent.locks.ReentrantLock) VpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfaces) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList) ArrayList(java.util.ArrayList) VpnInterfacesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfacesKey) VpnToDpnListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnListBuilder) IpAddresses(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.IpAddresses) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) IpAddressesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.IpAddressesKey) VpnInterfacesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfacesBuilder) ExecutionException(java.util.concurrent.ExecutionException)

Example 39 with Sent

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());
}
Also used : ArpReponderInputBuilder(org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput.ArpReponderInputBuilder) ArrayList(java.util.ArrayList) InstructionWriteMetadata(org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)

Example 40 with Sent

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;
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) HashMap(java.util.HashMap) InstructionKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)

Aggregations

ArrayList (java.util.ArrayList)14 ExecutionException (java.util.concurrent.ExecutionException)13 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)11 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)9 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)5 InstructionWriteMetadata (org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata)4 TunnelTypeVxlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan)4 GotMapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply)4 MapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply)4 MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)4 UnknownHostException (java.net.UnknownHostException)3 Objects.requireNonNull (java.util.Objects.requireNonNull)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 VpnToDpnList (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList)3 VpnToDpnListBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnListBuilder)3 VpnInterfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfaces)3 VpnInterfacesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfacesBuilder)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 BigInteger (java.math.BigInteger)2 InetSocketAddress (java.net.InetSocketAddress)2