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

Adding feature to top level container doesn't work #322

Closed
shmuelnatan opened this issue Mar 31, 2022 · 7 comments
Closed

Adding feature to top level container doesn't work #322

shmuelnatan opened this issue Mar 31, 2022 · 7 comments

Comments

@shmuelnatan
Copy link
Contributor

Let's say I have the following two yang files (one has a feature and the other doesn't).

module module-foo {

    yang-version "1";

    // namespace
    namespace "http://foo/namespace";

    feature foo-feature;
    grouping foo-top {
        container foo-container {
            if-feature foo-feature;
            leaf foo-leaf {
                type string;
           }
       }
    }
    uses foo-top;
}
module module-boo {

    yang-version "1";

    // namespace
    namespace "http://boo/namespace";

    grouping boo-top {
        container boo-container {
            leaf boo-leaf {
                type string;
           }
       }
    }
    uses boo-top;
}

I do not add to my config file <CLICON_FEATURE>module-foo:feature-foo</CLICON_FEATURE>.
My database looks like this

<config>
   <module-boo xmlns="http://boo/namespace">
      <boo-leaf>boo</boo-leaf>
   </module-boo>
   <module-foo xmlns="http://foo/namespace"/>
</config>

I then want to bind the database with xmldb_put using OP_CREATE but this function fails due to an unknown element from the foo module. There is no binding done prior to using this function.
I think it's connected to the fact that the only info in the module is not enabled due to the feature that is not set.

P.S. We do not want to enable CLICON_YANG_UNKNOWN_ANYDATA to avoid problems in the future.

@olofhagsand
Copy link
Member

I think your db example is wrong. I think it is supposed to look like this?

<config>
   <boo-container xmlns="http://boo/namespace">
      <boo-leaf>boo</boo-leaf>
   </boo-container>
   <foo-container xmlns="http://foo/namespace"/>
</config>

Is that correct?

@olofhagsand
Copy link
Member

If so, I get the following error when loading that content as s startup-db:

olof@alarik> sudo clixon_backend -Ff /usr/local/etc/example.xml -s startup
Apr  1 12:43:36: clixon_backend: 598 
  <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
    <rpc-error>
      <error-type>application</error-type>
      <error-tag>unknown-element</error-tag>
      <error-info>
        <bad-element>foo-container</bad-element>
      </error-info>
      <error-severity>error</error-severity>
    <error-message>Failed to find YANG spec of XML node: foo-container with parent: config in namespace: urn:example:clixon</error-message>
  </rpc-error>
</rpc-reply>
Apr  1 12:43:36: startup_failsafe: 320: Database error: Startup failed and no Failsafe database found, exiting

@olofhagsand
Copy link
Member

This may be the same consequence that you pointed out with CREATE.
I am unsure what to do with this, it would be good to have some reference from RFC7950 on how to act here.
What would be your expected behavior?

@olofhagsand
Copy link
Member

olofhagsand commented Apr 1, 2022

Some info here: https://www.rfc-editor.org/rfc/rfc7950.html#section-7.20.1
Notably:

Schema nodes tagged with an "if-feature" statement are ignored by the server unless the server supports the given feature expression.

Which could indicate that clixon throwing an error is wrong, the presence should just be "ignored"

@shmuelnatan
Copy link
Contributor Author

I think your db example is wrong. I think it is supposed to look like this?

<config>
   <boo-container xmlns="http://boo/namespace">
      <boo-leaf>boo</boo-leaf>
   </boo-container>
   <foo-container xmlns="http://foo/namespace"/>
</config>

Is that correct?

This is correct. The expected behavior should be that foo-container should be ignored.

@olofhagsand
Copy link
Member

Changing to enhancement: "Not supported features should be ignored, not throw errors"

olofhagsand added a commit that referenced this issue Apr 6, 2022
  * Instead of removing YANG which is disabled by `if-feature`, replace it with an yang `anydata` node.
  * This means XML specified by such YANG is ignored, and it is not an error to access it
  * Note the similarity with `CLICON_YANG_UNKNOWN_ANYDATA`
@olofhagsand
Copy link
Member

Fixed. Please verify.
Also described in https://clixon-docs.readthedocs.io/en/latest/yang.html#if-feature-and-anydata

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants