Skip to content

Commit 89f51c3

Browse files
committed
feat(dataplane,mgmt): Add new flow-filter implementation to dataplane
Swap the flow-filter stage for its new, ACL-based implementation, but do not delete the legacy implementation (and setup) just yet. Signed-off-by: Quentin Monnet <qmo@qmon.net>
1 parent b58e014 commit 89f51c3

7 files changed

Lines changed: 36 additions & 2 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dataplane/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ axum-server = { workspace = true }
2020
concurrency = { workspace = true }
2121
config = { workspace = true }
2222
dyn-iter = { workspace = true }
23+
flofi = { workspace = true }
2324
flow-entry = { workspace = true }
2425
flow-filter = { workspace = true }
2526
futures = { workspace = true }

dataplane/src/packet_processor/mod.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use super::packet_processor::ipforward::IpForwarder;
1212

1313
use concurrency::sync::Arc;
1414

15+
use flofi::{Flofi, FlofiContextWriter};
1516
use flow_entry::flow_table::{FlowLookup, FlowTable};
1617
use flow_filter::{FlowFilter, FlowFilterTableWriter};
1718

@@ -42,6 +43,7 @@ where
4243
pub nattablesw: NatTablesWriter,
4344
pub natallocatorw: NatAllocatorWriter,
4445
pub flowfiltertablesw: FlowFilterTableWriter,
46+
pub flofi_writer: FlofiContextWriter,
4547
pub stats: StatsCollector,
4648
pub vpc_stats_store: Arc<VpcStatsStore>,
4749
pub portfw_w: PortFwTableWriter,
@@ -66,6 +68,8 @@ pub(crate) fn start_router<Buf: PacketBufferMut>(
6668
let flow_table = Arc::new(FlowTable::default());
6769
let flowfiltertablesw = FlowFilterTableWriter::new();
6870
let flowfiltertablesr_factory = flowfiltertablesw.get_reader_factory();
71+
let flofi_writer = FlofiContextWriter::new();
72+
let flofi_reader_factory = flofi_writer.get_reader_factory();
6973
let nattablesw = NatTablesWriter::new();
7074
let natallocatorw = NatAllocatorWriter::new();
7175
let nattabler_factory = nattablesw.get_reader_factory();
@@ -109,7 +113,9 @@ pub(crate) fn start_router<Buf: PacketBufferMut>(
109113
);
110114
let pktdump = PacketDumper::new("pipeline-end", true, None);
111115
let stats_stage = Stats::new("stats", stats_w.clone());
112-
let flow_filter = FlowFilter::new("flow-filter", flowfiltertablesr_factory.handle());
116+
let _flow_filter = FlowFilter::new("flow-filter", flowfiltertablesr_factory.handle());
117+
let flofi = Flofi::new("flofi", flofi_reader_factory.handle());
118+
113119
let icmp_error_handler = IcmpErrorHandler::new(flow_table_clone.clone());
114120
let flow_lookup = FlowLookup::new("flow-lookup", flow_table_clone.clone());
115121
let portfw = PortForwarder::new(
@@ -127,7 +133,7 @@ pub(crate) fn start_router<Buf: PacketBufferMut>(
127133
.add_stage(iprouter1)
128134
.add_stage(icmp_error_handler)
129135
.add_stage(flow_lookup)
130-
.add_stage(flow_filter)
136+
.add_stage(flofi)
131137
.add_stage(static_nat)
132138
.add_stage(portfw)
133139
.add_stage(masquerade)
@@ -146,6 +152,7 @@ pub(crate) fn start_router<Buf: PacketBufferMut>(
146152
nattablesw,
147153
natallocatorw,
148154
flowfiltertablesw,
155+
flofi_writer,
149156
stats,
150157
vpc_stats_store,
151158
portfw_w,

dataplane/src/runtime.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ pub fn main() {
243243
nattablesw: setup.nattablesw,
244244
natallocatorw: setup.natallocatorw,
245245
flowfilterw: setup.flowfiltertablesw,
246+
flofi_writer: setup.flofi_writer,
246247
portfw_w: setup.portfw_w,
247248
vpc_stats_store: setup.vpc_stats_store,
248249
dp_status_r: dp_status.clone(),

mgmt/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ bolero = ["dep:bolero", "interface-manager/bolero", "id/bolero", "net/bolero", "
2020
args = { workspace = true }
2121
config = { workspace = true }
2222
concurrency = { workspace = true }
23+
flofi = { workspace = true }
2324
flow-entry = { workspace = true }
2425
flow-filter = { workspace = true }
2526
id = { workspace = true }

mgmt/src/processor/proc.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use config::{DeviceConfig, ExternalConfig, GenId, GwConfig, InternalConfig, Vali
2222

2323
use crate::processor::confbuild::internal::build_internal_config;
2424
use crate::processor::confbuild::router::generate_router_config;
25+
use flofi::{FlofiContext, FlofiContextWriter};
2526
use flow_filter::{FlowFilterTable, FlowFilterTableWriter};
2627
use nat::masquerade::{MasqueradeConfig, NatAllocatorWriter};
2728
use nat::portfw::PortFwTableWriter;
@@ -97,6 +98,9 @@ pub struct ConfigProcessorParams {
9798
// writer for flow filter table
9899
pub flowfilterw: FlowFilterTableWriter,
99100

101+
// writer for flofi table
102+
pub flofi_writer: FlofiContextWriter,
103+
100104
// writer for port forwarding table
101105
pub portfw_w: PortFwTableWriter,
102106

@@ -527,6 +531,15 @@ fn apply_flow_filtering_config(
527531
Ok(())
528532
}
529533

534+
fn apply_flofi_config(
535+
overlay: &ValidatedOverlay,
536+
flofi_writer: &mut FlofiContextWriter,
537+
) -> ConfigResult {
538+
flofi_writer.store(FlofiContext::try_from(overlay)?);
539+
debug!("Successfully updated flofi table");
540+
Ok(())
541+
}
542+
530543
fn apply_port_forwarding_config(
531544
vpc_table: &ValidatedVpcTable,
532545
portfw_w: &mut PortFwTableWriter,
@@ -573,6 +586,7 @@ impl ConfigProcessor {
573586
let nattablesw = &mut self.proc_params.nattablesw;
574587
let natallocatorw = &mut self.proc_params.natallocatorw;
575588
let flowfilterw = &mut self.proc_params.flowfilterw;
589+
let flofi_writer = &mut self.proc_params.flofi_writer;
576590
let portfw_w = &mut self.proc_params.portfw_w;
577591
let flow_table = &self.proc_params.flow_table;
578592

@@ -623,6 +637,9 @@ impl ConfigProcessor {
623637
/* apply flow filtering config */
624638
apply_flow_filtering_config(config.external().overlay(), flowfilterw)?;
625639

640+
/* apply flofi config */
641+
apply_flofi_config(config.external().overlay(), flofi_writer)?;
642+
626643
/* apply port-forwarding config */
627644
apply_port_forwarding_config(config.external().overlay().vpc_table(), portfw_w)?;
628645

mgmt/src/tests/mgmt.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ pub mod test {
99
use config::external::gwgroup::GwGroupMember;
1010
use config::external::gwgroup::GwGroupTable;
1111

12+
use flofi::FlofiContextWriter;
1213
use flow_entry::flow_table::FlowTable;
1314
use lpm::prefix::Prefix;
1415
use net::eth::mac::Mac;
@@ -460,6 +461,9 @@ pub mod test {
460461
/* create FlowFilterTable for flow filtering */
461462
let flowfilterw = FlowFilterTableWriter::new();
462463

464+
/* create FlowFilterTable for flow filtering */
465+
let flofi_writer = FlofiContextWriter::new();
466+
463467
/* create port forwarding table */
464468
let portfw_w = PortFwTableWriter::new();
465469

@@ -481,6 +485,7 @@ pub mod test {
481485
nattablesw,
482486
natallocatorw,
483487
flowfilterw,
488+
flofi_writer,
484489
portfw_w,
485490
vpc_stats_store,
486491
dp_status_r,

0 commit comments

Comments
 (0)