8000 Update URR report by chen042531 · Pull Request #139 · free5gc/gtp5g · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Update URR report #139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Mar 5, 2025
Merged

Conversation

chen042531
Copy link
Contributor
@chen042531 chen042531 commented Feb 7, 2025

Refactor period counter statistics and reading mechanism to ensure data consistency

Changes:

  • Reader

    1. Update the table that the writer will write to (opposite to the one being read).
    2. Read data.
  • Writer

    1. Acquire the target table for writing.
    2. Write data.

Locking mechanism adjustments:

  • Reader lock scope:

    • Lock is held while updating the writer's target table and released immediately after, allowing the reader to read the current table freely.
  • Writer lock scope:

    • Lock is held while acquiring the target table and writing data.
    • Ensures consistency between packet count and packet volume, preventing a scenario where packet count is updated but packet volume remains stale before the reader fetches the data.

// set the use_bytes2 flag to the opposite value
urr->use_bytes2 = !urr->use_bytes2;
// sleep for 1 millisecond to make sure the counter is updated
// before the report is converted
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// before converting to the report

include/urr.h Outdated
@@ -79,6 +79,7 @@ struct urr {
struct Volume volumequota;

// For usage report volume measurement
bool use_bytes2;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to

    bool use_vol2;
    struct VolumeMeasurement vol;
    struct VolumeMeasurement vol2;

src/gtpu/encap.c Outdated
@@ -670,15 +670,16 @@ int update_urr_counter_and_send_report(struct pdr *pdr, struct far *far, u64 vol
} else {
volume = vol;
}

// Caculate Volume measurement for each trigger
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix typo Calculate

include/urr.h Outdated
struct VolumeMeasurement bytes;
struct VolumeMeasurement bytes2;
bool use_vol2;
struct VolumeMeasurement vol;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to vol1

@@ -158,13 +158,15 @@ int gtp5g_genl_get_usage_report(struct sk_buff *skb, struct genl_info *info)
goto fail;
}

// set the use_vol2 flag to the opposite value
Copy link
Collaborator
@tim-ywliu tim-ywliu Mar 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// use the other one vol counter

@@ -250,13 +252,15 @@ int gtp5g_genl_get_multi_usage_reports(struct sk_buff *skb, struct genl_info *in
goto fail;
}

// set the use_vol2 flag to the opposite value
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// use the other one vol counter

@chen042531 chen042531 force-pushed the urr-counter-update branch from 4507bfe to a2ca3e7 Compare March 4, 2025 08:35
…ta consistency

Changes:
- Reader
  1. Update the table that the writer will write to (opposite to the one being read).
  2. Read data.

- Writer
  1. Acquire the target table for writing.
  2. Write data.

Locking mechanism adjustments:
- Reader lock scope:
  - Lock is held while updating the writer's target table and released immediately after, allowing the reader to read the current table freely.

- Writer lock scope:
  - Lock is held while acquiring the target table and writing data.
  - Ensures consistency between packet count and packet volume, preventing a scenario where packet count is updated but packet volume remains stale before the reader fetches the data.
@chen042531 chen042531 force-pushed the urr-counter-update branch from a2ca3e7 to e1d3a98 Compare March 4, 2025 08:38
@tim-ywliu tim-ywliu force-pushed the urr-counter-update branch from cb12d3c to 2c5a3ed Compare March 5, 2025 13:34
@tim-ywliu tim-ywliu merged commit 0b16b14 into free5gc:master Mar 5, 2025
convert_urr_to_report(urrs[i], &report[i]);
}
urr_counter = get_urr_counter_by_trigger(urrs[i], triggers[i]);
convert_urr_to_report(urr, urr_counter, &report[i]);
Copy link
Collaborator
@ianchen0119 ianchen0119 Mar 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chen042531 @tim-ywliu
This change introduces a new bug in the online charging feature. I believe the first parameter should be urrs[i] instead of urr.
I propose a fix for this issue in #143 , please help to review the PR.

Thanks!

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.

3 participants
0