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());
}
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;
}
}
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));
}
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();
}
Aggregations