Skip to content

Commit

Permalink
nft: exit is terminate
Browse files Browse the repository at this point in the history
  • Loading branch information
hack3ric committed Nov 15, 2024
1 parent 6179aa8 commit 3cc77ac
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/kernel/linux/nft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,6 @@ impl Nftables {
Ok(Self { table, chain })
}

async fn exit(&self) -> Result<()> {
let mut batch = Batch::new();
batch.delete(schema::NfListObject::Chain(schema::Chain {
family: types::NfFamily::INet,
table: self.table.clone(),
name: self.chain.clone(),
..Default::default()
}));
Ok(apply_ruleset_async(&batch.to_nftables(), None, None).await?)
}

pub fn make_new_rule(
&self,
stmts: Cow<'static, [stmt::Statement]>,
Expand Down Expand Up @@ -100,7 +89,14 @@ impl Nftables {
}

pub async fn terminate(self) {
_ = self.exit().await;
let mut batch = Batch::new();
batch.delete(schema::NfListObject::Chain(schema::Chain {
family: types::NfFamily::INet,
table: self.table.clone(),
name: self.chain.clone(),
..Default::default()
}));
_ = apply_ruleset_async(&batch.to_nftables(), None, None).await;
}
}

Expand Down

0 comments on commit 3cc77ac

Please sign in to comment.