clicon / clixon

YANG-based toolchain including NETCONF and RESTCONF interfaces and an interactive CLI
http://www.clicon.org/
Other
215 stars 72 forks source link

Doesn't reply with message-id #530

Open SpiffiRacoon opened 5 months ago

SpiffiRacoon commented 5 months ago

When receiving a request Clixon-controller doesn't properly reply to the sender with the same message-id. This causes the operation and connection to error out when using other netconf clients.

The reply should look more like in the examples here: https://datatracker.ietf.org/doc/html/rfc4741#section-4.2

Example of error when testing to get_config(source='running') using ncclient with modified transport to support unix domain sockets (Fork).

>>> clixonTest.get_config(source='running')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/spiffi/.virtualenvs/ncclient-testing/lib/python3.10/site-packages/ncclient/manager.py", line 270, in execute
    return cls(self._session,
  File "/home/spiffi/.virtualenvs/ncclient-testing/lib/python3.10/site-packages/ncclient/operations/retrieve.py", line 166, in request
    return self._request(node)
  File "/home/spiffi/.virtualenvs/ncclient-testing/lib/python3.10/site-packages/ncclient/operations/rpc.py", line 364, in _request
    raise self._error
  File "/home/spiffi/.virtualenvs/ncclient-testing/lib/python3.10/site-packages/ncclient/transport/session.py", line 241, in run
    self.parser.parse(data)
  File "/home/spiffi/.virtualenvs/ncclient-testing/lib/python3.10/site-packages/ncclient/transport/parser.py", line 116, in parse
    self._parse11()
  File "/home/spiffi/.virtualenvs/ncclient-testing/lib/python3.10/site-packages/ncclient/transport/parser.py", line 205, in _parse11
    self._session._dispatch_message(message)
  File "/home/spiffi/.virtualenvs/ncclient-testing/lib/python3.10/site-packages/ncclient/transport/unixSocket.py", line 45, in _dispatch_message
    return super(UnixSocketSession, self)._dispatch_message(raw)
  File "/home/spiffi/.virtualenvs/ncclient-testing/lib/python3.10/site-packages/ncclient/transport/session.py", line 90, in _dispatch_message
    l.callback(root, raw) # no try-except; fail loudly if you must!
  File "/home/spiffi/.virtualenvs/ncclient-testing/lib/python3.10/site-packages/ncclient/operations/rpc.py", line 249, in callback
    raise OperationError("Could not find 'message-id' attribute in <rpc-reply>")
ncclient.operations.errors.OperationError: Could not find 'message-id' attribute in <rpc-reply>

Output from clixon-backen running in D3 mode:

Jun 14 09:46:38.717664: clixon_msg_rcv11:606: Recv [3]: <?xml version="1.0" encoding="UTF-8"?><nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:a97807ce-d58a-4da7-b184-12e3ab660695"><nc:get-config><nc:source><nc:running/></nc:source></nc:get-config></nc:rpc>
Jun 14 09:46:38.718262: clixon_msg_send:358: Send [3]: 
#1052
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><data><devices xmlns="http://clicon.org/controller"><device><name>router1</name><user>noc</user><conn-type>NETCONF_SSH</conn-type><ssh-stricthostkey>false</ssh-stricthostkey><addr>172.18.0.2</addr><config><restconf xmlns="http://clicon.org/restconf"><enable>true</enable><auth-type>none</auth-type><debug>0</debug><log-destination>file</log-destination><pretty>false</pretty><socket><namespace>default</namespace><address>0.0.0.0</address><port>80</port><ssl>false</ssl></socket></restconf></config></device><device><name>router2</name><user>noc</user><conn-type>NETCONF_SSH</conn-type><ssh-stricthostkey>false</ssh-stricthostkey><addr>172.18.0.3</addr><config><restconf xmlns="http://clicon.org/restconf"><enable>true</enable><auth-type>none</auth-type><debug>0</debug><log-destination>file</log-destination><pretty>false</pretty><socket><namespace>default</namespace><address>0.0.0.0</address><port>80</port><ssl>false</ssl></socket></restconf></config></device></devices></data></rpc-reply>
##
Jun 14 09:46:38.718817: clixon_msg_rcv11:600: Recv [3]: EOF
olofhagsand commented 5 months ago

Internal NETCONF protocol issue. Related to https://github.com/clicon/clixon/issues/532