-
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
Open
qmonnet
wants to merge
17
commits into
main
Choose a base branch
from
pr/qmonnet/user-acls
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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 c7339e1
feat(acl-filter): Add and implement new ACL filter crate
qmonnet 24fbc2e
feat(acl-filter): Implement Display trait for acl-filter's context
qmonnet 60b228f
test(acl-filter): Add unit tests for ACL filter
qmonnet 855af08
feat(dataplane,mgmt): Init EAL early for the ACL filter rte_acl backend
daniel-noland 89a6203
feat(dataplane,mgmt): Add ACL filter pipeline stage
qmonnet ee23168
fix(acl,acl-filter): Defer atomic statics via LazyLock for loom
qmonnet f726b63
feat(acl-filter): add tracing target for acl-filter
Fredi-raspall 0ced66a
feat(acl-filter): add #[must_use] annotations
Fredi-raspall 8328bf0
feat(acl-filter): impl Display for PacketSummary
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,101 @@ | ||
| // 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> { | ||
| 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() ?