Search in sources :

Example 6 with Notify

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify in project netvirt by opendaylight.

the class VpnInterfaceManager method processVpnInterfaceUp.

// "Unconditional wait" and "Wait not in loop" wrt the VpnNotifyTask below - suppressing the FB violation -
// see comments below.
@SuppressFBWarnings({ "UW_UNCOND_WAIT", "WA_NOT_IN_LOOP" })
protected void processVpnInterfaceUp(final Uint64 dpId, VpnInterface vpnInterface, final String primaryRd, final int lportTag, boolean isInterfaceUp, TypedWriteTransaction<Configuration> writeConfigTxn, TypedWriteTransaction<Operational> writeOperTxn, TypedReadWriteTransaction<Configuration> writeInvTxn, Interface interfaceState, final String vpnName, Set<String> prefixListForRefreshFib) throws ExecutionException, InterruptedException {
    final String interfaceName = vpnInterface.getName();
    Optional<VpnInterfaceOpDataEntry> optOpVpnInterface = vpnUtil.getVpnInterfaceOpDataEntry(interfaceName, vpnName);
    VpnInterfaceOpDataEntry opVpnInterface = optOpVpnInterface.isPresent() ? optOpVpnInterface.get() : null;
    boolean isBgpVpnInternetVpn = vpnUtil.isBgpVpnInternet(vpnName);
    if (!isInterfaceUp) {
        LOG.info("processVpnInterfaceUp: Binding vpn service to interface {} onto dpn {} for vpn {}", interfaceName, dpId, vpnName);
        Uint32 vpnId = vpnUtil.getVpnId(vpnName);
        if (VpnConstants.INVALID_ID.equals(vpnId)) {
            LOG.warn("processVpnInterfaceUp: VpnInstance to VPNId mapping not available for VpnName {}" + " processing vpninterface {} on dpn {}, bailing out now.", vpnName, interfaceName, dpId);
            return;
        }
        boolean waitForVpnInterfaceOpRemoval = false;
        if (opVpnInterface != null) {
            String opVpnName = opVpnInterface.getVpnInstanceName();
            String primaryInterfaceIp = null;
            if (Objects.equals(opVpnName, vpnName)) {
                // Please check if the primary VRF Entry does not exist for VPNInterface
                // If so, we have to process ADD, as this might be a DPN Restart with Remove and Add triggered
                // back to back
                // However, if the primary VRF Entry for this VPNInterface exists, please continue bailing out !
                List<Adjacency> adjs = vpnUtil.getAdjacenciesForVpnInterfaceFromConfig(interfaceName);
                if (adjs == null) {
                    LOG.error("processVpnInterfaceUp: VPN Interface {} on dpn {} for vpn {} failed as adjacencies" + " for this vpn interface could not be obtained", interfaceName, dpId, vpnName);
                    return;
                }
                for (Adjacency adj : adjs) {
                    if (adj.getAdjacencyType() == AdjacencyType.PrimaryAdjacency) {
                        primaryInterfaceIp = adj.getIpAddress();
                        break;
                    }
                }
                if (primaryInterfaceIp == null) {
                    LOG.error("processVpnInterfaceUp: VPN Interface {} addition on dpn {} for vpn {} failed" + " as primary adjacency for this vpn interface could not be obtained", interfaceName, dpId, vpnName);
                    return;
                }
                // Get the rd of the vpn instance
                VrfEntry vrf = vpnUtil.getVrfEntry(primaryRd, primaryInterfaceIp);
                if (vrf != null) {
                    LOG.error("processVpnInterfaceUp: VPN Interface {} on dpn {} for vpn {} already provisioned ," + " bailing out from here.", interfaceName, dpId, vpnName);
                    return;
                }
                waitForVpnInterfaceOpRemoval = true;
            } else {
                LOG.error("processVpnInterfaceUp: vpn interface {} to go to configured vpn {} on dpn {}," + " but in operational vpn {}", interfaceName, vpnName, dpId, opVpnName);
            }
        }
        if (!waitForVpnInterfaceOpRemoval) {
            // Add the VPNInterface and quit
            vpnFootprintService.updateVpnToDpnMapping(dpId, vpnName, primaryRd, interfaceName, null, /*ipAddressSourceValuePair*/
            true);
            processVpnInterfaceAdjacencies(dpId, lportTag, vpnName, primaryRd, interfaceName, vpnId, writeConfigTxn, writeOperTxn, writeInvTxn, interfaceState, prefixListForRefreshFib);
            if (!isBgpVpnInternetVpn) {
                vpnUtil.bindService(vpnName, interfaceName, false);
            }
            LOG.info("processVpnInterfaceUp: Plumbed vpn interface {} onto dpn {} for vpn {}", interfaceName, dpId, vpnName);
            if (interfaceManager.isExternalInterface(interfaceName)) {
                processExternalVpnInterface(interfaceName, vpnName, dpId, lportTag, NwConstants.ADD_FLOW);
            }
            return;
        }
        // FIB didn't get a chance yet to clean up this VPNInterface
        // Let us give it a chance here !
        LOG.info("processVpnInterfaceUp: Trying to add VPN Interface {} on dpn {} for vpn {}," + " but waiting for FIB to clean up! ", interfaceName, dpId, vpnName);
        try {
            Runnable notifyTask = new VpnNotifyTask();
            synchronized (notifyTask) {
                // Per FB's "Unconditional wait" violation, the code should really verify that the condition it
                // intends to wait for is not already satisfied before calling wait. However the VpnNotifyTask is
                // published here while holding the lock on it so this path will hit the wait before notify can be
                // invoked.
                vpnIntfMap.put(interfaceName, notifyTask);
                try {
                    notifyTask.wait(VpnConstants.MAX_WAIT_TIME_IN_MILLISECONDS);
                } catch (InterruptedException e) {
                // Ignored
                }
            }
        } finally {
            vpnIntfMap.remove(interfaceName);
        }
        if (opVpnInterface != null) {
            LOG.warn("processVpnInterfaceUp: VPN Interface {} removal on dpn {} for vpn {}" + " by FIB did not complete on time," + " bailing addition ...", interfaceName, dpId, vpnName);
            vpnUtil.unsetScheduledToRemoveForVpnInterface(interfaceName);
            return;
        }
        // VPNInterface got removed, proceed with Add
        LOG.info("processVpnInterfaceUp: Continuing to plumb vpn interface {} onto dpn {} for vpn {}", interfaceName, dpId, vpnName);
        vpnFootprintService.updateVpnToDpnMapping(dpId, vpnName, primaryRd, interfaceName, null, /*ipAddressSourceValuePair*/
        true);
        processVpnInterfaceAdjacencies(dpId, lportTag, vpnName, primaryRd, interfaceName, vpnId, writeConfigTxn, writeOperTxn, writeInvTxn, interfaceState, prefixListForRefreshFib);
        if (!isBgpVpnInternetVpn) {
            vpnUtil.bindService(vpnName, interfaceName, false);
        }
        LOG.info("processVpnInterfaceUp: Plumbed vpn interface {} onto dpn {} for vpn {} after waiting for" + " FIB to clean up", interfaceName, dpId, vpnName);
        if (interfaceManager.isExternalInterface(interfaceName)) {
            processExternalVpnInterface(interfaceName, vpnName, dpId, lportTag, NwConstants.ADD_FLOW);
        }
    } else {
        try {
            // Interface is retained in the DPN, but its Link Up.
            // Advertise prefixes again for this interface to BGP
            InstanceIdentifier<VpnInterface> identifier = VpnUtil.getVpnInterfaceIdentifier(vpnInterface.getName());
            InstanceIdentifier<VpnInterfaceOpDataEntry> vpnInterfaceOpIdentifier = VpnUtil.getVpnInterfaceOpDataEntryIdentifier(interfaceName, vpnName);
            advertiseAdjacenciesForVpnToBgp(primaryRd, dpId, vpnInterfaceOpIdentifier, vpnName, interfaceName);
            // Perform similar operation as interface add event for extraroutes.
            InstanceIdentifier<Adjacencies> path = identifier.augmentation(Adjacencies.class);
            Optional<Adjacencies> optAdjacencies = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, path);
            if (!optAdjacencies.isPresent()) {
                LOG.trace("No config adjacencyKeyAdjacencyMap present for vpninterface {}", vpnInterface);
                return;
            }
            Map<AdjacencyKey, Adjacency> adjacencyKeyAdjacencyMap = optAdjacencies.get().nonnullAdjacency();
            for (Adjacency adjacency : adjacencyKeyAdjacencyMap.values()) {
                if (adjacency.getAdjacencyType() == AdjacencyType.PrimaryAdjacency) {
                    continue;
                }
                // if BGPVPN Internet, filter only IPv6 Adjacencies
                if (isBgpVpnInternetVpn && !vpnUtil.isAdjacencyEligibleToVpnInternet(adjacency)) {
                    continue;
                }
                addNewAdjToVpnInterface(vpnInterfaceOpIdentifier, primaryRd, adjacency, dpId, writeOperTxn, writeConfigTxn, writeInvTxn, prefixListForRefreshFib);
            }
        } catch (InterruptedException | ExecutionException e) {
            LOG.error("processVpnInterfaceUp: Failed to read data store for interface {} vpn {} rd {} dpn {}", interfaceName, vpnName, primaryRd, dpId);
        }
    }
}
Also used : AdjacencyKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.AdjacencyKey) Adjacencies(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.Adjacencies) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) VpnInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.interfaces.VpnInterface) Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.Adjacency) VpnInterfaceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry) ExecutionException(java.util.concurrent.ExecutionException) Uint32(org.opendaylight.yangtools.yang.common.Uint32) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 7 with Notify

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify in project controller by opendaylight.

the class EventSourceTopic method notifyExistingNodes.

private void notifyExistingNodes(final EventSourceTopology eventSourceTopology) {
    LOG.debug("Notify existing nodes");
    final Pattern nodeRegex = this.nodeIdPattern;
    final ReadOnlyTransaction tx = eventSourceTopology.getDataBroker().newReadOnlyTransaction();
    final ListenableFuture<Optional<Topology>> future = tx.read(LogicalDatastoreType.OPERATIONAL, EventSourceTopology.EVENT_SOURCE_TOPOLOGY_PATH);
    Futures.addCallback(future, new FutureCallback<Optional<Topology>>() {

        @Override
        public void onSuccess(@Nonnull final Optional<Topology> data) {
            if (data.isPresent()) {
                final List<Node> nodes = data.get().getNode();
                if (nodes != null) {
                    for (final Node node : nodes) {
                        if (nodeRegex.matcher(node.getNodeId().getValue()).matches()) {
                            notifyNode(EventSourceTopology.EVENT_SOURCE_TOPOLOGY_PATH.child(Node.class, node.getKey()));
                        }
                    }
                }
            }
            tx.close();
        }

        @Override
        public void onFailure(final Throwable ex) {
            LOG.error("Can not notify existing nodes", ex);
            tx.close();
        }
    }, MoreExecutors.directExecutor());
}
Also used : NotificationPattern(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.NotificationPattern) Pattern(java.util.regex.Pattern) Optional(com.google.common.base.Optional) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) List(java.util.List) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology)

Example 8 with Notify

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify in project lispflowmapping by opendaylight.

the class MapNotifySerializationTest method deserialize__MultipleRecords.

@Test
public void deserialize__MultipleRecords() throws Exception {
    // LISP(Type = 4 Map-Notify, I=1
    // Record Counter: 4
    // EID prefixes: 153.16.254.1 -- 152.16.254.1 -- 151.16.254.1 --
    // 150.16.254.1
    // Local RLOCs: 192.168.136.10 -- 192.168.136.11 -- 192.168.136.12 --
    // 192.168.136.13
    // 
    MapNotify mn = MapNotifySerializer.getInstance().deserialize(hexToByteBuffer("40 00 00 " + // Record count
    "04 " + "FF BB 00 00 00 00 00 00 00 01 00 14 87 c1 33 cd " + "d1 1e bc 80 fd 3e 71 11 81 17 40 74 26 25 44 bd " + // Record
    "00 00 00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " + // 1
    "ff 00 00 05 00 01 c0 a8 88 0a " + // contd
    "00 00 00 0a 01 20 10 00 00 00 00 01 98 10 fe 01 01 64 " + // 2
    "ff 00 00 05 00 01 c0 a8 88 0b " + // contd
    "00 00 00 0a 01 20 10 00 00 00 00 01 97 10 fe 01 01 64 " + // 3
    "ff 00 00 05 00 01 c0 a8 88 0c " + // contd
    "00 00 00 0a 01 20 10 00 00 00 00 01 96 10 fe 01 01 64 " + // 4
    "ff 00 00 05 00 01 c0 a8 88 0d "));
    assertEquals(4, mn.getMappingRecordItem().size());
    assertEquals(LispAddressUtil.asIpv4PrefixBinaryEid("153.16.254.1/32"), mn.getMappingRecordItem().get(0).getMappingRecord().getEid());
    assertEquals(LispAddressUtil.asIpv4PrefixBinaryEid("151.16.254.1/32"), mn.getMappingRecordItem().get(2).getMappingRecord().getEid());
    assertEquals(LispAddressUtil.asIpv4Rloc("192.168.136.11"), mn.getMappingRecordItem().get(1).getMappingRecord().getLocatorRecord().get(0).getRloc());
    assertEquals(LispAddressUtil.asIpv4Rloc("192.168.136.13"), mn.getMappingRecordItem().get(3).getMappingRecord().getLocatorRecord().get(0).getRloc());
}
Also used : MapNotify(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify) Test(org.junit.Test)

Example 9 with Notify

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify in project lispflowmapping by opendaylight.

the class MapNotifySerializationTest method deserialize__SHA256.

@Test
public void deserialize__SHA256() throws Exception {
    // LISP(Type = 4 Map-Notify, I=0
    // Record Counter: 1
    // Nonce: (something)
    // Key ID: 0x0002
    // AuthDataLength: 32 Data:
    // 70 30 d4 c6 10 44 0d 83 be 4d bf fd a9 8c 57 6d 68 a5 bf 32 11 c9 7b
    // 58 c4 b9 9f 06 11 23 b9 38
    // EID prefix: 153.16.254.1/32 (EID=0x9910FE01), TTL: 10, Authoritative,
    // No-Action
    // Local RLOC: 192.168.136.10 (RLOC=0xC0A8880A), Reachable,
    // Priority/Weight: 1/100, Multicast Priority/Weight: 255/0
    // 
    MapNotify mn = MapNotifySerializer.getInstance().deserialize(hexToByteBuffer("40 00 00 01 FF BB " + "00 00 00 00 00 00 00 02 00 20 70 30 d4 c6 10 44 0d 83 be 4d bf fd a9 8c 57 6d 68 a5 bf 32 " + "11 c9 7b 58 c4 b9 9f 06 11 23 b9 38 00 00 " + "00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " + "ff 00 00 05 00 01 c0 a8 88 0a"));
    assertFalse(mn.isXtrSiteIdPresent());
    assertEquals(1, mn.getMappingRecordItem().size());
    assertEquals(0xFFBB000000000000L, mn.getNonce().longValue());
    assertEquals(0x0002, mn.getKeyId().shortValue());
    byte[] expectedAuthenticationData = { (byte) 0x70, (byte) 0x30, (byte) 0xd4, (byte) 0xc6, (byte) 0x10, (byte) 0x44, (byte) 0x0d, (byte) 0x83, (byte) 0xbe, (byte) 0x4d, (byte) 0xbf, (byte) 0xfd, (byte) 0xa9, (byte) 0x8c, (byte) 0x57, (byte) 0x6d, (byte) 0x68, (byte) 0xa5, (byte) 0xbf, (byte) 0x32, (byte) 0x11, (byte) 0xc9, (byte) 0x7b, (byte) 0x58, (byte) 0xc4, (byte) 0xb9, (byte) 0x9f, (byte) 0x06, (byte) 0x11, (byte) 0x23, (byte) 0xb9, (byte) 0x38 };
    ArrayAssert.assertEquals(expectedAuthenticationData, mn.getAuthenticationData());
}
Also used : MapNotify(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify) Test(org.junit.Test)

Example 10 with Notify

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify in project lispflowmapping by opendaylight.

the class MapNotifySerializationTest method deserialize__SomeEidToLocatorFiels.

@Test
public void deserialize__SomeEidToLocatorFiels() throws Exception {
    // LISP(Type = 4 Map-Notify, I=0
    // Record Counter: 4
    // EID prefixes: 153.16.254.1 -- 152.16.254.1 -- 151.16.254.1 --
    // 150.16.254.1
    // Local RLOCs: 192.168.136.10 -- 192.168.136.11 -- 192.168.136.12 --
    // 192.168.136.13
    // 
    MapNotify mn = MapNotifySerializer.getInstance().deserialize(hexToByteBuffer("40 00 00 " + // 
    "04 " + // Record count
    "FF BB 00 00 00 00 00 00 00 01 00 14 b9 cd 7b 89 " + // 
    "65 c2 56 03 be dd 81 20 47 e5 c3 4f 56 02 e1 59 " + // 
    "00 00 00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " + // 0
    "ff 00 00 05 00 01 c0 a8 88 0a " + // contd
    "00 00 00 0b 01 17 50 00 01 11 00 01 98 10 fe 01 01 64 " + // 1
    "ff 00 00 05 00 01 c0 a8 88 0b " + // contd
    "00 00 00 0c 01 20 00 00 02 22 00 01 97 10 fe 01 01 64 " + // 2
    "ff 00 00 05 00 01 c0 a8 88 0c " + // contd
    "00 00 00 0d 01 20 20 00 03 33 00 01 96 10 fe 01 01 64 " + // 3
    "ff 00 00 05 00 01 c0 a8 88 0d "));
    assertEquals(4, mn.getMappingRecordItem().size());
    final MappingRecord record0 = mn.getMappingRecordItem().get(0).getMappingRecord();
    final MappingRecord record1 = mn.getMappingRecordItem().get(1).getMappingRecord();
    final MappingRecord record2 = mn.getMappingRecordItem().get(2).getMappingRecord();
    final MappingRecord record3 = mn.getMappingRecordItem().get(3).getMappingRecord();
    assertEquals(10, record0.getRecordTtl().intValue());
    assertEquals(13, record3.getRecordTtl().intValue());
    assertEquals(32, MaskUtil.getMaskForAddress(record0.getEid().getAddress()));
    assertEquals(23, MaskUtil.getMaskForAddress(record1.getEid().getAddress()));
    assertEquals(Action.NoAction, record0.getAction());
    assertEquals(Action.SendMapRequest, record1.getAction());
    assertEquals(Action.NoAction, record2.getAction());
    assertEquals(Action.NativelyForward, record3.getAction());
    assertTrue(record0.isAuthoritative());
    assertTrue(record1.isAuthoritative());
    assertFalse(record2.isAuthoritative());
    assertFalse(record3.isAuthoritative());
    assertEquals(0x000, record0.getMapVersion().shortValue());
    assertEquals(0x111, record1.getMapVersion().shortValue());
    assertEquals(0x222, record2.getMapVersion().shortValue());
    assertEquals(0x333, record3.getMapVersion().shortValue());
}
Also used : MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) MapNotify(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)16 Notify (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify)12 MapNotify (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify)8 Notification (org.opendaylight.yangtools.yang.binding.Notification)6 ArrayList (java.util.ArrayList)5 JAXBException (javax.xml.bind.JAXBException)5 Notify (org.oasis_open.docs.wsn.b_2.Notify)5 Open (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Open)5 JMSException (javax.jms.JMSException)4 AclInterface (org.opendaylight.netvirt.aclservice.api.utils.AclInterface)4 MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)4 Message (javax.jms.Message)3 TextMessage (javax.jms.TextMessage)3 NotificationMessageHolderType (org.oasis_open.docs.wsn.b_2.NotificationMessageHolderType)3 BGPDocumentedException (org.opendaylight.protocol.bgp.parser.BGPDocumentedException)3 Ipv4AddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone)3 OpenBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.OpenBuilder)3 Optional (com.google.common.base.Optional)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)2 ByteBuf (io.netty.buffer.ByteBuf)2