pespin submitted this change.

View Change

Approvals: pespin: Looks good to me, approved Jenkins Builder: Verified
client: Avoid sending link frame over non-connected conn

Otherwise error messages appear upon start when starting the capture and
the conns haven't yet been established (they are started immediately
afterwards in main.c).
The errors are actually harmless since network code takes care of
sending a link frame upon connection TCP/TLS handshake completes.

Change-Id: I091523e1d9f644e97b114b4cc524307a83dd564f
---
M include/osmo-pcap/osmo_pcap_client.h
M src/osmo_client_core.c
M src/osmo_client_network.c
3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/include/osmo-pcap/osmo_pcap_client.h b/include/osmo-pcap/osmo_pcap_client.h
index fdd59f9..fc65132 100644
--- a/include/osmo-pcap/osmo_pcap_client.h
+++ b/include/osmo-pcap/osmo_pcap_client.h
@@ -149,6 +149,7 @@
void osmo_client_conn_connect(struct osmo_pcap_client_conn *conn);
void osmo_client_conn_disconnect(struct osmo_pcap_client_conn *conn);
void osmo_client_conn_reconnect(struct osmo_pcap_client_conn *conn);
+bool osmo_client_conn_is_connected(const struct osmo_pcap_client_conn *conn);


struct osmo_pcap_handle *osmo_pcap_handle_alloc(struct osmo_pcap_client *client, const char *devname);
diff --git a/src/osmo_client_core.c b/src/osmo_client_core.c
index dd16878..7df14ca 100644
--- a/src/osmo_client_core.c
+++ b/src/osmo_client_core.c
@@ -277,8 +277,10 @@
return rc;
}

+ /* Restart already initialized pcap files to adapt for new capture parameters: */
llist_for_each_entry(conn, &client->conns, entry)
- osmo_client_conn_send_link(conn);
+ if (osmo_client_conn_is_connected(conn))
+ osmo_client_conn_send_link(conn);
return 0;
}

diff --git a/src/osmo_client_network.c b/src/osmo_client_network.c
index c4a9623..4b91429 100644
--- a/src/osmo_client_network.c
+++ b/src/osmo_client_network.c
@@ -605,3 +605,17 @@
}
}
}
+
+bool osmo_client_conn_is_connected(const struct osmo_pcap_client_conn *conn)
+{
+ if (conn->tls_on) {
+ /* No socket yet. */
+ if (conn->wqueue.bfd.fd < 0)
+ return false; /* No socket yet. */
+ if (conn->wqueue.bfd.cb == conn_cb_tls)
+ return false; /* Still doing TLS handshake */
+ return true;
+ }
+
+ return conn->cli && osmo_stream_cli_is_connected(conn->cli);
+}

To view, visit change 39945. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: merged
Gerrit-Project: osmo-pcap
Gerrit-Branch: master
Gerrit-Change-Id: I091523e1d9f644e97b114b4cc524307a83dd564f
Gerrit-Change-Number: 39945
Gerrit-PatchSet: 6
Gerrit-Owner: pespin <pespin@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: osmith <osmith@sysmocom.de>
Gerrit-Reviewer: pespin <pespin@sysmocom.de>