-
Notifications
You must be signed in to change notification settings - Fork 9
User ACLs logic implementation #1634
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
17 commits
Select commit
Hold shift + click to select a range
06e8d4e
feat(lpm): Implement From<...> for RangeSpec<u16> for types with ports
qmonnet 190f051
feat(config): Implement From<AclProtoMatch> for MaskSpec<u8>
qmonnet 01fd377
chore(config): Derive Copy for AclProtoMatch
qmonnet cbff5b7
feat(config): Add acl() method to ValidatedPeering
qmonnet 07b12b3
feat(config): Reject empty ACL lists
qmonnet a698e02
chore(config): Remove AclProtoMatch::Icmp variant
qmonnet 7bfbac8
feat(config): For ACLs, normalise AclProtoMatch(6|17) as TCP/UDP
qmonnet f2b44ea
feat(acl): Add feature for reference backend, Arc-share DpdkAclLookup
daniel-noland d44dae3
feat(acl-filter): Add and implement new ACL filter crate
qmonnet 3b8f381
feat(acl-filter): Implement Display trait for acl-filter's context
qmonnet 51e8ae9
feat(acl-filter): impl Display for PacketSummary
Fredi-raspall df4c100
test(acl-filter): Add unit tests for ACL filter
qmonnet 63ee4d4
feat(net,acl-filter): add DoneReason::AclDropped
Fredi-raspall b148aab
feat(dataplane,mgmt): Init EAL early for the ACL filter rte_acl backend
daniel-noland aa1c1e7
feat(dataplane,mgmt): Add ACL filter pipeline stage
qmonnet 2eb6312
fix(acl,acl-filter): Defer atomic statics via LazyLock for loom
qmonnet 7faebaa
feat(acl-filter): add tracing target for acl-filter
Fredi-raspall 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,37 @@ | ||
| [package] | ||
| name = "dataplane-acl-filter" | ||
| edition.workspace = true | ||
| license.workspace = true | ||
| publish.workspace = true | ||
| version.workspace = true | ||
|
|
||
| [dependencies] | ||
| acl = { workspace = true } | ||
| common = { workspace = true } | ||
| concurrency = { workspace = true } | ||
| config = { workspace = true } | ||
| dpdk = { workspace = true } | ||
| indenter = { workspace = true } | ||
| linkme = { workspace = true } | ||
| lookup = { workspace = true } | ||
| lpm = { workspace = true } | ||
| match-action = { workspace = true, features = ["derive"] } | ||
| net = { workspace = true } | ||
| pipeline = { workspace = true } | ||
| tracectl = { workspace = true } | ||
| tracing = { workspace = true } | ||
|
|
||
| [dev-dependencies] | ||
| # The reference (linear-scan) ACL backend is the differential-test oracle and drives the fast, | ||
| # EAL-free semantic suite. It is `cfg(test)`-gated in the source, so it is never part of a | ||
| # production build; this dev-dep just makes `acl::reference` available to test builds. | ||
| acl = { workspace = true, features = ["reference"] } | ||
| config = { workspace = true, features = ["testing"] } | ||
| dpdk = { workspace = true, features = ["test"] } | ||
| flow-entry = { workspace = true } | ||
| flow-filter = { workspace = true } | ||
| lpm = { workspace = true, features = ["testing"] } | ||
| nat = { workspace = true } | ||
| net = { workspace = true, features = ["builder"] } | ||
| tokio = { workspace = true, features = ["macros", "rt", "time"] } | ||
| tracing-test = { workspace = true, features = [] } |
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,106 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // Copyright Open Network Fabric Authors | ||
|
|
||
| //! Read and write handles for the ACL filter context. | ||
|
|
||
| use crate::context::{AclTables, PRODUCTION_BACKEND}; | ||
| use concurrency::slot::Slot; | ||
| use concurrency::sync::Arc; | ||
| use config::ConfigError; | ||
| use config::external::overlay::ValidatedOverlay; | ||
|
|
||
| #[derive(Debug, Default)] | ||
| pub struct AclFilterContext { | ||
| pub(super) acls: AclTables, | ||
| } | ||
|
|
||
| impl TryFrom<&ValidatedOverlay> for AclFilterContext { | ||
| type Error = ConfigError; | ||
|
|
||
| fn try_from(overlay: &ValidatedOverlay) -> Result<Self, Self::Error> { | ||
| let acls = AclTables::build(overlay, PRODUCTION_BACKEND)?; | ||
| Ok(Self { acls }) | ||
| } | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| impl AclFilterContext { | ||
| /// Build a context using the reference backend, for tests that want the fast, EAL-free oracle. | ||
| /// Production goes through [`TryFrom`], which uses the rte_acl backend. | ||
| pub(crate) fn for_test(overlay: &ValidatedOverlay) -> Self { | ||
| use crate::context::Backend; | ||
| let acls = AclTables::build(overlay, Backend::Reference) | ||
| .expect("reference backend build is infallible"); | ||
| Self { acls } | ||
| } | ||
|
|
||
| /// Build a context using the rte_acl backend, for the differential test that exercises the | ||
| /// production classifier. Requires the EAL to be initialized (`#[dpdk::with_eal]`). | ||
| pub(crate) fn for_test_dpdk(overlay: &ValidatedOverlay) -> Result<Self, ConfigError> { | ||
| use crate::context::Backend; | ||
| let acls = AclTables::build(overlay, Backend::Dpdk)?; | ||
| Ok(Self { acls }) | ||
| } | ||
| } | ||
|
|
||
| /// Control-plane handle used to hot-swap the context. | ||
| #[derive(Debug, Clone)] | ||
| pub struct AclFilterContextWriter(Arc<Slot<AclFilterContext>>); | ||
|
|
||
| impl Default for AclFilterContextWriter { | ||
| fn default() -> Self { | ||
| Self(Arc::new(Slot::from_pointee(AclFilterContext::default()))) | ||
| } | ||
| } | ||
|
|
||
| impl AclFilterContextWriter { | ||
| /// Create a new handle with a default context. | ||
| #[must_use] | ||
| pub fn new() -> Self { | ||
| Self::default() | ||
| } | ||
|
|
||
| /// Atomically publish a new context on reconfiguration. | ||
| pub fn store(&self, context: AclFilterContext) { | ||
| self.0.store(Arc::new(context)); | ||
| } | ||
|
|
||
| /// Obtain a reader for the context. | ||
| #[must_use] | ||
| pub fn get_reader(&self) -> AclFilterContextReader { | ||
| AclFilterContextReader(Arc::clone(&self.0)) | ||
| } | ||
|
|
||
| /// Obtain a reader factory for the context. | ||
| #[must_use] | ||
| pub fn get_reader_factory(&self) -> AclFilterContextReaderFactory { | ||
| AclFilterContextReaderFactory(self.get_reader()) | ||
| } | ||
| } | ||
|
|
||
| #[derive(Debug, Clone)] | ||
| pub struct AclFilterContextReader(Arc<Slot<AclFilterContext>>); | ||
|
|
||
| impl AclFilterContextReader { | ||
| /// Load the current context for read-only access. | ||
| #[must_use] | ||
| pub fn load(&self) -> Arc<AclFilterContext> { | ||
| // FIXME: We'd like to use self.0.load() instead of .load_full() (saves the cost of the | ||
| // atomic counter update, although x86_64 shouldn't be affected), but if we do, then the | ||
| // loom and shuttle back-ends expect a different return type for the method | ||
| // (arc_swap::Guard<Arc<AclFilterContext>>). We need to create a wrapper around that type in | ||
| // the concurrency crate. | ||
| self.0.load_full() | ||
| } | ||
| } | ||
|
|
||
| #[derive(Debug, Clone)] | ||
| pub struct AclFilterContextReaderFactory(AclFilterContextReader); | ||
|
|
||
| impl AclFilterContextReaderFactory { | ||
| /// Obtain a reader from the factory. | ||
| #[must_use] | ||
| pub fn handle(&self) -> AclFilterContextReader { | ||
| self.0.clone() | ||
| } | ||
| } | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why load_full() and not load() ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I couldn't get it to compile with
load()for all of the standard case, loom, and shuttle otherwise. I usedload_full()like we use in masquerade for the allocator. I can look a bit more into it, do you know what the right solution would be instead?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Fredi-raspall The alternative I have consists in introducing dedicated features for the crate:
If you think it's worth it, I can change.
@daniel-noland or do you know if we have a wrapper for this already? Introducing new crate features just to accommodate for the return type doesn't look optimal, maybe I'm missing something simpler?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed in meeting (without Fredi): Let's keep as it is for now, the perf delta isn't worth troubling ourselves with the new crate features. I added a FIXME: comment in the code to explain that, at some point, we should add a wrapper around the type in the
concurrencycrate, so we can use.load().