-
Notifications
You must be signed in to change notification settings - Fork 25
ROX-29399: Directional external-IPs #2130
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
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
ae32b56
Use the working version of the proto defs
ovalenti d4c351c
External-IPs can be enabled just in one direction
ovalenti 7195315
Additional unit tests with ingres and egress directions
ovalenti 13f2ef5
Rewrite to make the logic clearer
ovalenti 2e17cf4
Move ExternalIPsConfig to its own file.
ovalenti 41109ea
Directly make use of the ExternalIPsConfig in ConnTracker
ovalenti a4faa05
Trigger afterglow early connection close independently for each direc…
ovalenti bb0afb6
Move config change detection logic to Conntracker
ovalenti 36fb9f4
Refactor: limit the number of public methods and improve readability
ovalenti a42d526
Extract config to variable for more readability
ovalenti 9b8ae8a
Factorize the lambda content
ovalenti 75384fb
Use the finalized version of the proto defs
ovalenti 5ea1a23
Document runtime-config and the `direction` attribute
ovalenti 3464e73
Reordering ingress/egress description in the example sentence.
ovalenti 811b289
Forbid calls to .IsEnabled() with NONE
ovalenti 15dad81
Rename external_IPs_config_ -> external_ips_config_
ovalenti be59b85
Rename ExternalIPsConfig() -> GetExternalIPsConfig()
ovalenti f605fff
More ExternalIPsConfig unit tests
ovalenti 0110225
Added a couple of unit tests
JoukoVirtanen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#include "ExternalIPsConfig.h" | ||
|
||
namespace collector { | ||
|
||
ExternalIPsConfig::ExternalIPsConfig(std::optional<sensor::CollectorConfig> runtime_config, bool default_enabled) { | ||
if (!runtime_config.has_value()) { | ||
direction_enabled_ = default_enabled ? Direction::BOTH : Direction::NONE; | ||
return; | ||
} | ||
|
||
// At this point we know runtime_config has a value, we can access it directly | ||
const auto& external_ips = runtime_config->networking().external_ips(); | ||
if (external_ips.enabled() != sensor::ExternalIpsEnabled::ENABLED) { | ||
direction_enabled_ = Direction::NONE; | ||
return; | ||
} | ||
|
||
switch (external_ips.direction()) { | ||
case sensor::ExternalIpsDirection::INGRESS: | ||
direction_enabled_ = Direction::INGRESS; | ||
break; | ||
case sensor::ExternalIpsDirection::EGRESS: | ||
direction_enabled_ = Direction::EGRESS; | ||
break; | ||
default: | ||
direction_enabled_ = Direction::BOTH; | ||
break; | ||
} | ||
} | ||
|
||
std::ostream& operator<<(std::ostream& os, const ExternalIPsConfig& config) { | ||
os << "direction("; | ||
|
||
switch (config.GetDirection()) { | ||
case ExternalIPsConfig::Direction::NONE: | ||
os << "NONE"; | ||
break; | ||
case ExternalIPsConfig::Direction::INGRESS: | ||
os << "INGRESS"; | ||
break; | ||
case ExternalIPsConfig::Direction::EGRESS: | ||
os << "EGRESS"; | ||
break; | ||
case ExternalIPsConfig::Direction::BOTH: | ||
os << "BOTH"; | ||
break; | ||
default: | ||
os << "invalid"; | ||
break; | ||
} | ||
|
||
return os << ")"; | ||
} | ||
|
||
} // namespace collector |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#pragma once | ||
|
||
#include <assert.h> | ||
#include <optional> | ||
#include <ostream> | ||
|
||
#include <internalapi/sensor/collector.pb.h> | ||
|
||
namespace collector { | ||
|
||
// Encapsulates the configuration of the External-IPs feature | ||
class ExternalIPsConfig { | ||
public: | ||
enum Direction { | ||
NONE = 0, | ||
JoukoVirtanen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
INGRESS = 1 << 0, | ||
EGRESS = 1 << 1, | ||
BOTH = INGRESS | EGRESS, | ||
}; | ||
|
||
// Are External-IPs enabled in the provided direction ? | ||
bool IsEnabled(Direction direction) const { | ||
assert(direction != Direction::NONE); | ||
return (direction & direction_enabled_) == direction; | ||
} | ||
|
||
// Direction in which External-IPs are enabled | ||
Direction GetDirection() const { return direction_enabled_; } | ||
|
||
// Extract the External-IPs configuration from the provided runtime-conf. | ||
// If the runtime-configuration is unset then 'default_enabled' is used | ||
// as a fallback to enable in both directions. | ||
// 'runtime_config' should be locked prior to calling. | ||
ExternalIPsConfig(std::optional<sensor::CollectorConfig> runtime_config, bool default_enabled); | ||
|
||
ExternalIPsConfig(Direction direction = Direction::NONE) : direction_enabled_(direction) {} | ||
|
||
private: | ||
Direction direction_enabled_; | ||
}; | ||
|
||
std::ostream& operator<<(std::ostream& os, const ExternalIPsConfig& config); | ||
|
||
} // end namespace collector |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule stackrox
updated
3556 files
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.