Skip to content

fix(agent): identify an aperiodic subscription by its whole RIC ID - #36

Draft
Thecave3 wants to merge 1 commit into
duranta-project:devfrom
Thecave3:aperiodic-indication-ric-id
Draft

Thecave3 wants to merge 1 commit into
duranta-project:devfrom
Thecave3:aperiodic-indication-ric-id

Conversation

@Thecave3

@Thecave3 Thecave3 commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

An aperiodic indication is routed to its subscription by the RIC Requestor ID alone, and a service model can be handed another model's indication data.

This continues #16, which was closed when its base branch update-ubuntu-support was deleted after #31 merged. It is the same change rebased onto the current dev: one commit, and no longer a copy of #31's commits.

Why it happens

e2_async_event_agent() resolves the subscription an aperiodic indication answers with eq_ind_event_ric_req_id, which compares ric_req_id and ignores ric_inst_id and ran_func_id. But ag->ind_event is keyed on the full ric_gen_id_t and can hold several entries that share a Requestor ID: E2AP identifies a subscription by {RequestorID, InstanceID}. async_event_agent_api() did not even carry the RAN function, so the lookup could not have told them apart.

First match wins, and cmp_ric_gen_id orders ran_func_id descending, so the highest-numbered RAN function under a Requestor ID captures every aperiodic indication sent under it. Its service model is then given an ind_data of another model's type, decodes a foreign struct, and the RAN process aborts.

Is this reachable?

It is dormant with FlexRIC's own near-RT RIC, which allocates a new Requestor ID per subscription (ric->req_id++). The O-RAN SC near-RT RIC does not: its subscription manager sets one fixed Requestor ID on every subscription it sends (const ricRequestorId = 123 in pkg/control/control.go), so every subscription on a node arrives under the same one. An xApp holding subscriptions on two RAN functions through that RIC is enough.

The change

  • ric_gen_id_t is carried end to end instead of ric_req_id: sm_subs_data_t, wr_rc_sub_data_t, async_event_agent_api(), e2_async_event_agent() and free_aper_subs. stop_ind_event() already had the whole ID and was discarding the rest.
  • The lookup uses the existing full-ID eq_ind_event. eq_ind_event_ric_req_id is deleted, since it has no correct use.
  • The aperiodic fd had the same defect. It was derived as -ric_req_id, so two subscriptions sharing a Requestor ID collide on the bi_map key, and Requestor ID 0 gives fd 0, which stop_ind_event() reads back as a real fd. It now counts down from -1.
  • assert(it != l && "Not found RIC Request ID") becomes a logged drop. An indication for a subscription that was just deleted is a race the RAN can lose legitimately. With the RAN function now at hand, the service model is resolved and handed the payload to free.

This changes the signature of async_event_agent_api() and of the subscription structs a service model's on_subscription fills, so out-of-tree service models and RAN-side callers need to pass the whole ID. In this tree that is rc_sm_agent.c, the RC emulator and the tests.

Tests

test/aperiodic_routing/ is new. It builds a stub agent holding three aperiodic subscriptions under Requestor ID 123 (RAN functions 3 and 142, and 142 again with a different instance ID) and checks each indication reaches the subscription with the whole ID.

e2_async_event_agent() resolved the subscription an aperiodic indication
answers with eq_ind_event_ric_req_id, which compares ric_req_id only.
ag->ind_event is keyed on the full ric_gen_id_t and can hold several entries
sharing a RIC Requestor ID: E2AP identifies a subscription by
{RequestorID, InstanceID}, and the O-RAN SC near-RT RIC's subscription manager
sets one fixed Requestor ID on every subscription it sends (ricRequestorId =
123, pkg/control/control.go).

First match wins, and cmp_ric_gen_id orders ran_func_id descending, so the
highest-numbered RAN function under that Requestor ID captures every aperiodic
indication. Its service model is then handed another model's ind_data, decodes
a foreign struct and aborts the RAN process.

Carry ric_gen_id_t end to end (sm_subs_data_t, wr_rc_sub_data_t, the async API,
free_aper_subs) and match on it with the existing eq_ind_event. Delete
eq_ind_event_ric_req_id, which has no correct use.

The aperiodic fd had the same defect. It was derived as -ric_req_id, so two
subscriptions sharing a Requestor ID collide on the bi_map key, and Requestor
ID 0 yields fd 0, which stop_ind_event() reads back as a real fd. Count down
from -1 instead.

An indication for a subscription that was just deleted is a race the RAN can
lose legitimately, so log and drop it instead of asserting.

It is dormant with FlexRIC's own near-RT RIC, which allocates a new Requestor
ID per subscription.

test/aperiodic_routing/ routes three subscriptions under one Requestor ID and
fails on the Requestor-ID-only matching.

Assisted-by: Claude:claude-sonnet-5-5
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.

1 participant