ipaccess: Add connect timeout in e1inp_line
* VTY command e1_line N connect-timeout T to set the connect() timeout
* use ipa_client_conn_open2 to connect with timeout
Related: SYS#6237
Change-Id: I7379102d19c172bed2aa00377d92bc885f54b640
diff --git a/src/e1_input.c b/src/e1_input.c
index ee529cc..02f3b30 100644
--- a/src/e1_input.c
+++ b/src/e1_input.c
@@ -509,6 +509,7 @@
line->keepalive_idle_timeout = E1INP_USE_DEFAULT;
line->keepalive_num_probes = E1INP_USE_DEFAULT;
line->keepalive_probe_interval = E1INP_USE_DEFAULT;
+ line->connect_timeout = 0;
line->rate_ctr = rate_ctr_group_alloc(line, &e1inp_ctr_g_d, line->num);
if (!line->rate_ctr) {
diff --git a/src/e1_input_vty.c b/src/e1_input_vty.c
index f6781d1..ca45f93 100644
--- a/src/e1_input_vty.c
+++ b/src/e1_input_vty.c
@@ -245,6 +245,26 @@
return CMD_SUCCESS;
}
+DEFUN_ATTR(cfg_e1line_connect_timeout, cfg_e1_line_connect_timeout_cmd,
+ "e1_line <0-255> connect-timeout <0-60>",
+ E1_LINE_HELP "Set connect timeout\n" "Connect timeout in seconds (0 to disable)\n",
+ CMD_ATTR_IMMEDIATE)
+{
+ struct e1inp_line *line;
+ int e1_nr = atoi(argv[0]);
+ unsigned int timeout = atoi(argv[1]);
+
+ line = e1inp_line_find(e1_nr);
+ if (!line) {
+ vty_out(vty, "%% Line %d doesn't exist%s", e1_nr, VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ line->connect_timeout = timeout;
+
+ return CMD_SUCCESS;
+}
+
+
DEFUN_ATTR(cfg_e1line_pcap, cfg_e1line_pcap_cmd,
"e1_line <0-255> pcap .FILE",
E1_LINE_HELP "Setup a pcap recording of E1 traffic for line\n"
@@ -376,6 +396,9 @@
if (line->name)
vty_out(vty, " e1_line %u name %s%s", line->num,
line->name, VTY_NEWLINE);
+ if (line->connect_timeout != 0)
+ vty_out(vty, " e1_line %u connect-timeout %u%s", line->num, line->connect_timeout,
+ VTY_NEWLINE);
if (!line->keepalive_num_probes)
vty_out(vty, " no e1_line %u keepalive%s", line->num,
VTY_NEWLINE);
@@ -563,6 +586,7 @@
install_lib_element(L_E1INP_NODE, &cfg_e1_line_port_cmd);
install_lib_element(L_E1INP_NODE, &cfg_e1_line_socket_cmd);
install_lib_element(L_E1INP_NODE, &cfg_e1_line_name_cmd);
+ install_lib_element(L_E1INP_NODE, &cfg_e1_line_connect_timeout_cmd);
install_lib_element(L_E1INP_NODE, &cfg_e1_line_keepalive_cmd);
install_lib_element(L_E1INP_NODE, &cfg_e1_line_keepalive_params_cmd);
install_lib_element(L_E1INP_NODE, &cfg_e1_line_no_keepalive_cmd);
diff --git a/src/input/ipaccess.c b/src/input/ipaccess.c
index 44c1b78..8a52591 100644
--- a/src/input/ipaccess.c
+++ b/src/input/ipaccess.c
@@ -1124,7 +1124,7 @@
}
link->dscp = g_e1inp_ipaccess_pars.oml.dscp;
link->priority = g_e1inp_ipaccess_pars.oml.priority;
- if (ipa_client_conn_open(link) < 0) {
+ if (ipa_client_conn_open2(link, line->connect_timeout) < 0) {
LOGP(DLINP, LOGL_ERROR, "cannot open OML BTS link: %s\n",
strerror(errno));
ipa_client_conn_close(link);
@@ -1191,7 +1191,7 @@
}
rsl_link->dscp = g_e1inp_ipaccess_pars.rsl.dscp;
rsl_link->priority = g_e1inp_ipaccess_pars.rsl.priority;
- if (ipa_client_conn_open(rsl_link) < 0) {
+ if (ipa_client_conn_open2(rsl_link, line->connect_timeout) < 0) {
LOGP(DLINP, LOGL_ERROR, "cannot open RSL BTS link: %s\n",
strerror(errno));
ipa_client_conn_close(rsl_link);