[PATCH 8/8] alfred: vis: skip originators with unresolvable hard interface
Sven Eckelmann <[email protected]> Tue, 28 Jul 2026 18:01:37 +0200
| Newsgroups | org.open-mesh.lists.batman |
|---|---|
| Message-ID | <[email protected]> |
get_if_index_devindex() returns -1 on an error. But the result can also be
larger than 255. In both cases, the originator cannot be reported using the
vis_v1 type which is using an u8 for the ifindex storage.
The index must be prechecked before the entry is allocated. The value 255
must also be avoided because it used as marker for TT entries.
Fixes: bca55a86fecd ("alfred: vis: Add support for netlink")
Signed-off-by: Sven Eckelmann <[email protected]>
---
vis/vis.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/vis/vis.c b/vis/vis.c
index 025745d..b7a50af 100644
--- a/vis/vis.c
+++ b/vis/vis.c
@@ -531,6 +531,7 @@ static int parse_orig_list_netlink_cb(struct nl_msg *msg, void *arg)
uint32_t hardif;
uint8_t *neigh;
uint8_t *orig;
+ int ifindex;
uint8_t tq;
opts = container_of(query_opts, struct vis_netlink_opts,
@@ -567,12 +568,16 @@ static int parse_orig_list_netlink_cb(struct nl_msg *msg, void *arg)
if (memcmp(orig, neigh, ETH_ALEN) != 0)
return NL_OK;
+ ifindex = get_if_index_devindex(opts->globals, hardif);
+ if (ifindex < 0 || ifindex >= 255)
+ return NL_OK;
+
v_entry = malloc(sizeof(*v_entry));
if (!v_entry)
return NL_OK;
memcpy(v_entry->v.mac, orig, ETH_ALEN);
- v_entry->v.ifindex = get_if_index_devindex(opts->globals, hardif);
+ v_entry->v.ifindex = ifindex;
v_entry->v.qual = tq;
list_add_tail(&v_entry->list, &opts->globals->entry_list);
--
2.47.3