netopeer2 icon indicating copy to clipboard operation
netopeer2 copied to clipboard

will work If we make netopeer2 as a thread

Open samba2127 opened this issue 1 year ago • 5 comments

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

samba2127 avatar Mar 21 '24 09:03 samba2127

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().

michalvasko avatar Mar 21 '24 10:03 michalvasko

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

samba2127 avatar Mar 21 '24 11:03 samba2127

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.

michalvasko avatar Mar 22 '24 06:03 michalvasko

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

samba2127 avatar Mar 22 '24 07:03 samba2127

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.

michalvasko avatar Mar 22 '24 10:03 michalvasko

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 avatar Mar 25 '24 05:03 samba2127

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/[email protected] -- Up-to-date: /user/share/yang/modules/netopeer2/[email protected] -- Up-to-date: /user/share/yang/modules/netopeer2/[email protected] -- Up-to-date: /user/share/yang/modules/netopeer2/[email protected] -- Up-to-date: /user/share/yang/modules/netopeer2/[email protected] -- Up-to-date: /user/share/yang/modules/netopeer2/[email protected] -- Up-to-date: /user/share/yang/modules/netopeer2/[email protected] -- Up-to-date: /user/share/yang/modules/netopeer2/[email protected] -- Up-to-date: /user/share/yang/modules/netopeer2/[email protected] -- Up-to-date: /user/share/yang/modules/netopeer2/[email protected] -- Up-to-date: /user/share/yang/modules/netopeer2/[email protected] -- Up-to-date: /user/share/yang/modules/netopeer2/[email protected] -- Up-to-date: /user/share/yang/modules/netopeer2/[email protected] -- Up-to-date: /user/share/yang/modules/netopeer2/[email protected] -- Up-to-date: /user/share/yang/modules/netopeer2/[email protected] -- 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()).

samba2127 avatar Mar 25 '24 09:03 samba2127

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.

Roytak avatar Mar 25 '24 10:03 Roytak

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: @.***>

samba2127 avatar Mar 25 '24 10:03 samba2127

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.

Roytak avatar Mar 25 '24 10:03 Roytak

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 avatar Mar 25 '24 11:03 samba2127

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

samba2127 avatar Mar 27 '24 05:03 samba2127

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

michalvasko avatar Mar 27 '24 14:03 michalvasko

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?

samba2127 avatar Mar 28 '24 10:03 samba2127

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.

michalvasko avatar Mar 28 '24 12:03 michalvasko

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

samba2127 avatar Apr 01 '24 12:04 samba2127

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

michalvasko avatar Apr 02 '24 06:04 michalvasko

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?

samba2127 avatar Apr 02 '24 07:04 samba2127

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).

michalvasko avatar Apr 02 '24 07:04 michalvasko

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?

samba2127 avatar Apr 15 '24 03:04 samba2127

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.

michalvasko avatar Apr 15 '24 06:04 michalvasko