Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
carllin committed Apr 9, 2020
1 parent 6f80733 commit 7bf3deb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
16 changes: 6 additions & 10 deletions net-shaper/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,13 @@ fn delete_ifb(interface: &str) -> bool {
],
"Failed to setup ingress qdisc",
"tc qdisc delete dev <if> handle ffff: ingress",
false,
true,
) && run(
"modprobe",
&["ifb", "--remove"],
"Failed to delete ifb module",
"modprobe ifb --remove",
false,
true,
)
}

Expand Down Expand Up @@ -349,10 +349,6 @@ fn identify_my_partition(partitions: &[u8], index: u64, size: u64) -> usize {
let mut my_partition = 0;
let mut watermark = 0;
for (i, p) in partitions.iter().enumerate() {
println!(
"i: {}, p: {}, watermark: {}, index: {}, size: {}",
i, p, watermark, index, size
);
watermark += *p;
if u64::from(watermark) >= index * 100 / size {
my_partition = i;
Expand Down Expand Up @@ -407,7 +403,7 @@ fn shape_network_steps(
);
println!("My partition is {}", my_partition);

force_cleanup_network(interface);
cleanup_network(interface);

// Mark egress packets with our partition id
if !insert_iptables_rule(partition_id_to_tos(my_partition)) {
Expand All @@ -433,8 +429,8 @@ fn shape_network_steps(

println!("Setting up interconnects");
for i in &topology.interconnects {
println!("interconnects: {:#?}", i);
if i.b as usize == my_partition {
println!("interconnects: {:#?}", i);
let tos = partition_id_to_tos(i.a as usize);
if tos == 0 {
println!("Incorrect value of TOS/Partition in config {}", i.a);
Expand Down Expand Up @@ -466,7 +462,7 @@ fn parse_interface(interfaces: &str) -> &str {
panic!("No valid interfaces");
}

fn force_cleanup_network(interface: &str) {
fn cleanup_network(interface: &str) {
delete_all_filters("ifb0");
delete_ifb(interface);
flush_iptables_rule();
Expand Down Expand Up @@ -622,7 +618,7 @@ fn main() {
("cleanup", Some(args_matches)) => {
let interfaces = value_t_or_exit!(args_matches, "iface", String);
let iface = parse_interface(&interfaces);
force_cleanup_network(iface)
cleanup_network(iface)
}
("configure", Some(args_matches)) => configure(args_matches),
_ => {}
Expand Down
2 changes: 1 addition & 1 deletion net/remote/cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if [[ -f solana/netem.cfg ]]; then
solana/scripts/netem.sh delete < solana/netem.cfg
rm -f solana/netem.cfg
fi
solana/scripts/net-shaper.sh force_cleanup
solana/scripts/net-shaper.sh cleanup
for pattern in validator.sh boostrap-leader.sh solana- remote- iftop validator client node; do
echo "killing $pattern"
pkill -f $pattern
Expand Down
2 changes: 0 additions & 2 deletions scripts/net-shaper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ iface="$(ifconfig | grep mtu | grep -iv loopback | grep -i running | awk 'BEGIN

if [[ "$1" = cleanup ]]; then
$sudo ~solana/.cargo/bin/solana-net-shaper cleanup -f "$2" -s "$3" -p "$4" -i "$iface"
elif [[ "$1" = force_cleanup ]]; then
$sudo ~solana/.cargo/bin/solana-net-shaper force_cleanup -i "$iface"
else
$sudo ~solana/.cargo/bin/solana-net-shaper shape -f "$2" -s "$3" -p "$4" -i "$iface"
fi

0 comments on commit 7bf3deb

Please sign in to comment.