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

June 2022

  • 3 participants
  • 1374 discussions
Change in libosmo-pfcp[master]: add generic PFCP CP peer implementation
by neels 17 Jun '22

17 Jun '22
neels has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-pfcp/+/28317 ) Change subject: add generic PFCP CP peer implementation ...................................................................... add generic PFCP CP peer implementation Will be used by osmo-hnbgw, our first PFCP Control Plane entity. The implementation is generic enough that it can be re-used by other CP entities. Related: SYS#5895 Change-Id: If8c5f69f596ea6ba8bd1723f4dc57b91d3799795 --- M include/osmocom/pfcp/Makefile.am A include/osmocom/pfcp/pfcp_cp_peer.h M src/libosmo-pfcp/Makefile.am A src/libosmo-pfcp/pfcp_cp_peer.c 4 files changed, 469 insertions(+), 0 deletions(-) Approvals: Jenkins Builder: Verified diff --git a/include/osmocom/pfcp/Makefile.am b/include/osmocom/pfcp/Makefile.am index 5d2db19..898113f 100644 --- a/include/osmocom/pfcp/Makefile.am +++ b/include/osmocom/pfcp/Makefile.am @@ -5,6 +5,7 @@ pfcp_msg.h \ pfcp_proto.h \ pfcp_strs.h \ + pfcp_cp_peer.h \ $(NULL) pfcpdir = $(includedir)/osmocom/pfcp diff --git a/include/osmocom/pfcp/pfcp_cp_peer.h b/include/osmocom/pfcp/pfcp_cp_peer.h new file mode 100644 index 0000000..8c6e448 --- /dev/null +++ b/include/osmocom/pfcp/pfcp_cp_peer.h @@ -0,0 +1,63 @@ +/* + * (C) 2021-2022 by sysmocom - s.f.m.c. GmbH <info(a)sysmocom.de> + * All Rights Reserved. + * + * Author: Neels Janosch Hofmeyr <nhofmeyr(a)sysmocom.de> + * + * SPDX-License-Identifier: GPL-2.0+ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#pragma once + +#include <stdint.h> +#include <stdbool.h> + +#include <osmocom/core/socket.h> +#include <osmocom/core/use_count.h> +#include <osmocom/pfcp/pfcp_proto.h> + +struct osmo_fsm_inst; +struct osmo_pfcp_endpoint; +struct osmo_pfcp_cp_peer; + +typedef void (*osmo_pfcp_cp_peer_assoc_cb)(struct osmo_pfcp_cp_peer *cp_peer, bool associated); + +struct osmo_pfcp_cp_peer { + struct osmo_fsm_inst *fi; + struct osmo_pfcp_endpoint *ep; + struct osmo_sockaddr remote_addr; + uint64_t next_seid_state; + + /* If non-NULL, called whenever the peer completes a PFCP Association, and when it loses association. + * Argument associated == true means the peer has just associated; + * associated == false means the association has been lost. */ + osmo_pfcp_cp_peer_assoc_cb assoc_cb; + /* Application private data for assoc_cb, in case ep->priv does not suffice. */ + void *priv; + + struct osmo_use_count use_count; + struct osmo_use_count_entry use_count_buf[128]; +}; + +struct osmo_pfcp_cp_peer *osmo_pfcp_cp_peer_alloc(void *ctx, + struct osmo_pfcp_endpoint *ep, + const struct osmo_sockaddr *remote_addr); +int osmo_pfcp_cp_peer_associate(struct osmo_pfcp_cp_peer *cp_peer); +bool osmo_pfcp_cp_peer_is_associated(const struct osmo_pfcp_cp_peer *cp_peer); +struct osmo_pfcp_msg *osmo_pfcp_cp_peer_new_msg_tx(struct osmo_pfcp_cp_peer *cp_peer, + enum osmo_pfcp_message_type msg_type); +void osmo_pfcp_cp_peer_set_msg_ctx(struct osmo_pfcp_cp_peer *cp_peer, struct osmo_pfcp_msg *m); diff --git a/src/libosmo-pfcp/Makefile.am b/src/libosmo-pfcp/Makefile.am index 1f4b80f..a1e9904 100644 --- a/src/libosmo-pfcp/Makefile.am +++ b/src/libosmo-pfcp/Makefile.am @@ -28,6 +28,7 @@ pfcp_ies_custom.c \ pfcp_msg.c \ pfcp_strs.c \ + pfcp_cp_peer.c \ \ pfcp_ies_auto.c \ $(NULL) diff --git a/src/libosmo-pfcp/pfcp_cp_peer.c b/src/libosmo-pfcp/pfcp_cp_peer.c new file mode 100644 index 0000000..c47b440 --- /dev/null +++ b/src/libosmo-pfcp/pfcp_cp_peer.c @@ -0,0 +1,404 @@ +/* + * (C) 2021-2022 by sysmocom - s.f.m.c. GmbH <info(a)sysmocom.de> + * All Rights Reserved. + * + * Author: Neels Janosch Hofmeyr <nhofmeyr(a)sysmocom.de> + * + * SPDX-License-Identifier: GPL-2.0+ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#include <errno.h> + +#include <osmocom/core/utils.h> +#include <osmocom/core/fsm.h> +#include <osmocom/core/tdef.h> + +#include <osmocom/pfcp/pfcp_endpoint.h> +#include <osmocom/pfcp/pfcp_cp_peer.h> + +#define LOG_CP_PEER(CP_PEER, LOGLEVEL, FMT, ARGS...) \ + LOGPFSML((CP_PEER)->fi, LOGLEVEL, FMT, ##ARGS) + +enum pfcp_cp_peer_fsm_state { + PFCP_CP_PEER_ST_DISABLED, + PFCP_CP_PEER_ST_WAIT_ASSOC_SETUP_RESP, + PFCP_CP_PEER_ST_WAIT_RETRY, + PFCP_CP_PEER_ST_ASSOCIATED, + PFCP_CP_PEER_ST_GRACEFUL_RELEASE, + PFCP_CP_PEER_ST_WAIT_USE_COUNT, +}; + +enum pfcp_cp_peer_fsm_event { + PFCP_CP_PEER_EV_RX_ASSOC_SETUP_RESP, + PFCP_CP_PEER_EV_RX_ASSOC_UPDATE_REQ, + PFCP_CP_PEER_EV_USE_COUNT_ZERO, +}; + +static const struct value_string pfcp_cp_peer_fsm_event_names[] = { + OSMO_VALUE_STRING(PFCP_CP_PEER_EV_RX_ASSOC_SETUP_RESP), + OSMO_VALUE_STRING(PFCP_CP_PEER_EV_RX_ASSOC_UPDATE_REQ), + OSMO_VALUE_STRING(PFCP_CP_PEER_EV_USE_COUNT_ZERO), + {} +}; + +static struct osmo_fsm pfcp_cp_peer_fsm; + +static const struct osmo_tdef_state_timeout pfcp_cp_peer_fsm_timeouts[32] = { + [PFCP_CP_PEER_ST_WAIT_RETRY] = { .T = -26 }, + /* PFCP_CP_PEER_ST_WAIT_ASSOC_SETUP_RESP is terminated by the on_pfcp_assoc_resp() callback */ + [PFCP_CP_PEER_ST_GRACEFUL_RELEASE] = { .T = -21 }, +}; + +/* Transition to a state, using the T timer defined in pfcp_cp_peer_fsm_timeouts. + * Assumes local variable fi exists. */ +#define osmo_pfcp_cp_peer_fsm_state_chg(state) \ + osmo_tdef_fsm_inst_state_chg(fi, state, \ + pfcp_cp_peer_fsm_timeouts, \ + osmo_pfcp_tdefs, \ + 5) + +static int pfcp_cp_peer_use_cb(struct osmo_use_count_entry *e, int32_t old_use_count, const char *file, int line) +{ + struct osmo_pfcp_cp_peer *cp_peer = e->use_count->talloc_object; + + if (!e->use) + return -EINVAL; + + LOGPFSMSLSRC(cp_peer->fi, DLPFCP, LOGL_DEBUG, file, line, + "%s %s: now used by %s\n", + e->count > old_use_count ? "+" : "-", e->use, + osmo_use_count_to_str_c(OTC_SELECT, &cp_peer->use_count)); + + if (e->count < 0) + return -ERANGE; + + if (osmo_use_count_total(&cp_peer->use_count) == 0) + osmo_fsm_inst_dispatch(cp_peer->fi, PFCP_CP_PEER_EV_USE_COUNT_ZERO, NULL); + return 0; +} + +/* Allocate PFCP CP peer FSM and start sending PFCP Association Setup Request messages to remote_addr, using endpoint + * ep. As soon as a successful response is received, change to state PFCP_CP_PEER_ST_ASSOCIATED. + */ +struct osmo_pfcp_cp_peer *osmo_pfcp_cp_peer_alloc(void *ctx, + struct osmo_pfcp_endpoint *ep, + const struct osmo_sockaddr *remote_addr) +{ + struct osmo_pfcp_cp_peer *cp_peer; + struct osmo_fsm_inst *fi = osmo_fsm_inst_alloc(&pfcp_cp_peer_fsm, ctx, NULL, LOGL_DEBUG, NULL); + OSMO_ASSERT(fi); + + cp_peer = talloc(fi, struct osmo_pfcp_cp_peer); + OSMO_ASSERT(cp_peer); + fi->priv = cp_peer; + *cp_peer = (struct osmo_pfcp_cp_peer){ + .fi = fi, + .ep = ep, + .remote_addr = *remote_addr, + .use_count = { + .talloc_object = cp_peer, + .use_cb = pfcp_cp_peer_use_cb, + }, + }; + osmo_use_count_make_static_entries(&cp_peer->use_count, cp_peer->use_count_buf, ARRAY_SIZE(cp_peer->use_count_buf)); + + osmo_fsm_inst_update_id_f_sanitize(fi, '-', osmo_sockaddr_to_str_c(OTC_SELECT, &cp_peer->remote_addr)); + return cp_peer; +} + +int osmo_pfcp_cp_peer_associate(struct osmo_pfcp_cp_peer *cp_peer) +{ + struct osmo_fsm_inst *fi = cp_peer->fi; + + switch (fi->state) { + case PFCP_CP_PEER_ST_DISABLED: + case PFCP_CP_PEER_ST_WAIT_RETRY: + /* Idling. Send Association Setup Request now. */ + return osmo_pfcp_cp_peer_fsm_state_chg(PFCP_CP_PEER_ST_WAIT_ASSOC_SETUP_RESP); + default: + /* Already associated, or busy associating. */ + return 0; + case PFCP_CP_PEER_ST_WAIT_USE_COUNT: + /* Already asked to deallocate. */ + return -ENOLINK; + } + return 0; +} + +static int pfcp_cp_peer_fsm_timer_cb(struct osmo_fsm_inst *fi) +{ + switch (fi->state) { + + case PFCP_CP_PEER_ST_WAIT_RETRY: + osmo_pfcp_cp_peer_fsm_state_chg(PFCP_CP_PEER_ST_WAIT_ASSOC_SETUP_RESP); + return 0; + + default: + return 1; + } +} + +static int on_pfcp_assoc_resp(struct osmo_pfcp_msg *req, struct osmo_pfcp_msg *rx_resp, const char *errmsg); + +/* Send PFCP Association Setup Request */ +static void pfcp_cp_peer_wait_assoc_setup_resp_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state) +{ + struct osmo_pfcp_cp_peer *cp_peer = fi->priv; + struct osmo_pfcp_msg *m; + + m = osmo_pfcp_cp_peer_new_msg_tx(cp_peer, OSMO_PFCP_MSGT_ASSOC_SETUP_REQ); + m->ies.assoc_setup_req.recovery_time_stamp = cp_peer->ep->recovery_time_stamp; + + m->ies.assoc_setup_req.cp_function_features_present = true; + osmo_pfcp_bits_set(m->ies.assoc_setup_req.cp_function_features.bits, OSMO_PFCP_CP_FEAT_BUNDL, true); + + m->ctx.resp_cb = on_pfcp_assoc_resp; + + LOG_CP_PEER(cp_peer, LOGL_NOTICE, "Associating with %s...\n", + osmo_sockaddr_to_str_c(OTC_SELECT, &cp_peer->remote_addr)); + + if (osmo_pfcp_endpoint_tx(cp_peer->ep, m)) { + LOG_CP_PEER(cp_peer, LOGL_ERROR, "Failed to transmit PFCP Association Setup Request to UPF at %s\n", + osmo_sockaddr_to_str_c(OTC_SELECT, &cp_peer->remote_addr)); + osmo_pfcp_cp_peer_fsm_state_chg(PFCP_CP_PEER_ST_WAIT_RETRY); + } +} + +static int on_pfcp_assoc_resp(struct osmo_pfcp_msg *req, struct osmo_pfcp_msg *rx_resp, const char *errmsg) +{ + struct osmo_fsm_inst *fi = req->ctx.peer_fi; + struct osmo_pfcp_cp_peer *cp_peer = fi->priv; + enum osmo_pfcp_cause *cause; + + if (!rx_resp) { + LOG_CP_PEER(cp_peer, LOGL_ERROR, "Error: PFCP Association Setup Response: %s\n", + errmsg ? : "no response received"); + goto assoc_failed; + } + + cause = osmo_pfcp_msg_cause(rx_resp); + if (!cause) { + LOG_CP_PEER(cp_peer, LOGL_ERROR, "Invalid PFCP Association Setup Response: no Cause value\n"); + goto assoc_failed; + } + if (*cause != OSMO_PFCP_CAUSE_REQUEST_ACCEPTED) { + LOG_CP_PEER(cp_peer, LOGL_ERROR, "UPF rejected PFCP Association Setup Request with Cause: %s\n", + osmo_pfcp_cause_str(*cause)); + goto assoc_failed; + } + + osmo_fsm_inst_dispatch(fi, PFCP_CP_PEER_EV_RX_ASSOC_SETUP_RESP, rx_resp); + return 0; + +assoc_failed: + osmo_pfcp_cp_peer_fsm_state_chg(PFCP_CP_PEER_ST_WAIT_RETRY); + return 0; +} + +static void pfcp_cp_peer_wait_assoc_setup_resp_action(struct osmo_fsm_inst *fi, uint32_t event, void *data) +{ + switch (event) { + + case PFCP_CP_PEER_EV_RX_ASSOC_SETUP_RESP: + osmo_pfcp_cp_peer_fsm_state_chg(PFCP_CP_PEER_ST_ASSOCIATED); + break; + + default: + OSMO_ASSERT(false); + } +} + +static void pfcp_cp_peer_associated_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state) +{ + struct osmo_pfcp_cp_peer *cp_peer = fi->priv; + LOG_CP_PEER(cp_peer, LOGL_NOTICE, "Associated with UPF %s\n", + osmo_sockaddr_to_str_c(OTC_SELECT, &cp_peer->remote_addr)); + if (cp_peer->assoc_cb) + cp_peer->assoc_cb(cp_peer, true); +} + +static void pfcp_cp_peer_associated_action(struct osmo_fsm_inst *fi, uint32_t event, void *data) +{ + struct osmo_pfcp_cp_peer *cp_peer = fi->priv; + + switch (event) { + + case PFCP_CP_PEER_EV_RX_ASSOC_UPDATE_REQ: + LOG_CP_PEER(cp_peer, LOGL_ERROR, "PFCP Association Update Request is not implemented\n"); + break; + + default: + OSMO_ASSERT(false); + } +} + +static void pfcp_cp_peer_associated_onleave(struct osmo_fsm_inst *fi, uint32_t next_state) +{ + struct osmo_pfcp_cp_peer *cp_peer = fi->priv; + LOG_CP_PEER(cp_peer, LOGL_NOTICE, "Disassociating from UPF %s\n", + osmo_sockaddr_to_str_c(OTC_SELECT, &cp_peer->remote_addr)); + if (cp_peer->assoc_cb) + cp_peer->assoc_cb(cp_peer, false); +} + +static void pfcp_cp_peer_graceful_release_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state) +{ + struct osmo_pfcp_cp_peer *cp_peer = fi->priv; + LOG_CP_PEER(cp_peer, LOGL_ERROR, "PFCP graceful release is not implemented\n"); +} + +static void pfcp_cp_peer_graceful_release_action(struct osmo_fsm_inst *fi, uint32_t event, void *data) +{ + struct osmo_pfcp_cp_peer *cp_peer = fi->priv; + LOG_CP_PEER(cp_peer, LOGL_ERROR, "PFCP graceful release is not implemented\n"); +} + +static void pfcp_cp_peer_wait_use_count_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state) +{ + struct osmo_pfcp_cp_peer *cp_peer = fi->priv; + if (!osmo_use_count_total(&cp_peer->use_count)) + osmo_fsm_inst_term(fi, OSMO_FSM_TERM_REGULAR, NULL); +} + +static void pfcp_cp_peer_allstate_action(struct osmo_fsm_inst *fi, uint32_t event, void *data) +{ + switch (event) { + case PFCP_CP_PEER_EV_USE_COUNT_ZERO: + switch (fi->state) { + default: + /* still busy, ignore. */ + return; + case PFCP_CP_PEER_ST_WAIT_USE_COUNT: + /* Waiting for deallocation; now there are no more users, deallocate. */ + osmo_fsm_inst_term(fi, OSMO_FSM_TERM_REGULAR, NULL); + return; + } + default: + OSMO_ASSERT(false); + } +} + +#define S(x) (1 << (x)) + +static const struct osmo_fsm_state pfcp_cp_peer_fsm_states[] = { + [PFCP_CP_PEER_ST_DISABLED] = { + .name = "disabled", + .out_state_mask = 0 + | S(PFCP_CP_PEER_ST_WAIT_ASSOC_SETUP_RESP) + | S(PFCP_CP_PEER_ST_WAIT_USE_COUNT) + , + }, + [PFCP_CP_PEER_ST_WAIT_ASSOC_SETUP_RESP] = { + .name = "wait_assoc_setup_resp", + .in_event_mask = 0 + | S(PFCP_CP_PEER_EV_RX_ASSOC_SETUP_RESP) + , + .out_state_mask = 0 + | S(PFCP_CP_PEER_ST_ASSOCIATED) + | S(PFCP_CP_PEER_ST_WAIT_RETRY) + | S(PFCP_CP_PEER_ST_WAIT_USE_COUNT) + , + .onenter = pfcp_cp_peer_wait_assoc_setup_resp_onenter, + .action = pfcp_cp_peer_wait_assoc_setup_resp_action, + }, + [PFCP_CP_PEER_ST_WAIT_RETRY] = { + .name = "wait_retry", + .out_state_mask = 0 + | S(PFCP_CP_PEER_ST_WAIT_ASSOC_SETUP_RESP) + | S(PFCP_CP_PEER_ST_WAIT_USE_COUNT) + , + }, + [PFCP_CP_PEER_ST_ASSOCIATED] = { + .name = "associated", + .in_event_mask = 0 + | S(PFCP_CP_PEER_EV_RX_ASSOC_UPDATE_REQ) + , + .out_state_mask = 0 + | S(PFCP_CP_PEER_ST_WAIT_ASSOC_SETUP_RESP) + | S(PFCP_CP_PEER_ST_GRACEFUL_RELEASE) + | S(PFCP_CP_PEER_ST_WAIT_USE_COUNT) + , + .onenter = pfcp_cp_peer_associated_onenter, + .action = pfcp_cp_peer_associated_action, + .onleave = pfcp_cp_peer_associated_onleave, + }, + [PFCP_CP_PEER_ST_GRACEFUL_RELEASE] = { + .name = "graceful_release", + .in_event_mask = 0 + , + .out_state_mask = 0 + | S(PFCP_CP_PEER_ST_WAIT_RETRY) + | S(PFCP_CP_PEER_ST_WAIT_USE_COUNT) + , + .onenter = pfcp_cp_peer_graceful_release_onenter, + .action = pfcp_cp_peer_graceful_release_action, + }, + [PFCP_CP_PEER_ST_WAIT_USE_COUNT] = { + .name = "wait_use_count", + .in_event_mask = 0 + | S(PFCP_CP_PEER_EV_USE_COUNT_ZERO) + , + .onenter = pfcp_cp_peer_wait_use_count_onenter, + }, +}; + +static struct osmo_fsm pfcp_cp_peer_fsm = { + .name = "pfcp_cp_peer", + .states = pfcp_cp_peer_fsm_states, + .num_states = ARRAY_SIZE(pfcp_cp_peer_fsm_states), + .log_subsys = DLPFCP, + .event_names = pfcp_cp_peer_fsm_event_names, + .timer_cb = pfcp_cp_peer_fsm_timer_cb, + .allstate_action = pfcp_cp_peer_allstate_action, + .allstate_event_mask = 0 + | S(PFCP_CP_PEER_EV_USE_COUNT_ZERO) + , +}; + +static __attribute__((constructor)) void pfcp_cp_peer_fsm_register(void) +{ + OSMO_ASSERT(osmo_fsm_register(&pfcp_cp_peer_fsm) == 0); +} + +bool osmo_pfcp_cp_peer_is_associated(const struct osmo_pfcp_cp_peer *cp_peer) +{ + return cp_peer && cp_peer->fi->state == PFCP_CP_PEER_ST_ASSOCIATED; +} + +void osmo_pfcp_cp_peer_set_msg_ctx(struct osmo_pfcp_cp_peer *cp_peer, struct osmo_pfcp_msg *m) +{ + if (m->ctx.peer_fi) + return; + + m->ctx.peer_fi = cp_peer->fi; + + m->ctx.peer_use_count = &cp_peer->use_count; + m->ctx.peer_use_token = (m->rx ? "PFCPrx" : "PFCPtx"); + osmo_use_count_get_put(m->ctx.peer_use_count, m->ctx.peer_use_token, 1); +} + +struct osmo_pfcp_msg *osmo_pfcp_cp_peer_new_msg_tx(struct osmo_pfcp_cp_peer *cp_peer, + enum osmo_pfcp_message_type msg_type) +{ + struct osmo_pfcp_msg *m; + m = osmo_pfcp_msg_alloc_tx(cp_peer->ep, &cp_peer->remote_addr, &cp_peer->ep->cfg.local_node_id, NULL, + msg_type); + if (!m) + return m; + osmo_pfcp_cp_peer_set_msg_ctx(cp_peer, m); + return m; +} null-- To view, visit https://gerrit.osmocom.org/c/libosmo-pfcp/+/28317 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-pfcp Gerrit-Branch: master Gerrit-Change-Id: If8c5f69f596ea6ba8bd1723f4dc57b91d3799795 Gerrit-Change-Number: 28317 Gerrit-PatchSet: 2 Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-MessageType: merged
1 0
0 0
Change in osmo-hlr[master]: ctrl: Introduce CTRL command subscriber.by-*.msisdn
by pespin 17 Jun '22

17 Jun '22
pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-hlr/+/28319 ) Change subject: ctrl: Introduce CTRL command subscriber.by-*.msisdn ...................................................................... Patch Set 2: Verified+1 (1 comment) Patchset: PS2: Trailing whitespace expected. -- To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/28319 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Change-Id: I5f2e807859f7e28e0984c8dc37edc69319fd8e10 Gerrit-Change-Number: 28319 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Fri, 17 Jun 2022 17:14:15 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
Change in osmo-hlr[master]: ctrl: Introduce CTRL command subscriber.by-*.msisdn
by pespin 17 Jun '22

17 Jun '22
Attention is currently required from: pespin. pespin has removed a vote from this change. ( https://gerrit.osmocom.org/c/osmo-hlr/+/28319 ) Change subject: ctrl: Introduce CTRL command subscriber.by-*.msisdn ...................................................................... Removed Verified-1 by Jenkins Builder (1000002) -- To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/28319 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Change-Id: I5f2e807859f7e28e0984c8dc37edc69319fd8e10 Gerrit-Change-Number: 28319 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: deleteVote
1 0
0 0
Change in osmo-hlr[master]: ctrl: Introduce cmd SET subscriber.create <imsi>
by pespin 17 Jun '22

17 Jun '22
pespin has removed a vote from this change. ( https://gerrit.osmocom.org/c/osmo-hlr/+/28318 ) Change subject: ctrl: Introduce cmd SET subscriber.create <imsi> ...................................................................... Removed Verified-1 by Jenkins Builder (1000002) -- To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/28318 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Change-Id: Id1b760cd07712245a0eeabaac7891bce93c1fe8e Gerrit-Change-Number: 28318 Gerrit-PatchSet: 3 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: deleteVote
1 0
0 0
Change in osmo-hlr[master]: ctrl: Introduce cmd SET subscriber.create <imsi>
by pespin 17 Jun '22

17 Jun '22
pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-hlr/+/28318 ) Change subject: ctrl: Introduce cmd SET subscriber.create <imsi> ...................................................................... Patch Set 3: Verified+1 (1 comment) Patchset: PS3: Trailing whitespace expected. -- To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/28318 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Change-Id: Id1b760cd07712245a0eeabaac7891bce93c1fe8e Gerrit-Change-Number: 28318 Gerrit-PatchSet: 3 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Fri, 17 Jun 2022 17:13:54 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
Change in osmo-hlr[master]: Fix db_subscr_create() not returning -EEXIST expected by VTY subscrib...
by pespin 17 Jun '22

17 Jun '22
Attention is currently required from: pespin. Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/osmo-hlr/+/28316 to look at the new patch set (#2). Change subject: Fix db_subscr_create() not returning -EEXIST expected by VTY subscriber create cmd ...................................................................... Fix db_subscr_create() not returning -EEXIST expected by VTY subscriber create cmd As a result, the -EEXIST code path printing a specific error for inserting already existing subscribers was not being triggered. Change-Id: Id24dc6e0ff5115c8c9025404dd7296250d2b03ee --- M src/db_hlr.c M tests/db/db_test.c M tests/db/db_test.err 3 files changed, 14 insertions(+), 11 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/16/28316/2 -- To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/28316 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Change-Id: Id24dc6e0ff5115c8c9025404dd7296250d2b03ee Gerrit-Change-Number: 28316 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: newpatchset
1 0
0 0
Change in osmo-hlr[master]: ctrl: Introduce cmd SET subscriber.create <imsi>
by pespin 17 Jun '22

17 Jun '22
Attention is currently required from: pespin. Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/osmo-hlr/+/28318 to look at the new patch set (#3). Change subject: ctrl: Introduce cmd SET subscriber.create <imsi> ...................................................................... ctrl: Introduce cmd SET subscriber.create <imsi> Create a new subscriber from CTRL, similar to VTY command "imsi IDENT create". On success SET_REPLY contains the ID of the newly created subscriber. Related: SYS#5993 Change-Id: Id1b760cd07712245a0eeabaac7891bce93c1fe8e --- M include/osmocom/hlr/logging.h M src/ctrl.c M src/logging.c M tests/test_subscriber.ctrl M tests/test_subscriber_errors.ctrl 5 files changed, 66 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/18/28318/3 -- To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/28318 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Change-Id: Id1b760cd07712245a0eeabaac7891bce93c1fe8e Gerrit-Change-Number: 28318 Gerrit-PatchSet: 3 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: newpatchset
1 0
0 0
Change in osmo-hlr[master]: ctrl: Introduce CTRL command subscriber.by-*.msisdn
by pespin 17 Jun '22

17 Jun '22
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-hlr/+/28319 ) Change subject: ctrl: Introduce CTRL command subscriber.by-*.msisdn ...................................................................... ctrl: Introduce CTRL command subscriber.by-*.msisdn This command provides getter and setter to set and retrieve the MSISDN of a subscriber. Related: SYS#5993 Change-Id: I5f2e807859f7e28e0984c8dc37edc69319fd8e10 --- M src/ctrl.c M tests/test_subscriber.ctrl M tests/test_subscriber_errors.ctrl 3 files changed, 101 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/19/28319/1 diff --git a/src/ctrl.c b/src/ctrl.c index 0596a25..9d39a8d 100644 --- a/src/ctrl.c +++ b/src/ctrl.c @@ -388,6 +388,57 @@ return set_subscr_cs_ps_enabled(cmd, data, false); } +CTRL_CMD_DEFINE(subscr_msisdn, "msisdn"); +static int verify_subscr_msisdn(struct ctrl_cmd *cmd, const char *value, void *data) +{ + struct hlr_subscriber subscr; + if (!value) + return 1; + if (strlen(value) > sizeof(subscr.msisdn) - 1) + return 1; + if (strcmp(value, "none") != 0 && !osmo_msisdn_str_valid(value)) + return 1; + return 0; +} +static int get_subscr_msisdn(struct ctrl_cmd *cmd, void *data) +{ + struct hlr_subscriber subscr; + struct hlr *hlr = data; + const char *by_selector = cmd->node; + + if (!get_subscriber(hlr->dbc, by_selector, &subscr, cmd)) + return CTRL_CMD_ERROR; + + if (strlen(subscr.msisdn) == 0) + snprintf(subscr.msisdn, sizeof(subscr.msisdn), "none"); + + cmd->reply = talloc_asprintf(cmd, "%s", subscr.msisdn); + return CTRL_CMD_REPLY; +} +static int set_subscr_msisdn(struct ctrl_cmd *cmd, void *data) +{ + struct hlr_subscriber subscr; + struct hlr *hlr = data; + const char *by_selector = cmd->node; + const char *msisdn; + + if (!get_subscriber(hlr->dbc, by_selector, &subscr, cmd)) + return CTRL_CMD_ERROR; + + if (strcmp(cmd->value, "none") == 0) + msisdn = NULL; + else + msisdn = cmd->value; + + if (db_subscr_update_msisdn_by_imsi(g_hlr->dbc, subscr.imsi, msisdn)) { + cmd->reply = "Update MSISDN failed"; + return CTRL_CMD_ERROR; + } + + cmd->reply = "OK"; + return CTRL_CMD_REPLY; +} + static int hlr_ctrl_node_lookup(void *data, vector vline, int *node_type, void **node_data, int *i) { @@ -424,6 +475,7 @@ rc |= ctrl_cmd_install(CTRL_NODE_SUBSCR_BY, &cmd_subscr_info_all); rc |= ctrl_cmd_install(CTRL_NODE_SUBSCR_BY, &cmd_subscr_ps_enabled); rc |= ctrl_cmd_install(CTRL_NODE_SUBSCR_BY, &cmd_subscr_cs_enabled); + rc |= ctrl_cmd_install(CTRL_NODE_SUBSCR_BY, &cmd_subscr_msisdn); return rc; } diff --git a/tests/test_subscriber.ctrl b/tests/test_subscriber.ctrl index 8d3c9dc..5b49702 100644 --- a/tests/test_subscriber.ctrl +++ b/tests/test_subscriber.ctrl @@ -624,3 +624,49 @@ periodic_lu_timer 0 periodic_rau_tau_timer 0 lmsi 00000000 + +GET 103 subscriber.by-imsi-901991234567891.msisdn +GET_REPLY 103 subscriber.by-imsi-901991234567891.msisdn none + +SET 104 subscriber.by-imsi-901991234567891.msisdn 555666 +SET_REPLY 104 subscriber.by-imsi-901991234567891.msisdn OK + +GET 105 subscriber.by-imsi-901991234567891.msisdn +GET_REPLY 105 subscriber.by-imsi-901991234567891.msisdn 555666 + +SET 106 subscriber.by-imsi-901991234567891.msisdn 888000 +SET_REPLY 106 subscriber.by-imsi-901991234567891.msisdn OK + +GET 107 subscriber.by-imsi-901991234567891.msisdn +GET_REPLY 107 subscriber.by-imsi-901991234567891.msisdn 888000 + +GET 108 subscriber.by-imsi-901991234567891.info +GET_REPLY 108 subscriber.by-imsi-901991234567891.info +id 124 +imsi 901991234567891 +msisdn 888000 +nam_cs 1 +nam_ps 1 +ms_purged_cs 0 +ms_purged_ps 0 +periodic_lu_timer 0 +periodic_rau_tau_timer 0 +lmsi 00000000 + +SET 109 subscriber.by-imsi-901991234567891.msisdn none +SET_REPLY 109 subscriber.by-imsi-901991234567891.msisdn OK + +GET 110 subscriber.by-imsi-901991234567891.msisdn +GET_REPLY 110 subscriber.by-imsi-901991234567891.msisdn none + +GET 111 subscriber.by-imsi-901991234567891.info +GET_REPLY 111 subscriber.by-imsi-901991234567891.info +id 124 +imsi 901991234567891 +nam_cs 1 +nam_ps 1 +ms_purged_cs 0 +ms_purged_ps 0 +periodic_lu_timer 0 +periodic_rau_tau_timer 0 +lmsi 00000000 diff --git a/tests/test_subscriber_errors.ctrl b/tests/test_subscriber_errors.ctrl index 425b0df..8309e61 100644 --- a/tests/test_subscriber_errors.ctrl +++ b/tests/test_subscriber_errors.ctrl @@ -114,3 +114,6 @@ SET 50 subscriber.create 901990000000001 ERROR 50 Subscriber already exists. + +SET 51 subscriber.by-imsi-1234567890123456.msisdn hellobadmsisdn +ERROR 51 Value failed verification. -- To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/28319 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Change-Id: I5f2e807859f7e28e0984c8dc37edc69319fd8e10 Gerrit-Change-Number: 28319 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
Change in osmo-hlr[master]: ctrl: Introduce cmd SET subscriber.create <imsi>
by pespin 17 Jun '22

17 Jun '22
Attention is currently required from: pespin. Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/osmo-hlr/+/28318 to look at the new patch set (#2). Change subject: ctrl: Introduce cmd SET subscriber.create <imsi> ...................................................................... ctrl: Introduce cmd SET subscriber.create <imsi> Create a new subscriber from CTRL, similar to VTY command "imsi IDENT create". On success SET_REPLY contains the ID of the newly created subscriber. Related: SYS#5993 Change-Id: Id1b760cd07712245a0eeabaac7891bce93c1fe8e --- M include/osmocom/hlr/logging.h M src/ctrl.c M src/logging.c M tests/test_subscriber.ctrl M tests/test_subscriber_errors.ctrl 5 files changed, 66 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/18/28318/2 -- To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/28318 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Change-Id: Id1b760cd07712245a0eeabaac7891bce93c1fe8e Gerrit-Change-Number: 28318 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: newpatchset
1 0
0 0
Change in osmo-hlr[master]: ctrl: Introduce cmd SET subscriber.create <imsi>
by pespin 17 Jun '22

17 Jun '22
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-hlr/+/28318 ) Change subject: ctrl: Introduce cmd SET subscriber.create <imsi> ...................................................................... ctrl: Introduce cmd SET subscriber.create <imsi> Create a new subscriber from CTRL, similar to VTY command "imsi IDENT create". On success SET_REPLY contains the ID of the newly created subscriber. Related: SYS#5993 Change-Id: Id1b760cd07712245a0eeabaac7891bce93c1fe8e --- M include/osmocom/hlr/logging.h M src/ctrl.c M src/logging.c M tests/test_subscriber.ctrl M tests/test_subscriber_errors.ctrl 5 files changed, 66 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/18/28318/1 diff --git a/include/osmocom/hlr/logging.h b/include/osmocom/hlr/logging.h index a8081af..0a44a08 100644 --- a/include/osmocom/hlr/logging.h +++ b/include/osmocom/hlr/logging.h @@ -11,6 +11,7 @@ DMSLOOKUP, DLU, DDGSM, + DCTRL, }; extern const struct log_info hlr_log_info; diff --git a/src/ctrl.c b/src/ctrl.c index 37177c5..0596a25 100644 --- a/src/ctrl.c +++ b/src/ctrl.c @@ -197,6 +197,43 @@ aud->u.umts.sqn); } +CTRL_CMD_DEFINE_WO_NOVRF(subscr_create, "create"); +static int set_subscr_create(struct ctrl_cmd *cmd, void *data) +{ + struct hlr_subscriber subscr; + struct hlr *hlr = data; + const char *imsi = cmd->value; + int rc; + + if (!osmo_imsi_str_valid(imsi)) { + cmd->reply = "Invalid IMSI value."; + return CTRL_CMD_ERROR; + } + + /* Create the subscriber in the DB */ + rc = db_subscr_create(g_hlr->dbc, imsi, DB_SUBSCR_FLAG_NAM_CS | DB_SUBSCR_FLAG_NAM_PS); + if (rc) { + if (rc == -EEXIST) + cmd->reply = "Subscriber already exists."; + else + cmd->reply = "Cannot create subscriber."; + return CTRL_CMD_ERROR; + } + + LOGP(DCTRL, LOGL_ERROR, "Created subscriber IMSI='%s'\n", + imsi); + + /* Retrieve data of newly created subscriber: */ + rc = db_subscr_get_by_imsi(hlr->dbc, imsi, &subscr); + if (rc < 0) { + cmd->reply = "Failed retreiving ID of newly created subscriber."; + return CTRL_CMD_ERROR; + } + + cmd->reply = talloc_asprintf(cmd, "%" PRIu64, subscr.id); + return CTRL_CMD_REPLY; +} + CTRL_CMD_DEFINE_RO(subscr_info, "info"); static int get_subscr_info(struct ctrl_cmd *cmd, void *data) { @@ -380,6 +417,8 @@ { int rc = 0; + rc |= ctrl_cmd_install(CTRL_NODE_SUBSCR, &cmd_subscr_create); + rc |= ctrl_cmd_install(CTRL_NODE_SUBSCR_BY, &cmd_subscr_info); rc |= ctrl_cmd_install(CTRL_NODE_SUBSCR_BY, &cmd_subscr_info_aud); rc |= ctrl_cmd_install(CTRL_NODE_SUBSCR_BY, &cmd_subscr_info_all); diff --git a/src/logging.c b/src/logging.c index eab0510..b7c265e 100644 --- a/src/logging.c +++ b/src/logging.c @@ -43,6 +43,12 @@ .color = "\033[1;35m", .enabled = 1, .loglevel = LOGL_NOTICE, }, + [DCTRL] = { + .name = "DDGSM", + .description = "Distributed GSM: MS lookup and proxy", + .color = "\033[1;30m", + .enabled = 1, .loglevel = LOGL_NOTICE, + }, }; const struct log_info hlr_log_info = { diff --git a/tests/test_subscriber.ctrl b/tests/test_subscriber.ctrl index 756e888..a5db5f3 100644 --- a/tests/test_subscriber.ctrl +++ b/tests/test_subscriber.ctrl @@ -610,3 +610,17 @@ periodic_rau_tau_timer 0 lmsi 00000000 +SET 101 subscriber.create 901991234567891 +SET_REPLY 101 subscriber.create 124 + +GET 100 subscriber.by-id-124.info +GET_REPLY 100 subscriber.by-id-124.info +id 124 +imsi 901991234567891 +nam_cs 1 +nam_ps 1 +ms_purged_cs 0 +ms_purged_ps 0 +periodic_lu_timer 0 +periodic_rau_tau_timer 0 +lmsi 00000000 diff --git a/tests/test_subscriber_errors.ctrl b/tests/test_subscriber_errors.ctrl index 0c5b587..425b0df 100644 --- a/tests/test_subscriber_errors.ctrl +++ b/tests/test_subscriber_errors.ctrl @@ -108,3 +108,9 @@ GET 48 subscriber.by-id-0x0123.info ERROR 48 Invalid value part of 'by-xxx-value' selector. + +SET 49 subscriber.create zzz +ERROR 49 Invalid IMSI value. + +SET 50 subscriber.create 901990000000001 +ERROR 50 Subscriber already exists. -- To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/28318 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Change-Id: Id1b760cd07712245a0eeabaac7891bce93c1fe8e Gerrit-Change-Number: 28318 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • ...
  • 138
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.