* clicon_msg_rcv: Added intr parameter for interrupting on ^C (default 0)
* Internal NETCONF (client <-> backend) * Ensure message-id increments * Separated rpc from notification socket in same session * Removed coverage icon from homepage since it stopped working some time ago
This commit is contained in:
parent
453e97ef6b
commit
5822c1a72a
21 changed files with 140 additions and 68 deletions
|
|
@ -1554,14 +1554,6 @@ from_client_msg(clicon_handle h,
|
|||
goto done;
|
||||
goto reply;
|
||||
}
|
||||
/* Sanity check:
|
||||
* op_id from internal message can be out-of-sync from client's sessions-id for the following reasons:
|
||||
* 1. Its a hello when the client starts with op_id=0 to get its proper id on hello reply
|
||||
* 2. The backend has restarted and the client uses an old op_id
|
||||
*/
|
||||
if (op_id != 0 && ce->ce_id != op_id){
|
||||
clicon_debug(1, "%s Warning: incoming session-id:%u does not match socket ce_id:%u", __FUNCTION__, op_id, ce->ce_id);
|
||||
}
|
||||
/* Check for empty frame (no mesaages), return empty message, not clear from RFC what to do */
|
||||
if (xml_child_nr_type(xt, CX_ELMNT) == 0){
|
||||
if (netconf_malformed_message(cbret, "Empty message in netconf rpc frame")< 0)
|
||||
|
|
@ -1580,6 +1572,15 @@ from_client_msg(clicon_handle h,
|
|||
}
|
||||
rpcname = xml_name(x);
|
||||
rpcprefix = xml_prefix(x);
|
||||
/* Sanity check:
|
||||
* op_id from internal message can be out-of-sync from client's sessions-id for the following reasons:
|
||||
* 1. Its a hello when the client starts with op_id=0 to get its proper id on hello reply
|
||||
* 2. The backend has restarted and the client uses an old op_id
|
||||
* 3. Its a create-subsciption message that uses a separate socket(=client)
|
||||
*/
|
||||
if (op_id != 0 && ce->ce_id != op_id && strcmp(rpcname, "create-subscription")){
|
||||
clicon_debug(1, "%s Warning: incoming session-id:%u does not match ce_id:%u on socket: %d", __FUNCTION__, op_id, ce->ce_id, ce->ce_s);
|
||||
}
|
||||
/* Note that this validation is also made in xml_yang_validate_rpc, but not for hello
|
||||
*/
|
||||
if (xml2ns(x, rpcprefix, &namespace) < 0)
|
||||
|
|
@ -1786,7 +1787,7 @@ from_client(int s,
|
|||
clicon_err(OE_NETCONF, EINVAL, "Internal error: s != ce->ce_s");
|
||||
goto done;
|
||||
}
|
||||
if (clicon_msg_rcv(ce->ce_s, &msg, &eof) < 0)
|
||||
if (clicon_msg_rcv(ce->ce_s, 0, &msg, &eof) < 0)
|
||||
goto done;
|
||||
if (eof){
|
||||
backend_client_rm(h, ce);
|
||||
|
|
|
|||
|
|
@ -48,6 +48,11 @@
|
|||
/* Backend client entry.
|
||||
* Keep state about every connected client.
|
||||
* References from RFC 6022, ietf-netconf-monitoring.yang sessions container
|
||||
* @note that there is a discrepancy here between a client and a session
|
||||
* A session may have multiple client endpoints, most notably a regular
|
||||
* client socket and a separate notification client socket.
|
||||
* But they are the same session.
|
||||
* But the clixon client-entry do not differentiate
|
||||
*/
|
||||
struct client_entry{
|
||||
struct client_entry *ce_next; /* The clients linked list */
|
||||
|
|
|
|||
|
|
@ -135,24 +135,26 @@ cli_notification_register(clicon_handle h,
|
|||
return retval;
|
||||
}
|
||||
|
||||
/* Signal functions, not exported to API */
|
||||
/* Signal functions
|
||||
* This is for CLIgen to handle these signals, eg ^Ĉ means abort command, not program
|
||||
*/
|
||||
void
|
||||
cli_signal_block(clicon_handle h)
|
||||
{
|
||||
clicon_signal_block (SIGTSTP);
|
||||
clicon_signal_block (SIGQUIT);
|
||||
clicon_signal_block (SIGCHLD);
|
||||
if (!clicon_quiet_mode(h))
|
||||
clicon_signal_block (SIGINT);
|
||||
clicon_signal_block (SIGTSTP);
|
||||
clicon_signal_block (SIGQUIT);
|
||||
clicon_signal_block (SIGCHLD);
|
||||
if (!clicon_quiet_mode(h))
|
||||
clicon_signal_block (SIGINT);
|
||||
}
|
||||
|
||||
void
|
||||
cli_signal_unblock(clicon_handle h)
|
||||
{
|
||||
clicon_signal_unblock (SIGTSTP);
|
||||
clicon_signal_unblock (SIGQUIT);
|
||||
clicon_signal_unblock (SIGCHLD);
|
||||
clicon_signal_unblock (SIGINT);
|
||||
clicon_signal_unblock (SIGTSTP);
|
||||
clicon_signal_unblock (SIGQUIT);
|
||||
clicon_signal_unblock (SIGCHLD);
|
||||
clicon_signal_unblock (SIGINT);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -1139,7 +1141,7 @@ cli_notification_cb(int s,
|
|||
int ret;
|
||||
|
||||
/* get msg (this is the reason this function is called) */
|
||||
if (clicon_msg_rcv(s, &reply, &eof) < 0)
|
||||
if (clicon_msg_rcv(s, 0, &reply, &eof) < 0)
|
||||
goto done;
|
||||
if (eof){
|
||||
clicon_err(OE_PROTO, ESHUTDOWN, "Socket unexpected close");
|
||||
|
|
|
|||
|
|
@ -167,6 +167,8 @@ cli_terminate(clicon_handle h)
|
|||
cvec *nsctx;
|
||||
cxobj *x;
|
||||
|
||||
if (clixon_exit_get() == 0)
|
||||
clixon_exit_set(1);
|
||||
if (clicon_data_get(h, "session-transport", NULL) == 0)
|
||||
clicon_rpc_close_session(h);
|
||||
if ((yspec = clicon_dbspec_yang(h)) != NULL)
|
||||
|
|
|
|||
|
|
@ -686,6 +686,8 @@ netconf_terminate(clicon_handle h)
|
|||
cvec *nsctx;
|
||||
cxobj *x;
|
||||
|
||||
if (clixon_exit_get() == 0)
|
||||
clixon_exit_set(1);
|
||||
/* Delete all plugins, and RPC callbacks */
|
||||
clixon_plugin_module_exit(h);
|
||||
clicon_rpc_close_session(h);
|
||||
|
|
|
|||
|
|
@ -453,7 +453,7 @@ netconf_notification_cb(int s,
|
|||
|
||||
clicon_debug(1, "%s", __FUNCTION__);
|
||||
/* get msg (this is the reason this function is called) */
|
||||
if (clicon_msg_rcv(s, &reply, &eof) < 0)
|
||||
if (clicon_msg_rcv(s, 0, &reply, &eof) < 0)
|
||||
goto done;
|
||||
/* handle close from remote end: this will exit the client */
|
||||
if (eof){
|
||||
|
|
|
|||
|
|
@ -913,7 +913,7 @@ restconf_openssl_init(clicon_handle h,
|
|||
* - If no local config found, query backend for config and open sockets.
|
||||
* That is, EITHER local config OR read config from backend once
|
||||
* @param[in] h Clicon handle
|
||||
* @param[in] inline_config XML restconf config, malloced (if retval = 1)
|
||||
* @param[in] inline_config If set, restconf conf is given by -R command-line
|
||||
* @param[out] xrestconf XML restconf config, malloced (if retval = 1)
|
||||
* @retval 1 OK (and xrestconf set)
|
||||
* @retval 0 Fail - no config
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ restconf_stream_cb(int s,
|
|||
|
||||
clicon_debug(1, "%s", __FUNCTION__);
|
||||
/* get msg (this is the reason this function is called) */
|
||||
if (clicon_msg_rcv(s, &reply, &eof) < 0){
|
||||
if (clicon_msg_rcv(s, 0, &reply, &eof) < 0){
|
||||
clicon_debug(1, "%s msg_rcv error", __FUNCTION__);
|
||||
goto done;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue