CESNET / netopeer2

NETCONF toolset
BSD 3-Clause "New" or "Revised" License
290 stars 186 forks source link

Getting disconnected from the netopeer server while pushing xml with empty leaf value. #1522

Closed SanchitChaudhary12 closed 3 months ago

SanchitChaudhary12 commented 6 months ago

Hey @michalvasko While pushing incorrect xml using edit-config , the netopeer session gets disconnected instead of throwing an error. The xml pushed with one empty leaf value. Procedure:

  1. Pushed the right xml with right value
  2. Pushed the wrong xml with empty leaf value.

Actual Xml: Screenshot from 2023-12-26 14-27-59

Xml pushed without leaf value

Screenshot from 2023-12-26 14-28-12

Observation: Issue will be created only when we first push the right xml and after that try to push the wrong xml. Screenshot from 2023-12-14 14-22-36

michalvasko commented 6 months ago

What version of netopeer2/libyang are you using? I think this has already been fixed.

SanchitChaudhary12 commented 6 months ago

These are the versions we are using. netopeer2 version -> v2.1.49 libyang version -> v2.1.30

michalvasko commented 5 months ago

So please update to the current devel branch of all the projects or at least to the latest release and try again.

SanchitChaudhary12 commented 5 months ago

Okay, thanks I will check and let you know.

Gris87 commented 3 months ago

This issue is still reproducing at version: netopeer2 version -> v2.2.13 libyang version -> v2.46.3 aka 2.1.148 libsysrepo version -> v2.2.15

netoper-server crashes with the following stacktrace:

#0  0x00007fd3ba7fb452 in ?? () from /usr/lib/libsysrepo.so.7
#1  0x00007fd3ba7fe04e in ?? () from /usr/lib/libsysrepo.so.7
#2  0x00007fd3ba7ff2fe in ?? () from /usr/lib/libsysrepo.so.7
#3  0x00007fd3ba7f5dbf in ?? () from /usr/lib/libsysrepo.so.7
#4  0x00007fd3ba7defa4 in sr_apply_changes () from /usr/lib/libsysrepo.so.7
#5  0x000000000040884d in np2srv_rpc_editconfig_cb (session=0x7fd3ac026270, UNUSED_sub_id=59, UNUSED_op_path=0x22f5b70 "/ietf-netconf:edit-config", input=0x7fd3ac025f90, event=SR_EV_RPC, UNUSED_request_id=2, UNUSED_output=0x7fd3ac030c70,
    UNUSED_private_data=0x0) at /netopeer2/src/netconf.c:305
#6  0x00007fd3ba81180e in ?? () from /usr/lib/libsysrepo.so.7
#7  0x00007fd3ba81831c in ?? () from /usr/lib/libsysrepo.so.7
#8  0x00007fd3ba7dfdd2 in sr_subscription_process_events () from /usr/lib/libsysrepo.so.7
#9  0x00007fd3ba819039 in ?? () from /usr/lib/libsysrepo.so.7
#10 0x00007fd3ba675034 in start_thread (arg=<optimized out>) at pthread_create.c:444
#11 0x00007fd3ba6f3c94 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:100 
Gris87 commented 3 months ago

This crash happens when we are trying to make edit-config with invalid leaf value

michalvasko commented 3 months ago

I have tested on the current devel branches and got a response

> edit-config --target running --config
ERROR
        type:     application
        tag:      bad-element
        severity: error
        message:  Invalid type uint32 empty value.
        info:
<bad-element xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">/o-ran-processing-element:processing-elements/ru-elements/transport-flow/eth-flow/vlan-id</bad-element>

so unless you can provide all the necessary files (YANG modules, data files, ...) and the exact steps to reproduce this (on the current devel branch), I cannot help you.

Gris87 commented 3 months ago

On latest release netopeer/sysrepo you can reproduce it this way:

  1. prepare files:

    
    $ cat test.yang
    module test {
    yang-version 1.1;
    namespace "urn:test:test";
    prefix "test";
    
    organization "test";
    
    description "test yang";
    
    revision "2024-03-24" {
    description "initial version";
    }
    typedef TestEnum {
    type enumeration {
      enum ENUM1 {
        value 0;
      }
      enum ENUM2 {
        value 1;
      }
    }
    }
    container Test {
    leaf test {
      type TestEnum;
    }
    }
    }

$ cat test.xml <?xml version="1.0"?>

ENUM1

$ cat invalid_test.xml <?xml version="1.0"?>

ENU

2. install module to sysrepo

$ sysrepoctl -i test.yang --init-data test.xml

3. start netopeer2-server

$ netopeer2-server -d -v3

4. try to change module data in running datastore using netconf in another terminal

$ netopeer2-cli

connect edit-config --target running --config=invalid_test.xml --defop replace --error rollback nc ERROR: SSH channel poll error (Socket error: disconnected). cli_send_recv: Failed to receive a reply.


so, ssh connection unexpectedly interrupts.

Let's check netopeer logs:

[INF]: SR: Connection 29 created.
[INF]: SR: Session 70 (user "root", CID 29) created.
[INF]: SR: Triggering "ietf-netconf-server" "done" event on enabled data.
[INF]: LN: Listening on 0.0.0.0:830 for SSH connections.
[INF]: SR: Triggering "ietf-keystore" "done" event on enabled data.
[INF]: SR: Triggering "ietf-truststore" "done" event on enabled data.
[INF]: SR: Triggering "ietf-netconf-acm" "done" event on enabled data.
[INF]: SR: Triggering "ietf-netconf-acm" "done" event on enabled data.
[INF]: SR: Triggering "ietf-netconf-acm" "done" event on enabled data.
[INF]: SR: Triggering "ietf-netconf-acm" "done" event on enabled data.
[INF]: LN: Accepted a connection on 0.0.0.0:830 from 127.0.0.1:46422.
[INF]: LN: Received an SSH message "request-service" of subtype "ssh-userauth".
[INF]: LN: Received an SSH message "request-auth" of subtype "none".
[INF]: LN: User "root" authenticated.
[INF]: LN: Received an SSH message "request-channel-open" of subtype "session".
[INF]: LN: Received an SSH message "request-channel" of subtype "subsystem".
[INF]: SR: Session 78 (user "root", CID 29) created.
[INF]: SR: There are no subscribers for "ietf-netconf-notifications" notifications.
[INF]: NP: Generated new event (netconf-session-start).
[INF]: SR: EV ORIGIN: "/ietf-netconf-monitoring:get-schema" "rpc" ID 1 priority 0 for 1 subscribers published.
[INF]: SR: EV LISTEN: "/ietf-netconf-monitoring:get-schema" "rpc" ID 1 priority 0 processing (remaining 1 subscribers).
[INF]: NP: Module "ietf-datastores@<any>" was requested.
[INF]: SR: EV LISTEN: "/ietf-netconf-monitoring:get-schema" "rpc" ID 1 priority 0 success (remaining 0 subscribers).
[INF]: SR: EV ORIGIN: "/ietf-netconf-monitoring:get-schema" "rpc" ID 1 priority 0 succeeded.
[INF]: NP: Session 1: thread 2 event new RPC.
[INF]: SR: EV ORIGIN: "/ietf-netconf:get" "rpc" ID 1 priority 0 for 1 subscribers published.
[INF]: SR: EV LISTEN: "/ietf-netconf:get" "rpc" ID 1 priority 0 processing (remaining 1 subscribers).
[INF]: SR: EV LISTEN: "/ietf-netconf:get" "rpc" ID 1 priority 0 success (remaining 0 subscribers).
[INF]: SR: EV ORIGIN: "/ietf-netconf:get" "rpc" ID 1 priority 0 succeeded.
[INF]: NP: Session 1: thread 2 event new RPC.
[INF]: SR: EV ORIGIN: "/ietf-netconf-monitoring:get-schema" "rpc" ID 2 priority 0 for 1 subscribers published.
[INF]: SR: EV LISTEN: "/ietf-netconf-monitoring:get-schema" "rpc" ID 2 priority 0 processing (remaining 1 subscribers).
[INF]: NP: Module "test@2024-03-24" was requested.
[INF]: SR: EV LISTEN: "/ietf-netconf-monitoring:get-schema" "rpc" ID 2 priority 0 success (remaining 0 subscribers).
[INF]: SR: EV ORIGIN: "/ietf-netconf-monitoring:get-schema" "rpc" ID 2 priority 0 succeeded.
[INF]: NP: Session 1: thread 0 event new RPC.
[INF]: SR: EV ORIGIN: "/ietf-netconf:get" "rpc" ID 2 priority 0 for 1 subscribers published.
[INF]: SR: EV LISTEN: "/ietf-netconf:get" "rpc" ID 2 priority 0 processing (remaining 1 subscribers).
[INF]: SR: EV LISTEN: "/ietf-netconf:get" "rpc" ID 2 priority 0 success (remaining 0 subscribers).
[INF]: SR: EV ORIGIN: "/ietf-netconf:get" "rpc" ID 2 priority 0 succeeded.
[INF]: NP: Session 1: thread 0 event new RPC.
[INF]: SR: EV ORIGIN: "/ietf-netconf:edit-config" "rpc" ID 1 priority 0 for 1 subscribers published.
[INF]: SR: EV LISTEN: "/ietf-netconf:edit-config" "rpc" ID 1 priority 0 processing (remaining 1 subscribers).
[WRN]: SR: Recovered a read-lock of CID 27 (sr_shmmod_lock).
[WRN]: SR: Recovered a read-upgr-lock of CID 27 (sr_shmmod_lock).
Segmentation fault (core dumped)

seems like it crushes when it tries to rollback.

I will check this on latest devel a bit later.

Gris87 commented 3 months ago

The same situation with the latest devel

michalvasko commented 3 months ago

Thanks, I manage to reproduce it this way, fixed in the latest sysrepo.

Gris87 commented 3 months ago

Great news!!! Can I ask you to make new sysrepo release if it's possible?

michalvasko commented 3 months ago

There are still a few changes left that should make it into the next release (we are always releasing all the projects together, not just sysrepo) but I am hoping it will happen this or the next week.