diff options
author | Simon THOBY <git@nightmared.fr> | 2022-10-05 22:31:29 +0200 |
---|---|---|
committer | Simon THOBY <git@nightmared.fr> | 2022-10-05 22:31:29 +0200 |
commit | d7c0d6721148a63a78666274cf57ae68ddfb2b01 (patch) | |
tree | 6737fb52960e5b14e53f2efbeaa5837ebfb9a25e /examples/add-rules.rs | |
parent | dc2c0bc1ba921f113d5f90a05245cfccab9dbdaa (diff) |
sending batches now works properly without hanging
Diffstat (limited to 'examples/add-rules.rs')
-rw-r--r-- | examples/add-rules.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/examples/add-rules.rs b/examples/add-rules.rs index 229db97..11e7b6f 100644 --- a/examples/add-rules.rs +++ b/examples/add-rules.rs @@ -37,7 +37,7 @@ //! ``` use ipnetwork::{IpNetwork, Ipv4Network}; -use rustables::{query::send_batch, Batch, ProtoFamily, Table}; +use rustables::{Batch, ProtoFamily, Table}; //use rustables::{nft_expr, query::send_batch, sys::libc, Batch, Chain, ProtoFamily, Rule, Table}; use std::{ffi::CString, io, net::Ipv4Addr, rc::Rc}; @@ -57,6 +57,10 @@ fn main() -> Result<(), Error> { // this table under its `ProtoFamily::Inet` ruleset. batch.add(&table, rustables::MsgType::Add); + let table = Table::new("lool", ProtoFamily::Inet); + + batch.add(&table, rustables::MsgType::Add); + // // Create input and output chains under the table we created above. // // Hook the chains to the input and output event hooks, with highest priority (priority zero). // // See the `Chain::set_hook` documentation for details. @@ -170,7 +174,7 @@ fn main() -> Result<(), Error> { // Finalize the batch and send it. This means the batch end message is written into the batch, telling // netfilter the we reached the end of the transaction message. It's also converted to a // Vec<u8>, containing the raw netlink data so it can be sent over a netlink socket to netfilter. - Ok(send_batch(batch)?) + Ok(batch.send()?) } // Look up the interface index for a given interface name. |