Conversation
5554d42 to
562a0a5
Compare
MarkusPettersson98
left a comment
There was a problem hiding this comment.
@MarkusPettersson98 reviewed 14 of 24 files at r1, 2 of 3 files at r2, all commit messages.
Reviewable status: 16 of 24 files reviewed, 2 unresolved discussions (waiting on @hulthe)
nftnl/src/table.rs line 27 at r2 (raw file):
/// Creates a new table instance with the given name and protocol family. pub fn new<T: AsRef<CStr>>(name: T, family: ProtoFamily) -> Table { let table = unsafe { try_alloc!(sys::nftnl_table_alloc()) };
Very minor nit: The unsafe scope could be kept down by moving it inside of the try_alloc! invocation. This is done in some places already, and not in other places.
Code quote:
let table = unsafe { try_alloc!(sys::nftnl_table_alloc()) };nftnl/src/expr/counter.rs line 12 at r2 (raw file):
impl Expression for Counter { fn to_expr(&self, _rule: &Rule) -> ptr::NonNull<sys::nftnl_expr> { try_alloc!(unsafe { sys::nftnl_expr_alloc(c"counter".as_ptr()) })
Like here!
Code quote:
try_alloc!(unsafe { sys::nftnl_expr_alloc(c"counter".as_ptr()) })
MarkusPettersson98
left a comment
There was a problem hiding this comment.
🙌
@MarkusPettersson98 reviewed 7 of 24 files at r1, 1 of 3 files at r2.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @hulthe)
nftnl/examples/add-rules.rs line 195 at r2 (raw file):
socket.send_all(batch)?; // TODO: this buffer must be aligned to nlmsghdr
TODO
Code quote:
// TODO: this buffer must be aligned to nlmsghdr
hulthe
left a comment
There was a problem hiding this comment.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @MarkusPettersson98 and @Serock3)
nftnl/src/table.rs line 27 at r2 (raw file):
Previously, MarkusPettersson98 (Markus Pettersson) wrote…
Very minor nit: The
unsafescope could be kept down by moving it inside of thetry_alloc!invocation. This is done in some places already, and not in other places.
Done
MarkusPettersson98
left a comment
There was a problem hiding this comment.
@MarkusPettersson98 reviewed 2 of 2 files at r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Serock3)
MarkusPettersson98
left a comment
There was a problem hiding this comment.
@MarkusPettersson98 reviewed 5 of 5 files at r4, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Serock3)
> `NLMSG_ERROR` and `NLMSG_DONE` are of practical importance. They carry > return codes for operations. Note that unless the NLM_F_ACK flag is > set on the request Netlink will not respond with NLMSG_ERROR if there > is no error. To avoid having to special-case this quirk it is > recommended to always set NLM_F_ACK. source: https://www.kernel.org/doc/html/next/userspace-api/netlink/intro.html
This removes the burden about having to worry about null-pointers when looking at struct/function definitions.
The impl forgot add the trailing null-pointer required for C strings, and since libnftnl accepts C-strings, is better to just use the CStr rust types directly.
Fixing and refactorings of things I've encountered to hopefully make nftnl better
This change is