From abecf789261e53bdb99a0ab275008e4d8f65cb6d Mon Sep 17 00:00:00 2001 From: Neels Janosch Hofmeyr Date: Sat, 26 Nov 2022 02:58:08 +0100 Subject: [PATCH] osmo_pfcp_ip_addrs_set(): do not set port number struct osmo_pfcp_ip_addrs uses an osmo_sockaddr for storing IP addresses. Even though osmo_sockaddr contains a port number, no port number gets encoded in PFCP messages. Hence always set the port to 0. I noticed that when osmo_pfcp_ip_addrs_set() is invoked with an osmo_sockaddr that incidentally has a port number set, subsequent logging of e.g. a PFCP F-TEID shows a port number, which is confusing. Change-Id: Ib29a123c06d459c99d7c1c0b9a7694fb78cd9fd8 --- src/libosmo-pfcp/pfcp_msg.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libosmo-pfcp/pfcp_msg.c b/src/libosmo-pfcp/pfcp_msg.c index ff8860a..18b9113 100644 --- a/src/libosmo-pfcp/pfcp_msg.c +++ b/src/libosmo-pfcp/pfcp_msg.c @@ -494,16 +494,20 @@ uint64_t osmo_pfcp_next_seid(uint64_t *next_seid_state) return *next_seid_state; } +/* Set either dst->v4 or dst->v6 to addr, depending on addr->family. Set the IP address to addr and port to 0, not + * copying the port information from addr. Return zero on success, negative on error (i.e. no known family in addr). */ int osmo_pfcp_ip_addrs_set(struct osmo_pfcp_ip_addrs *dst, const struct osmo_sockaddr *addr) { switch (addr->u.sas.ss_family) { case AF_INET: dst->v4_present = true; dst->v4 = *addr; + osmo_sockaddr_set_port(&dst->v4.u.sa, 0); return 0; case AF_INET6: dst->v6_present = true; dst->v6 = *addr; + osmo_sockaddr_set_port(&dst->v6.u.sa, 0); return 0; default: return -ENOTSUP;