b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
From: Sven Eckelmann <sven@narfation.org>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: Sven Eckelmann <sven@narfation.org>
Subject: [PATCH 8/8] alfred: vis: skip originators with unresolvable hard interface
Date: Tue, 28 Jul 2026 18:01:37 +0200	[thread overview]
Message-ID: <20260728-bugfixes-vis-v1-8-2540447c8a67@narfation.org> (raw)
In-Reply-To: <20260728-bugfixes-vis-v1-0-2540447c8a67@narfation.org>

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 <sven@narfation.org>
---
 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


      parent reply	other threads:[~2026-07-28 18:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-28 16:01 [PATCH 0/8] alfred: vis: random fixes Sven Eckelmann
2026-07-28 16:01 ` [PATCH 1/8] alfred: vis: reject too long unix socket paths Sven Eckelmann
2026-07-28 16:01 ` [PATCH 2/8] alfred: vis: keep interface names always in heap Sven Eckelmann
2026-07-28 16:01 ` [PATCH 3/8] alfred: vis: return query_rtnl_link error on failed send Sven Eckelmann
2026-07-28 16:01 ` [PATCH 4/8] alfred: vis: handle short reads on the unix socket Sven Eckelmann
2026-07-28 16:01 ` [PATCH 5/8] alfred: vis: report failures while reading the answer Sven Eckelmann
2026-07-28 16:01 ` [PATCH 6/8] alfred: vis: don't drop the rest of the answer for a bogus dataset Sven Eckelmann
2026-07-28 16:01 ` [PATCH 7/8] alfred: vis: fix jsondoc output for nodes without vis entries Sven Eckelmann
2026-07-28 16:01 ` Sven Eckelmann [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260728-bugfixes-vis-v1-8-2540447c8a67@narfation.org \
    --to=sven@narfation.org \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).