diff --git a/control-plane/p4RuntimeSerializer.cpp b/control-plane/p4RuntimeSerializer.cpp index e84dc4ef97b..613d5b5d5f0 100644 --- a/control-plane/p4RuntimeSerializer.cpp +++ b/control-plane/p4RuntimeSerializer.cpp @@ -71,6 +71,14 @@ static bool isMetadataType(const IR::Type* type) { return metadataAnnotation != nullptr; } +/// @return true if @node has an @hidden annotation. +static bool isHidden(const IR::Node* node) { + if (!node->is()) return false; + auto annotations = node->to()->getAnnotations(); + auto hiddenAnnotation = annotations->getSingle("hidden"); + return hiddenAnnotation != nullptr; +} + /// @return a version of @name which has been sanitized for exposure to the /// control plane. static cstring controlPlaneName(const cstring& name) { @@ -891,6 +899,8 @@ class P4RuntimeSerializer { } void addAction(const IR::P4Action* actionDeclaration) { + if (isHidden(actionDeclaration)) return; + auto name = controlPlaneName(actionDeclaration); auto id = symbols.getId(P4RuntimeSymbolType::ACTION, name); auto annotations = actionDeclaration->to(); @@ -954,6 +964,8 @@ class P4RuntimeSerializer { const std::vector& actions, const std::vector& matchFields, bool supportsTimeout) { + if (isHidden(tableDeclaration)) return; + auto name = controlPlaneName(tableDeclaration); auto annotations = tableDeclaration->to();