public icon indicating copy to clipboard operation
public copied to clipboard

Introduce user-counters

Open dplore opened this issue 1 month ago • 1 comments

Change Scope

  • Introduce a new top level container for configuring user defined counters.
  • This change is backwards compatible.

Platform Implementations

Arista EOS and Juniper JunOS each have packet counter actions for their traffic-policy and filter based forwarding.

Arista EOS traffic policies

traffic-policies
  traffic-policy send-v6-to-my_nhg
    match v6-dscp3 ipv6
         dscp 3
         !
         actions
            count
            redirect next-hop group v6_my_nhg

JunOS filter based forwarding

      match my-af3-traffic ipv4
         source prefix field-set src-af3-prefixes
         destination prefix field-set dst-af3-prefixes
         actions
            count ip-af3-queue
            set dscp 24
            set traffic class 3
            redirect next-hop group ingress-vip
         !

See #1371 for additional implementation references and example operational use cases.

The CLI semantics are different in that action to perform a count and the user named counter are both created with a single line of CLI. In OC, we need a way to create the counter and stream the state of the counter. A new top level model is introduced to allow user-defined counters to potentially be reused across other features in the future.

Tree View

+module: openconfig-user-counters
+  +--rw user-counters
+     +--rw user-counter* [name]
+        +--rw name      -> ../config/name
+        +--rw config
+        |  +--rw name?   string
+        +--ro state
+           +--ro name?       string
+           +--ro counters
+              +--ro value?   oc-yang:counter64
+


module: openconfig-network-instance
  +--rw network-instances
     +--rw network-instance* [name]
         +--rw policy-forwarding
         |  +--rw policies
         |  |  +--rw policy* [policy-id]
         |  |     +--rw rules
         |  |        +--rw rule* [sequence-id]
         |  |           +--rw action
         |  |           |  +--rw config
+        |  |           |  |  +--rw count?                             -> /oc-uc:user-counters/user-counter/config/name
         |  |           |  |  +--rw discard?                           boolean
         |  |           |  |  +--rw decapsulate-gre?                   boolean
         |  |           |  |  +--rw decap-network-instance?            -> /network-instances/network-instance/config/name
         |  |           |  |  +--rw decap-fallback-network-instance?   -> /network-instances/network-instance/config/name
         |  |           |  |  +--rw post-decap-network-instance?       -> /network-instances/network-instance/config/name
         |  |           |  |  +--rw network-instance?                  -> /network-instances/network-instance/config/name
         |  |           |  |  +--rw path-selection-group?              -> ../../../../../../../path-selection-groups/path-selection-group/config/group-id
         |  |           |  |  +--rw next-hop?                          oc-inet:ip-address
         |  |           |  |  +--rw next-hop-group?                    -> ../../../../../../../../static/next-hop-groups/next-hop-group/config/name
         |  |           |  |  +--rw decapsulate-mpls-in-udp?           boolean
         |  |           |  |  +--rw decapsulate-gue?                   boolean
         |  |           |  |  +--rw ip-ttl?                            uint8
         |  |           |  +--ro state
+        |  |           |  |  +--ro count?                             -> /oc-uc:user-counters/user-counter/config/name
         |  |           |  |  +--ro discard?                           boolean
         |  |           |  |  +--ro decapsulate-gre?                   boolean
         |  |           |  |  +--ro decap-network-instance?            -> /network-instances/network-instance/config/name
         |  |           |  |  +--ro decap-fallback-network-instance?   -> /network-instances/network-instance/config/name
         |  |           |  |  +--ro post-decap-network-instance?       -> /network-instances/network-instance/config/name
         |  |           |  |  +--ro network-instance?                  -> /network-instances/network-instance/config/name
         |  |           |  |  +--ro path-selection-group?              -> ../../../../../../../path-selection-groups/path-selection-group/config/group-id
         |  |           |  |  +--ro next-hop?                          oc-inet:ip-address
         |  |           |  |  +--ro next-hop-group?                    -> ../../../../../../../../static/next-hop-groups/next-hop-group/config/name
         |  |           |  |  +--ro decapsulate-mpls-in-udp?           boolean
         |  |           |  |  +--ro decapsulate-gue?                   boolean
         |  |           |  |  +--ro ip-ttl?                            uint8


dplore avatar Dec 16 '25 22:12 dplore

No major YANG version changes in commit c442f4062e2beb2e0777b4cae6ebdba05ac8ad6f

OpenConfigBot avatar Dec 16 '25 22:12 OpenConfigBot