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

December 2022

  • 1 participants
  • 1979 discussions
Change in libosmo-pfcp[master]: tweak comment in pfcp_ies_custom.c
by fixeria 01 Dec '22

01 Dec '22
Attention is currently required from: neels. fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-pfcp/+/30404 ) Change subject: tweak comment in pfcp_ies_custom.c ...................................................................... Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/libosmo-pfcp/+/30404 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-pfcp Gerrit-Branch: master Gerrit-Change-Id: I1530939cc63369668d2f3e5a126912713c06d0c1 Gerrit-Change-Number: 30404 Gerrit-PatchSet: 1 Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Attention: neels <nhofmeyr(a)sysmocom.de> Gerrit-Comment-Date: Thu, 01 Dec 2022 05:44:22 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
Change in libosmo-pfcp[master]: add osmo_pfcp_ie_outer_header_creation_to_str_*()
by fixeria 01 Dec '22

01 Dec '22
Attention is currently required from: neels. fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-pfcp/+/30403 ) Change subject: add osmo_pfcp_ie_outer_header_creation_to_str_*() ...................................................................... Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/libosmo-pfcp/+/30403 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-pfcp Gerrit-Branch: master Gerrit-Change-Id: I4ad1570485c8081b82284e4e6b4de4d7eed414b0 Gerrit-Change-Number: 30403 Gerrit-PatchSet: 1 Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Attention: neels <nhofmeyr(a)sysmocom.de> Gerrit-Comment-Date: Thu, 01 Dec 2022 05:44:06 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
Change in libosmo-pfcp[master]: bitmask to string: shorten
by neels 01 Dec '22

01 Dec '22
Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/libosmo-pfcp/+/30408 to look at the new patch set (#2). Change subject: bitmask to string: shorten ...................................................................... bitmask to string: shorten Remove braces and spaces from PFCP bits to string conversion. Instead of "( FOO BAR BAZ )", print "FOO+BAR+BAZ". Instead of "( FORW )", print "FORW". Instead of "( )", print "-". The spaces tend to break up readability of strings logged by osmo-upf. In particular, this affects UP and CP capability bits, Apply Action, Outer Header Creation. Change-Id: I38426d6381e96d4a683e46eba1bdd29c73d3f027 --- M src/libosmo-pfcp/pfcp_ies_custom.c M tests/libosmo-pfcp/pfcp_test.ok 2 files changed, 8 insertions(+), 6 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-pfcp refs/changes/08/30408/2 -- To view, visit https://gerrit.osmocom.org/c/libosmo-pfcp/+/30408 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-pfcp Gerrit-Branch: master Gerrit-Change-Id: I38426d6381e96d4a683e46eba1bdd29c73d3f027 Gerrit-Change-Number: 30408 Gerrit-PatchSet: 2 Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-MessageType: newpatchset
1 0
0 0
Change in libosmo-pfcp[master]: fix coding of Node ID: FQDN type
by neels 01 Dec '22

01 Dec '22
neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-pfcp/+/30407 ) Change subject: fix coding of Node ID: FQDN type ...................................................................... fix coding of Node ID: FQDN type Decode FQDN type Node IDs into "human" dotted notation instead of storing the DNS type data in the FQDN string. Related: OS#5806 Change-Id: I25d0f9b095287aa30e24498d8361c0a326ded447 --- M src/libosmo-pfcp/pfcp_ies_custom.c M tests/libosmo-pfcp/pfcp_test.ok 2 files changed, 12 insertions(+), 7 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-pfcp refs/changes/07/30407/1 diff --git a/src/libosmo-pfcp/pfcp_ies_custom.c b/src/libosmo-pfcp/pfcp_ies_custom.c index ac1f6f0..8da3420 100644 --- a/src/libosmo-pfcp/pfcp_ies_custom.c +++ b/src/libosmo-pfcp/pfcp_ies_custom.c @@ -379,6 +379,7 @@ const void *ip; unsigned int ip_len; unsigned int want_len; + int rc; ENSURE_LENGTH_IS_AT_LEAST(1); node_id->type = *(uint8_t *)tlv->val; ip = &tlv->val[1]; @@ -400,8 +401,9 @@ osmo_sockaddr_from_octets(&node_id->ip, ip, ip_len); break; case OSMO_PFCP_NODE_ID_T_FQDN: - /* Copy and add a trailing nul */ - OSMO_STRLCPY_ARRAY(node_id->fqdn, ip); + rc = qname_decode(node_id->fqdn, sizeof(node_id->fqdn), ip, ip_len); + if (rc <= 0) + RETURN_ERROR(rc ? : -EINVAL, "Invalid FQDN in Node ID"); break; default: RETURN_ERROR(-EINVAL, "Invalid Node ID Type: %d", node_id->type); @@ -413,6 +415,7 @@ { unsigned int l; const struct osmo_pfcp_ie_node_id *node_id = encode_from; + int rc; msgb_put_u8(tlv->dst, node_id->type); switch (node_id->type) { case OSMO_PFCP_NODE_ID_T_IPV4: @@ -424,9 +427,11 @@ osmo_sockaddr_to_octets(msgb_put(tlv->dst, l), l, &node_id->ip); break; case OSMO_PFCP_NODE_ID_T_FQDN: - l = strnlen(node_id->fqdn, sizeof(node_id->fqdn)); - /* Copy without trailing nul */ - memcpy((char *)msgb_put(tlv->dst, l), node_id->fqdn, l); + rc = qname_encode(tlv->dst->tail, msgb_tailroom(tlv->dst), node_id->fqdn); + if (rc <= 0) + RETURN_ERROR(rc ? : -EINVAL, "Encoding Node ID FQDN from '%s' failed", + (const char *)encode_from); + msgb_put(tlv->dst, rc); break; default: RETURN_ERROR(-EINVAL, "Invalid Node ID Type: %d", node_id->type); diff --git a/tests/libosmo-pfcp/pfcp_test.ok b/tests/libosmo-pfcp/pfcp_test.ok index 02424cd..73e05a5 100644 --- a/tests/libosmo-pfcp/pfcp_test.ok +++ b/tests/libosmo-pfcp/pfcp_test.ok @@ -36,8 +36,8 @@ encoding: ASSOC_SETUP_RESP PFCPv1 ASSOC_SETUP_RESP hdr={seq=4} ies={ 'Node ID'=fqdn:"example.com" 'Cause'=Request accepted (success) 'Recovery Time Stamp'=724249387 'UP Function Features'=( BUCP PDIU ) } osmo_pfcp_msg_encode() rc = 0 -20 06 00 2b 00 00 04 00 00 3c 00 0c 02 65 78 61 6d 70 6c 65 2e 63 6f 6d 00 13 00 01 01 00 60 00 04 2b 2b 2b 2b 00 2b 00 06 01 02 00 00 00 00 . -osmo_pfcp_msg_decode_header() rc = 47 +20 06 00 2c 00 00 04 00 00 3c 00 0d 02 07 65 78 61 6d 70 6c 65 03 63 6f 6d 00 13 00 01 01 00 60 00 04 2b 2b 2b 2b 00 2b 00 06 01 02 00 00 00 00 . +osmo_pfcp_msg_decode_header() rc = 48 rc == msgb_length() osmo_pfcp_msg_decode_tlv() rc = 0 parsed == orig -- To view, visit https://gerrit.osmocom.org/c/libosmo-pfcp/+/30407 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-pfcp Gerrit-Branch: master Gerrit-Change-Id: I25d0f9b095287aa30e24498d8361c0a326ded447 Gerrit-Change-Number: 30407 Gerrit-PatchSet: 1 Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
Change in libosmo-pfcp[master]: bitmask to string: shorten
by neels 01 Dec '22

01 Dec '22
neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-pfcp/+/30408 ) Change subject: bitmask to string: shorten ...................................................................... bitmask to string: shorten Remove braces and spaces from PFCP bits to string conversion. Instead of "( FOO BAR BAZ )", print "FOO+BAR+BAZ". Instead of "( FORW )", print "FORW". The spaces tend to break up readability of strings logged by osmo-upf. In particular, this affects UP and CP capability bits, Apply Action, Outer Header Creation. Change-Id: I38426d6381e96d4a683e46eba1bdd29c73d3f027 --- M src/libosmo-pfcp/pfcp_ies_custom.c M tests/libosmo-pfcp/pfcp_test.ok 2 files changed, 6 insertions(+), 6 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-pfcp refs/changes/08/30408/1 diff --git a/src/libosmo-pfcp/pfcp_ies_custom.c b/src/libosmo-pfcp/pfcp_ies_custom.c index 8da3420..f8266ec 100644 --- a/src/libosmo-pfcp/pfcp_ies_custom.c +++ b/src/libosmo-pfcp/pfcp_ies_custom.c @@ -496,13 +496,13 @@ int osmo_pfcp_bits_to_str_buf(char *buf, size_t buflen, const uint8_t *bits, const struct value_string *bit_strs) { struct osmo_strbuf sb = { .buf = buf, .len = buflen }; - OSMO_STRBUF_PRINTF(sb, "("); + bool first = true; for (; bit_strs->str; bit_strs++) { if (osmo_pfcp_bits_get(bits, bit_strs->value)) { - OSMO_STRBUF_PRINTF(sb, " %s", bit_strs->str); + OSMO_STRBUF_PRINTF(sb, "%s%s", first ? "" : "+", bit_strs->str); + first = false; } } - OSMO_STRBUF_PRINTF(sb, " )"); return sb.chars_needed; } diff --git a/tests/libosmo-pfcp/pfcp_test.ok b/tests/libosmo-pfcp/pfcp_test.ok index 73e05a5..6111fab 100644 --- a/tests/libosmo-pfcp/pfcp_test.ok +++ b/tests/libosmo-pfcp/pfcp_test.ok @@ -34,7 +34,7 @@ === start test_enc_dec[3] encoding: ASSOC_SETUP_RESP -PFCPv1 ASSOC_SETUP_RESP hdr={seq=4} ies={ 'Node ID'=fqdn:"example.com" 'Cause'=Request accepted (success) 'Recovery Time Stamp'=724249387 'UP Function Features'=( BUCP PDIU ) } +PFCPv1 ASSOC_SETUP_RESP hdr={seq=4} ies={ 'Node ID'=fqdn:"example.com" 'Cause'=Request accepted (success) 'Recovery Time Stamp'=724249387 'UP Function Features'=BUCP+PDIU } osmo_pfcp_msg_encode() rc = 0 20 06 00 2c 00 00 04 00 00 3c 00 0d 02 07 65 78 61 6d 70 6c 65 03 63 6f 6d 00 13 00 01 01 00 60 00 04 2b 2b 2b 2b 00 2b 00 06 01 02 00 00 00 00 . osmo_pfcp_msg_decode_header() rc = 48 @@ -67,7 +67,7 @@ === start test_enc_dec[6] 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 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 = 215 @@ -89,7 +89,7 @@ === start test_enc_dec[8] 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 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 = 206 -- To view, visit https://gerrit.osmocom.org/c/libosmo-pfcp/+/30408 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-pfcp Gerrit-Branch: master Gerrit-Change-Id: I38426d6381e96d4a683e46eba1bdd29c73d3f027 Gerrit-Change-Number: 30408 Gerrit-PatchSet: 1 Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
Change in libosmo-pfcp[master]: tweak comment in pfcp_ies_custom.c
by neels 01 Dec '22

01 Dec '22
neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-pfcp/+/30404 ) Change subject: tweak comment in pfcp_ies_custom.c ...................................................................... tweak comment in pfcp_ies_custom.c Change-Id: I1530939cc63369668d2f3e5a126912713c06d0c1 --- M src/libosmo-pfcp/pfcp_ies_custom.c 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-pfcp refs/changes/04/30404/1 diff --git a/src/libosmo-pfcp/pfcp_ies_custom.c b/src/libosmo-pfcp/pfcp_ies_custom.c index 06b7494..3531e02 100644 --- a/src/libosmo-pfcp/pfcp_ies_custom.c +++ b/src/libosmo-pfcp/pfcp_ies_custom.c @@ -36,7 +36,7 @@ #include <osmocom/pfcp/pfcp_strs.h> #include <osmocom/pfcp/pfcp_msg.h> -/* Assumes presence of local variable osmo_pfcp_msg *m. m->log_ctx may be NULL. */ +/* Assumes presence of local variable decoded_struct to derive osmo_pfcp_msg* from. m->log_ctx may be NULL. */ #define RETURN_ERROR(RC, FMT, ARGS...) \ do {\ OSMO_ASSERT(decoded_struct); \ -- To view, visit https://gerrit.osmocom.org/c/libosmo-pfcp/+/30404 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-pfcp Gerrit-Branch: master Gerrit-Change-Id: I1530939cc63369668d2f3e5a126912713c06d0c1 Gerrit-Change-Number: 30404 Gerrit-PatchSet: 1 Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
Change in libosmo-pfcp[master]: pfcp coding errmsgs: drop extra newlines
by neels 01 Dec '22

01 Dec '22
neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-pfcp/+/30405 ) Change subject: pfcp coding errmsgs: drop extra newlines ...................................................................... pfcp coding errmsgs: drop extra newlines Change-Id: I4eea1efc9bd67676b6202e50d41974b2717a2511 --- M src/libosmo-pfcp/pfcp_ies_custom.c 1 file changed, 6 insertions(+), 6 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-pfcp refs/changes/05/30405/1 diff --git a/src/libosmo-pfcp/pfcp_ies_custom.c b/src/libosmo-pfcp/pfcp_ies_custom.c index 3531e02..1891902 100644 --- a/src/libosmo-pfcp/pfcp_ies_custom.c +++ b/src/libosmo-pfcp/pfcp_ies_custom.c @@ -813,42 +813,42 @@ s_tag = osmo_pfcp_bits_get(ohc->desc_bits, OSMO_PFCP_OUTER_HEADER_CREATION_S_TAG); if ((gtp_u_udp_ipv4 || gtp_u_udp_ipv6) != (ohc->teid_present)) - RETURN_ERROR(-EINVAL, "teid_present = %s does not match the description bits 0x%02x\n", + RETURN_ERROR(-EINVAL, "teid_present = %s does not match the description bits 0x%02x", ohc->teid_present ? "true" : "false", ohc->desc_bits[0]); if (ohc->teid_present) msgb_put_u32(tlv->dst, ohc->teid); if ((gtp_u_udp_ipv4 || udp_ipv4 || ipv4) != ohc->ip_addr.v4_present) - RETURN_ERROR(-EINVAL, "ipv4_addr_present = %s does not match the description bits 0x%02x\n", + RETURN_ERROR(-EINVAL, "ipv4_addr_present = %s does not match the description bits 0x%02x", ohc->ip_addr.v4_present ? "true" : "false", ohc->desc_bits[0]); if (ohc->ip_addr.v4_present) osmo_sockaddr_to_octets(msgb_put(tlv->dst, 4), 4, &ohc->ip_addr.v4); if ((gtp_u_udp_ipv6 || udp_ipv6 || ipv6) != ohc->ip_addr.v6_present) - RETURN_ERROR(-EINVAL, "ipv6_addr_present = %s does not match the description bits 0x%02x\n", + RETURN_ERROR(-EINVAL, "ipv6_addr_present = %s does not match the description bits 0x%02x", ohc->ip_addr.v6_present ? "true" : "false", ohc->desc_bits[0]); if (ohc->ip_addr.v6_present) osmo_sockaddr_to_octets(msgb_put(tlv->dst, 16), 16, &ohc->ip_addr.v6); if ((udp_ipv4 || udp_ipv6) != ohc->port_number_present) - RETURN_ERROR(-EINVAL, "port_number_present = %s does not match the description bits 0x%02x\n", + RETURN_ERROR(-EINVAL, "port_number_present = %s does not match the description bits 0x%02x", ohc->port_number_present ? "true" : "false", ohc->desc_bits[0]); if (ohc->port_number_present) msgb_put_u16(tlv->dst, ohc->port_number); if (c_tag != ohc->c_tag_present) - RETURN_ERROR(-EINVAL, "c_tag_present = %s does not match the description bits 0x%02x%02x\n", + RETURN_ERROR(-EINVAL, "c_tag_present = %s does not match the description bits 0x%02x%02x", ohc->c_tag_present ? "true" : "false", ohc->desc_bits[1], ohc->desc_bits[0]); if (ohc->c_tag_present) osmo_store32be_ext(ohc->c_tag, msgb_put(tlv->dst, 3), 3); if (s_tag != ohc->s_tag_present) - RETURN_ERROR(-EINVAL, "s_tag_present = %s does not match the description bits 0x%02x%02x\n", + RETURN_ERROR(-EINVAL, "s_tag_present = %s does not match the description bits 0x%02x%02x", ohc->s_tag_present ? "true" : "false", ohc->desc_bits[1], ohc->desc_bits[0]); if (ohc->s_tag_present) -- To view, visit https://gerrit.osmocom.org/c/libosmo-pfcp/+/30405 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-pfcp Gerrit-Branch: master Gerrit-Change-Id: I4eea1efc9bd67676b6202e50d41974b2717a2511 Gerrit-Change-Number: 30405 Gerrit-PatchSet: 1 Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
Change in libosmo-pfcp[master]: fix coding of Network Instance IE
by neels 01 Dec '22

01 Dec '22
neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-pfcp/+/30406 ) Change subject: fix coding of Network Instance IE ...................................................................... fix coding of Network Instance IE Network instance names should be coded like in DNS, where each label is preceded by a length byte. Add static functions to converting between dotted and DNS notation. These qualify for moving to libosmocore utils, but giving them a spin here in libosmo-pfcp first (main aim is to speed up the fix now). Related: SYS#6192 Change-Id: I9d67464ef0f92b0512cfd6e48d203f8828a82a19 --- M src/libosmo-pfcp/pfcp_ies_custom.c M tests/libosmo-pfcp/pfcp_test.ok 2 files changed, 107 insertions(+), 8 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-pfcp refs/changes/06/30406/1 diff --git a/src/libosmo-pfcp/pfcp_ies_custom.c b/src/libosmo-pfcp/pfcp_ies_custom.c index 1891902..ac1f6f0 100644 --- a/src/libosmo-pfcp/pfcp_ies_custom.c +++ b/src/libosmo-pfcp/pfcp_ies_custom.c @@ -81,6 +81,97 @@ tlv->len - ((POS) - tlv->val)); \ } while (0) +/* TODO: this probably qualifies for a libosmocore utils.c function */ +/* A memcpy that can be used by OSMO_STRBUF_APPEND(). */ +static int strncpy_buf(char *buf, size_t buflen, const char *src, size_t len) +{ + size_t cpylen = len; + if (cpylen < SIZE_MAX) + cpylen++; + cpylen = OSMO_MIN(buflen, cpylen); + osmo_strlcpy(buf, src, cpylen); + return len; +} + +/* TODO: this probably qualifies for a libosmocore utils.c function */ +/*! Decode a domain string from a qname (RFC 1035 4.1.2). + * \param[out] buf Output buffer to write the dotted domain name to. + * \param[in] buflen memory available in buf. + * \param[in] qname buffer with length-value pairs for each label (e.g. 0x03 "sip" 0x05 "voice" ...) + * \param[in] qname_len amount of bytes that can be read at most from the memory location that qname points to. + * \returns number of chars that would be written, like snprintf(), negative on error. + */ +static int qname_decode(char *buf, size_t buflen, const uint8_t *qname, size_t qname_len) +{ + struct osmo_strbuf sb = { .buf = buf, .len = buflen }; + const uint8_t *qname_pos = qname; + const uint8_t *qname_end = qname + qname_len; + + /* zero input bytes? */ + if (qname_len < 1) { + if (buflen) + buf[0] = '\0'; + return 0; + } + + while (qname_pos < qname_end) { + size_t len = *qname_pos; + qname_pos++; + + /* Two dots in a row is not allowed */ + if (!len) + return -EINVAL; + /* label must not exceed length of input data */ + if (qname_pos + len > qname_end) + return -EINVAL; + + /* Place a dot before each label, but not at the start. */ + if (sb.chars_needed) + OSMO_STRBUF_PRINTF(sb, "."); + /* Copy label */ + OSMO_STRBUF_APPEND(sb, strncpy_buf, (const char *)qname_pos, len); + qname_pos += len; + } + + return sb.chars_needed; +} + +/* TODO: this probably qualifies for a libosmocore utils.c function */ +/*! Encode a domain string as qname (RFC 1035 4.1.2). + * Encode each label as length-value pairs (e.g. 0x03 "sip" 0x05 "voice" ...). + * No final '\0' character is written. + * \param[out] dst Encode qname to this memory location. + * \param[in] dst_maxlen Memory available at dst. + * \param[in] domain multiple labels separated by dots, e.g. "sip.voice.1234.msisdn". + * \returns nr of bytes written, negative on error. + */ +int qname_encode(uint8_t *dst, size_t dst_maxlen, const char *domain) +{ + uint8_t *dst_pos = dst; + uint8_t *dst_end = dst_pos + dst_maxlen; + const char *pos = domain; + + while (*pos) { + const char *next_dot = strchr(pos, '.'); + size_t len = next_dot ? next_dot - pos : strlen(pos); + + if (len < 1 || len > UINT8_MAX) + return -EINVAL; + + if (dst_pos + 1 + len > dst_end) + return -ENOSPC; + *dst_pos = len; + dst_pos++; + memcpy(dst_pos, pos, len); + dst_pos += len; + + if (!next_dot) + break; + pos = next_dot + 1; + } + return dst_pos - dst; +} + void osmo_pfcp_ie_f_seid_set(struct osmo_pfcp_ie_f_seid *f_seid, uint64_t seid, const struct osmo_sockaddr *remote_addr) { *f_seid = (struct osmo_pfcp_ie_f_seid) { @@ -698,16 +789,24 @@ 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; - osmo_strlcpy(network_inst->str, (const char *)tlv->val, OSMO_MIN(sizeof(network_inst->str), tlv->len+1)); + int rc; + + rc = qname_decode(network_inst->str, sizeof(network_inst->str), tlv->val, tlv->len); + if (rc < 0) + RETURN_ERROR(rc ? : -EINVAL, "decoding qname (RFC 1035 4.1.2) failed"); return 0; } 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; - unsigned int l = strlen(network_inst->str); - if (l) - memcpy(msgb_put(tlv->dst, l), network_inst->str, l); + int rc; + + rc = qname_encode(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; } diff --git a/tests/libosmo-pfcp/pfcp_test.ok b/tests/libosmo-pfcp/pfcp_test.ok index b8eddb9..02424cd 100644 --- a/tests/libosmo-pfcp/pfcp_test.ok +++ b/tests/libosmo-pfcp/pfcp_test.ok @@ -69,8 +69,8 @@ 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 } } } } 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 . -osmo_pfcp_msg_decode_header() rc = 213 +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 = 215 rc == msgb_length() osmo_pfcp_msg_decode_tlv() rc = 0 parsed == orig @@ -91,8 +91,8 @@ 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" } } } } 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 . -osmo_pfcp_msg_decode_header() rc = 203 +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 = 206 rc == msgb_length() osmo_pfcp_msg_decode_tlv() rc = 0 parsed == orig -- To view, visit https://gerrit.osmocom.org/c/libosmo-pfcp/+/30406 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-pfcp Gerrit-Branch: master Gerrit-Change-Id: I9d67464ef0f92b0512cfd6e48d203f8828a82a19 Gerrit-Change-Number: 30406 Gerrit-PatchSet: 1 Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
Change in libosmo-pfcp[master]: add osmo_pfcp_ie_outer_header_creation_to_str_*()
by neels 01 Dec '22

01 Dec '22
neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-pfcp/+/30403 ) Change subject: add osmo_pfcp_ie_outer_header_creation_to_str_*() ...................................................................... add osmo_pfcp_ie_outer_header_creation_to_str_*() Make osmo_pfcp_enc_to_str_outer_header_creation() as osmo_pfcp_ie_outer_header_creation_to_str_*() functions. Used by I0d4d9edcfc94b61bdc74cfd4ff837f151d1c28ae (osmo-upf) Change-Id: I4ad1570485c8081b82284e4e6b4de4d7eed414b0 --- M include/osmocom/pfcp/pfcp_ies_custom.h M src/libosmo-pfcp/pfcp_ies_custom.c 2 files changed, 16 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-pfcp refs/changes/03/30403/1 diff --git a/include/osmocom/pfcp/pfcp_ies_custom.h b/include/osmocom/pfcp/pfcp_ies_custom.h index 565fee2..0540bfe 100644 --- a/include/osmocom/pfcp/pfcp_ies_custom.h +++ b/include/osmocom/pfcp/pfcp_ies_custom.h @@ -161,6 +161,10 @@ uint32_t s_tag; }; +int osmo_pfcp_ie_outer_header_creation_to_str_buf(char *buf, size_t buflen, + const struct osmo_pfcp_ie_outer_header_creation *ohc); +char *osmo_pfcp_ie_outer_header_creation_to_str_c(void *ctx, const struct osmo_pfcp_ie_outer_header_creation *ohc); + /* 3GPP TS 29.244 8.2.64. */ struct osmo_pfcp_ie_outer_header_removal { enum osmo_pfcp_outer_header_removal_desc desc; diff --git a/src/libosmo-pfcp/pfcp_ies_custom.c b/src/libosmo-pfcp/pfcp_ies_custom.c index 422b6a9..06b7494 100644 --- a/src/libosmo-pfcp/pfcp_ies_custom.c +++ b/src/libosmo-pfcp/pfcp_ies_custom.c @@ -857,9 +857,9 @@ return 0; } -int osmo_pfcp_enc_to_str_outer_header_creation(char *buf, size_t buflen, const void *encode_from) +int osmo_pfcp_ie_outer_header_creation_to_str_buf(char *buf, size_t buflen, + const struct osmo_pfcp_ie_outer_header_creation *ohc) { - const struct osmo_pfcp_ie_outer_header_creation *ohc = encode_from; struct osmo_strbuf sb = { .buf = buf, .len = buflen }; OSMO_STRBUF_APPEND(sb, osmo_pfcp_bits_to_str_buf, ohc->desc_bits, osmo_pfcp_outer_header_creation_strs); if (ohc->teid_present) @@ -877,6 +877,16 @@ return sb.chars_needed; } +char *osmo_pfcp_ie_outer_header_creation_to_str_c(void *ctx, const struct osmo_pfcp_ie_outer_header_creation *ohc) +{ + OSMO_NAME_C_IMPL(ctx, 128, "ERROR", osmo_pfcp_ie_outer_header_creation_to_str_buf, ohc) +} + +int osmo_pfcp_enc_to_str_outer_header_creation(char *buf, size_t buflen, const void *encode_from) +{ + return osmo_pfcp_ie_outer_header_creation_to_str_buf(buf, buflen, encode_from); +} + int osmo_pfcp_dec_activate_predefined_rules(void *decoded_struct, void *decode_to, const struct osmo_gtlv_load *tlv) { struct osmo_pfcp_ie_activate_predefined_rules *activate_predefined_rules = decode_to; -- To view, visit https://gerrit.osmocom.org/c/libosmo-pfcp/+/30403 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-pfcp Gerrit-Branch: master Gerrit-Change-Id: I4ad1570485c8081b82284e4e6b4de4d7eed414b0 Gerrit-Change-Number: 30403 Gerrit-PatchSet: 1 Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 195
  • 196
  • 197
  • 198
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.