Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit fce0eb4
Author: Sukchan Lee <acetcom@gmail.com>
Date:   Fri Jul 8 21:36:52 2022 +0900

    [SBI] fixed wrong request-nf-type (#1650)

commit fe11ee1
Author: Oliver Smith <osmith@sysmocom.de>
Date:   Mon Jul 4 15:16:54 2022 +0200

    d/open5gs-upf.postinst: don't restart service in chroot

    Don't attempt to restart systemd-networkd if systemd is not running
    (e.g. installing open5gs inside a chroot).

    Fix for:
      System has not been booted with systemd as init system (PID 1). Can't operate.
      Failed to connect to bus: Host is down
      dpkg: error processing package open5gs-upf:amd64 (--configure):
       installed open5gs-upf:amd64 package post-installation script subprocess returned error exit status 1

commit eabe8df
Author: Sukchan Lee <acetcom@gmail.com>
Date:   Mon Jul 4 17:37:00 2022 +0900

    [PFCP] Added UE IP address in the EPC (#1642)

commit 29525b2
Author: Networkmama <networkmama12@gmail.com>
Date:   Fri Jul 1 22:44:58 2022 +0530

    [SMF] copy UE ip address to uplink PDR rules.

    This helps UPF to add ACL based on src ip

    Signed-off-by: Networkmama <networkmama12@gmail.com>

commit af4021b
Author: Sukchan Lee <acetcom@gmail.com>
Date:   Mon Jul 4 17:30:19 2022 +0900

    [PFCP] Fixed a endianness Apply Action (#1640)

commit 318fc25
Author: Sukchan Lee <acetcom@gmail.com>
Date:   Fri Jul 1 21:49:31 2022 +0900

    [CORE] Added memory check (#1638)

commit 6adf541
Author: Bostjan Meglic <b.meglic@iskratel.si>
Date:   Wed Jun 29 12:58:05 2022 +0000

    [CORE] Fix detection of a failed memory allocation

commit ab11220
Author: Bostjan Meglic <b.meglic@iskratel.si>
Date:   Wed Jun 29 12:15:51 2022 +0000

    [ALL] Fix differences in function parameter names between definition and declaration

commit 114f783
Author: Bostjan Meglic <b.meglic@iskratel.si>
Date:   Thu Jun 30 05:55:19 2022 +0000

    [MISC] Add support for static code analysis

    Static code analysis can be executed with following commands:
      meson build
      ninja -C build analyze-cppcheck
      ninja -C build analyze-clang-tidy

    These commands are available only if additional tools are installed:
      - cppcheck
      - clang-tidy
      - clang-tools is optional if you want to paralelize the clang-tidy

    In case of cppcheck analysis, a file called build/cppchecklog.log is
    created with the analysis results.

    In case of clang-tidy analysis, some checks are disabled. See file
    .clang-tidy, and reenable them if you see fit.
    Also it does not scan all the files in the project, since some of them
    are imported from other sources. It does not scan any sources under:
      - subprojects/
      - lib/asn1c/
      - lib/ipfw/

commit 50be661
Author: Sukchan Lee <acetcom@gmail.com>
Date:   Thu Jun 30 13:33:16 2022 +0900

    Fixed a crash when slice/session overflow (#1637)

commit ad159d1
Author: Sukchan Lee <acetcom@gmail.com>
Date:   Thu Jun 30 10:53:19 2022 +0900

    [GTP] Refine error code path without assertion

    Refer to #1635, #1620, #1606, #1594

commit b1d982a
Author: Sukchan Lee <acetcom@gmail.com>
Date:   Thu Jun 30 10:35:03 2022 +0900

    [PFCP] Refine error code path without assertion

    Refer to #1635, #1620

commit 0be5e76
Author: Sukchan Lee <acetcom@gmail.com>
Date:   Thu Jun 30 09:11:38 2022 +0900

    Revert "[SGWC] pfcp: Retrieve sess when SEID=0 (#1620)"

    This reverts commit 9700563.

commit 6332f10
Author: Sukchan Lee <acetcom@gmail.com>
Date:   Thu Jun 30 09:11:31 2022 +0900

    Revert "[GTP] context when TEID=0 (#1620, #1606, #1594)"

    This reverts commit 0d61f7a.

commit 051c19b
Author: Sukchan Lee <acetcom@gmail.com>
Date:   Wed Jun 29 14:35:01 2022 +0900

    Changes MAX TLV MORE to 16

    OGS_MAX_NUM_OF_PDR is 16, but OGS_TLV_MAX_MORE is 8.
    To match the size of two macros, increased OGS_TLV_MAX_MORE to 16.

commit b5956e5
Author: Pau Espin Pedrol <pespin@sysmocom.de>
Date:   Wed Jun 29 04:10:43 2022 +0200

    [UPF] N4: Remove unnecessary assert (#1634)

commit 52d5c61
Author: Sukchan Lee <acetcom@gmail.com>
Date:   Wed Jun 29 11:07:44 2022 +0900

    [GTP] avoid abort for ogs_gtp_node_new() (#1633)

commit c5a5450
Author: Pau Espin Pedrol <pespin@sysmocom.de>
Date:   Wed Jun 29 03:28:18 2022 +0200

    [GTP] Avoid abort if ogs_gtp_node_new() returns NULL (#1633)

    * [GTP] Avoid abort if ogs_gtp_node_new() returns NULL

    * [SGWC] Avoid abort if ogs_gtp_node_add_by_addr() returns NULL

commit 2dd577f
Author: Sukchan Lee <acetcom@gmail.com>
Date:   Tue Jun 28 16:58:15 2022 +0900

    [SCTP] Add protection code jumbo frame (#1632)

commit 0d61f7a
Author: Sukchan Lee <acetcom@gmail.com>
Date:   Tue Jun 28 15:32:14 2022 +0900

    [GTP] context when TEID=0 (#1620, #1606, #1594)

commit 9700563
Author: Sukchan Lee <acetcom@gmail.com>
Date:   Tue Jun 28 13:20:46 2022 +0900

    [SGWC] pfcp: Retrieve sess when SEID=0 (#1620)

commit 5eaf662
Author: Pau Espin Pedrol <pespin@sysmocom.de>
Date:   Tue Jun 28 04:19:57 2022 +0200

    [SMF] pfcp: Retrieve sess when response with SEID=0 is received (#1620)

    3GPP TS 29.244 7.2.2.4.2 documents that the peer will set SEID=0 in the
    response when we request something for a session not existing at the peer.
    If that's the case, we still want to locate the local session which
    originated the request, so let's store the local SEID in the xact when
    submitting the message, so that we can retrieve the related SEID and
    find the session if we receive SEID=0.

commit a3593c6
Author: Pau Espin Pedrol <pespin@sysmocom.de>
Date:   Mon Jun 27 14:51:14 2022 +0200

    [SMF] Gn: QoS Profile and PCO IE improvements (#1631)
  • Loading branch information
acetcom committed Jul 9, 2022
1 parent b7c5ae0 commit f43f73a
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 36 deletions.
129 changes: 94 additions & 35 deletions lib/sbi/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ static char *add_params_to_uri(CURL *easy, char *uri, ogs_hash_t *params)
return uri;
}

static void _connection_remove(connection_t *conn);

static connection_t *connection_add(
ogs_sbi_client_t *client, ogs_sbi_client_cb_f client_cb,
ogs_sbi_request_t *request, void *data)
Expand All @@ -269,37 +271,67 @@ static connection_t *connection_add(
conn->data = data;

conn->method = ogs_strdup(request->h.method);
ogs_expect_or_return_val(conn->method, NULL);
if (!conn->method) {
ogs_error("conn->method is NULL");
_connection_remove(conn);
return NULL;
}

conn->num_of_header = ogs_hash_count(request->http.headers);
if (conn->num_of_header) {
conn->headers = ogs_calloc(conn->num_of_header, sizeof(char *));
ogs_expect_or_return_val(conn->headers, NULL);
if (!conn->headers) {
ogs_error("conn->headers is NULL");
_connection_remove(conn);
return NULL;
}
for (hi = ogs_hash_first(request->http.headers), i = 0;
hi && i < conn->num_of_header; hi = ogs_hash_next(hi), i++) {
const char *key = ogs_hash_this_key(hi);
char *val = ogs_hash_this_val(hi);

conn->headers[i] = ogs_msprintf("%s: %s", key, val);
ogs_expect_or_return_val(conn->headers[i], NULL);
if (!conn->headers[i]) {
ogs_error("conn->headers[i=%d] is NULL", i);
_connection_remove(conn);
return NULL;
}
conn->header_list = curl_slist_append(
conn->header_list, conn->headers[i]);
}
}

conn->timer = ogs_timer_add(
ogs_app()->timer_mgr, connection_timer_expired, conn);
ogs_expect_or_return_val(conn->timer, NULL);

ogs_list_add(&client->connection_list, conn);
if (!conn->timer) {
ogs_error("conn->timer is NULL");
_connection_remove(conn);
return NULL;
}

/* If http response is not received within deadline,
* Open5GS will discard this request. */
ogs_timer_start(conn->timer,
ogs_app()->time.message.sbi.connection_deadline);

conn->easy = curl_easy_init();
ogs_assert(conn->easy);
if (!conn->easy) {
ogs_error("conn->easy is NULL");
_connection_remove(conn);
return NULL;
}

if (ogs_hash_count(request->http.params)) {
char *uri = add_params_to_uri(conn->easy,
request->h.uri, request->http.params);
if (!uri) {
ogs_error("add_params_to_uri() failed");
_connection_remove(conn);
return NULL;
}

request->h.uri = uri;
}

/* HTTP Method */
if (strcmp(request->h.method, OGS_SBI_HTTP_METHOD_PUT) == 0 ||
Expand All @@ -312,7 +344,11 @@ static connection_t *connection_add(
if (request->http.content) {
conn->content = ogs_memdup(
request->http.content, request->http.content_length);
ogs_assert(conn->content);
if (!conn->content) {
ogs_error("conn->content is NULL");
_connection_remove(conn);
return NULL;
}
curl_easy_setopt(conn->easy,
CURLOPT_POSTFIELDS, conn->content);
curl_easy_setopt(conn->easy,
Expand All @@ -336,11 +372,7 @@ static connection_t *connection_add(
CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE);
#endif

if (ogs_hash_count(request->http.params)) {
request->h.uri = add_params_to_uri(conn->easy,
request->h.uri, request->http.params);
ogs_expect_or_return_val(request->h.uri, NULL);
}
ogs_list_add(&client->connection_list, conn);

curl_easy_setopt(conn->easy, CURLOPT_URL, request->h.uri);

Expand All @@ -358,47 +390,57 @@ static connection_t *connection_add(
return conn;
}

static void connection_remove(connection_t *conn)
static void _connection_remove(connection_t *conn)
{
ogs_sbi_client_t *client = NULL;
int i;

ogs_assert(conn);
client = conn->client;
ogs_assert(client);

ogs_list_remove(&client->connection_list, conn);

ogs_assert(conn->timer);
ogs_timer_delete(conn->timer);

ogs_assert(conn->easy);
ogs_assert(client->multi);
curl_multi_remove_handle(client->multi, conn->easy);
curl_easy_cleanup(conn->easy);

ogs_assert(conn->method);
ogs_free(conn->method);

if (conn->content)
ogs_free(conn->content);

if (conn->location)
ogs_free(conn->location);

if (conn->memory)
ogs_free(conn->memory);

if (conn->easy)
curl_easy_cleanup(conn->easy);

if (conn->timer)
ogs_timer_delete(conn->timer);

if (conn->num_of_header) {
for (i = 0; i < conn->num_of_header; i++)
ogs_free(conn->headers[i]);
if (conn->headers[i])
ogs_free(conn->headers[i]);
ogs_free(conn->headers);
}
curl_slist_free_all(conn->header_list);

if (conn->memory)
ogs_free(conn->memory);
if (conn->method)
ogs_free(conn->method);

ogs_pool_free(&connection_pool, conn);
}

static void connection_remove(connection_t *conn)
{
ogs_sbi_client_t *client = NULL;

ogs_assert(conn);
client = conn->client;
ogs_assert(client);

ogs_list_remove(&client->connection_list, conn);

ogs_assert(client->multi);
curl_multi_remove_handle(client->multi, conn->easy);

_connection_remove(conn);
}

static void connection_remove_all(ogs_sbi_client_t *client)
{
connection_t *conn = NULL, *next_conn = NULL;
Expand Down Expand Up @@ -502,7 +544,7 @@ static void check_multi_info(ogs_sbi_client_t *client)
}
}

bool ogs_sbi_client_send_request(
bool ogs_sbi_client_send_reqmem_persistent(
ogs_sbi_client_t *client, ogs_sbi_client_cb_f client_cb,
ogs_sbi_request_t *request, void *data)
{
Expand All @@ -513,15 +555,32 @@ bool ogs_sbi_client_send_request(

if (request->h.uri == NULL) {
request->h.uri = ogs_sbi_client_uri(client, &request->h);
ogs_expect_or_return_val(request->h.uri, false);
}
ogs_debug("[%s] %s", request->h.method, request->h.uri);

conn = connection_add(client, client_cb, request, data);
ogs_expect_or_return_val(conn, false);

return true;
}

bool ogs_sbi_client_send_request(
ogs_sbi_client_t *client, ogs_sbi_client_cb_f client_cb,
ogs_sbi_request_t *request, void *data)
{
bool rc;

ogs_assert(client);
ogs_assert(request);

rc = ogs_sbi_client_send_reqmem_persistent(
client, client_cb, request, data);
ogs_expect(rc == true);

ogs_sbi_request_free(request);

return true;
return rc;
}

static size_t write_cb(void *contents, size_t size, size_t nmemb, void *data)
Expand Down
4 changes: 4 additions & 0 deletions lib/sbi/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ void ogs_sbi_client_remove(ogs_sbi_client_t *client);
void ogs_sbi_client_remove_all(void);
ogs_sbi_client_t *ogs_sbi_client_find(ogs_sockaddr_t *addr);

bool ogs_sbi_client_send_reqmem_persistent(
ogs_sbi_client_t *client, ogs_sbi_client_cb_f client_cb,
ogs_sbi_request_t *request, void *data);

bool ogs_sbi_client_send_request(
ogs_sbi_client_t *client, ogs_sbi_client_cb_f client_cb,
ogs_sbi_request_t *request, void *data);
Expand Down
2 changes: 1 addition & 1 deletion src/nrf/sbi-path.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static int server_cb(ogs_sbi_request_t *request, void *data)
if (rv != OGS_DONE)
ogs_error("ogs_queue_push() failed:%d", (int)rv);
else
ogs_error("ogs_queue_push() failed:%d", (int)rv);
ogs_warn("ogs_queue_push() failed:%d", (int)rv);
ogs_sbi_request_free(request);
nrf_event_free(e);
return OGS_ERROR;
Expand Down

0 comments on commit f43f73a

Please sign in to comment.