lists.osmocom.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

gerrit-log

Thread Start a new thread
Download
Threads by month
  • ----- 2026 -----
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2025 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
gerrit-log@lists.osmocom.org

April 2025

  • 1 participants
  • 1186 discussions
[XS] Change in osmo-pcap[master]: server: vty: Fix writing config max-snaplen param
by pespin 07 Apr '25

07 Apr '25
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-pcap/+/39946?usp=email ) Change subject: server: vty: Fix writing config max-snaplen param ...................................................................... server: vty: Fix writing config max-snaplen param Change-Id: I2cb5e9f28e3d8ab0d35a37629968d0fb9460e843 --- M src/osmo_server_vty.c 1 file changed, 1 insertion(+), 1 deletion(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/src/osmo_server_vty.c b/src/osmo_server_vty.c index 0a86633..dfe9857 100644 --- a/src/osmo_server_vty.c +++ b/src/osmo_server_vty.c @@ -119,7 +119,7 @@ else vty_out(vty, " no max-file-size%s", VTY_NEWLINE); if (pcap_server->max_snaplen != DEFAULT_SNAPLEN) - vty_out(vty, " server max-snaplen %d%s", pcap_server->max_snaplen, VTY_NEWLINE); + vty_out(vty, " max-snaplen %d%s", pcap_server->max_snaplen, VTY_NEWLINE); if (pcap_server->zmq_port > 0) vty_out(vty, " zeromq-publisher %s %d%s", pcap_server->zmq_ip, pcap_server->zmq_port, VTY_NEWLINE); -- To view, visit https://gerrit.osmocom.org/c/osmo-pcap/+/39946?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-pcap Gerrit-Branch: master Gerrit-Change-Id: I2cb5e9f28e3d8ab0d35a37629968d0fb9460e843 Gerrit-Change-Number: 39946 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
1 0
0 0
[XS] Change in osmo-pcap[master]: server: vty: Fix writing config max-snaplen param
by laforge 07 Apr '25

07 Apr '25
Attention is currently required from: pespin. laforge has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/osmo-pcap/+/39946?usp=email ) Change subject: server: vty: Fix writing config max-snaplen param ...................................................................... Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/osmo-pcap/+/39946?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: osmo-pcap Gerrit-Branch: master Gerrit-Change-Id: I2cb5e9f28e3d8ab0d35a37629968d0fb9460e843 Gerrit-Change-Number: 39946 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Mon, 07 Apr 2025 21:31:39 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes
1 0
0 0
[XS] Change in osmo-ci[master]: jobs/ttcn3-testsuites-testenv: Add ttcn3-pcap-client-test-io_uring
by laforge 07 Apr '25

07 Apr '25
Attention is currently required from: osmith, pespin. laforge has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/osmo-ci/+/39943?usp=email ) Change subject: jobs/ttcn3-testsuites-testenv: Add ttcn3-pcap-client-test-io_uring ...................................................................... Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/osmo-ci/+/39943?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: osmo-ci Gerrit-Branch: master Gerrit-Change-Id: I817b4d27cd2e8faabf2ebb5ad28f025535571282 Gerrit-Change-Number: 39943 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Attention: osmith <osmith(a)sysmocom.de> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Mon, 07 Apr 2025 21:31:29 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes
1 0
0 0
[XS] Change in osmo-pcap[master]: server: vty: Fix writing config max-snaplen param
by pespin 07 Apr '25

07 Apr '25
pespin has uploaded a new patch set (#2). ( https://gerrit.osmocom.org/c/osmo-pcap/+/39946?usp=email ) Change subject: server: vty: Fix writing config max-snaplen param ...................................................................... server: vty: Fix writing config max-snaplen param Change-Id: I2cb5e9f28e3d8ab0d35a37629968d0fb9460e843 --- M src/osmo_server_vty.c 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcap refs/changes/46/39946/2 -- To view, visit https://gerrit.osmocom.org/c/osmo-pcap/+/39946?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newpatchset Gerrit-Project: osmo-pcap Gerrit-Branch: master Gerrit-Change-Id: I2cb5e9f28e3d8ab0d35a37629968d0fb9460e843 Gerrit-Change-Number: 39946 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-CC: Jenkins Builder
1 0
0 0
[XS] Change in osmo-pcap[master]: client: Process up to 10 recorded pkts per poll iteration
by pespin 07 Apr '25

07 Apr '25
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-pcap/+/39949?usp=email ) Change subject: client: Process up to 10 recorded pkts per poll iteration ...................................................................... client: Process up to 10 recorded pkts per poll iteration This should decrease CPU use of lipcap capturing under high capturing load, which is welcome now that we support osmo_io with io-uring backend on the Tx side towards osmo-pcap-server. The processing number is kept low in order to avoid starving the event loop, as well as avoid filling up the msgb queue of the Tx side towards osmo-pcap-server. Related: SYS#7290 Change-Id: I569fc8489bae2b829ef4040d3c5111a61129de68 --- M src/osmo_client_core.c 1 file changed, 3 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcap refs/changes/49/39949/1 diff --git a/src/osmo_client_core.c b/src/osmo_client_core.c index 5ded001..11236bf 100644 --- a/src/osmo_client_core.c +++ b/src/osmo_client_core.c @@ -175,7 +175,9 @@ struct osmo_pcap_handle *ph = fd->data; int rc; - rc = pcap_dispatch(ph->handle, 1, pcap_read_one_cb, (u_char *)ph); + /* Read up to 10 packets at once, to avoid starving the event loop and + * filling up transmit queue towards peer. */ + rc = pcap_dispatch(ph->handle, 10, pcap_read_one_cb, (u_char *)ph); if (rc < 0) { rate_ctr_inc2(ph->ctrg, PH_CTR_PERR); rate_ctr_inc2(ph->client->ctrg, CLIENT_CTR_PERR); -- To view, visit https://gerrit.osmocom.org/c/osmo-pcap/+/39949?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-pcap Gerrit-Branch: master Gerrit-Change-Id: I569fc8489bae2b829ef4040d3c5111a61129de68 Gerrit-Change-Number: 39949 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de>
1 0
0 0
[XS] Change in osmo-pcap[master]: client: constify args in can_forward_packet()
by pespin 07 Apr '25

07 Apr '25
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-pcap/+/39947?usp=email ) Change subject: client: constify args in can_forward_packet() ...................................................................... client: constify args in can_forward_packet() Change-Id: I3568b962fea7d0e34b68f75cea7b59b1df158238 --- M src/osmo_client_core.c 1 file changed, 3 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcap refs/changes/47/39947/1 diff --git a/src/osmo_client_core.c b/src/osmo_client_core.c index 7df14ca..62b2c3c 100644 --- a/src/osmo_client_core.c +++ b/src/osmo_client_core.c @@ -101,9 +101,9 @@ } static int can_forward_packet( - struct osmo_pcap_client *client, - struct osmo_pcap_handle *ph, - struct pcap_pkthdr *hdr, + const struct osmo_pcap_client *client, + const struct osmo_pcap_handle *ph, + const struct pcap_pkthdr *hdr, const u_char *data) { int ll_type; -- To view, visit https://gerrit.osmocom.org/c/osmo-pcap/+/39947?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-pcap Gerrit-Branch: master Gerrit-Change-Id: I3568b962fea7d0e34b68f75cea7b59b1df158238 Gerrit-Change-Number: 39947 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de>
1 0
0 0
[XS] Change in osmo-pcap[master]: server: vty: Fix writing config max-snaplent param
by pespin 07 Apr '25

07 Apr '25
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-pcap/+/39946?usp=email ) Change subject: server: vty: Fix writing config max-snaplent param ...................................................................... server: vty: Fix writing config max-snaplent param Change-Id: I2cb5e9f28e3d8ab0d35a37629968d0fb9460e843 --- M src/osmo_server_vty.c 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcap refs/changes/46/39946/1 diff --git a/src/osmo_server_vty.c b/src/osmo_server_vty.c index 0a86633..dfe9857 100644 --- a/src/osmo_server_vty.c +++ b/src/osmo_server_vty.c @@ -119,7 +119,7 @@ else vty_out(vty, " no max-file-size%s", VTY_NEWLINE); if (pcap_server->max_snaplen != DEFAULT_SNAPLEN) - vty_out(vty, " server max-snaplen %d%s", pcap_server->max_snaplen, VTY_NEWLINE); + vty_out(vty, " max-snaplen %d%s", pcap_server->max_snaplen, VTY_NEWLINE); if (pcap_server->zmq_port > 0) vty_out(vty, " zeromq-publisher %s %d%s", pcap_server->zmq_ip, pcap_server->zmq_port, VTY_NEWLINE); -- To view, visit https://gerrit.osmocom.org/c/osmo-pcap/+/39946?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-pcap Gerrit-Branch: master Gerrit-Change-Id: I2cb5e9f28e3d8ab0d35a37629968d0fb9460e843 Gerrit-Change-Number: 39946 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de>
1 0
0 0
[S] Change in osmo-pcap[master]: client: use pcap_dispatch to avoid extra pkt buffer copy
by pespin 07 Apr '25

07 Apr '25
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-pcap/+/39948?usp=email ) Change subject: client: use pcap_dispatch to avoid extra pkt buffer copy ...................................................................... client: use pcap_dispatch to avoid extra pkt buffer copy pcap_next() allows use of returned buffer until next time the same API is called. In order to do so, it internally calls pcap_dispatch() with an internal handler (in the case of linux pcapint_oneshot_linux()). That handler basically memcpy()s the pkt buffer obtained in the pcap_dispatch callback into a temporary static buffer which is then returned. We don't need any of that here, and by using pcap_dispatch() directly (as recommended in pcapint_oneshot_linux() function documentation) we can skip an extra memcpy() of each packet buffer captured. Furthermore, it will allow us processing multiple packets from the captured queue (RA_SOCKET+mmap implementation in linux) in one poll iteration if several packets have been captured. This will be done in a follow-up patch. pcap handle is marked non-blocking to allow polling from it without ending up blocked. Applying filter is moved beforehand, as seen in libpcap capturetest example. Related: SYS#7290 Change-Id: I055efb66fac5e04c541d75ec2c0f654cdfb17838 --- M src/osmo_client_core.c 1 file changed, 28 insertions(+), 14 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcap refs/changes/48/39948/1 diff --git a/src/osmo_client_core.c b/src/osmo_client_core.c index 62b2c3c..5ded001 100644 --- a/src/osmo_client_core.c +++ b/src/osmo_client_core.c @@ -152,27 +152,36 @@ return check_gprs(payload_data, payload_len); } +static void pcap_read_one_cb(u_char *user, const struct pcap_pkthdr *hdr, const u_char *data) +{ + struct osmo_pcap_handle *ph = (struct osmo_pcap_handle *)user; + struct osmo_pcap_client *client = ph->client; + struct osmo_pcap_client_conn *conn; + + /* NOTE: hdr & data are only available during the call of this callback, + * and should be copied somewhere else if need be accessed later. + * In here we are fine since we generate a msgb and copy over the + * content on each loop iteration below. */ + + if (!can_forward_packet(client, ph, hdr, data)) + return; + + llist_for_each_entry(conn, &client->conns, entry) + osmo_client_conn_send_data(conn, ph, hdr, data); +} static int pcap_read_cb(struct osmo_fd *fd, unsigned int what) { struct osmo_pcap_handle *ph = fd->data; - struct osmo_pcap_client *client = ph->client; - struct osmo_pcap_client_conn *conn; - struct pcap_pkthdr hdr; - const u_char *data; + int rc; - data = pcap_next(ph->handle, &hdr); - if (!data) { + rc = pcap_dispatch(ph->handle, 1, pcap_read_one_cb, (u_char *)ph); + if (rc < 0) { rate_ctr_inc2(ph->ctrg, PH_CTR_PERR); - rate_ctr_inc2(client->ctrg, CLIENT_CTR_PERR); + rate_ctr_inc2(ph->client->ctrg, CLIENT_CTR_PERR); return -1; } - if (!can_forward_packet(client, ph, &hdr, data)) - return 0; - - llist_for_each_entry(conn, &client->conns, entry) - osmo_client_conn_send_data(conn, ph, &hdr, data); return 0; } @@ -440,6 +449,7 @@ struct osmo_pcap_client *client = ph->client; int fd; char errbuf[PCAP_ERRBUF_SIZE]; + int one = 1; LOGPH(ph, LOGL_INFO, "Opening device for capture with snaplen %zu\n", (size_t) client->snaplen); ph->handle = pcap_open_live(ph->devname, client->snaplen, 0, 1000, errbuf); @@ -448,6 +458,12 @@ return -2; } + if (client->filter_string) + osmo_pcap_handle_install_filter(ph); + + if (pcap_setnonblock(ph->handle, one, errbuf) == -1) + LOGPH(ph, LOGL_ERROR, "Failed pcap_setnonblock(): %s\n", errbuf); + fd = pcap_fileno(ph->handle); if (fd == -1) { LOGPH(ph, LOGL_ERROR, "No file descriptor provided.\n"); @@ -463,7 +479,5 @@ osmo_timer_setup(&ph->pcap_stat_timer, pcap_check_stats_cb, ph); pcap_check_stats_cb(ph); - if (client->filter_string) - osmo_pcap_handle_install_filter(ph); return 0; } -- To view, visit https://gerrit.osmocom.org/c/osmo-pcap/+/39948?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-pcap Gerrit-Branch: master Gerrit-Change-Id: I055efb66fac5e04c541d75ec2c0f654cdfb17838 Gerrit-Change-Number: 39948 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de>
1 0
0 0
[S] Change in osmo-pcap[master]: client: Avoid sending link frame over non-connected conn
by pespin 07 Apr '25

07 Apr '25
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-pcap/+/39945?usp=email ) Change subject: client: Avoid sending link frame over non-connected conn ...................................................................... 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(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcap refs/changes/45/39945/1 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 412fe56..73eccac 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) + return false; /* Still doing TLS handshake */ + return true; + } + + return conn->cli && osmo_stream_cli_is_connected(conn->cli); +} -- To view, visit https://gerrit.osmocom.org/c/osmo-pcap/+/39945?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-pcap Gerrit-Branch: master Gerrit-Change-Id: I091523e1d9f644e97b114b4cc524307a83dd564f Gerrit-Change-Number: 39945 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de>
1 0
0 0
[M] Change in osmo-pcap[master]: client: use osmo_stream_cli to transmit data to pcap-server
by pespin 07 Apr '25

07 Apr '25
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-pcap/+/39944?usp=email ) Change subject: client: use osmo_stream_cli to transmit data to pcap-server ...................................................................... client: use osmo_stream_cli to transmit data to pcap-server Similarly to previous work done in osmo-pcap-server, the switch to osmo_stream doesn't cover the TLS-enabled scenario, since moving TLS related code to osmo_stream requires significant amount of work and can be done in a subsequent step. Related: SYS#7290 Change-Id: I72e8a6ceb4fb1eb70372e13bb139ead0e2bc0860 --- M include/osmo-pcap/osmo_pcap_client.h M src/Makefile.am M src/osmo_client_network.c M src/osmo_client_vty.c 4 files changed, 143 insertions(+), 35 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcap refs/changes/44/39944/1 diff --git a/include/osmo-pcap/osmo_pcap_client.h b/include/osmo-pcap/osmo_pcap_client.h index 1b66488..fdd59f9 100644 --- a/include/osmo-pcap/osmo_pcap_client.h +++ b/include/osmo-pcap/osmo_pcap_client.h @@ -70,7 +70,7 @@ char *srv_ip; int srv_port; char *source_ip; - struct osmo_wqueue wqueue; + struct osmo_stream_cli *cli; struct osmo_timer_list timer; enum osmo_pcap_protocol protocol; @@ -87,6 +87,7 @@ unsigned tls_log_level; struct osmo_tls_session tls_session; + struct osmo_wqueue wqueue; /* back pointer */ struct osmo_pcap_client *client; diff --git a/src/Makefile.am b/src/Makefile.am index 504952f..b45bf84 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -26,6 +26,7 @@ $(NULL) osmo_pcap_client_LDADD = \ + $(LIBOSMONETIF_LIBS) \ $(LIBOSMOGSM_LIBS) \ $(LIBOSMOVTY_LIBS) \ $(LIBOSMOCORE_LIBS) \ diff --git a/src/osmo_client_network.c b/src/osmo_client_network.c index abdb7d3..412fe56 100644 --- a/src/osmo_client_network.c +++ b/src/osmo_client_network.c @@ -32,6 +32,8 @@ #include <osmocom/core/select.h> #include <osmocom/core/socket.h> +#include <osmocom/netif/stream.h> + #include <arpa/inet.h> #include <netinet/in.h> #include <netdb.h> @@ -61,13 +63,26 @@ static void write_data(struct osmo_pcap_client_conn *conn, struct msgb *msg) { - if (osmo_wqueue_enqueue_quiet(&conn->wqueue, msg) != 0) { - LOGCONN(conn, LOGL_ERROR, "Failed to enqueue msg (capacity: %u/%u)\n", - conn->wqueue.current_length, conn->wqueue.max_length); + if (conn->tls_on) { + if (osmo_wqueue_enqueue_quiet(&conn->wqueue, msg) != 0) { + LOGCONN(conn, LOGL_ERROR, "Failed to enqueue msg (capacity: %u/%u)\n", + conn->wqueue.current_length, conn->wqueue.max_length); + rate_ctr_inc2(conn->client->ctrg, CLIENT_CTR_QERR); + msgb_free(msg); + } + return; + } + + if (!conn->cli) { + LOGCONN(conn, LOGL_NOTICE, "Failed to enqueue msg (no stream)\n"); rate_ctr_inc2(conn->client->ctrg, CLIENT_CTR_QERR); msgb_free(msg); return; } + osmo_stream_cli_send(conn->cli, msg); + /* FIXME: osmo_stream_cli_send() doesn't have a rc, hence we cannot never increment on error: + * rate_ctr_inc2(conn->client->ctrg, CLIENT_CTR_QERR); + */ } static int read_cb(struct osmo_fd *fd) @@ -128,22 +143,15 @@ * The write queue needs to work differently for GNUtls. Before we can * send data we will need to complete handshake. */ - if (conn->tls_on) { - if (!osmo_tls_init_client_session(conn)) { - lost_connection(conn); - return -1; - } - conn->tls_session.handshake_done = handshake_done_cb; - conn->tls_session.error = tls_error_cb; - - /* fd->data now points somewhere else, stop */ - return 0; - } else { - conn->wqueue.bfd.cb = osmo_wqueue_bfd_cb; - conn->wqueue.bfd.data = conn; - osmo_wqueue_clear(&conn->wqueue); - osmo_client_conn_send_link(conn); + if (!osmo_tls_init_client_session(conn)) { + lost_connection(conn); + return -1; } + conn->tls_session.handshake_done = handshake_done_cb; + conn->tls_session.error = tls_error_cb; + + /* fd->data now points somewhere else, stop */ + return 0; } if (what & OSMO_FD_READ) @@ -446,15 +454,13 @@ write_data(conn, msg); } -void osmo_client_conn_connect(struct osmo_pcap_client_conn *conn) +static void osmo_client_conn_connect_tls(struct osmo_pcap_client_conn *conn) { int rc; uint16_t srv_port; int sock_type, sock_proto; unsigned int when; - osmo_client_conn_disconnect(conn); - conn->wqueue.read_cb = read_cb; conn->wqueue.write_cb = write_cb; osmo_wqueue_clear(&conn->wqueue); @@ -490,6 +496,91 @@ rate_ctr_inc2(conn->client->ctrg, CLIENT_CTR_CONNECT); } +static int stream_cli_connect_cb(struct osmo_stream_cli *cli) +{ + struct osmo_pcap_client_conn *conn = osmo_stream_cli_get_data(cli); + osmo_client_conn_send_link(conn); + return 0; +} + +static int stream_cli_disconnect_cb(struct osmo_stream_cli *cli) +{ + struct osmo_pcap_client_conn *conn = osmo_stream_cli_get_data(cli); + lost_connection(conn); + return 0; +} + +static int stream_cli_read_cb(struct osmo_stream_cli *cli, int res, struct msgb *msg) +{ + struct osmo_pcap_client_conn *conn = osmo_stream_cli_get_data(cli); + + msgb_free(msg); + if (res <= 0) { + LOGCONN(conn, LOGL_ERROR, "Lost connection on read\n"); + lost_connection(conn); + } + return 0; +} + +void osmo_client_conn_connect(struct osmo_pcap_client_conn *conn) +{ + uint16_t srv_port; + int sock_type, sock_proto; + struct osmo_stream_cli *cli; + + osmo_client_conn_disconnect(conn); + + /* We still don't support the tls layer through osmo_stream... */ + if (conn->tls_on) { + osmo_client_conn_connect_tls(conn); + return; + } + + switch (conn->protocol) { + case PROTOCOL_OSMOPCAP: + srv_port = conn->srv_port; + sock_type = SOCK_STREAM; + sock_proto = IPPROTO_TCP; + break; + case PROTOCOL_IPIP: + srv_port = 0; + sock_type = SOCK_RAW; + sock_proto = IPPROTO_IPIP; + break; + default: + OSMO_ASSERT(0); + break; + } + + OSMO_ASSERT(!conn->cli); + conn->cli = cli = osmo_stream_cli_create(conn); + osmo_stream_cli_set_name(cli, conn->name); + osmo_stream_cli_set_data(cli, conn); + osmo_stream_cli_set_type(cli, sock_type); + osmo_stream_cli_set_proto(cli, sock_proto); + osmo_stream_cli_set_local_addr(cli, conn->source_ip); + osmo_stream_cli_set_local_port(cli, 0); + osmo_stream_cli_set_addr(cli, conn->srv_ip); + osmo_stream_cli_set_port(cli, srv_port); + osmo_stream_cli_set_nodelay(cli, true); + osmo_stream_cli_set_tx_queue_max_length(cli, conn->wqueue.max_length); + + /* Reconnect is handled by upper layers: */ + osmo_stream_cli_set_reconnect_timeout(cli, -1); + osmo_stream_cli_set_connect_cb(cli, stream_cli_connect_cb); + osmo_stream_cli_set_disconnect_cb(cli, stream_cli_disconnect_cb); + osmo_stream_cli_set_read_cb2(cli, stream_cli_read_cb); + + if (osmo_stream_cli_open(cli)) { + LOGCONN(conn, LOGL_ERROR, "cannot open OML BTS link: %s\n", strerror(errno)); + conn->cli = NULL; + osmo_stream_cli_destroy(cli); + return; + } + + rate_ctr_inc2(conn->client->ctrg, CLIENT_CTR_CONNECT); +} + void osmo_client_conn_reconnect(struct osmo_pcap_client_conn *conn) { lost_connection(conn); @@ -497,12 +588,20 @@ void osmo_client_conn_disconnect(struct osmo_pcap_client_conn *conn) { - if (conn->wqueue.bfd.fd >= 0) { - osmo_tls_release(&conn->tls_session); - osmo_fd_unregister(&conn->wqueue.bfd); - close(conn->wqueue.bfd.fd); - conn->wqueue.bfd.fd = -1; - } - osmo_timer_del(&conn->timer); + + if (conn->tls_on) { + if (conn->wqueue.bfd.fd >= 0) { + osmo_tls_release(&conn->tls_session); + osmo_fd_unregister(&conn->wqueue.bfd); + close(conn->wqueue.bfd.fd); + conn->wqueue.bfd.fd = -1; + } + } else { + if (conn->cli) { + struct osmo_stream_cli *cli = conn->cli; + conn->cli = NULL; + osmo_stream_cli_destroy(cli); + } + } } diff --git a/src/osmo_client_vty.c b/src/osmo_client_vty.c index 1824324..127e52f 100644 --- a/src/osmo_client_vty.c +++ b/src/osmo_client_vty.c @@ -25,6 +25,7 @@ #include <osmo-pcap/common.h> #include <osmocom/core/talloc.h> +#include <osmocom/netif/stream.h> #include <stdlib.h> @@ -262,12 +263,12 @@ { struct osmo_pcap_client_conn *conn = get_conn(vty); - if (!conn->tls_on) { - if (conn->wqueue.bfd.fd >= 0) - osmo_client_conn_reconnect(conn); - } + if (conn->tls_on) + return CMD_SUCCESS; + osmo_client_conn_disconnect(conn); conn->tls_on = true; + osmo_client_conn_connect(conn); return CMD_SUCCESS; } @@ -278,10 +279,12 @@ { struct osmo_pcap_client_conn *conn = get_conn(vty); - if (conn->tls_on) - osmo_client_conn_reconnect(conn); + if (!conn->tls_on) + return CMD_SUCCESS; + osmo_client_conn_disconnect(conn); conn->tls_on = false; + osmo_client_conn_connect(conn); return CMD_SUCCESS; } @@ -568,6 +571,10 @@ struct osmo_pcap_client_conn *conn = get_conn(vty); conn->wqueue.max_length = atoi(argv[0]); + /* Apply on conn immediately if already created: */ + if (conn->cli) + osmo_stream_cli_set_tx_queue_max_length(conn->cli, conn->wqueue.max_length); + return CMD_SUCCESS; } -- To view, visit https://gerrit.osmocom.org/c/osmo-pcap/+/39944?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-pcap Gerrit-Branch: master Gerrit-Change-Id: I72e8a6ceb4fb1eb70372e13bb139ead0e2bc0860 Gerrit-Change-Number: 39944 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de>
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • ...
  • 119
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.