aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGleb Smirnoff <glebius@FreeBSD.org>2025-12-22 01:18:27 +0000
committerGleb Smirnoff <glebius@FreeBSD.org>2025-12-22 02:23:14 +0000
commit129e15d4994311958db59a1718d4ff42d440ce2b (patch)
tree3d79348d3fa4ce34ffc33c2a2c15eabd22b016b8
parentb275907fa338b1ed6e9b5b5dd1b5069c36605285 (diff)
ipfw: fix bpf tap point lookup
The trick I blindly used works for pointers to structs, but not for rule numbers that can differ only by 1. PR: 291854 Fixes: 3daae1ac1d82ecdcd855101bab5206e914b12350
-rw-r--r--sys/netpfil/ipfw/ip_fw_bpf.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/netpfil/ipfw/ip_fw_bpf.c b/sys/netpfil/ipfw/ip_fw_bpf.c
index aa92d30007c2..d9897f700d57 100644
--- a/sys/netpfil/ipfw/ip_fw_bpf.c
+++ b/sys/netpfil/ipfw/ip_fw_bpf.c
@@ -63,10 +63,10 @@ struct ipfw_tap {
char name[sizeof("ipfw4294967295")];
};
-static int32_t
+static inline int
tap_compare(const struct ipfw_tap *a, const struct ipfw_tap *b)
{
- return ((int32_t)(a->rule/2 - b->rule/2));
+ return (a->rule != b->rule ? (a->rule < b->rule ? -1 : 1) : 0);
}
RB_HEAD(tap_tree, ipfw_tap);
VNET_DEFINE_STATIC(struct tap_tree, tap_tree);