Skip to content

Conversation

@themarwhal
Copy link
Member

@themarwhal themarwhal commented Aug 25, 2020

Signed-off-by: Marie Bremner marwhal@fb.com

Summary

This diff includes the actual implementation to handle a set message of session->rules from PolicyDB.
The steps needed to accomplish this is the following:

  1. Receive SetSessionRules request
  2. Push a function into the event loop to handle the request.
    a. Fetch the list of sessions mentioned in the request from SessionStore
    b. Go through each session and apply a combination of subscriber wide RuleSet and APN specific RuleSet
    c. Since this is a set message, we will want to install any rules in the set that does not already exist and remove any rules in the session that does not exist in the set.
    d. Propagate the rule change to PipelineD. If applicable, we will also create/delete dedicated bearers.
    e. Apply the updates back to SessionStore
  3. Respond to PolicyDB with status OK

Since we need to do many looks up in the rule set we receive, I've defined two new structures to make that easier. By converting the received proto message to the following structures, we do not have to iterate through the rules every time.

struct RuleSetToApply {
  std::unordered_map<std::string, PolicyRule> dynamic_rules;
  std::unordered_set<std::string> static_rules;
};
struct RuleSetBySubscriber {
  std::string imsi;
  std::unordered_map<std::string, RuleSetToApply> rule_set_by_apn;
  std::experimental::optional<RuleSetToApply> subscriber_wide_rule_set;
};

Two additional unit tests were added to test the SessionState and LocalEnforcer layer.

Test Plan

SessionD unit tests
S1AP test

Additional Information

  • This change is backwards-breaking

@themarwhal themarwhal requested a review from uri200 as a code owner August 25, 2020 14:31
Signed-off-by: Marie Bremner <marwhal@fb.com>
Copy link
Contributor

@ulaskozat ulaskozat left a comment

Choose a reason for hiding this comment

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

LGTM. We should add an integration test for this in another PR.

@ulaskozat ulaskozat merged commit bca3852 into magma:master Aug 25, 2020
prabinakpattnaik pushed a commit to prabinakpattnaik/magma that referenced this pull request Aug 25, 2020
@themarwhal themarwhal deleted the policydb-rule-install-impl branch August 27, 2020 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: agw Access gateway-related issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[sessiond] Set interface for policy rules that include IMSI and APN info that uniquely matches to a session at sessiond

2 participants