Search in sources :

Example 46 with Prefixes

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.operational.rev151009.bgp.neighbor.prefix.counters_state.Prefixes in project lispflowmapping by opendaylight.

the class MapRegisterSerializationTest method deserialize__MultipleRecords.

@Test
public void deserialize__MultipleRecords() throws Exception {
    // LISP(Type = 3 Map-Register, P=1, M=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
    // 
    MapRegister mr = MapRegisterSerializer.getInstance().deserialize(hexToByteBuffer("38 00 01 " + // 
    "04 " + // Record count
    "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 " + // 
    "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 "), null);
    assertEquals(4, mr.getMappingRecordItem().size());
    assertEquals(LispAddressUtil.asIpv4PrefixBinaryEid("153.16.254.1/32"), mr.getMappingRecordItem().get(0).getMappingRecord().getEid());
    assertEquals(LispAddressUtil.asIpv4PrefixBinaryEid("151.16.254.1/32"), mr.getMappingRecordItem().get(2).getMappingRecord().getEid());
    assertEquals(LispAddressUtil.asIpv4Rloc("192.168.136.11"), mr.getMappingRecordItem().get(1).getMappingRecord().getLocatorRecord().get(0).getRloc());
    assertEquals(LispAddressUtil.asIpv4Rloc("192.168.136.13"), mr.getMappingRecordItem().get(3).getMappingRecord().getLocatorRecord().get(0).getRloc());
}
Also used : MapRegister(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister) Test(org.junit.Test)

Example 47 with Prefixes

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.operational.rev151009.bgp.neighbor.prefix.counters_state.Prefixes in project lispflowmapping by opendaylight.

the class MappingSystem method getWidestNegativePrefix.

@Override
public Eid getWidestNegativePrefix(Eid key) {
    if (!MaskUtil.isMaskable(key.getAddress())) {
        LOG.warn("Widest negative prefix only makes sense for maskable addresses!");
        return null;
    }
    // We assume that ILispMapCache#getWidestNegativeMapping() returns null for positive mappings, and 0/0
    // for empty cache.
    Eid nbPrefix = pmc.getWidestNegativeMapping(key);
    if (nbPrefix == null) {
        LOG.trace("getWidestNegativePrefix NB: positive mapping, returning null");
        return null;
    }
    if (LOG.isTraceEnabled()) {
        LOG.trace("getWidestNegativePrefix NB: {}", LispAddressStringifier.getString(nbPrefix));
    }
    Eid sbPrefix = smc.getWidestNegativeMapping(key);
    if (sbPrefix == null) {
        LOG.trace("getWidestNegativePrefix SB: positive mapping, returning null");
        return null;
    }
    if (LOG.isTraceEnabled()) {
        LOG.trace("getWidestNegativePrefix SB: {}", LispAddressStringifier.getString(sbPrefix));
    }
    // since prefixes overlap, just return the more specific (larger mask)
    if (LispAddressUtil.getIpPrefixMask(nbPrefix) < LispAddressUtil.getIpPrefixMask(sbPrefix)) {
        return sbPrefix;
    } else {
        return nbPrefix;
    }
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)

Example 48 with Prefixes

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.operational.rev151009.bgp.neighbor.prefix.counters_state.Prefixes in project lispflowmapping by opendaylight.

the class MappingSystem method mergeNegativePrefixes.

/*
     * Merges adjacent negative prefixes and notifies their subscribers.
     */
private void mergeNegativePrefixes(Eid eid) {
    LOG.debug("Merging negative prefixes starting from EID {}", LispAddressStringifier.getString(eid));
    // If we delete nodes while we walk up the radix trie the algorithm will give incorrect results, because
    // removals rearrange relationships in the trie. So we save prefixes to be removed into a HashMap.
    Map<Eid, MappingData> mergedMappings = new HashMap<>();
    Eid currentNode = smc.getSiblingPrefix(eid);
    MappingData mapping = (MappingData) smc.getMapping(null, currentNode);
    if (mapping != null && mapping.isNegative().or(false)) {
        mergedMappings.put(currentNode, mapping);
    } else {
        return;
    }
    Eid previousNode = currentNode;
    currentNode = smc.getVirtualParentSiblingPrefix(currentNode);
    while (currentNode != null) {
        mapping = (MappingData) smc.getMapping(null, currentNode);
        if (mapping != null && mapping.isNegative().or(false)) {
            mergedMappings.put(currentNode, mapping);
        } else {
            break;
        }
        previousNode = currentNode;
        currentNode = smc.getVirtualParentSiblingPrefix(previousNode);
    }
    for (Eid key : mergedMappings.keySet()) {
        removeSbMapping(key, mergedMappings.get(key));
    }
    smc.removeMapping(eid);
    addNegativeMapping(getVirtualParent(previousNode));
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData)

Example 49 with Prefixes

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.operational.rev151009.bgp.neighbor.prefix.counters_state.Prefixes in project lispflowmapping by opendaylight.

the class MappingMergeUtil method computeNbSbIntersection.

private static MappingRecord computeNbSbIntersection(MappingRecord nbMapping, MappingRecord sbMapping) {
    // returns a MappingRecord which has the more specific EID, and intersection of locator records.
    // If locators intersection is empty, original NB mapping is returned.
    // The intersection is only computed for mappings with maskable EIDs.
    // Supports both maskable and non-maskable EIDs
    MappingRecordBuilder mrb = new MappingRecordBuilder(nbMapping);
    if (MaskUtil.isMaskable(sbMapping.getEid().getAddress()) && MaskUtil.isMaskable(nbMapping.getEid().getAddress())) {
        short sbMask = MaskUtil.getMaskForAddress(sbMapping.getEid().getAddress());
        short nbMask = MaskUtil.getMaskForAddress(nbMapping.getEid().getAddress());
        if (nbMapping.getEid().getAddress() instanceof org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey) {
            nbMask = SourceDestKeyHelper.getDstMask(nbMapping.getEid());
            if (nbMask < sbMask) {
                // We have to create a new SourceDest EID, where the source is same as the
                // one in NB record, and dest EID is the more specific from SB mapping record.
                SourceDestKey srcDstKey = ((org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey) nbMapping.getEid().getAddress()).getSourceDestKey();
                SourceDestKeyBuilder sdb = new SourceDestKeyBuilder(srcDstKey);
                sdb.setDest(new SimpleAddress(getIpPrefix(sbMapping.getEid().getAddress())));
                mrb.setEid(LispAddressUtil.asSrcDstEid(sdb.build(), nbMapping.getEid().getVirtualNetworkId()));
            }
        } else if (nbMask < sbMask) {
            // Both EIDs are IP prefixes. SB mapping is a subprefix so we have to update EID intersection
            mrb.setEid(sbMapping.getEid());
        }
    }
    // find and update locators intersection if not empty
    List<LocatorRecord> commonLocators = getCommonLocatorRecords(nbMapping, sbMapping);
    if (commonLocators != null && !commonLocators.isEmpty()) {
        mrb.setLocatorRecord(commonLocators);
    }
    return mrb.build();
}
Also used : SourceDestKeyBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKeyBuilder) Preconditions(com.google.common.base.Preconditions) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord) SourceDestKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKey) SimpleAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)

Aggregations

ArrayList (java.util.ArrayList)21 Prefixes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes)14 BigInteger (java.math.BigInteger)13 List (java.util.List)9 Routes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes)8 Logger (org.slf4j.Logger)8 LoggerFactory (org.slf4j.LoggerFactory)8 Collections (java.util.Collections)7 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)7 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)7 DestinationIpv4Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.ipv4.prefixes.DestinationIpv4Builder)7 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)7 Optional (com.google.common.base.Optional)6 Inject (javax.inject.Inject)6 Singleton (javax.inject.Singleton)6 Test (org.junit.Test)6 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)6 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)6 MDSALUtil (org.opendaylight.genius.mdsalutil.MDSALUtil)6 NwConstants (org.opendaylight.genius.mdsalutil.NwConstants)6