Skip to content

Commit 9f6b8f7

Browse files
authored
Turn multicast into an optional feature (#201)
1 parent cf31be9 commit 9f6b8f7

28 files changed

Lines changed: 909 additions & 552 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
#:
3+
#: name = "multicast-test"
4+
#: variety = "basic"
5+
#: target = "ubuntu-22.04"
6+
#: rust_toolchain = true
7+
#:
8+
#: output_rules = [
9+
#: "/work/simulator.log",
10+
#: "/work/dpd.log",
11+
#: ]
12+
#:
13+
14+
#### >>>>>>>>>>>>>>>>>>>>>>>>>>>> Local Usage >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
15+
####
16+
#### The following environment variables are useful.
17+
####
18+
#### - JUST_TEST=1 Just runs the tests, skipping system prep.
19+
#### - TESTNAME='$name' Will just run the specified test.
20+
#### - STARTUP_TIMEOUT=n Seconds to wait for tofino-model/dpd to start.
21+
#### Defaults to 15.
22+
#### - NOBUILD=1 Don't build sidecar.p4 (in case you've already
23+
#### built it)
24+
####
25+
#### <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
26+
27+
export RUST_BACKTRACE=1
28+
29+
set -o errexit
30+
set -o pipefail
31+
set -o xtrace
32+
33+
export MULTICAST=1
34+
source .github/buildomat/packet-test-common.sh

.github/buildomat/jobs/packet-test.sh

Lines changed: 1 addition & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -30,104 +30,4 @@ set -o errexit
3030
set -o pipefail
3131
set -o xtrace
3232

33-
source .github/buildomat/common.sh
34-
source .github/buildomat/linux.sh
35-
36-
wd=`pwd`
37-
export WS=$wd
38-
STARTUP_TIMEOUT=${STARTUP_TIMEOUT:=15}
39-
40-
function cleanup {
41-
set +o errexit
42-
set +o pipefail
43-
cd $wd
44-
sudo -E pkill -9 dpd
45-
sudo -E pkill -9 tofino-model
46-
sudo -E ./tools/veth_teardown.sh
47-
stty sane
48-
# wait for daemons to die, if log file sizes change this can fail CI
49-
sleep 10
50-
}
51-
trap cleanup EXIT
52-
53-
if [[ $JUST_TEST -ne 1 ]]; then
54-
# See what hugepages was before starting
55-
sysctl vm.nr_hugepages
56-
# Make sure huge pages is enabled. This is required for running the SDE on
57-
# linux.
58-
sudo -E sysctl -w vm.nr_hugepages=128
59-
# Under some circumstances the sysctl may not completely work, so flush
60-
# the vm caches and retry.
61-
sudo -E sh -c 'echo 3 > /proc/sys/vm/drop_caches'
62-
sudo -E sysctl -w vm.nr_hugepages=128
63-
# See what hugepages is now. If this is zero and things go sideways later,
64-
# you'll know why.
65-
sysctl vm.nr_hugepages
66-
67-
banner "Packages"
68-
sudo apt update -y
69-
sudo apt install -y \
70-
libpcap-dev \
71-
libclang-dev \
72-
libssl-dev \
73-
pkg-config \
74-
libcli-dev \
75-
sysvbanner
76-
fi
77-
78-
export SDE=/opt/oxide/tofino_sde
79-
80-
banner "Build"
81-
if [[ $NOBUILD -ne 1 ]]; then
82-
cargo build --features=tofino_asic --bin dpd --bin swadm
83-
cargo xtask codegen --stages $TOFINO_STAGES
84-
fi
85-
86-
banner "Test"
87-
sudo -E ./tools/veth_setup.sh
88-
id=`id -un`
89-
gr=`id -gn`
90-
sudo -E mkdir -p /work
91-
sudo -E chown $id:$gr /work
92-
sudo -E ./tools/run_tofino_model.sh &> /work/simulator.log &
93-
sleep $STARTUP_TIMEOUT
94-
sudo -E ./tools/run_dpd.sh -m 127.0.0.1 &> /work/dpd.log &
95-
sleep $STARTUP_TIMEOUT
96-
97-
banner "Links"
98-
99-
./target/debug/swadm -h '[::1]' link ls || echo "failed to list links"
100-
101-
banner "swadm Checks"
102-
103-
pushd swadm
104-
105-
DENDRITE_TEST_HOST='[::1]' \
106-
DENDRITE_TEST_VERBOSITY=3 \
107-
cargo test \
108-
--no-fail-fast \
109-
--test \
110-
counters \
111-
-- \
112-
--ignored
113-
114-
popd
115-
116-
banner "Packet Tests"
117-
118-
set +o errexit
119-
set +o pipefail
120-
stty sane
121-
set -o errexit
122-
set -o pipefail
123-
124-
pushd dpd-client
125-
126-
DENDRITE_TEST_HOST='[::1]' \
127-
DENDRITE_TEST_VERBOSITY=3 \
128-
cargo test \
129-
--features tofino_asic \
130-
--no-fail-fast \
131-
$TESTNAME \
132-
-- \
133-
--ignored
33+
source .github/buildomat/packet-test-common.sh
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
export RUST_BACKTRACE=1
2+
3+
source .github/buildomat/common.sh
4+
source .github/buildomat/linux.sh
5+
6+
wd=`pwd`
7+
export WS=$wd
8+
MODEL_STARTUP_TIMEOUT=${MODEL_STARTUP_TIMEOUT:=5}
9+
STARTUP_TIMEOUT=${STARTUP_TIMEOUT:=120}
10+
11+
if [ x$MULTICAST == x ]; then
12+
BUILD_FEATURES=tofino_asic
13+
CODEGEN_FEATURES=
14+
SWADM_FEATURES=
15+
else
16+
BUILD_FEATURES=tofino_asic,multicast
17+
CODEGEN_FEATURES=--multicast
18+
SWADM_FEATURES=--features=multicast
19+
fi
20+
21+
function cleanup {
22+
set +o errexit
23+
set +o pipefail
24+
cd $wd
25+
sudo -E pkill -9 dpd
26+
sudo -E pkill -9 tofino-model
27+
sudo -E ./tools/veth_teardown.sh
28+
stty sane
29+
# wait for daemons to die, if log file sizes change this can fail CI
30+
sleep 10
31+
}
32+
trap cleanup EXIT
33+
34+
if [[ $JUST_TEST -ne 1 ]]; then
35+
# See what hugepages was before starting
36+
sysctl vm.nr_hugepages
37+
# Make sure huge pages is enabled. This is required for running the SDE on
38+
# linux.
39+
sudo -E sysctl -w vm.nr_hugepages=128
40+
# Under some circumstances the sysctl may not completely work, so flush
41+
# the vm caches and retry.
42+
sudo -E sh -c 'echo 3 > /proc/sys/vm/drop_caches'
43+
sudo -E sysctl -w vm.nr_hugepages=128
44+
# See what hugepages is now. If this is zero and things go sideways later,
45+
# you'll know why.
46+
sysctl vm.nr_hugepages
47+
48+
banner "Packages"
49+
sudo apt update -y
50+
sudo apt install -y \
51+
libpcap-dev \
52+
libclang-dev \
53+
libssl-dev \
54+
pkg-config \
55+
libcli-dev \
56+
sysvbanner
57+
fi
58+
59+
export SDE=/opt/oxide/tofino_sde
60+
61+
banner "Build"
62+
if [[ $NOBUILD -ne 1 ]]; then
63+
cargo build --features=$BUILD_FEATURES --bin dpd --bin swadm
64+
cargo xtask codegen --stages $TOFINO_STAGES $CODEGEN_FEATURES
65+
fi
66+
67+
banner "Test"
68+
sudo -E ./tools/veth_setup.sh
69+
id=`id -un`
70+
gr=`id -gn`
71+
sudo -E mkdir -p /work
72+
sudo -E chown $id:$gr /work
73+
sudo -E ./tools/run_tofino_model.sh &> /work/simulator.log &
74+
sleep $MODEL_STARTUP_TIMEOUT
75+
sudo -E ./tools/run_dpd.sh -m 127.0.0.1 &> /work/dpd.log &
76+
echo "waiting for dpd to come online"
77+
set +o errexit
78+
79+
SLEEP_TIME=5
80+
iters=$(( $STARTUP_TIMEOUT / $SLEEP_TIME ))
81+
while [ 1 ] ; do
82+
./target/debug/swadm --host '[::1]' build-info 2> /dev/null
83+
if [ $? == 0 ]; then
84+
break
85+
fi
86+
iters=$(($iters - 1))
87+
if [ $iters = 0 ]; then
88+
echo "dpd failed to come online in $STARTUP_TIMEOUT seconds"
89+
exit 1
90+
fi
91+
sleep $SLEEP_TIME
92+
done
93+
set -o errexit
94+
95+
banner "Links"
96+
97+
./target/debug/swadm --host '[::1]' link ls || echo "failed to list links"
98+
99+
banner "swadm Checks"
100+
101+
pushd swadm
102+
103+
DENDRITE_TEST_HOST='[::1]' \
104+
DENDRITE_TEST_VERBOSITY=3 \
105+
cargo test \
106+
--no-fail-fast \
107+
$SWADM_FEATURES \
108+
--test \
109+
counters \
110+
-- \
111+
--ignored
112+
113+
popd
114+
115+
banner "Packet Tests"
116+
117+
set +o errexit
118+
set +o pipefail
119+
stty sane
120+
set -o errexit
121+
set -o pipefail
122+
123+
pushd dpd-client
124+
125+
DENDRITE_TEST_HOST='[::1]' \
126+
DENDRITE_TEST_VERBOSITY=3 \
127+
cargo test \
128+
--features $BUILD_FEATURES \
129+
--no-fail-fast \
130+
$TESTNAME \
131+
-- \
132+
--ignored

aal/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ name = "aal"
33
version = "0.1.0"
44
edition = "2024"
55

6-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
6+
[features]
7+
multicast = []
78

89
[dependencies]
910
common.workspace = true

aal/src/lib.rs

Lines changed: 45 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,52 @@ pub enum AsicError {
112112
Missing(String),
113113
}
114114

115-
/// The `AsicOps` trait contains all of the non-Table related ASIC operations
115+
/// The `AsicMulticastOps` trait contains the multicast-related ASIC operations
116116
/// that the dataplane daemon requires.
117+
#[cfg(feature = "multicast")]
118+
pub trait AsicMulticastOps {
119+
/// Return a vector containing all of the defined multicast groups.
120+
fn mc_domains(&self) -> Vec<u16>;
121+
122+
/// For a given multicast group, return the number of ports assigned to it.
123+
fn mc_port_count(&self, group_id: u16) -> AsicResult<usize>;
124+
125+
/// Add a port to a multicast group. The port is identified using its ASIC
126+
/// identifier.
127+
fn mc_port_add(
128+
&self,
129+
group_id: u16,
130+
port: AsicId,
131+
rid: u16,
132+
level_1_excl_id: u16,
133+
) -> AsicResult<()>;
134+
135+
/// Remove a port from a multicast group. The port is identified using its ASIC
136+
/// identifier.
137+
fn mc_port_remove(&self, group_id: u16, port: AsicId) -> AsicResult<()>;
138+
139+
/// Create a new, unpopulated multicast group.
140+
fn mc_group_create(&self, group_id: u16) -> AsicResult<()>;
141+
142+
/// Destroy a multicast group.
143+
fn mc_group_destroy(&self, group_id: u16) -> AsicResult<()>;
144+
145+
/// Check if a multicast group exists.
146+
fn mc_group_exists(&self, group_id: u16) -> bool {
147+
self.mc_domains().contains(&group_id)
148+
}
149+
150+
/// Get the total number of multicast groups.
151+
fn mc_groups_count(&self) -> AsicResult<usize>;
152+
153+
/// Set the maximum number of multicast nodes.
154+
fn mc_set_max_nodes(
155+
&self,
156+
max_nodes: u32,
157+
max_link_aggregated_nodes: u32,
158+
) -> AsicResult<()>;
159+
}
160+
117161
pub trait AsicOps {
118162
/// Reports the kind of media plugged into the port
119163
// TODO-correctness: This should probably take a `PortId` or `Connector`.
@@ -196,47 +240,6 @@ pub trait AsicOps {
196240
connector: Connector,
197241
) -> AsicResult<Vec<u8>>;
198242

199-
/// Return a vector containing all of the defined multicast groups.
200-
fn mc_domains(&self) -> Vec<u16>;
201-
202-
/// For a given multicast group, return the number of ports assigned to it.
203-
fn mc_port_count(&self, group_id: u16) -> AsicResult<usize>;
204-
205-
/// Add a port to a multicast group. The port is identified using its ASIC
206-
/// identifier.
207-
fn mc_port_add(
208-
&self,
209-
group_id: u16,
210-
port: AsicId,
211-
rid: u16,
212-
level_1_excl_id: u16,
213-
) -> AsicResult<()>;
214-
215-
/// Remove a port from a multicast group. The port is identified using its ASIC
216-
/// identifier.
217-
fn mc_port_remove(&self, group_id: u16, port: AsicId) -> AsicResult<()>;
218-
219-
/// Create a new, unpopulated multicast group.
220-
fn mc_group_create(&self, group_id: u16) -> AsicResult<()>;
221-
222-
/// Destroy a multicast group.
223-
fn mc_group_destroy(&self, group_id: u16) -> AsicResult<()>;
224-
225-
/// Check if a multicast group exists.
226-
fn mc_group_exists(&self, group_id: u16) -> bool {
227-
self.mc_domains().contains(&group_id)
228-
}
229-
230-
/// Get the total number of multicast groups.
231-
fn mc_groups_count(&self) -> AsicResult<usize>;
232-
233-
/// Set the maximum number of multicast nodes.
234-
fn mc_set_max_nodes(
235-
&self,
236-
max_nodes: u32,
237-
max_link_aggregated_nodes: u32,
238-
) -> AsicResult<()>;
239-
240243
/// Get sidecar identifiers of the device being managed.
241244
fn get_sidecar_identifiers(&self) -> AsicResult<impl SidecarIdentifiers>;
242245

asic/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ tofino_asic = [
1313
tofino_stub = []
1414
softnpu = ["softnpu-lib", "dep:propolis"]
1515
chaos = []
16+
multicast = ["aal/multicast"]
1617

1718
[lib]
1819
# The genpd.rs code generated by bindgen causes the doctest to fail

0 commit comments

Comments
 (0)