fix coding of Network Instance IE

Network instance names should be coded like in DNS, where each label is
preceded by a length byte.

Related: SYS#6192
Change-Id: I9d67464ef0f92b0512cfd6e48d203f8828a82a19
This commit is contained in:
Neels Hofmeyr 2022-12-01 03:05:58 +01:00
parent 2ee6a68045
commit 9110daf27f
8 changed files with 25 additions and 8 deletions

View File

@ -7,3 +7,4 @@
# If any interfaces have been added since the last public release: c:r:a + 1. # If any interfaces have been added since the last public release: c:r:a + 1.
# If any interfaces have been removed or changed since the last public release: c:r:0. # If any interfaces have been removed or changed since the last public release: c:r:0.
#library what description / commit summary line #library what description / commit summary line
libosmo-pfcp libosmogsm>=1.7.0 libosmo-pfcp now uses API from libosmogsm (from libosmocore.git)

View File

@ -38,6 +38,7 @@ PKG_PROG_PKG_CONFIG([0.20])
dnl checks for libraries dnl checks for libraries
PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.7.0) PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.7.0)
PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 1.7.0)
dnl checks for header files dnl checks for header files
AC_HEADER_STDC AC_HEADER_STDC

View File

@ -12,6 +12,7 @@ BuildRequires: libtool >= 2
BuildRequires: lksctp-tools-devel BuildRequires: lksctp-tools-devel
BuildRequires: pkgconfig >= 0.20 BuildRequires: pkgconfig >= 0.20
BuildRequires: pkgconfig(libosmocore) >= 1.7.0 BuildRequires: pkgconfig(libosmocore) >= 1.7.0
BuildRequires: pkgconfig(libosmogsm) >= 1.7.0
BuildRequires: pkgconfig(talloc) BuildRequires: pkgconfig(talloc)
%description %description

1
debian/control vendored
View File

@ -11,6 +11,7 @@ Build-Depends: debhelper (>=10),
libtool, libtool,
pkg-config, pkg-config,
libosmocore-dev (>= 1.7.0), libosmocore-dev (>= 1.7.0),
libosmogsm-dev (>= 1.7.0),
libtalloc-dev (>= 2.1.0) libtalloc-dev (>= 2.1.0)
Standards-Version: 3.9.8 Standards-Version: 3.9.8
Vcs-Git: https://gitea.osmocom.org/osmocom/libosmo-pfcp Vcs-Git: https://gitea.osmocom.org/osmocom/libosmo-pfcp

View File

@ -9,12 +9,14 @@ AM_CPPFLAGS = \
AM_CFLAGS = \ AM_CFLAGS = \
-Wall \ -Wall \
$(LIBOSMOCORE_CFLAGS) \ $(LIBOSMOCORE_CFLAGS) \
$(LIBOSMOGSM_CFLAGS) \
$(LIBOSMOVTY_CFLAGS) \ $(LIBOSMOVTY_CFLAGS) \
$(COVERAGE_CFLAGS) \ $(COVERAGE_CFLAGS) \
$(NULL) $(NULL)
AM_LDFLAGS = \ AM_LDFLAGS = \
$(LIBOSMOCORE_LIBS) \ $(LIBOSMOCORE_LIBS) \
$(LIBOSMOGSM_LIBS) \
$(LIBOSMOVTY_LIBS) \ $(LIBOSMOVTY_LIBS) \
$(COVERAGE_LDFLAGS) \ $(COVERAGE_LDFLAGS) \
$(NULL) $(NULL)

View File

@ -29,6 +29,7 @@
#include <osmocom/core/logging.h> #include <osmocom/core/logging.h>
#include <osmocom/core/utils.h> #include <osmocom/core/utils.h>
#include <osmocom/core/msgb.h> #include <osmocom/core/msgb.h>
#include <osmocom/gsm/apn.h>
#include <osmocom/gtlv/gtlv.h> #include <osmocom/gtlv/gtlv.h>
@ -698,16 +699,24 @@ int osmo_pfcp_enc_to_str_apply_action(char *buf, size_t buflen, const void *enco
int osmo_pfcp_dec_network_inst(void *decoded_struct, void *decode_to, const struct osmo_gtlv_load *tlv) int osmo_pfcp_dec_network_inst(void *decoded_struct, void *decode_to, const struct osmo_gtlv_load *tlv)
{ {
struct osmo_pfcp_ie_network_inst *network_inst = decode_to; struct osmo_pfcp_ie_network_inst *network_inst = decode_to;
osmo_strlcpy(network_inst->str, (const char *)tlv->val, OSMO_MIN(sizeof(network_inst->str), tlv->len+1));
if (tlv->len < 1 || sizeof(network_inst->str) < tlv->len)
RETURN_ERROR(-EINVAL, "Network Instance value part is too long");
if (osmo_apn_to_str(network_inst->str, tlv->val, tlv->len) == NULL)
RETURN_ERROR(-EINVAL, "decoding qname (RFC 1035 4.1.2) failed");
return 0; return 0;
} }
int osmo_pfcp_enc_network_inst(struct osmo_gtlv_put *tlv, const void *decoded_struct, const void *encode_from) int osmo_pfcp_enc_network_inst(struct osmo_gtlv_put *tlv, const void *decoded_struct, const void *encode_from)
{ {
const struct osmo_pfcp_ie_network_inst *network_inst = encode_from; const struct osmo_pfcp_ie_network_inst *network_inst = encode_from;
unsigned int l = strlen(network_inst->str); int rc;
if (l)
memcpy(msgb_put(tlv->dst, l), network_inst->str, l); rc = osmo_apn_from_str(tlv->dst->tail, msgb_tailroom(tlv->dst), network_inst->str);
if (rc <= 0)
RETURN_ERROR(rc ? : -EINVAL, "encoding qname (RFC 1035 4.1.2) from '%s' failed",
(const char *)encode_from);
msgb_put(tlv->dst, rc);
return 0; return 0;
} }

View File

@ -7,6 +7,7 @@ AM_CPPFLAGS = \
AM_CFLAGS = \ AM_CFLAGS = \
-Wall \ -Wall \
$(LIBOSMOCORE_CFLAGS) \ $(LIBOSMOCORE_CFLAGS) \
$(LIBOSMOGSM_CFLAGS) \
$(NULL) $(NULL)
check_PROGRAMS = \ check_PROGRAMS = \
@ -24,6 +25,7 @@ pfcp_test_SOURCES = \
pfcp_test_LDADD = \ pfcp_test_LDADD = \
$(top_builddir)/src/libosmo-pfcp/libosmo-pfcp.la \ $(top_builddir)/src/libosmo-pfcp/libosmo-pfcp.la \
$(top_builddir)/src/libosmo-gtlv/libosmo-gtlv.la \ $(top_builddir)/src/libosmo-gtlv/libosmo-gtlv.la \
$(LIBOSMOGSM_LIBS) \
$(LIBOSMOCORE_LIBS) \ $(LIBOSMOCORE_LIBS) \
$(NULL) $(NULL)

View File

@ -69,8 +69,8 @@ parsed == orig
encoding: SESSION_EST_REQ encoding: SESSION_EST_REQ
PFCPv1 SESSION_EST_REQ hdr={seq=7 SEID=0x0} ies={ 'Node ID'=v4:127.0.0.1 'F-SEID'=0x1234567890abcdef,v4:10.9.8.7 'Create PDR'={ { 'PDR ID'=1 'Precedence'=255 'PDI'={ 'Source Interface'=Core 'Network Instance'="foo" 'UE IP Address'=,dst,v4:192.168.0.23 } 'FAR ID'=1 }, { 'PDR ID'=2 'Precedence'=255 'PDI'={ 'Source Interface'=Access 'F-TEID'=CHOOSE-v4 'Network Instance'="bar" } 'Outer Header Removal'=GTP_U_UDP_IPV4 'FAR ID'=2 } } 'Create FAR'={ { 'FAR ID'=1 'Apply Action'=( FORW ) 'Forwarding Parameters'={ 'Destination Interface'=Access 'Outer Header Creation'=( GTP_U_UDP_IPV4 ),TEID:0xabcdef,v4:10.9.8.7 } }, { 'FAR ID'=2 'Apply Action'=( FORW ) 'Forwarding Parameters'={ 'Destination Interface'=Core } } } } PFCPv1 SESSION_EST_REQ hdr={seq=7 SEID=0x0} ies={ 'Node ID'=v4:127.0.0.1 'F-SEID'=0x1234567890abcdef,v4:10.9.8.7 'Create PDR'={ { 'PDR ID'=1 'Precedence'=255 'PDI'={ 'Source Interface'=Core 'Network Instance'="foo" 'UE IP Address'=,dst,v4:192.168.0.23 } 'FAR ID'=1 }, { 'PDR ID'=2 'Precedence'=255 'PDI'={ 'Source Interface'=Access 'F-TEID'=CHOOSE-v4 'Network Instance'="bar" } 'Outer Header Removal'=GTP_U_UDP_IPV4 'FAR ID'=2 } } 'Create FAR'={ { 'FAR ID'=1 'Apply Action'=( FORW ) 'Forwarding Parameters'={ 'Destination Interface'=Access 'Outer Header Creation'=( GTP_U_UDP_IPV4 ),TEID:0xabcdef,v4:10.9.8.7 } }, { 'FAR ID'=2 'Apply Action'=( FORW ) 'Forwarding Parameters'={ 'Destination Interface'=Core } } } }
osmo_pfcp_msg_encode() rc = 0 osmo_pfcp_msg_encode() rc = 0
21 32 00 d1 00 00 00 00 00 00 00 00 00 00 07 00 00 3c 00 05 00 7f 00 00 01 00 39 00 0d 02 12 34 56 78 90 ab cd ef 0a 09 08 07 00 01 00 2f 00 38 00 02 00 01 00 1d 00 04 00 00 00 ff 00 02 00 15 00 14 00 01 01 00 16 00 03 66 6f 6f 00 5d 00 05 06 c0 a8 00 17 00 6c 00 04 00 00 00 01 00 01 00 30 00 38 00 02 00 02 00 1d 00 04 00 00 00 ff 00 02 00 11 00 14 00 01 00 00 15 00 01 05 00 16 00 03 62 61 72 00 5f 00 01 00 00 6c 00 04 00 00 00 02 00 03 00 25 00 6c 00 04 00 00 00 01 00 2c 00 02 02 00 00 04 00 13 00 2a 00 01 00 00 54 00 0a 01 00 00 ab cd ef 0a 09 08 07 00 03 00 17 00 6c 00 04 00 00 00 02 00 2c 00 02 02 00 00 04 00 05 00 2a 00 01 01 . 21 32 00 d3 00 00 00 00 00 00 00 00 00 00 07 00 00 3c 00 05 00 7f 00 00 01 00 39 00 0d 02 12 34 56 78 90 ab cd ef 0a 09 08 07 00 01 00 30 00 38 00 02 00 01 00 1d 00 04 00 00 00 ff 00 02 00 16 00 14 00 01 01 00 16 00 04 03 66 6f 6f 00 5d 00 05 06 c0 a8 00 17 00 6c 00 04 00 00 00 01 00 01 00 31 00 38 00 02 00 02 00 1d 00 04 00 00 00 ff 00 02 00 12 00 14 00 01 00 00 15 00 01 05 00 16 00 04 03 62 61 72 00 5f 00 01 00 00 6c 00 04 00 00 00 02 00 03 00 25 00 6c 00 04 00 00 00 01 00 2c 00 02 02 00 00 04 00 13 00 2a 00 01 00 00 54 00 0a 01 00 00 ab cd ef 0a 09 08 07 00 03 00 17 00 6c 00 04 00 00 00 02 00 2c 00 02 02 00 00 04 00 05 00 2a 00 01 01 .
osmo_pfcp_msg_decode_header() rc = 213 osmo_pfcp_msg_decode_header() rc = 215
rc == msgb_length() rc == msgb_length()
osmo_pfcp_msg_decode_tlv() rc = 0 osmo_pfcp_msg_decode_tlv() rc = 0
parsed == orig parsed == orig
@ -91,8 +91,8 @@ parsed == orig
encoding: SESSION_MOD_REQ encoding: SESSION_MOD_REQ
PFCPv1 SESSION_MOD_REQ hdr={seq=9 SEID=0x0} ies={ 'Remove PDR'={ { 'PDR ID'=1 } } 'Remove FAR'={ { 'FAR ID'=1 } } 'Create PDR'={ { 'PDR ID'=3 'Precedence'=255 'PDI'={ 'Source Interface'=Access 'F-TEID'=CHOOSE-v4 'Network Instance'="baz" } 'Outer Header Removal'=GTP_U_UDP_IPV4 'FAR ID'=3 } } 'Create FAR'={ { 'FAR ID'=3 'Apply Action'=( FORW ) 'Forwarding Parameters'={ 'Destination Interface'=Access 'Outer Header Creation'=( GTP_U_UDP_IPV4 ),TEID:0xabcdef,v4:10.9.8.7 } } } 'Update PDR'={ { 'PDR ID'=1 'Outer Header Removal'=GTP_U_UDP_IPV4 'PDI'={ 'Source Interface'=Access 'F-TEID'=CHOOSE-v4 'Network Instance'="moo" } 'FAR ID'=1 } } 'Update FAR'={ { 'FAR ID'=1 'Update Forwarding Parameters'={ 'Network Instance'="internet" } } } } PFCPv1 SESSION_MOD_REQ hdr={seq=9 SEID=0x0} ies={ 'Remove PDR'={ { 'PDR ID'=1 } } 'Remove FAR'={ { 'FAR ID'=1 } } 'Create PDR'={ { 'PDR ID'=3 'Precedence'=255 'PDI'={ 'Source Interface'=Access 'F-TEID'=CHOOSE-v4 'Network Instance'="baz" } 'Outer Header Removal'=GTP_U_UDP_IPV4 'FAR ID'=3 } } 'Create FAR'={ { 'FAR ID'=3 'Apply Action'=( FORW ) 'Forwarding Parameters'={ 'Destination Interface'=Access 'Outer Header Creation'=( GTP_U_UDP_IPV4 ),TEID:0xabcdef,v4:10.9.8.7 } } } 'Update PDR'={ { 'PDR ID'=1 'Outer Header Removal'=GTP_U_UDP_IPV4 'PDI'={ 'Source Interface'=Access 'F-TEID'=CHOOSE-v4 'Network Instance'="moo" } 'FAR ID'=1 } } 'Update FAR'={ { 'FAR ID'=1 'Update Forwarding Parameters'={ 'Network Instance'="internet" } } } }
osmo_pfcp_msg_encode() rc = 0 osmo_pfcp_msg_encode() rc = 0
21 34 00 c7 00 00 00 00 00 00 00 00 00 00 09 00 00 0f 00 06 00 38 00 02 00 01 00 10 00 08 00 6c 00 04 00 00 00 01 00 01 00 30 00 38 00 02 00 03 00 1d 00 04 00 00 00 ff 00 02 00 11 00 14 00 01 00 00 15 00 01 05 00 16 00 03 62 61 7a 00 5f 00 01 00 00 6c 00 04 00 00 00 03 00 03 00 25 00 6c 00 04 00 00 00 03 00 2c 00 02 02 00 00 04 00 13 00 2a 00 01 00 00 54 00 0a 01 00 00 ab cd ef 0a 09 08 07 00 09 00 28 00 38 00 02 00 01 00 5f 00 01 00 00 02 00 11 00 14 00 01 00 00 15 00 01 05 00 16 00 03 6d 6f 6f 00 6c 00 04 00 00 00 01 00 0a 00 18 00 6c 00 04 00 00 00 01 00 0b 00 0c 00 16 00 08 69 6e 74 65 72 6e 65 74 . 21 34 00 ca 00 00 00 00 00 00 00 00 00 00 09 00 00 0f 00 06 00 38 00 02 00 01 00 10 00 08 00 6c 00 04 00 00 00 01 00 01 00 31 00 38 00 02 00 03 00 1d 00 04 00 00 00 ff 00 02 00 12 00 14 00 01 00 00 15 00 01 05 00 16 00 04 03 62 61 7a 00 5f 00 01 00 00 6c 00 04 00 00 00 03 00 03 00 25 00 6c 00 04 00 00 00 03 00 2c 00 02 02 00 00 04 00 13 00 2a 00 01 00 00 54 00 0a 01 00 00 ab cd ef 0a 09 08 07 00 09 00 29 00 38 00 02 00 01 00 5f 00 01 00 00 02 00 12 00 14 00 01 00 00 15 00 01 05 00 16 00 04 03 6d 6f 6f 00 6c 00 04 00 00 00 01 00 0a 00 19 00 6c 00 04 00 00 00 01 00 0b 00 0d 00 16 00 09 08 69 6e 74 65 72 6e 65 74 .
osmo_pfcp_msg_decode_header() rc = 203 osmo_pfcp_msg_decode_header() rc = 206
rc == msgb_length() rc == msgb_length()
osmo_pfcp_msg_decode_tlv() rc = 0 osmo_pfcp_msg_decode_tlv() rc = 0
parsed == orig parsed == orig