Skip to content
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

Add VRRP checks for if instance is an owner. #37

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Paul-weqe
Copy link
Member

VRRP instance is an owner if it holds a virtual IP address as it's parent interface. Currently checked during virtual-address configuration and when the primary interface has change in addresses (addition / deletion) which may affect the is_owner state.

Adding owner logic to FSM is work in progress

VRRP instance is an owner if it holds a virtual IP
address as it's parent interface. Currently being
checked during virtual-address configuration and
when the primary interface has change in addresses
(addition / deletion) which may affect the is_owner
state.

Signed-off-by: Paul Wekesa <[email protected]>
@Paul-weqe Paul-weqe requested a review from rwestphal December 11, 2024 16:33
Copy link

codecov bot commented Dec 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 58.37%. Comparing base (937a1b3) to head (023a835).
Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #37      +/-   ##
==========================================
+ Coverage   57.90%   58.37%   +0.47%     
==========================================
  Files         201      200       -1     
  Lines       50537    50135     -402     
  Branches    50537    50135     -402     
==========================================
+ Hits        29264    29267       +3     
+ Misses      19379    19132     -247     
+ Partials     1894     1736     -158     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

.virtual_addresses
.iter()
.any(|addr| interface_sys.addresses.contains(addr));
false
Copy link
Member

Choose a reason for hiding this comment

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

You should return the result of the last expression instead of always returning false

@@ -403,6 +412,16 @@ impl Instance {
let _ = net.net_tx_packetp.send(msg);
}
}

/// an instance is an owner if the ip address of the parent interface is
Copy link
Member

Choose a reason for hiding this comment

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

Comments should start with an uppercase for consistency with the rest of the codebase

@@ -403,6 +412,16 @@ impl Instance {
let _ = net.net_tx_packetp.send(msg);
}
}

/// an instance is an owner if the ip address of the parent interface is
/// part of the virutal addresses held by the instance.
Copy link
Member

Choose a reason for hiding this comment

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

typo (s/virutal/virtual/)

@@ -234,6 +238,9 @@ impl Provider for Interface {
);
instance.timer_set(&interface);
}
// owner status may change when virtual address is added
Copy link
Member

Choose a reason for hiding this comment

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

Owner status can also change when an IP address is added to or removed from the interface.

For simplicity, we could compute the owner status on demand whenever necessary, instead of caching and continuously updating it. There's only a few places where we need to consult the owner status, and computing it is a cheap operation.

Copy link
Member Author

@Paul-weqe Paul-weqe Dec 12, 2024

Choose a reason for hiding this comment

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

@rwestphal You're right, the owner status can also change when an IP address is added or removed from an interface.

I will add the check_is_owner() to only be called on demand. This will also mean removing the is_owner field from Instance.

My thought process was I wanted to cover cases where we have access to Instance but no access to InterfaceSys(which is needed for checking owner status). Seeing how the VRRP codebase is structured, that was a pretty terrible choice since we always fetch the Instance from the Interface and will almost always have access to InterfaceSys, either via the View or the Interface directly.

Update vrrp's is_owner checks based on reviews:

- call check_is_owner() on demand.
- Comment Capitalization.
- spelling checks

General changes:
- have the check_is_owner check be positive for
all virtual IP addresses instead of any of them

Signed-off-by: Paul Wekesa <[email protected]>
@Paul-weqe
Copy link
Member Author

@rwestphal I believe the failing clippy check is a false negative.

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.

2 participants