Skip to content

e2ap: complete the RIC Service Update procedure - #11

Draft
Thecave3 wants to merge 4 commits into
duranta-project:devfrom
Thecave3:ric-service-update
Draft

Thecave3 wants to merge 4 commits into
duranta-project:devfrom
Thecave3:ric-service-update

Conversation

@Thecave3

Copy link
Copy Markdown
Collaborator

Why

RIC Service Update is the only way an E2 node can tell the RIC that its RAN function
list changed after E2 Setup — a function added, revised or withdrawn while the node is
running. In dev the procedure is declared and then stops at
assert(0 != 0 && "Untested code") in the v2.03 decoder, so a node that sends one takes
the RIC down.

Nothing in the tree exercises it today, which is why the gaps below have gone unnoticed.
They are not all "unimplemented": three are wrong rather than missing.

What this fixes

  • The decoder aborts. Four assert(0 != 0 && "Untested code") paths in
    v2_03/dec/e2ap_msg_dec_asn.c replaced with real decoding.
  • eq_ric_service_update() compared the modified list inverted — in all three E2AP
    versions. It returned equal for different lists and different for equal ones.
  • The deleted list was appended to the modified list's IE, so a withdrawal was
    encoded as a revision.
  • Optional IEs were read positionally, which misreads any message that omits one.
  • No TransactionID, which the procedure requires.

Plus trigger_ric_service_update_api(), so a service model that re-advertises its
definition at runtime has something to call, and a logged drop instead of an abort in
msg_handler_ric.c when an E2 node is not in conn_e2_nodes.

Scope

This is a bug-fix PR against existing E2AP code. It carries no new service model and no
dApp or E3 content. It is a prerequisite for the E2SM-DAPP PR that follows, but it stands
on its own and is reviewable by anyone who does not care about that one.

Verification

Built against dev with -DKPM_VERSION=KPM_V3_00; clean build, no new warnings.
ctest 12 of 14.

The two failures are Unit_test_Agent_RIC_xApp and Unit_test_nearRT_RIC, and they are
pre-existing on dev: both abort at
src/ric/plugin_ric.c:187: sm_plugin_ric: Assertion 'it != end_it && "RAN function ID not found in the RAN"'. I built pristine dev separately to confirm the same two fail the
same way, and plugin_ric.c and both test harnesses are untouched by this PR.

Worth knowing when reproducing: both tests dlopen everything in the plugin directory, so
run them with -p <dir containing only this build's service models> or unrelated plugins
from another build will fail them for a different reason.

@durantabot

Copy link
Copy Markdown
Collaborator

CI Build: #44 | Failed on the following stages:

@durantabot

Copy link
Copy Markdown
Collaborator

CI Build: #79 | Failed on the following stages:

@Thecave3
Thecave3 marked this pull request as draft November 17, 2026 15:55
Ninjabippo1205 and others added 4 commits November 26, 2026 08:37
eq_ric_service_update() compared the entries of the modified list with

  if (eq_ran_function(&m0->modified[i], &m1->modified[i]))
    return false;

so it reported two RIC Service Updates as different precisely when their
modified lists matched, and as equal when they did not. The added and
deleted lists next to it both test for == false; only this one is missing
it. Present identically in v1_01, v2_03 and v3_01.

It has gone unnoticed because the only caller is the encode/decode round
trip test, and that test is not run: the RIC Service Update codec asserted
"Untested code", so the test was commented out of main(). The next commit
implements the codec and enables the test, which is how this surfaced.

Co-authored-by: Andrea Lacava <thecave003@gmail.com>
Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Andrea Lacava <thecave003@gmail.com>
Both e2ap_enc_service_update_asn_pdu() and e2ap_dec_service_update()
(and their Acknowledge counterparts) opened with

  assert(0 != 0 && "Untested code");

so the procedure could not be exercised at all. Beneath the assert the
code did not match the ASN.1:

  - The mandatory TransactionID IE was never encoded, although the
    decoder read it from index 0 and E2AP marks it mandatory.
  - All three RAN-function lists were encoded unconditionally, so an
    update carrying only one of them still emitted two empty
    RANfunctions-Lists, violating SIZE(1..maxofRANfunctionID).
  - The decoder read the lists positionally, at fixed indices 1..3.
    Since every list is optional, any update that omitted one read the
    wrong IE, or an IE that was not there.
  - The deleted list built RANfunction-ItemIEs and appended them to
    ran_mod's list rather than ran_del's, using RANfunction-Item where
    the ASN.1 asks for RANfunctionID-Item.
  - RANfunctionsAdded and RANfunctionsModified are distinct CHOICE
    members of the same generated type (RANfunctions_List and
    RANfunctions_List_1). The encoder had them the other way round from
    the decoder.
  - In the Acknowledge, the accepted and rejected items were tagged
    ProtocolIE_ID_id_RANfunction_Item instead of
    ProtocolIE_ID_id_RANfunctionID_Item, and criticality was ignore
    where the ASN.1 says reject.

The decoder now reads the TransactionID at index 0 and dispatches the
remaining IEs by id rather than by position, which is what makes the
optional lists work in any combination.

test_service_update() and test_service_update_ack() already existed but
were commented out of main(). They are enabled, given the transaction id
to round trip, and the update test now fills all three lists at once --
filling only one, as before, would not have caught the added/modified
member mix-up. test_service_update_empty() covers the other boundary: an
update carrying nothing but the mandatory TransactionID.

Co-authored-by: Andrea Lacava <thecave003@gmail.com>
Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Andrea Lacava <thecave003@gmail.com>
mv_rd_e2_setup() ended in assert(0 != 0 && "Unknown types"), so an E2
SETUP answer whose service-model definition type is not one of the eight
handled here takes the whole process down.

That is reachable without anything being wrong: the plugin directory is
scanned, not enumerated, so a service model left in libs_dir by another
install is loaded and answers E2 SETUP with a type this build has no case
for. It is also what a build configured with a different service-model
set hits against an agent that has more.

Leave dst zeroed instead. A service model is selected by RAN-function id
when a subscription arrives, so one that is not modelled here is simply
never chosen; there is no path that consumes the zeroed definition.

Co-authored-by: Andrea Lacava <thecave003@gmail.com>
Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Andrea Lacava <thecave003@gmail.com>
With the codec in place the procedure still had no implementation on
either side: e2ap_handle_service_update_ric() was
assert(0 != 0 && "Not Implemented"), the agent had no way to send an
update, and RIC_SERVICE_UPDATE reached neither the iApp dispatch table
nor the E2 node registry.

A service model whose RAN function definition depends on state the RAN
only learns after E2 SETUP has no other way to tell the RIC: E2 SETUP
happens once per connection. This closes that gap.

Agent side:
  - e2_send_ric_service_update() encodes and sends the update.
  - trigger_ric_service_update_api(ran_func_id) re-advertises one RAN
    function with a monotonically increasing revision, which is what
    makes the RIC replace the stored definition instead of rejecting a
    duplicate. It takes the RAN function id rather than picking a
    service model itself, so it stays independent of which service
    models a deployment loads.
  - e2ap_handle_service_update_ack_agent() reports the outcome and
    names any RAN function the RIC rejected.

RIC side:
  - e2ap_handle_service_update_ric() applies the added and deleted
    lists to the E2 node's accepted set and answers with a RIC Service
    Update Acknowledge listing what it took.
  - The update carries no node id, so near_ric resolves it from the
    socket the message arrived on, via the new reverse lookup
    find_map_sad_e2_node(). That lookup returns false rather than
    asserting when the socket has no node registered, and an update for
    an unknown node is logged and dropped: this path is driven by
    whatever arrives on the SCTP socket, so an assertion there would let
    a stale or malformed update from any peer take the RIC down.
  - The update is forwarded to the iApp, which applies it to the E2 node
    registry through the new update_reg_e2_node(), so an xApp connecting
    afterwards sees the current RAN function list.

RIC Service Update Failure is still unimplemented; a rejected update is
reported through the Acknowledge's rejected list.

Co-authored-by: Andrea Lacava <thecave003@gmail.com>
Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Andrea Lacava <thecave003@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants