CESNET / netopeer2

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

will work If we make netopeer2 as a thread #1553

Closed samba2127 closed 3 months ago

samba2127 commented 3 months ago

Could you please let me know if we make netopeer2 as a thread instead of process. If we make as a thread what needs to be taken care in the main.c file . Is there any flag to provide while compiling as a thread.

Thanks Samba

michalvasko commented 3 months ago

I must say I have never heard about anything being compiled "as a thread" but I suppose a library with a function matching the thread function prototype could be called this way. In any case, netopeer2 does not support anything like that. But, in theory, all you need to do is rename its main to something else and compile it as a library, then you get the function that you can use in pthread_create().

samba2127 commented 3 months ago

Hi Michalvasko I have added code NetconfTaskMain in place of main() and created as a library libnetopeer2.so file . I called this NetconfTaskMain form the another process. But it getting crash as soon as call this function. i am note getting any information. is possbile to create any log file instead of syslog and stderr

michalvasko commented 3 months ago

I do not think any logging will help you, I would use valgrind, gdb or a sanitizer to learn the cause of the crash. But note that as soon as you start doing similar modifications, I cannot really provide any support.

samba2127 commented 3 months ago

i have created as library and i am able to execute the code . But getting the following error [ERR]: NP: Module "ietf-netconf" feature "writable-running" not enabled in sysrepo. [ERR]: NP: Server init failed.

what could be the reasons for this error. Please help me anything missing any files. share/yang/modules/libnetconf2/ share/yang/modules/netopeer2/ share/yang/modules/libyang/* and copied the all libraries. is it required other than this any configuration

michalvasko commented 3 months ago

For the server to start, you need to at least run scripts/setup.sh on the target system. Other scripts are meant to setup some basic working configuration but the server should start even without it.

samba2127 commented 3 months ago

In my box will not work setup.sh. Could you please explain to me reason of the following error Module "ietf-netconf" feature "writable-running" not enabled in sysrepo.

Could you please let me know the issue other than setup.sh how to fix this isse

samba2127 commented 3 months ago

Hi Michalvasko, I was trying in ubuntu-pc . getting "[ERR]: NP: Module "ietf-netconf" feature "writable-running" not enabled in sysrepo." error
in message. Getting the same error even after executing "ldconfig" .

anilk@techie-OptiPlex-390:~/netopeer2/sysrepo/build$ sudo make install anilk@techie-OpiPlex-390:~/netopeer2/libnetopeer2/build$sudo make install anilk@techie-OptiPlex-390:~/netopeer2/netopeer2/build$ sudo make install [ 27%] Built target serverobj [ 37%] Built target netopeer2-server [ 75%] Built target netopeer [100%] Built target netopeer2-cli Install the project... -- Install configuration: "Debug" -- Up-to-date: /user/share/yang/modules/netopeer2 -- Up-to-date: /user/share/yang/modules/netopeer2/ietf-netconf@2013-09-29.yang -- Up-to-date: /user/share/yang/modules/netopeer2/ietf-network-instance@2019-01-21.yang -- Up-to-date: /user/share/yang/modules/netopeer2/ietf-datastores@2018-02-14.yang -- Up-to-date: /user/share/yang/modules/netopeer2/ietf-interfaces@2018-02-20.yang -- Up-to-date: /user/share/yang/modules/netopeer2/ietf-netconf-monitoring@2010-10-04.yang -- Up-to-date: /user/share/yang/modules/netopeer2/ietf-netconf-nmda@2019-01-07.yang -- Up-to-date: /user/share/yang/modules/netopeer2/ietf-netconf-acm@2018-02-14.yang -- Up-to-date: /user/share/yang/modules/netopeer2/ietf-yang-push@2019-09-09.yang -- Up-to-date: /user/share/yang/modules/netopeer2/ietf-yang-patch@2017-02-22.yang -- Up-to-date: /user/share/yang/modules/netopeer2/ietf-ip@2018-02-22.yang -- Up-to-date: /user/share/yang/modules/netopeer2/ietf-restconf@2017-01-26.yang -- Up-to-date: /user/share/yang/modules/netopeer2/ietf-subscribed-notifications@2019-09-09.yang -- Up-to-date: /user/share/yang/modules/netopeer2/ietf-yang-schema-mount@2019-01-14.yang -- Up-to-date: /user/share/yang/modules/netopeer2/notifications@2008-07-14.yang -- Up-to-date: /user/share/yang/modules/netopeer2/nc-notifications@2008-07-14.yang -- Up-to-date: /user/share/netopeer2/scripts -- Up-to-date: /user/share/netopeer2/scripts/merge_config.sh -- Up-to-date: /user/share/netopeer2/scripts/merge_hostkey.sh -- Up-to-date: /user/share/netopeer2/scripts/setup.sh -- Up-to-date: /user/share/netopeer2/scripts/remove.sh -- Up-to-date: /user/share/netopeer2/scripts/common.sh -- Up-to-date: /user/sbin/netopeer2-server -- Up-to-date: /user/share/man/man8/netopeer2-server.8 -- Up-to-date: /etc/pam.d/netopeer2.conf -- Up-to-date: /user/bin/netopeer2-cli -- Up-to-date: /user/share/man/man1/netopeer2-cli.1 anilk@techie-OptiPlex-390:~/netopeer2/netopeer2/build$ /user/sbin/netopeer2-server -v2 -d [INF]: SR: Connection 3 created. [INF]: SR: Session 3 (user "anilk", CID 3) created. [ERR]: NP: Module "ietf-netconf" feature "writable-running" not enabled in sysrepo. [ERR]: NP: Server init failed. [INF]: NP: Server terminated. [ERR]: LN: Invalid argument data (nc_server_config_setup_diff()).

Roytak commented 3 months ago

Hi, I just had the same issue. I am not sure what exactly causes it, but running make sr_clean in sysrepo and then updating to the latest devel branch of netopeer2 fixed this for me. Not sure what versions you are using, but I switched to all the project's latest devel version and now it works. If you can't switch to these versions, Michal should be here in a couple days to help.

samba2127 commented 3 months ago

Hi Roman,

I am using the netopeer2 version 2.2.13.

Is this same version you are using?

If not please let me know, I will also use the same version which you are using.

Thanks,

Samba


From: Roman Janota @.***> Sent: Monday, March 25, 2024 3:33:36 PM To: CESNET/netopeer2 Cc: Samba Siva Reddy; Author Subject: Re: [CESNET/netopeer2] will work If we make netopeer2 as a thread (Issue #1553)

[CAUTION: This email originated from outside of Tejas. Do not click links or open attachments unless you recognize the sender and know the content is safe]

Hi, I just had the same issue. I am not sure what exactly causes it, but running make sr_clean in sysrepo and then updating to the latest devel branch of netopeer2 fixed this for me. Not sure what versions you are using, but I switched to all the project's latest devel version and now it works. If you can't switch to these versions, Michal should be here in a couple days to help.

— Reply to this email directly, view it on GitHubhttps://github.com/CESNET/netopeer2/issues/1553#issuecomment-2017632305, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BFY5QEEYIWYFRJQSCV7FGBDYZ7Y7RAVCNFSM6AAAAABFBDHBWGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJXGYZTEMZQGU. You are receiving this because you authored the thread.Message ID: @.***>

Roytak commented 3 months ago

Nevermind, the version has nothing to do with this.

In my box will not work setup.sh

Why? The error "[ERR]: NP: Module "ietf-netconf" feature "writable-running" not enabled in sysrepo." is caused by this most likely. You need to run the script for it to work.

I am using the devel branch, there have been some changes to the scripts since version 2.2.13, so if you're not getting any output on why the script fails, consider updating to the devel branch.

samba2127 commented 3 months ago

Thanks Roman janota

Yes this issue is resolved with devel branch .


From: Roman Janota @.***> Sent: Monday, March 25, 2024 3:44:31 PM To: CESNET/netopeer2 Cc: Samba Siva Reddy; Author Subject: Re: [CESNET/netopeer2] will work If we make netopeer2 as a thread (Issue #1553)

[CAUTION: This email originated from outside of Tejas. Do not click links or open attachments unless you recognize the sender and know the content is safe]

Nevermind, the version has nothing to do with this.

In my box will not work setup.shhttps://linkprotect.cudasvc.com/url?a=https%3a%2f%2fsetup.sh&c=E,1,oxCtUqDguql5p7bz0_RR-loPEXEtIwqVcBgnSYEpDd4IiyROfvYpK2PY8rtbqdWO1SGlhfe_MnVQlShfxJ-foP8rRJnrfxJM1Ds1LQYs_VMey0l-mHbYeOJpSv8c&typo=1&ancr_add=1

Why? The error "[ERR]: NP: Module "ietf-netconf" feature "writable-running" not enabled in sysrepo." is caused by this most likely. You need to run the script for it to work.

I am using the devel branch, there have been some changes to the scripts since version 2.2.13, so if you're not getting any output on why the script fails, consider updating to the devel branch.

— Reply to this email directly, view it on GitHubhttps://github.com/CESNET/netopeer2/issues/1553#issuecomment-2017653058, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BFY5QECETA3KWLEFGNU4C2TYZ72IPAVCNFSM6AAAAABFBDHBWGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJXGY2TGMBVHA. You are receiving this because you authored the thread.Message ID: @.***>

samba2127 commented 3 months ago

In my box multiple interfaces are running . I want to make it run and listen on particular interface. How can i do this instead of default local host to the specified interface.

This will be very helpful to get answer ASAP

michalvasko commented 3 months ago

Edit ietf-netconf-server configuration stored in sysrepo. For example, using sysrepocfg -E vim -m ietf-netconf-server.

samba2127 commented 3 months ago

Thanks Michalvasko.

I want to make changes in the code itself. Where can we make and server listen on the particular interface. what is the use of netopeer2-server.sock?

michalvasko commented 3 months ago

I want to make changes in the code itself.

Then you are on your own, we do not provide support with that.

Where can we make and server listen on the particular interface.

The code is in libnetconf2, not netopeer2.

what is the use of netopeer2-server.sock?

Local UNIX socket interface.

samba2127 commented 3 months ago

Hi Michal, Here code is failing . what could be the reason.
printf("nc_server_config_fill_netconf_server entry \n"); ret = lyd_find_path(data, "/ietf-netconf-server:netconf-server", 0, &tree); if (ret || (tree->flags & LYD_DEFAULT)) { / not found / printf("nc_server_config_fill_netconf_server -----ietf-netconf-server not found \n"); ret = 0; goto cleanup; } Here i changed the sysrepo standard path /etc/sysrepo to /dev/shm/sysrepo. Do i need to set any thing in the libyang direcotry Sysrepo repository: /dev/shm/sysrepo

Module Name | Revision | Flags | Startup Owner | Startup Perms | Running Perms | Submodules | Features

ietf-netconf | 2013-09-29 | I | root:root | 600 | 600 | | writable-running candidate confirmed-commit rollback-on-error validate startup url xpath ietf-netconf-notifications | 2012-02-06 | I | root:root | 644 | 644 | | ietf-netconf-server | 2023-12-28 | I | root:root | 600 | 600 | | ssh-listen tls-listen ssh-call-home tls-call-home central-netconf-server-supported

michalvasko commented 3 months ago

I am sorry but like I said, once you start changing the code, we cannot provide any support.

samba2127 commented 3 months ago

Hi Michal,

I did not any code changes. I used only Netconftaskmain function instead of main. Remaining code will be same and sysrepo path changed.

if i use unix socket do we need to pass any arguments along with -U option?

michalvasko commented 3 months ago

Okay, but you have changed the repository path to a volatile (on most systems) directory, which is usually empty after reboot. But it is meant for persistent files that should not be deleted on their own, which is probably the root of your problem.

As for the UNIX socket, it is all documented in the help (netopeer2-server -h).

samba2127 commented 2 months ago

Hi ,

How to make config to true through netopeer2-cli .

    container stats {
        config false;
        leaf counter {
            type uint64;
        }

        leaf counter2 {
            type uint64;
        }
    }

from edit-config command?

michalvasko commented 2 months ago

Your question is not related to this issue and you should have created a new one. You cannot "edit" state data so they cannot be modified by edit-config. You can set them via sysrepo, details are in the docs.