neels has submitted this change. ( https://gerrit.osmocom.org/c/osmo-upf/+/28753 )
Change subject: apply refactoring of osmo_pfcp_msg_alloc API ......................................................................
apply refactoring of osmo_pfcp_msg_alloc API
libosmo-pfcp I0d71134e42932cc72992eba73a15e82bc7cd11bd clarifies the osmo_pfcp_msg_alloc functions, apply the necessary changes here.
Related: SYS#5599 Depends: I0d71134e42932cc72992eba73a15e82bc7cd11bd (libosmo-pfcp) Change-Id: I73e6da3b80f05e9408c81f41ac05d6578b8e31cf --- M src/osmo-pfcp-tool/pfcp_tool_vty.c M src/osmo-upf/up_endpoint.c M src/osmo-upf/up_peer.c 3 files changed, 24 insertions(+), 30 deletions(-)
Approvals: neels: Looks good to me, approved Jenkins Builder: Verified
diff --git a/src/osmo-pfcp-tool/pfcp_tool_vty.c b/src/osmo-pfcp-tool/pfcp_tool_vty.c index 2943c76..8593217 100644 --- a/src/osmo-pfcp-tool/pfcp_tool_vty.c +++ b/src/osmo-pfcp-tool/pfcp_tool_vty.c @@ -193,8 +193,7 @@ return CMD_WARNING; }
- m = osmo_pfcp_msg_alloc_tx(OTC_SELECT, &peer->remote_addr, &g_pfcp_tool->ep->cfg.local_node_id, NULL, - OSMO_PFCP_MSGT_ASSOC_SETUP_REQ); + m = osmo_pfcp_msg_alloc_tx_req(OTC_SELECT, &peer->remote_addr, OSMO_PFCP_MSGT_ASSOC_SETUP_REQ); m->ies.assoc_setup_req.recovery_time_stamp = g_pfcp_tool->ep->recovery_time_stamp;
m->ies.assoc_setup_req.cp_function_features_present = true; @@ -222,7 +221,9 @@ return CMD_WARNING; }
- m = osmo_pfcp_msg_alloc_tx(OTC_SELECT, &peer->remote_addr, &g_pfcp_tool->ep->cfg.local_node_id, NULL, 0); + /* Allocate using API function to have the usual talloc destructor set up, then copy the last request or + * response over it. */ + m = osmo_pfcp_msg_alloc_rx(OTC_SELECT, &peer->remote_addr); if (strcmp(argv[0], "req") == 0) *m = peer->last_req; else @@ -392,8 +393,7 @@ }; osmo_pfcp_ip_addrs_set(&cp_f_seid.ip_addr, &g_pfcp_tool->ep->cfg.local_addr);
- m = osmo_pfcp_msg_alloc_tx(OTC_SELECT, &peer->remote_addr, &g_pfcp_tool->ep->cfg.local_node_id, NULL, - OSMO_PFCP_MSGT_SESSION_EST_REQ); + m = osmo_pfcp_msg_alloc_tx_req(OTC_SELECT, &peer->remote_addr, OSMO_PFCP_MSGT_SESSION_EST_REQ); m->h.seid_present = true; /* the UPF has yet to assign a SEID for itself, no matter what SEID we (the CPF) use for this session */ m->h.seid = 0; @@ -567,8 +567,7 @@ }; osmo_pfcp_ip_addrs_set(&cp_f_seid.ip_addr, &g_pfcp_tool->ep->cfg.local_addr);
- m = osmo_pfcp_msg_alloc_tx(OTC_SELECT, &peer->remote_addr, &g_pfcp_tool->ep->cfg.local_node_id, NULL, - OSMO_PFCP_MSGT_SESSION_EST_REQ); + m = osmo_pfcp_msg_alloc_tx_req(OTC_SELECT, &peer->remote_addr, OSMO_PFCP_MSGT_SESSION_EST_REQ); m->h.seid_present = true; m->h.seid = 0; /* GTP tunmap: remove header from both directions, and add header in both directions */ @@ -688,8 +687,7 @@ }; osmo_pfcp_ip_addrs_set(&cp_f_seid.ip_addr, &g_pfcp_tool->ep->cfg.local_addr);
- m = osmo_pfcp_msg_alloc_tx(OTC_SELECT, &peer->remote_addr, &g_pfcp_tool->ep->cfg.local_node_id, NULL, - OSMO_PFCP_MSGT_SESSION_MOD_REQ); + m = osmo_pfcp_msg_alloc_tx_req(OTC_SELECT, &peer->remote_addr, OSMO_PFCP_MSGT_SESSION_MOD_REQ); m->h.seid_present = true; m->h.seid = session->up_f_seid.seid; m->ies.session_mod_req = (struct osmo_pfcp_msg_session_mod_req){ @@ -732,8 +730,7 @@ return CMD_WARNING; }
- m = osmo_pfcp_msg_alloc_tx(OTC_SELECT, &peer->remote_addr, &g_pfcp_tool->ep->cfg.local_node_id, NULL, - OSMO_PFCP_MSGT_SESSION_DEL_REQ); + m = osmo_pfcp_msg_alloc_tx_req(OTC_SELECT, &peer->remote_addr, OSMO_PFCP_MSGT_SESSION_DEL_REQ); m->h.seid_present = true; m->h.seid = session->up_f_seid.seid;
diff --git a/src/osmo-upf/up_endpoint.c b/src/osmo-upf/up_endpoint.c index b33e112..ef3702a 100644 --- a/src/osmo-upf/up_endpoint.c +++ b/src/osmo-upf/up_endpoint.c @@ -62,13 +62,12 @@ }
static void up_ep_rx_not_impl_req(struct up_endpoint *up_ep, const struct osmo_pfcp_msg *m, - enum osmo_pfcp_message_type resp_msgt, - const struct osmo_pfcp_ie_node_id *node_id, enum osmo_pfcp_cause cause) + enum osmo_pfcp_message_type resp_msgt, enum osmo_pfcp_cause cause) { struct osmo_pfcp_msg *tx; enum osmo_pfcp_cause *tx_cause; OSMO_LOG_PFCP_MSG(m, LOGL_ERROR, "message type not implemented\n"); - tx = osmo_pfcp_msg_alloc_tx(OTC_SELECT, NULL, &up_ep->pfcp_ep->cfg.local_node_id, m, resp_msgt); + tx = osmo_pfcp_msg_alloc_tx_resp(OTC_SELECT, m, resp_msgt); tx_cause = osmo_pfcp_msg_cause(tx); if (tx_cause) *tx_cause = cause; @@ -77,7 +76,7 @@
static void up_ep_rx_pfd_mgmt_req(struct up_endpoint *up_ep, const struct osmo_pfcp_msg *m) { - up_ep_rx_not_impl_req(up_ep, m, OSMO_PFCP_MSGT_PFD_MGMT_RESP, NULL, OSMO_PFCP_CAUSE_SERVICE_NOT_SUPPORTED); + up_ep_rx_not_impl_req(up_ep, m, OSMO_PFCP_MSGT_PFD_MGMT_RESP, OSMO_PFCP_CAUSE_SERVICE_NOT_SUPPORTED); }
static void up_ep_rx_assoc_setup_req(struct up_endpoint *up_ep, const struct osmo_pfcp_msg *m) @@ -95,8 +94,7 @@ if (!m->ctx.peer_fi) { struct osmo_pfcp_msg *tx; OSMO_LOG_PFCP_MSG(m, LOGL_ERROR, "Peer is not associated, cannot update association\n"); - tx = osmo_pfcp_msg_alloc_tx(OTC_SELECT, NULL, &up_ep->pfcp_ep->cfg.local_node_id, m, OSMO_PFCP_MSGT_ASSOC_UPDATE_RESP); - /* FIXME set node_id, cause */ + tx = osmo_pfcp_msg_alloc_tx_resp(OTC_SELECT, m, OSMO_PFCP_MSGT_ASSOC_UPDATE_RESP); osmo_pfcp_endpoint_tx(up_ep->pfcp_ep, tx); return; } @@ -108,8 +106,7 @@ if (!m->ctx.peer_fi) { struct osmo_pfcp_msg *tx; OSMO_LOG_PFCP_MSG(m, LOGL_ERROR, "Peer is not associated. Sending ACK response anyway\n"); - tx = osmo_pfcp_msg_alloc_tx(OTC_SELECT, NULL, &up_ep->pfcp_ep->cfg.local_node_id, m, OSMO_PFCP_MSGT_ASSOC_RELEASE_RESP); - /* FIXME set node_id, cause */ + tx = osmo_pfcp_msg_alloc_tx_resp(OTC_SELECT, m, OSMO_PFCP_MSGT_ASSOC_RELEASE_RESP); osmo_pfcp_endpoint_tx(up_ep->pfcp_ep, tx); return; } @@ -118,14 +115,13 @@
static void up_ep_rx_node_report_req(struct up_endpoint *up_ep, const struct osmo_pfcp_msg *m) { - up_ep_rx_not_impl_req(up_ep, m, OSMO_PFCP_MSGT_NODE_REPORT_RESP, NULL /* FIXME? */, - OSMO_PFCP_CAUSE_SERVICE_NOT_SUPPORTED); + up_ep_rx_not_impl_req(up_ep, m, OSMO_PFCP_MSGT_NODE_REPORT_RESP, OSMO_PFCP_CAUSE_SERVICE_NOT_SUPPORTED); }
static void up_ep_rx_session_set_del_req(struct up_endpoint *up_ep, const struct osmo_pfcp_msg *m) { up_ep_rx_not_impl_req(up_ep, m, OSMO_PFCP_MSGT_SESSION_SET_DEL_RESP, - &up_ep->pfcp_ep->cfg.local_node_id, OSMO_PFCP_CAUSE_SERVICE_NOT_SUPPORTED); + OSMO_PFCP_CAUSE_SERVICE_NOT_SUPPORTED); }
static void up_ep_rx_session_est_req(struct up_endpoint *up_ep, const struct osmo_pfcp_msg *m) @@ -133,7 +129,7 @@ if (!m->ctx.peer_fi) { struct osmo_pfcp_msg *tx; OSMO_LOG_PFCP_MSG(m, LOGL_ERROR, "Peer is not associated, cannot establish session\n"); - tx = osmo_pfcp_msg_alloc_tx(OTC_SELECT, NULL, &up_ep->pfcp_ep->cfg.local_node_id, m, OSMO_PFCP_MSGT_SESSION_EST_RESP); + tx = osmo_pfcp_msg_alloc_tx_resp(OTC_SELECT, m, OSMO_PFCP_MSGT_SESSION_EST_RESP); tx->ies.session_est_resp.cause = OSMO_PFCP_CAUSE_NO_ESTABLISHED_PFCP_ASSOC; osmo_pfcp_endpoint_tx(up_ep->pfcp_ep, tx); return; @@ -146,8 +142,7 @@ if (!m->ctx.session_fi) { /* Session not found. */ struct osmo_pfcp_msg *tx; - tx = osmo_pfcp_msg_alloc_tx(OTC_SELECT, NULL, &up_ep->pfcp_ep->cfg.local_node_id, m, - OSMO_PFCP_MSGT_SESSION_MOD_RESP); + tx = osmo_pfcp_msg_alloc_tx_resp(OTC_SELECT, m, OSMO_PFCP_MSGT_SESSION_MOD_RESP); if (!m->ctx.peer_fi) { /* Not even the peer is associated. */ OSMO_LOG_PFCP_MSG(m, LOGL_ERROR, "Peer is not associated, cannot modify session\n"); @@ -169,7 +164,7 @@ if (!m->ctx.session_fi) { /* Session not found. */ struct osmo_pfcp_msg *tx; - tx = osmo_pfcp_msg_alloc_tx(OTC_SELECT, NULL, &up_ep->pfcp_ep->cfg.local_node_id, m, OSMO_PFCP_MSGT_SESSION_DEL_RESP); + tx = osmo_pfcp_msg_alloc_tx_resp(OTC_SELECT, m, OSMO_PFCP_MSGT_SESSION_DEL_RESP); if (!m->ctx.peer_fi) { /* Not even the peer is associated. */ OSMO_LOG_PFCP_MSG(m, LOGL_ERROR, "Peer is not associated, cannot delete session\n"); @@ -188,7 +183,7 @@
static void up_ep_rx_session_rep_req(struct up_endpoint *up_ep, const struct osmo_pfcp_msg *m) { - up_ep_rx_not_impl_req(up_ep, m, OSMO_PFCP_MSGT_SESSION_REP_RESP, NULL, OSMO_PFCP_CAUSE_SERVICE_NOT_SUPPORTED); + up_ep_rx_not_impl_req(up_ep, m, OSMO_PFCP_MSGT_SESSION_REP_RESP, OSMO_PFCP_CAUSE_SERVICE_NOT_SUPPORTED); }
static void up_endpoint_rx_cb(struct osmo_pfcp_endpoint *ep, struct osmo_pfcp_msg *m, struct osmo_pfcp_msg *req) diff --git a/src/osmo-upf/up_peer.c b/src/osmo-upf/up_peer.c index d0d7dbd..633e458 100644 --- a/src/osmo-upf/up_peer.c +++ b/src/osmo-upf/up_peer.c @@ -194,9 +194,11 @@ struct osmo_pfcp_msg *up_peer_init_tx(struct up_peer *peer, struct osmo_pfcp_msg *in_reply_to, enum osmo_pfcp_message_type message_type) { - struct osmo_pfcp_msg *tx = osmo_pfcp_msg_alloc_tx(OTC_SELECT, &peer->remote_addr, - &peer->up_endpoint->pfcp_ep->cfg.local_node_id, - in_reply_to, message_type); + struct osmo_pfcp_msg *tx; + if (in_reply_to) + tx = osmo_pfcp_msg_alloc_tx_resp(OTC_SELECT, in_reply_to, message_type); + else + tx = osmo_pfcp_msg_alloc_tx_req(OTC_SELECT, &peer->remote_addr, message_type); up_peer_set_msg_ctx(peer, tx); return tx; }