Search in sources :

Example 31 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 MappingServiceIntegrationTest method test21SBnegativeToSBmoreSpecific.

/*
     * Mapping change: adding a more specific southbound mapping overlapping a less specific negative mapping
     * Support status: SUPPORTED
     * Description: When a more specific SB mapping is added, the subscribers of the overlapping less specific existing
     *              negative SB mapping are notified, the negative is deleted, and then more specific negatives are
     *              created when requested.
     */
private void test21SBnegativeToSBmoreSpecific() {
    cleanUP();
    allowNullAuthenticationForAllIPv4(1L);
    // First we add two negative mappings to NB with a hole between them
    insertNBMappings(1L, "192.167.0.0/16", "192.169.0.0/16");
    // We query for the hole, adding a negative SB mapping for 192.168.0.0/16 with a subscriber in the process
    MapReply mapReply = lms.handleMapRequest(newMapRequest(1L, "192.168.0.1/32"));
    Eid expectedNegativePrefix = LispAddressUtil.asIpv4PrefixBinaryEid(1L, "192.168.0.0/16");
    MappingRecord mr = mapReply.getMappingRecordItem().get(0).getMappingRecord();
    assertEquals(expectedNegativePrefix, mr.getEid());
    assertTrue(MappingRecordUtil.isNegativeMapping(mr));
    // Add the more specific new overlapping SB mapping
    registerSBMapping(1L, "192.168.254.0/24", "10.10.10.10");
    // Notification is sent for the original prefix
    MappingServiceIntegrationTestUtil.checkSmr(socket, lms, mapService, 1L, "192.168.0.0");
    mapReply = lms.handleMapRequest(newMapRequest(1L, "192.168.0.1/32"));
    expectedNegativePrefix = LispAddressUtil.asIpv4PrefixBinaryEid(1L, "192.168.0.0/17");
    mr = mapReply.getMappingRecordItem().get(0).getMappingRecord();
    assertEquals(expectedNegativePrefix, mr.getEid());
    assertTrue(MappingRecordUtil.isNegativeMapping(mr));
    mapReply = lms.handleMapRequest(newMapRequest(1L, "192.168.254.1/32"));
    Eid expectedPositivePrefix = LispAddressUtil.asIpv4PrefixBinaryEid(1L, "192.168.254.0/24");
    mr = mapReply.getMappingRecordItem().get(0).getMappingRecord();
    assertEquals(expectedPositivePrefix, mr.getEid());
    assertTrue(MappingRecordUtil.isPositiveMapping(mr));
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) MapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply) GotMapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply) MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)

Example 32 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 MappingServiceIntegrationTest method test8NBtoSBexactMatch.

/*
     * Mapping change: adding a southbound mapping matching a northbound mapping
     * Support status: SUPPORTED
     * Description: When a SB mapping is added that has an existing exact match NB counterpart the subscribers of the
     *              prefix are notified. This is not strictly necessary for the NB_FIRST policy, but it is still useful
     *              for the NB_AND_SB policy.
     */
private void test8NBtoSBexactMatch() {
    cleanUP();
    allowNullAuthenticationForAllIPv4(1L);
    mapService.setLookupPolicy(IMappingService.LookupPolicy.NB_AND_SB);
    // Original NB mapping
    insertNBMapping(1L, "192.168.0.0/16", "172.16.0.1", "10.10.10.10");
    // Subscribe, by sending a Map-Request
    MapReply mapReply = lms.handleMapRequest(newMapRequest(1L, "192.168.0.1/32"));
    // Add a mapping with the same EID but different locator set in SB
    registerSBMapping(1L, "192.168.0.0/16", "10.10.10.10");
    // Notification is sent for the prefix
    MappingServiceIntegrationTestUtil.checkSmr(socket, lms, mapService, 1L, "192.168.0.0");
}
Also used : MapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply) GotMapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply)

Example 33 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 MappingServiceIntegrationTest method test18SBnegativeToNBmoreSpecific.

/*
     * Mapping change: adding a more specific northbound mapping overlapping a less specific negative southbound mapping
     * Support status: SUPPORTED
     * Description: When a more specific NB mapping is added, the overlapping negative prefix is deleted, its
     *              subscribers notified, and then more specific negatives are created when requested.
     */
private void test18SBnegativeToNBmoreSpecific() {
    cleanUP();
    // First we add two negative mappings to NB with a hole between them
    insertNBMappings(1L, "192.167.0.0/16", "192.169.0.0/16");
    // We query for the hole, adding a negative SB mapping for 192.168.0.0/16 with a subscriber in the process
    MapReply mapReply = lms.handleMapRequest(newMapRequest(1L, "192.168.0.1/32"));
    Eid expectedNegativePrefix = LispAddressUtil.asIpv4PrefixBinaryEid(1L, "192.168.0.0/16");
    MappingRecord mr = mapReply.getMappingRecordItem().get(0).getMappingRecord();
    assertEquals(expectedNegativePrefix, mr.getEid());
    assertTrue(MappingRecordUtil.isNegativeMapping(mr));
    // Add the more specific new overlapping NB mapping
    insertNBMappings(1L, "192.168.1.0/24");
    // Notification is sent for the original prefix
    MappingServiceIntegrationTestUtil.checkSmr(socket, lms, mapService, 1L, "192.168.0.0");
    // The original negative should now be broken up
    mapReply = lms.handleMapRequest(newMapRequest(1L, "192.168.0.1/32"));
    expectedNegativePrefix = LispAddressUtil.asIpv4PrefixBinaryEid(1L, "192.168.0.0/24");
    mr = mapReply.getMappingRecordItem().get(0).getMappingRecord();
    assertEquals(expectedNegativePrefix, mr.getEid());
    assertTrue(MappingRecordUtil.isNegativeMapping(mr));
    mapReply = lms.handleMapRequest(newMapRequest(1L, "192.168.64.1/32"));
    expectedNegativePrefix = LispAddressUtil.asIpv4PrefixBinaryEid(1L, "192.168.64.0/18");
    mr = mapReply.getMappingRecordItem().get(0).getMappingRecord();
    assertEquals(expectedNegativePrefix, mr.getEid());
    assertTrue(MappingRecordUtil.isNegativeMapping(mr));
    mapReply = lms.handleMapRequest(newMapRequest(1L, "192.168.1.1/32"));
    Eid expectedPositivePrefix = LispAddressUtil.asIpv4PrefixBinaryEid(1L, "192.168.1.0/24");
    mr = mapReply.getMappingRecordItem().get(0).getMappingRecord();
    assertEquals(expectedPositivePrefix, mr.getEid());
    assertTrue(MappingRecordUtil.isPositiveMapping(mr));
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) MapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply) GotMapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply) MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)

Example 34 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 MappingServiceIntegrationTestUtil method checkSmr.

/**
 * Read packets from the given socket until a Map-Request is found. Assert that the request is an SMR, and the
 * Source EID field contains the given IPv4 EID. Note that the source EID does not have a mask length. If a
 * reference to the LISP Mapping Service is passed, send an SMR-invoked Map-Request, to simulate what would happen
 * in the real world. If a reference to the Mapping Service is passed, the internal state of the map caches and
 * subscribers is logged.
 *
 * @param socket the receive socket
 * @param lms reference to the LISP Mapping Service, if present, an SMR-invoked Map-Request is sent in reply to the
 *            SMR
 * @param ms reference to the Mapping System, if present, the internal state of map-caches and subscribers is logged
 * @param vni the VNI for the expected EID
 * @param eids the expected EIDs, as an IPv4 string, without mask length
 */
static void checkSmr(DatagramSocket socket, IFlowMapping lms, IMappingService ms, long vni, String... eids) {
    LOG.debug("checkSmr: expecting {} SMRs: {}", eids.length, eids);
    List<MapRequest> mapRequests = receiveExpectedSmrs(socket, eids.length);
    assertNoMoreSMRs(socket, ms);
    HashMap<Eid, Integer> eidSet = prepareExpectedEids(vni, eids);
    for (MapRequest mapRequest : mapRequests) {
        LOG.trace("Solicit Map-Request: {}", mapRequest);
        Eid originalSourceEid = mapRequest.getEidItem().get(0).getEid();
        assertEquals(DEFAULT_IPV4_EID_PREFIX, originalSourceEid);
        Eid smrEid = mapRequest.getSourceEid().getEid();
        int counterDecremented = eidSet.get(smrEid) - 1;
        if (counterDecremented < 0) {
            fail("checkSmr: SMR contains EID " + LispAddressStringifier.getString(smrEid) + ", which is not in the list of expected EIDs: " + eidSet);
        } else {
            LOG.debug("checkSmr: successfully received expected SMR for {}", LispAddressStringifier.getString(smrEid));
        }
        if (lms != null) {
            sendSMRInvokedMapRequestMessage(mapRequest, lms);
        // TODO Capture the reply to the SMR-invoked Map-Request and assert on the expected result
        }
    }
    if (ms != null) {
        printMapCacheState(ms);
    }
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) MapRequest(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest)

Example 35 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 AuthenticationKeyDataListener method authKeysForEidsUnchanged.

/**
 * We maintain a HashMap with the update times of AuthenticationKey objects in the updatedEntries field. We keep
 * entries in the HashMap for the Map-Register cache timeout interval, and lazy remove them afterwards. As a result
 * the same EID will be considered updated during that interval, even on subsequent queries. This is necessary
 * because more than one xTR may register the same EID, and to avoid complexity we don't store origin information.
 * The performance trade-off is not significant, because during a typical cache timeout the same xTR will send only
 * a few registration packets (2 for the default value of 90s, when UDP Map-Registers are sent at 1 minute
 * intervals).
 *
 * @param eids List of EIDs to check
 * @param timeout MapRegister cache timeout value
 * @return false if any of the EIDs in the eids list was updated in the last timout period, true otherwise
 */
public synchronized boolean authKeysForEidsUnchanged(List<EidLispAddress> eids, long timeout) {
    boolean result = true;
    Long currentTime = System.currentTimeMillis();
    for (EidLispAddress eidLispAddress : eids) {
        Long updateTime = updatedEntries.get(eidLispAddress.getEid());
        if (updateTime != null) {
            result = false;
            if (currentTime - updateTime > timeout) {
                updatedEntries.remove(eidLispAddress.getEid());
            }
        }
    }
    return result;
}
Also used : EidLispAddress(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.map.register.cache.metadata.container.map.register.cache.metadata.EidLispAddress)

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