7 Commits

Author SHA1 Message Date
Neels Hofmeyr
f49790f8c8 contrib: add osmo-upf-tunend.gtplab2.cfg 2024-09-10 05:46:38 +02:00
Neels Janosch Hofmeyr
6859de09d2 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
2024-08-16 02:20:44 +02:00
Neels Janosch Hofmeyr
5ac599ce17 upf gtp-u echo: improve loging
Tweak GTPv1-U Echo logging to more consistently show logging like:

DGTP INFO apn11 [23] 127.0.0.11:2152: <- 127.0.0.12:2152: rx GTPv1-U Echo Request: seq_nr=123 recovery_count=131
DGTP INFO apn11 [23] 127.0.0.11:2152: -> 127.0.0.12:2152: tx GTPv1-U Echo Response: seq_nr=123 recovery_count=570

Change-Id: I3c7fe7c3eb1467ae34085da6bbf26a935a6c927b
2024-08-16 02:20:44 +02:00
Neels Janosch Hofmeyr
33061164f3 contrib/pfcp-tool-scripts: adjust tunend_session_est.vty and upf cfg to match up
Change-Id: I3d6a26b45f084c281887bee541cf01b690c9d1de
2024-08-16 02:20:44 +02:00
Neels Janosch Hofmeyr
62e0f7e135 drop unreachable statement
Change-Id: I0710fd0e38a5ce26ac532ab7150e285f171accfb
2024-08-16 02:20:44 +02:00
Neels Janosch Hofmeyr
58a9c167b3 fix EXTRA_DIST for vty test scripts
Like e.g. in osmo-msc.git, osmo-bsc.git, use wildcard $(srcdir)/*.vty to
make sure we never forget to distribute committed VTY test scripts.

Change-Id: If4dca81ce287ce1b1af32057634af912a8b89665
2024-08-16 02:20:44 +02:00
Neels Janosch Hofmeyr
7bd92c13aa fix msgb memleak on GTP echo response
Change-Id: I2bd2e9c57bf392074eed9628a69eb710d4e459a6
2024-08-16 02:20:44 +02:00
5 changed files with 77 additions and 20 deletions

View File

@@ -23,3 +23,7 @@ pfcp
local-addr 127.0.0.12
tunmap
table-name osmo-upf-12
# gtp-dev only for GTP-U Echo service
tunend
dev create gtp-echo-12 127.0.0.12

View File

@@ -0,0 +1,25 @@
log stderr
logging filter all 1
logging color 1
logging print category-hex 0
logging print category 1
logging timestamp 0
logging print file basename last
logging print level 1
logging level set-all notice
logging level set-all info
logging level session debug
logging level nft debug
logging level gtp debug
#logging level set-all debug
line vty
bind 127.0.0.2
ctrl
bind 127.0.0.2
timer pfcp x24 5000
pfcp
local-addr 172.16.32.2
tunend
dev create apn2 172.16.32.2

View File

@@ -1,5 +1,5 @@
timer pfcp x23 0
pfcp-peer 127.0.0.1
pfcp-peer 127.0.0.11
tx assoc-setup-req
sleep 1
session tunend

View File

@@ -50,23 +50,43 @@ struct gtp1u_hdr {
static int tx_echo_resp(struct upf_gtp_dev *dev, const struct osmo_sockaddr *remote, uint16_t seq_nr);
static int rx_echo_req(struct upf_gtp_dev *dev, const struct osmo_sockaddr *remote, const struct gtp1u_hdr *rx_h)
static int rx_echo_req(struct upf_gtp_dev *dev, const struct osmo_sockaddr *remote, const struct gtp1u_hdr *rx_h,
size_t msg_len)
{
if (!rx_h->s) {
LOG_GTP_DEV(dev, LOGL_ERROR, "rx GTPv1-U ECHO REQ without sequence nr\n");
return -1;
}
uint16_t seq_nr = 0;
uint8_t recovery_count = 0;
if (msg_len >= (sizeof(*rx_h) + 2) && rx_h->data2[0] == GTP1U_IEI_RECOVERY)
recovery_count = rx_h->data2[1];
seq_nr = rx_h->s;
LOG_GTP_DEV(dev, LOGL_INFO, "<- %s: rx GTPv1-U Echo Request: seq_nr=%u recovery_count=%u\n",
osmo_sockaddr_to_str(remote), seq_nr, recovery_count);
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;
struct gtp1u_hdr *tx_h;
int rc;
msg = msgb_alloc_headroom(1024, 128, "GTP-echo-resp");
msg = msgb_alloc_headroom(1024, 128, "GTPv1-U-echo-resp");
tx_h = (void *)msgb_put(msg, sizeof(*tx_h));
*tx_h = (struct gtp1u_hdr){
@@ -90,10 +110,15 @@ static int tx_echo_resp(struct upf_gtp_dev *dev, const struct osmo_sockaddr *rem
rc = sendto(dev->gtpv1.ofd.fd, msgb_data(msg), msgb_length(msg), 0, &remote->u.sa, sizeof(*remote));
if (rc < 0) {
int err = errno;
LOG_GTP_DEV(dev, LOGL_ERROR, "GTP1-U sendto(len=%d, to=%s): %s\n", msgb_length(msg),
osmo_sockaddr_to_str(remote), strerror(err));
rc = -errno;
LOG_GTP_DEV(dev, LOGL_ERROR, "-> %s: tx GTPv1-U Echo Response: sendto(len=%d): %s\n",
osmo_sockaddr_to_str(remote), msgb_length(msg), strerror(-rc));
} else {
LOG_GTP_DEV(dev, LOGL_INFO, "-> %s: tx GTPv1-U Echo Response: seq_nr=%u recovery_count=%u\n",
osmo_sockaddr_to_str(remote), seq_nr, g_upf->tunend.recovery_count);
rc = 0;
}
msgb_free(msg);
return rc;
}
@@ -120,39 +145,42 @@ int upf_gtpu_echo_read_cb(struct osmo_fd *ofd, unsigned int what)
/* A GTPv1-U header of size 8 is valid, but this code expects to handle only ECHO REQUEST messages. These are
* required to have a sequence number, hence this check here consciously uses the full sizeof(*h) == 12. */
if (sz < sizeof(*h)) {
LOG_GTP_DEV(dev, LOGL_ERROR, "rx GTP packet smaller than the GTPv1-U header + sequence nr: %zd < %zu\n",
sz, sizeof(*h));
LOG_GTP_DEV(dev, LOGL_ERROR,
"<- %s: rx GTPv1-U packet smaller than the GTPv1-U header + sequence nr: %zd < %zu\n",
osmo_sockaddr_to_str(&remote), sz, sizeof(*h));
return -1;
}
h = (const struct gtp1u_hdr *)buf;
if (h->version != 1) {
LOG_GTP_DEV(dev, LOGL_ERROR, "rx GTP v%u: only GTP version 1 supported\n", h->version);
LOG_GTP_DEV(dev, LOGL_ERROR, "<- %s: rx GTPv1-U v%u: only GTP version 1 supported\n",
osmo_sockaddr_to_str(&remote), h->version);
return -1;
}
h_length = osmo_load16be(&h->length);
if (offsetof(struct gtp1u_hdr, data1) + h_length > sz) {
LOG_GTP_DEV(dev, LOGL_ERROR, "rx GTP: header + h.length = %zu > received bytes = %zd\n",
offsetof(struct gtp1u_hdr, data1) + h_length, sz);
LOG_GTP_DEV(dev, LOGL_ERROR, "<- %s: rx GTPv1-U: header + h.length = %zu > received bytes = %zd\n",
osmo_sockaddr_to_str(&remote), offsetof(struct gtp1u_hdr, data1) + h_length, sz);
return -1;
}
switch (h->msg_type) {
case GTP1U_MSGTYPE_ECHO_REQ:
return rx_echo_req(dev, &remote, h);
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;
}
return 0;
}
int upf_gtpu_echo_setup(struct upf_gtp_dev *dev)
{
if (dev->gtpv1.ofd.fd == -1) {
LOGP(DGTP, LOGL_ERROR, "Cannot setup GTP-U ECHO: GTP-v1 socket not initialized\n");
LOGP(DGTP, LOGL_ERROR, "Cannot setup GTPv1-U ECHO: socket not initialized\n");
return -EINVAL;
}

View File

@@ -21,7 +21,7 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac
} >'$(srcdir)/package.m4'
EXTRA_DIST = \
upf.vty \
$(srcdir)/*.vty \
testsuite.at \
$(srcdir)/package.m4 \
$(TESTSUITE) \