* [PATCH] batctl: neighbor: Fix print neighbors table header
@ 2024-09-08 17:44 noahbpeterson1997
2024-09-08 18:12 ` Sven Eckelmann
0 siblings, 1 reply; 4+ messages in thread
From: noahbpeterson1997 @ 2024-09-08 17:44 UTC (permalink / raw)
To: b.a.t.m.a.n
netlink_print_neighbors() now prints the correct header to match what
batman-advanced currently outputs.
The examples in the README.rst are updated too.
Signed-off-by: Noah Peterson <noahbpeterson1997@gmail.com>
---
README.rst | 6 +++---
neighbors.c | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/README.rst b/README.rst
index 3495fba..5eda1d3 100644
--- a/README.rst
+++ b/README.rst
@@ -376,9 +376,9 @@ Usage::
Example::
- IF Neighbor last-seen
- enp0s1 16:7b:3c:c2:bf:b8 4.612s
- enp0s1 ae:1b:bf:52:25:58 0.740s
+ Neighbor last-seen speed IF
+ 16:7b:3c:c2:bf:b8 4.612s ( 1000.0) [ enp0s1]
+ ae:1b:bf:52:25:58 0.740s ( 1000.0) [ enp0s1]
batctl originators
diff --git a/neighbors.c b/neighbors.c
index 3102b0e..9dcdb81 100644
--- a/neighbors.c
+++ b/neighbors.c
@@ -121,7 +121,7 @@ static int netlink_print_neighbors(struct state *state, char *orig_iface,
{
return netlink_print_common(state, orig_iface, read_opts,
orig_timeout, watch_interval,
- "IF Neighbor last-seen\n",
+ " Neighbor last-seen speed IF\n",
BATADV_CMD_GET_NEIGHBORS,
neighbors_callback);
}
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] batctl: neighbor: Fix print neighbors table header
2024-09-08 17:44 [PATCH] batctl: neighbor: Fix print neighbors table header noahbpeterson1997
@ 2024-09-08 18:12 ` Sven Eckelmann
2024-09-08 19:47 ` noahbpeterson1997
0 siblings, 1 reply; 4+ messages in thread
From: Sven Eckelmann @ 2024-09-08 18:12 UTC (permalink / raw)
To: noahbpeterson1997; +Cc: b.a.t.m.a.n
[-- Attachment #1: Type: text/plain, Size: 1626 bytes --]
On Sunday, 8 September 2024 19:44:28 CEST noahbpeterson1997@gmail.com wrote:
> netlink_print_neighbors() now prints the correct header to match what
> batman-advanced currently outputs.
This is wrong, this is not what it outputs for the default B.A.T.M.A.N. IV:
$ batctl n
[B.A.T.M.A.N. adv 2024.0-openwrt-2, MainIF/MAC: primary0/ae:1b:bf:52:25:5b (bat0/52:54:00:ec:00:01 BATMAN_IV)]
IF Neighbor last-seen
vxlan 16:7b:3c:c2:bf:bc 2.880s
mesh-vpn 02:12:7b:00:04:01 0.830s
[...]
> Example::
>
> - IF Neighbor last-seen
> - enp0s1 16:7b:3c:c2:bf:b8 4.612s
> - enp0s1 ae:1b:bf:52:25:58 0.740s
> + Neighbor last-seen speed IF
> + 16:7b:3c:c2:bf:b8 4.612s ( 1000.0) [ enp0s1]
> + ae:1b:bf:52:25:58 0.740s ( 1000.0) [ enp0s1]
>
>
> batctl originators
> diff --git a/neighbors.c b/neighbors.c
> index 3102b0e..9dcdb81 100644
> --- a/neighbors.c
> +++ b/neighbors.c
> @@ -121,7 +121,7 @@ static int netlink_print_neighbors(struct state *state, char *orig_iface,
> {
> return netlink_print_common(state, orig_iface, read_opts,
> orig_timeout, watch_interval,
> - "IF Neighbor last-seen\n",
> + " Neighbor last-seen speed IF\n",
> BATADV_CMD_GET_NEIGHBORS,
> neighbors_callback);
> }
>
Kind regards,
Sven
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] batctl: neighbor: Fix print neighbors table header
2024-09-08 18:12 ` Sven Eckelmann
@ 2024-09-08 19:47 ` noahbpeterson1997
2024-09-09 9:29 ` Sven Eckelmann
0 siblings, 1 reply; 4+ messages in thread
From: noahbpeterson1997 @ 2024-09-08 19:47 UTC (permalink / raw)
To: b.a.t.m.a.n
> This is wrong, this is not what it outputs for the default B.A.T.M.A.N. IV:
Oops. I believe I now have this issue corrected. I copied the routing algorithm checking code from the netlink_print_gateways() function in gateways.c and change the header accordingly. Let me know if I should revert the change in README.rst.
---
README.rst | 6 +++---
neighbors.c | 22 +++++++++++++++++++++-
2 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/README.rst b/README.rst
index 3495fba..5eda1d3 100644
--- a/README.rst
+++ b/README.rst
@@ -376,9 +376,9 @@ Usage::
Example::
- IF Neighbor last-seen
- enp0s1 16:7b:3c:c2:bf:b8 4.612s
- enp0s1 ae:1b:bf:52:25:58 0.740s
+ Neighbor last-seen speed IF
+ 16:7b:3c:c2:bf:b8 4.612s ( 1000.0) [ enp0s1]
+ ae:1b:bf:52:25:58 0.740s ( 1000.0) [ enp0s1]
batctl originators
diff --git a/neighbors.c b/neighbors.c
index 3102b0e..f34952b 100644
--- a/neighbors.c
+++ b/neighbors.c
@@ -6,6 +6,7 @@
* License-Filename: LICENSES/preferred/GPL-2.0
*/
+#include <errno.h>
#include <net/if.h>
#include <netinet/if_ether.h>
#include <netlink/netlink.h>
@@ -119,9 +120,28 @@ static int netlink_print_neighbors(struct state *state, char *orig_iface,
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);
}
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] batctl: neighbor: Fix print neighbors table header
2024-09-08 19:47 ` noahbpeterson1997
@ 2024-09-09 9:29 ` Sven Eckelmann
0 siblings, 0 replies; 4+ messages in thread
From: Sven Eckelmann @ 2024-09-09 9:29 UTC (permalink / raw)
To: noahbpeterson1997; +Cc: b.a.t.m.a.n
[-- Attachment #1: Type: text/plain, Size: 1367 bytes --]
On Sunday, 8 September 2024 21:47:27 CEST noahbpeterson1997@gmail.com wrote:
> > This is wrong, this is not what it outputs for the default B.A.T.M.A.N. IV:
>
> Oops. I believe I now have this issue corrected. I copied the routing algorithm checking code from the netlink_print_gateways() function in gateways.c and change the header accordingly. Let me know if I should revert the change in README.rst.
Doesn't apply:
patching file README.rst
patching file neighbors.c
Hunk #2 FAILED at 120.
1 out of 2 hunks FAILED -- saving rejects to file neighbors.c.rej
And you need to resubmit it as proper patch in a separate thread with
"[PATCH v2]" (instead of "[PATCH]") at the start of the Subject.
> Let me know if I should revert the change in README.rst.
Yes, please revert it. And I don't want to read stuff like "The examples in
the README.rst are updated too." - which is a rather obvious information.
And regarding "netlink_print_neighbors() now prints the correct header to
match what batman-advanced currently outputs." The first part is trivial (but
incorrect) and the last part doesn't make any sense. Please describe instead
what the problem was and what the idea behind the fix is. And potential other
information which might be helpful to understand the context for future
persons stumbling over your change.
Kind regards,
Sven
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-09-09 9:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-08 17:44 [PATCH] batctl: neighbor: Fix print neighbors table header noahbpeterson1997
2024-09-08 18:12 ` Sven Eckelmann
2024-09-08 19:47 ` noahbpeterson1997
2024-09-09 9:29 ` Sven Eckelmann
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.