diff options
author | Jan Srnicek <jsrnicek@cisco.com> | 2017-05-16 12:48:47 +0200 |
---|---|---|
committer | Marek Gradzki <mgradzki@cisco.com> | 2017-05-18 09:32:02 +0000 |
commit | f1189488bce92471d6e5e5a666befa2340bd20ae (patch) | |
tree | 020200cab38d98cec1dd6f45db018b6bca44efe0 /lisp/lisp2vpp/src/main/java/io/fd | |
parent | b4b8fba02e15dd061f0bc05fb87f121980893ca1 (diff) |
HC2VPP-90 - Ipv4/Ipv6 prefix based eid's support
- adds full support for prefix based eid's ,both in
non-normalized and normalized form
Change-Id: I22451d20e0f9b540da447c8f120b917e0b30a6b7
Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
Diffstat (limited to 'lisp/lisp2vpp/src/main/java/io/fd')
11 files changed, 338 insertions, 79 deletions
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/context/util/EidMappingContext.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/context/util/EidMappingContext.java index 5288a609d..9cb489940 100644 --- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/context/util/EidMappingContext.java +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/context/util/EidMappingContext.java @@ -188,13 +188,13 @@ public class EidMappingContext implements EidTranslator { private Eid copyEid( org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.dp.subtable.grouping.local.mappings.local.mapping.Eid eid) { - return new EidBuilder().setAddress(eid.getAddress()).setAddressType(eid.getAddressType()) + return new EidBuilder().setAddress(normalizeIfPrefixBased(eid.getAddress())).setAddressType(eid.getAddressType()) .setVirtualNetworkId(eid.getVirtualNetworkId()).build(); } private Eid copyEid( org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.dp.subtable.grouping.remote.mappings.remote.mapping.Eid eid) { - return new EidBuilder().setAddress(eid.getAddress()).setAddressType(eid.getAddressType()) + return new EidBuilder().setAddress(normalizeIfPrefixBased(eid.getAddress())).setAddressType(eid.getAddressType()) .setVirtualNetworkId(eid.getVirtualNetworkId()).build(); } diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/AdjacencyCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/AdjacencyCustomizer.java index 72ed941f5..afbe2f3bf 100755 --- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/AdjacencyCustomizer.java +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/AdjacencyCustomizer.java @@ -145,9 +145,11 @@ public class AdjacencyCustomizer extends FutureJVppCustomizer builder.setId(currentAdjacencyId) .setKey(new AdjacencyKey(currentAdjacencyId)) .setLocalEid(getArrayAsLocalEid( - MappingsDumpParams.EidType.valueOf(currentAdjacency.eidType), currentAdjacency.leid, vni)) + MappingsDumpParams.EidType.valueOf(currentAdjacency.eidType), currentAdjacency.leid, + currentAdjacency.leidPrefixLen, vni)) .setRemoteEid(getArrayAsRemoteEid( - MappingsDumpParams.EidType.valueOf(currentAdjacency.eidType), currentAdjacency.reid, vni)); + MappingsDumpParams.EidType.valueOf(currentAdjacency.eidType), currentAdjacency.reid, + currentAdjacency.reidPrefixLen, vni)); } private EntityDumpExecutor<OneAdjacenciesGetReply, AdjacencyDumpParams> createExecutor() { @@ -199,9 +201,11 @@ public class AdjacencyCustomizer extends FutureJVppCustomizer final MappingContext mappingContext) { return new EidIdentificatorPairBuilder() .setLocalEidId(new MappingId(localMappingContext.getId(getArrayAsEidLocal( - MappingsDumpParams.EidType.valueOf(data.eidType), data.leid, vni), mappingContext))) + MappingsDumpParams.EidType.valueOf(data.eidType), data.leid, data.leidPrefixLen, vni), + mappingContext))) .setRemoteEidId(new MappingId(remoteMappingContext.getId(getArrayAsEidLocal( - MappingsDumpParams.EidType.valueOf(data.eidType), data.reid, vni), mappingContext))) + MappingsDumpParams.EidType.valueOf(data.eidType), data.reid, data.reidPrefixLen, vni), + mappingContext))) .build(); } } diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/LocalMappingCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/LocalMappingCustomizer.java index ff71d9c00..81409296d 100755 --- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/LocalMappingCustomizer.java +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/LocalMappingCustomizer.java @@ -105,7 +105,6 @@ public class LocalMappingCustomizer final long vni = id.firstKeyOf(VniTable.class).getVirtualNetworkIdentifier(); - final String localMappingId = id.firstKeyOf(LocalMapping.class).getId().getValue(); final Eid eid = localMappingContext.getEid(mappingId, ctx.getMappingContext()); //Requesting for specific mapping dump,only from local mappings with specified eid/vni/eid type @@ -135,7 +134,7 @@ public class LocalMappingCustomizer "No Locator Set name found for index %s", details.locatorSetIndex); builder.setLocatorSet(locatorSetContext.getName(details.locatorSetIndex, ctx.getMappingContext())); builder.setKey(new LocalMappingKey(new MappingId(id.firstKeyOf(LocalMapping.class).getId()))); - builder.setEid(getArrayAsEidLocal(valueOf(details.eidType), details.eid, details.vni)); + builder.setEid(getArrayAsEidLocal(valueOf(details.eidType), details.eid, details.eidPrefixLen, details.vni)); if (details.key != null) { builder.setHmacKey( @@ -149,7 +148,7 @@ public class LocalMappingCustomizer } private Address getAddressFromDumpDetail(final OneEidTableDetails detail) { - return getArrayAsEidLocal(valueOf(detail.eidType), detail.eid, detail.vni).getAddress(); + return getArrayAsEidLocal(valueOf(detail.eidType), detail.eid, detail.eidPrefixLen, detail.vni).getAddress(); } @Override @@ -184,7 +183,7 @@ public class LocalMappingCustomizer return replyOptional.get().oneEidTableDetails.stream() .filter(a -> a.vni == vni) .filter(subtableFilterForLocalMappings(id)) - .map(detail -> getArrayAsEidLocal(valueOf(detail.eidType), detail.eid, detail.vni)) + .map(detail -> getArrayAsEidLocal(valueOf(detail.eidType), detail.eid, detail.eidPrefixLen, detail.vni)) .map(localEid -> localMappingContext.getId(localEid, context.getMappingContext())) .map(MappingId::new) .map(LocalMappingKey::new) diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/RemoteMappingCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/RemoteMappingCustomizer.java index 2ba9eb831..04b89a59f 100755 --- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/RemoteMappingCustomizer.java +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/RemoteMappingCustomizer.java @@ -148,7 +148,6 @@ public class RemoteMappingCustomizer extends FutureJVppCustomizer "No mapping stored for id %s", mappingId); final long vni = id.firstKeyOf(VniTable.class).getVirtualNetworkIdentifier(); - final String remoteMappingId = id.firstKeyOf(RemoteMapping.class).getId().getValue(); final Eid eid = copyEid(remoteMappingContext.getEid(mappingId, ctx.getMappingContext())); final MappingsDumpParams dumpParams = new MappingsDumpParamsBuilder() .setVni(Long.valueOf(vni).intValue()) @@ -172,11 +171,11 @@ public class RemoteMappingCustomizer extends FutureJVppCustomizer OneEidTableDetails details = replyOptional.get().oneEidTableDetails.stream() .filter(subtableFilterForRemoteMappings(id)) .filter(a -> compareAddresses(eid.getAddress(), - getArrayAsEidLocal(valueOf(a.eidType), a.eid, a.vni).getAddress())) + getArrayAsEidLocal(valueOf(a.eidType), a.eid, a.eidPrefixLen, a.vni).getAddress())) .collect( RWUtils.singleItemCollector()); - builder.setEid(getArrayAsEidRemote(valueOf(details.eidType), details.eid, details.vni)); + builder.setEid(getArrayAsEidRemote(valueOf(details.eidType), details.eid, details.eidPrefixLen, details.vni)); builder.setKey(new RemoteMappingKey(new MappingId(id.firstKeyOf(RemoteMapping.class).getId()))); builder.setTtl(resolveTtl(details.ttl)); builder.setAuthoritative( @@ -217,7 +216,7 @@ public class RemoteMappingCustomizer extends FutureJVppCustomizer .stream() .filter(a -> a.vni == vni) .filter(subtableFilterForRemoteMappings(id)) - .map(detail -> getArrayAsEidRemote(valueOf(detail.eidType), detail.eid, detail.vni)) + .map(detail -> getArrayAsEidRemote(valueOf(detail.eidType), detail.eid, detail.eidPrefixLen, detail.vni)) .map(remoteEid -> remoteMappingContext.getId(remoteEid, context.getMappingContext())) .map(MappingId::new) .map(RemoteMappingKey::new) diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/dump/executor/params/MappingsDumpParams.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/dump/executor/params/MappingsDumpParams.java index 6b422f503..3c440668d 100755 --- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/dump/executor/params/MappingsDumpParams.java +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/dump/executor/params/MappingsDumpParams.java @@ -16,7 +16,9 @@ package io.fd.hc2vpp.lisp.translate.read.dump.executor.params; +import com.google.common.collect.ImmutableMap; import java.util.Arrays; +import java.util.Map; /** * Parameters for executing dump of mappings @@ -82,15 +84,27 @@ public final class MappingsDumpParams { public enum EidType { IPV4(0), IPV6(1), - MAC(2); - + MAC(2), + IPV4_PREFIX(3), + IPV6_PREFIX(4); + + /** + * From vpp api perspective, ipv4 is the same as ipv4-prefix, it differs just in prefix value. + * Respectively for ipv6/ipv6-prefix + */ + private static final Map<EidType, Integer> VPP_EID_TYPE_REGISTER = ImmutableMap.of( + IPV4, 0, IPV6, 1, MAC, 2, IPV4_PREFIX, 0, IPV6_PREFIX, 1); + + /** + * This value should be use just for our logic, do not use it to bind vpp requests + */ private final int value; private EidType(final int value) { this.value = value; } - public static final EidType valueOf(int value) { + public static EidType valueOf(int value) { switch (value) { case 0: return IPV4; @@ -98,13 +112,17 @@ public final class MappingsDumpParams { return IPV6; case 2: return MAC; + case 3: + return IPV4_PREFIX; + case 4: + return IPV6_PREFIX; default: throw new IllegalArgumentException("Illegal value"); } } - public final int getValue() { - return this.value; + public final int getVppTypeBinding() { + return VPP_EID_TYPE_REGISTER.get(this); } } @@ -150,10 +168,6 @@ public final class MappingsDumpParams { private byte[] eid; private byte filter; - public static final MappingsDumpParamsBuilder newInstance() { - return new MappingsDumpParamsBuilder(); - } - public MappingsDumpParamsBuilder setEidSet(final QuantityType quantityType) { this.eidSet = (byte) quantityType.getValue(); return this; @@ -170,7 +184,7 @@ public final class MappingsDumpParams { } public MappingsDumpParamsBuilder setEidType(final EidType eidType) { - this.eidType = (byte) eidType.getValue(); + this.eidType = (byte) eidType.getVppTypeBinding(); return this; } diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/trait/MappingProducer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/trait/MappingProducer.java index c9694c7a6..bceae832e 100644 --- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/trait/MappingProducer.java +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/trait/MappingProducer.java @@ -16,10 +16,14 @@ package io.fd.hc2vpp.lisp.translate.read.trait; +import com.google.common.collect.ImmutableSet; import io.fd.honeycomb.translate.write.WriteFailedException; +import java.util.Set; import javax.annotation.Nonnull; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.Ipv4Afi; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.Ipv4PrefixAfi; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.Ipv6Afi; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.Ipv6PrefixAfi; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.LispAddressFamily; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.MacAfi; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.dp.subtable.grouping.local.mappings.LocalMapping; @@ -33,15 +37,21 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; */ public interface MappingProducer { + Set<Class<? extends LispAddressFamily>> VRF_ALLOWED_ADDRESS_TYPES = ImmutableSet.of( + Ipv4Afi.class, + Ipv6Afi.class, + Ipv4PrefixAfi.class, + Ipv6PrefixAfi.class); + /** - * Checks whether provided {@link LocalMapping} can be written under subtree idenfied by {@link InstanceIdentifier} + * Checks whether provided {@link LocalMapping} can be written under subtree identified by {@link InstanceIdentifier} */ default void checkAllowedCombination(@Nonnull final InstanceIdentifier<LocalMapping> identifier, @Nonnull final LocalMapping data) throws WriteFailedException { final Class<? extends LispAddressFamily> eidAddressType = data.getEid().getAddressType(); if (identifier.firstIdentifierOf(VrfSubtable.class) != null) { - if (Ipv4Afi.class != eidAddressType && Ipv6Afi.class != eidAddressType) { + if (!VRF_ALLOWED_ADDRESS_TYPES.contains(eidAddressType)) { throw new WriteFailedException.CreateFailedException(identifier, data, new IllegalArgumentException("Only Ipv4/Ipv6 eid's are allowed for Vrf Subtable")); } @@ -58,7 +68,7 @@ public interface MappingProducer { final Class<? extends LispAddressFamily> eidAddressType = data.getEid().getAddressType(); if (identifier.firstIdentifierOf(VrfSubtable.class) != null) { - if (Ipv4Afi.class != eidAddressType && Ipv6Afi.class != eidAddressType) { + if (!VRF_ALLOWED_ADDRESS_TYPES.contains(eidAddressType)) { throw new WriteFailedException.CreateFailedException(identifier, data, new IllegalArgumentException("Only Ipv4/Ipv6 eid's are allowed for Vrf Subtable")); } diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/trait/MappingReader.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/trait/MappingReader.java index bad719d01..993a6451c 100644 --- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/trait/MappingReader.java +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/trait/MappingReader.java @@ -37,15 +37,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; /** - * Trait providing predicates to filter mappings to respective subtables + * Trait providing predicates to filter mappings to respective sub-tables */ public interface MappingReader extends JvppReplyConsumer { Predicate<OneEidTableDetails> BRIDGE_DOMAIN_MAPPINGS_ONLY = - (OneEidTableDetails detail) -> detail.eidType == MAC.getValue(); + (OneEidTableDetails detail) -> detail.eidType == MAC.getVppTypeBinding(); Predicate<OneEidTableDetails> VRF_MAPPINGS_ONLY = - (OneEidTableDetails detail) -> detail.eidType == IPV4.getValue() || detail.eidType == IPV6.getValue(); + (OneEidTableDetails detail) -> detail.eidType == IPV4.getVppTypeBinding() || detail.eidType == IPV6.getVppTypeBinding(); default Predicate<OneEidTableDetails> subtableFilterForLocalMappings( @Nonnull final InstanceIdentifier<LocalMapping> identifier) { diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/util/EidTranslator.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/util/EidTranslator.java index 2c65c0c8f..deae3f5f6 100755 --- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/util/EidTranslator.java +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/util/EidTranslator.java @@ -16,40 +16,59 @@ package io.fd.hc2vpp.lisp.translate.util; +import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static io.fd.hc2vpp.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType; import static io.fd.hc2vpp.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.IPV4; +import static io.fd.hc2vpp.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.IPV4_PREFIX; import static io.fd.hc2vpp.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.IPV6; +import static io.fd.hc2vpp.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.IPV6_PREFIX; import static io.fd.hc2vpp.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.MAC; +import static java.lang.Integer.parseInt; +import static java.lang.String.format; +import inet.ipaddr.IPAddress; import io.fd.hc2vpp.common.translate.util.AddressTranslator; +import java.net.InetAddress; +import java.net.UnknownHostException; import java.util.Arrays; import javax.annotation.Nonnull; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6AddressNoZone; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.Ipv4Afi; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.Ipv4PrefixAfi; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.Ipv6Afi; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.Ipv6PrefixAfi; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.LispAddress; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.MacAfi; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Builder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4PrefixBuilder; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Builder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Prefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6PrefixBuilder; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Mac; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.MacBuilder; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.adjacencies.grouping.adjacencies.adjacency.LocalEid; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.adjacencies.grouping.adjacencies.adjacency.RemoteEid; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.dp.subtable.grouping.local.mappings.local.mapping.Eid; +import org.slf4j.Logger; /** * Trait providing converting logic for eid's */ +// TODO - HC2VPP-149 - restructuralize code public interface EidTranslator extends AddressTranslator, EidMetadataProvider { + byte DEFAULT_V4_PREFIX = 32; + byte DEFAULT_V6_PREFIX = (byte) 128; + default byte getPrefixLength(LocalEid address) { return resolverPrefixLength(address.getAddress()); } @@ -77,57 +96,103 @@ public interface EidTranslator extends AddressTranslator, EidMetadataProvider { switch (resolveType(address)) { case IPV4: - return 32; + return DEFAULT_V4_PREFIX; case IPV6: - return (byte) 128; + return DEFAULT_V6_PREFIX; case MAC: return 0; + case IPV4_PREFIX: + return extractPrefix(Ipv4Prefix.class.cast(address).getIpv4Prefix().getValue()); + case IPV6_PREFIX: + return extractPrefix(Ipv6Prefix.class.cast(address).getIpv6Prefix().getValue()); default: throw new IllegalArgumentException("Illegal type"); } } - default Eid getArrayAsEidLocal(@Nonnull final EidType type, final byte[] address, final int vni) { + static byte extractPrefix(final String data) { + return Byte.valueOf(data.substring(data.indexOf('/') + 1)); + } + + default Eid getArrayAsEidLocal(@Nonnull final EidType type, final byte[] address, final byte prefix, + final int vni) { switch (type) { case IPV4: { - return newLocalEidBuilder(Ipv4Afi.class, vni).setAddress( - new Ipv4Builder().setIpv4(arrayToIpv4AddressNoZone(address)).build()) - .build(); + // vpp does no have separate constant for prefix based ,so if prefix is different than + // default, map it to prefix type. Same in any other logic switched by eid type + return prefix != DEFAULT_V4_PREFIX + ? newLocalEidBuilder(Ipv4PrefixAfi.class, vni).setAddress( + new Ipv4PrefixBuilder().setIpv4Prefix(v4Prefix(address, prefix)).build()).build() + : newLocalEidBuilder(Ipv4Afi.class, vni).setAddress( + new Ipv4Builder().setIpv4(arrayToIpv4AddressNoZone(address)).build()) + .build(); } case IPV6: { - return newLocalEidBuilder(Ipv6Afi.class, vni).setAddress( - new Ipv6Builder().setIpv6(arrayToIpv6AddressNoZone(address)).build()) - .build(); + return prefix != DEFAULT_V6_PREFIX + ? newLocalEidBuilder(Ipv6PrefixAfi.class, vni).setAddress( + new Ipv6PrefixBuilder().setIpv6Prefix(v6Prefix(address, prefix)).build()).build() + : newLocalEidBuilder(Ipv6Afi.class, vni).setAddress( + new Ipv6Builder().setIpv6(arrayToIpv6AddressNoZone(address)).build()) + .build(); } case MAC: { return newLocalEidBuilder(MacAfi.class, vni).setAddress( new MacBuilder().setMac(new MacAddress(byteArrayToMacSeparated(address))) .build()).build(); } + case IPV4_PREFIX: { + return newLocalEidBuilder(Ipv4PrefixAfi.class, vni).setAddress( + new Ipv4PrefixBuilder().setIpv4Prefix(v4Prefix(address, prefix)).build()).build(); + } + case IPV6_PREFIX: { + return newLocalEidBuilder(Ipv6PrefixAfi.class, vni).setAddress( + new Ipv6PrefixBuilder().setIpv6Prefix(v6Prefix(address, prefix)).build()).build(); + } default: { throw new IllegalStateException("Unknown type detected"); } } } + static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix v4Prefix( + final byte[] address, final byte prefix) { + return new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix( + prefixValue(INSTANCE.arrayToIpv4AddressNoZone(address).getValue(), String.valueOf(prefix))); + } + + static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix v6Prefix( + final byte[] address, final byte prefix) { + return new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix( + prefixValue(INSTANCE.arrayToIpv6AddressNoZone(address).getValue(), String.valueOf(prefix))); + } + + static String prefixValue(final String prefix, final String suffix) { + // normalize prefix based address to prevent duplicates + IPAddress normalizedForm = IPAddress.from(getAddress(prefix)).toSubnet(parseInt(suffix)); + + return normalizedForm.toCompressedString(); + } + default org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.dp.subtable.grouping.remote.mappings.remote.mapping.Eid getArrayAsEidRemote( - @Nonnull final EidType type, final byte[] address, final int vni) { + @Nonnull final EidType type, final byte[] address, final byte prefix, final int vni) { switch (type) { case IPV4: { - return newRemoteEidBuilder(Ipv4Afi.class, vni) - .setAddress( - new Ipv4Builder().setIpv4(arrayToIpv4AddressNoZone(address)) - .build()) - .build(); + return prefix != DEFAULT_V4_PREFIX + ? newRemoteEidBuilder(Ipv4PrefixAfi.class, vni).setAddress( + new Ipv4PrefixBuilder().setIpv4Prefix(v4Prefix(address, prefix)).build()).build() + : newRemoteEidBuilder(Ipv4Afi.class, vni) + .setAddress(new Ipv4Builder().setIpv4(arrayToIpv4AddressNoZone(address)).build()) + .build(); } case IPV6: { - return newRemoteEidBuilder(Ipv6Afi.class, vni) - .setAddress( - new Ipv6Builder().setIpv6(arrayToIpv6AddressNoZone(address)) - .build()) - .build(); + return prefix != DEFAULT_V6_PREFIX + ? newRemoteEidBuilder(Ipv6PrefixAfi.class, vni).setAddress( + new Ipv6PrefixBuilder().setIpv6Prefix(v6Prefix(address, prefix)).build()).build() + : newRemoteEidBuilder(Ipv6Afi.class, vni) + .setAddress(new Ipv6Builder().setIpv6(arrayToIpv6AddressNoZone(address)).build()) + .build(); } case MAC: { return newRemoteEidBuilder(MacAfi.class, vni) @@ -135,15 +200,28 @@ public interface EidTranslator extends AddressTranslator, EidMetadataProvider { new MacBuilder().setMac(new MacAddress(byteArrayToMacSeparated(address))) .build()).build(); } + case IPV4_PREFIX: { + return newRemoteEidBuilder(Ipv4PrefixAfi.class, vni).setAddress( + new Ipv4PrefixBuilder().setIpv4Prefix(v4Prefix(address, prefix)).build()).build(); + } + case IPV6_PREFIX: { + return newRemoteEidBuilder(Ipv6PrefixAfi.class, vni).setAddress( + new Ipv6PrefixBuilder().setIpv6Prefix(v6Prefix(address, prefix)).build()).build(); + } default: { throw new IllegalStateException("Unknown type detected"); } } } - default LocalEid getArrayAsLocalEid(@Nonnull final EidType type, final byte[] address, final int vni) { + default LocalEid getArrayAsLocalEid(@Nonnull final EidType type, final byte[] address, final byte prefix, + final int vni) { switch (type) { case IPV4: { + if (prefix != DEFAULT_V4_PREFIX) { + return newEidBuilderLocal(Ipv4PrefixAfi.class, vni).setAddress( + new Ipv4PrefixBuilder().setIpv4Prefix(v4Prefix(address, prefix)).build()).build(); + } return newEidBuilderLocal(Ipv4Afi.class, vni) .setAddress( new Ipv4Builder().setIpv4(arrayToIpv4AddressNoZone(address)) @@ -151,6 +229,10 @@ public interface EidTranslator extends AddressTranslator, EidMetadataProvider { .build(); } case IPV6: { + if (prefix != DEFAULT_V6_PREFIX) { + return newEidBuilderLocal(Ipv6PrefixAfi.class, vni).setAddress( + new Ipv6PrefixBuilder().setIpv6Prefix(v6Prefix(address, prefix)).build()).build(); + } return newEidBuilderLocal(Ipv6Afi.class, vni) .setAddress( new Ipv6Builder().setIpv6(arrayToIpv6AddressNoZone(address)) @@ -163,27 +245,38 @@ public interface EidTranslator extends AddressTranslator, EidMetadataProvider { new MacBuilder().setMac(new MacAddress(byteArrayToMacSeparated(address))) .build()).build(); } + case IPV4_PREFIX: { + return newEidBuilderLocal(Ipv4PrefixAfi.class, vni).setAddress( + new Ipv4PrefixBuilder().setIpv4Prefix(v4Prefix(address, prefix)).build()).build(); + } + case IPV6_PREFIX: { + return newEidBuilderLocal(Ipv6PrefixAfi.class, vni).setAddress( + new Ipv6PrefixBuilder().setIpv6Prefix(v6Prefix(address, prefix)).build()).build(); + } default: { throw new IllegalStateException("Unknown type detected"); } } } - default RemoteEid getArrayAsRemoteEid(@Nonnull final EidType type, final byte[] address, final int vni) { + default RemoteEid getArrayAsRemoteEid(@Nonnull final EidType type, final byte[] address, final byte prefix, + final int vni) { switch (type) { case IPV4: { - return newEidBuilderRemote(Ipv4Afi.class, vni) - .setAddress( - new Ipv4Builder().setIpv4(arrayToIpv4AddressNoZone(address)) - .build()) - .build(); + return (prefix != DEFAULT_V4_PREFIX) + ? newEidBuilderRemote(Ipv4PrefixAfi.class, vni).setAddress( + new Ipv4PrefixBuilder().setIpv4Prefix(v4Prefix(address, prefix)).build()).build() + : newEidBuilderRemote(Ipv4Afi.class, vni) + .setAddress(new Ipv4Builder().setIpv4(arrayToIpv4AddressNoZone(address)).build()) + .build(); } case IPV6: { - return newEidBuilderRemote(Ipv6Afi.class, vni) - .setAddress( - new Ipv6Builder().setIpv6(arrayToIpv6AddressNoZone(address)) - .build()) - .build(); + return prefix != DEFAULT_V6_PREFIX + ? newEidBuilderRemote(Ipv6PrefixAfi.class, vni) + .setAddress(new Ipv6PrefixBuilder().setIpv6Prefix(v6Prefix(address, prefix)).build()).build() + : newEidBuilderRemote(Ipv6Afi.class, vni) + .setAddress(new Ipv6Builder().setIpv6(arrayToIpv6AddressNoZone(address)).build()) + .build(); } case MAC: { return newEidBuilderRemote(MacAfi.class, vni) @@ -191,25 +284,42 @@ public interface EidTranslator extends AddressTranslator, EidMetadataProvider { new MacBuilder().setMac(new MacAddress(byteArrayToMacSeparated(address))) .build()).build(); } + case IPV4_PREFIX: { + return newEidBuilderRemote(Ipv4PrefixAfi.class, vni).setAddress( + new Ipv4PrefixBuilder().setIpv4Prefix(v4Prefix(address, prefix)).build()).build(); + } + case IPV6_PREFIX: { + return newEidBuilderRemote(Ipv6PrefixAfi.class, vni).setAddress( + new Ipv6PrefixBuilder().setIpv6Prefix(v6Prefix(address, prefix)).build()).build(); + } default: { throw new IllegalStateException("Unknown type detected"); } } } - default String getArrayAsEidString( - EidType type, byte[] address) { + default String getArrayAsEidString(final EidType type, final byte[] address, final byte prefix) { switch (type) { case IPV4: { - return arrayToIpv4AddressNoZone(address).getValue(); + return prefix != DEFAULT_V4_PREFIX + ? v4Prefix(address, prefix).getValue() + : arrayToIpv4AddressNoZone(address).getValue(); } case IPV6: { - return arrayToIpv6AddressNoZone(address).getValue(); + return prefix != DEFAULT_V6_PREFIX + ? v6Prefix(address, prefix).getValue() + : arrayToIpv6AddressNoZone(address).getValue(); } case MAC: { //as wrong as it looks ,its right(second param is not end index,but count) return byteArrayToMacSeparated(Arrays.copyOfRange(address, 0, 6)); } + case IPV4_PREFIX: { + return v4Prefix(address, prefix).getValue(); + } + case IPV6_PREFIX: { + return v6Prefix(address, prefix).getValue(); + } default: { throw new IllegalStateException("Unknown type detected"); } @@ -261,6 +371,10 @@ public interface EidTranslator extends AddressTranslator, EidMetadataProvider { return IPV6; } else if (address instanceof Mac) { return MAC; + } else if (address instanceof Ipv4Prefix) { + return IPV4_PREFIX; + } else if (address instanceof Ipv6Prefix) { + return IPV6_PREFIX; } else { throw new IllegalStateException("Unknown type detected"); } @@ -308,11 +422,49 @@ public interface EidTranslator extends AddressTranslator, EidMetadataProvider { return ipv6AddressNoZoneToArray(new Ipv6AddressNoZone(((Ipv6) address).getIpv6())); case MAC: return parseMac(((Mac) address).getMac().getValue()); + case IPV4_PREFIX: + return ipv4AddressPrefixToArray(v4LispPrefixToInetPrefix(Ipv4Prefix.class.cast(address))); + case IPV6_PREFIX: + return ipv6AddressPrefixToArray(v6LispPrefixToInetPrefix(Ipv6Prefix.class.cast(address))); default: throw new IllegalArgumentException("Unsupported type"); } } + default Address normalizeIfPrefixBased(Address address){ + if(address instanceof Ipv4Prefix){ + final String[] parts = ((Ipv4Prefix) address).getIpv4Prefix().getValue().split("/"); + + return new Ipv4PrefixBuilder().setIpv4Prefix( + new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix( + prefixValue(parts[0], parts[1]))) + .build(); + } + + if (address instanceof Ipv6Prefix){ + final String[] parts = ((Ipv6Prefix) address).getIpv6Prefix().getValue().split("/"); + + return new Ipv6PrefixBuilder().setIpv6Prefix( + new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix( + prefixValue(parts[0], parts[1]))).build(); + } + + // if not prefix based, does nothing + return address; + } + + static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix v4LispPrefixToInetPrefix( + final Ipv4Prefix prefix) { + return new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix( + prefix.getIpv4Prefix().getValue()); + } + + static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix v6LispPrefixToInetPrefix( + final Ipv6Prefix prefix) { + return new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix( + prefix.getIpv6Prefix().getValue()); + } + default boolean compareEids( LispAddress first, LispAddress second) { @@ -338,6 +490,77 @@ public interface EidTranslator extends AddressTranslator, EidMetadataProvider { return ((Mac) firstAddress).getMac().getValue().equals(((Mac) secondAddress).getMac().getValue()); } + if (firstAddress instanceof Ipv4Prefix && secondAddress instanceof Ipv4Prefix) { + + final String firstPrefix = ((Ipv4Prefix) firstAddress).getIpv4Prefix().getValue(); + final String secondPrefix = ((Ipv4Prefix) secondAddress).getIpv4Prefix().getValue(); + + // for ex. 192.168.2.1/24 and 192.168.2.2/24 will be optimized to + // 192.168.2.0/24 + return isSameSubnet(firstPrefix, secondPrefix); + } + + if (firstAddress instanceof Ipv6Prefix && secondAddress instanceof Ipv6Prefix) { + final String firstPrefix = ((Ipv6Prefix) firstAddress).getIpv6Prefix().getValue(); + final String secondPrefix = ((Ipv6Prefix) secondAddress).getIpv6Prefix().getValue(); + + // same here + return isSameSubnet(firstPrefix, secondPrefix); + } + return false; } + + /** + * Configuration data store whatever value is put, so it can be non-normalized, but + * vpp optimize all eid prefix based values, returns true if such case + */ + default void checkIgnoredSubnetUpdate(@Nonnull final Address dataBefore, + @Nonnull final Address dataAfter, + @Nonnull Logger logger) { + boolean isSameSubnet = false; + if (dataBefore instanceof Ipv4Prefix && dataAfter instanceof Ipv4Prefix) { + isSameSubnet = isSameSubnet(((Ipv4Prefix) dataBefore).getIpv4Prefix().getValue(), + ((Ipv4Prefix) dataAfter).getIpv4Prefix().getValue()); + } + + if (dataBefore instanceof Ipv6Prefix && dataAfter instanceof Ipv6Prefix) { + isSameSubnet = isSameSubnet(((Ipv6Prefix) dataBefore).getIpv6Prefix().getValue(), + ((Ipv6Prefix) dataAfter).getIpv6Prefix().getValue()); + } + + if (isSameSubnet) { + logger.warn("Attempt to update address within same subnet detected, ignoring[{} vs {}]", dataBefore, + dataAfter); + return; + } + + throw new UnsupportedOperationException("Operation not supported"); + } + + static boolean isSameSubnet(final String firstPrefix, final String secondPrefix) { + final String[] firstPrefixParts = getPrefixParts(firstPrefix); + final String[] secondPrefixParts = getPrefixParts(secondPrefix); + + IPAddress firstAddress = + IPAddress.from(getAddress(firstPrefixParts[0])).toSubnet(parseInt(firstPrefixParts[1])); + IPAddress secondAddress = + IPAddress.from(getAddress(secondPrefixParts[0])).toSubnet(parseInt(secondPrefixParts[1])); + + return firstAddress.compareTo(secondAddress) == 0; + } + + static String[] getPrefixParts(final String prefixString) { + final String[] split = prefixString.split("/"); + checkArgument(split.length == 2, "%s is not a valid ip prefix", prefixString); + return split; + } + + static InetAddress getAddress(final String value) { + try { + return InetAddress.getByName(value); + } catch (UnknownHostException e) { + throw new IllegalArgumentException(format("Unable to convert %s", value), e); + } + } } diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/AdjacencyCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/AdjacencyCustomizer.java index df5f431be..fc6de8653 100755 --- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/AdjacencyCustomizer.java +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/AdjacencyCustomizer.java @@ -41,11 +41,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.adjacencies.grouping.adjacencies.adjacency.RemoteEid; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.eid.table.grouping.eid.table.VniTable; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class AdjacencyCustomizer extends FutureJVppCustomizer implements ListWriterCustomizer<Adjacency, AdjacencyKey>, ByteDataTranslator, EidTranslator, JvppReplyConsumer { + private static final Logger LOG = LoggerFactory.getLogger(AdjacencyCustomizer.class); + private final EidMappingContext localEidsMappingContext; private final EidMappingContext remoteEidsMappingContext; private final AdjacenciesMappingContext adjacenciesMappingContext; @@ -97,7 +101,9 @@ public class AdjacencyCustomizer extends FutureJVppCustomizer public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<Adjacency> id, @Nonnull final Adjacency dataBefore, @Nonnull final Adjacency dataAfter, @Nonnull final WriteContext writeContext) throws WriteFailedException { - throw new UnsupportedOperationException("Operation not supported"); + // case that happens during initialization + checkIgnoredSubnetUpdate(dataBefore.getLocalEid().getAddress(), dataAfter.getLocalEid().getAddress(), LOG); + checkIgnoredSubnetUpdate(dataBefore.getRemoteEid().getAddress(), dataAfter.getRemoteEid().getAddress(), LOG); } @Override @@ -145,7 +151,7 @@ public class AdjacencyCustomizer extends FutureJVppCustomizer request.leidLen = getPrefixLength(localEid); request.reid = getEidAsByteArray(remoteEid); request.reidLen = getPrefixLength(remoteEid); - request.eidType = (byte) localEidType.getValue(); + request.eidType = (byte) localEidType.getVppTypeBinding(); request.vni = vni; getReply(getFutureJVpp().oneAddDelAdjacency(request).toCompletableFuture()); diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/LocalMappingCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/LocalMappingCustomizer.java index 582a37756..d3a03b298 100755 --- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/LocalMappingCustomizer.java +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/LocalMappingCustomizer.java @@ -18,8 +18,6 @@ package io.fd.hc2vpp.lisp.translate.write; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; -import static io.fd.hc2vpp.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.IPV4; -import static io.fd.hc2vpp.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.IPV6; import static java.nio.charset.StandardCharsets.UTF_8; import io.fd.hc2vpp.common.translate.util.ByteDataTranslator; @@ -44,6 +42,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.eid.table.grouping.eid.table.VniTable; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.hmac.key.grouping.HmacKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** @@ -53,6 +53,8 @@ public class LocalMappingCustomizer extends FutureJVppCustomizer implements ListWriterCustomizer<LocalMapping, LocalMappingKey>, ByteDataTranslator, EidTranslator, JvppReplyConsumer, MappingProducer { + private static final Logger LOG = LoggerFactory.getLogger(LocalMappingCustomizer.class); + private final EidMappingContext localMappingsContext; public LocalMappingCustomizer(@Nonnull FutureJVppCore futureJvpp, @Nonnull EidMappingContext localMappingsContext) { @@ -85,7 +87,8 @@ public class LocalMappingCustomizer extends FutureJVppCustomizer public void updateCurrentAttributes(InstanceIdentifier<LocalMapping> id, LocalMapping dataBefore, LocalMapping dataAfter, WriteContext writeContext) throws WriteFailedException { - throw new UnsupportedOperationException("Operation not supported"); + // case that happens during initialization + checkIgnoredSubnetUpdate(dataBefore.getEid().getAddress(), dataAfter.getEid().getAddress(), LOG); } @Override @@ -120,16 +123,12 @@ public class LocalMappingCustomizer extends FutureJVppCustomizer request.isAdd = booleanToByte(add); request.eid = getEidAsByteArray(data.getEid()); - request.eidType = (byte) getEidType(data.getEid()).getValue(); + request.eidType = (byte) getEidType(data.getEid()).getVppTypeBinding(); request.locatorSetName = data.getLocatorSet().getBytes(UTF_8); request.vni = vni; //default prefixes - if (request.eidType == IPV4.getValue()) { - request.prefixLen = 32; - } else if (request.eidType == IPV6.getValue()) { - request.prefixLen = (byte) 128; - } + request.prefixLen = getPrefixLength(data.getEid()); final HmacKey hmacKey = data.getHmacKey(); if (hmacKey != null) { diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/RemoteMappingCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/RemoteMappingCustomizer.java index 056dcde1d..f6774890b 100755 --- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/RemoteMappingCustomizer.java +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/RemoteMappingCustomizer.java @@ -51,6 +51,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.dp.subtable.grouping.remote.mappings.remote.mapping.locator.list.positive.mapping.Rlocs; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.eid.table.grouping.eid.table.VniTable; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** @@ -60,6 +62,8 @@ public class RemoteMappingCustomizer extends FutureJVppCustomizer implements ListWriterCustomizer<RemoteMapping, RemoteMappingKey>, EidTranslator, AddressTranslator, JvppReplyConsumer, MappingProducer { + private static final Logger LOG = LoggerFactory.getLogger(RemoteMappingCustomizer.class); + private final EidMappingContext remoteMappingContext; public RemoteMappingCustomizer(@Nonnull final FutureJVppCore futureJvpp, @@ -92,7 +96,8 @@ public class RemoteMappingCustomizer extends FutureJVppCustomizer public void updateCurrentAttributes(InstanceIdentifier<RemoteMapping> id, RemoteMapping dataBefore, RemoteMapping dataAfter, WriteContext writeContext) throws WriteFailedException { - throw new UnsupportedOperationException("Operation not supported"); + // case that happens during initialization + checkIgnoredSubnetUpdate(dataBefore.getEid().getAddress(), dataAfter.getEid().getAddress(), LOG); } @Override @@ -124,7 +129,7 @@ public class RemoteMappingCustomizer extends FutureJVppCustomizer request.isAdd = booleanToByte(add); request.vni = vni; - request.eidType = (byte) getEidType(data.getEid()).getValue(); + request.eidType = (byte) getEidType(data.getEid()).getVppTypeBinding(); request.eid = getEidAsByteArray(data.getEid()); //this is not length of eid array,but prefix length(bad naming by vpp) |