ConfD User Community

How to change SSH port using C API


#1

Hi,

How I can change the SSH port (which is default 830) USING C API.
I know that it can be changed by editing the confd.conf file but I want to let the user define it.

thanks,


#2

You can configure SSH parameters, including IP-address and port, from CDB. For more information see section 28.4.2. Storing ConfD configuration parameters in CDB in the User Guide.


#3

Hi,

I am using external DB so this YANG model won’t help.
I need other way to change this configuration using C API.
I thought about 1 option:

  1. open the confd.conf file using open() and change the file.
  2. run maapi_reload to update the modificaiton.

But if there is C API for that it will be much better then modifying text file from source code.

Thanks,


#4

Just because you are storing some data in an external DB doesn’t mean that you can’t enable storage of the ConfD config in CDB as @jjohansson suggests.
If you do need that config in an external DB, you can likely just annotate that confdconf yang model with a callpoint.
See also examples.confd/confdconf for an example


#5

Hi,

As I mentioned I am using CFGD process connected to CONFD with external DB. Listen for CONFD and getting triggers for configuration requests from CONFD.
Another process is RCPD which I am using to configure CONFD CDB using confd_dyncfg.yang.
when I am doing maapi_apply_trans (in RCPD) the control socket in CFGD crash.
In RCPD I am doing the following:
create socket, maapi_connect(), maapi_start_user_session(), maapi_start_trans(), maapi_set_elem2, maapi_apply_trans.

please assist.

thanks,


#6

Hi,

I see now that the problem is when I call maapi_apply_trans(), I assume that it fail and duw to that the conrol socket is closed.
The question is why?
Should I use cdb_set_*** functions to change the CDB instead of the maapi functions?

thanks,


#7

Hi,

After looking again in the forum in items related to my problem, I understood that when I am calling maapi_apply_trans() I am entering a deadlock.
The question is why?
The control & worker sockets I have are in CFGD process, while the maapi_apply_trans() being executed from RCPD process.
How can this deadlock can be solved? what is the right process to change the CDB using C APIs?

Please assist.

thanks,


#8

MAAPI is the correct way. There shouldn’t be any deadlocks unless you’re subscribing for CDB updates from the same process.

A small example using confd_cmd and the 1-2-3 example shows how to do it:

$ confd_cmd -dd -c “mset /dhcp/logFacility mail”
mset “/dhcp/logFacility” “mail”
TRACE Connected (maapi) to ConfD
TRACE MAAPI_START_USER_SESSION --> CONFD_OK
TRACE MAAPI_START_TRANS --> CONFD_OK
TRACE MAAPI_SET_ELEM2 /dhcp/logFacility --> CONFD_OK
TRACE MAAPI_APPLY_TRANS --> CONFD_OK
TRACE MAAPI_STOP_TRANS --> CONFD_OK
TRACE MAAPI_END_USER_SESSION --> CONFD_OK
$


#9

Hi,

This is the sequence I got.
I think it is the same as you mentioned but as you can see the maapi_apply_trans return error:
slot_polling_run endTRACE Connected (maapi) to ConfD
TRACE MAAPI_START_USER_SESSION
28-Jun-2017::22:25:31.256 13667/b0fffb40/39 SEND op=100 isrel=0 th=-1 {#Bin,{{127,0,0,1},0},system,1,false,[#Bin],{undefined,undefined,undefined,#Bin<./services/services_(10)…>}}
–> CONFD_OK
TRACE MAAPI_START_TRANS
28-Jun-2017::22:25:32.401 13667/b0fffb40/39 SEND op=140 isrel=0 th=-1 {2,2,0,0,0,{undefined,undefined,undefined,#Bin<./services/services_(10)…>}}
28-Jun-2017::22:25:32.432 13667/b0fffb40/39 GOT 7
–> CONFD_OK
TRACE MAAPI_SET_NAMESPACE
28-Jun-2017::22:25:35.543 13667/b0fffb40/39 SEND op=160 isrel=0 th=7 300447312
–> CONFD_OK
TRACE MAAPI_SET_ELEM2 /confd_dyncfg:confdConfig/confd_dyncfg:netconf/confd_dyncfg:transport/confd_dyncfg:ssh/confd_dyncfg:port
28-Jun-2017::22:25:38.113 13667/b0fffb40/39 SEND op=173 isrel=0 th=7 {#Bin<8888>,[[confd_dyncfg|confdConfig],[confd_dyncfg|netconf],[confd_dyncfg|transport],[confd_dyncfg|ssh],[confd_dyncfg|port]]}
–> CONFD_OK
TRACE MAAPI_APPLY_TRANS
28-Jun-2017::22:25:39.936 13667/b0fffb40/39 SEND op=143 isrel=0 th=7 {false,0}
TRACE New user session: 28 for user:admin ctx:system --> CONFD_OK
TRACE CALL trans init(thandle=7,mode=“rw”,db=running) --> CONFD_OK
TRACE CALL trans prepare(thandle=7)du: cannot access ‘/sdlog/syslog’: No such file or directory
DEBUG external error - application timeout
–> CONFD_ERR

Please assist.

Thanks.


#10

@evyatar, I believe you need to go back and focus on why your application handling your external DB through the ConfD DP API timeout.

Use the ConfD developer log trace and your ext DB application libconfd trace + other extDB app debug print outs that you may have implemented to debug the issue.


#11

Hi,

I found the problem and now it is working.

Thank you very much for the support.