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

copy-config's RPC cxobj parameter does not contain namespace #131

Closed
itzik-solomon opened this issue Aug 30, 2020 · 10 comments
Closed

copy-config's RPC cxobj parameter does not contain namespace #131

itzik-solomon opened this issue Aug 30, 2020 · 10 comments
Labels

Comments

@itzik-solomon
Copy link

copy-config RPC parameters are sent to the BE without namespace attribute (this is probably also the case with other netconf RPCs).
this is in contrast to the example RPCs in CLI client.

@olofhagsand olofhagsand added the bug label Sep 2, 2020
@olofhagsand
Copy link
Member

I interpret this as xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" is not provided or expected for top-level constructs. This is because clixon has a compile-time option called: USE_NETCONF_NS_AS_DEFAULT which assumes top-level namespaces is the base netconf namespace.
This is wrong and will be changed.

olofhagsand added a commit that referenced this issue Sep 2, 2020
  * Only requests on the form: `<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><edit-config>...` will be accepted
  * All replies will be on the form: `<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">...`
  * Requests such as: `<rpc><edit-config>...` will not  be accepted.
  * You can revert this behaviour (to clixon pre-4.6 behaviour) by enabling `CLICON_NAMESPACE_NETCONF_DEFAULT`
  * This API change is a consequence of: [copy-config's RPC cxobj parameter does not contain namespace #131](#131)
@olofhagsand
Copy link
Member

Fixed by patch above. Please verify.

@itzik-solomon
Copy link
Author

I hope to check this too tomorrow.

@dima1308
Copy link

dima1308 commented Sep 9, 2020

@Topitzik did you checked it?

@itzik-solomon
Copy link
Author

itzik-solomon commented Sep 10, 2020

the logs indeed show that the namespace arrived, but it seems to be stripped from the cxobj provided.
which means the namespace still can not be visible to the RPC callback function.

@olofhagsand
Copy link
Member

Can you please provide some more detail on expected and actual behavior?

@itzik-solomon
Copy link
Author

here is an example:
expected cxobj (in main example BE plugin function example_copy_extra this parameter is called 'xe')
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" username="root"> <copy-config><source><running/></source><target><startup/></target></copy-config> </rpc>
actual behavior:
<copy-config><target><startup/></target><source><running/></source></copy-config>
basically the internal netconf RPCs are stripped from the RPC encapsulation (which provide the context like namespace and user) while external RPCs keep this encapsulation.

@olofhagsand
Copy link
Member

olofhagsand commented Sep 11, 2020

Thats because the callback is called with xe pointing to the rpc instance. If you use its parent, you will get the namespace, eg in gdb:

(gdb) p xml_print(stderr, xml_parent(xe))
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" username="olof">
   <copy-config>
      <target>
         <startup/>
      </target>
      <source>
         <running/>
      </source>
   </copy-config>
</rpc>
(gdb) where
#0  from_client_copy_config (h=0x55555576a260, xe=0x555555cb24e0, cbret=0x555555cb7150, 
    arg=0x555555cb2350, regarg=0x0) at backend_client.c:743
#1  0x00007ffff7542321 in rpc_callback_call (h=0x55555576a260, xe=0x555555cb24e0, cbret=0x555555cb7150, 
    arg=0x555555cb2350) at clixon_plugin.c:775
#2  0x0000555555560672 in from_client_msg (h=0x55555576a260, ce=0x555555cb2350, msg=0x555555c90870)
    at backend_client.c:1674
#3  0x0000555555560a1e in from_client (s=5, arg=0x555555cb2350) at backend_client.c:1763
#4  0x00007ffff75178dc in clixon_event_loop () at clixon_event.c:348
#5  0x000055555555c12a in main (argc=0, argv=0x7fffffffe4d0) at backend_main.c:951

Also, at this point I usually use the function xml2ns() to get the namespace. Eg:

(gdb) p xml2ns(xe, 0, &ns)
$9 = 0
(gdb) p ns
$10 = 0x555555cb6940 "urn:ietf:params:xml:ns:netconf:base:1.0"

@itzik-solomon
Copy link
Author

ohh I didn't know xe had a parent.
working exactly as you said,
thanks.

@olofhagsand
Copy link
Member

I take that as a resolve.

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

No branches or pull requests

3 participants