[PATCH 05/15] NAN: Fix intersection logic in nan_ndl_determine_status()
Andrei Otcheretianski
andrei.otcheretianski at intel.com
Thu Oct 8 09:05:14 PDT 2026
Common schedule bitmap may be empty (but not NULL) if the peer has a
disjoint schedule on the same channel. Check properly that the common
schedule is either NULL or the intersection is empty.
Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski at intel.com>
---
src/nan/nan_ndl.c | 2 +-
src/utils/bitfield.c | 16 ++++++++++++++++
src/utils/bitfield.h | 1 +
3 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/src/nan/nan_ndl.c b/src/nan/nan_ndl.c
index ce0e212cbe..1511f55931 100644
--- a/src/nan/nan_ndl.c
+++ b/src/nan/nan_ndl.c
@@ -513,7 +513,7 @@ static enum nan_ndl_status nan_ndl_determine_status(struct nan_data *nan,
own_chan_bf = NULL;
}
- if (!common_bf) {
+ if (bitfield_is_empty(common_bf)) {
wpa_printf(MSG_DEBUG,
"NAN: NDL: No common availability between local and peer");
diff --git a/src/utils/bitfield.c b/src/utils/bitfield.c
index b79f43516c..2cc6ec03f5 100644
--- a/src/utils/bitfield.c
+++ b/src/utils/bitfield.c
@@ -239,6 +239,22 @@ int bitfield_intersects(const struct bitfield *a, const struct bitfield *b)
}
+int bitfield_is_empty(const struct bitfield *bf)
+{
+ size_t i, upper;
+
+ if (!bf)
+ return -1;
+
+ upper = (bf->max_bits + 7) / 8;
+ for (i = 0; i < upper; i++)
+ if (bf->bits[i])
+ return 0;
+
+ return 1;
+}
+
+
void bitfield_dump(struct bitfield *bf, const char *title)
{
wpa_printf(MSG_DEBUG, "bitfield: %s: max_bits=%zu",
diff --git a/src/utils/bitfield.h b/src/utils/bitfield.h
index db136cd176..d36e369926 100644
--- a/src/utils/bitfield.h
+++ b/src/utils/bitfield.h
@@ -26,6 +26,7 @@ int bitfield_intersect_in_place(struct bitfield *a, const struct bitfield *b);
int bitfield_is_subset(const struct bitfield *a, const struct bitfield *b);
size_t bitfield_size(const struct bitfield *bf);
int bitfield_intersects(const struct bitfield *a, const struct bitfield *b);
+int bitfield_is_empty(const struct bitfield *bf);
void bitfield_dump(struct bitfield *bf, const char *title);
#endif /* BITFIELD_H */
--
2.53.0
More information about the Hostap
mailing list