From 6859de09d2ae0e363070e152489d9f8579085aa8 Mon Sep 17 00:00:00 2001 From: Neels Janosch Hofmeyr Date: Fri, 16 Aug 2024 00:47:53 +0200 Subject: [PATCH] upf gtp-u echo: rx Echo Response messages Support receiving of Echo Responses, so far showed an error log for unsupported message type. Just log the message. Prep for upcoming patch to allow sending Echo Requests from VTY. Change-Id: Idad417746a1ea797e8fbfe04ca9c84923a6118fa --- src/osmo-upf/upf_gtpu_echo.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/osmo-upf/upf_gtpu_echo.c b/src/osmo-upf/upf_gtpu_echo.c index d8958e8..b234065 100644 --- a/src/osmo-upf/upf_gtpu_echo.c +++ b/src/osmo-upf/upf_gtpu_echo.c @@ -65,6 +65,21 @@ static int rx_echo_req(struct upf_gtp_dev *dev, const struct osmo_sockaddr *remo return tx_echo_resp(dev, remote, rx_h->ext.seq_nr); } +static void rx_echo_resp(struct upf_gtp_dev *dev, const struct osmo_sockaddr *remote, const struct gtp1u_hdr *rx_h, + size_t msg_len) +{ + if (msg_len < (sizeof(*rx_h) + 2)) { + LOG_GTP_DEV(dev, LOGL_ERROR, + "<- %s: rx GTPv1-U Echo Response, but message is too short (%zu < %zu)\n", + osmo_sockaddr_to_str_c(OTC_SELECT, remote), msg_len, (sizeof(*rx_h) + 2)); + return; + } + + uint8_t recovery_count = rx_h->data2[1]; + LOG_GTP_DEV(dev, LOGL_INFO, "<- %s: rx GTPv1-U Echo Response: seq_nr=%u recovery_count=%u\n", + osmo_sockaddr_to_str(remote), rx_h->ext.seq_nr, recovery_count); +} + static int tx_echo_resp(struct upf_gtp_dev *dev, const struct osmo_sockaddr *remote, uint16_t seq_nr) { struct msgb *msg; @@ -153,6 +168,9 @@ int upf_gtpu_echo_read_cb(struct osmo_fd *ofd, unsigned int what) switch (h->msg_type) { case GTP1U_MSGTYPE_ECHO_REQ: return rx_echo_req(dev, &remote, h, sz); + case GTP1U_MSGTYPE_ECHO_RSP: + rx_echo_resp(dev, &remote, h, sz); + return 0; default: LOG_GTP_DEV(dev, LOGL_ERROR, "rx: GTPv1-U message type %u not supported\n", h->msg_type); return -1;