b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] Odd use of %14pM in net/batman-adv/distributed-arp-table.c
@ 2017-06-13 21:51 Joe Perches
  2017-06-14  8:23 ` Sven Eckelmann
  0 siblings, 1 reply; 6+ messages in thread
From: Joe Perches @ 2017-06-13 21:51 UTC (permalink / raw)
  To: Marek Lindner, Simon Wunderlich, Antonio Quartulli
  Cc: David S. Miller, b.a.t.m.a.n, netdev, linux-kernel

An output mac address is 17 bytes

         1
12345678901234567
00:11:22:33:44:55

but in net/batman-adv/distributed-arp-table.c

int batadv_dat_cache_seq_print_text(struct seq_file *seq, void *offset)
{
[...]
			seq_printf(seq, " * %15pI4 %14pM %4i %6i:%02i\n",
				   &dat_entry->ip, dat_entry->mac_addr,
				   batadv_print_vid(dat_entry->vid),
				   last_seen_mins, last_seen_secs);

%14pM is odd as this should not emit the last byte of the
mac address.  So given the example above, it would output
00:11:22:33:44

Is that what's really desired?

If so, I'd suggest using something more obvious like %5phC


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [B.A.T.M.A.N.] Odd use of %14pM in net/batman-adv/distributed-arp-table.c
  2017-06-13 21:51 [B.A.T.M.A.N.] Odd use of %14pM in net/batman-adv/distributed-arp-table.c Joe Perches
@ 2017-06-14  8:23 ` Sven Eckelmann
  2017-06-14  9:32   ` Joe Perches
  2017-06-14  9:33   ` [B.A.T.M.A.N.] [PATCH] batman-adv: Remove unnecessary length qualifier in %14pM Joe Perches
  0 siblings, 2 replies; 6+ messages in thread
From: Sven Eckelmann @ 2017-06-14  8:23 UTC (permalink / raw)
  To: b.a.t.m.a.n
  Cc: Joe Perches, Marek Lindner, Simon Wunderlich, Antonio Quartulli,
	netdev, David S. Miller, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1282 bytes --]

On Dienstag, 13. Juni 2017 14:51:41 CEST Joe Perches wrote:
> An output mac address is 17 bytes
[...]
> but in net/batman-adv/distributed-arp-table.c
[...]
> %14pM is odd as this should not emit the last byte of the
> mac address.  So given the example above, it would output
> 00:11:22:33:44
[...]

I completely agree too the "wrong length" part. It is currently not omitting 
the last byte:

    Distributed ARP Table (bat0):
              IPv4             MAC        VID   last-seen
     *   10.204.28.206 e8:50:8b:8b:71:8d   -1      4:05
     *    10.204.77.54 6c:2f:2c:43:70:eb   -1      1:56
     *    10.25.21.138 ec:1f:72:c3:15:51   -1      4:21
     *   10.204.27.220 08:70:45:8c:ac:db   -1      2:32
     *   192.168.42.22 64:66:b3:bb:8e:ef   -1      0:18
     *     10.204.64.1 02:ba:7a:df:04:00   -1      0:00
     *   192.168.42.27 e8:de:27:f9:0f:48   -1      0:32

But it definitely also not "correct". I see something similar in the IV OGM
code:

    net/batman-adv/bat_iv_ogm.c:               "bidirectional: orig = %-15pM neigh = %-15pM => own_bcast = %2i, real recv = %2i, local tq: %3i, asym_penalty: %3i, iface_penalty: %3i, total tq: %3i, if_incoming = %s, if_outgoing = %s\n",

Do you want to provide a patch to convert it to simple %pM's?

Kind regards,
	Sven

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [B.A.T.M.A.N.] Odd use of %14pM in net/batman-adv/distributed-arp-table.c
  2017-06-14  8:23 ` Sven Eckelmann
@ 2017-06-14  9:32   ` Joe Perches
  2017-06-14  9:33   ` [B.A.T.M.A.N.] [PATCH] batman-adv: Remove unnecessary length qualifier in %14pM Joe Perches
  1 sibling, 0 replies; 6+ messages in thread
From: Joe Perches @ 2017-06-14  9:32 UTC (permalink / raw)
  To: Sven Eckelmann, b.a.t.m.a.n
  Cc: Marek Lindner, Simon Wunderlich, Antonio Quartulli, netdev,
	David S. Miller, linux-kernel

On Wed, 2017-06-14 at 10:23 +0200, Sven Eckelmann wrote:
> On Dienstag, 13. Juni 2017 14:51:41 CEST Joe Perches wrote:
> > An output mac address is 17 bytes
> 
> [...]
> > but in net/batman-adv/distributed-arp-table.c
> 
> [...]
> > %14pM is odd as this should not emit the last byte of the
> > mac address.  So given the example above, it would output
> > 00:11:22:33:44
> 
> [...]
> 
> I completely agree too the "wrong length" part. It is currently not omitting 
> the last byte:

Right, I only looked at vsprintf.c and mistook precision for
field_width.

Do you want to provide a patch to convert it to simple %pM's?

OK.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [B.A.T.M.A.N.] [PATCH] batman-adv: Remove unnecessary length qualifier in %14pM
  2017-06-14  8:23 ` Sven Eckelmann
  2017-06-14  9:32   ` Joe Perches
@ 2017-06-14  9:33   ` Joe Perches
  2017-06-14 19:20     ` David Miller
  2017-06-14 19:41     ` Sven Eckelmann
  1 sibling, 2 replies; 6+ messages in thread
From: Joe Perches @ 2017-06-14  9:33 UTC (permalink / raw)
  To: Marek Lindner, Simon Wunderlich, Antonio Quartulli
  Cc: Sven Eckelmann, David S. Miller, b.a.t.m.a.n, netdev, linux-kernel

It's misleading and unnecessary.

Signed-off-by: Joe Perches <joe@perches.com>
---
 net/batman-adv/distributed-arp-table.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c
index 6930d6b50f99..b6cfa78e9381 100644
--- a/net/batman-adv/distributed-arp-table.c
+++ b/net/batman-adv/distributed-arp-table.c
@@ -834,7 +834,7 @@ int batadv_dat_cache_seq_print_text(struct seq_file *seq, void *offset)
 			last_seen_msecs = last_seen_msecs % 60000;
 			last_seen_secs = last_seen_msecs / 1000;
 
-			seq_printf(seq, " * %15pI4 %14pM %4i %6i:%02i\n",
+			seq_printf(seq, " * %15pI4 %pM %4i %6i:%02i\n",
 				   &dat_entry->ip, dat_entry->mac_addr,
 				   batadv_print_vid(dat_entry->vid),
 				   last_seen_mins, last_seen_secs);
-- 
2.10.0.rc2.1.g053435c


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [B.A.T.M.A.N.] [PATCH] batman-adv: Remove unnecessary length qualifier in %14pM
  2017-06-14  9:33   ` [B.A.T.M.A.N.] [PATCH] batman-adv: Remove unnecessary length qualifier in %14pM Joe Perches
@ 2017-06-14 19:20     ` David Miller
  2017-06-14 19:41     ` Sven Eckelmann
  1 sibling, 0 replies; 6+ messages in thread
From: David Miller @ 2017-06-14 19:20 UTC (permalink / raw)
  To: joe; +Cc: mareklindner, sw, a, sven, b.a.t.m.a.n, netdev, linux-kernel

From: Joe Perches <joe@perches.com>
Date: Wed, 14 Jun 2017 02:33:52 -0700

> It's misleading and unnecessary.
> 
> Signed-off-by: Joe Perches <joe@perches.com>

Simon will you take this into your batman-adv tree?

Thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [B.A.T.M.A.N.] [PATCH] batman-adv: Remove unnecessary length qualifier in %14pM
  2017-06-14  9:33   ` [B.A.T.M.A.N.] [PATCH] batman-adv: Remove unnecessary length qualifier in %14pM Joe Perches
  2017-06-14 19:20     ` David Miller
@ 2017-06-14 19:41     ` Sven Eckelmann
  1 sibling, 0 replies; 6+ messages in thread
From: Sven Eckelmann @ 2017-06-14 19:41 UTC (permalink / raw)
  To: Joe Perches
  Cc: Marek Lindner, Simon Wunderlich, Antonio Quartulli,
	David S. Miller, b.a.t.m.a.n, netdev, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 378 bytes --]

On Mittwoch, 14. Juni 2017 02:33:52 CEST Joe Perches wrote:
> It's misleading and unnecessary.
> 
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
>  net/batman-adv/distributed-arp-table.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

The patch was applied and is currently queued up as 
454ea1866ef45c6f1b747bd27a8203318be72b5d in batadv/net-next.

Thanks,
	Sven

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-06-14 19:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-13 21:51 [B.A.T.M.A.N.] Odd use of %14pM in net/batman-adv/distributed-arp-table.c Joe Perches
2017-06-14  8:23 ` Sven Eckelmann
2017-06-14  9:32   ` Joe Perches
2017-06-14  9:33   ` [B.A.T.M.A.N.] [PATCH] batman-adv: Remove unnecessary length qualifier in %14pM Joe Perches
2017-06-14 19:20     ` David Miller
2017-06-14 19:41     ` Sven Eckelmann

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).