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-abis[master]: Remove mISDN header from received channel data
by laforge 12 Dec '22

12 Dec '22
Attention is currently required from: jolly. laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-abis/+/30448 ) Change subject: Remove mISDN header from received channel data ...................................................................... Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/30448 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-abis Gerrit-Branch: master Gerrit-Change-Id: I37f12baa1013cd1cfc6f6531b132669071eec926 Gerrit-Change-Number: 30448 Gerrit-PatchSet: 1 Gerrit-Owner: jolly <andreas(a)eversberg.eu> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Attention: jolly <andreas(a)eversberg.eu> Gerrit-Comment-Date: Mon, 12 Dec 2022 09:47:20 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
Change in libosmo-abis[master]: Fix support for HDLC/RAW type channels at mISDN.c
by laforge 12 Dec '22

12 Dec '22
Attention is currently required from: jolly. laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-abis/+/30446 ) Change subject: Fix support for HDLC/RAW type channels at mISDN.c ...................................................................... Patch Set 1: (3 comments) Patchset: PS1: fine with me now, except for the TODO-RELEASE. File include/osmocom/abis/e1_input.h: https://gerrit.osmocom.org/c/libosmo-abis/+/30446/comment/908c9714_f671453d PS1, Line 120: in please add an entry to TOOD-RELEASE as this breaks the ABI towards applications, i.e. we need a related .so-version change of the library when we tag the next versions. File src/input/misdn.c: https://gerrit.osmocom.org/c/libosmo-abis/+/30446/comment/113998da_3df20a4e PS1, Line 690: /* TS 16 is the D-channel, so we use D-channel proto */ : bfd->fd = socket(PF_ISDN, SOCK_DGRAM, : (ts == 16) ? ISDN_P_NT_E1 : ISDN_P_B_HDLC); > mISDN handles TS 16 different, so that ISDN_P_NT_E1 must be given instead of ISDN_P_B_HDLC. […] Oh my, that's sad. I sometimes feel like we should remove mISDN support with all its constraints. Or at least not build it by default, to avoid users falling into traps. Nobody except you seems to know/understand them, and we have no piece of documentation explaining to users that you cannot use TS16 for e.g. TRAU frames on a mISDN line. In any case, all unrelated to this patch. -- To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/30446 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-abis Gerrit-Branch: master Gerrit-Change-Id: Ie9a2a3f6ae1ad7da1711b6ff2f0aeda39839a427 Gerrit-Change-Number: 30446 Gerrit-PatchSet: 1 Gerrit-Owner: jolly <andreas(a)eversberg.eu> Gerrit-Reviewer: Jenkins Builder Gerrit-CC: laforge <laforge(a)osmocom.org> Gerrit-Attention: jolly <andreas(a)eversberg.eu> Gerrit-Comment-Date: Mon, 12 Dec 2022 09:47:00 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: jolly <andreas(a)eversberg.eu> Comment-In-Reply-To: laforge <laforge(a)osmocom.org> Gerrit-MessageType: comment
1 0
0 0
Change in libosmo-pfcp[master]: gtlv: decoding error: log size limited hexdump of IE
by neels 11 Dec '22

11 Dec '22
neels has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-pfcp/+/30502 ) Change subject: gtlv: decoding error: log size limited hexdump of IE ...................................................................... gtlv: decoding error: log size limited hexdump of IE When a decoding error is encountered, log the value part of the root cause as hexdump, but at most 16 bytes (16*3 chars as hexdump). Contrived example of the change: before this patch: <-tx- PFCP seq-4 ASSOC_SETUP_RESP: 0: Invalid FQDN (-22: Invalid argument) <-tx- PFCP seq-4 ASSOC_SETUP_RESP: 0: tag 0x3c = Node ID: Error while decoding this IE (-22: Invalid argument) after this patch: <-tx- PFCP seq-4 ASSOC_SETUP_RESP: 0: Invalid FQDN (-22: Invalid argument) <-tx- PFCP seq-4 ASSOC_SETUP_RESP: 0: tag 0x3c = Node ID: Error while decoding this IE. L=20 V=[ 02 07 65 78 61 6d 70 6c 65 03 63 6f 6d 01 02 03 ...] (-22: Invalid argument) Change-Id: Ie814a117db3dfea32cf3f01cf124a2e472cb869f --- M src/libosmo-gtlv/gtlv_dec_enc.c 1 file changed, 6 insertions(+), 2 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved fixeria: Looks good to me, but someone else must approve diff --git a/src/libosmo-gtlv/gtlv_dec_enc.c b/src/libosmo-gtlv/gtlv_dec_enc.c index 385ebfa..37e8a51 100644 --- a/src/libosmo-gtlv/gtlv_dec_enc.c +++ b/src/libosmo-gtlv/gtlv_dec_enc.c @@ -218,8 +218,12 @@ if (!iec->dec_func) RETURN_ERROR(-EIO, gtlv->ti, "IE definition lacks a dec_func()"); rc = iec->dec_func(decoded_struct, membof(obj, obj_maxlen, memb_ofs), gtlv); - if (rc) - RETURN_ERROR(rc, gtlv->ti, "Error while decoding this IE"); + if (rc) { + const size_t maxlen = 16; + RETURN_ERROR(rc, gtlv->ti, "Error while decoding this IE. L=%zu V=[ %s%s]", + gtlv->len, osmo_hexdump(gtlv->val, OSMO_MIN(maxlen, gtlv->len)), + gtlv->len > maxlen ? "..." : ""); + } } if (multi_count_p) { -- To view, visit https://gerrit.osmocom.org/c/libosmo-pfcp/+/30502 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-pfcp Gerrit-Branch: master Gerrit-Change-Id: Ie814a117db3dfea32cf3f01cf124a2e472cb869f Gerrit-Change-Number: 30502 Gerrit-PatchSet: 4 Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
Change in libosmo-pfcp[master]: fix coding of Node ID: FQDN type
by neels 11 Dec '22

11 Dec '22
neels has submitted this change. ( 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, 10 insertions(+), 7 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved fixeria: Looks good to me, but someone else must approve diff --git a/src/libosmo-pfcp/pfcp_ies_custom.c b/src/libosmo-pfcp/pfcp_ies_custom.c index 736f39d..b334241 100644 --- a/src/libosmo-pfcp/pfcp_ies_custom.c +++ b/src/libosmo-pfcp/pfcp_ies_custom.c @@ -317,8 +317,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); + ENSURE_RANGE("FQDN value length", ip_len, 1, sizeof(node_id->fqdn)); + if (osmo_apn_to_str(node_id->fqdn, ip, ip_len) == NULL) + RETURN_ERROR(-EINVAL, "FQDN: osmo_apn_to_str() failed"); break; default: RETURN_ERROR(-EINVAL, "Invalid Node ID Type: %d", node_id->type); @@ -330,6 +331,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: @@ -341,9 +343,10 @@ 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 = osmo_apn_from_str(tlv->dst->tail, msgb_tailroom(tlv->dst), node_id->fqdn); + if (rc <= 0) + RETURN_ERROR(-EINVAL, "osmo_apn_from_str(\"%s\") failed", node_id->fqdn); + 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: 5 Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
Change in libosmo-pfcp[master]: bitmask to string: shorten
by neels 11 Dec '22

11 Dec '22
neels has submitted this change. ( 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". 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(-) Approvals: Jenkins Builder: Verified fixeria: Looks good to me, but someone else must approve pespin: Looks good to me, approved laforge: Looks good to me, approved diff --git a/src/libosmo-pfcp/pfcp_ies_custom.c b/src/libosmo-pfcp/pfcp_ies_custom.c index b334241..e2e9f02 100644 --- a/src/libosmo-pfcp/pfcp_ies_custom.c +++ b/src/libosmo-pfcp/pfcp_ies_custom.c @@ -411,13 +411,15 @@ 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, " )"); + if (first) + 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 2 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. -- 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: 6 Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
Change in libosmo-pfcp[master]: fix coding of Network Instance IE
by neels 11 Dec '22

11 Dec '22
neels has submitted this change. ( 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. Related: SYS#6192 Change-Id: I9d67464ef0f92b0512cfd6e48d203f8828a82a19 --- M TODO-RELEASE M configure.ac M contrib/libosmo-pfcp.spec.in M src/libosmo-pfcp/Makefile.am M src/libosmo-pfcp/pfcp_ies_custom.c M tests/libosmo-pfcp/Makefile.am M tests/libosmo-pfcp/pfcp_test.ok 7 files changed, 28 insertions(+), 8 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved fixeria: Looks good to me, but someone else must approve diff --git a/TODO-RELEASE b/TODO-RELEASE index d0852fc..19c1fce 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -7,3 +7,4 @@ # 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. #library what description / commit summary line +libosmo-pfcp libosmogsm>=1.7.0 libosmo-pfcp now uses API from libosmogsm (from libosmocore.git) diff --git a/configure.ac b/configure.ac index ba7ff86..4d10d3f 100644 --- a/configure.ac +++ b/configure.ac @@ -38,6 +38,7 @@ dnl checks for libraries PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.7.0) +PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 1.7.0) dnl checks for header files AC_HEADER_STDC diff --git a/contrib/libosmo-pfcp.spec.in b/contrib/libosmo-pfcp.spec.in index d6481c2..e789ef6 100644 --- a/contrib/libosmo-pfcp.spec.in +++ b/contrib/libosmo-pfcp.spec.in @@ -12,6 +12,7 @@ BuildRequires: lksctp-tools-devel BuildRequires: pkgconfig >= 0.20 BuildRequires: pkgconfig(libosmocore) >= 1.7.0 +BuildRequires: pkgconfig(libosmogsm) >= 1.7.0 BuildRequires: pkgconfig(talloc) %description diff --git a/src/libosmo-pfcp/Makefile.am b/src/libosmo-pfcp/Makefile.am index d202c6a..6ca88b8 100644 --- a/src/libosmo-pfcp/Makefile.am +++ b/src/libosmo-pfcp/Makefile.am @@ -9,12 +9,14 @@ AM_CFLAGS = \ -Wall \ $(LIBOSMOCORE_CFLAGS) \ + $(LIBOSMOGSM_CFLAGS) \ $(LIBOSMOVTY_CFLAGS) \ $(COVERAGE_CFLAGS) \ $(NULL) AM_LDFLAGS = \ $(LIBOSMOCORE_LIBS) \ + $(LIBOSMOGSM_LIBS) \ $(LIBOSMOVTY_LIBS) \ $(COVERAGE_LDFLAGS) \ $(NULL) diff --git a/src/libosmo-pfcp/pfcp_ies_custom.c b/src/libosmo-pfcp/pfcp_ies_custom.c index 1891902..736f39d 100644 --- a/src/libosmo-pfcp/pfcp_ies_custom.c +++ b/src/libosmo-pfcp/pfcp_ies_custom.c @@ -29,6 +29,7 @@ #include <osmocom/core/logging.h> #include <osmocom/core/utils.h> #include <osmocom/core/msgb.h> +#include <osmocom/gsm/apn.h> #include <osmocom/gtlv/gtlv.h> @@ -81,6 +82,13 @@ tlv->len - ((POS) - tlv->val)); \ } while (0) +#define ENSURE_RANGE(NAME, VAL, MINVAL, MAXVAL) \ + do { \ + if ((VAL) < (MINVAL) || (VAL) > (MAXVAL)) \ + RETURN_ERROR(-ERANGE, "%s == %d, should be in range %d .. %d", NAME, \ + (int)(VAL), (int)(MINVAL), (int)(MAXVAL)); \ + } while (0) + 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 +706,21 @@ 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)); + ENSURE_RANGE("Network Instance value length", tlv->len, 1, sizeof(network_inst->str)); + if (osmo_apn_to_str(network_inst->str, tlv->val, tlv->len) == NULL) + RETURN_ERROR(-EINVAL, "osmo_apn_to_str() 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 = osmo_apn_from_str(tlv->dst->tail, msgb_tailroom(tlv->dst), network_inst->str); + if (rc <= 0) + RETURN_ERROR(-EINVAL, "osmo_apn_from_str(\"%s\") failed", network_inst->str); + msgb_put(tlv->dst, rc); return 0; } diff --git a/tests/libosmo-pfcp/Makefile.am b/tests/libosmo-pfcp/Makefile.am index e9ff6d3..f4314f2 100644 --- a/tests/libosmo-pfcp/Makefile.am +++ b/tests/libosmo-pfcp/Makefile.am @@ -7,6 +7,7 @@ AM_CFLAGS = \ -Wall \ $(LIBOSMOCORE_CFLAGS) \ + $(LIBOSMOGSM_CFLAGS) \ $(NULL) check_PROGRAMS = \ @@ -24,6 +25,7 @@ pfcp_test_LDADD = \ $(top_builddir)/src/libosmo-pfcp/libosmo-pfcp.la \ $(top_builddir)/src/libosmo-gtlv/libosmo-gtlv.la \ + $(LIBOSMOGSM_LIBS) \ $(LIBOSMOCORE_LIBS) \ $(NULL) 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: 5 Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de> Gerrit-CC: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
Change in libosmo-pfcp[master]: gtlv: decoding error: log size limited hexdump of IE
by neels 11 Dec '22

11 Dec '22
Attention is currently required from: fixeria. neels has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-pfcp/+/30502 ) Change subject: gtlv: decoding error: log size limited hexdump of IE ...................................................................... Patch Set 4: (1 comment) File src/libosmo-gtlv/gtlv_dec_enc.c: https://gerrit.osmocom.org/c/libosmo-pfcp/+/30502/comment/677d6f05_300be5fd PS4, Line 224: osmo_hexdump > We may want to have a special version of osmo_hexdump_max() in libosmocore. would fit well, but i think this here is simple enough that we don't need to extend the API. (btw i'm using the "legacy" version returning a static buffer because libosmo-gtlv must not make assumptions on allocation handling = cannot use OTC_SELECT) -- To view, visit https://gerrit.osmocom.org/c/libosmo-pfcp/+/30502 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-pfcp Gerrit-Branch: master Gerrit-Change-Id: Ie814a117db3dfea32cf3f01cf124a2e472cb869f Gerrit-Change-Number: 30502 Gerrit-PatchSet: 4 Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Comment-Date: Sun, 11 Dec 2022 23:00:15 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: comment
1 0
0 0
Change in osmo-upf[master]: nft: allow to get the ruleset string without running
by neels 11 Dec '22

11 Dec '22
neels has submitted this change. ( https://gerrit.osmocom.org/c/osmo-upf/+/30498 ) Change subject: nft: allow to get the ruleset string without running ...................................................................... nft: allow to get the ruleset string without running Separate string composition of the nftables ruleset from the actual actvation of the ruleset to nftables. For a 'show' VTY command added in upcoming patch, I'd like to be able to vty_out() an nftables rule set. Provide API for that. Change-Id: I0124a68ccf1ac7b90c5cc32d0cbf58d0cc219ccc --- M include/osmocom/upf/upf_nft.h M src/osmo-upf/upf_nft.c 2 files changed, 8 insertions(+), 2 deletions(-) Approvals: Jenkins Builder: Verified fixeria: Looks good to me, approved laforge: Looks good to me, but someone else must approve diff --git a/include/osmocom/upf/upf_nft.h b/include/osmocom/upf/upf_nft.h index fe8bb12..4cdcb51 100644 --- a/include/osmocom/upf/upf_nft.h +++ b/include/osmocom/upf/upf_nft.h @@ -49,5 +49,6 @@ int upf_nft_init(); int upf_nft_free(); +char *upf_nft_tunmap_get_ruleset_str(void *ctx, struct upf_nft_tunmap_desc *tunmap); int upf_nft_tunmap_create(struct upf_nft_tunmap_desc *tunmap); int upf_nft_tunmap_delete(struct upf_nft_tunmap_desc *tunmap); diff --git a/src/osmo-upf/upf_nft.c b/src/osmo-upf/upf_nft.c index 8f59d01..7c1ec53 100644 --- a/src/osmo-upf/upf_nft.c +++ b/src/osmo-upf/upf_nft.c @@ -215,7 +215,7 @@ }; } -int upf_nft_tunmap_create(struct upf_nft_tunmap_desc *tunmap) +char *upf_nft_tunmap_get_ruleset_str(void *ctx, struct upf_nft_tunmap_desc *tunmap) { struct upf_nft_args args; @@ -228,7 +228,12 @@ } upf_nft_args_from_tunmap_desc(&args, tunmap); - return upf_nft_run(upf_nft_ruleset_tunmap_create_c(OTC_SELECT, &args)); + return upf_nft_ruleset_tunmap_create_c(ctx, &args); +} + +int upf_nft_tunmap_create(struct upf_nft_tunmap_desc *tunmap) +{ + return upf_nft_run(upf_nft_tunmap_get_ruleset_str(OTC_SELECT, tunmap)); } int upf_nft_tunmap_delete(struct upf_nft_tunmap_desc *tunmap) -- To view, visit https://gerrit.osmocom.org/c/osmo-upf/+/30498 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-upf Gerrit-Branch: master Gerrit-Change-Id: I0124a68ccf1ac7b90c5cc32d0cbf58d0cc219ccc Gerrit-Change-Number: 30498 Gerrit-PatchSet: 3 Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
Change in osmo-upf[master]: vty: add: show nft-rule tunmap example
by neels 11 Dec '22

11 Dec '22
neels has submitted this change. ( https://gerrit.osmocom.org/c/osmo-upf/+/30499 ) Change subject: vty: add: show nft-rule tunmap example ...................................................................... vty: add: show nft-rule tunmap example Add VTY command to print out an nftables ruleset that osmo-upf produces, with arbitrary IP addrs / TEIDs inserted. This allows tracking in *.vty tests how the nftables rulesets are changed by patches. future: - Adding the 'tunmap' keyword to allow adding show commands for different uses of nftables. - Adding the 'example' keyword to allow adding show commands for actual tunmap IDs / PFCP session IDs / ... - Matches upcoming vty commands 'nft-rule tunmap append .NFT_RULE' 'no nft-rule tunmap append' 'show nft-rule tunmap append' Add new separate nft-rule.vty -- more to come here in upcoming patch. Change-Id: I9b57aa492c051e480c9bd819ae58f8f59a13af40 --- M src/osmo-upf/upf_nft.c M src/osmo-upf/upf_vty.c A tests/nft-rule.vty M tests/upf.vty 4 files changed, 65 insertions(+), 3 deletions(-) Approvals: Jenkins Builder: Verified fixeria: Looks good to me, but someone else must approve neels: Looks good to me, approved laforge: Looks good to me, but someone else must approve diff --git a/src/osmo-upf/upf_nft.c b/src/osmo-upf/upf_nft.c index 7c1ec53..81ca9d0 100644 --- a/src/osmo-upf/upf_nft.c +++ b/src/osmo-upf/upf_nft.c @@ -64,6 +64,12 @@ int upf_nft_init() { int rc; + + /* Always set up the default settings, also in mockup mode, so that the VTY reflects sane values */ + if (!g_upf->nft.table_name) + g_upf->nft.table_name = talloc_strdup(g_upf, "osmo-upf"); + + /* When in mockup mode, do not set up nft_ctx and netfilter table */ if (g_upf->nft.mockup) { LOGP(DNFT, LOGL_NOTICE, "tunmap/mockup active: not allocating libnftables nft_ctx. FOR TESTING PURPOSES ONLY.\n"); @@ -76,9 +82,6 @@ return -EIO; } - if (!g_upf->nft.table_name) - g_upf->nft.table_name = talloc_strdup(g_upf, "osmo-upf"); - rc = upf_nft_run(upf_nft_ruleset_table_create(OTC_SELECT, g_upf->nft.table_name)); if (rc) { LOGP(DNFT, LOGL_ERROR, "Failed to create nft table %s\n", diff --git a/src/osmo-upf/upf_vty.c b/src/osmo-upf/upf_vty.c index aff7590..6d74b21 100644 --- a/src/osmo-upf/upf_vty.c +++ b/src/osmo-upf/upf_vty.c @@ -254,6 +254,43 @@ return CMD_SUCCESS; } +#define NFT_RULE_STR "nftables rule specifics\n" +#define TUNMAP_STR "GTP tunmap use case (a.k.a. forwarding between two GTP tunnels)\n" + +DEFUN(show_nft_rule_tunmap_example, show_nft_rule_tunmap_example_cmd, + "show nft-rule tunmap example", + SHOW_STR NFT_RULE_STR TUNMAP_STR + "Print a complete nftables ruleset for a tunmap filled with example IP addresses and TEIDs\n") +{ + struct osmo_sockaddr_str str = {}; + struct upf_nft_tunmap_desc d = { + .access = { + .local_teid = 0x201, + .remote_teid = 0x102, + }, + .core = { + .local_teid = 0x203, + .remote_teid = 0x302, + }, + .id = 123, + }; + + osmo_sockaddr_str_from_str2(&str, "1.1.1.1"); + osmo_sockaddr_str_to_sockaddr(&str, &d.access.gtp_remote_addr.u.sas); + + osmo_sockaddr_str_from_str2(&str, "2.2.2.1"); + osmo_sockaddr_str_to_sockaddr(&str, &d.access.gtp_local_addr.u.sas); + + osmo_sockaddr_str_from_str2(&str, "2.2.2.3"); + osmo_sockaddr_str_to_sockaddr(&str, &d.core.gtp_local_addr.u.sas); + + osmo_sockaddr_str_from_str2(&str, "3.3.3.3"); + osmo_sockaddr_str_to_sockaddr(&str, &d.core.gtp_remote_addr.u.sas); + + vty_out(vty, "%s%s", upf_nft_tunmap_get_ruleset_str(OTC_SELECT, &d), VTY_NEWLINE); + return CMD_SUCCESS; +} + static struct cmd_node cfg_netinst_node = { NETINST_NODE, "%s(config-netinst)# ", @@ -435,6 +472,7 @@ install_element(TUNMAP_NODE, &cfg_tunmap_mockup_cmd); install_element(TUNMAP_NODE, &cfg_tunmap_no_mockup_cmd); install_element(TUNMAP_NODE, &cfg_tunmap_table_name_cmd); + install_element(TUNMAP_NODE, &show_nft_rule_tunmap_example_cmd); install_node(&cfg_netinst_node, config_write_netinst); install_element(CONFIG_NODE, &cfg_netinst_cmd); diff --git a/tests/nft-rule.vty b/tests/nft-rule.vty new file mode 100644 index 0000000..f328871 --- /dev/null +++ b/tests/nft-rule.vty @@ -0,0 +1,8 @@ +OsmoUPF> enable +OsmoUPF# configure terminal +OsmoUPF(config)# tunmap + +OsmoUPF(config-tunmap)# show nft-rule tunmap example +add chain inet osmo-upf tunmap123 { type filter hook prerouting priority -300; } +add rule inet osmo-upf tunmap123 meta l4proto udp ip daddr 2.2.2.1 @ih,32,32 0x00000201 ip saddr set 2.2.2.3 ip daddr set 3.3.3.3 @ih,32,32 set 0x00000302 counter; +add rule inet osmo-upf tunmap123 meta l4proto udp ip daddr 2.2.2.3 @ih,32,32 0x00000203 ip saddr set 2.2.2.1 ip daddr set 1.1.1.1 @ih,32,32 set 0x00000102 counter; diff --git a/tests/upf.vty b/tests/upf.vty index 5100b17..8931719 100644 --- a/tests/upf.vty +++ b/tests/upf.vty @@ -52,6 +52,7 @@ mockup no mockup table-name TABLE_NAME + show nft-rule tunmap example OsmoUPF(config-tunmap)# exit OsmoUPF(config)# tunmap @@ -60,6 +61,7 @@ mockup no mockup table-name TABLE_NAME + show nft-rule tunmap example OsmoUPF(config-tunmap)# mockup? mockup don't actually send rulesets to nftables, just return success @@ -70,3 +72,14 @@ table-name Set the nft inet table name to create and place GTP tunnel forwarding chains in (as in 'nft add table inet foo'). If multiple instances of osmo-upf are running on the same system, each osmo-upf must have its own table name. Otherwise the names of created forwarding chains will collide. The default table name is "osmo-upf". OsmoUPF(config-tunmap)# table-name ? TABLE_NAME nft inet table name + +OsmoUPF(config-tunmap)# show? + show Show running system information +OsmoUPF(config-tunmap)# show ? +... + nft-rule nftables rule specifics +... +OsmoUPF(config-tunmap)# show nft-rule ? + tunmap GTP tunmap use case (a.k.a. forwarding between two GTP tunnels) +OsmoUPF(config-tunmap)# show nft-rule tunmap ? + example Print a complete nftables ruleset for a tunmap filled with example IP addresses and TEIDs -- To view, visit https://gerrit.osmocom.org/c/osmo-upf/+/30499 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-upf Gerrit-Branch: master Gerrit-Change-Id: I9b57aa492c051e480c9bd819ae58f8f59a13af40 Gerrit-Change-Number: 30499 Gerrit-PatchSet: 3 Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
Change in osmo-upf[master]: nft: ensure to assign rule id only once
by neels 11 Dec '22

11 Dec '22
neels has submitted this change. ( https://gerrit.osmocom.org/c/osmo-upf/+/30496 ) Change subject: nft: ensure to assign rule id only once ...................................................................... nft: ensure to assign rule id only once Make sure an assigned id is not overwritten. So far this function was guaranteed to be called only once. But I would like to allow getting the nftables ruleset string more than once in a future patch. Prepare that. Change-Id: I4e8c48c01fb2f5d4cfd223fe03abbf15b1a55670 --- M include/osmocom/upf/upf_nft.h M src/osmo-upf/upf_nft.c 2 files changed, 7 insertions(+), 2 deletions(-) Approvals: Jenkins Builder: Verified fixeria: Looks good to me, approved laforge: Looks good to me, but someone else must approve diff --git a/include/osmocom/upf/upf_nft.h b/include/osmocom/upf/upf_nft.h index 9108a4f..fe8bb12 100644 --- a/include/osmocom/upf/upf_nft.h +++ b/include/osmocom/upf/upf_nft.h @@ -42,6 +42,7 @@ struct osmo_sockaddr gtp_remote_addr; uint32_t remote_teid; } core; + /* id as in ruleset name 'tunmap<id>'. If zero, no id has been assigned yet. */ uint32_t id; }; diff --git a/src/osmo-upf/upf_nft.c b/src/osmo-upf/upf_nft.c index 4dfea6c..c34cbfb 100644 --- a/src/osmo-upf/upf_nft.c +++ b/src/osmo-upf/upf_nft.c @@ -215,8 +215,12 @@ struct upf_nft_args args; /* Give this tunnel mapping a new id, returned to the caller so that the tunnel mapping can be deleted later */ - g_upf->nft.next_id_state++; - tunmap->id = g_upf->nft.next_id_state; + if (!tunmap->id) { + g_upf->nft.next_id_state++; + if (!g_upf->nft.next_id_state) + g_upf->nft.next_id_state++; + tunmap->id = g_upf->nft.next_id_state; + } upf_nft_args_from_tunmap_desc(&args, tunmap); return upf_nft_run(upf_nft_ruleset_tunmap_create_c(OTC_SELECT, &args)); -- To view, visit https://gerrit.osmocom.org/c/osmo-upf/+/30496 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-upf Gerrit-Branch: master Gerrit-Change-Id: I4e8c48c01fb2f5d4cfd223fe03abbf15b1a55670 Gerrit-Change-Number: 30496 Gerrit-PatchSet: 3 Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • ...
  • 198
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.