nftables-napi 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
package/src/netlink/set_ops.cpp
CHANGED
|
@@ -64,14 +64,21 @@ static NlResult bulk_set_elem_op(
|
|
|
64
64
|
nftnl_set_set_u32(s.get(), NFTNL_SET_KEY_LEN, key_len);
|
|
65
65
|
|
|
66
66
|
for (size_t i = offset; i < end; ++i) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
nftnl_set_elem_set(
|
|
67
|
+
// Start element: carries the key, timeout, and counters
|
|
68
|
+
auto* e_start = nftnl_set_elem_alloc();
|
|
69
|
+
if (!e_start) return {false, "nftnl_set_elem_alloc failed"};
|
|
70
|
+
nftnl_set_elem_set(e_start, NFTNL_SET_ELEM_KEY, family_addrs[i]->bytes, family_addrs[i]->len);
|
|
71
71
|
if (timeout_ms > 0) {
|
|
72
|
-
nftnl_set_elem_set_u64(
|
|
72
|
+
nftnl_set_elem_set_u64(e_start, NFTNL_SET_ELEM_TIMEOUT, timeout_ms);
|
|
73
73
|
}
|
|
74
|
-
nftnl_set_elem_add(s.get(),
|
|
74
|
+
nftnl_set_elem_add(s.get(), e_start);
|
|
75
|
+
|
|
76
|
+
// End element: exclusive upper bound with INTERVAL_END flag
|
|
77
|
+
auto* e_end = nftnl_set_elem_alloc();
|
|
78
|
+
if (!e_end) return {false, "nftnl_set_elem_alloc failed"};
|
|
79
|
+
nftnl_set_elem_set(e_end, NFTNL_SET_ELEM_KEY, family_addrs[i]->end_bytes, family_addrs[i]->len);
|
|
80
|
+
nftnl_set_elem_set_u32(e_end, NFTNL_SET_ELEM_FLAGS, NFT_SET_ELEM_INTERVAL_END);
|
|
81
|
+
nftnl_set_elem_add(s.get(), e_end);
|
|
75
82
|
}
|
|
76
83
|
|
|
77
84
|
NlBatch batch;
|