From 6509e0875c394fa122e56bbaa93b2f11205d1d67 Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Wed, 20 Jul 2016 09:48:14 +0200 Subject: HONEYCOMB-118: extend classifer model to support node names. * configuration write is supported (updates local cache with relative node mapping) * operational read is supported only for nodes with existing relative node mapping * ACL support (using vpp-classfier or ietf-acl model) is not affected by the patch (tables/sessions for access controll refer to neighbour nodes as packet-handling-action, not vpp-node-name) Change-Id: Ice0c846803cc7e8960c3571fd2a13ed46ba53702 Signed-off-by: Marek Gradzki --- .../v3po/vppclassifier/ClassifySessionReader.java | 33 +++++++++++++--------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionReader.java') diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionReader.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionReader.java index 590a502fd..143cd00da 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionReader.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionReader.java @@ -23,11 +23,11 @@ import static io.fd.honeycomb.translate.v3po.interfacesstate.InterfaceUtils.prin import com.google.common.base.Optional; import com.google.common.primitives.UnsignedInts; +import io.fd.honeycomb.translate.MappingContext; import io.fd.honeycomb.translate.read.ReadContext; +import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer; import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer; -import io.fd.honeycomb.translate.read.ReadFailedException; -import io.fd.honeycomb.translate.v3po.util.NamingContext; import io.fd.honeycomb.translate.v3po.util.TranslateUtils; import java.util.Arrays; import java.util.Collections; @@ -66,10 +66,10 @@ public class ClassifySessionReader extends FutureJVppCustomizer private static final Logger LOG = LoggerFactory.getLogger(ClassifySessionReader.class); static final String CACHE_KEY = ClassifySessionReader.class.getName(); - private final NamingContext classifyTableContext; + private final VppClassifierContextManager classifyTableContext; public ClassifySessionReader(@Nonnull final FutureJVppCore futureJVppCore, - @Nonnull final NamingContext classifyTableContext) { + @Nonnull final VppClassifierContextManager classifyTableContext) { super(futureJVppCore); this.classifyTableContext = checkNotNull(classifyTableContext, "classifyTableContext should not be null"); } @@ -102,10 +102,11 @@ public class ClassifySessionReader extends FutureJVppCustomizer if (classifySession.isPresent()) { final ClassifySessionDetails detail = classifySession.get(); - builder.setHitNext(readVppNode(detail.hitNextIndex, LOG)); + builder.setHitNext( + readVppNode(detail.tableId, detail.hitNextIndex, classifyTableContext, ctx.getMappingContext(), LOG).get()); if (detail.opaqueIndex != ~0) { // value is specified: - builder.setOpaqueIndex(readOpaqueIndex(detail.opaqueIndex)); + builder.setOpaqueIndex(readOpaqueIndex(detail.tableId, detail.opaqueIndex, ctx.getMappingContext())); } builder.setAdvance(detail.advance); builder.setMatch(key.getMatch()); @@ -116,13 +117,14 @@ public class ClassifySessionReader extends FutureJVppCustomizer } } - private OpaqueIndex readOpaqueIndex(final int opaqueIndex) { + private OpaqueIndex readOpaqueIndex(final int tableIndex, final int opaqueIndex, final MappingContext ctx) { // We first try to map the value to a vpp node, if that fails, simply wrap the u32 value // FIXME: the approach might fail if the opaqueIndex contains small value that collides // with some of the adjacent nodes - final VppNode node = readVppNode(opaqueIndex, LOG); - if (node != null) { - return new OpaqueIndex(node); + + final Optional node = readVppNode(tableIndex, opaqueIndex, classifyTableContext, ctx, LOG); + if (node.isPresent()) { + return new OpaqueIndex(node.get()); } else { return new OpaqueIndex(UnsignedInts.toLong(opaqueIndex)); } @@ -145,10 +147,10 @@ public class ClassifySessionReader extends FutureJVppCustomizer } final String tableName = tableKey.getName(); - checkState(classifyTableContext.containsIndex(tableName, ctx.getMappingContext()), + checkState(classifyTableContext.containsTable(tableName, ctx.getMappingContext()), "Reading classify sessions for table {}, but table index could not be found in the classify table context", tableName); - final int tableId = classifyTableContext.getIndex(tableName, ctx.getMappingContext()); + final int tableId = classifyTableContext.getTableIndex(tableName, ctx.getMappingContext()); LOG.debug("Dumping classify sessions for classify table id={}", tableId); try { @@ -157,8 +159,11 @@ public class ClassifySessionReader extends FutureJVppCustomizer classifySessionDump = TranslateUtils .getReplyForRead(getFutureJVpp().classifySessionDump(dumpRequest).toCompletableFuture(), id); - // update the cache: - ctx.getModificationCache().put(cacheKey, classifySessionDump); + if (classifySessionDump != null) { + // update the cache: + ctx.getModificationCache().put(cacheKey, classifySessionDump); + } + return classifySessionDump; } catch (VppBaseCallException e) { throw new ReadFailedException(id, e); -- cgit 1.2.3-korg