From 984bbe393c725cb68358c0f9c50ad7ad96d877ab Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Tue, 15 Oct 2024 21:27:37 +0200 Subject: [PATCH] batctl: Dynamically select header format in netlink_print_neighbors The netlink_print_neighbors() function previously used a static header format, which did not account for variations between the neighbor list output from different BATMAN routing algorithms (BATMAN_IV vs. BATMAN_V). This change ensures that the table header output in `batctl n` is accurate for both BATMAN routing algorithms. Signed-off-by: Sven Eckelmann --- batctl/Makefile | 2 +- ...ly-select-header-format-in-netlink_p.patch | 55 +++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 batctl/patches/0007-batctl-Dynamically-select-header-format-in-netlink_p.patch diff --git a/batctl/Makefile b/batctl/Makefile index 4cb336b..88bfd39 100644 --- a/batctl/Makefile +++ b/batctl/Makefile @@ -4,7 +4,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=batctl PKG_VERSION:=2023.1 -PKG_RELEASE:=2 +PKG_RELEASE:=3 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://downloads.open-mesh.org/batman/releases/batman-adv-$(PKG_VERSION) diff --git a/batctl/patches/0007-batctl-Dynamically-select-header-format-in-netlink_p.patch b/batctl/patches/0007-batctl-Dynamically-select-header-format-in-netlink_p.patch new file mode 100644 index 0000000..a0814cd --- /dev/null +++ b/batctl/patches/0007-batctl-Dynamically-select-header-format-in-netlink_p.patch @@ -0,0 +1,55 @@ +From: Noah Peterson +Date: Tue, 10 Sep 2024 13:22:02 -0600 +Subject: batctl: Dynamically select header format in netlink_print_neighbors + +The netlink_print_neighbors() function previously used a static header +format, which did not account for variations between the neighbor list +output from different BATMAN routing algorithms (BATMAN_IV vs. BATMAN_V). + +This change ensures that the table header output in `batctl n` is accurate +for both BATMAN routing algorithms. + +Signed-off-by: Noah Peterson +Signed-off-by: Sven Eckelmann +Origin: upstream, https://git.open-mesh.org/batctl.git/commit/649456d9d00cf701eb35cee1c8c5442752c70613 + +--- a/neighbors.c ++++ b/neighbors.c +@@ -6,6 +6,7 @@ + * License-Filename: LICENSES/preferred/GPL-2.0 + */ + ++#include + #include + #include + #include +@@ -119,9 +120,28 @@ static int netlink_print_neighbors(struc + int read_opts, float orig_timeout, + float watch_interval) + { ++ char *header = NULL; ++ char *info_header; ++ ++ /* only parse routing algorithm name */ ++ last_err = -EINVAL; ++ info_header = netlink_get_info(state, BATADV_CMD_GET_ORIGINATORS, NULL); ++ free(info_header); ++ ++ if (strlen(algo_name_buf) == 0) ++ return last_err; ++ ++ if (!strcmp("BATMAN_IV", algo_name_buf)) ++ header = "IF Neighbor last-seen\n"; ++ if (!strcmp("BATMAN_V", algo_name_buf)) ++ header = " Neighbor last-seen speed IF\n"; ++ ++ if (!header) ++ return -EINVAL; ++ + return netlink_print_common(state, orig_iface, read_opts, + orig_timeout, watch_interval, +- "IF Neighbor last-seen\n", ++ header, + BATADV_CMD_GET_NEIGHBORS, + neighbors_callback); + } -- 2.30.2