#include "northbound_cli.h"
#include "printfrr.h"
#include "json.h"
+#include "sockopt.h"
#include <arpa/telnet.h>
#include <termios.h>
* put the data of collective vty->obuf Linked List items on the
* socket and free the vty->obuf data.
*/
- if (vty->vty_buf_size_accumulated >= VTY_MAX_INTERMEDIATE_FLUSH) {
+ if (vty->vty_buf_size_accumulated >= vty->buf_size_intermediate) {
vty->vty_buf_size_accumulated = 0;
vtysh_flush(vty);
}
* Increasing the SEND socket buffer size so that the socket can hold
* before sending it to VTY shell.
*/
- ret = setsockopt(sock, SOL_SOCKET, SO_SNDBUF, (char *)&sndbufsize,
- sizeof(sndbufsize));
- if (ret < 0) {
+ ret = setsockopt_so_sendbuf(sock, sndbufsize);
+ if (ret <= 0) {
flog_err(EC_LIB_SOCKET,
"Cannot set socket %d send buffer size, %s", sock,
safe_strerror(errno));
close(sock);
return;
}
+
set_cloexec(sock);
#ifdef VTYSH_DEBUG
#endif /* VTYSH_DEBUG */
vty = vty_new();
+
+ vty->buf_size_set = ret;
+ if (vty->buf_size_set < VTY_MAX_INTERMEDIATE_FLUSH)
+ vty->buf_size_intermediate = vty->buf_size_set / 2;
+ else
+ vty->buf_size_intermediate = VTY_MAX_INTERMEDIATE_FLUSH;
+
vty->fd = sock;
vty->wfd = sock;
vty->type = VTY_SHELL_SERV;
bool mgmt_locked_candidate_ds;
bool mgmt_locked_running_ds;
uint64_t vty_buf_size_accumulated;
+
+ int buf_size_set;
+ uint64_t buf_size_intermediate;
};
static inline void vty_push_context(struct vty *vty, int node, uint64_t id)
#include "frrstr.h"
#include "json.h"
#include "ferr.h"
+#include "sockopt.h"
DEFINE_MTYPE_STATIC(MVTYSH, VTYSH_CMD, "Vtysh cmd copy");
* Increasing the RECEIVE socket buffer size so that the socket can hold
* after receving from other process.
*/
- ret = setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (char *)&rcvbufsize,
- sizeof(rcvbufsize));
- if (ret < 0) {
+ ret = setsockopt_so_recvbuf(sock, rcvbufsize);
+ if (ret <= 0) {
#ifdef DEBUG
fprintf(stderr, "Cannot set socket %d rcv buffer size, %s\n",
sock, safe_strerror(errno));