Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sysrepo union type leaf is wrong in SR_EV_ENABLED event #3475

Open
bozhiz opened this issue Dec 11, 2024 · 1 comment
Open

sysrepo union type leaf is wrong in SR_EV_ENABLED event #3475

bozhiz opened this issue Dec 11, 2024 · 1 comment
Labels
is:bug Bug description. status:completed From the developer perspective, the issue was solved (bug fixed, question answered,...)

Comments

@bozhiz
Copy link

bozhiz commented Dec 11, 2024

Issue:
the pbit default value is "any" in enum type. dei default value is "any" in enum type, but pbit is SR_STRING_T "any" in SR_EV_ENABLED.

I don't set such two nodes pbit/dei in my configuration.
In libyang 2.1.80, sysrepo 2.2.73, libnetconf2 2.1.34, netopeer2 2.1.62:
under SR_EV_ENABLED, SR_EV_UPDATE and SR_EV_CHANGE, the pbit/dei type is SR_ENUM_T, value is "any".

In libyang 3.4.2, sysrepo 2.11.7, libnetconf2 3.5.1, netopeer2 2.2.31:
under SR_EV_UPDATE and SR_EV_CHANGE, the pbit/dei type is SR_ENUM_T, value is "any".
under SR_EV_ENABLED, the pbit type is SR_STRING_T, value is "any"; the dei type is SR_ENUM_T, value is "any".
The pbit is SR_STRING_T is wrong here.

The YANG definition:
bbf-frame-classification@2022-03-01, it is imported by ietf-interfaces@2018-02-20

  grouping dot1q-tag-ranges-or-any {
    description
      "Grouping to allow configuration to identify an 802.1Q VLAN tag
       that matches any specific VLAN ID within a set of non
       overlapping VLAN ID ranges, or the 'any' value to match any
       VLAN ID.";
    container dot1q-tag {
      description
        "Identifies an 802.1Q VLAN tag with an explicit tag-type, an
         ordered list of VLAN ID ranges, or 'any' VLAN ID.";
      leaf tag-type {
        type union {
          type bbf-dot1qt:dot1q-tag-type;
          type bbf-dot1qt:ether-type;
          type bbf-dot1qt:ether-type-hex;
          type enumeration {
            enum any {
              description
                "Matches any tag type.";
            }
          }
        }
        mandatory true;
        description
          "VLAN tag type.";
      }
      leaf vlan-id {
        type union {
          type bbf-dot1qt:vlan-id-range;
          type enumeration {
            enum any {
              description
                "Matches any VLAN ID in the range 1 to 4094, or
                 matches priority tagged frames.";
            }
            enum priority-tagged {
              description
                "Priority-tagged frames are frames with a VLAN tag
                 present and that match VLAN ID 0.";
            }
          }
        }
        mandatory true;
        description
          "Allowed VLAN IDs.";
      }
      leaf pbit {
        type union {
          type bbf-dot1qt:pbit-list;
          type enumeration {
            enum any {
              description
                "Matches any p-bits value in the range of 0 to 7.";
            }
          }
        }
        default "any";
        description
          "Allowed p-bits values.";
      }
      leaf dei {
        type union {
          type bbf-dot1qt:dei;
          type enumeration {
            enum any {
              description
                "Matches any Drop Eligible Indicator (DEI) value,
                 i.e. value 0 or 1.";
            }
          }
        }
        default "any";
        description
          "Allowed DEI values.";
      }
    }
  }

The startup/running datastore dump by sysrepocfg:

                <dot1q-tag>                                                               
                  <tag-type xmlns:bbf-dot1qt="urn:bbf:yang:bbf-dot1q-types">bbf-dot1qt:c-vlan</tag-type>                                                                             
                  <vlan-id>450</vlan-id>                                                  
                </dot1q-tag>   
@bozhiz bozhiz changed the title sysrepo union type leaf in SR_SUBSCR_ENABLED event sysrepo union type leaf is wrong in SR_EV_ENABLED event Dec 11, 2024
michalvasko added a commit to CESNET/libyang that referenced this issue Dec 16, 2024
If skipped, the value may be stored as an incorrect
type, which is not expected.

Fixes sysrepo/sysrepo#3475
@michalvasko
Copy link
Collaborator

Right, union values need to be validated. If you update libyang and use its current devel branch, it should work.

@michalvasko michalvasko added is:bug Bug description. status:completed From the developer perspective, the issue was solved (bug fixed, question answered,...) labels Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
is:bug Bug description. status:completed From the developer perspective, the issue was solved (bug fixed, question answered,...)
Projects
None yet
Development

No branches or pull requests

2 participants